diff options
| author | historia <[not public]> | 2026-07-17 17:12:39 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-17 17:12:39 -0400 |
| commit | 6e6c4a157564100249bb58f412485055bb2d10cf (patch) | |
| tree | d457414b989e737287384f87004bffa70ac23886 /internal/player | |
| parent | e09e7badbc722f580a9d7674c46d6ff3cc320b26 (diff) | |
| download | thehouseoficarus-6e6c4a157564100249bb58f412485055bb2d10cf.tar.gz | |
feat: implement run energy, shorten walk time to 1-2 ticks between rooms, update graceful set
Diffstat (limited to 'internal/player')
| -rw-r--r-- | internal/player/player.go | 24 |
1 files changed, 24 insertions, 0 deletions
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 |
