• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Apply armour reduction on hit (without orb effect)

Status
Not open for further replies.
Level 12
Joined
May 22, 2015
Messages
1,051
I want to basically make orb of corruption, except it isn't an orb effect.

I have damage detection and I can tell when it is a normal attack. I can apply the armour reduction with a spell and dummy unit (already does this, actually). My problem is that I need the first hit to deal damage with the reduced armour as well.

Any idea how I can do this?

I can modify damage with the damage system, but how much damage do I need to add? Is there a nice way to quickly calculate how much damage to add?

My only idea is to:
- If the unit does not already have the armour reduction buff, then
- Make the damaged unit have full health
- Deal 100 damage
- Find actual damage dealt
- Make dummy unit and cast the armour reduction spell
- Make the damaged unit have full health
- Deal 100 damage
- Find actual damage dealt
- Reset damaged unit to previous health
- Divide second damage by first damage
- Multiply current hit damage by the result

Ignore that it could kill the unit - even when at full health - I can deal with that if I need to. I believe this will work, but holy hell that is a ton of steps. For reference, it is likely that only 2 or 3 units will have this ability at most, though it could have a ton (not in the players' interest since you would most definitely lose horribly).

Is there anything easier / less expensive to calculate?
 

Ardenian

A

Ardenian

Maybe via an order event ?
Check if a unit gets an order to attack another unit having the item orb of corruption.
If so, then execute the dummy spell.

I don't know how it behaves when the unit does not get a manual order, but changing target in battle. You might have to use a workaround with stopping the attacking unit and then casting the dummy unit spell and afterwards ordering the attacking unit to attack the unit having the buff now.
 
Level 12
Joined
May 22, 2015
Messages
1,051
I could trigger it on the event "Unit - A unit is attacked", but then it would happen without your unit hitting them. You could start the attack animation and then move away and the enemy will still have the orb of corruption debuff on them, which is something I don't want.
 

Ardenian

A

Ardenian

Does only one unit use this item ? You could add a small expiration time then, in relation to the attack speed of the attacking unit.

Hm, another way could be to create a dummy with an armor reducing aura at the point of the attacked unit. Set the attacking unit to a variable and check its orders. If the unit gains orders interrupting the attack, like moving away, then remove the dummy unit.
The disadvantage is that you have to set the position of the dummy unit to the position of the attacked unit which is an awful thing, if I recall right, as you have to create a loop using periodic timers.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Well I will have way more freedom if I can do it nicely with the trigger instead of the orb effect. I could add armour penetration like in LoL where it ignores armour only for your hits and stuff like that (basically apply armour reduction, do damage, remove armour reduction).

I would just prefer if this was not an orb effect.


The attack animation for units would vary greatly since you can put the item on a bunch of different units. It would also mess up badly for ranged units since the timing can vary drastically.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Other way of doing it:
Set orb effect duration to 0.01 seconds.

It'll only work for your attacks, unless you have someone attack during that 0.01 seconds time.

Well I can remove the buff in the damage detection. It may still happen if multiple units hit at the same time, but it would be super rare.

The problem with this is that it would still be an orb effect. It wouldn't be able to stack with other armour reduction modifiers (if I wanted them to stack) and it would collide with other orb effects.

The armour detection system could work, but it would be pretty much the exact same as just finding the damage difference (in terms of expensiveness). I don't mind doing all the calculations and stuff myself, so I will probably just go with that. The calculations in there may be handy for me, though. +rep

I'm mostly worried about code that is slow on something like this, but it really shouldn't be happening THAT much. It would most likely just be once per attack per hero that actually has a corresponding item. This will be something like 0-3 per game minus cases where people are doing something silly (almost certainly resulting in a loss).

Thanks everyone for the help.
 
Level 12
Joined
May 22, 2015
Messages
1,051
You don't need to detect armor type or amount. You can quite literally use a bonusmod(or some item abilities) to change the armor amount.

I would need to modify the damage just for the current hit. Modifying it on damage detection won't change how much damage it does since the damage amount is already determined.

If there is some way to increase the damage the correct amount without knowing how much armour the unit has originally and without knowing the original damage before armour / shield block, then I can do that instead. I just don't know how to do it more easily than by checking how much more damage the unit will receive (as a percentage) after armour has been reduced.
 
Well the only methods I know of I suggested already for you SAUS, I think someone was working on a system for this as well.

Edit: Found it, Wietlol was inspired from DDS's because they couldn't do what your trying to do and he made one. Not sure if he ever fixed this problem though it was to deal pure damage and not have reduced damage by default armor. http://www.hiveworkshop.com/forums/lab-715/new-damage-system-266183/
 
Level 12
Joined
May 22, 2015
Messages
1,051
You don't need to modify the damage. Just give the unit an ability that changes armor. You know, the same kind of ability that items have.

When do I add the ability though? I need to have it reduce armour for the attack that is currently happening. If I can have it happen just before the actual damage is dealt, that is fine, I just don't want it to be such that you can right click on an enemy and then right click away and still have the armour reduction on them.

I'm pretty sure adding it in the damage detection system will not modify the damage of the current attack. This means that the armour will only be reduced for other attacks (depends on duration of the ability). I want it to modify the current attack that puts the negative armour on the enemy as well.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
The typical armor formula is fairly simple. Every positive point of armor increases effective health against physical attacks by 6% compared to the previous. That is, the effective health gain increases exponentially compared to the base amount of health. At the end of this page are the armor formulae.

The solution would be as follows:
When a unit that has the "orb" deals damage you check if the target already has its buff.
a)It does. Don't do anything, because the armor formula already handles it.
b)It doesn't. Use the armor formula to increase damage done based on how much armor the unit is supposed to be missing.

