RedMattis Posted December 23, 2014 Share Posted December 23, 2014 (edited) I've found the solution for this, so I thought I'd share it with you since it was pretty tough to figure out based on the problem. Basically you need to make the character stop shape shifting while dead.-- All code stolen right from Wolfgang, so some of this might not be relevant for you.-- Just before your conditions which trigger shape shifting. In Wolfgang's case this is his "onhungerchange" function.if inst.sg:HasStateTag("nomorph") or inst:HasTag("playerghost") or inst.components.health:IsDead() then return end-- Enable and disable stuff depending on if the character is alive or dead.local function onbecamehuman(inst) if inst._wasnomorph == nil then inst.strength = "normal" inst._wasnomorph = inst.sg:HasStateTag("nomorph") inst.talksoundoverride = nil inst.hurtsoundoverride = nil inst:ListenForEvent("hungerdelta", onhungerchange) inst:ListenForEvent("newstate", onnewstate) onhungerchange(inst, nil, true) endendlocal function onbecameghost(inst) if inst._wasnomorph ~= nil then inst.strength = "normal" inst._wasnomorph = nil inst.talksoundoverride = nil inst.hurtsoundoverride = nil inst:RemoveEventCallback("hungerdelta", onhungerchange) inst:RemoveEventCallback("newstate", onnewstate) endendlocal function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) endendHope this was useful to someone. Cheers. Edited December 23, 2014 by RedMattis Link to comment Share on other sites More sharing options...
QuickShot010 Posted January 13, 2015 Share Posted January 13, 2015 How does this work if you use this code? inst:AddComponent("beard") inst.components.beard.onreset = function() inst.AnimState:SetBuild("drok") end inst.components.beard.prize = "beardhair" local beard_days = {1,2,3,4,5} local beard_bits = {3,5,8,10,14} inst.components.beard:AddCallback(beard_days[1], function() inst.components.beard.bits = beard_bits[1] inst.AnimState:SetBuild("drokquarter") end) inst.components.beard:AddCallback(beard_days[2], function() inst.components.beard.bits = beard_bits[2] inst.AnimState:SetBuild("drokhalf") end) inst.components.beard:AddCallback(beard_days[3], function() inst.components.beard.bits = beard_bits[3] inst.AnimState:SetBuild("drokfull") end) inst.components.beard:AddCallback(beard_days[4], function() inst.components.beard.bits = beard_bits[4] inst.AnimState:SetBuild("drokfullstubble") end) inst.components.beard:AddCallback(beard_days[5], function() inst.components.beard.bits = beard_bits[5] inst.AnimState:SetBuild("drokfullbeard") end) 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