Cuddlepuff Posted December 1, 2016 Share Posted December 1, 2016 Today, I've tried to use Sanity as variable for my character in Don't Starve Together - making them stronger the lower their sanity gets but I can't really find a way to accomplish this. I've tried so many things and I can't seem to find the right way to do it. Here's the master_postinit section: local master_postinit = function(inst) -- choose which sounds this character will play inst.soundsname = "willow" -- Stats inst.components.health:SetMaxHealth(150) inst.components.hunger:SetMax(150) inst.components.sanity:SetMax(10) local sanity_percent = inst.components.sanity.current -- Variation Test -- Damage variations local sanity_damage_var = sanity_percent / 10 local sanity_damage_mult = 1.5 - sanity_damage_var -- Speed variations local sanity_speed_var = sanity_percent / 20 local sanity_speed_mult = 1.25 - sanity_speed_var inst.components.combat.damagemultiplier = sanity_damage_mult -- Damage Multiplier inst.components.locomotor:SetExternalSpeedMultiplier(inst, "cuddlepuff_speed_mult", sanity_speed_mult) -- Speed Multiplier -- Hunger rate (optional) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.OnLoad = onload inst.OnNewSpawn = onload end All I need is someone to enlighten me. Am I doing it wrong? And where is my mistake? Is it impossible to do that? Link to comment Share on other sites More sharing options...
Aquaterion Posted December 1, 2016 Share Posted December 1, 2016 I already replied on your other post with the same exact title and question.. please don't spam Link to comment Share on other sites More sharing options...
. . . Posted December 1, 2016 Share Posted December 1, 2016 Above YOURCHARACTER's master_postinit you would put local function sanitydelta(inst) if inst.components.sanity.current >= 100 then inst.components.combat.damagemultiplier = 100 elseif inst.components.sanity.current >= 50 then inst.components.combat.damagemultiplier = 1 elseif inst.components.sanity.current <= 50 then inst.components.combat.damagemultiplier = 0 end end Inside YOURCHARACTER's master_postinit you would put inst:ListenForEvent("sanitydelta", sanitydelta) Link to comment Share on other sites More sharing options...
Neu7ral Posted December 1, 2016 Share Posted December 1, 2016 (edited) Another variant. above. local function sanitydelta(inst) if inst.components.sanity and inst.components.combat then local sanity = inst.components.sanity:GetPercent() inst.components.combat.damagemultiplier = 1.75 - 1 * sanity end end Inside your master_postinit. inst:ListenForEvent("sanitydelta", sanitydelta) Note:This code calculates your current sanity. 1.75 is current Warren max damage and the -1 is the damage removal because of sanity. Edited December 1, 2016 by Neutral_Steve Link to comment Share on other sites More sharing options...
HomShaBom Posted December 2, 2016 Share Posted December 2, 2016 Even though answers were given above, you could check out how its done for wolfgang but instead of hunger use sanity and make him stranger instead of weaker when it's low. 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