SphereCommunity
Custom armor rating calculation - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: Custom armor rating calculation (/Thread-Custom-armor-rating-calculation)



Custom armor rating calculation - Murmur - 05-10-2017 05:00 PM

First, I'd like to thank everyone for helping me get to this point. I have wanted to create my own custom combat system for literally 15+ years and it's finally becoming a reality, so thank you very much.

I have successfully created my custom @HitTry and @Hit, and I'm very satisfied with them.

Logically, next is doing my @GetHit for calculating armor.

Since my server would be considered a customized T2A or pre-T2a, all I need to do is calculate how much damage is done in melee and spells in regards to one value, the AR value (or I guess in modern terms, physical AR).

I have my pseudocode completely fleshed out, and I have tested all the calculations on a dynamic spreadsheet. There is only one snag I've hit.

My core calculation in my pseudocode is
Code:
damage * (100 - ARMOR) / 100

I've tried my absolute best to do my homework at each step, and I'm 100% convinced all my code works with this base formula, but of course, there is a snag in the 'Vision'.

With this formula, any AR value greater than or equal to 100 technically negates any value of damage dealt. That's easy to fix by using percentages to guarantee damage at the end of the calculation, but I'm wanting a little more flexibility in my custom armors that I'm planning on making, so I'd like to use AR values up to 200.

I've messed around with this formula for like 4 hours straight on a spreadsheet and never found one that works. Let me paint 2 scenarios:

Scenario 1:
Armor Calculation is currently 'damage * (100 - ARMOR) / 100'.
20damage * (100 - 50AR) / 100
So that would be:
20 * (50) / 100 = 10 damage

Does anyone have any good ideas on how to implement a similar equation, but with 200AR as the 'max'?

Obviously, this doesn't work:
Scenario 2:
Armor Calculation is currently 'damage * (200 - ARMOR) / 100'.
20damage * (200 - 50AR) / 100
So that would be:
20 * (150) / 100 = 30 damage

It was immediately clear to me this is no good. But I tried for 4 hours to find another algorithm that worked and I just don't think I'm creative enough to figure it out. Has anyone else seen/heard/used a good algorithm for my server idea?

I'd appreciate any input, and thanks again for all the help. I really appreciate it.
-Murmur


RE: Custom armor rating calculation - darksun84 - 05-10-2017 08:17 PM

Changing the / 100 to /200 should do the trick:

damage * ( 200 - AR ) / 200

At 100 AR you will have 50% damage reduction
At 50 AR you will have 25% damage reduction

and so on


RE: Custom armor rating calculation - bmanny - 05-11-2017 02:55 AM

I do something like this that works nice for me. You would need to determine how you get your armorMod though. I do mine based on my tactics versus creature armor.

if
WeaponDMG * (armorMod/100+1) > 1
dmg = WeaponDMG * (armorMod/100+1)
else
dmg = 1


RE: Custom armor rating calculation - Murmur - 05-11-2017 04:48 PM

Thanks darksun84 and bmanny.

@bmanny - I'm completely re-writing it all from nothing. So with your example of dmg = WeaponDMG * (armorMod/100+1), I plugged my AR value (physical AR in modern terms), which, for instance, a full set of normal plate gives 28 AR. When I use your formula with my AR, it looks like this:

10 damage (dagger) * (28AR/100+1) = 12.8 damage
and then lets use a heavy crossbow
24 damage (heavy crossbow) * (28AR/100+1) = 30.72 damage

then I change the armor value from 28 to 100

10 damage (dagger) * (100AR/100+1) = 20.0 damage
and then lets use a heavy crossbow
24 damage (heavy crossbow) * (100AR/100+1) = 48 damage

So with the same weapon, with 100 AR, its doing more damage. So that wouldn't work, I'd have to rewrite how I get my armor value, which has already been done. Thanks for the suggestion though! I'm sure it will help someone at some point searching the forums in the future.

@darksun84 - I have tested this formula a lot tonight, and it looks like it will work for now. I think I want a gradual curve on the % of damage that is mitigated, and I'll probably have to write this out with like 4 different formulas depending on if my armor is less than 50, less than 100, less than 150 and less than 200 but the formula you suggested is almost exactly what I needed at this point.

Thank you again to both of you.
-Murmur


RE: Custom armor rating calculation - bmanny - 05-12-2017 01:55 AM

I would actually recommend NOT testing damage against AR. The system is very unscalable and to create engaging pve content means breaking pvp content.

I would try something like this:
Test some variable against armor to get a damage mod.
Apply the damage mod directly to weapon damage(can make damage go up or down).
You may want to regulate the damage to make sure it doesn't go too high or too low.


RE: Custom armor rating calculation - Coruja - 05-17-2017 02:28 PM

maybe "damage * (200 - AR) / 200" should do the trick if you want use max AR value of 200

that's exactly the same way how elemental damages are calculated:
Code:
damage type * (100 - resist type) / 100
of course the main difference is that on elemental combat you must split the single damage into all 5 types (physical/fire/cold/poison/energy) to calculate each value and then add all the 5 results into the final damage. Clients also have RESPHYSICALMAX/RESFIREMAX/etc that will limit char max resist value (75 by default) to prevent them reach resist >= 100 and break the formula. 75 is a nice limit because even at maximum resist ppl still get 25% of the damage. Using old AR there's no MAXAR property so you must do something like this on your code, because if the max AR is 200, it's not a good idea let ppl have 200 AR to make them immortal always resisting 100% of all damages

also if you want to skip sphere internal resist calculations to calculate using your own formula on @GetHit, don't forget to add damage type "dam_fixed" on your @Hit trigger and all other sources of damage, like spells ("LOCAL.DamType |= dam_fixed" on @Effect / @SpellEffect), custom scripts (using DAMAGE 10 dam_fixed), etc


RE: Custom armor rating calculation - Artyk - 08-10-2017 04:11 AM

There could be a mathematical formula for your case, but you have to prefix a maximum armor achievable and with that maximum the percentage of reduction you want.
Also you have to choose if every point of armor has a flat corresponding % of reduction or some particular behavior, like the next armor point gives less than the preceding.

In the case you want armor to be flat %, simply use a proportion to calculate the reduction:
max_reduction : max_armor = actual_reduction : actual_armor => actual_reduction = max_reduction * actual_armor / max_armor

In the other case tell us what kind "curve" you want and maybe can be solved with a formula Smile