From f5156c1a88350f8f2534e1bc80847172e74cf489 Mon Sep 17 00:00:00 2001 From: dolorous Date: Sat, 7 Jun 2008 18:44:17 +0000 Subject: Add more cleanups. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5548 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells2.cc | 107 ++++++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 44 deletions(-) (limited to 'crawl-ref/source/spells2.cc') diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 16bc5b3cf6..d61de07a87 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -1830,13 +1830,73 @@ bool cast_call_imp(int pow, bool god_gift) return (success); } +bool cast_call_canine_familiar(int pow, bool god_gift) +{ + bool success = false; + + monster_type mon = MONS_PROGRAM_BUG; + + const int dur = std::min(2 + (random2(pow) / 4), 6); + + const int chance = random2(pow); + + if (chance < 10) + mon = MONS_JACKAL; + else if (chance < 15) + mon = MONS_HOUND; + else + { + switch (chance % 7) + { + case 0: + if (one_chance_in(you.species == SP_HILL_ORC ? 3 : 6)) + mon = MONS_WARG; + else + mon = MONS_WOLF; + break; + + case 1: + case 2: + mon = MONS_WAR_DOG; + break; + + case 3: + case 4: + mon = MONS_HOUND; + break; + + default: + mon = MONS_JACKAL; + break; + } + } + + bool friendly = (random2(pow) > 3); + + 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 canine appears!%s", + friendly ? "" : " It doesn't look very happy."); + } + + if (!success) + canned_msg(MSG_NOTHING_HAPPENS); + + return (success); +} + bool summon_general_creature_spell(spell_type spell, int pow, bool god_gift) { bool success = false; - bool quiet = (spell == SPELL_CALL_CANINE_FAMILIAR); - monster_type mon = MONS_PROGRAM_BUG; beh_type beha = (spell == SPELL_SUMMON_GREATER_DEMON) ? BEH_CHARMED @@ -1844,7 +1904,6 @@ bool summon_general_creature_spell(spell_type spell, int pow, int hostile = (spell == SPELL_SUMMON_DEMON || spell == SPELL_DEMONIC_HORDE - || spell == SPELL_CALL_CANINE_FAMILIAR || spell == SPELL_SUMMON_UGLY_THING) ? 3 : (spell == SPELL_SUMMON_GREATER_DEMON || spell == SPELL_SUMMON_WRAITHS @@ -1875,38 +1934,6 @@ bool summon_general_creature_spell(spell_type spell, int pow, : DEMON_LESSER); break; - case SPELL_CALL_CANINE_FAMILIAR: - { - const int chance = random2(pow); - if (chance < 10) - mon = MONS_JACKAL; - else if (chance < 15) - mon = MONS_HOUND; - else - { - switch (chance % 7) - { - case 0: - if (one_chance_in(you.species == SP_HILL_ORC ? 3 : 6)) - mon = MONS_WARG; - else - mon = MONS_WOLF; - break; - case 1: - case 2: - mon = MONS_WAR_DOG; - break; - case 3: - case 4: - mon = MONS_HOUND; - break; - default: - mon = MONS_JACKAL; - break; - } - } - } - case SPELL_SUMMON_ICE_BEAST: mon = MONS_ICE_BEAST; break; @@ -1951,7 +1978,7 @@ bool summon_general_creature_spell(spell_type spell, int pow, mpr("You open a gate to Pandemonium!"); } - if (summon_general_creature(pow, quiet, mon, beha, + if (summon_general_creature(pow, false, mon, beha, hostile, dur, false)) { success = true; @@ -1991,14 +2018,6 @@ bool summon_general_creature(int pow, bool quiet, monster_type mon, switch (mon) { - case MONS_JACKAL: - case MONS_HOUND: - case MONS_WARG: - case MONS_WOLF: - case MONS_WAR_DOG: - msg = "A canine appears!"; - break; - case MONS_ICE_BEAST: msg = "A chill wind blows around you."; break; -- cgit v1.2.3-54-g00ecf