summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 11:52:47 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 11:52:47 +0000
commit37b869723d4dc21ae205cd632f016d050f754fcc (patch)
treebcc9cae590590b7fb0d87af68441efdf8fea8729 /crawl-ref/source
parent197e914235a08d505781e2b75b69998e8452b051 (diff)
downloadcrawl-ref-37b869723d4dc21ae205cd632f016d050f754fcc.tar.gz
crawl-ref-37b869723d4dc21ae205cd632f016d050f754fcc.zip
[1739347] Fixed acquirement giving unwieldable weapons.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1814 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/effects.cc18
-rw-r--r--crawl-ref/source/item_use.cc19
-rw-r--r--crawl-ref/source/item_use.h3
3 files changed, 27 insertions, 13 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 6b5825d3a7..da910dbd3d 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -22,6 +22,7 @@
#include "beam.h"
#include "direct.h"
#include "hiscores.h"
+#include "item_use.h"
#include "itemname.h"
#include "itemprop.h"
#include "items.h"
@@ -1143,7 +1144,7 @@ bool acquirement(object_class_type force_class, int agent)
else
{
randart_properties_t proprt;
- for (int item_tries = 0; item_tries < 50; item_tries++)
+ for (int item_tries = 0; item_tries < 200; item_tries++)
{
// BCR - unique is now used for food quantity.
thing_created = items( unique, class_wanted, type_wanted, true,
@@ -1152,12 +1153,21 @@ bool acquirement(object_class_type force_class, int agent)
if (thing_created == NON_ITEM)
continue;
+ const item_def &doodad(mitm[thing_created]);
+ if (doodad.base_type == OBJ_WEAPONS
+ && !can_wield(&doodad, false, true))
+ {
+ destroy_item(thing_created);
+ thing_created = NON_ITEM;
+ continue;
+ }
+
// MT - Check: god-gifted weapons and armor shouldn't kill you.
// Except Xom.
if ((agent == GOD_TROG || agent == GOD_OKAWARU)
- && is_random_artefact(mitm[thing_created]))
+ && is_random_artefact(doodad))
{
- randart_wpn_properties( mitm[thing_created], proprt );
+ randart_wpn_properties( doodad, proprt );
// check vs stats. positive stats will automatically fall
// through. As will negative stats that won't kill you.
@@ -1176,7 +1186,7 @@ bool acquirement(object_class_type force_class, int agent)
if (thing_created == NON_ITEM)
{
- mpr("The demon of the infinite void smiles at you.");
+ mpr("The demon of the infinite void smiles upon you.");
return (false);
}
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 34ee576593..17c5f8d091 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -76,25 +76,28 @@ static bool enchant_armour( void );
// Rather messy - we've gathered all the can't-wield logic from wield_weapon()
// here.
-bool can_wield(const item_def *weapon, bool say_reason)
+bool can_wield(const item_def *weapon, bool say_reason,
+ bool ignore_temporary_disability)
{
#define SAY(x) if (say_reason) { x; } else
- if (you.duration[DUR_BERSERKER])
+ if (!ignore_temporary_disability && you.duration[DUR_BERSERKER])
{
SAY(canned_msg(MSG_TOO_BERSERK));
return false;
}
- if (you.attribute[ATTR_TRANSFORMATION] != TRAN_NONE
- && !can_equip( EQ_WEAPON ))
+ if (!ignore_temporary_disability
+ && you.attribute[ATTR_TRANSFORMATION] != TRAN_NONE
+ && !can_equip( EQ_WEAPON ))
{
SAY(mpr("You can't wield anything in your present form."));
return false;
}
- if (you.equip[EQ_WEAPON] != -1
- && you.inv[you.equip[EQ_WEAPON]].base_type == OBJ_WEAPONS
- && item_cursed( you.inv[you.equip[EQ_WEAPON]] ))
+ if (!ignore_temporary_disability
+ && you.equip[EQ_WEAPON] != -1
+ && you.inv[you.equip[EQ_WEAPON]].base_type == OBJ_WEAPONS
+ && item_cursed( you.inv[you.equip[EQ_WEAPON]] ))
{
SAY(mpr("You can't unwield your weapon to draw a new one!"));
return false;
@@ -113,7 +116,7 @@ bool can_wield(const item_def *weapon, bool say_reason)
}
}
- if (is_shield_incompatible(*weapon))
+ if (!ignore_temporary_disability && is_shield_incompatible(*weapon))
{
SAY(mpr("You can't wield that with a shield."));
return (false);
diff --git a/crawl-ref/source/item_use.h b/crawl-ref/source/item_use.h
index be9c28ff44..3ba4d11a00 100644
--- a/crawl-ref/source/item_use.h
+++ b/crawl-ref/source/item_use.h
@@ -104,7 +104,8 @@ struct item_def;
/* ***********************************************************************
* called from: food
* *********************************************************************** */
-bool can_wield(const item_def *weapon, bool say_why = false);
+bool can_wield(const item_def *weapon, bool say_why = false,
+ bool ignore_temporary_disability = false);
// last updated 12may2000 {dlb}
/* ***********************************************************************