From 6e6c4a157564100249bb58f412485055bb2d10cf Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 17 Jul 2026 17:12:39 -0400 Subject: feat: implement run energy, shorten walk time to 1-2 ticks between rooms, update graceful set --- internal/player/player.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'internal/player') diff --git a/internal/player/player.go b/internal/player/player.go index d78ae9d..ef3acb3 100644 --- a/internal/player/player.go +++ b/internal/player/player.go @@ -184,6 +184,7 @@ type Player struct { MoveDirection string `yaml:"-"` MoveTarget int `yaml:"-"` MovePendingTrigger *behavior.Trigger `yaml:"-"` + MoveUsesEnergy bool `yaml:"-"` VisualTickCurrent int `yaml:"-"` AutotriggerMod string `yaml:"-"` QueuedTrigger string `yaml:"-"` @@ -191,6 +192,8 @@ type Player struct { HazardTimer int `yaml:"-"` PendingDangerDir string `yaml:"-"` Battery float64 `yaml:"battery"` + RunEnergy int `yaml:"run_energy,omitempty"` + RunEnergyAccum int `yaml:"-"` ActiveTechs map[string]bool `yaml:"-"` QuickTech string `yaml:"quick_tech,omitempty"` TechActivatedSinceTick map[string]bool `yaml:"-"` @@ -231,6 +234,7 @@ func (p *Player) ClearMoveState() { p.MoveDirection = "" p.MoveTarget = 0 p.MovePendingTrigger = nil + p.MoveUsesEnergy = false } func (p *Player) OptionBool(name string) bool { @@ -352,6 +356,7 @@ func New(name string) *Player { p.Skills[Hitpoints] = XPForLevel(10) p.HP = p.MaxHP() p.Battery = p.MaxBattery() + p.RunEnergy = p.MaxRunEnergy() return p } @@ -467,6 +472,25 @@ func (p *Player) MaxBattery() float64 { return float64(p.Level(Technology)) } +// MaxRunEnergy is 3x the player's Agility level (the OSRS-inspired cap). +func (p *Player) MaxRunEnergy() int { + return 3 * p.Level(Agility) +} + +func (p *Player) HasRunEnergy() bool { + return p.RunEnergy > 0 +} + +// ClampRunEnergy caps current run energy to the player's current maximum. +// Called whenever the Agility level can change (XP gains) since leveling up +// raises the cap but should not auto-refill the missing energy. +func (p *Player) ClampRunEnergy() { + max := p.MaxRunEnergy() + if p.RunEnergy > max { + p.RunEnergy = max + } +} + func (p *Player) HasActiveTech(techID string) bool { if p.ActiveTechs == nil { return false -- cgit v1.2.3