TungstenX Posted February 9, 2024 Posted February 9, 2024 Good day, I'm making a mod and would like to spawn a mannequin or corpse when player does xyz. I've looked at a few solution but it is not quit what I'm looking for. E.g. the solution (AddWorldInventoryItem) in the following topic will show the "icon" of the corpse, i.e. Base.CorpseMale (https://pzwiki.net/wiki/PZwiki:Item_List#Corpse) Is there a way to spawn the "model" of a mannequin or a corpse immediate given the player's coordinates? In other words, the mannequin will appear next to the player when the player does xyz.
Hugo Qwerty Posted February 10, 2024 Posted February 10, 2024 Not something I've done, but you probably want to look at: https://zomboid-javadoc.com/41.78/zombie/iso/objects/IsoMannequin.html I assume you create the mannequin using the 2nd constructor, then call addToWorld() You could also look at how this mod does it: https://steamcommunity.com/sharedfiles/filedetails/?id=2866782076&searchtext=fred TungstenX 1
TungstenX Posted February 10, 2024 Author Posted February 10, 2024 Thank you @Hugo Qwerty Will have a look
TungstenX Posted March 1, 2024 Author Posted March 1, 2024 Here is how the function evolved so far. It is not working properly, seem to only work once. I need to figure out how to dress it and change poses. Also having issue with sprite for mannequin. Currently I'm calling this method via a context menu to speed up the testing function spawn(x, y, z) local player = getPlayer() local modData = player:getModData() -- Check if mannequin was spawned before - Only one if modData and modData.manny then local gmsc = modData.manny if gmsc.spawned then -- already spawned return end end -- Where to put Manny local targetSquare = getSquare(x,y,z) -- TODO: figure out direction to face local facingDir = "E" -- Create a Mannequin as a Manny -- TODO: That sprite thingy local newMannequin = IsoMannequin.new(player:getCell(), targetSquare, getSprite("Base.MannequinScarecrow01")) newMannequin:setSquare(targetSquare) --TODO: Dress mannequin, change pose --update direction newMannequin:setDir(IsoDirections[facingDir]) -- This is not working, why? -- This throws an error --newMannequin:addToWorld() -- Copy and paste, no idea what it does for i = 1, newMannequin:getContainerCount() do newMannequin:getContainerByIndex(i - 1):setExplored(true); end -- always on top, not working --targetSquare:AddSpecialObject( newMannequin ) -- Not sure about this if isClient() then newMannequin:transmitCompleteItemToServer() end -- Jumping the hoops, not sure if all is needed? triggerEvent("OnObjectAdded", newMannequin) getTileOverlays():fixTableTopOverlays(targetSquare) targetSquare:RecalcProperties() targetSquare:RecalcAllWithNeighbours(true) triggerEvent("OnContainerUpdate") IsoGenerator.updateGenerator(targetSquare) -- Add to player's modData modData.manny = {} modData.manny.mannequinObject = newMannequin; modData.manny.spawned = true; end Is this approach correct? Is there a better way to do it? That sprite thingy?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now