diff options
Diffstat (limited to 'internal/game/combat_mob.go')
| -rw-r--r-- | internal/game/combat_mob.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/internal/game/combat_mob.go b/internal/game/combat_mob.go index b16e4e1..b717d8e 100644 --- a/internal/game/combat_mob.go +++ b/internal/game/combat_mob.go @@ -174,7 +174,7 @@ func (g *Game) applyMobHit(sess *net.Session, p *player.Player, mob *world.MobIn sess.WriteLine(g.colorize(sess, "miss", fmt.Sprintf("You power through %s's relentless attacks and just flee!", mobDisplayName(mob, false)))) - g.beginEscapeMove(p) + g.beginEscapeMove(sess, p) } else { p.ClearEscape() p.WalkSequence = nil @@ -209,7 +209,7 @@ func (g *Game) applyMobMiss(sess *net.Session, p *player.Player, mob *world.MobI sess.WriteLine(g.colorize(sess, "miss", fmt.Sprintf("%s misses you.", attacker))) if p.EscapeDir != "" { - g.beginEscapeMove(p) + g.beginEscapeMove(sess, p) } } @@ -252,7 +252,7 @@ func (g *Game) endCombat(sess *net.Session, p *player.Player, mob *world.MobInst } if p.EscapeDir != "" { - g.beginEscapeMove(p) + g.beginEscapeMove(sess, p) return } @@ -459,14 +459,11 @@ func (g *Game) stopCombat(playerName string) { // beginEscapeMove starts the actual movement after the escape gate (a mob // miss, a mob death, or the 3-strike "power through" relief) has fired. It // copies the stashed Escape* fields into the Move* fields, recomputes -// moveTicks, sets MoveTicks for the normal 1-2 tick run delay, and records -// whether completion should drain run energy. -// -// beginEscapeMove is only reachable when doMove's in-combat branch stashed the -// escape, and that branch is itself gated on moveTicks returning > 0; the -// Cape-of-Agility / GodMode 0-tick bypass never enters the stash path, so there -// is no 0-tick branch to handle here. -func (g *Game) beginEscapeMove(p *player.Player) { +// moveTicks, and either completes an instant 0-tick move (Cape of Agility or +// GodMode acquired while the escape was pending) or sets MoveTicks for the +// normal 1-2 tick run delay and records whether completion should drain run +// energy. +func (g *Game) beginEscapeMove(sess *net.Session, p *player.Player) { p.MoveDirection = p.EscapeDir p.MoveTarget = p.EscapeTarget p.MovePendingTrigger = p.EscapeTrigger @@ -476,5 +473,14 @@ func (g *Game) beginEscapeMove(p *player.Player) { ticks, usesEnergy := g.moveTicks(p, isWalk) p.MoveUsesEnergy = usesEnergy + if ticks <= 0 { + // The player may have gained instant-move gear (Cape of Agility) or + // GodMode after the escape was stashed but before the gate fired, so + // moveTicks can now return 0 here even though doMove's stash branch + // required >0 at stash time. Complete the move instead of leaving it + // stuck at MoveTicks==0 forever. + g.completeMove(sess, p) + return + } p.MoveTicks = ticks } |
