diff options
author | Jude Brown <bookofjude@users.sourceforge.net> | 2010-01-03 22:30:38 +1000 |
---|---|---|
committer | Jude Brown <bookofjude@users.sourceforge.net> | 2010-01-03 23:54:24 +1000 |
commit | 865ad15a82f21145b5623417549107317cb44b5b (patch) | |
tree | aaf4bc18e85aca4ce5650d0de34e58c477ddc644 | |
parent | 12e2dc2661d4ecb2344b75a2fd9d6f4a4dcdc1a2 (diff) | |
download | crawl-ref-865ad15a82f21145b5623417549107317cb44b5b.tar.gz crawl-ref-865ad15a82f21145b5623417549107317cb44b5b.zip |
Fix put_to_sleep, implement for monsters.
-rw-r--r-- | crawl-ref/source/actor.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/beam.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/godwrath.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/monster.cc | 9 | ||||
-rw-r--r-- | crawl-ref/source/monster.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/player.h | 2 |
7 files changed, 19 insertions, 9 deletions
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h index e3b3ae4af6..f429742e33 100644 --- a/crawl-ref/source/actor.h +++ b/crawl-ref/source/actor.h @@ -174,6 +174,7 @@ public: virtual void petrify(actor *attacker, int strength) = 0; virtual void slow_down(actor *attacker, int strength) = 0; virtual void confuse(actor *attacker, int strength) = 0; + virtual void put_to_sleep(actor *attacker, int strength) = 0; virtual void expose_to_element(beam_type element, int strength = 0) = 0; virtual void drain_stat(int stat, int amount, actor* attacker) { } virtual bool can_hibernate(bool holi_only = false) const; diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 2745db78d2..2ac31458bf 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -3961,7 +3961,7 @@ void bolt::affect_player_enchantment() break; case BEAM_SLEEP: - you.put_to_sleep(ench_power); + you.put_to_sleep(NULL, ench_power); break; case BEAM_CORONA: @@ -5529,11 +5529,10 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon) 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; - } + mon->put_to_sleep(agent(), 0); + if (simple_monster_message(mon, " falls asleep!")) + obvious_effect = true; + return (MON_AFFECTED); case BEAM_INVISIBILITY: diff --git a/crawl-ref/source/godwrath.cc b/crawl-ref/source/godwrath.cc index e3e87198ca..00a002e4c3 100644 --- a/crawl-ref/source/godwrath.cc +++ b/crawl-ref/source/godwrath.cc @@ -336,7 +336,7 @@ static bool _cheibriados_retribution() case 2: case 3: mpr("You lose track of time."); - you.put_to_sleep(50); + you.put_to_sleep(NULL, 50); break; case 4: diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index e79967096c..1171a3c2c3 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -5716,6 +5716,15 @@ void monsters::hibernate(int) add_ench(ENCH_SLEEP_WARY); } +void monsters::put_to_sleep(actor *attacker, int strength) +{ + if (has_ench(ENCH_SLEEPY)) + return; + + behaviour = BEH_SLEEP; + add_ench(ENCH_SLEEPY); +} + void monsters::check_awaken(int) { // XXX diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h index b93ed65571..bae6cb4711 100644 --- a/crawl-ref/source/monster.h +++ b/crawl-ref/source/monster.h @@ -394,6 +394,7 @@ public: bool wizard_tele = false); void hibernate(int power = 0); + void put_to_sleep(actor *attacker, int power = 0); void check_awaken(int disturbance); int stat_hp() const { return hit_points; } diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 564bf18de1..b4a2611d9e 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -7125,7 +7125,7 @@ void player::hibernate(int) set_duration(DUR_SLEEP, 3 + random2avg(5, 2)); } -void player::put_to_sleep(int power) +void player::put_to_sleep(actor*, int power) { ASSERT(!crawl_state.arena); diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index e9b59b2364..9a44db2e71 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -490,7 +490,7 @@ public: bool asleep() const; void hibernate(int power = 0); - void put_to_sleep(int power = 0); + void put_to_sleep(actor *, int power = 0); void awake(); void check_awaken(int disturbance); |