Jump to content

Recommended Posts

hi

I wish to use function components.sanity:SetInducedInsanity and so far it works just fine.

However I don't want the character's sanity to permanently lock to 0. How can I circumvent this?

Essentially I just want the increased Shadow Creature count, everything else should work the same such as gaining sanity from various methods.

Edited by Hell-met
Link to comment
https://forums.kleientertainment.com/forums/topic/105337-induced-sanity/
Share on other sites

It's hard-coded in components/shadowcreaturespawner.lua, local function UpdatePopulation line 122

if player.components.sanity.inducedinsanity then
        local maxpop = 5
        local inc_chance = .7
        local dec_chance = .4
        local targetpop = params.targetpop

        --Figure out our new target
        if targetpop > maxpop then
            targetpop = targetpop - 1
        elseif math.random() < inc_chance then
            if targetpop < maxpop then
                targetpop = targetpop + 1
            end
        elseif targetpop > 0 and math.random() < dec_chance then
            targetpop = targetpop - 1
        end

        --Start spawner if target population has changed
        if params.targetpop ~= targetpop then
            params.targetpop = targetpop
            StartSpawn(player, params)
        end

        --Shorter reschedule for population update due to induced insanity
        params.poptask = player:DoTaskInTime(5 + math.random(), UpdatePopulation, params)

Since pretty much everything in there is private, you might have to copy over the file to your mod's scripts folder and work your magic there, then add this line in your modmain.lua:

AddComponentPostInit("shadowcreaturespawner", Class)

Would be nice if someone can point out any other way to override the local function UpdatePopulation without having to override the entire class.

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...