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/world | |
| parent | 1aba2bdd23aebed4032333e74aa553c40a31fcbd (diff) | |
| download | thehouseoficarus-a6f0ad79e2e3a5b7c11eef1ffc3233f3a2766f77.tar.gz | |
feat: fractional ticks and server game_speed implemented. potentially insanely janky.
Diffstat (limited to 'internal/world')
| -rw-r--r-- | internal/world/mob.go | 10 | ||||
| -rw-r--r-- | internal/world/room.go | 6 | ||||
| -rw-r--r-- | internal/world/world.go | 26 |
3 files changed, 21 insertions, 21 deletions
diff --git a/internal/world/mob.go b/internal/world/mob.go index 59c8a20..c161e10 100644 --- a/internal/world/mob.go +++ b/internal/world/mob.go @@ -28,11 +28,11 @@ type MobDef struct { Strength int `yaml:"strength"` Defense int `yaml:"defense"` HP int `yaml:"hp"` - Speed int `yaml:"speed"` + Speed float64 `yaml:"speed"` Aggressive bool `yaml:"aggressive"` Protected bool `yaml:"protected"` Unique bool `yaml:"unique"` - RespawnTicks int `yaml:"respawn_ticks"` + RespawnTicks float64 `yaml:"respawn_ticks"` Drops DropTable `yaml:"drops"` } @@ -46,17 +46,17 @@ type MobInstance struct { Attack int Strength int Defense int - Speed int + Speed float64 Aggressive bool Protected bool Unique bool - RespawnTicks int + RespawnTicks float64 RoomID int HomeRoomID int Drops DropTable IdleDescription string WanderRooms []int - WanderInterval int + WanderInterval float64 WanderTickCounter int regenerateTick int } diff --git a/internal/world/room.go b/internal/world/room.go index 46fb876..16fd3fd 100644 --- a/internal/world/room.go +++ b/internal/world/room.go @@ -43,7 +43,7 @@ var ExitOrder = []ExitDir{ type SpawnDef struct { ItemID string `yaml:"item_id"` Quantity int `yaml:"quantity"` - RespawnTicks int `yaml:"respawn_ticks"` + RespawnTicks float64 `yaml:"respawn_ticks"` } type ExitDef struct { @@ -80,7 +80,7 @@ type Room struct { type RoomMob struct { ID string `yaml:"id"` WanderRooms []int `yaml:"wander_rooms"` - WanderInterval int `yaml:"wander_interval"` + WanderInterval float64 `yaml:"wander_interval"` } func (rm *RoomMob) UnmarshalYAML(value *yaml.Node) error { @@ -104,5 +104,5 @@ type EnterStep struct { type RoomObject struct { ID string `yaml:"id"` WanderRooms []int `yaml:"wander_rooms"` - WanderInterval int `yaml:"wander_interval"` + WanderInterval float64 `yaml:"wander_interval"` } diff --git a/internal/world/world.go b/internal/world/world.go index ac5345e..a554432 100644 --- a/internal/world/world.go +++ b/internal/world/world.go @@ -54,18 +54,18 @@ type ObjMove struct { type ObjState struct { Depleted bool - DepleteTimer int + DepleteTimer float64 DefID string Name string Index int RoomID int JustRespawned bool WanderRooms []int - WanderInterval int + WanderInterval float64 WanderCounter int - SharedMax int + SharedMax float64 SharedTimer int - Quality int + Quality float64 } func (w *World) ObjStateKey(roomID int, defID string, index int) string { @@ -102,7 +102,7 @@ func (w *World) ensureObjectStatesLocked(roomID int, defIDs []string) { } } -func (w *World) AddObjInstance(roomID int, defID string, quality int) { +func (w *World) AddObjInstance(roomID int, defID string, quality float64) { w.mu.Lock() defer w.mu.Unlock() if w.objStates == nil { @@ -250,7 +250,7 @@ func (w *World) SetObjName(roomID int, defID string, name string) { } } -func (w *World) SetObjWander(roomID int, defID string, rooms []int, interval int) { +func (w *World) SetObjWander(roomID int, defID string, rooms []int, interval float64) { w.mu.Lock() defer w.mu.Unlock() for _, st := range w.objStates { @@ -261,13 +261,13 @@ func (w *World) SetObjWander(roomID int, defID string, rooms []int, interval int } } -func (w *World) SetObjDepleteTimer(roomID int, defID string, max int) { +func (w *World) SetObjDepleteTimer(roomID int, defID string, max float64) { w.mu.Lock() defer w.mu.Unlock() for _, st := range w.objStates { if st.RoomID == roomID && st.DefID == defID && st.SharedMax == 0 { st.SharedMax = max - st.SharedTimer = max + st.SharedTimer = int(max) } } } @@ -284,7 +284,7 @@ func (w *World) AllSharedObjStates() []*ObjState { return out } -func (w *World) SetObjDepleted(roomID int, defID string, index int, delay int) { +func (w *World) SetObjDepleted(roomID int, defID string, index int, delay float64) { w.mu.Lock() defer w.mu.Unlock() key := w.objStateKey(roomID, defID, index) @@ -486,7 +486,7 @@ func (w *World) SeedGroundItems(roomID int) { e.quantity += s.Quantity e.respawnQty += s.Quantity e.isSpawn = true - e.respawnDelay = s.RespawnTicks + e.respawnDelay = int(s.RespawnTicks) merged = true break } @@ -496,7 +496,7 @@ func (w *World) SeedGroundItems(roomID int) { itemID: s.ItemID, quantity: s.Quantity, isSpawn: true, - respawnDelay: s.RespawnTicks, + respawnDelay: int(s.RespawnTicks), respawnQty: s.Quantity, } w.groundItems[roomID] = append(w.groundItems[roomID], e) @@ -545,7 +545,7 @@ func (w *World) Tick() { st.Depleted = false st.JustRespawned = true if st.SharedMax > 0 { - st.SharedTimer = st.SharedMax + st.SharedTimer = int(st.SharedMax) } } } @@ -577,7 +577,7 @@ func (w *World) TickObjWander() { continue } st.WanderCounter++ - if st.WanderCounter >= st.WanderInterval { + if float64(st.WanderCounter) >= st.WanderInterval { st.WanderCounter = 0 toRoom := st.WanderRooms[rand.Intn(len(st.WanderRooms))] if toRoom == st.RoomID { |
