aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_attack.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/cmd_attack.go')
-rw-r--r--internal/game/cmd_attack.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/internal/game/cmd_attack.go b/internal/game/cmd_attack.go
index 2f79c16..ef80189 100644
--- a/internal/game/cmd_attack.go
+++ b/internal/game/cmd_attack.go
@@ -131,8 +131,9 @@ func (g *Game) startCombat(sess *net.Session, p *player.Player, mob *world.MobIn
styleStr = " Style: " + string(p.AttackStyle) + " (" + strings.Join(styleParts, ", ") + ")"
}
sess.WriteLine(fmt.Sprintf("\nYou attack %s!%s", mobDisplayName(mob, true), styleStr))
+ p.ActionState = &ActionState{Type: ActionCombating, TargetName: mob.Name}
- g.Ticks.Subscribe(playerSpeed, func() bool {
+ g.Ticks.Subscribe(g.computeTicks(playerSpeed), func() bool {
cs := combat.GetCombat(p.Name)
if cs == nil || !cs.Active {
return false
@@ -150,7 +151,7 @@ func (g *Game) startCombat(sess *net.Session, p *player.Player, mob *world.MobIn
return true
})
- g.Ticks.Subscribe(mob.Speed, func() bool {
+ g.Ticks.Subscribe(g.computeTicks(mob.Speed), func() bool {
cs := combat.GetCombat(p.Name)
if cs == nil || !cs.Active {
return false
@@ -277,6 +278,7 @@ func (g *Game) mobAttack(sess *net.Session, p *player.Player, mob *world.MobInst
func (g *Game) endCombat(sess *net.Session, p *player.Player, mob *world.MobInstance) {
g.combatPadWidth = 0
combat.LeaveCombat(p.Name)
+ p.ActionState = nil
if p.HP <= 0 {
sess.WriteLine("\nOh dear, you are dead!")
@@ -340,9 +342,9 @@ func (g *Game) endCombat(sess *net.Session, p *player.Player, mob *world.MobInst
}
}
- respawnTicks := mob.RespawnTicks
+ respawnTicks := g.computeTicks(mob.RespawnTicks)
if respawnTicks <= 0 {
- respawnTicks = 30
+ respawnTicks = g.computeTicks(30)
}
instanceID := mob.InstanceID
g.Ticks.Subscribe(respawnTicks, func() bool {
@@ -467,12 +469,12 @@ func (g *Game) respawnMob(instanceID string) {
}
}
-func (g *Game) playerWeaponSpeed(p *player.Player) int {
+func (g *Game) playerWeaponSpeed(p *player.Player) float64 {
if itemID, ok := p.Equipment[object.SlotMainHand]; ok {
def, err := g.ItemStore.Load(itemID)
if err == nil && def.Speed > 0 {
return def.Speed
}
}
- return 5
+ return 5.0
}