SenL Posted February 17, 2015 Share Posted February 17, 2015 I'm looking at alwaysontikitorch and it gives sanity aura... the code: inst:AddComponent("sanityaura") inst.components.sanityaura.aura = TUNING.SANITYAURA_TINY The sanityaura component lua is:local SanityAura = Class(function(self, inst) self.inst = inst self.aura = 0 self.aurafn = nil self.penalty = nilend) function SanityAura:GetAura(observer)if self.aurafn thenreturn self.aurafn(self.inst, observer)endreturn self.auraend return SanityAura Nothing about giving or taking away sanity.How does it work? Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/51106-sanityaura-how-does-it-work/ Share on other sites More sharing options...
Jjmarco Posted February 17, 2015 Share Posted February 17, 2015 @SenL, The sanityaura component doesn't take away sanity by itself. Instead, the sanity component looks at the values of the sanityaura components of entities around you and add them to the the character's overall sanity drop/gain rate. It all happens in the Recalc method of sanity:local aura_delta = 0 local x,y,z = self.inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x,y,z, TUNING.SANITY_EFFECT_RANGE, nil, {"FX", "NOCLICK", "DECOR","INLIMBO"} ) -- this looks for all mobs around the player for k,v in pairs(ents) do if v.components.sanityaura and v ~= self.inst then -- checks if they have a sanity aura local distsq = self.inst:GetDistanceSqToInst(v) local aura_val = v.components.sanityaura:GetAura(self.inst)/math.max(1, distsq) if aura_val < 0 then aura_val = aura_val * self.neg_aura_mult end aura_delta = aura_delta + aura_val end endself.rate = (dapper_delta + light_delta + aura_delta + rain_delta) -- this adds the sum of all sanity auras to the overall sanity rate Link to comment https://forums.kleientertainment.com/forums/topic/51106-sanityaura-how-does-it-work/#findComment-614079 Share on other sites More sharing options...
SenL Posted February 17, 2015 Author Share Posted February 17, 2015 Ooh I see.Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/51106-sanityaura-how-does-it-work/#findComment-614085 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