|
From: <gi...@cr...> - 2025-12-04 18:55:15
|
via 3d4d16ab83bbe094104be8b285b3eb9804d19e27 (commit)
from 5710f06dab9fdb6eec60da92f0b4cf3a83d82427 (commit)
-----------------------------------------------------------------------
commit 3d4d16ab83bbe094104be8b285b3eb9804d19e27
Author: DracoOmega <dra...@gm...>
Date: Thu Dec 4 15:21:31 2025 -0330
Fix player orbs often preventing blocks from working (WizardIke)
An orb the player had equipped would be returned by you.shield(), despite
not being a shield. This had the indirect effect of preventing the player
from blocking many things, due to the block limit of an orb being 0.
(Whereas not having any 'shield' at all gives a block limit of 1). This
meant that, no matter how many other sources of SH the player might have,
such as amulets of reflection, Qazlal, or mutations, they would be unable
to block. Even Divine Shield didn't work on spell projectiles (though, by
coincidental differences in codepath, it did work on melee and ranged
attacks).
Now player::shield() can only return actual shields (amusingly enough,
monster::shield() did already work properly). actor::offhand_item() is
added for the few cases where we just want to know if some non-weapon is
taking up that slot, whether a shield or not.
-----------------------------------------------------------------------
Summary of changes:
crawl-ref/source/actor.h | 1 +
crawl-ref/source/hints.cc | 5 +----
crawl-ref/source/mon-cast.cc | 2 +-
crawl-ref/source/monster.cc | 9 +++++++--
crawl-ref/source/monster.h | 1 +
crawl-ref/source/ng-setup.cc | 2 +-
crawl-ref/source/player-act.cc | 8 +++++++-
crawl-ref/source/player.cc | 7 ++++---
crawl-ref/source/player.h | 1 +
9 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h
index 99e145e030..90bd728fcd 100644
--- a/crawl-ref/source/actor.h
+++ b/crawl-ref/source/actor.h
@@ -104,6 +104,7 @@ public:
bool rescale = true) const = 0;
virtual int has_claws(bool allow_tran = true) const = 0;
virtual item_def *shield() const = 0;
+ virtual item_def *offhand_item() const = 0;
virtual item_def *body_armour() const = 0;
virtual int wearing(object_class_type obj_type, int sub_type,
bool count_plus = 0, bool check_attuned = false) const = 0;
diff --git a/crawl-ref/source/hints.cc b/crawl-ref/source/hints.cc
index f5f0247f8a..9f18733baf 100644
--- a/crawl-ref/source/hints.cc
+++ b/crawl-ref/source/hints.cc
@@ -1699,11 +1699,8 @@ void learned_something_new(hints_event_type seen_what, coord_def gc)
}
print_hint("HINT_YOU_MISCAST");
- if (!player_effectively_in_light_armour()
- || is_shield(you.shield()))
- {
+ if (!player_effectively_in_light_armour() || you.shield())
print_hint("HINT_MISCAST_ARMOUR");
- }
print_hint("HINT_MISCAST_CONTAMINATION_AND_MP");
break;
diff --git a/crawl-ref/source/mon-cast.cc b/crawl-ref/source/mon-cast.cc
index f38a4f5db1..6e9be72ea8 100644
--- a/crawl-ref/source/mon-cast.cc
+++ b/crawl-ref/source/mon-cast.cc
@@ -7003,7 +7003,7 @@ static void _cast_bestow_arms(monster& caster)
targs.push_back(*mi);
- if (!mi->shield())
+ if (!mi->offhand_item())
two_hand_eligable = true;
// Attempting to give a ranged weapon to a dual-wielder is strange
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 01cb4d9d5b..68f694d57b 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -2025,11 +2025,16 @@ item_def *monster::shield() const
{
item_def *shield = mslot_item(MSLOT_SHIELD);
- if (shield && shield->sub_type != ARM_ORB)
+ if (shield && is_shield(*shield))
return shield;
return nullptr;
}
+item_def *monster::offhand_item() const
+{
+ return mslot_item(MSLOT_SHIELD);
+}
+
item_def* monster::body_armour() const
{
return mslot_item(MSLOT_ARMOUR);
@@ -3030,7 +3035,7 @@ int monster::shield_class() const
{
int sh = 0;
const item_def *shld = shield();
- if (shld && is_shield(*shld))
+ if (shld)
{
// Look, this is all nonsense.
// First, take the item properties.
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index b8857736b6..60e27a90e5 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -300,6 +300,7 @@ public:
item_def *melee_weapon() const;
item_def *missiles() const;
item_def *shield() const override;
+ item_def *offhand_item() const override;
item_def *body_armour() const override;
item_def *get_defining_object() const;
diff --git a/crawl-ref/source/ng-setup.cc b/crawl-ref/source/ng-setup.cc
index 80e4c950a1..74ed9925c6 100644
--- a/crawl-ref/source/ng-setup.cc
+++ b/crawl-ref/source/ng-setup.cc
@@ -224,7 +224,7 @@ static void _give_job_spells(job_type job)
static void _give_offhand_weapon()
{
const item_def *wpn = you.weapon();
- if (!wpn || you.shield() || you.hands_reqd(*wpn) != HANDS_ONE)
+ if (!wpn || you.offhand_item() || you.hands_reqd(*wpn) != HANDS_ONE)
return;
if (is_range_weapon(*wpn))
{
diff --git a/crawl-ref/source/player-act.cc b/crawl-ref/source/player-act.cc
index d2265a8626..4638b01dd8 100644
--- a/crawl-ref/source/player-act.cc
+++ b/crawl-ref/source/player-act.cc
@@ -354,11 +354,17 @@ hands_reqd_type player::hands_reqd(const item_def &item, bool base) const
item_def *player::shield() const
{
item_def *offhand_item = you.equipment.get_first_slot_item(SLOT_OFFHAND, false);
- if (!offhand_item || offhand_item->base_type != OBJ_ARMOUR)
+ if (!offhand_item || !is_shield(*offhand_item))
return nullptr;
return offhand_item;
}
+// Returns any non-weapon item the player has in their offhand (ie: a shield or an orb)
+item_def *player::offhand_item() const
+{
+ return you.equipment.get_first_slot_item(SLOT_OFFHAND, false);
+}
+
item_def* player::body_armour() const
{
return you.equipment.get_first_slot_item(SLOT_BODY_ARMOUR);
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index c5d3d21751..9265c5990d 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -2296,7 +2296,7 @@ int player_shield_class(int scale, bool random, bool ignore_temporary)
return 0;
const item_def *shield_item = you.shield();
- if (is_shield(shield_item))
+ if (shield_item)
shield += _sh_from_shield(*shield_item);
// mutations
@@ -6111,8 +6111,9 @@ void player::shield_block_succeeded(actor *attacker)
shield_blocks++;
practise_shield_block();
- if (is_shield(shield()))
- count_action(CACT_BLOCK, shield()->sub_type);
+ item_def* sh = shield();
+ if (sh)
+ count_action(CACT_BLOCK, sh->sub_type);
else
count_action(CACT_BLOCK, -1, BLOCK_OTHER); // non-shield block
}
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 75721b3a0b..f61ceb3e64 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -705,6 +705,7 @@ public:
item_def *weapon(int which_attack = -1) const override;
item_def *body_armour() const override;
item_def *shield() const override;
+ item_def *offhand_item() const override;
item_def *offhand_weapon() const override;
item_def *active_talisman() const;
--
Dungeon Crawl Stone Soup
|