server/npc_regeneration.go (1301B)
1 package main 2 3 import "time" 4 5 func (server *server) advanceNPCRegeneration(now time.Time, updates map[*worldClient][][]byte) { 6 for _, npc := range server.simulationNPCs(now) { 7 if npc.health == 0 { 8 continue 9 } 10 if npc.regenerationAt.IsZero() { 11 npc.regenerationAt = now 12 continue 13 } 14 if now.Sub(npc.regenerationAt) < 2*time.Second { 15 continue 16 } 17 // Preserve the phase across combat transitions and skip scheduler backlogs. 18 intervals := now.Sub(npc.regenerationAt) / (2 * time.Second) 19 npc.regenerationAt = npc.regenerationAt.Add(intervals * 2 * time.Second) 20 npc.regenerationSeconds += 2 21 22 // kkr.dll FUN_1006ea50: NPC idle recovery replaces delta and interval. 23 // NPC spawns retain native defaults: interval 30, delta 3, BodyDevelopment 24 // below RestModifier 100, and stat 519 = 0, independent of species/level. 25 health := npc.health 26 if npc.fighting == 0 { 27 npc.health = min(npc.maximumHealth(), npc.health+max(1, npc.maximumHealth()/120)) 28 } else if npc.regenerationSeconds%60 == 0 { 29 npc.health = min(npc.maximumHealth(), npc.health+3) 30 } 31 32 // Publish recovery during combat; the HealthDamage receiver reconciles queued results. 33 if npc.health != health { 34 server.queueHealthSnapshot(updates, npc) 35 } else { 36 server.queueQuietHealth(updates, npc) 37 } 38 } 39 }