kOnoNicolasGa Posted December 22, 2021 Share Posted December 22, 2021 Well, i want to make my character have Walter ability, but, i was trying to make it gain a percentage of sanity based on every tree around him, how could i make it? Every tree around my character gives him 1 of sanity per second, but i want to make him gain like, 0,5 sanity per second. Someone could give me a hand? Since now ty guys! Link to comment https://forums.kleientertainment.com/forums/topic/136406-modding-a-character-to-make-it-gain-sanity-by-trees/ Share on other sites More sharing options...
skittles sour Posted December 24, 2021 Share Posted December 24, 2021 You can check the custom sanity fn of the willow prefab file, where we have: local FIRE_TAGS = { "fire" } local function sanityfn(inst)--, dt) local delta = inst.components.temperature:IsFreezing() and -TUNING.SANITYAURA_LARGE 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 rad = v.components.burnable:GetLargestLightRadius() or 1 local sz = TUNING.SANITYAURA_TINY * 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) end end return delta end and where you can replace the fire tags with tree tags, adjust the distance, and change the sanity amount as you please. 1 Link to comment https://forums.kleientertainment.com/forums/topic/136406-modding-a-character-to-make-it-gain-sanity-by-trees/#findComment-1527754 Share on other sites More sharing options...
kOnoNicolasGa Posted December 24, 2021 Author Share Posted December 24, 2021 55 minutes ago, Bad Willow said: You can check the custom sanity fn of the willow prefab file, where we have: local FIRE_TAGS = { "fire" } local function sanityfn(inst)--, dt) local delta = inst.components.temperature:IsFreezing() and -TUNING.SANITYAURA_LARGE 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 rad = v.components.burnable:GetLargestLightRadius() or 1 local sz = TUNING.SANITYAURA_TINY * 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) end end return delta end and where you can replace the fire tags with tree tags, adjust the distance, and change the sanity amount as you please. Tysm for sharing the script to me. I already solved the problem! Link to comment https://forums.kleientertainment.com/forums/topic/136406-modding-a-character-to-make-it-gain-sanity-by-trees/#findComment-1527765 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