Snoopy2016 Posted March 6, 2017 Share Posted March 6, 2017 Hello floks, im new to modding and currently trying around with adjusting an existing character for my girlfriend. i wont upload it since i dont have the copyright for it. it is just for my personal use. Since the character is a rabbit, other rabbits are not afraid of him any more. I managed to make this work by adding: inst:RemoveTag("scarytoprey") to my character prefab. After that i wanted him to gain sanity while standing next to rabbits. I used a code which i found in another thread of this forum: local function sanityfn(inst) local x,y,z = inst.Transform:GetWorldPosition() local delta = 0 local ents = TheSim:FindEntities(x,y,z, 4, {"rabbit"}) for k,v in pairs(ents) do local bonus_sanity = TUNING.SANITYAURA_LOW local distsq = math.max(inst:GetDistanceSqToInst(v),1) delta = delta + bonus_sanity/distsq end return delta end inst.components.sanity.custom_rate_fn = sanityfn While now i get sanity by standing near rabbits all rabbits immediately start to run in their rabbitholes when i cross the map^^ Can someone help me with that? Did i miss something? Link to comment Share on other sites More sharing options...
. . . Posted March 6, 2017 Share Posted March 6, 2017 For gaining sanity around rabbits I think you can put this in your modmain.lua, maaaybe Spoiler if GLOBAL.TheNet:GetIsServer() then AddPrefabPostInit("rabbit", function(inst) inst:AddComponent("sanityaura") inst.components.sanityaura.aura = 0 end) AddComponentPostInit("sanityaura", function(self) local old = self.GetAura function self:GetAura(observer) if observer.prefab == "YOURCHARACTERNAMEHERE" and self.inst.prefab == "rabbit" then return .1 end return old(self,observer) end end) end Link to comment Share on other sites More sharing options...
Snoopy2016 Posted March 6, 2017 Author Share Posted March 6, 2017 Hello SuperDavid, thanks for your help! But since im totally beginner, can u tell me the exact place to put it? or doesnt it matter where to put it? Greetings Snoopy Link to comment Share on other sites More sharing options...
. . . Posted March 6, 2017 Share Posted March 6, 2017 (edited) you can put anuywhere in modmain.lua Also, make sure where it says YOURCHARACTERNAMEHERE to change to name of your charharacter's prefab file is name Edited March 6, 2017 by SuperDavid Link to comment Share on other sites More sharing options...
Snoopy2016 Posted March 7, 2017 Author Share Posted March 7, 2017 Haha. That last sentence made my day Link to comment Share on other sites More sharing options...
. . . Posted March 7, 2017 Share Posted March 7, 2017 1 hour ago, Snoopy2016 said: Haha. That last sentence made my day That's what happens when you don't sleep an entire day, hahaha ! And I hope your thing works all fine & stuff now ! 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