Andreasgamming Posted February 12, 2018 Share Posted February 12, 2018 local function sanitydelta(inst) if inst.components.sanity.current >= 100 then inst.components.combat.damagemultiplier = 1.5 elseif inst.components.sanity.current >= 50 then inst.components.combat.damagemultiplier = 2 elseif inst.components.sanity.current <= 50 then inst.components.combat.damagemultiplier = 4 end end This code, as almost every one who looks at it will know this already, increases the damage multiplier as sanity goes down, I want to tweak it so it not only increases the attack damage of a character but also increases the hunger rate of the character. I've got an Idea but not too sure if it'll work. Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/ Share on other sites More sharing options...
Aquaterion Posted February 12, 2018 Share Posted February 12, 2018 36 minutes ago, Andreasgamming said: local function sanitydelta(inst) if inst.components.sanity.current >= 100 then inst.components.combat.damagemultiplier = 1.5 elseif inst.components.sanity.current >= 50 then inst.components.combat.damagemultiplier = 2 elseif inst.components.sanity.current <= 50 then inst.components.combat.damagemultiplier = 4 end end This code, as almost every one who looks at it will know this already, increases the damage multiplier as sanity goes down, I want to tweak it so it not only increases the attack damage of a character but also increases the hunger rate of the character. I've got an Idea but not too sure if it'll work. inst.components.hunger.hungerrate = 1 Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1003404 Share on other sites More sharing options...
Andreasgamming Posted February 12, 2018 Author Share Posted February 12, 2018 So then I just do local function sanitydelta(inst) if inst.components.sanity.current >= 100 then nst.components.hunger.hungerrate = 1.5 elseif inst.components.sanity.current >= 50 then nst.components.hunger.hungerrate = 2 elseif inst.components.sanity.current <= 50 then nst.components.hunger.hungerrate = 4 end end Right? Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1003407 Share on other sites More sharing options...
Aquaterion Posted February 12, 2018 Share Posted February 12, 2018 if they're gonna trigger at the same time as sanity changes then you should do them like so; local function sanitydelta(inst) if inst.components.sanity.current >= 100 then inst.components.combat.damagemultiplier = 1.5 inst.components.hunger.hungerrate = 1.5 elseif inst.components.sanity.current >= 50 then inst.components.combat.damagemultiplier = 2 inst.components.hunger.hungerrate = 2 elseif inst.components.sanity.current <= 50 then inst.components.combat.damagemultiplier = 4 inst.components.hunger.hungerrate = 4 end end Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1003410 Share on other sites More sharing options...
Andreasgamming Posted February 12, 2018 Author Share Posted February 12, 2018 Ah alrighty Thanks! Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1003413 Share on other sites More sharing options...
Andreasgamming Posted February 14, 2018 Author Share Posted February 14, 2018 New Question, How can I make this code inst:AddComponent("healthRegen") Configurable or add a value that I can change? Also how can I make it to where the shadow creatures ignore the player or be passive towards her? Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1003866 Share on other sites More sharing options...
Andreasgamming Posted February 16, 2018 Author Share Posted February 16, 2018 Alrighty is there any way to give a character a damage resistance, Make them take more damage from starving, and as well as give them a small healtt regen? Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1004845 Share on other sites More sharing options...
Kyrogeniz Posted February 16, 2018 Share Posted February 16, 2018 (edited) Okay, for the damage increase when starving, you'll need something like this: local function sanitydelta(inst) if inst.components.sanity.current > 100 then inst.components.health:SetAbsorptionAmount (-0.1) -- 10% more damage taken elseif inst.components.sanity.current > 50 then inst.components.health:SetAbsorptionAmount (-0.3) -- 30% more damage taken elseif inst.components.sanity.current < 50 then inst.components.health:SetAbsorptionAmount (-0.5) -- 50% more damage taken end end This should work; here are both the damage multiplier above and this code put into one block: . local function sanitydelta(inst) if inst.components.sanity.current >= 100 then inst.components.combat.damagemultiplier = 1.5 --1.5x damage multiplier inst.components.hunger.hungerrate = 1.5 --1.5x hunger rate inst.components.health:SetAbsorptionAmount (-0.1) -- 10% more damage taken elseif inst.components.sanity.current >= 50 then inst.components.combat.damagemultiplier = 2 -- 2x damage multiplier inst.components.hunger.hungerrate = 2 -- 2x hunger rate inst.components.health:SetAbsorptionAmount (-0.3) -- 30% more damage taken elseif inst.components.sanity.current <= 50 then inst.components.combat.damagemultiplier = 4 -- 4x damage multiplier inst.components.hunger.hungerrate = 4 -- 4x hunger rate inst.components.health:SetAbsorptionAmount (-0.5) -- 50% more damage taken end end I can work on the regeneration after class. Edited February 18, 2018 by Kyrogeniz Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1005007 Share on other sites More sharing options...
Andreasgamming Posted February 16, 2018 Author Share Posted February 16, 2018 ^_^ Thanks! I'll get these added then tested! Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1005065 Share on other sites More sharing options...
Andreasgamming Posted February 18, 2018 Author Share Posted February 18, 2018 Bump Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1005825 Share on other sites More sharing options...
Kyrogeniz Posted February 18, 2018 Share Posted February 18, 2018 Did the last code work? I'm experimenting with triggering regeneration states now. Quote function HealthRegeneration(inst) if inst.components.sanity.current > 100 and inst.components.health.current < 100 then --set that to the max hp in them all inst.components.health:StartRegen(2,2) --amount, period elseif inst.components.sanity.current > 50 and inst.components.health.current < 100 then inst.components.health:StartRegen(4,2) elseif inst.components.sanity.current < 50 and inst.components.health.current < 100 then inst.components.health:StartRegen(6,2) end end Here's my theory; it's untested cause I'm going to eat soon, but lemme know if it helps out! @Andreasgamming Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1006069 Share on other sites More sharing options...
Andreasgamming Posted February 19, 2018 Author Share Posted February 19, 2018 Well the health Regen isn't based on the sanity like the hunger rate and the strength is... I need is to be passive and strong enough to at least give players a little time to find food before they die. I would also like to know how to make night vision toggle-able, have players being able to turn their night vision on or off with the push of a key or a configuration... Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1006436 Share on other sites More sharing options...
Kyrogeniz Posted February 19, 2018 Share Posted February 19, 2018 46 minutes ago, Andreasgamming said: Well the health Regen isn't based on the sanity like the hunger rate and the strength is... I need is to be passive and strong enough to at least give players a little time to find food before they die. I would also like to know how to make night vision toggle-able, have players being able to turn their night vision on or off with the push of a key or a configuration... So for the health regen, then, just take the code straight out of it like this: Quote function HealthRegeneration(inst) if inst.components.health.current < 100 then --set that to the max hp in them all inst.components.health:StartRegen(2,2) --amount, period end end Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1006475 Share on other sites More sharing options...
Andreasgamming Posted February 19, 2018 Author Share Posted February 19, 2018 I tested it, and it doesn't seem to work... Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1006497 Share on other sites More sharing options...
Kyrogeniz Posted February 19, 2018 Share Posted February 19, 2018 (edited) How about just: inst.components.health:StartRegen(2,2) inside the character LUA? Edited February 19, 2018 by Kyrogeniz Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1006521 Share on other sites More sharing options...
Andreasgamming Posted February 19, 2018 Author Share Posted February 19, 2018 I'll try that Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1006523 Share on other sites More sharing options...
Andreasgamming Posted February 20, 2018 Author Share Posted February 20, 2018 It had crashed saying that inst wasn't declared... Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1006622 Share on other sites More sharing options...
Kyrogeniz Posted February 20, 2018 Share Posted February 20, 2018 (edited) Where did you place it? I copy-pasted it directly into Pryce's .lua and his master_postinit and it worked fine. Quote local master_postinit = function(inst) inst.soundsname = "pryce" inst.components.health:SetMaxHealth(200) inst.components.hunger:SetMax(170) inst.components.sanity:SetMax(90) inst.components.combat.damagemultiplier = 1.75 inst.components.hunger.hungerrate = 1.5 * TUNING.WILSON_HUNGER_RATE inst.OnLoad = onload inst.components.health:StartRegen(2,2) inst:ListenForEvent("killed", onkilledother) end Edited February 20, 2018 by Kyrogeniz Link to comment https://forums.kleientertainment.com/forums/topic/87528-tweaking-a-few-lines-of-code-in-my-mod/#findComment-1006782 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