* physical combat is based of adnd v3 (originally it was v2) but has been altered many times over the years and adnd combat doesn't scale well

* there used to even be a d20 die roll but I was suprised just now to see that has been removed!

* dunno if this is still true but high def makes pvp for the attacker hard since they can't match it with AS

physical damage

Loosely speaking it goes like this

i) work out the base damage inflicted, let's call that base_d - this is primarly from stats, plus +, mats, etc

ii) work out the difference of the defender def and attacker AS, call that diff

iii) work out how much to scale (mostly down) the damage: scale = 1.1 - diff / 20

iv) adjust scale such that it is min 0.25 or max 1.1

v) actual damage is scale * base_d

so studying iii) and doing some math, the takehome points are:

If def - as >= 17 then the damage is Minimised. Ie, if the defender has 17 more def than the attacker has As, then the damage is minimised

If def<=as, then the damage is maximised. ie, if the attacker has at least as much as as the defender has def, then the damage is maxised

The main design problem is this: there is only 17 pts difference (of def-as) between Min damage and max Damge

appendix

- Code: Select all
`damage = int((bdamage + slay_damage + stat_bonus)*mat_mult) + critical_bonus;`

if(damage_multiplier>0) damage*=damage_multiplier;

// now scale the damage down according to def-as

float defAC=defender->get_ac();

if(attacker->id<100 && get_material(plyr[attacker->id].weapon)==MAT_DIAMOND) defAC=0; // mat diamond cuts thru any defence

float diff=defAC-attacker->get_thaco();

float scale=1.1-diff/20.0f;

if(scale>1.1) scale=1.1f;

else if(scale<0.25) scale=0.25f; // 20% min

damage=ROUND(damage*scale);

if(damage==0) damage=1;

magic damage

some spells have their own formula, but generally speaking most spells' base damage scale to caster's int and most spells damage is reduced by high MR-int, and surprisingly the maths is almost the same for physical !

i) work out the base damage base_d

ii) work out the diff of defender MR and attacker int ... diff=MR-int

iii) work out how much to scale base dmg by (watch carefully) : scale=1.1- diff / (MR/4) !!!

iv) adjust scale such that it is min 0.25 or max 1.1

v) actual damage is scale * base_d

this is the same as for combat except point iii) - the 17 range is now a variable scale, that is higher the tougher the mob is (leaving more room for the attacker's int to do more than the minimised damage

code:

- Code: Select all

int scale_magic_damage(int caster_int, int defender_mr, int base_damage, bool enchantment) {

if (defender_mr>=FULL_MAGIC_RESISTANCE) return 0; // 10k immunity rule

if (enchantment) return base_damage; // no scaling

float diff=defender_mr - caster_int;

float scale=1.1-diff/(defender_mr/4.0f);

if(scale>1.1) scale=1.1f;

else if(scale<0.25) scale=0.25f; // 20% always gets thru (was 5%)

int damage=ROUND(base_damage*scale);

if(damage==0) damage=1;

return damage;

}

case study i)

red dragon, 800 INT vs player with 1000 MR

scale=1.1-(1000-800)/(1000/4)

scale=1.1-200/250

scale=0.3

so if drag VF you for say 50 (whether it does or not i don't know) then the delivered damage would be 50 * 0.3 = 15 and that would be mostly resisted

case study ii)

heroic red dragon INT 2400 vs player with 1000 MR

you should be able to see that this will be full damage

scale=1.1-(1000-2400)/(1000/4)

scale=1.1--1400/250

scale=6.7 (which is capped to 1.1)

so to work out the MR you need to minimise damage vs a heroic red dragon:

0.25=1.1-(MR-2400)/(MR/4)

juggle

MR=3047

check:

0.25=1.1-(3047-2400)/(MR/4)

as a ratio: 3047/2500 = 1.21x - as an exercise you can check to see if this ratio holds for all MR/INT combos ! (I just did it on paper and it does)

similarly to work out the MR you need to start reducing the damage vs a heroic red dragon:

1.1=1.1-(MR-2400)/(MR/4)

MR=2400

take home: you need the same MR as the attacker's INT to start resisting, and you need 1.21x MR to best resist

notice the scale from 2400->3047 is much larger than that for physical (which is locked at 17) - however the ranges of int & mr go from 0 to 1000s, while as/def go from 0 to about 100 (?) - so it's debatable whether physical needs changing