Peachykeen Posted April 30, 2017 Share Posted April 30, 2017 My partner and I are working on customer DST characters, and her character is essentially a girl scout. We wanted to have her character to gain sanity while at campfires and hopefully also fire pits. We were wondering if anyone knew how to do this/what the coding would be? I know Willow has a similar perk so not sure if there's something we can pull from her coding to achieve this. Thanks for any help Link to comment Share on other sites More sharing options...
mrboosch Posted May 2, 2017 Share Posted May 2, 2017 Hello, You can accomplish this by adding a custom sanity function t your character. It might go something like this: -- Fire Sanity fn, gets added to sanity functions later local function sanityfn(inst) -- first we get some information about what things are near our character -- the max_rad tells us how far out to look local x, y, z = inst.Transform:GetWorldPosition() local delta = 0 local max_rad = 10 -- Next we find things. Mine finds fire (like willow) - you should change this to find campfire, or specific sources you want. local ents = TheSim:FindEntities(x, y, z, max_rad, { "fire" }) for i, v in ipairs(ents) do --this checks to see if the thing that was found is actively burning. --if it is, and if the player is within the light radius of the fire, then change their sanity if v.components.burnable ~= nil and v.components.burnable:IsBurning() then local rad = v.components.burnable:GetLargestLightRadius() or 1 local sz = TUNING.SANITYAURA_MED * math.min(max_rad, rad) / max_rad -- this is to alter the distance of the character to fire effect - defining how close they have to be local distsq = inst:GetDistanceSqToInst(v) - 9 delta = delta + sz / math.max(1, distsq) end end return delta end Once you have your sanity function defined, you can add it to your character to supplement the existing sanity function by adding it into the master_postinit function of your character's prefab like this: inst.components.sanity.custom_rate_fn = sanityfn This code is a good start, but you'll need to alter it to do exactly what you want - I hope it helps you. Link to comment Share on other sites More sharing options...
Peachykeen Posted May 3, 2017 Author Share Posted May 3, 2017 Thank you very much! My partner's much better at coding than me so i'll direct her to your response Link to comment 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