Jump to content

Recommended Posts

Okay, so basically I set up ghost mode to trigger for characters using a different stategraph than the normal one.  When they revive, however, everything gets reset to a regular player's stategraph.  So, I set a function which goes off when you respawn from a ghost.  It's supposed to set the stategraph, build, and bank back to normal, but the player still becomes like a regular one upon revival.  Any suggestions?

The lazy way:

function setChar(inst)	inst.AnimState:SetBank("deerclops")	inst.AnimState:SetBuild("deerclops_build")	inst:SetStateGraph("SGdeerclops")endAddPlayerPostInit(function(inst)	inst:DoTaskInTime(0, setChar)	inst:ListenForEvent("respawnfromghost", function()		inst:DoTaskInTime(10, setChar)	end)end)

Setting them after being revived do work, the problem is WHEN you set each thing. If you set them too early, you break everything; just in time, either nothing happens or it's perfect; a bit late, and it works.

The lazy way:

function setChar(inst)	inst.AnimState:SetBank("deerclops")	inst.AnimState:SetBuild("deerclops_build")	inst:SetStateGraph("SGdeerclops")endAddPlayerPostInit(function(inst)	inst:DoTaskInTime(0, setChar)	inst:ListenForEvent("respawnfromghost", function()		inst:DoTaskInTime(10, setChar)	end)end)

Setting them after being revived do work, the problem is WHEN you set each thing. If you set them too early, you break everything; just in time, either nothing happens or it's perfect; a bit late, and it works.

@DarkXero,, it appears this makes every character a deerclops.  Did I do something wrong, or does something about it being local need to be put in?

 

Edited by Mario384

@Mario384, correct, but I used AddPlayerPostInit for testing purposes.

 

That should go inside the master_postinit of the character.

 

Well, after editing some of this around, it works now.  Thanks for all your help, man, without your assistance this wouldn't have been possible.

@DarkXero,  well, after a bit of further testing after my previous post, apparently it's not working (sort of).  It doesn't change unless the player relogs, and when you return everything is as it should be.  Not sure if this is on the code's side, or some sort of bug.

Edited by Mario384

@Mario384, I would like a zip or link to where I can get the files. I'm not sure where the problem is. Try bumping the 10 from DoTaskInTime to 20.

 

Else, I would need more details as to how find the bug. Because when I tried, my character would start as Deerclops, then die, then perform a resurrection with Wilson anims, then appear as Wilson, then change to Deerclops, no need for relogging. But then again I don't know how are you handling this. I just patch things up to run something similar to yours.

Edited by DarkXero

http://forums.kleientertainment.com/files/file/1105-dst-playable-deerclops/ Here's one where you can get the file for deerclops.  I believe the reason why it works for you is because you're replacing Wilson.  Meanwhile, mine is a seperate character.  Also, setting it to 20 for DoTaskInTime did not prevail. 

You put my functions inside a

local function CheckForGhostRespawn(inst)    inst:DoTaskInTime(0, setChar)    inst:ListenForEvent("respawnfromghost", function()        inst:DoTaskInTime(10, setChar)    end)end

then never ran a CheckForGhostRespawn. They never get executed.

 

Put them as is, inside the master_postinit, without them being the definition for the CheckForGhostRespawn.

You put my functions inside a

local function CheckForGhostRespawn(inst)    inst:DoTaskInTime(0, setChar)    inst:ListenForEvent("respawnfromghost", function()        inst:DoTaskInTime(10, setChar)    end)end

then never ran a CheckForGhostRespawn. They never get executed.

 

Put them as is, inside the master_postinit, without them being the definition for the CheckForGhostRespawn.

I can't believe I didn't realize that was what was wrong with it.  Once again, friend, I thank you dearly, your knowledge has helped me greatly.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...