Well-met Posted April 25, 2019 Share Posted April 25, 2019 (edited) 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 April 25, 2019 by Hell-met Link to comment https://forums.kleientertainment.com/forums/topic/105337-induced-sanity/ Share on other sites More sharing options...
Well-met Posted April 25, 2019 Author Share Posted April 25, 2019 seems odd to me that no function directly controls the amount of shadows that spawn. It seems hard coded to an event call? Link to comment https://forums.kleientertainment.com/forums/topic/105337-induced-sanity/#findComment-1185046 Share on other sites More sharing options...
Botspan Posted April 26, 2019 Share Posted April 26, 2019 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. Link to comment https://forums.kleientertainment.com/forums/topic/105337-induced-sanity/#findComment-1185475 Share on other sites More sharing options...
Well-met Posted April 26, 2019 Author Share Posted April 26, 2019 would sure be nice indeed. Link to comment https://forums.kleientertainment.com/forums/topic/105337-induced-sanity/#findComment-1185818 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