GalloViking Posted February 7, 2015 Share Posted February 7, 2015 (edited) Hello everyone!I'm a beginner in the world of modding. Actually making a RoG (that I will eventually convert to DST) character, I wanted to know if you could help me for different things, or just direct me to a tutorial about this. 1) I try make my character emit light based on her actual sanity, but I have no idea about this. I'm trying to let her emit a torch light at 100% sanity. Light would decrease until 25% sanity, where she would emit nothing. 2) I'd like her to have a small sanity regen during day. Doesn't sound hard to make, but I have no idea how... 3 I would like followers like pigs, to stay with with her longer (forever if possible) when she feeds them. Thanks for reading. You can PM me if you want or answer here, as you wish. Edited February 7, 2015 by GalloViking Link to comment https://forums.kleientertainment.com/forums/topic/50660-help-needed-for-sanity-perks/ Share on other sites More sharing options...
Jjmarco Posted February 8, 2015 Share Posted February 8, 2015 (edited) @GalloViking, 1) In your character's common_postinit, put this:inst.entity:AddLight() -- adds light to character's entity inst.Light:Enable(true)inst.Light:SetIntensity(.75)inst.Light:SetColour(197 / 255, 197 / 255, 50 / 255) -- torchlight color (RGB)inst.Light:SetFalloff(0.5) -- torchlight falloff (how much precentage of radius until light fades)inst.Light:SetRadius(2) -- torchlight radius inst:ListenForEvent("sanitydelta", ChangeLightIntensity) -- when sanity changes, call ChangeLightIntensityThis will add torch-like light to every player who plays as this character. Anywhere above common_postinit, put the ChangeLightIntensity function (you can change the name if you want):local function ChangeLightIntensity(inst, data) -- data contains newpercent, oldpercent, and overtime (boolean) if data.newpercent < .25 then inst.Light:Enable(false) -- if sanity is under 25% of max, turn off light else -- else, enable light and set light intensity to sanity percentage (max 75%, torchlight) inst.Light:Enable(true) inst.Light:SetIntensity(.75*data.newpercent) endend 2) In your character's master_postinit, put this:-- this function is called when the game recalculates sanity regeninst.components.sanity.custom_rate_fn = function() local day = GLOBAL.TheWorld.state.isday and not GLOBAL.TheWorld:HasTag("cave") -- makes sure world is day and not in cave if day then return TUNING.DAPPERNESS_SMALL -- if day, give small sanity regen else return 0 -- else, give nothing endendYou can change the rate of sanity regen: there's DAPPERNESS_TINY, MED, LARGE, HUGE (data/scripts/tuning.lua). 3) Put this anywhere in your modmain:AddComponentPostInit("follower", function(self) local old_AddLoyaltyTime = self.AddLoyaltyTime function self:AddLoyaltyTime(time) -- overrides AddLoyaltyTime of follower component old_AddLoyaltyTime(self, time) if self.leader and self.leader.prefab == "your char's prefab here" then self.task:Cancel() -- if leader is your character, stops task telling follower to leave player after a while self.task = nil end end -- same as above, but with LongUpdate local old_LongUpdate = self.LongUpdate function self:LongUpdate(dt) old_LonhUpdate(self, dt) if self.leader and self.leader.prefab == "your char's prefab here" then self.task:Cancel() self.task = nil end endend)Haven't tested that one, but I think it'll work.It will make it so any follower your character picks up will stay loyal to your character forever, unless you attack it or you die. All of the above should work on both DS and DST. I tested the 2 first on DST.Only if you are in DS, substitute every TheWorld with GetWorld(), and ignore master_postinit and common_postinit (put everything in the same init function, as master and common_postinit are for DST). Tell me if it works, and if you have any questions, don't hesitate to ask! Edited February 8, 2015 by Jjmarco Link to comment https://forums.kleientertainment.com/forums/topic/50660-help-needed-for-sanity-perks/#findComment-610844 Share on other sites More sharing options...
GalloViking Posted February 8, 2015 Author Share Posted February 8, 2015 (edited) I did the sanity regen during the day (thanks to Maxwell, haha) and the pig followers too. All I need now is what told for sanity based light. I'll edit this post after trying what you told me. Edit: It works perfectly. Thank you a lot! You're my hero. And yes, I may have another question, but it's about DST. I'll PM you. Edited February 8, 2015 by GalloViking Link to comment https://forums.kleientertainment.com/forums/topic/50660-help-needed-for-sanity-perks/#findComment-610957 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