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/tick.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/tick.go')
| -rw-r--r-- | internal/game/tick.go | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/internal/game/tick.go b/internal/game/tick.go index 3c3f1d3..4d037ec 100644 --- a/internal/game/tick.go +++ b/internal/game/tick.go @@ -82,7 +82,7 @@ func (g *Game) WanderTick() { continue } inst.WanderTickCounter++ - if inst.WanderTickCounter < inst.WanderInterval { + if float64(inst.WanderTickCounter) < inst.WanderInterval { continue } inst.WanderTickCounter = 0 @@ -144,40 +144,36 @@ func (g *Game) WanderTick() { } } -func (g *Game) WoodcuttingTick() { +func (g *Game) SharedDepletionTick() { + activeKeys := make(map[string]bool) + for _, sess := range g.Hub.AllSessions() { + p, ok := sess.Player.(*player.Player) + if !ok || p == nil || p.Action == nil || p.Action.Type != "gather" { + continue + } + if key, ok := p.Action.Data["instance_key"].(string); ok { + activeKeys[key] = true + } + } + all := g.World.AllSharedObjStates() for _, st := range all { if st.Depleted { continue } key := g.World.ObjStateKey(st.RoomID, st.DefID, st.Index) - choppers := g.countChoppers(st.RoomID, key) - if choppers > 0 { + if activeKeys[key] { if st.SharedTimer > 0 { st.SharedTimer-- } } else { - if st.SharedTimer < st.SharedMax { + if st.SharedTimer < int(st.SharedMax) { st.SharedTimer++ } } } } -func (g *Game) countChoppers(roomID int, instanceKey string) int { - count := 0 - for _, sess := range g.Hub.PlayersInRoom(roomID) { - p, ok := sess.Player.(*player.Player) - if !ok || p.Action == nil || p.Action.Type != "gather" { - continue - } - if key, ok := p.Action.Data["instance_key"].(string); ok && key == instanceKey { - count++ - } - } - return count -} - func (g *Game) legalMobExits(inst *world.MobInstance) []int { room, err := g.World.LoadRoom(inst.RoomID) if err != nil || len(room.Exits) == 0 { |
