summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/beam.cc50
-rw-r--r--crawl-ref/source/fight.cc20
-rw-r--r--crawl-ref/source/fight.h3
-rw-r--r--crawl-ref/source/monstuff.cc10
4 files changed, 47 insertions, 36 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 71973ed73d..e0dcfc4656 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -2413,9 +2413,7 @@ static bool _monster_resists_mass_enchantment(monsters *monster,
bool mass_enchantment( enchant_type wh_enchant, int pow, int origin,
int *m_succumbed, int *m_attempted )
{
- int i; // loop variable {dlb}
bool msg_generated = false;
- monsters *monster;
if (m_succumbed)
*m_succumbed = 0;
@@ -2424,16 +2422,18 @@ bool mass_enchantment( enchant_type wh_enchant, int pow, int origin,
viewwindow(false, false);
- if (pow > 200)
- pow = 200;
+ pow = std::min(pow, 200);
const kill_category kc = (origin == MHITYOU ? KC_YOU : KC_OTHER);
- for (i = 0; i < MAX_MONSTERS; i++)
+ for (int i = 0; i < MAX_MONSTERS; i++)
{
- monster = &menv[i];
+ monsters* const monster = &menv[i];
- if (monster->type == -1 || !mons_near(monster))
+ if (!monster->alive())
+ continue;
+
+ if (!mons_near(monster))
continue;
if (monster->has_ench(wh_enchant))
@@ -2450,35 +2450,23 @@ bool mass_enchantment( enchant_type wh_enchant, int pow, int origin,
if (m_succumbed)
++*m_succumbed;
- if (player_monster_visible( monster ))
- {
- // turn message on
- msg_generated = true;
- switch (wh_enchant)
- {
- case ENCH_FEAR:
- simple_monster_message(monster,
- " looks frightened!");
- break;
- case ENCH_CONFUSION:
- simple_monster_message(monster,
- " looks rather confused.");
- break;
- case ENCH_CHARM:
- simple_monster_message(monster,
- " submits to your will.");
- break;
- default:
- // oops, I guess not!
- msg_generated = false;
- }
+ // Do messaging.
+ const char* msg;
+ switch (wh_enchant)
+ {
+ case ENCH_FEAR: msg = " looks frightened!"; break;
+ case ENCH_CONFUSION: msg = " looks rather confused."; break;
+ case ENCH_CHARM: msg = " submits to your will."; break;
+ default: msg = NULL; break;
}
+ if (msg)
+ msg_generated = simple_monster_message(monster, msg);
// Extra check for fear (monster needs to reevaluate behaviour).
if (wh_enchant == ENCH_FEAR)
- behaviour_event( monster, ME_SCARE, origin );
+ behaviour_event(monster, ME_SCARE, origin);
}
- } // end "for i"
+ }
if (!msg_generated)
canned_msg(MSG_NOTHING_HAPPENS);
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 29176020ae..e9dc16ee95 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -320,6 +320,7 @@ melee_attack::melee_attack(actor *attk, actor *defn,
did_hit(false), perceived_attack(false), obvious_effect(false),
needs_message(false), attacker_visible(false), defender_visible(false),
attacker_invisible(false), defender_invisible(false),
+ defender_starting_attitude(ATT_HOSTILE),
unarmed_ok(allow_unarmed),
attack_number(which_attack),
to_hit(0), base_damage(0), potential_damage(0), damage_done(0),
@@ -378,6 +379,17 @@ void melee_attack::init_attack()
&& see_grid(defender->pos()));
needs_message = (attacker_visible || defender_visible);
+ if (defender && defender->atype() == ACT_MONSTER)
+ {
+ defender_starting_attitude = defender_as_monster()->temp_attitude();
+ }
+ else
+ {
+ // Not really, but this is used for god conducts,
+ // so hostile is fine.
+ defender_starting_attitude = ATT_HOSTILE;
+ }
+
if (defender && defender->submerged())
unarmed_ok = false;
@@ -1949,6 +1961,14 @@ void melee_attack::_monster_die(monsters* monster, killer_type killer,
if (chaos)
def_copy = new monsters(*monster);
+ // The monster is about to die, so restore its original attitude
+ // for the cleanup effects (god reactions.) This could be a
+ // problem if the "killing" is actually an Abyss banishment - we
+ // don't want to create permafriendlies this way - so don't do it
+ // then.
+ if (monster == defender && killer != KILL_RESET)
+ monster->attitude = defender_starting_attitude;
+
monster_die(monster, killer, killer_index);
if (chaos)
diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h
index 9786a8ba7c..e4048e6f9f 100644
--- a/crawl-ref/source/fight.h
+++ b/crawl-ref/source/fight.h
@@ -80,6 +80,9 @@ public:
bool attacker_visible, defender_visible;
bool attacker_invisible, defender_invisible;
+ // What was the monster's attitude when the attack began?
+ mon_attitude_type defender_starting_attitude;
+
bool unarmed_ok;
int attack_number;
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index e15e4bf1eb..b987a9d0c2 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -1120,22 +1120,22 @@ int monster_die(monsters *monster, killer_type killer,
if (you.religion == GOD_TROG
&& !player_under_penance() && you.piety > random2(1000))
{
- int bonus = 3 + random2avg( 10, 2 );
+ const int bonus = 3 + random2avg( 10, 2 );
you.duration[DUR_BERSERKER] += bonus;
you.duration[DUR_MIGHT] += bonus;
- haste_player( bonus );
+ haste_player(bonus);
mpr("You feel the power of Trog in you as your rage grows.",
MSGCH_GOD, GOD_TROG);
}
- else if (wearing_amulet( AMU_RAGE ) && one_chance_in(30))
+ else if (wearing_amulet(AMU_RAGE) && one_chance_in(30))
{
- int bonus = 2 + random2(4);
+ const int bonus = 2 + random2(4);
you.duration[DUR_BERSERKER] += bonus;
you.duration[DUR_MIGHT] += bonus;
- haste_player( bonus );
+ haste_player(bonus);
mpr("Your amulet glows a violent red.");
}