# Problems with damage and status effect

**URL:** <https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint\
**Created:** [September 14, 2022, 9:37am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451 "2022-09-14T09:37:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LoadingUserName](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LoadingUserName](https://forums.unrealengine.com/u/LoadingUserName)\
**Post date:** [September 14, 2022, 9:37am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/1 "2022-09-14T09:37:18Z")

</div>

Been trying to figure this out all day. I have base damage set to 5, health is 100. The first attack that lands does 55 damage, then each attack after does the normal 5. I can’t figure out why it’s multiplying for the first hit. Second part is that the enemy won’t resume normal walk speed after 8 seconds, but if I get close enough for it to attack it seems that walk speed resets after the attack animation plays.

 ![health-slow](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/5/f/b5f67ca94a7e9b25ae5b84dcb9d42b21487d2150.jpeg)  
 ![icebolt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/f/e/6fe412c9c90dcdc32135da5ac900cce8668f3e91.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 14, 2022, 9:49am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/2 "2022-09-14T09:49:26Z")

</div>

> [@LoadingUserName](#):
>
> The first attack that lands does 55 damage

`Print String` damage after `Event Any Damage` - what does it say? How often does it print? You see the expected value or something strange? How is this value treated in the widget later on? Perhaps it’s a matter of formatting?

> [@LoadingUserName](#):
>
> Second part is that the enemy won’t resume normal walk speed after 8 seconds,

You destroyed that actor. So the script after the `Destroy` node will not work correctly since the actor `IceBolt` no longer exists. Put the slow down script in the Enemy blueprint instead, it belongs there.

---

<div class="post-metadata">

**Author:** ![LoadingUserName](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LoadingUserName](https://forums.unrealengine.com/u/LoadingUserName)\
**Post date:** [September 14, 2022, 9:55am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/3 "2022-09-14T09:55:29Z")

</div>

> [@Everynone](#):
>
> `Print String` damage after `Event Any Damage` - what does it say? How often does it print? You see the expected value or something strange? How is this value treated in the widget later on? Perhaps it’s a matter of formatting?

I already did that, that’s how I know the first hit does 55 and the rest are 5. It prints damage done per hit. Nothing unusual besides the first being 55.

> [@Everynone](#):
>
> You destroyed that actor. So the script after the `Destroy` node will not work correctly since the actor `IceBolt` no longer exists. Put the slow down script in the Enemy blueprint instead, it belongs there.

All right, so move the set slowed before the destroy actor then? The slow down script is in the enemy bp, only the set variable is in the skill bp.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 14, 2022, 10:03am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/4 "2022-09-14T10:03:16Z")

</div>

> I already did that, that’s how I know the first hit does 55 and the rest are 5. It prints damage done per hit. Nothing unusual besides the first being 55.

How about when damage is applied - is the correct value being printed before you push the value in? How many times does it trigger?

> [@LoadingUserName](#):
>
> All right, so move the set slowed before the destroy actor then? The slow down script is in the enemy bp, only the set variable is in the skill bp.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/0/6/306a17349f3f1559d7dad6033e1028458a0f705a.jpeg)

This script is no good and will stop working as soon as you have more than 1 enemy. Read the tooltip on the `Get Actor of Class` node. Consider removing it altogether and try the following in the enemy:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/4/ab46a621c5dc226b0c560c6e49a29b282da1ee3b.png)

Why complicate life with booleans and waste performance with ticking. Later on, once you have this stuff working the way you need, you could look into the `Damage Type` (see pin on the `Event Any Damange` node) - this will allow you to identify the incoming damage better. _Ice_ will slow the character down but _Fire_ will apply a _DoT_ effect of some sort, surely.

> health is 100

I’d triple check that. Measure twice, cut once. You have this `Health` variable flagged as `Instance Editable` - perhaps it was changed from the Class Defaults.

---

<div class="post-metadata">

**Author:** ![LoadingUserName](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LoadingUserName](https://forums.unrealengine.com/u/LoadingUserName)\
**Post date:** [September 14, 2022, 10:16am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/5 "2022-09-14T10:16:39Z")

</div>

It’s a single print per hit. First one prints out 55, then each hit after prints 5.

> [@Everynone](#):
>
> Why complicate life with booleans and waste performance with ticking.

Well, I’m kind of winging it here. Been weeks since I had time to mess with this and just been learning as I go since I started a few months back. Thanks for the info, man. I’m probably just going to scrap these files and start over this part over.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 14, 2022, 10:19am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/6 "2022-09-14T10:19:43Z")

</div>

> [@LoadingUserName](#):
>
> It’s a single print per hit. First one prints out 55, then each hit after prints 5.

Is this applied or received? This is still not too clear at this point. Simplify the whole thing as much as you can to debug it and get to the bottom of it:

- in one blueprint:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/9/d/c9de66ab3467fe245671730573a53bfa11426228.png)

- and in the other:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/5/d/95d33419669750f853bc2f8f4359f43ed6f04814.png)

What do you get?

---

<div class="post-metadata">

**Author:** ![LoadingUserName](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LoadingUserName](https://forums.unrealengine.com/u/LoadingUserName)\
**Post date:** [September 26, 2022, 11:14am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/7 "2022-09-26T11:14:09Z")

</div>

I just rebuilt it from the ground up. I’m sure there’s a better way… but this works just fine for the moment. Two problems I have now is I can’t get my burning DoT to stop after 10 seconds and figuring out how to attach a particle effect to the enemy per status effect. IE, flames for burning, frosty cloud for chilled(slowed), etc, etc. Red circle was just a desperate final attempt. Didn’t expect it to work but, yeah this whole thing is just a learning project.

 ![BE-ad-full](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/5/655b499aacfc16ded5281ee2cd2233a183aff4d8.jpeg)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 26, 2022, 11:26am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/8 "2022-09-26T11:26:14Z")

</div>

> [@LoadingUserName](#):
>
> Two problems I have now is I can’t get my burning DoT to stop after 10 seconds

A really versatile method I can’t recommend _enough_ is through actor components.

When event happens, we dynamically create and attach an actor component to target actor. This components can deal damage, heal, shows particles, count time and handle anything related to this effect. When the timer expires, the component destroys itself.

Some examples:

> [@Healing of damage over time](https://forums.unrealengine.com/t/healing-of-damage-over-time/152498/4):
>
> The component has 1 function (top) and 1 custom event (bottom): Variables: Injury Type is an enumerator (Mild | Moderate | Severe) Health Modifier - how the component affects Player Health Recovery Time - how long it persists in seconds When added to the player’s blueprint, we run the \*Set Recovery and Health \*function (as seen below). The component is then configured according to the Injury Type; here, we set Recovery Time and the \*Health Modifier. \*We also Set Timer By E…

> [@How to start making an Oblivian style Spell creation system](https://forums.unrealengine.com/t/how-to-start-making-an-oblivian-style-spell-creation-system/619474/5):
>
> This. @AndracoDragons look into actor components. Each component can host variables and define behaviours. A spell actor can have any number of those components present. These can be added and removed dynamically, too. Here’s a crude & overly simplified example: a spell actor some of components defining the behaviour / effects of the spell: the component hurts pawns with fire damage every .25s for as long (up to 4s) as they stay within the spell’s Area Of Influence defined by th…

> [@How to make potion that heals over time?](https://forums.unrealengine.com/t/how-to-make-potion-that-heals-over-time/118293/4):
>
> You could make a simple event that regenerates player’s health using a timer. For something very simple it might just be enough. But there is a better, more modular method that does not limit you to having a single effect affecting the player (or any other entity for that matter). Think of it as of a temporary effect (or an ability) that the player gains for X amount of time and once the time is up, the effect expires. And more of those can be active at the same time, too. So imbibing a couple …

> [@Is there a better way to handle this](https://forums.unrealengine.com/t/is-there-a-better-way-to-handle-this/449749/4):
>
> Well im planning on adding more Debuffs and wanted to know if there is a easier/more efficient way of doing this. There is. Consider the following and see if it’s applicable to how you need your systems to work. Actor Component - can be created in the Content Browser, it’s a piece of reusable functionality that can be added / removed from actors, during run-time too - that’s what we’re doing here. The general idea is: design an actor component that acts as a buff / debuff for each effe…

* * *

The official vid I learnt it from:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/c/c/bcc3d0df50158c1955c450c29b3b9bbd255898a3.jpeg "Using BP Components for Game Behaviour | Live Training | Unreal Engine") ](https://www.youtube.com/watch?v=qr4ZjieAQKY)

This approach allows you build modular, easily scalable systems where the functionality is encapsulated within the component - so you do not need to burden the Player, NPC, Enemies or world entities with all possible combinations of what could happen to them.

You instead spawn a desired effect on them and it goes away on its own.

---

<div class="post-metadata">

**Author:** ![LoadingUserName](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LoadingUserName](https://forums.unrealengine.com/u/LoadingUserName)\
**Post date:** [September 26, 2022, 11:29am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/9 "2022-09-26T11:29:55Z")

</div>

Cool, man, thanks. I’ll look into it.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [September 26, 2022, 11:46am UTC](https://forums.unrealengine.com/t/problems-with-damage-and-status-effect/648451/10 "2022-09-26T11:46:19Z")

</div>

> Two problems I have now is I can’t get my burning DoT to stop after 10 seconds and figuring out how to attach a particle effect to the enemy per status effect. IE, flames for burning, frosty cloud for chilled(slowed), etc, etc.

Consider this as a kick-starter:

- a parent actor component and a bunch of children responsible for various effects:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/4/3/a43206e75e5fc51508b8f3c0ba40e4116c006055.png)

- a trap actor in the world that will spawn an effect component:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/f/4/bf4d45752685fda116e0d31ea5f5ef7b43b6d94c.jpeg)

- the component we give to the actor when they walk into the trap - AC\_FireTrap:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/f/7/df712f4299bf6a4db3a174fba62e0d4fb676e34f.png)

- The result:

The component lives on the player for 3s, does its job and then destroys itself.

Good luck!
