diff options
Diffstat (limited to 'crawl-ref/source/beam.cc')
-rw-r--r-- | crawl-ref/source/beam.cc | 122 |
1 files changed, 77 insertions, 45 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 27600e0a31..973962a6af 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -45,8 +45,9 @@ #include "message.h" #include "misc.h" #include "mon-behv.h" -#include "monplace.h" -#include "monstuff.h" +#include "mon-iter.h" +#include "mon-place.h" +#include "mon-stuff.h" #include "mon-util.h" #include "mutation.h" #include "ouch.h" @@ -1180,14 +1181,14 @@ const zap_info zap_data[] = { }, { - ZAP_BACKLIGHT, + ZAP_CORONA, "0", 100, NULL, NULL, BLUE, true, - BEAM_BACKLIGHT, + BEAM_CORONA, DCHAR_SPACE, false, false, @@ -1196,14 +1197,14 @@ const zap_info zap_data[] = { }, { - ZAP_SLEEP, + ZAP_HIBERNATION, "0", 100, NULL, NULL, BLACK, true, - BEAM_SLEEP, + BEAM_HIBERNATION, DCHAR_SPACE, false, false, @@ -1321,6 +1322,22 @@ const zap_info zap_data[] = { false, false, 0 + }, + + { + ZAP_SLEEP, + "0", + 100, + NULL, + NULL, + BLACK, + true, + BEAM_SLEEP, + DCHAR_SPACE, + false, + false, + false, + 0 } }; @@ -2615,26 +2632,18 @@ bool mass_enchantment( enchant_type wh_enchant, int pow, int origin, const kill_category kc = (origin == MHITYOU ? KC_YOU : KC_OTHER); - for (int i = 0; i < MAX_MONSTERS; ++i) + for (monster_iterator mi(&you.get_los()); mi; ++mi) { - monsters* const monster = &menv[i]; - - if (!monster->alive()) - continue; - - if (!mons_near(monster)) - continue; - - if (monster->has_ench(wh_enchant)) + if (mi->has_ench(wh_enchant)) continue; if (m_attempted) ++*m_attempted; - if (_monster_resists_mass_enchantment(monster, wh_enchant, pow)) + if (_monster_resists_mass_enchantment(*mi, wh_enchant, pow)) continue; - if (monster->add_ench(mon_enchant(wh_enchant, 0, kc))) + if (mi->add_ench(mon_enchant(wh_enchant, 0, kc))) { if (m_succumbed) ++*m_succumbed; @@ -2649,11 +2658,11 @@ bool mass_enchantment( enchant_type wh_enchant, int pow, int origin, default: msg = NULL; break; } if (msg) - msg_generated = simple_monster_message(monster, msg); + msg_generated = simple_monster_message(*mi, msg); // Extra check for fear (monster needs to reevaluate behaviour). if (wh_enchant == ENCH_FEAR) - behaviour_event(monster, ME_SCARE, origin); + behaviour_event(*mi, ME_SCARE, origin); } } @@ -2889,7 +2898,7 @@ void fire_tracer(const monsters *monster, bolt &pbolt, bool explode_only) // When a mimic is hit by a ranged attack, it teleports away (the slow // way) and changes its appearance - the appearance change is in -// monster_teleport() in monstuff.cc. +// monster_teleport() in mon-stuff.cc. void mimic_alert(monsters *mimic) { if (!mimic->alive()) @@ -3124,6 +3133,7 @@ void bolt::affect_ground() int rc = create_monster(mgen_data(MONS_BALLISTOMYCETE, beh, + agent(), 0, 0, pos(), @@ -3355,8 +3365,8 @@ void bolt::affect_place_explosion_clouds() (whose_kill() == KC_OTHER ? BEH_HOSTILE : BEH_FRIENDLY); mons_place( - mgen_data(MONS_FIRE_VORTEX, att, 2, SPELL_FIRE_STORM, p, - MHITNOT, 0, god)); + mgen_data(MONS_FIRE_VORTEX, att, agent(), 2, SPELL_FIRE_STORM, + p, MHITNOT, 0, god)); } } } @@ -3667,9 +3677,8 @@ void bolt::tracer_affect_player() for (unsigned int i = 0; i < messages.size(); ++i) mpr(messages[i].c_str(), MSGCH_WARN); - range_used += range_used_on_hit(&you); - apply_hit_funcs(&you, 0); + range_used += range_used_on_hit(&you); } bool bolt::misses_player() @@ -3823,11 +3832,15 @@ void bolt::affect_player_enchantment() switch (flavour) { + case BEAM_HIBERNATION: + you.hibernate(ench_power); + break; + case BEAM_SLEEP: you.put_to_sleep(ench_power); break; - case BEAM_BACKLIGHT: + case BEAM_CORONA: you.backlight(); obvious_effect = true; break; @@ -4053,11 +4066,11 @@ void bolt::affect_player_enchantment() } } + apply_hit_funcs(&you, 0); + // Regardless of effect, we need to know if this is a stopper // or not - it seems all of the above are. range_used += range_used_on_hit(&you); - - apply_hit_funcs(&you, 0); } @@ -4324,8 +4337,8 @@ void bolt::tracer_enchantment_affect_monster(monsters* mon) handle_stop_attack_prompt(mon); if (!beam_cancelled) { - range_used += range_used_on_hit(mon); apply_hit_funcs(mon, 0); + range_used += range_used_on_hit(mon); } } @@ -4484,9 +4497,10 @@ void bolt::tracer_nonenchantment_affect_monster(monsters* mon) mpr(messages[i].c_str(), MSGCH_MONSTER_DAMAGE); } + apply_hit_funcs(mon, final); + // Either way, we could hit this monster, so update range used. range_used += range_used_on_hit(mon); - apply_hit_funcs(mon, final); } void bolt::tracer_affect_monster(monsters* mon) @@ -4585,8 +4599,8 @@ void bolt::enchantment_affect_monster(monsters* mon) beogh_follower_convert(mon, true); } - range_used += range_used_on_hit(mon); apply_hit_funcs(mon, 0); + range_used += range_used_on_hit(mon); } void bolt::monster_post_hit(monsters* mon, int dmg) @@ -4980,9 +4994,8 @@ void bolt::affect_monster(monsters* mon) mon = &orig; } - range_used += range_used_on_hit(mon); - apply_hit_funcs(mon, final, corpse); + range_used += range_used_on_hit(mon); } bool bolt::has_saving_throw() const @@ -5040,8 +5053,8 @@ bool _ench_flavour_affects_monster(beam_type flavour, const monsters* mon) rc = !mon->res_negative_energy(); break; - case BEAM_SLEEP: - rc = mon->can_sleep(); + case BEAM_HIBERNATION: + rc = mon->can_hibernate(); break; case BEAM_PORKALATOR: @@ -5186,7 +5199,7 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon) } // The monster can be no more than lightly wounded/damaged, - // using the formula from monstuff.cc:mons_get_damage_level(). + // using the formula from mon-stuff.cc:mons_get_damage_level(). if (mon->hit_points <= mon->max_hit_points * 3 / 4) { simple_monster_message(mon, "'s soul is too badly injured."); @@ -5245,17 +5258,17 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon) mon->hurt(agent(), damage.roll(), flavour); return (MON_AFFECTED); - case BEAM_SLEEP: - if (mon->can_sleep()) + case BEAM_HIBERNATION: + if (mon->can_hibernate()) { if (simple_monster_message(mon, " looks drowsy...")) obvious_effect = true; - mon->put_to_sleep(); + mon->hibernate(); return (MON_AFFECTED); } return (MON_UNAFFECTED); - case BEAM_BACKLIGHT: + case BEAM_CORONA: if (backlight_monsters(mon->pos(), hit, 0)) { obvious_effect = true; @@ -5350,6 +5363,17 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon) } return (MON_AFFECTED); + case BEAM_SLEEP: + if (mon->has_ench(ENCH_SLEEPY)) + return (MON_UNAFFECTED); + + if (mon->add_ench(mon_enchant(ENCH_SLEEPY, 0, whose_kill()))) + { + if (simple_monster_message(mon, " falls asleep!")) + obvious_effect = true; + } + return (MON_AFFECTED); + case BEAM_INVISIBILITY: { // Store the monster name before it becomes an "it" -- bwr @@ -5358,7 +5382,7 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon) if (!mon->has_ench(ENCH_INVIS) && mon->add_ench(ENCH_INVIS)) { // A casting of invisibility erases backlight. - mon->del_ench(ENCH_BACKLIGHT); + mon->del_ench(ENCH_CORONA); // Can't use simple_monster_message() here, since it checks // for visibility of the monster (and it's now invisible). @@ -5404,13 +5428,20 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon) if (mons_is_ghost_demon(mon->type)) return (MON_UNAFFECTED); - monster_type orig_type = mon->type; + monsters orig_mon(*mon); if (monster_polymorph(mon, (mon->holiness() == MH_DEMONIC ? MONS_HELL_HOG : MONS_HOG))) { obvious_effect = true; + + // Don't restore items to monster if it reverts. + orig_mon.inv = mon->inv; + + // For monster reverting to original form. + mon->props[ORIG_MONSTER_KEY] = orig_mon; } - mon->number = ((int) orig_type + 1); + + return (MON_AFFECTED); } @@ -5913,7 +5944,7 @@ bool bolt::nasty_to(const monsters *mon) const // degeneration / sleep / enslave soul if (flavour == BEAM_DEGENERATE - || flavour == BEAM_SLEEP + || flavour == BEAM_HIBERNATION || flavour == BEAM_ENSLAVE_SOUL) { return (mon->holiness() == MH_NATURAL); @@ -6161,8 +6192,9 @@ std::string beam_type_name(beam_type type) case BEAM_ENSLAVE_DEMON: return ("enslave demon"); case BEAM_BLINK: return ("blink"); case BEAM_PETRIFY: return ("petrify"); - case BEAM_BACKLIGHT: return ("backlight"); + case BEAM_CORONA: return ("backlight"); case BEAM_PORKALATOR: return ("porkalator"); + case BEAM_HIBERNATION: return ("hibernation"); case BEAM_SLEEP: return ("sleep"); case BEAM_BERSERK: return ("berserk"); case BEAM_POTION_BLACK_SMOKE: return ("black smoke"); |