diff options
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 { |
