From f79c9dacc90e9a7880f73abe03565e6d797e20a9 Mon Sep 17 00:00:00 2001 From: haranp Date: Wed, 4 Jul 2007 11:54:17 +0000 Subject: Implemented Blade card. Damnation will no longer work in Abyss/Pan/Lab. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1747 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/decks.cc | 31 +++++++++++++++++++++++-------- crawl-ref/source/item_use.cc | 28 +++++++++++++++------------- crawl-ref/source/item_use.h | 2 ++ 3 files changed, 40 insertions(+), 21 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index 6e72756b13..c035744aa8 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -19,7 +19,9 @@ #include "beam.h" #include "effects.h" #include "food.h" +#include "invent.h" #include "it_use2.h" +#include "item_use.h" #include "itemprop.h" #include "items.h" #include "misc.h" @@ -314,7 +316,9 @@ bool deck_triple_draw() return false; } - item_def& item(you.inv[you.equip[EQ_WEAPON]]); + const int slot = you.equip[EQ_WEAPON]; + item_def& item(you.inv[slot]); + if ( item.plus2 != 0 ) { mpr("You can't triple draw from a marked deck."); @@ -349,6 +353,8 @@ bool deck_triple_draw() else canned_msg(MSG_HUH); } + + // Note that card_effect() might cause you to unwield the deck. card_effect(draws[selected], deck_rarity(item)); // remove the cards from the deck @@ -356,8 +362,10 @@ bool deck_triple_draw() if (item.plus <= 0) { mpr("The deck of cards disappears in a puff of smoke."); - unwield_item(you.equip[EQ_WEAPON]); - dec_inv_item_quantity( you.equip[EQ_WEAPON], 1 ); + if ( slot == you.equip[EQ_WEAPON] ) + unwield_item(slot); + + dec_inv_item_quantity( slot, 1 ); } you.wield_change = true; return true; @@ -561,6 +569,12 @@ static void velocity_card(int power, deck_rarity_type rarity) static void damnation_card(int power, deck_rarity_type rarity) { + if ( you.level_type != LEVEL_DUNGEON ) + { + canned_msg(MSG_NOTHING_HAPPENS); + return; + } + // pick a random monster nearby to banish (or yourself) const int mon_to_banish = choose_random_nearby_monster(1); @@ -770,13 +784,14 @@ static void helm_card(int power, deck_rarity_type rarity) } } -// Do one of: vorpalise, sure blade, dancing weapon -// XXX XXX FIXME Hard to do now, because you have to -// wield the deck in order to evoke it! static void blade_card(int power, deck_rarity_type rarity) { - // not yet implemented - return; + // Pause before jumping to the list. + if (Options.auto_list) + more(); + + wield_weapon(false); + const int power_level = get_power_level(power, rarity); if ( power_level >= 2 ) { diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index a5593022d4..f6ee93ef8f 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -747,15 +747,12 @@ bool do_wear_armour( int item, bool quiet ) return (false); } - for (int loopy = EQ_CLOAK; loopy <= EQ_BODY_ARMOUR; loopy++) + if ( wearing_slot(item) ) { - if (item == you.equip[loopy]) - { - if (!quiet) - mpr("You are already wearing that!"); + if (!quiet) + mpr("You are already wearing that!"); - return (false); - } + return (false); } // if you're wielding something, @@ -1106,13 +1103,10 @@ void throw_anything(void) } else { - for (int loopy = EQ_CLOAK; loopy <= EQ_AMULET; loopy++) + if ( wearing_slot(throw_slot) ) { - if (throw_slot == you.equip[loopy]) - { - mpr("You are wearing that object!"); - return; - } + mpr("You are wearing that object!"); + return; } } @@ -3730,3 +3724,11 @@ void use_randart(const item_def &item) xom_is_stimulated(256); } } + +bool wearing_slot(int inv_slot) +{ + for (int i = EQ_CLOAK; i <= EQ_AMULET; ++i) + if ( inv_slot == you.equip[i] ) + return true; + return false; +} diff --git a/crawl-ref/source/item_use.h b/crawl-ref/source/item_use.h index 721ea9678b..be9c28ff44 100644 --- a/crawl-ref/source/item_use.h +++ b/crawl-ref/source/item_use.h @@ -149,4 +149,6 @@ void warn_shield_penalties(); int item_special_wield_effect(const item_def &item); +bool wearing_slot(int inv_slot); + #endif -- cgit v1.2.3-54-g00ecf