Kyun Posted January 5, 2014 Share Posted January 5, 2014 Hi, I'm messing around with zeds and haven't succeded at checking if a zed is dead. Here's what i'm doing :-- spawning of a zedlocal zed = getVirtualZombieManager():createRealZombieNow(fromx, fromy, fromz); zed:setFakeDead(false);zed:setForceFakeDead(false);zed:PathTo(tox, toy, toz, true);table.insert(zedTable, zed);And to check if one have been killed :for _,v in pairs(zedTable) do if v:isDead() then print(v:toString() .. " is dead"); -- other stuff endendv:isDead() never returns true (of course I killed the zombie before triggering the function). I tried to check the objects on the IsoZombie square to find a IsoDeadBody, but it is not on the same square (it's also an ugly way to solve the problem ). Thanks,Kyun EDIT : if I don't kill the zombie with my axe and use v:Kill(nil) instead then v:isDead() do return true. Weird. Link to comment Share on other sites More sharing options...
RoboMat Posted January 5, 2014 Share Posted January 5, 2014 Try:if v:getHealth() == 0 then...instead. Maybe that one works. Link to comment Share on other sites More sharing options...
ExcentriCreation Posted January 6, 2014 Share Posted January 6, 2014 This seems odd to me, while experimenting with the "do not push this button" event in NecroForge (I didn't keep it in the released version), I used isDead() & it worked fine in a onTick event.... Maybe its because a corpse isn't an IsoGameCharacter?.... Like I said..... odd Link to comment Share on other sites More sharing options...
RoboMat Posted January 6, 2014 Share Posted January 6, 2014 I think the problem might come from this: public void Hit(HandWeapon weapon, IsoGameCharacter wielder, float damageSplit, boolean bIgnoreDamage, float modDelta) { super.Hit(weapon, wielder, damageSplit, bIgnoreDamage, modDelta); this.target = wielder; if (this.Health <= 0.0F) { if (!this.bDead) { DoZombieInventory(); LuaEventManager.triggerEvent("OnZombieDead", this); this.bDead = true; } } this.TimeSinceSeenFlesh = 0; }As it only sets the bDead variable of the IsoZombie and not the one of the superclass (no guarantee that this is correct, as I didn't spend too much time on reading through the java code).Why not use an alternative approach?[...]-- spawning of a zedlocal zed = getVirtualZombieManager():createRealZombieNow(fromx, fromy, fromz);zed:setFakeDead(false);zed:setForceFakeDead(false);zed:PathTo(tox, toy, toz, true);-- mark zombielocal md = zed:getModData();md.id = "SpecialZombieICreated";[...]-- called when zombie is killedlocal function check(_z) local z = _z; local md = z:getModData(); -- see if it is one of our marked zombies if md.id == "SpecialZombieICreated" then doAwesomeStuff(); else return; endendEvents.OnZombieDead.Add(check); ExcentriCreation and Kyun 2 Link to comment Share on other sites More sharing options...
ExcentriCreation Posted January 6, 2014 Share Posted January 6, 2014 IsoDeadBody is a derivative of IsoMovingObject not IsoGameCharacter. So both isDead() & getHealth() will return nill EDIT:In order to use those methods, you will have to call them before PZ turns Zed into IsoDeadBody(), like a onTick event Link to comment Share on other sites More sharing options...
Kyun Posted January 7, 2014 Author Share Posted January 7, 2014 Hi, Thanks a lot, you're both right, the super is not the same so ... (I also think a zed can have 0 health and not be dead; at 0 health if I gently push it bare handed, it dies on ground). OnTick is good but OnZombieDead is less ressource heavy The modData trick worked perfectly ! btw where did you find this event ?! I have this list :Event reference - Project Zomboid mods & tutorials EDIT : thanks a lot, got them all now Thanks again,Kyun Link to comment Share on other sites More sharing options...
RoboMat Posted January 7, 2014 Share Posted January 7, 2014 I've got it from the java source code. Check the LuaEventManager.class. Link to comment Share on other sites More sharing options...
ExcentriCreation Posted January 7, 2014 Share Posted January 7, 2014 Aye, modData would be better for what you were doing, I was just explaining how the dead bodies work. When I was experimenting with it I already had the onTick event so I could make them talk every so often..... ".. ONE .... OF .... US! .." ".. YOU .... ARE .... DAMNED! .." Link to comment Share on other sites More sharing options...
Kyun Posted January 7, 2014 Author Share Posted January 7, 2014 Yeah I use your mod, that "don't push it" really bugged me, I clicked, and died painfully , really usefull to play with stuff and test custom mods Looking forward to the parsing of custom items.txt (maybe you could use the receipes, and the items needed, to store almost all game items ?) ExcentriCreation 1 Link to comment Share on other sites More sharing options...
ExcentriCreation Posted January 7, 2014 Share Posted January 7, 2014 If it can be done it will be in ScriptManager, I overlooked it last time I tried Sorry bout bugging you.... It said not to push it Seriously though, it was either that or make a screamer (like the paranormal vids) & hook that up to the button.... I think the zombies were less of a dick move Link to comment Share on other sites More sharing options...
Kyun Posted January 7, 2014 Author Share Posted January 7, 2014 Hm, I'm don't think it's necessary to make another thread so I'll ask here Yeah, still me and my beloved zeds : they don't want to spawn It works using coordinates close to the player, but not far way :local zed = getVirtualZombieManager():createRealZombieNow(fromx, fromy, fromz);zed:setFakeDead(false);attempted index: setFakeDead of non-table: nullCoordinates were (9511, 11204, 0). This is odd, my guess is I have to explore the world before being able to spawn stuff ?Thanks again Link to comment Share on other sites More sharing options...
RoboMat Posted January 7, 2014 Share Posted January 7, 2014 I think you and me have the same problem. Now that you posted it I think it has to do with the game switching to "meta" (can't think of the proper term atm) where the world isn't really there but only simulated. Link to comment Share on other sites More sharing options...
Kyun Posted January 7, 2014 Author Share Posted January 7, 2014 Make sense, so I should be looking for a VirtualZombie something. I went around the world collecting coordinates so it's gonna be worth it ! Isn't that your mod ? I think it is Link to comment Share on other sites More sharing options...
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