From 8033b8adea72198452d8eb21e26385715e60d1d4 Mon Sep 17 00:00:00 2001 From: haranp Date: Tue, 16 Sep 2008 20:57:38 +0000 Subject: FR 2112931: temporary brands are extensible. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6938 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spells2.cc | 66 ++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'crawl-ref/source/spells2.cc') diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 7534aa549b..6fe3af29fd 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -259,35 +259,34 @@ int corpse_rot(int power) bool brand_weapon(brand_type which_brand, int power) { - int temp_rand; // probability determination {dlb} - int duration_affected = 0; + if ( !you.weapon() ) + return (false); - const int wpn = you.equip[EQ_WEAPON]; + const bool temp_brand = you.duration[DUR_WEAPON_BRAND]; + item_def& weapon = *you.weapon(); - if (you.duration[DUR_WEAPON_BRAND]) + // Can't brand non-weapons. + if (weapon.base_type != OBJ_WEAPONS || is_range_weapon(weapon)) return (false); - if (wpn == -1) + // Can't brand artefacts. + if (is_artefact(weapon)) return (false); - if (you.inv[wpn].base_type != OBJ_WEAPONS - || is_range_weapon(you.inv[wpn])) - { + // Can't brand already-branded items. + if (!temp_brand && get_weapon_brand(weapon) != SPWPN_NORMAL) return (false); - } - if (is_fixed_artefact( you.inv[wpn] ) - || is_random_artefact( you.inv[wpn] ) - || get_weapon_brand( you.inv[wpn] ) != SPWPN_NORMAL ) - { + // Can't rebrand a temporarily-branded item to a different brand. + if (temp_brand && (get_weapon_brand(weapon) != which_brand)) return (false); - } - - std::string msg = you.inv[wpn].name(DESC_CAP_YOUR); + + std::string msg = weapon.name(DESC_CAP_YOUR); + const int wpn_type = get_vorpal_type(weapon); - const int wpn_type = get_vorpal_type(you.inv[wpn]); - - switch (which_brand) // use SPECIAL_WEAPONS here? + bool emit_special_message = !temp_brand; + int duration_affected = 0; + switch (which_brand) { case SPWPN_FLAMING: msg += " bursts into flame!"; @@ -322,15 +321,8 @@ bool brand_weapon(brand_type which_brand, int power) case SPWPN_DISTORTION: //jmf: Added for Warp Weapon. msg += " seems to "; - - temp_rand = random2(6); - msg += ((temp_rand == 0) ? "twist" : - (temp_rand == 1) ? "bend" : - (temp_rand == 2) ? "vibrate" : - (temp_rand == 3) ? "flex" : - (temp_rand == 4) ? "wobble" - : "twang"); - + msg += random_choose_string("twist", "bend", "vibrate", + "flex", "wobble", "twang", NULL); msg += (coinflip() ? " oddly." : " strangely."); duration_affected = 5; @@ -352,6 +344,8 @@ bool brand_weapon(brand_type which_brand, int power) msg += " shrieks in agony."; noisy(15, you.pos()); duration_affected = 8; + // We must repeat the special message here (as there's a side effect.) + emit_special_message = true; break; case SPWPN_DUMMY_CRUSHING: //jmf: Added for Maxwell's Silver Hammer. @@ -366,12 +360,18 @@ bool brand_weapon(brand_type which_brand, int power) break; } - set_item_ego_type( you.inv[wpn], OBJ_WEAPONS, which_brand ); + if ( !temp_brand ) + { + set_item_ego_type( weapon, OBJ_WEAPONS, which_brand ); + you.wield_change = true; + } - mpr(msg.c_str()); - you.wield_change = true; + if ( emit_special_message ) + mpr(msg.c_str()); + else + mprf("%s flashes.", weapon.name(DESC_CAP_YOUR).c_str()); - int dur_change = duration_affected + roll_dice( 2, power ); + const int dur_change = duration_affected + roll_dice( 2, power ); you.duration[DUR_WEAPON_BRAND] += dur_change; @@ -379,7 +379,7 @@ bool brand_weapon(brand_type which_brand, int power) you.duration[DUR_WEAPON_BRAND] = 50; return (true); -} // end brand_weapon() +} // Restore the stat in which_stat by the amount in stat_gain, displaying // a message if suppress_msg is false, and doing so in the recovery -- cgit v1.2.3-54-g00ecf