From 4f344bc0461bf77daf839129bf3802c77ba2bfa6 Mon Sep 17 00:00:00 2001 From: dolorous Date: Sun, 8 Jun 2008 05:49:35 +0000 Subject: Clean up "Sticks to Snakes", too. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5587 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells2.cc | 120 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) (limited to 'crawl-ref/source/spells2.cc') diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 5de9a1070b..79f433a300 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -35,6 +35,7 @@ #include "directn.h" #include "dungeon.h" #include "effects.h" +#include "invent.h" #include "itemname.h" #include "itemprop.h" #include "items.h" @@ -1541,6 +1542,125 @@ bool cast_summon_small_mammals(int pow, bool god_gift) return (success); } +bool cast_sticks_to_snakes(int pow, bool god_gift) +{ + monster_type mon = MONS_PROGRAM_BUG; + int count = 0; + int max = 1 + random2(1 + you.skills[SK_TRANSMIGRATION]) / 4; + int dur = std::min(3 + random2(pow) / 20, 5); + const int weapon = you.equip[EQ_WEAPON]; + + if (weapon == -1) + { + msg::stream << "Your " << your_hand(true) << " feel slithery!" + << std::endl; + return (false); + } + + // Don't enchant sticks marked with {!D}. + if (!check_warning_inscriptions(you.inv[ weapon ], OPER_DESTROY)) + { + mprf("%s feel%s slithery for a moment!", + you.inv[weapon].name(DESC_CAP_YOUR).c_str(), + you.inv[weapon].quantity > 1 ? "s" : ""); + return (false); + } + + const beh_type beha = item_cursed(you.inv[ weapon ]) ? BEH_HOSTILE + : BEH_FRIENDLY; + const unsigned short hitting = (beha == BEH_HOSTILE) ? MHITYOU + : you.pet_target; + + if ((you.inv[weapon].base_type == OBJ_MISSILES + && (you.inv[weapon].sub_type == MI_ARROW))) + { + if (you.inv[weapon].quantity < max) + max = you.inv[weapon].quantity; + + for (int i = 0; i <= max; i++) + { + if (one_chance_in(5 - std::min(4, div_rand_round(pow * 2, 25))) + || get_ammo_brand(you.inv[weapon]) == SPMSL_POISONED) + { + mon = random2(100) < pow / 3 ? MONS_BROWN_SNAKE : MONS_SNAKE; + } + else + { + mon = MONS_SMALL_SNAKE; + } + + if (create_monster( + mgen_data(mon, beha, dur, + you.pos(), hitting, + god_gift ? MF_GOD_GIFT : 0)) != -1) + { + count++; + } + } + } + + if (you.inv[ weapon ].base_type == OBJ_WEAPONS + && (you.inv[ weapon ].sub_type == WPN_CLUB + || you.inv[ weapon ].sub_type == WPN_SPEAR + || you.inv[ weapon ].sub_type == WPN_QUARTERSTAFF + || you.inv[ weapon ].sub_type == WPN_SCYTHE + || you.inv[ weapon ].sub_type == WPN_GIANT_CLUB + || you.inv[ weapon ].sub_type == WPN_GIANT_SPIKED_CLUB + || you.inv[ weapon ].sub_type == WPN_BOW + || you.inv[ weapon ].sub_type == WPN_LONGBOW + || you.inv[ weapon ].sub_type == WPN_ANKUS + || you.inv[ weapon ].sub_type == WPN_HALBERD + || you.inv[ weapon ].sub_type == WPN_GLAIVE + || you.inv[ weapon ].sub_type == WPN_BLOWGUN)) + { + // Upsizing Snakes to Brown Snakes as the base class for using + // the really big sticks (so bonus applies really only to trolls, + // ogres, and most importantly ogre magi). Still it's unlikely + // any character is strong enough to bother lugging a few of + // these around. -- bwr + if (item_mass(you.inv[weapon]) < 300) + mon = MONS_SNAKE; + else + mon = MONS_BROWN_SNAKE; + + if (pow > 20 && one_chance_in(3)) + mon = MONS_BROWN_SNAKE; + + if (pow > 40 && one_chance_in(3)) + mon = MONS_YELLOW_SNAKE; + + if (pow > 70 && one_chance_in(3)) + mon = MONS_BLACK_SNAKE; + + if (pow > 90 && one_chance_in(3)) + mon = MONS_GREY_SNAKE; + + if (create_monster( + mgen_data(mon, beha, dur, + you.pos(), hitting, + god_gift ? MF_GOD_GIFT : 0)) != -1) + { + count++; + } + } + + if (count > you.inv[you.equip[EQ_WEAPON]].quantity) + count = you.inv[you.equip[EQ_WEAPON]].quantity; + + if (count > 0) + { + dec_inv_item_quantity(you.equip[EQ_WEAPON], count); + + mprf("You create %s snake%s!", + count > 1 ? "some" : "a", count > 1 ? "s" : ""); + return (true); + } + + msg::stream << "Your " << your_hand(true) << " feel slithery!" + << std::endl; + return (false); +} + bool cast_summon_scorpions(int pow, bool god_gift) { bool success = false; -- cgit v1.2.3-54-g00ecf