Birdskull Posted August 7, 2019 Share Posted August 7, 2019 Hey all. I'm hoping someone can help me figure out what it is I'm missing, here. The idea is the character will have the option to "possess" a deer as a form of revival. I borrowed from the meat effigy and have attached that code to this post for convenience. Problems: - Health penalty doesn't occur upon attuning - Character becomes immobile after revival Relevant excerpt from my modmain: AddPrefabPostInit("deer", function(inst) inst:AddTag("resurrector") if not GLOBAL.TheWorld.ismastersim then return end inst:AddComponent("attunable") inst.components.attunable:SetAttunableTag("remoteresurrector") inst.components.attunable:SetOnAttuneCostFn(onattunecost) inst.components.attunable:SetOnLinkFn(onlink) inst.components.attunable:SetOnUnlinkFn(onunlink) inst:ListenForEvent("activateresurrection", inst.Remove) end) function DeerPostInit(inst) local function onattunecost(inst, player) if player.components.health == nil or math.ceil(player.components.health.currenthealth) < TUNING.EFFIGY_HEALTH_PENALTY then return false, "NOHEALTH" end local delta = math.min(math.max(0, player.components.health.currenthealth - 1), TUNING.EFFIGY_HEALTH_PENALTY) player:PushEvent("consumehealthcost") player.components.health:DoDelta(-delta, false, "statue_attune", true, inst, true) return true end local function onlink(inst, player, isloading) if not isloading then inst.SoundEmitter:PlaySound("dontstarve/common/together/meat_effigy_attune/on") inst.AnimState:PlayAnimation("attune_on") end end local function onunlink(inst, player, isloading) if not (isloading or inst.AnimState:IsCurrentAnimation("attune_on")) then inst.SoundEmitter:PlaySound("dontstarve/common/together/meat_effigy_attune/off") inst.AnimState:PlayAnimation("attune_off") end end local function PlayAttuneSound(inst) if inst.AnimState:IsCurrentAnimation("place") or inst.AnimState:IsCurrentAnimation("attune_on") then inst.SoundEmitter:PlaySound("dontstarve/common/together/meat_effigy_attune/on") end end end AddPrefabPostInit("deer", DeerPostInit) local function possessedDeerFree(inst) inst:DoTaskInTime(0, function() if inst.char == "oracle" then local x, y, z = inst.Transform:GetWorldPosition() inst:Remove() GLOBAL.SpawnPrefab("deer").Transform:SetPosition(x, y, z) end end) end AddPrefabPostInit("skeleton_player", possessedDeerFree) Video of what's currently going down: resurrectionstatue.lua Link to comment Share on other sites More sharing options...
Ultroman Posted August 7, 2019 Share Posted August 7, 2019 Seems like a very specific problem, probably a sever/client problem. See if there's a difference between trying it on a server with and without caves. If not, try printing everywhere you can, so you can see what is and isn't happening as you'd expect. It seems the player isn't being properly activated again. 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