summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/player.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-26 13:18:19 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-26 13:18:19 +0000
commitc96c36a0477909874c98bdbda3d13333ddb453e2 (patch)
tree0c2a18233a65c55086d640be41685824c12d782e /crawl-ref/source/player.cc
parenta2c2fe61d7f40cb8f5fecd84fdacfdf47d28f16a (diff)
downloadcrawl-ref-c96c36a0477909874c98bdbda3d13333ddb453e2.tar.gz
crawl-ref-c96c36a0477909874c98bdbda3d13333ddb453e2.zip
Implement FR 1894211: All transformations will now cause your equipment
to meld into your body than rather than being removed, so that when untransforming you don't have to put everything on again. * Wielded stuff cannot be melded, and does not yet use the autoswap function. * As before, the low-level transformation spells refuse to work with cursed equipment. * The messages are unnecessarily spammy if you change forms while already transformed (first everything is re-equipped, then unequipped again). Conversely, on simply untransforming the lack of messages might be confusing. * Might be buggy, feedback welcome! git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7300 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/player.cc')
-rw-r--r--crawl-ref/source/player.cc41
1 files changed, 35 insertions, 6 deletions
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 1e38fb5282..d79d211372 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -588,6 +588,29 @@ bool player_has_feet()
return (true);
}
+bool you_tran_can_wear(const item_def &item)
+{
+ switch (item.base_type)
+ {
+ case OBJ_WEAPONS:
+ return you_tran_can_wear(EQ_WEAPON);
+
+ case OBJ_JEWELLERY:
+ return you_tran_can_wear(jewellery_is_amulet(item) ? EQ_AMULET
+ : EQ_LEFT_RING);
+ case OBJ_ARMOUR:
+ if (item.sub_type == ARM_CAP)
+ {
+ const int transform = you.attribute[ATTR_TRANSFORMATION];
+ return (transform != TRAN_BAT && transform != TRAN_AIR);
+ }
+ return you_tran_can_wear(get_armour_slot(item), true);
+
+ default:
+ return (true);
+ }
+}
+
bool you_tran_can_wear(int eq, bool check_mutation)
{
// Not a transformation, but also temporary -> check first.
@@ -605,14 +628,14 @@ bool you_tran_can_wear(int eq, bool check_mutation)
}
}
- int transform = you.attribute[ATTR_TRANSFORMATION];
+ const int transform = you.attribute[ATTR_TRANSFORMATION];
// No further restrictions.
if (transform == TRAN_NONE || transform == TRAN_LICH)
return (true);
- // Bats cannot use anything, clouds obviously so.
- if (transform == TRAN_BAT || transform == TRAN_AIR)
+ // Bats cannot wear anything except amulets, clouds obviously nothing.
+ if (transform == TRAN_BAT && eq != EQ_AMULET || transform == TRAN_AIR)
return (false);
// Everyone else can wear jewellery, at least.
@@ -730,6 +753,9 @@ bool berserk_check_wielded_weapon()
// Returns number of matches (in the case of rings, both are checked)
int player_equip( equipment_type slot, int sub_type, bool calc_unid )
{
+ if (!you_tran_can_wear(slot))
+ return (0);
+
int ret = 0;
switch (slot)
@@ -826,6 +852,9 @@ int player_equip( equipment_type slot, int sub_type, bool calc_unid )
// and armour type-id on wield/wear.
int player_equip_ego_type( int slot, int special )
{
+ if (!you_tran_can_wear(slot))
+ return (0);
+
int ret = 0;
int wpn;
@@ -1960,10 +1989,10 @@ int player_AC(void)
for (i = EQ_CLOAK; i <= EQ_BODY_ARMOUR; i++)
{
- if ( i == EQ_SHIELD )
+ if (i == EQ_SHIELD)
continue;
- if ( you.equip[i] == -1 )
+ if (you.equip[i] == -1 || !you_tran_can_wear(you.equip[i]))
continue;
const item_def& item = you.inv[you.equip[i]];
@@ -4416,7 +4445,7 @@ int scan_randarts(randart_prop_type which_property, bool calc_unid)
{
const int eq = you.equip[i];
- if (eq == -1)
+ if (eq == -1 || !you_tran_can_wear(eq))
continue;
// Only weapons give their effects when in our hands.