Regen if don`t take damage problem (multiplayer)

Hi guys, i need your help! I want create 2 simple things for my multiplayer game.

  1. I want create an armor regen if the player dont receive damage for X seconds. Let me explane my think better.. Player dont receve damage → start regen Armor. Player receve damage → stop Armor regen → lose Armor → Armor = 0 → lose Health → Health = 0 → Death.
    I made an Armor regen and damage, and they work well but if I add a Branch with “Have Damage?” the damage don`t work. If I bypass the Branch and I connect “Event anydamage” with “set Armor” the damage work but the Armor continue to reload (Armor regen and Armor damage at the same time).
  2. I want create a “stun” if the enemy is hit by the “Torch” than I create a Branch after the “Have damage?” Branch but don`t work.
    Thanks to anyone who want to help me.

Please show the code for Armor regen

Wait I see it in the links.

I havent identified the problem yet but you are doing it wrong to put a delay in a tick event.

If you want it to happen every 0.1 sec then just use a Timer instead or change the Tick rate to be slower.

heres a more complete example maybe itll help a bit. the only issue i could forsee is that you may need to store the armor value after subtracting from it, may not need to though. in any event im falling asleep in my chair so who knows maybe i left in an error somewhere haha

Thank you very much for your fast reply guys. I try to ricreate the ThompsonN13s nodes but dont work for me, no damage, no regen. I also try to create a timer but i dont know how it works. Sorry but i use Unreal from 2 months, Im noob ahahhah

what do you mean when you say it doesnt work? have you done any debugging to see at which point it fails? are you using the apply damage node when you are damaging the player?

i just recreated the entire system for testing complete with a way to apply damage to the player and two progress bars representing health and armor and it seemed to work without issue. the only places i could see where you would have an issue would be either by not applying damage using the apply damage node or if you were using progress bars since many new people have issues with those.

i guess i can try to make a explanation of how the script provided works. the beginning event will trigger anytime damage comes in from the built in damage nodes. we then subtract the damage from the armor and check if the armors value is less than 0. if the armor is more than 0 then we just set the armor value and move on to the regen. if the armor is less than 0 then we need to deduct however much damage the armor couldnt cover from the health. to do this we need the absolute value of the remaining damage. example time: say we have 5 armor and take 10 damage, 5-10= -5, so we need to subtract 5 from health, absolute value is like getting the magnitude without caring about direction, so the absolute value of -5 is 5. once we subtract the damage from health we set the value of health, then we can set the value of armor to 0 since 0 is its min value (logically speaking). next we check is the health greater than 0, if true we want to destroy the actor (or run a death script), if false we want to move to the regen.

this brings us to the third branch in the script, this branch just checks if we are currently regen-ing. if we are then we want to stop the regen since we took damage. the next node is the retriggerable delay which controls the amount of time since damage until the regen starts. i explained this before but basically each time its called it will restart the time until completion and will not output until it reaches 0. once the delay reaches 0 we want the regen to start so we call a custom event regen.

now the regen event just serves to begin the timer. the timer once started will loop (since the option is checked) at a interval of ever 0.2 seconds (the time value). this means it will call the add health event each time it triggers, so add health will be called every 0.2 seconds until we tell the timer to stop. the clear timer nodes are how we tell the timer to stop looping and end. on to the add health event, this events purpose is to fill health until full then once health is full fill the armor (i used 100 to represent full in this case). to accomplish this we first check is health not equal to 100, if its not 100 then we need to add health (this cant handle a value greater than full), if health does equal 100 then its full and we move on to armor. we then ask the same thing for armor. if both health and armor are full then we stop the timer since we dont need to regen anymore. i didnt mention this setup adds one health per 0.2 seconds due to the increment float (++) node. also if health is added it ends the script at that point and doesnt also add armor.

that should cover most of the logic. if you have questions on something let me know. as with anything if you have a problem or question try to be specific so we can better help.

below is a very basic example of doing a health regen after a time threshold of not taking damage. as for the decreasing armor before health and all that i did a write up a month or two ago that ill try to find later.

i guess i should explain a bit more. the retriggerable delay will restart each time its called and will not call anything after it until it is allowed to reach 0. so if you take damage when the delay is at .5 seconds left it will restart back at 3 seconds (or whatever you set), this makes it ideal for your situation. also another thing to note that i didnt include in the picture is that if you want damage to interrupt the health regeneration you just need to clear the timer like you see after the branch.

Hi, sorry if I didn`t reply but this week was very hard at work, by the way I found a solution for my issue, I post the nodes that i have created if anyone have the same problem like me, just remember to set “replicate” on “Armor” and “Have Damage?” variables. Thank you very much for your time!alt text

your method is pretty inefficient. your calling the add armor event every 0.1 seconds all the time, you would be better suited to have it state based so the script only runs when its needed (like when armor is below max). you also dont really need the timer just after the event any damage its much simpler to use a delay and maybe a sequence node.