Project Zomboid

Project Zomboid

Not enough ratings
getZombieByID
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
548.135 KB
30 Jul, 2023 @ 7:14pm
1 Change Note ( view )

Subscribe to download
getZombieByID

Description
Supports B41+. Built for Multiplayer.
A new save is not required



Description
In multiplayer, every Zombie that is processed by the game is assigned their own unique Online ID. This Online ID is persistent across all multiplayer clients, and is used by the game internally for a few things such as when a player attacks a zombie.
While you can get a zombie's Online ID, there is no functionality for modders to get a zombie by this Online ID. This means that performing an action on a zombie that is not already synced by the game is not easy and very slow to do, as you have to iterate over all zombies until you find a match.
Modders have gotten around this by using outfits and other things on zombies to make the game treat them differently, but even those systems have limitations and don't apply to ALL zombies.

getZombieByID solves this by periodically building a cache of all of the zombies around your current player, with the zombie's Online ID being the key to the cache.
With this you can pass the zombie's Online ID around using server commands, and each client is able to perform an action on the same zombie!

FOR GENERAL USERS
By itself, this mod does nothing and provides no functionality for your game. This is intended to be a modder's resource, and will be included as a requirement by other mods.
If you have no mods that require this, it is recommended to disable it in Multiplayer worlds. In singleplayer, this mod does nothing and will cause no additional load; it is safe to leave enabled.
Building the cache can be expensive as there could potentially be hundreds of zombies to iterate through, however, I have tried to optimize this as much as possible.

Configuration
A new option is available under the "Multiplayer" tab in the general options to set, in seconds, how often the zombie cache updates. By default, the cache is rebuilt every 120 seconds (2 minutes).

Compatibility
Should be compatible with everything.

Workshop ID: 3012642917
Mod ID: getZombieByID
Popular Discussions View All (1)
4
31 Jul, 2023 @ 1:19am
PINNED: How to use in your mods
dhert