diff options
| author | historia <[not public]> | 2026-06-14 22:38:23 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-14 22:38:23 -0400 |
| commit | a6f0ad79e2e3a5b7c11eef1ffc3233f3a2766f77 (patch) | |
| tree | 89601a502bbfcb50302cf03f09b6febc6040eeb0 /internal/game/cmd_attack.go | |
| parent | 1aba2bdd23aebed4032333e74aa553c40a31fcbd (diff) | |
| download | thehouseoficarus-a6f0ad79e2e3a5b7c11eef1ffc3233f3a2766f77.tar.gz | |
feat: fractional ticks and server game_speed implemented. potentially insanely janky.
Diffstat (limited to 'internal/game/cmd_attack.go')
| -rw-r--r-- | internal/game/cmd_attack.go | 14 |
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 } |
