From ffcae9af0299c5d8510532adf7ed01eb6ce81364 Mon Sep 17 00:00:00 2001 From: haranp Date: Thu, 28 Jun 2007 22:31:17 +0000 Subject: Fixup of gunofdis patch for returning weapons [1744612]: Returning brand implemented for daggers, hand axes, and spears. Monsters will pick up and use (and hopefully be occasionally generated with) returning weapons, which they can both throw for ranged attacks and use hand-to-hand. The chance of a returning weapon not returning is proportional to ranged combat skill (for the player) or HD (for monsters.) If it doesn't return, it just acts as if it was thrown normally. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1684 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/item_use.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source/item_use.cc') diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index a9df7881e1..676fb0cbd1 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -514,6 +514,10 @@ void wield_effects(int item_wield_2, bool showMsgs) mpr("You sense a holy aura."); break; + case SPWPN_RETURNING: + mpr("It wiggles slightly."); + break; + case SPWPN_PAIN: mpr("A searing pain shoots up your arm!"); break; @@ -1367,6 +1371,7 @@ bool throw_it(struct bolt &pbolt, int throw_2, bool teleport, int acc_bonus) int dice_mult = 100; bool launched = false; // item is launched bool thrown = false; // item is sensible thrown item + bool returning = false; // item will return to pack int slayDam = 0; if (!teleport) @@ -1790,6 +1795,8 @@ bool throw_it(struct bolt &pbolt, int throw_2, bool teleport, int acc_bonus) // CALCULATIONS FOR THROWN WEAPONS if (thrown) { + returning = (get_weapon_brand(item) == SPWPN_RETURNING && + !one_chance_in(you.skills[SK_RANGED_COMBAT]+1)); baseHit = 0; // since darts/rocks are missiles, they only use inv_plus @@ -1994,10 +2001,14 @@ bool throw_it(struct bolt &pbolt, int throw_2, bool teleport, int acc_bonus) { // Dropping item copy, since the launched item might be different // (e.g. venom blowgun) - fire_beam( pbolt, &item ); + fire_beam(pbolt, returning ? NULL : &item); } - dec_inv_item_quantity( throw_2, 1 ); + if ( returning ) + msg::stream << item.name(DESC_CAP_THE) << " returns to your pack!" + << std::endl; + else + dec_inv_item_quantity( throw_2, 1 ); // throwing and blowguns are silent if (launched && lnchType != WPN_BLOWGUN) -- cgit v1.2.3-54-g00ecf