Project Zomboid

Project Zomboid

Angry Turrets
Candy Pants 29 Mar, 2023 @ 7:30pm
Strange lag...
If I have this mod enabled, I get a strange stuttering when I'm at my base. Disabling the mod seems to fix it but I'm not sure what's causing it...
< >
Showing 1-4 of 4 comments
Taiga 12 Apr, 2023 @ 3:24pm 
Sadly we get lots of lag when there's more than like two or three active at any one time. Im hoping this can be fixed.
The Z  [developer] 18 Apr, 2023 @ 3:50pm 
Each Active Turret (ammo in it makes it active) adding a search each time its is ready to shot.
If you got couple of them active near you (about 200 tiles around you) - you will have an additional CPU load. So, if you feel unacceptable lag for you - reduce an amount of turrets, make the game lighter by lower your display settings such as texture resolution, upgrade your PC or just stop using them for now until PZ will receive a global performance optimization.
Sadly I could not see any links to this mod on github, but I have a recommendation to make :)

I noticed you call getGameTime():getRealworldSecondsSinceLastUpdate() a few times in AT_TurretUpdate function.

I'd like to recommend setting this at the top of AT_AngryTurretsServerUpdate:

local gameTime
local timeSinceLastUpdate = 0
Events.OnGameTimeLoaded.Add(function()
gameTime = GameTime.getInstance()
end)


Then in DoZTurretJob() you could just add
timeSinceLastUpdate = gameTime:getMultipliedSecondsSinceLastUpdate()

And in AT_TurretUpdate() you could update reloadtime and aimingtime according to that value instead :)

That way you you will not only call the java function only once, but even the time will be reused during the tick, all the turrets will go through timeSinceLastUpdate each tick anyway so it will not get "out of date" during runtime.

Also MultipliedSeconds takes into accound game-speed!

Thank you for your time and I hope you get this.
The Z  [developer] 26 Nov, 2023 @ 4:22am 
@Leif G. W. Persson got your point, thank you. This will not happen next day, but I'll use your improvement in future update. Thank you for your contribution :)
< >
Showing 1-4 of 4 comments
Per page: 1530 50