Project Zomboid

Project Zomboid

Angry Turrets
sasquatch 28 Aug, 2022 @ 9:49am
Code things!
I've been tweaking the original Sentry Turret mod too and I was wondering if you noticed the slowdown on large hordes of zombies yet. I've been using "Don't Feed the Zombies" to try to clear the map and I noticed that once a few hundred corpses piled up the inventory checks on the turrets for ammo were really slowing things down so I disabled ammo checks lol. I was thinking maybe putting the ammo into an integer and removing from the turrent inventory and adding a "Return Ammo" right-click option or something instead of doing container checks but I'm still in need of the unlimited ammo!

To compensate for slowdown I added a corpse sweep every couple of seconds and a second removal sweep if they detect over a threshold. I should probably have created a new item/object dedicated to this process but I just dumped it into the shotgun turret for now.

I also added a update to the player kill count on successful turret kills.

I just uploaded my modded files to github. Lol I wasn't expecting to share them so it's a real mess but let me know if you have any suggestions or comments!

https://github.com/afewvowels/zomboid-sentry-turret-rework/blob/main/media/lua/server/ST_TurretUpdate.lua

What's different about coding for MP v. SP mods?

Thanks!
< >
Showing 1-4 of 4 comments
The Z  [developer] 29 Aug, 2022 @ 8:45pm 
Hey, checked your code recently.
I personally think that you are doing it in a kinda rude way.
I didn't try to use "Don't feed the Zombies" mod, but I read its descriptions and as for me, the mod "Don't feed the Zombies" could produce a lot of load by itself just by leaving the loot from each zombie laying on a floor forever. But maybe I'm wrong and I didn't test it

White we ere developing Angry Turrets we faced a huge lag with some potentially working algorithms of detecting zeds in turrets range.

For example the algorithm which is used for SP in Sentry Turrets in case of MP almost stopped server from functioning by just 4 sniper turrets installed.

We tested a bunch of different ways of determinating the correct targets until came into the one, which we wrote just for exact case.

About containers check - no, I don't think that it could be a super heavy, it checks only containers of exact turrets locations, but not for rest of the things around.
But your idea about changing the ammo placed into containers just into a property of a turret - sounds great! It will have its own disadvantages something like - if the turret is destroyed - the all its ammo will be lost with it, or at least will not be dropped on a floor as its now by default.

About your MP/SP question.
You better to check this topic for the begging o learn more about concepts:
https://steamlists.com/project-zomboid-client-server-concept-script-guide/
and then just check some examples which are working with MP.

But if we will say with simple words:
In SP - all is happening in once side - player's pc.
In MP - all centralized part happens on Server and you need to take care to show all what is happening there to all players on their pcs (Client). If a player kills a zombie for ex. you need to inform Server that this specific zombie in the world is getting to be killed and server is responsible to tell this next to rest of the currently connected Clients.

Here, in Angry Turrets, for ex. we are taking care for ammo in containers to be synced for with other players in their containers to be consumed.

I don't thing that answered the exact thing you were asking for, but hopefully it could help you somehow in your ninja modding way ;) Good Luck.
sasquatch 30 Aug, 2022 @ 5:55pm 
Wow only 4 turrets lol. I'll have to take a closer look at your targeting algorithm and see what I can learn! I did get the feeling that just using 2 loops to check every square in around the turret would be inefficient. That's O(n^2) yeah? I'm using the nested loops on my custom edition of the Super Bulldozer which clears 50x50 tiles of trees/grass/bushes instead of the author's 2x2 square and boy does the framerate drop when I'm driving it lol.

Also I can't tell if it's something that I changed in my code but I noticed that I can place the turrets on water. Oops! :steamhappy:

Anyway thanks for the response and cool video for the mod!
Glytch3r 12 Sep, 2022 @ 5:16am 
hi can i get your discord link i have a few questions
pls send me a msg
Glytch3r#2892
sasquatch 2 Dec, 2022 @ 1:16am 
Originally posted by Glytch3r:
hi can i get your discord link i have a few questions
pls send me a msg
Glytch3r#2892

Hey sorry about not responding sooner, hit me up at AlienHerald#8950
< >
Showing 1-4 of 4 comments
Per page: 1530 50