b) translates to (armor*0.06)/(1+0.06*armor)-((armor+x)*0.06)/(1+0.06*(armor+x)) where x is the default armor change from orb of corruption.
This gives us the difference between reductions.
If you can simplify this formula, do so. If you can't, well, no problem.
We then do damage/(1-reductiondifference)
I'm not sure if I did everything right. It sure sounds more complicated now than it is though.

Note: I am actually quite bad at math. Just trying to show you the approach.
 
Level 12
Joined
May 22, 2015
Messages
1,051
The typical armor formula is fairly simple. Every positive point of armor increases effective health against physical attacks by 6% compared to the previous. That is, the effective health gain increases exponentially compared to the base amount of health. At the end of this page are the armor formulae.

The solution would be as follows:
When a unit that has the "orb" deals damage you check if the target already has its buff.
a)It does. Don't do anything, because the armor formula already handles it.
b)It doesn't. Use the armor formula to increase damage done based on how much armor the unit is supposed to be missing.

b) translates to (armor*0.06)/(1+0.06*armor)-((armor+x)*0.06)/(1+0.06*(armor+x)) where x is the default armor change from orb of corruption.
This gives us the difference between reductions.
If you can simplify this formula, do so. If you can't, well, no problem.
We then do damage/(1-reductiondifference)
I'm not sure if I did everything right. It sure sounds more complicated now than it is though.

Note: I am actually quite bad at math. Just trying to show you the approach.

I'll look more into it, but from going through it in my head (before I made this thread), I had come to the conclusion that it would not be possible to get the correct value without knowing the armour value of the unit taking damage. Finding the armour value requires doing damage to test the armour, so it wouldn't really be much better than my solution (which is basically the same thing, except it would need to do the damage twice in favour of less complicated math for calculating the damage difference).

On another note, one thing that has messed me up a bunch is the hardened skin ability. Is there any way to deal physical damage that ignores hardened skin? The damage reduction can mess up calculations like this. I could just remove the ability every time, but that could be annoying (might need to check entire inventory and stuff).
 
Level 13
Joined
Oct 18, 2013
Messages
691
That is, the effective health gain increases exponentially compared to the base amount of health.
Is this true? I thought the effective health increase from Armor increased linearly. 1=6% Extra, 2=12% Extra. That would make it linear, right?
 
Status
Not open for further replies.
Top