From 31572bc04436d47f93998921996ff0e12e8ef360 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 1 Apr 2008 14:22:36 +0000 Subject: Fixed royal jelly passive damage in monster-vs-monster combat. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4022 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/debug.cc | 5 +++++ crawl-ref/source/externs.h | 6 +++--- crawl-ref/source/mon-util.cc | 14 ++++++++++---- crawl-ref/source/monstuff.cc | 6 +----- crawl-ref/source/player.cc | 3 ++- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 9294f8e504..10e838de3c 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -441,6 +441,11 @@ void create_spec_monster_name(int x, int y) y = place.y; } } + + // Wizmode users should be able to conjure up uniques even if they + // were already created. + if (mons_is_unique(mspec.mid) && you.unique_creatures[mspec.mid]) + you.unique_creatures[mspec.mid] = false; if (!dgn_place_monster(mspec, you.your_level, x, y, false)) { diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 0fdb94ad99..9c0733954f 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -147,7 +147,7 @@ public: virtual bool is_icy() const = 0; virtual void go_berserk(bool intentional) = 0; virtual void mutate() = 0; - virtual void hurt(const actor *attacker, int amount) = 0; + virtual int hurt(const actor *attacker, int amount) = 0; virtual void heal(int amount, bool max_too = false) = 0; virtual void banish(const std::string &who = "") = 0; virtual void blink() = 0; @@ -851,7 +851,7 @@ public: void confuse(int strength); void rot(actor *agent, int rotlevel, int immed_rot); void heal(int amount, bool max_too = false); - void hurt(const actor *agent, int amount); + int hurt(const actor *agent, int amount); int holy_aura() const; int warding() const; @@ -1194,7 +1194,7 @@ public: void slow_down(int str); void confuse(int strength); void rot(actor *agent, int rotlevel, int immed_rot); - void hurt(const actor *agent, int amount); + int hurt(const actor *agent, int amount); void heal(int amount, bool max_too = false); void blink(); void teleport(bool right_now = false, bool abyss_shift = false); diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 364feab6f5..bd92668cb9 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -3715,13 +3715,18 @@ god_type monsters::deity() const return (god); } -void monsters::hurt(const actor *agent, int amount) +int monsters::hurt(const actor *agent, int amount) { if (amount <= 0) - return; - + return (0); + + amount = std::min(amount, hit_points); hit_points -= amount; - if ((hit_points < 1 || hit_dice < 1) && type != -1) + + // Allow the victim to exhibit passive damage behaviour (royal jelly). + react_to_damage(amount); + + if (agent && (hit_points < 1 || hit_dice < 1) && type != -1) { if (agent->atype() == ACT_PLAYER) monster_die(this, KILL_YOU, 0); @@ -3729,6 +3734,7 @@ void monsters::hurt(const actor *agent, int amount) monster_die(this, KILL_MON, monster_index( dynamic_cast(agent) )); } + return (amount); } void monsters::rot(actor *agent, int rotlevel, int immed_rot) diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 107951b5b2..28b340f0fb 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -6486,12 +6486,8 @@ unsigned int monster_index(const monsters *monster) int hurt_monster(monsters * victim, int damage_dealt) { damage_dealt = std::max(std::min(damage_dealt, victim->hit_points), 0); - victim->hit_points -= damage_dealt; - // Allow the victim to exhibit passive damage behaviour (royal jelly). - victim->react_to_damage(damage_dealt); - - return (damage_dealt); + return (victim->hurt(NULL, damage_dealt)); } bool heal_monster(monsters * patient, int health_boost, diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index bdc7ba2615..ac233e5034 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6194,7 +6194,7 @@ void player::teleport(bool now, bool abyss_shift) you_teleport(); } -void player::hurt(const actor *agent, int amount) +int player::hurt(const actor *agent, int amount) { const monsters *mon = dynamic_cast(agent); if (agent->atype() == ACT_MONSTER) @@ -6208,6 +6208,7 @@ void player::hurt(const actor *agent, int amount) ASSERT(false); ouch(amount, 0, KILLED_BY_SOMETHING); } + return (amount); } void player::drain_stat(int stat, int amount, actor* attacker) -- cgit v1.2.3-54-g00ecf