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/abl-show.cc | 2 +- crawl-ref/source/acr.cc | 2 +- crawl-ref/source/dat/descript/items.txt | 5 ++ crawl-ref/source/effects.cc | 83 +++++++++++++++++++++++++++++++-- crawl-ref/source/effects.h | 7 +++ crawl-ref/source/enum.h | 7 +++ crawl-ref/source/item_use.cc | 24 ++++++++++ crawl-ref/source/itemname.cc | 1 + crawl-ref/source/itemprop.h | 1 + crawl-ref/source/makeitem.cc | 62 ++++++++++++------------ crawl-ref/source/religion.cc | 2 +- crawl-ref/source/shopping.cc | 1 + crawl-ref/source/spells2.cc | 40 ---------------- crawl-ref/source/spells2.h | 7 --- crawl-ref/source/spells3.cc | 4 +- crawl-ref/source/spl-cast.cc | 2 +- 16 files changed, 165 insertions(+), 85 deletions(-) diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index e994554ca0..374c117c78 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -1351,7 +1351,7 @@ static bool do_ability(const ability_def& abil) break; case ABIL_ZIN_HOLY_WORD: - holy_word( you.skills[SK_INVOCATIONS] * 8 ); + holy_word( you.skills[SK_INVOCATIONS] * 8, HOLY_WORD_GENERIC ); exercise(SK_INVOCATIONS, 3 + random2(5)); break; diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index ff19ff29ed..057a65c3bb 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2721,7 +2721,7 @@ static void decrement_durations() if (you.duration[DUR_BACKLIGHT] > 0 && !--you.duration[DUR_BACKLIGHT] && !you.backlit()) mpr("You are no longer glowing.", MSGCH_DURATION); - // Leak piety from the piety pool (currently Zin only) into actual piety. + // Leak piety from the piety pool into actual piety. // Note that changes of religious status without corresponding actions // (killing monsters, offering items, ...) might be confusing for characters // of other religions. diff --git a/crawl-ref/source/dat/descript/items.txt b/crawl-ref/source/dat/descript/items.txt index 748da1c49b..a92c0695b0 100644 --- a/crawl-ref/source/dat/descript/items.txt +++ b/crawl-ref/source/dat/descript/items.txt @@ -1141,6 +1141,11 @@ scroll of fog This scroll surrounds the reader with a dense cloud of fog. %%%% +scroll of holy word + +This scroll calls on the powers of Heaven to cause great damage to any +nearby unholy creature - including you! +%%%% scroll of identify This useful magic scroll allows you to determine the properties of any 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); } diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h index 8078b5d50c..768637bb9c 100644 --- a/crawl-ref/source/effects.h +++ b/crawl-ref/source/effects.h @@ -96,6 +96,13 @@ void mons_direct_effect(struct bolt &pbolt, int i); void yell(bool force = false); +// last updated 24may2000 {dlb} +/* *********************************************************************** + * called from: item_use - spell + * *********************************************************************** */ +bool holy_word(int pow, int caster, bool silent = false); + + // last updated 12may2000 {dlb} /* *********************************************************************** * called from: ability - decks - fight - it_use3 - item_use - mstuff2 - diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index cc598900ab..109e01ee27 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -1222,6 +1222,13 @@ enum god_type GOD_RANDOM = 100 }; +enum holy_word_source_type +{ + HOLY_WORD_GENERIC = -1, + HOLY_WORD_SCROLL = -2, + HOLY_WORD_SPELL = -3 // SPELL_HOLY_WORD +}; + enum hunger_state // you.hunger_state { HS_RAVENOUS, // 0: not used within code, really diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 9566601153..422d50e887 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -4322,6 +4322,30 @@ void read_scroll( int slot ) } break; + case SCR_HOLY_WORD: + { + int pow = 100; + + if (is_good_god(you.religion)) + { + pow += (you.religion == GOD_SHINING_ONE) ? you.piety : + you.piety / 2; + } + + if (!holy_word(pow, HOLY_WORD_SCROLL, !item_type_known(scroll))) + { + canned_msg(MSG_NOTHING_HAPPENS); + id_the_scroll = false; + } + + // good gods like this, regardless of whether it damages anything + if (is_good_god(you.religion)) + { + you.duration[DUR_PIETY_POOL] += 10; + if (you.duration[DUR_PIETY_POOL] > 500) + you.duration[DUR_PIETY_POOL] = 500; + } + } } // end switch // finally, destroy and identify the scroll diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index a7bbc0fbe9..3ac3df5ee8 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -548,6 +548,7 @@ static const char* scroll_type_name(int scrolltype) case SCR_VORPALISE_WEAPON: return "vorpalise weapon"; case SCR_RECHARGING: return "recharging"; case SCR_ENCHANT_WEAPON_III: return "enchant weapon III"; + case SCR_HOLY_WORD: return "holy word"; default: return "bugginess"; } } diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h index 9744906312..34c0f747d9 100644 --- a/crawl-ref/source/itemprop.h +++ b/crawl-ref/source/itemprop.h @@ -320,6 +320,7 @@ enum scroll_type SCR_VORPALISE_WEAPON, // 20 SCR_RECHARGING, SCR_ENCHANT_WEAPON_III, + SCR_HOLY_WORD, NUM_SCROLLS }; diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index fb43795f29..9db84a802d 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -2332,48 +2332,51 @@ static void generate_scroll_item(item_def& item, int force_type, { // only used in certain cases {dlb} const int depth_mod = random2(1 + item_level); - const int temp_rand = random2(920); + const int temp_rand = random2(935); item.sub_type = - ((temp_rand > 751) ? SCR_IDENTIFY : // 18.26% - (temp_rand > 629) ? SCR_REMOVE_CURSE : // 13.26% - (temp_rand > 554) ? SCR_TELEPORTATION : // 8.15% - (temp_rand > 494) ? SCR_DETECT_CURSE : // 6.52% - (temp_rand > 464) ? SCR_FEAR : // 3.26% - (temp_rand > 434) ? SCR_NOISE : // 3.26% - (temp_rand > 404) ? SCR_MAGIC_MAPPING : // 3.26% - (temp_rand > 374) ? SCR_FOG : // 3.26% - (temp_rand > 344) ? SCR_RANDOM_USELESSNESS :// 3.26% - (temp_rand > 314) ? SCR_CURSE_WEAPON : // 3.26% - (temp_rand > 284) ? SCR_CURSE_ARMOUR : // 3.26% - (temp_rand > 254) ? SCR_RECHARGING : // 3.26% - (temp_rand > 224) ? SCR_BLINKING : // 3.26% - (temp_rand > 194) ? SCR_PAPER : // 3.26% - (temp_rand > 164) ? SCR_ENCHANT_ARMOUR : // 3.26% - (temp_rand > 134) ? SCR_ENCHANT_WEAPON_I : // 3.26% - (temp_rand > 104) ? SCR_ENCHANT_WEAPON_II : // 3.26% + ((temp_rand > 766) ? SCR_IDENTIFY : // 17.97% + (temp_rand > 644) ? SCR_REMOVE_CURSE : // 13.05% + (temp_rand > 569) ? SCR_TELEPORTATION : // 8.02% + (temp_rand > 509) ? SCR_DETECT_CURSE : // 6.42% + (temp_rand > 479) ? SCR_FEAR : // 3.21% + (temp_rand > 449) ? SCR_NOISE : // 3.21% + (temp_rand > 419) ? SCR_MAGIC_MAPPING : // 3.21% + (temp_rand > 389) ? SCR_FOG : // 3.21% + (temp_rand > 359) ? SCR_RANDOM_USELESSNESS :// 3.21% + (temp_rand > 329) ? SCR_CURSE_WEAPON : // 3.21% + (temp_rand > 299) ? SCR_CURSE_ARMOUR : // 3.21% + (temp_rand > 269) ? SCR_RECHARGING : // 3.21% + (temp_rand > 239) ? SCR_BLINKING : // 3.21% + (temp_rand > 209) ? SCR_PAPER : // 3.21% + (temp_rand > 179) ? SCR_ENCHANT_ARMOUR : // 3.21% + (temp_rand > 149) ? SCR_ENCHANT_WEAPON_I : // 3.21% + (temp_rand > 119) ? SCR_ENCHANT_WEAPON_II : // 3.21% // Crawl is kind to newbie adventurers {dlb}: // yes -- these five are messy {dlb}: // yes they are a hellish mess of tri-ops and long lines, // this formating is somewhat better -- bwr - (temp_rand > 74) ? + (temp_rand > 89) ? ((item_level < 4) ? SCR_TELEPORTATION - : SCR_IMMOLATION) : // 3.26% - (temp_rand > 59) ? + : SCR_IMMOLATION) : // 3.21% + (temp_rand > 74) ? ((depth_mod < 4) ? SCR_TELEPORTATION - : SCR_ACQUIREMENT) : // 1.63% - (temp_rand > 44) ? + : SCR_ACQUIREMENT) : // 1.60% + (temp_rand > 59) ? ((depth_mod < 4) ? SCR_DETECT_CURSE - : SCR_SUMMONING) : // 1.63% - (temp_rand > 29) ? - ((depth_mod < 4) ? SCR_TELEPORTATION // 1.63% + : SCR_SUMMONING) : // 1.60% + (temp_rand > 44) ? + ((depth_mod < 4) ? SCR_TELEPORTATION // 1.60% : SCR_ENCHANT_WEAPON_III) : + (temp_rand > 29) ? + ((depth_mod < 7) ? SCR_DETECT_CURSE + : SCR_TORMENT) : // 1.60% (temp_rand > 14) ? ((depth_mod < 7) ? SCR_DETECT_CURSE - : SCR_TORMENT) // 1.63% + : SCR_HOLY_WORD) // 1.60% // default: - : ((depth_mod < 7) ? SCR_TELEPORTATION // 1.63% + : ((depth_mod < 7) ? SCR_TELEPORTATION // 1.60% : SCR_VORPALISE_WEAPON)); } @@ -2381,7 +2384,8 @@ static void generate_scroll_item(item_def& item, int force_type, if ( item.sub_type == SCR_VORPALISE_WEAPON || item.sub_type == SCR_ENCHANT_WEAPON_III || item.sub_type == SCR_ACQUIREMENT || - item.sub_type == SCR_TORMENT ) + item.sub_type == SCR_TORMENT || + item.sub_type == SCR_HOLY_WORD ) item.quantity = 1; else { diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index ffc4276199..4612919c80 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -3272,7 +3272,7 @@ static bool bless_weapon( int god, int brand, int colour ) if ( god == GOD_SHINING_ONE ) { - holy_word( 100, true ); + holy_word( 100, HOLY_WORD_GENERIC, true ); // un-bloodify surrounding squares for (int i=-3;i<=3;i++) for (int j=-3;j<=3;j++) diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index 2d1985664f..f12c308f98 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -1235,6 +1235,7 @@ unsigned int item_value( item_def item, bool ident ) valued += 95; break; case SCR_TORMENT: + case SCR_HOLY_WORD: valued += 75; break; case SCR_ENCHANT_WEAPON_II: diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 09c8ecf973..296fe73e13 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -798,46 +798,6 @@ void turn_undead(int pow) } // end "for tu" } // end turn_undead() -void holy_word(int pow, bool silent) -{ - 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; - - 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) - { - 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" -} // end holy_word() - typedef std::pair counted_monster; typedef std::vector counted_monster_list; static void record_monster_by_name(counted_monster_list &list, diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h index 1578ac622f..4ff0e96a49 100644 --- a/crawl-ref/source/spells2.h +++ b/crawl-ref/source/spells2.h @@ -119,13 +119,6 @@ void cast_twisted(int power, beh_type corps_beh, int corps_hit); void drain_life(int pow); -// last updated 24may2000 {dlb} -/* *********************************************************************** - * called from: ability - spell - * *********************************************************************** */ -void holy_word(int pow, bool silent = false); - - // last updated 24may2000 {dlb} /* *********************************************************************** * called from: ability - food - it_use2 - spell diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 0a62f4473d..681d5cb0eb 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -29,6 +29,7 @@ #include "direct.h" #include "debug.h" #include "delay.h" +#include "effects.h" // holy word #include "food.h" #include "itemname.h" #include "itemprop.h" @@ -46,7 +47,6 @@ #include "randart.h" #include "religion.h" #include "spells1.h" -#include "spells2.h" // holy word #include "spells4.h" #include "spl-cast.h" #include "spl-util.h" @@ -895,7 +895,7 @@ bool cast_sanctuary(const int power) you.flash_colour = WHITE; viewwindow( true, false ); - holy_word( 100, true ); + holy_word( 100, HOLY_WORD_GENERIC, true ); #ifndef USE_TILE delay(1000); #endif diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index dab3229a35..a90515e36e 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1245,7 +1245,7 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) break; case SPELL_HOLY_WORD: - holy_word(50); + holy_word(50, HOLY_WORD_SPELL); break; case SPELL_DETECT_CURSE: -- cgit v1.2.3-54-g00ecf