From: <ha...@us...> - 2007-06-28 22:31:18
|
Revision: 1684 http://svn.sourceforge.net/crawl-ref/?rev=1684&view=rev Author: haranp Date: 2007-06-28 15:31:17 -0700 (Thu, 28 Jun 2007) Log Message: ----------- 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. Modified Paths: -------------- trunk/crawl-ref/source/beam.cc trunk/crawl-ref/source/enum.h trunk/crawl-ref/source/item_use.cc trunk/crawl-ref/source/itemname.cc trunk/crawl-ref/source/makeitem.cc trunk/crawl-ref/source/mon-util.cc trunk/crawl-ref/source/monstuff.cc trunk/crawl-ref/source/mstuff2.cc Modified: trunk/crawl-ref/source/beam.cc =================================================================== --- trunk/crawl-ref/source/beam.cc 2007-06-28 18:05:48 UTC (rev 1683) +++ trunk/crawl-ref/source/beam.cc 2007-06-28 22:31:17 UTC (rev 1684) @@ -3633,7 +3633,7 @@ if (player_monster_visible( &menv[tid] ) && mons_near(mon)) { msg::stream << "The " << beam.name << " misses " - << str_monam(*mon, DESC_NOCAP_THE) << std::endl; + << mon->name(DESC_NOCAP_THE) << '.' << std::endl; } return (0); } Modified: trunk/crawl-ref/source/enum.h =================================================================== --- trunk/crawl-ref/source/enum.h 2007-06-28 18:05:48 UTC (rev 1683) +++ trunk/crawl-ref/source/enum.h 2007-06-28 22:31:17 UTC (rev 1684) @@ -3172,6 +3172,7 @@ SPWPN_PAIN, // 15 SPWPN_DISTORTION, SPWPN_REACHING, // 17 + SPWPN_RETURNING, SPWPN_CONFUSE, SPWPN_RANDART_I = 25, // 25 SPWPN_RANDART_II, Modified: trunk/crawl-ref/source/item_use.cc =================================================================== --- trunk/crawl-ref/source/item_use.cc 2007-06-28 18:05:48 UTC (rev 1683) +++ trunk/crawl-ref/source/item_use.cc 2007-06-28 22:31:17 UTC (rev 1684) @@ -514,6 +514,10 @@ 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 @@ 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 @@ // 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 @@ { // 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) Modified: trunk/crawl-ref/source/itemname.cc =================================================================== --- trunk/crawl-ref/source/itemname.cc 2007-06-28 18:05:48 UTC (rev 1683) +++ trunk/crawl-ref/source/itemname.cc 2007-06-28 22:31:17 UTC (rev 1684) @@ -301,6 +301,7 @@ case SPWPN_PAIN: return ((terse) ? " (pain)" : " of pain"); case SPWPN_DISTORTION: return ((terse) ? " (distort)" : " of distortion"); case SPWPN_REACHING: return ((terse) ? " (reach)" : " of reaching"); + case SPWPN_RETURNING: return ((terse) ? " (return)" : " of returning"); case SPWPN_VAMPIRICISM: return ((terse) ? " (vamp)" : ""); // non-terse already handled Modified: trunk/crawl-ref/source/makeitem.cc =================================================================== --- trunk/crawl-ref/source/makeitem.cc 2007-06-28 18:05:48 UTC (rev 1683) +++ trunk/crawl-ref/source/makeitem.cc 2007-06-28 22:31:17 UTC (rev 1684) @@ -1324,6 +1324,9 @@ case WPN_DAGGER: + if (one_chance_in(4)) + set_weapon_special(p, SPWPN_RETURNING); + if (one_chance_in(10)) set_weapon_special(p, SPWPN_PAIN); @@ -1434,6 +1437,10 @@ if (one_chance_in(10)) set_weapon_special(p, SPWPN_VAMPIRICISM); + if (mitm[p].sub_type == WPN_HAND_AXE && + one_chance_in(10)) + set_weapon_special(p, SPWPN_RETURNING); + if (got_distortion_roll(item_level)) set_weapon_special(p, SPWPN_DISTORTION); @@ -1504,6 +1511,9 @@ if (one_chance_in(10)) set_weapon_special(p, SPWPN_VAMPIRICISM); + if (mitm[p].sub_type == WPN_SPEAR && one_chance_in(6)) + set_weapon_special(p, SPWPN_RETURNING); + if (got_distortion_roll(item_level)) set_weapon_special(p, SPWPN_DISTORTION); Modified: trunk/crawl-ref/source/mon-util.cc =================================================================== --- trunk/crawl-ref/source/mon-util.cc 2007-06-28 18:05:48 UTC (rev 1683) +++ trunk/crawl-ref/source/mon-util.cc 2007-06-28 22:31:17 UTC (rev 1684) @@ -1980,6 +1980,10 @@ const int weapon = mon->inv[MSLOT_WEAPON]; const int ammo = mon->inv[MSLOT_MISSILE]; + if ( weapon != NON_ITEM && + get_weapon_brand(mitm[weapon]) == SPWPN_RETURNING ) + return true; + const int lnchClass = (weapon != NON_ITEM) ? mitm[weapon].base_type : -1; const int lnchType = (weapon != NON_ITEM) ? mitm[weapon].sub_type : 0; Modified: trunk/crawl-ref/source/monstuff.cc =================================================================== --- trunk/crawl-ref/source/monstuff.cc 2007-06-28 18:05:48 UTC (rev 1683) +++ trunk/crawl-ref/source/monstuff.cc 2007-06-28 22:31:17 UTC (rev 1684) @@ -3274,7 +3274,22 @@ if (mons_itemuse(monster->type) < MONUSE_OPEN_DOORS) return (false); - const int mon_item = monster->inv[MSLOT_MISSILE]; + int mon_item; + const int mon_wpn = monster->inv[MSLOT_WEAPON]; + bool returning = false; + + // weapons of returning can be thrown + if ( mon_wpn != NON_ITEM && + get_weapon_brand(mitm[mon_wpn]) == SPWPN_RETURNING ) + { + mon_item = mon_wpn; + returning = true; + } + else + { + mon_item = monster->inv[MSLOT_MISSILE]; + } + if (mon_item == NON_ITEM || !is_valid_item( mitm[mon_item] )) return (false); @@ -3308,7 +3323,7 @@ throw_type( lnchClass, lnchType, wepClass, wepType, launched, thrown ); - if (!launched && !thrown) + if (!launched && !thrown && !returning) return (false); // ok, we'll try it. Modified: trunk/crawl-ref/source/mstuff2.cc =================================================================== --- trunk/crawl-ref/source/mstuff2.cc 2007-06-28 18:05:48 UTC (rev 1683) +++ trunk/crawl-ref/source/mstuff2.cc 2007-06-28 22:31:17 UTC (rev 1684) @@ -1006,12 +1006,11 @@ bool mons_throw(struct monsters *monster, struct bolt &pbolt, int hand_used) { - // this was assumed during cleanup down below: - ASSERT( hand_used == monster->inv[MSLOT_MISSILE] ); - // XXX: ugly hack, but avoids adding dynamic allocation to this code - static char throw_buff[ ITEMNAME_SIZE ]; + char throw_buff[ ITEMNAME_SIZE ]; + bool returning = (get_weapon_brand(mitm[hand_used]) == SPWPN_RETURNING); + int baseHit = 0, baseDam = 0; // from thrown or ammo int ammoHitBonus = 0, ammoDamBonus = 0; // from thrown or ammo int lnchHitBonus = 0, lnchDamBonus = 0; // special add from launcher @@ -1048,6 +1047,11 @@ // figure out if we're thrown or launched throw_type( lnchClass, lnchType, wepClass, wepType, launched, thrown ); + if (returning) + { + launched = false; + thrown = true; + } // extract launcher bonuses due to magic if (launched) @@ -1280,12 +1284,25 @@ scale_dice(pbolt.damage); // decrease inventory - fire_beam( pbolt, &item ); + bool really_returns; + if ( returning && !one_chance_in(mons_power(monster->type) + 3) ) + really_returns = true; + else + really_returns = false; - if (dec_mitm_item_quantity( hand_used, 1 )) - monster->inv[MSLOT_MISSILE] = NON_ITEM; + fire_beam( pbolt, really_returns ? NULL : &item ); + if ( really_returns ) + { + msg::stream << "The weapon returns to " + << monster->name(DESC_NOCAP_THE) + << "'s hand!" << std::endl; + } + if ( !really_returns ) + if (dec_mitm_item_quantity( hand_used, 1 )) + monster->inv[returning ? MSLOT_WEAPON : MSLOT_MISSILE] = NON_ITEM; + return (true); } // end mons_throw() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |