Lumina Posted July 30, 2017 Share Posted July 30, 2017 Hi, I want the character i'm working on to lose sanity near moles (because they steal treasure). So as far as i understand i must search entities to search for moles, right ? How do i do this ? Thanks for the help Link to comment Share on other sites More sharing options...
alainmcd Posted July 30, 2017 Share Posted July 30, 2017 Use custom_rate_fn in your character's master_postinit: inst.components.sanity.custom_rate_fn = sanityfn Define a sanityfn in your character file that uses TheSim:FindEntities: TheSim:FindEntities(x, y, z, radius, MUSTHAVETAGS, CANTHAVETAGS, MUSTHAVEONETAG) MUSTHAVETAGS, CANTHAVETAGS and MUSTHAVEONETAG should be tables containing all tags to look for (and, not and or respectively). So something like: local function sanityfn(inst) local x, y, z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, {"mole"}) local delta = 0 for k, v in pairs(ents) do local distsq = math.max(inst:GetDistanceSqToInst(v), 1) delta = delta - TUNING.SANITYAURA_SMALL / distsq end return delta end Link to comment Share on other sites More sharing options...
Lumina Posted July 30, 2017 Author Share Posted July 30, 2017 Thanks, it's working fine 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