aboutsummaryrefslogtreecommitdiff
path: root/internal/game/combat_attack.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/combat_attack.go')
-rw-r--r--internal/game/combat_attack.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/internal/game/combat_attack.go b/internal/game/combat_attack.go
index 180038b..3cbb9c8 100644
--- a/internal/game/combat_attack.go
+++ b/internal/game/combat_attack.go
@@ -116,6 +116,7 @@ func (g *Game) findMob(sess *net.Session, input string, roomID int) *world.MobIn
if idx-1 < len(candidates) {
return candidates[idx-1]
}
+ sess.WriteLine(fmt.Sprintf("There's no '%s' here.", input))
return nil
}
@@ -134,6 +135,14 @@ func (g *Game) findMob(sess *net.Session, input string, roomID int) *world.MobIn
return candidates[0]
}
+// leaveCombat ends the player's combat and clears any stashed flee state.
+// Combat.Leave alone leaves EscapeDir/Target/IsWalk set with no move in flight,
+// so the next mob miss would start an unprompted escape in the stale direction.
+func (g *Game) leaveCombat(p *player.Player) {
+ g.Combat.Leave(p.Name)
+ p.ClearEscape()
+}
+
func (g *Game) startCombat(sess *net.Session, p *player.Player, mob *world.MobInstance) {
// One player fights one mob at a time. doAttack and the aggro path already
// check this, but act_steal/act_talk call startCombat directly; without the
@@ -447,7 +456,7 @@ func (g *Game) applyPlayerHit(sess *net.Session, p *player.Player, mob *world.Mo
if isRanged && p.AmmoQty <= 0 {
sess.WriteLine("You've run out of ammo!")
- g.Combat.Leave(p.Name)
+ g.leaveCombat(p)
}
}
@@ -458,7 +467,7 @@ func (g *Game) applyPlayerMiss(sess *net.Session, p *player.Player, mob *world.M
g.consumeAmmo(p)
if p.AmmoQty <= 0 {
sess.WriteLine("You've run out of ammo!")
- g.Combat.Leave(p.Name)
+ g.leaveCombat(p)
}
}
}