Project Zomboid

Project Zomboid

Act Undead
 This topic has been pinned, so it's probably important
Burryaga  [developer] 24 Jun, 2024 @ 7:06am
Act Undead Framework Guide
Using Act Undead as a framework can offer several opportunities that modders may appreciate. This mod can be used to easily add custom animations, sound effects, and events that trigger while players are acting undead.

Animations and Sounds

The following code demonstrates how custom player-zombie animations and sound scripts can be both added to and removed from this mod to suit the preferences of future modders.
-- Somewhere in media/lua/client: ActUndead = require("ActUndead/Main") -- The zombieWalkType can be used as a flag in your xml AnimSet files. ActUndead.addAnimation("zombieWalkTypeForCustomWalk", "walk") ActUndead.addAnimation("zombieWalkTypeForCustomSprint", "sprint") -- These sound object names are defined in the scripts folder. -- Their scripts point to .ogg files in the sound folder. -- Sounds available to males and females by default. ActUndead.addSound("soundScriptName") ActUndead.addSound("soundScriptName", "female") -- Sounds and animations are removed exactly as they are added. ActUndead.removeAnimation("zombieWalkTypeCustomRun", "run") ActUndead.removeSound("soundScriptName", "male") ActUndead.removeSound("soundScriptName") -- You can also add or remove indexed lists (works with automaatic indexing). -- By default, sprinting animations are just faster versions of running, but this is a sandbox option. local zombieWalkTypes = { "customDash1", "customDash2", "customDash3" } ActUndead.addAnimationList(zombieWalkTypes, "sprint") local soundDefinitions = { "ShamblingShoutOops", "ShamblingStubbedToe", "ShamblingRanIntoTree" } ActUndead.removeSoundList(soundDefinitions)
The included sounds are extracted from the vanilla game's FMOD bank files.

Custom Event Handling

Use the following examples as a guide to attach your own functions to the new events added by this mod!

-- Using modules will make it easier for other modders to patch or extend your code. local Module = {} -- The variable "now" is the result of getTimestampMs() very shortly before the event fires. Module.zombiesListen = function(player, range) -- Whatever you want to do. end Events.OnShamblingPlayerMoaning.Add(Module.zombiesListen) Module.zombiesReact = function(playerIndex, player, now, reasons) -- Whatever you want to do. end Events.OnShamblingPlayerRevealed.Add(Module.zombiesReact) Module.blessingEffects = function(player, timeUnseen) -- Whatever you want to do. end Events.OnShamblingPlayerMisfortune.Add(Module.blessingEffects) Module.extraConsequences = function(playerIndex, player, now, activity) -- Whatever you want to do. end Events.OnShamblingPlayerConsequence.Add(Module.extraConsequences) Module.theySmellBlood = function(player, now) -- Whatever you want to do. end Events.OnShamblingBloodSmellAlert.Add(Module.theySmellBlood) -- Don't forget to export your module at the end of your file so that others can use it! return Module

Now you know, and knowing is half the battle! Take this data and go be dangerous. Happy modding! Remember, if you need help, I don't mind direct messages via Discord. You can also ping me (Burryaga) in either the official Project Zomboid server[discord.gg] or the Project Zomboid Modding Community server[discord.gg] if you're feeling social!