Naplez Posted January 11, 2015 Share Posted January 11, 2015 Hello! I want to coding my mod character don't lose any sanity with ghosts and other player's ghosts because he likes paranormal stuff. I looked up my mod's lua and DST's sanity lua but still can't find out how. Is there any way to make it possible? I would be really glad if you can help me. ;~; Link to comment https://forums.kleientertainment.com/forums/topic/48960-dont-lose-sanity-with-other-player-ghosts/ Share on other sites More sharing options...
Naplez Posted January 11, 2015 Author Share Posted January 11, 2015 I think I found out how with google, maybe...I added in my character's lua this ↓ inst.components.sanity.ghost_drain_mult = 0 Anyone knows it will works or not? ;~; If it works, will it works with the mob ghosts too? Link to comment https://forums.kleientertainment.com/forums/topic/48960-dont-lose-sanity-with-other-player-ghosts/#findComment-600518 Share on other sites More sharing options...
Ryuushu Posted January 11, 2015 Share Posted January 11, 2015 (edited) Just recover what you lose from sanity draining stuff by adding a custom sanity rate function to your character: -- Stolen from sanity.lualocal function GetNumGhostPlayers() local num = 0 if GetGhostSanityDrain( TheNet:GetServerGameMode() ) then for i,v in pairs(AllPlayers) do if v:HasTag("playerghost") then num = num + 1 end end end return numendlocal function nospooky(inst) local delta = 0 -- Recover what we lost from ghost players local ghost_drain_mult = GetNumGhostPlayers() if ghost_drain_mult > TUNING.MAX_SANITY_GHOST_PLAYER_DRAIN_MULT then ghost_drain_mult = TUNING.MAX_SANITY_GHOST_PLAYER_DRAIN_MULT end delta = delta + TUNING.SANITY_GHOST_PLAYER_DRAIN * ghost_drain_mult * -1 -- Recover what we lost from ghosts local aura_delta = 0 local x,y,z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x,y,z, TUNING.SANITY_EFFECT_RANGE, {"ghost"}) -- Do ghost players have the tag ghost too? for k,v in pairs(ents) do if v.components.sanityaura and v ~= inst then local distsq = inst:GetDistanceSqToInst(v) local aura_val = v.components.sanityaura:GetAura(inst)/math.max(1, distsq) if aura_val < 0 then aura_val = aura_val * inst.components.sanity.neg_aura_mult end aura_delta = aura_delta + aura_val end end delta = delta + (aura_delta * -1) return deltaend...local function master_postinit() ... inst.components.sanity.custom_rate_fn = nospooky ...end..... Thought it'd be shorter <<;sanity.ghost_drain_mult does nothing, it's more or less handled like a local value in the Recalc function:self.ghost_drain_mult = GetNumGhostPlayers() Edited January 11, 2015 by Ryuushu Link to comment https://forums.kleientertainment.com/forums/topic/48960-dont-lose-sanity-with-other-player-ghosts/#findComment-600531 Share on other sites More sharing options...
Naplez Posted January 12, 2015 Author Share Posted January 12, 2015 Just recover what you lose from sanity draining stuff by adding a custom sanity rate function to your character: -- Stolen from sanity.lualocal function GetNumGhostPlayers() local num = 0 if GetGhostSanityDrain( TheNet:GetServerGameMode() ) then for i,v in pairs(AllPlayers) do if v:HasTag("playerghost") then num = num + 1 end end end return numendlocal function nospooky(inst) local delta = 0 -- Recover what we lost from ghost players local ghost_drain_mult = GetNumGhostPlayers() if ghost_drain_mult > TUNING.MAX_SANITY_GHOST_PLAYER_DRAIN_MULT then ghost_drain_mult = TUNING.MAX_SANITY_GHOST_PLAYER_DRAIN_MULT end delta = delta + TUNING.SANITY_GHOST_PLAYER_DRAIN * ghost_drain_mult * -1 -- Recover what we lost from ghosts local aura_delta = 0 local x,y,z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x,y,z, TUNING.SANITY_EFFECT_RANGE, {"ghost"}) -- Do ghost players have the tag ghost too? for k,v in pairs(ents) do if v.components.sanityaura and v ~= inst then local distsq = inst:GetDistanceSqToInst(v) local aura_val = v.components.sanityaura:GetAura(inst)/math.max(1, distsq) if aura_val < 0 then aura_val = aura_val * inst.components.sanity.neg_aura_mult end aura_delta = aura_delta + aura_val end end delta = delta + (aura_delta * -1) return deltaend...local function master_postinit() ... inst.components.sanity.custom_rate_fn = nospooky ...end..... Thought it'd be shorter <<;sanity.ghost_drain_mult does nothing, it's more or less handled like a local value in the Recalc function:self.ghost_drain_mult = GetNumGhostPlayers() @Ryuushu Thank you so much to your help! You are so nice! ;▽; Should I put this in mycharacter.lua? Can I ask you where should I exactly put in? Link to comment https://forums.kleientertainment.com/forums/topic/48960-dont-lose-sanity-with-other-player-ghosts/#findComment-600707 Share on other sites More sharing options...
Ryuushu Posted January 12, 2015 Share Posted January 12, 2015 @NaplezAh, yes, it goes in your character's prefab file. The two functions can go anywhere inside the file. The custom_rate_fn goes inside your character's master_postinit. Link to comment https://forums.kleientertainment.com/forums/topic/48960-dont-lose-sanity-with-other-player-ghosts/#findComment-600717 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