From b7594aaf2042402a9f4ad0c31a7bfe860db8899c Mon Sep 17 00:00:00 2001 From: dolorous Date: Sat, 7 Jun 2008 20:14:18 +0000 Subject: Clean up yet more. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5550 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/monplace.cc | 132 ++++++++++++++++++++++--------------------- crawl-ref/source/monplace.h | 5 +- crawl-ref/source/mstuff2.cc | 4 +- crawl-ref/source/spells2.cc | 83 ++++++++++++++++++++------- crawl-ref/source/spells2.h | 4 ++ crawl-ref/source/spl-cast.cc | 8 ++- 6 files changed, 146 insertions(+), 90 deletions(-) diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 7787b5c63c..f8043905af 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -2129,112 +2129,114 @@ bool empty_surrounds(int emx, int emy, dungeon_feature_type spc_wanted, return (good_count > 0); } -monster_type summon_any_demon(demon_class_type demon_class) +monster_type summon_any_demon(demon_class_type dct) { - monster_type summoned = MONS_PROGRAM_BUG; + monster_type mon = MONS_PROGRAM_BUG; + int temp_rand; // probability determination {dlb} - switch (demon_class) + switch (dct) { case DEMON_LESSER: temp_rand = random2(60); - summoned = ((temp_rand > 49) ? MONS_IMP : // 10 in 60 - (temp_rand > 40) ? MONS_WHITE_IMP : // 9 in 60 - (temp_rand > 31) ? MONS_LEMURE : // 9 in 60 - (temp_rand > 22) ? MONS_UFETUBUS : // 9 in 60 - (temp_rand > 13) ? MONS_MANES : // 9 in 60 - (temp_rand > 4) ? MONS_MIDGE // 9 in 60 - : MONS_SHADOW_IMP); // 5 in 60 + mon = ((temp_rand > 49) ? MONS_IMP : // 10 in 60 + (temp_rand > 40) ? MONS_WHITE_IMP : // 9 in 60 + (temp_rand > 31) ? MONS_LEMURE : // 9 in 60 + (temp_rand > 22) ? MONS_UFETUBUS : // 9 in 60 + (temp_rand > 13) ? MONS_MANES : // 9 in 60 + (temp_rand > 4) ? MONS_MIDGE // 9 in 60 + : MONS_SHADOW_IMP); // 5 in 60 break; case DEMON_COMMON: temp_rand = random2(3948); - summoned = ((temp_rand > 3367) ? MONS_NEQOXEC : // 14.69% - (temp_rand > 2787) ? MONS_ORANGE_DEMON : // 14.69% - (temp_rand > 2207) ? MONS_HELLWING : // 14.69% - (temp_rand > 1627) ? MONS_SMOKE_DEMON : // 14.69% - (temp_rand > 1047) ? MONS_YNOXINUL : // 14.69% - (temp_rand > 889) ? MONS_RED_DEVIL : // 4.00% - (temp_rand > 810) ? MONS_HELLION : // 2.00% - (temp_rand > 731) ? MONS_ROTTING_DEVIL : // 2.00% - (temp_rand > 652) ? MONS_TORMENTOR : // 2.00% - (temp_rand > 573) ? MONS_REAPER : // 2.00% - (temp_rand > 494) ? MONS_SOUL_EATER : // 2.00% - (temp_rand > 415) ? MONS_HAIRY_DEVIL : // 2.00% - (temp_rand > 336) ? MONS_ICE_DEVIL : // 2.00% - (temp_rand > 257) ? MONS_BLUE_DEVIL : // 2.00% - (temp_rand > 178) ? MONS_BEAST : // 2.00% - (temp_rand > 99) ? MONS_IRON_DEVIL : // 2.00% - (temp_rand > 49) ? MONS_SUN_DEMON // 1.26% - : MONS_SHADOW_IMP); // 1.26% + mon = ((temp_rand > 3367) ? MONS_NEQOXEC : // 14.69% + (temp_rand > 2787) ? MONS_ORANGE_DEMON : // 14.69% + (temp_rand > 2207) ? MONS_HELLWING : // 14.69% + (temp_rand > 1627) ? MONS_SMOKE_DEMON : // 14.69% + (temp_rand > 1047) ? MONS_YNOXINUL : // 14.69% + (temp_rand > 889) ? MONS_RED_DEVIL : // 4.00% + (temp_rand > 810) ? MONS_HELLION : // 2.00% + (temp_rand > 731) ? MONS_ROTTING_DEVIL : // 2.00% + (temp_rand > 652) ? MONS_TORMENTOR : // 2.00% + (temp_rand > 573) ? MONS_REAPER : // 2.00% + (temp_rand > 494) ? MONS_SOUL_EATER : // 2.00% + (temp_rand > 415) ? MONS_HAIRY_DEVIL : // 2.00% + (temp_rand > 336) ? MONS_ICE_DEVIL : // 2.00% + (temp_rand > 257) ? MONS_BLUE_DEVIL : // 2.00% + (temp_rand > 178) ? MONS_BEAST : // 2.00% + (temp_rand > 99) ? MONS_IRON_DEVIL : // 2.00% + (temp_rand > 49) ? MONS_SUN_DEMON // 1.26% + : MONS_SHADOW_IMP); // 1.26% break; case DEMON_GREATER: temp_rand = random2(1000); - summoned = ((temp_rand > 868) ? MONS_CACODEMON : // 13.1% - (temp_rand > 737) ? MONS_BALRUG : // 13.1% - (temp_rand > 606) ? MONS_BLUE_DEATH : // 13.1% - (temp_rand > 475) ? MONS_GREEN_DEATH : // 13.1% - (temp_rand > 344) ? MONS_EXECUTIONER : // 13.1% - (temp_rand > 244) ? MONS_FIEND : // 10.0% - (temp_rand > 154) ? MONS_ICE_FIEND : // 9.0% - (temp_rand > 73) ? MONS_SHADOW_FIEND // 8.1% - : MONS_PIT_FIEND); // 7.4% + mon = ((temp_rand > 868) ? MONS_CACODEMON : // 13.1% + (temp_rand > 737) ? MONS_BALRUG : // 13.1% + (temp_rand > 606) ? MONS_BLUE_DEATH : // 13.1% + (temp_rand > 475) ? MONS_GREEN_DEATH : // 13.1% + (temp_rand > 344) ? MONS_EXECUTIONER : // 13.1% + (temp_rand > 244) ? MONS_FIEND : // 10.0% + (temp_rand > 154) ? MONS_ICE_FIEND : // 9.0% + (temp_rand > 73) ? MONS_SHADOW_FIEND // 8.1% + : MONS_PIT_FIEND); // 7.4% break; default: - summoned = MONS_GIANT_ANT; // this was the original behaviour {dlb} + mon = MONS_GIANT_ANT; // this was the original behaviour {dlb} break; } - return summoned; -} // end summon_any_demon() + return (mon); +} -monster_type rand_dragon( dragon_class_type type ) +monster_type summon_any_dragon(dragon_class_type dct) { - monster_type summoned = MONS_PROGRAM_BUG; + monster_type mon = MONS_PROGRAM_BUG; + int temp_rand; - switch (type) + switch (dct) { case DRAGON_LIZARD: temp_rand = random2(100); - summoned = ((temp_rand > 80) ? MONS_SWAMP_DRAKE : - (temp_rand > 59) ? MONS_KOMODO_DRAGON : - (temp_rand > 34) ? MONS_FIREDRAKE : - (temp_rand > 11) ? MONS_DEATH_DRAKE : - MONS_DRAGON); + mon = ((temp_rand > 80) ? MONS_SWAMP_DRAKE : + (temp_rand > 59) ? MONS_KOMODO_DRAGON : + (temp_rand > 34) ? MONS_FIREDRAKE : + (temp_rand > 11) ? MONS_DEATH_DRAKE : + MONS_DRAGON); break; case DRAGON_DRACONIAN: temp_rand = random2(70); - summoned = ((temp_rand > 60) ? MONS_YELLOW_DRACONIAN : - (temp_rand > 50) ? MONS_BLACK_DRACONIAN : - (temp_rand > 40) ? MONS_PALE_DRACONIAN : - (temp_rand > 30) ? MONS_GREEN_DRACONIAN : - (temp_rand > 20) ? MONS_PURPLE_DRACONIAN : - (temp_rand > 10) ? MONS_RED_DRACONIAN - : MONS_WHITE_DRACONIAN); + mon = ((temp_rand > 60) ? MONS_YELLOW_DRACONIAN : + (temp_rand > 50) ? MONS_BLACK_DRACONIAN : + (temp_rand > 40) ? MONS_PALE_DRACONIAN : + (temp_rand > 30) ? MONS_GREEN_DRACONIAN : + (temp_rand > 20) ? MONS_PURPLE_DRACONIAN : + (temp_rand > 10) ? MONS_RED_DRACONIAN + : MONS_WHITE_DRACONIAN); break; case DRAGON_DRAGON: temp_rand = random2(90); - summoned = ((temp_rand > 80) ? MONS_MOTTLED_DRAGON : - (temp_rand > 70) ? MONS_LINDWURM : - (temp_rand > 60) ? MONS_STORM_DRAGON : - (temp_rand > 50) ? MONS_MOTTLED_DRAGON : - (temp_rand > 40) ? MONS_STEAM_DRAGON : - (temp_rand > 30) ? MONS_DRAGON : - (temp_rand > 20) ? MONS_ICE_DRAGON : - (temp_rand > 10) ? MONS_SWAMP_DRAGON - : MONS_SHADOW_DRAGON); + mon = ((temp_rand > 80) ? MONS_MOTTLED_DRAGON : + (temp_rand > 70) ? MONS_LINDWURM : + (temp_rand > 60) ? MONS_STORM_DRAGON : + (temp_rand > 50) ? MONS_MOTTLED_DRAGON : + (temp_rand > 40) ? MONS_STEAM_DRAGON : + (temp_rand > 30) ? MONS_DRAGON : + (temp_rand > 20) ? MONS_ICE_DRAGON : + (temp_rand > 10) ? MONS_SWAMP_DRAGON + : MONS_SHADOW_DRAGON); break; default: break; } - return (summoned); + return (mon); } diff --git a/crawl-ref/source/monplace.h b/crawl-ref/source/monplace.h index 9d877a86ab..53b840269c 100644 --- a/crawl-ref/source/monplace.h +++ b/crawl-ref/source/monplace.h @@ -266,9 +266,10 @@ bool empty_surrounds( int emx, int emy, dungeon_feature_type spc_wanted, /* *********************************************************************** * called from: ability - acr - items - maps - mstuff2 - spell - spells * *********************************************************************** */ -monster_type summon_any_demon( demon_class_type demon_class ); +monster_type summon_any_demon(demon_class_type dct); + +monster_type summon_any_dragon(dragon_class_type dct); -monster_type rand_dragon( dragon_class_type type ); bool drac_colour_incompatible(int drac, int colour); /* *********************************************************************** diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index fc55309671..ff8ce661f7 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -752,11 +752,11 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast) for (sumcount = 0; sumcount < sumcount2; sumcount++) { - const monster_type mons = rand_dragon( DRAGON_LIZARD ); + const monster_type mons = summon_any_dragon(DRAGON_LIZARD); if (mons == MONS_DRAGON) { monsters.clear(); - monsters.push_back( rand_dragon(DRAGON_DRAGON) ); + monsters.push_back(summon_any_dragon(DRAGON_DRAGON)); break; } monsters.push_back( mons ); diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index d61de07a87..d7789efa73 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -1830,6 +1830,62 @@ bool cast_call_imp(int pow, bool god_gift) return (success); } +static bool _summon_demon_wrapper(int pow, bool god_gift, demon_class_type dct, + int dur, bool friendly) +{ + bool success = false; + + monster_type mon = summon_any_demon(dct); + + if (create_monster( + mgen_data(mon, + friendly ? BEH_FRIENDLY : BEH_HOSTILE, + dur, you.pos(), + friendly ? you.pet_target : MHITYOU, + god_gift ? MF_GOD_GIFT : 0)) != -1) + { + success = true; + + mprf("A demon appears!%s", + friendly ? "" : " It doesn't look very happy."); + } + + if (!success) + canned_msg(MSG_NOTHING_HAPPENS); + + return (success); +} + +bool cast_summon_demon(int pow, bool god_gift) +{ + mpr("You open a gate to Pandemonium!"); + + return _summon_demon_wrapper(pow, god_gift, DEMON_COMMON, + std::min(2 + (random2(pow) / 4), 6), + random2(pow) > 3); +} + +bool cast_demonic_horde(int pow, bool god_gift) +{ + bool success = false; + + const int how_many = 7 + random2(5); + + mpr("You open a gate to Pandemonium!"); + + for (int i = 0; i < how_many; ++i) + { + if (_summon_demon_wrapper(pow, god_gift, DEMON_COMMON, + std::min(2 + (random2(pow) / 4), 6), + random2(pow) > 3)) + { + success = true; + } + } + + return (success); +} + bool cast_call_canine_familiar(int pow, bool god_gift) { bool success = false; @@ -1902,9 +1958,7 @@ bool summon_general_creature_spell(spell_type spell, int pow, beh_type beha = (spell == SPELL_SUMMON_GREATER_DEMON) ? BEH_CHARMED : BEH_FRIENDLY; - int hostile = (spell == SPELL_SUMMON_DEMON - || spell == SPELL_DEMONIC_HORDE - || spell == SPELL_SUMMON_UGLY_THING) ? 3 : + int hostile = (spell == SPELL_SUMMON_UGLY_THING) ? 3 : (spell == SPELL_SUMMON_GREATER_DEMON || spell == SPELL_SUMMON_WRAITHS || spell == SPELL_SUMMON_DRAGON) ? 5 @@ -1914,9 +1968,7 @@ bool summon_general_creature_spell(spell_type spell, int pow, || spell == SPELL_SUMMON_WRAITHS) ? 5 : -1; - int how_many = (spell == SPELL_DEMONIC_HORDE) ? - 7 + random2(5) : - (spell == SPELL_SUMMON_WRAITHS) ? + int how_many = (spell == SPELL_SUMMON_WRAITHS) ? stepdown_value(1 + random2(pow) / 30 + random2(pow) / 30, 2, 2, 6, 8) : 1; @@ -1925,15 +1977,6 @@ bool summon_general_creature_spell(spell_type spell, int pow, { switch (spell) { - case SPELL_SUMMON_DEMON: - case SPELL_DEMONIC_HORDE: - case SPELL_SUMMON_GREATER_DEMON: - mon = summon_any_demon( - (spell == SPELL_SUMMON_GREATER_DEMON) ? DEMON_GREATER : - (spell == SPELL_SUMMON_DEMON) ? DEMON_COMMON - : DEMON_LESSER); - break; - case SPELL_SUMMON_ICE_BEAST: mon = MONS_ICE_BEAST; break; @@ -1946,6 +1989,10 @@ bool summon_general_creature_spell(spell_type spell, int pow, break; } + case SPELL_SUMMON_GREATER_DEMON: + mon = summon_any_demon(DEMON_GREATER); + break; + case SPELL_SUMMON_WRAITHS: { const int chance = random2(25); @@ -1971,12 +2018,8 @@ bool summon_general_creature_spell(spell_type spell, int pow, break; } - if (i == 0 && (spell == SPELL_SUMMON_DEMON - || spell == SPELL_DEMONIC_HORDE - || spell == SPELL_SUMMON_GREATER_DEMON)) - { + if (i == 0 && spell == SPELL_SUMMON_GREATER_DEMON) mpr("You open a gate to Pandemonium!"); - } if (summon_general_creature(pow, false, mon, beha, hostile, dur, false)) diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h index 23595c7316..f776c80cea 100644 --- a/crawl-ref/source/spells2.h +++ b/crawl-ref/source/spells2.h @@ -149,6 +149,10 @@ bool cast_summon_swarm(int pow, bool god_gift = false, * *********************************************************************** */ bool cast_call_imp(int pow, bool god_gift = false); +bool cast_summon_demon(int pow, bool god_gift = false); + +bool cast_demonic_horde(int pow, bool god_gift = false); + bool cast_call_canine_familiar(int pow, bool god_gift = false); bool summon_general_creature_spell(spell_type spell, int pow, diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index d03436bbdd..a071ff77fa 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1495,9 +1495,15 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) cast_call_canine_familiar(powc); break; - // Remember that most holy spells don't yet use powc! case SPELL_SUMMON_DEMON: + cast_summon_demon(powc); + break; + case SPELL_DEMONIC_HORDE: + cast_demonic_horde(powc); + break; + + // Remember that most holy spells don't yet use powc! case SPELL_SUMMON_ICE_BEAST: case SPELL_SUMMON_UGLY_THING: case SPELL_SUMMON_GREATER_DEMON: -- cgit v1.2.3-54-g00ecf