summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/player-act.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-06-04 22:54:07 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-06-04 22:54:07 -0700
commit4e359b6150a2b2f3201f52ffc1ea586a5c2d0a2a (patch)
treecb56385872922f49cdd538efa5ce6c562ef111d6 /crawl-ref/source/player-act.cc
parent6f0af88fe662aaa218d7d1bb35a4fa2f54ed3e01 (diff)
downloadcrawl-ref-4e359b6150a2b2f3201f52ffc1ea586a5c2d0a2a.tar.gz
crawl-ref-4e359b6150a2b2f3201f52ffc1ea586a5c2d0a2a.zip
Move go_berserk() out of misc.cc
Diffstat (limited to 'crawl-ref/source/player-act.cc')
-rw-r--r--crawl-ref/source/player-act.cc113
1 files changed, 111 insertions, 2 deletions
diff --git a/crawl-ref/source/player-act.cc b/crawl-ref/source/player-act.cc
index 3a2f982714..de6a73310a 100644
--- a/crawl-ref/source/player-act.cc
+++ b/crawl-ref/source/player-act.cc
@@ -9,6 +9,7 @@
#include <math.h>
+#include "act-iter.h"
#include "areas.h"
#include "art-enum.h"
#include "artefact.h"
@@ -17,13 +18,17 @@
#include "env.h"
#include "fight.h"
#include "food.h"
+#include "godconduct.h"
#include "goditem.h"
#include "hints.h"
#include "itemprop.h"
#include "items.h"
+#include "item_use.h"
#include "libutil.h"
#include "misc.h"
#include "monster.h"
+#include "player-stats.h"
+#include "religion.h"
#include "spl-damage.h"
#include "state.h"
#include "stuff.h"
@@ -721,9 +726,113 @@ void player::attacking(actor *other, bool ranged)
go_berserk(false);
}
-void player::go_berserk(bool intentional, bool potion)
+/**
+ * Check to see if Chei slows down the berserking player.
+ * @param intentional If true, this was initiated by the player, and additional
+ * messages can be printed if we can't berserk.
+ * @return True if Chei will slow the player, false otherwise.
+ */
+static bool _chei_prevents_berserk_haste(bool intentional)
+{
+ if (!you_worship(GOD_CHEIBRIADOS))
+ return false;
+
+ // Chei makes berserk not speed you up.
+ // Unintentional would be forgiven "just this once" every time.
+ // Intentional could work as normal, but that would require storing
+ // whether you transgressed to start it -- so we just consider this
+ // a part of your penance.
+ if (!intentional)
+ {
+ simple_god_message(" protects you from inadvertent hurry.");
+ return true;
+ }
+
+ did_god_conduct(DID_HASTY, 8);
+ // Let's see if you've lost your religion...
+ if (!you_worship(GOD_CHEIBRIADOS))
+ return false;
+
+ simple_god_message(" forces you to slow down.");
+ return true;
+}
+
+/**
+ * Make the player go berserk!
+ * @param intentional If true, this was initiated by the player, and additional
+ * messages can be printed if we can't berserk.
+ * @param potion If true, this was caused by the player quaffing !berserk;
+ * and we get the same additional messages as when
+ * intentional is true.
+ * @return True if we went berserk, false otherwise.
+ */
+bool player::go_berserk(bool intentional, bool potion)
{
- ::go_berserk(intentional, potion);
+ ASSERT(!crawl_state.game_is_arena());
+
+ if (!you.can_go_berserk(intentional, potion))
+ return false;
+
+ if (stasis_blocks_effect(true,
+ "%s thrums violently and saps your rage.",
+ 3,
+ "%s vibrates violently and saps your rage."))
+ {
+ return false;
+ }
+
+ if (crawl_state.game_is_hints())
+ Hints.hints_berserk_counter++;
+
+ mpr("A red film seems to cover your vision as you go berserk!");
+
+ if (you.duration[DUR_FINESSE] > 0)
+ {
+ you.duration[DUR_FINESSE] = 0; // Totally incompatible.
+ mpr("Finesse? Hah! Time to rip out guts!");
+ }
+
+ if (!_chei_prevents_berserk_haste(intentional))
+ mpr("You feel yourself moving faster!");
+
+ mpr("You feel mighty!");
+
+ // Cutting the duration in half since berserk causes haste and hasted
+ // actions have half the usual delay. This keeps player turns
+ // approximately consistent withe previous versions. -cao
+ // Only 1.5 now, but I'm keeping the reduction as a nerf. -1KB
+ int berserk_duration = (20 + random2avg(19,2)) / 2;
+
+ you.increase_duration(DUR_BERSERK, berserk_duration);
+
+ calc_hp();
+ set_hp(you.hp * 3 / 2);
+
+ deflate_hp(you.hp_max, false);
+
+ if (!you.duration[DUR_MIGHT])
+ notify_stat_change(STAT_STR, 5, true, "going berserk");
+
+ if (you.berserk_penalty != NO_BERSERK_PENALTY)
+ you.berserk_penalty = 0;
+
+ you.redraw_quiver = true; // Account for no firing.
+
+#if TAG_MAJOR_VERSION == 34
+ if (you.species == SP_LAVA_ORC)
+ {
+ mpr("You burn with rage!");
+ // This will get sqrt'd later, so.
+ you.temperature = TEMP_MAX;
+ }
+#endif
+
+ if (player_equip_unrand(UNRAND_JIHAD))
+ for (monster_near_iterator mi(you.pos(), LOS_NO_TRANS); mi; ++mi)
+ if (mi->friendly())
+ mi->go_berserk(false);
+
+ return true;
}
bool player::can_go_berserk() const