From 09d325dcf5e779eab5550d3fd3377bde50101428 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 8 Jul 2026 19:59:14 -0400 Subject: feat: unify on use, on look, and on kill. all support same conditions/actions now. --- internal/player/player.go | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'internal/player') 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 { -- cgit v1.2.3