I'd like to incorporate a method for my player to leech life from enemies based on the damage of each attack.
The image below shows how damage is calculated in my game. It's a bit complicated, since there are many possible debuffs the monsters could have to increase the damage taken.
I want to take 5% of the damage dealt and add it to player health.
What I have done so far is add another line below it "Add to Health -> Damage calculation*0.05", but this is very cumbersome. I have 40 different attack types in this game, and I am looking for a simpler way to do this.
Is there a way to store the damage value each time a monster takes damage and use that in a calculation to add player health?
Thanks.