aboutsummaryrefslogtreecommitdiff
path: root/internal/player
diff options
context:
space:
mode:
Diffstat (limited to 'internal/player')
-rw-r--r--internal/player/player.go29
1 files changed, 20 insertions, 9 deletions
diff --git a/internal/player/player.go b/internal/player/player.go
index fcf274b..f56521e 100644
--- a/internal/player/player.go
+++ b/internal/player/player.go
@@ -180,14 +180,13 @@ type Player struct {
WalkSequence []string `yaml:"-"`
ConsumeCooldown int `yaml:"-"`
HomeTransportCooldown int `yaml:"-"`
- MoveTicks int `yaml:"-"`
+ MoveTicks int `yaml:"-"`
MoveDirection string `yaml:"-"`
- MoveTarget int `yaml:"-"`
- MovePendingGlobalFlags map[string]any `yaml:"-"`
- MovePendingPlayerFlags map[string]any `yaml:"-"`
- VisualTickCurrent int `yaml:"-"`
- AutotriggerMod string `yaml:"-"`
- QueuedTrigger string `yaml:"-"`
+ MoveTarget int `yaml:"-"`
+ MovePendingInteraction *behavior.Interaction `yaml:"-"`
+ VisualTickCurrent int `yaml:"-"`
+ AutotriggerMod string `yaml:"-"`
+ QueuedTrigger string `yaml:"-"`
AttackTimer int `yaml:"-"`
HazardTimer int `yaml:"-"`
PendingDangerDir string `yaml:"-"`
@@ -219,8 +218,7 @@ func (p *Player) ClearMoveState() {
p.MoveTicks = 0
p.MoveDirection = ""
p.MoveTarget = 0
- p.MovePendingGlobalFlags = nil
- p.MovePendingPlayerFlags = nil
+ p.MovePendingInteraction = nil
}
func (p *Player) OptionBool(name string) bool {
@@ -402,6 +400,19 @@ func (p *Player) HasItem(itemID string) bool {
return false
}
+// IsWielding reports whether the given item is currently held in one of the
+// player's weapon-hand equipment slots (main_hand or off_hand). It is the
+// "wielding" predicate used to gate on_kill interactions whose item_id names
+// a specific weapon — two-handed weapons occupy main_hand alone, while dual
+// wield / weapon + shield uses both hands. Armor, ammo, ring, and tool slots
+// do NOT count as "wielding".
+func (p *Player) IsWielding(itemID string) bool {
+ if itemID == "" {
+ return false
+ }
+ return p.Equipment[item.SlotMainHand] == itemID || p.Equipment[item.SlotOffHand] == itemID
+}
+
func (p *Player) CountItem(itemID string) int {
count := 0
for _, slot := range p.Inventory {