The_Sp00n Posted June 17, 2024 Share Posted June 17, 2024 So I learned that the downside I made for my mod doesn't work. Basically it is the opposite of Willow's passive sanity gain when near fire. So instead of gaining sanity when near fire, the modded character would lose sanity instead. I tried to just take some code from Willow (listed below) and return delta as negative but it didn't work. I tried making it so the sanity aura was negative and it didn't work. Any ideas bright minds of the forums? (note, the code posted below was all I copied, if I am missing other bits of code or something please tell me what I am missing) local FIRE_TAGS = { "fire" } local function sanityfn(inst)--, dt) local sanity_cap = TUNING.SANITYAURA_LARGE local sanity_per_ent = TUNING.SANITYAURA_TINY local delta = inst.components.temperature:IsFreezing() and -sanity_cap or 0 local x, y, z = inst.Transform:GetWorldPosition() local max_rad = 10 local ents = TheSim:FindEntities(x, y, z, max_rad, FIRE_TAGS) for i, v in ipairs(ents) do if v.components.burnable ~= nil and v.components.burnable:IsBurning() then local stack_size = v.components.stackable ~= nil and v.components.stackable.stacksize or 1 local rad = v.components.burnable:GetLargestLightRadius() or 1 local sz = stack_size * sanity_per_ent * math.min(max_rad, rad) / max_rad local distsq = inst:GetDistanceSqToInst(v) - 9 -- shift the value so that a distance of 3 is the minimum delta = delta + sz / math.max(1, distsq) if delta > sanity_cap then delta = sanity_cap break end end end return delta end Link to comment https://forums.kleientertainment.com/forums/topic/157253-anyone-know-how-to-reverse-willows-sanity-gain-from-fire/ Share on other sites More sharing options...
Glommer2 Posted June 20, 2024 Share Posted June 20, 2024 local FIRE_TAGS = { "fire" } local function sanityfn(inst)--, dt) local sanity_cap = TUNING.SANITYAURA_LARGE--max sanity rate local sanity_per_ent = TUNING.SANITYAURA_TINY local delta = 0 local x, y, z = inst.Transform:GetWorldPosition() local max_rad = 10 local ents = TheSim:FindEntities(x, y, z, max_rad, FIRE_TAGS) for i, v in ipairs(ents) do if v.components.burnable ~= nil and v.components.burnable:IsBurning() then local stack_size = v.components.stackable ~= nil and v.components.stackable.stacksize or 1 local rad = v.components.burnable:GetLargestLightRadius() or 1 local sz = stack_size * sanity_per_ent * math.min(max_rad, rad) / max_rad local distsq = inst:GetDistanceSqToInst(v) - 9 -- shift the value so that a distance of 3 is the minimum delta = delta + sz / math.max(1, distsq) if delta > sanity_cap then delta = sanity_cap break end end end return -delta--return a negative num so your sanity decrease end local function master_postinit(inst) inst.components.sanity.custom_rate_fn = sanityfn--this should be added into your master_postinit function end Link to comment https://forums.kleientertainment.com/forums/topic/157253-anyone-know-how-to-reverse-willows-sanity-gain-from-fire/#findComment-1727231 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