From f45c701b8b8c2afa6b52dad3ba3764a908fe446a Mon Sep 17 00:00:00 2001 From: dolorous Date: Thu, 21 Feb 2008 14:54:54 +0000 Subject: Implement [1891388]: Make Holy Word available in scroll form. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3450 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/effects.cc | 83 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/effects.cc') diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 098d757386..01e163b8f7 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -60,6 +60,83 @@ #include "view.h" #include "xom.h" +bool holy_word(int pow, int caster, bool silent) +{ + bool holy_influenced = false; + struct monsters *monster; + + if (!silent) + mpr("You speak a Word of immense power!"); + + // doubt this will ever happen, but it's here as a safety -- bwr + if (pow > 300) + pow = 300; + + if (you.is_undead || you.species == SP_DEMONSPAWN) + { + int hploss = you.hp / 2 - 1; + if (hploss >= you.hp) + hploss = you.hp - 1; + if (hploss < 0) + hploss = 0; + + if (hploss) + { + holy_influenced = true; + + mpr("You are blasted by holy energy!"); + + const char *aux = "holy word"; + if (caster < 0) + { + switch (caster) + { + case HOLY_WORD_SCROLL: + aux = "scroll of holy word"; + break; + } + caster = HOLY_WORD_GENERIC; + } + ouch(hploss, caster, + caster != HOLY_WORD_GENERIC ? KILLED_BY_MONSTER + : KILLED_BY_SOMETHING, + aux); + } + } + + for (int tu = 0; tu < MAX_MONSTERS; tu++) + { + monster = &menv[tu]; + + if (monster->type == -1 || !mons_near(monster)) + continue; + + if (mons_holiness(monster) == MH_UNDEAD + || mons_holiness(monster) == MH_DEMONIC) + { + holy_influenced = true; + + simple_monster_message(monster, " convulses!"); + + behaviour_event( monster, ME_ANNOY, MHITYOU ); + hurt_monster( monster, roll_dice( 2, 15 ) + (random2(pow) / 3) ); + + if (monster->hit_points < 1) + { + monster_die(monster, KILL_YOU, 0); + continue; + } + + if (monster->speed_increment >= 25) + monster->speed_increment -= 20; + + monster->add_ench(ENCH_FEAR); + } // end "if mons_holiness" + } // end "for tu" + + return holy_influenced; +} // end holy_word() + // torment_monsters is called with power 0 because torment is // UNRESISTABLE except for being undead or having torment // resistance! Even if we used maximum power of 1000, high @@ -112,9 +189,9 @@ int torment_monsters(int x, int y, int pow, int caster) } caster = TORMENT_GENERIC; } - ouch(hploss, caster, - caster != TORMENT_GENERIC? KILLED_BY_MONSTER - : KILLED_BY_SOMETHING, + ouch(hploss, caster, + caster != TORMENT_GENERIC ? KILLED_BY_MONSTER + : KILLED_BY_SOMETHING, aux); } -- cgit v1.2.3-54-g00ecf