Greetings All, I’m currently working on a Health Progress Bar for my characters. Some have additional progress bars for Armor or Shields, each having their own specified amounts. So here is the situation, lets say a character has 200 Health and 50 Armor. Then they take 100 Damage, the Armor can absorb 30% of the incoming Damage (50/0.7 = 72(Ceiled)).
100 (Damage) - 72 (Absorbed) = 28 (Remaining Overflow to subtract from Health)
If my math seems correct, how would I then go about taking the remaining overflow amount and smoothly have it take away from the characters health? Because at the moment the damage my character takes just subtracts from the Armor until it reaches 0 and then starts taking away from the health, rather than finishing off the armor and subtracting from the health depending on the amount of damage and remaining armor. I hope I’m explaining this properly, I’m attaching a snippet of my code to help. Thanks for taking the time to read and respond.
Sorry I didn’t specify in my post, not sure if it matters or not, but the damage event is getting inherited by child character classes. I noticed the 3 local variables you had for the Calculate Damage Function and wasn’t sure if setting up the function that way wouldn’t transfer over to the child characters, I ended up just making them regular variables as well for testing.
I tested this out in different ways and only got two outcomes. 1) When damaging another character (Server OR Client) the receiving Player’s Armor Value would plummet to Zero. (e.g. 200 Armor takes 70 Damage would just erase all armor). 2) Nothing would change, no Damage was being received.
I’ll keep testing this out though, thank you for giving me an idea to work with.
Function local vars are a part of the function itself. Local vars do not retain value changes once the function has finished. They “reset” to their defaults. Each of which in mine are 0.0
If you replace these with globals then you have to “RESET/CLEAR” them before you RETURN. Otherwise they will retain the values set in the function.
You can call the function from any class that has a reference to the owning actor.
Function usage
Some Event/Function determines the damage output of a hit. e.g. 212
Pass that value to the “Calculate Damage” function (Incoming DMG).
Function Returns what Player should receive and what the Armor should receive.
Player Health - Player DMG
Armor Health - Armor DMG
The only way armor is being reduced to 0 from a single hit is if the absorption dmg exceeds armor health or its being deducted multiple times.