diff options
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/spells2.cc | 85 | ||||
-rw-r--r-- | crawl-ref/source/spells2.h | 11 | ||||
-rw-r--r-- | crawl-ref/source/spells3.cc | 84 | ||||
-rw-r--r-- | crawl-ref/source/spells3.h | 8 | ||||
-rw-r--r-- | crawl-ref/source/xom.cc | 5 |
5 files changed, 99 insertions, 94 deletions
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index b3809f28e0..e50002258d 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -39,6 +39,7 @@ #include "itemname.h" #include "itemprop.h" #include "items.h" +#include "it_use2.h" #include "message.h" #include "misc.h" #include "monplace.h" @@ -2340,6 +2341,90 @@ bool cast_conjure_ball_lightning(int pow, bool god_gift) return (success); } +bool dancing_weapon(int pow, bool god_gift, bool force_hostile, + bool quiet_failure) +{ + bool success = true; + + const int dur = std::min(2 + (random2(pow) / 5), 6); + + const int wpn = you.equip[EQ_WEAPON]; + + // See if wielded item is appropriate. + if (wpn == -1 + || you.inv[wpn].base_type != OBJ_WEAPONS + || is_range_weapon(you.inv[wpn]) + || is_fixed_artefact(you.inv[wpn])) + { + success = false; + } + + // See if we can get an mitm for the dancing weapon. + const int i = get_item_slot(); + + if (i == NON_ITEM) + success = false; + + int monster; + + if (success) + { + // Cursed weapons become hostile. + const bool friendly = (!force_hostile && !item_cursed(you.inv[wpn])); + + monster = + create_monster( + mgen_data(MONS_DANCING_WEAPON, + friendly ? BEH_FRIENDLY : BEH_HOSTILE, + dur, you.pos(), + friendly ? you.pet_target : MHITYOU, + god_gift ? MF_GOD_GIFT : 0)); + + if (monster == -1) + success = false; + } + + if (!success) + { + destroy_item(i); + + if (!quiet_failure) + { + if (wpn != -1) + mpr("Your weapon vibrates crazily for a second."); + else + msg::stream << "Your " << your_hand(true) << " twitch." + << std::endl; + } + + return (false); + } + + // We are successful. Unwield the weapon, removing any wield effects. + unwield_item(); + + // Copy the unwielded item. + mitm[i] = you.inv[wpn]; + mitm[i].quantity = 1; + mitm[i].x = 0; + mitm[i].y = 0; + mitm[i].link = NON_ITEM; + + // Mark the weapon as thrown, so that we'll autograb it when the + // tango's done. + mitm[i].flags |= ISFLAG_THROWN; + + mprf("%s dances into the air!", you.inv[wpn].name(DESC_CAP_YOUR).c_str()); + + you.inv[wpn].quantity = 0; + + menv[monster].inv[MSLOT_WEAPON] = i; + menv[monster].colour = mitm[i].colour; + burden_change(); + + return (true); +} + // Makhleb or Kikubaaqudgha sends a demonic buddy (or enemy) for a // follower. bool summon_demon_type(monster_type mon, int pow, bool god_gift) diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h index 1c15a00256..7e2af16f3b 100644 --- a/crawl-ref/source/spells2.h +++ b/crawl-ref/source/spells2.h @@ -180,6 +180,17 @@ bool cast_summon_dragon(int pow, bool god_gift = false); bool cast_conjure_ball_lightning(int pow, bool god_gift = false); +// last updated 24may2000 {dlb} +/* *********************************************************************** + * called from: ability - religion - spell + * *********************************************************************** */ +bool dancing_weapon(int pow, bool god_gift = false, bool force_hostile = false, + bool quiet_failure = false); + +// last updated 24may2000 {dlb} +/* *********************************************************************** + * called from: ability - spell + * *********************************************************************** */ bool summon_demon_type(monster_type mon, int pow, bool god_gift = false); bool summon_berserker(int pow, bool god_gift = false, diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index d4f2989a2b..5ea049c087 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -36,7 +36,6 @@ #include "itemprop.h" #include "items.h" #include "item_use.h" -#include "it_use2.h" #include "message.h" #include "misc.h" #include "monplace.h" @@ -472,89 +471,6 @@ void simulacrum(int power) } } -bool dancing_weapon(int pow, bool force_hostile, - bool quiet_failure) -{ - bool success = true; - - const int dur = std::min(2 + (random2(pow) / 5), 6); - - const int wpn = you.equip[EQ_WEAPON]; - - // See if wielded item is appropriate: - if (wpn == -1 - || you.inv[wpn].base_type != OBJ_WEAPONS - || is_range_weapon(you.inv[wpn]) - || is_fixed_artefact( you.inv[wpn])) - { - success = false; - } - - // See if we can get an mitm for the dancing weapon: - int i = get_item_slot(); - - if (i == NON_ITEM) - success = false; - - int monster; - - if (success) - { - // Cursed weapons become hostile. - bool friendly = (!force_hostile && !item_cursed(you.inv[wpn])); - - monster = - create_monster( - mgen_data(MONS_DANCING_WEAPON, - friendly ? BEH_FRIENDLY : BEH_HOSTILE, - dur, you.pos(), - friendly ? you.pet_target : MHITYOU)); - - if (monster == -1) - success = false; - } - - if (!success) - { - destroy_item(i); - - if (!quiet_failure) - { - if (wpn != -1) - mpr("Your weapon vibrates crazily for a second."); - else - msg::stream << "Your " << your_hand(true) << " twitch." - << std::endl; - } - - return (false); - } - - // We are successful. Unwield the weapon, removing any wield effects. - unwield_item(); - - // Copy the unwielded item. - mitm[i] = you.inv[wpn]; - mitm[i].quantity = 1; - mitm[i].x = 0; - mitm[i].y = 0; - mitm[i].link = NON_ITEM; - - // Mark the weapon as thrown, so that we'll autograb it when the - // tango's done. - mitm[i].flags |= ISFLAG_THROWN; - - mprf("%s dances into the air!", you.inv[wpn].name(DESC_CAP_YOUR).c_str()); - - you.inv[wpn].quantity = 0; - - menv[monster].inv[MSLOT_WEAPON] = i; - menv[monster].colour = mitm[i].colour; - burden_change(); - - return (true); -} - // This function returns true if the player can use controlled teleport // here. bool allow_control_teleport( bool silent ) diff --git a/crawl-ref/source/spells3.h b/crawl-ref/source/spells3.h index ef6560071e..ce74a6a4b8 100644 --- a/crawl-ref/source/spells3.h +++ b/crawl-ref/source/spells3.h @@ -80,14 +80,6 @@ bool project_noise(void); // updated 24may2000 {dlb} /* *********************************************************************** - * called from: religion - spell - * *********************************************************************** */ -bool dancing_weapon(int pow, bool force_hostile = false, - bool quiet_failure = false); - - -// updated 24may2000 {dlb} -/* *********************************************************************** * called from: item_use - spell * *********************************************************************** */ bool detect_curse(bool suppress_msg); diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index ef3d73de5c..88e8bb6db0 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -27,7 +27,7 @@ #include "player.h" #include "randart.h" #include "religion.h" -#include "spells3.h" +#include "spells2.h" #include "spl-cast.h" #include "spl-util.h" #include "state.h" @@ -877,8 +877,9 @@ static bool xom_is_bad(int sever) { bool success = false; + // Nasty, but fun. if (one_chance_in(4)) - success = dancing_weapon(100, true, true); // Nasty, but fun. + success = dancing_weapon(100, true, true, true); else { const int numdemons = |