Conker446 Posted December 18, 2014 Share Posted December 18, 2014 (edited) TUNING.SANITY_NIGHT_LIGHT = 0/60TUNING.SANITY_NIGHT_MID = 0/60 TUNING.SANITY_NIGHT_DARK = 0/60TUNING.SANITY_DAY_GAIN = -8/60 I put this code to make my custom character nocturnal and I played as a guest in other player's server. This custom character has no problem. The real problem is that other characters decrease their sanity during the day too. And they also can create my mod character's own Item. I want to put these features only on my character. When I put all codes in common_postinit or master_postinit, it did not changed. What I have to do on this? Do I need to add some special code with them? Edited December 18, 2014 by Conker446 Link to comment Share on other sites More sharing options...
Conker446 Posted December 18, 2014 Author Share Posted December 18, 2014 (edited) .. Edited December 18, 2014 by Conker446 Link to comment Share on other sites More sharing options...
rezecib Posted December 18, 2014 Share Posted December 18, 2014 (edited) @Conker446, Any changes to TUNING like you're doing will always affect all players, unless you're changing tuning values that specifically mention a player (e.g. TUNING.WOLFGANG_START_MIGHTY_THRESH). As for what you want to do, if you look at Wolfgang, he has the night part you want: inst.components.sanity.night_drain_mult = 1.1So you can set that to zero to remove night drain entirely. Looking at the sanity component, though, it looks like this multiplier is also applied to the day value, so you'll probably have to use an approach like Willow's gaining sanity from fires:local function sanityfn(inst) local x,y,z = inst.Transform:GetWorldPosition() local delta = 0 local max_rad = 10 local ents = TheSim:FindEntities(x,y,z, max_rad, {"fire"}) for k,v in pairs(ents) do if v.components.burnable and v.components.burnable.burning then local sz = TUNING.SANITYAURA_TINY local rad = v.components.burnable:GetLargestLightRadius() or 1 sz = sz * ( math.min(max_rad, rad) / max_rad ) local distsq = inst:GetDistanceSqToInst(v) delta = delta + sz/math.max(1, distsq) end end return deltaend inst.components.sanity.custom_rate_fn = sanityfnWithout testing this at all, I think this rewrite of Willow's function should do what you want: inst.components.sanity.custom_rate_fn = function() if TheWorld.state.isday then return -8/60 else return 0 end endEdit: And ALL of this should be in the master_postinit, since only the host has the actual sanity component. Edited December 18, 2014 by rezecib Link to comment Share on other sites More sharing options...
Conker446 Posted December 18, 2014 Author Share Posted December 18, 2014 @Conker446, Any changes to TUNING like you're doing will always affect all players, unless you're changing tuning values that specifically mention a player (e.g. TUNING.WOLFGANG_START_MIGHTY_THRESH). As for what you want to do, if you look at Wolfgang, he has the night part you want: inst.components.sanity.night_drain_mult = 1.1So you can set that to zero to remove night drain entirely. Looking at the sanity component, though, it looks like this multiplier is also applied to the day value, so you'll probably have to use an approach like Willow's gaining sanity from fires:local function sanityfn(inst) local x,y,z = inst.Transform:GetWorldPosition() local delta = 0 local max_rad = 10 local ents = TheSim:FindEntities(x,y,z, max_rad, {"fire"}) for k,v in pairs(ents) do if v.components.burnable and v.components.burnable.burning then local sz = TUNING.SANITYAURA_TINY local rad = v.components.burnable:GetLargestLightRadius() or 1 sz = sz * ( math.min(max_rad, rad) / max_rad ) local distsq = inst:GetDistanceSqToInst(v) delta = delta + sz/math.max(1, distsq) end end return deltaend inst.components.sanity.custom_rate_fn = sanityfnWithout testing this at all, I think this rewrite of Willow's function should do what you want: inst.components.sanity.custom_rate_fn = function() if TheWorld.state.isday then return -8/60 else return 0 end end You are my savor!! 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