Jump to content

[Solved] How to make player lose no sanity from dead players?


Recommended Posts

Hello, I was wondering if there's a code to make players lose no sanity from dead players?

I remember using this long time ago in master_postinit, but it didn't seem to work?

inst.components.sanity.ghost_drain_mult = 0

Edited by Warbucks
Link to comment
Share on other sites

Hey, thanks for the help! Unfortunately, I don't really know what "hook the function" means cause I'm a code noob lol

I tried my best to guess and did this, but it didn't work :wilson_ecstatic:

local function Sanity:RecalcGhostDrain(inst)
	inst.components.sanity.ghost_drain_mult = 0
end

 

Link to comment
Share on other sites

50 minutes ago, Warbucks said:

 

 

Try this

function Sanity:RecalcGhostDrain()
    if GetGhostSanityDrain(TheNet:GetServerGameMode()) then
        local num_ghosts = TheWorld.shard.components.shard_players:GetNumGhosts()
        local num_alive = TheWorld.shard.components.shard_players:GetNumAlive()
        local group_resist = num_alive > num_ghosts and 1 - num_ghosts / num_alive or 0

        self.ghost_drain_mult = 0
    else
        self.ghost_drain_mult = 0
    end
end

Put this into the master_postinit of your character.

Link to comment
Share on other sites

This code (without sanity)

Spoiler

function RecalcGhostDrain()
    if GetGhostSanityDrain(TheNet:GetServerGameMode()) then
        local num_ghosts = TheWorld.shard.components.shard_players:GetNumGhosts()
        local num_alive = TheWorld.shard.components.shard_players:GetNumAlive()
        local group_resist = num_alive > num_ghosts and 1 - num_ghosts / num_alive or 0

        self.ghost_drain_mult = 0
    else
        self.ghost_drain_mult = 0
    end
end

 

Gives this crash "assign to undeclared variable 'RecalcGhostDrain'"

I also tried this and it didn't crash, but nothing happened

Spoiler

local function RecalcGhostDrain(inst)
    if GetGhostSanityDrain(TheNet:GetServerGameMode()) then
        local num_ghosts = TheWorld.shard.components.shard_players:GetNumGhosts()
        local num_alive = TheWorld.shard.components.shard_players:GetNumAlive()
        local group_resist = num_alive > num_ghosts and 1 - num_ghosts / num_alive or 0

        inst.ghost_drain_mult = 0
    else
        inst.ghost_drain_mult = 0
    end
end

 

and thanks again for help!

Link to comment
Share on other sites

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
 Share

×
  • Create New...