Kiibie Posted October 21, 2017 Share Posted October 21, 2017 Hello! I've been modding a character that is allergic to bees and I have set him to lose sanity around them, but I'm looking for a way that he could take WAY more damage when hit by them! Here's a thing I tried: local function onhit(inst) if target:HasTag("bee") then inst.components.health:SetAbsorptionAmount(-3) else inst.components.health:SetAbsorptionAmount(0.4) end end I thought it'd be fairly easy, but as I am very new to coding, I don't know how to proceed for this one. I tried to change his defense upon a hit, but I feel this is wrong as it does not work. Does anyone have an idea how this works? Link to comment https://forums.kleientertainment.com/forums/topic/83163-take-more-damage-from-bees-coding-help/ Share on other sites More sharing options...
. . . Posted October 21, 2017 Share Posted October 21, 2017 maybe this work, put in modmain.lua Spoiler local Character = "YOURCHARACTERPREFABNAMEHERE" local Damage_Mult = 2 -- double damage AddComponentPostInit("combat",function(inst) if not GLOBAL.TheWorld.ismastersim then return end local oldbonusdamagefn = inst.bonusdamagefn inst.bonusdamagefn = function(attacker, target, damage, weapon) local bonus = 0 if oldbonusdamagefn then bonus = oldbonusdamagefn(attacker, target, damage, weapon) or 0 end if target.prefab == Character and (attacker:HasTag("bee")) then bonus = bonus - (damage + bonus) * Damage_Mult end return bonus end end) Link to comment https://forums.kleientertainment.com/forums/topic/83163-take-more-damage-from-bees-coding-help/#findComment-965396 Share on other sites More sharing options...
Kiibie Posted October 21, 2017 Author Share Posted October 21, 2017 (edited) @SuperDavid It works, but the bee restores my life when it hits me! X'D I changed the "2" for a "-4" and it now works just fine! Thanks a bunch for this!! I would've never figured out by myself c': Edited October 21, 2017 by Kiibie Link to comment https://forums.kleientertainment.com/forums/topic/83163-take-more-damage-from-bees-coding-help/#findComment-965401 Share on other sites More sharing options...
Kiibie Posted October 21, 2017 Author Share Posted October 21, 2017 (edited) @SuperDavid I'm actually wondering if it's possible to make my character Groggy for a set amount of time when stung by a bee. OR even better, groggy until he heals himself with a healing salve or use an adrenaline shot. Would you happen to know how? I had made a character that got groggy under 30 of hunger, with that code: if inst.components.hunger.current >= (0) and inst.components.hunger.current < (30) then if inst:HasTag("groggy") then return else inst:AddTag("groggy") inst.components.locomotor:SetExternalSpeedMultiplier(inst, "grogginess", 0.6) This could somehow be written to when the character gets stung? Edited October 22, 2017 by Kiibie Link to comment https://forums.kleientertainment.com/forums/topic/83163-take-more-damage-from-bees-coding-help/#findComment-965405 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