Resistances?

Sep 21, 2016, 6:26 pm
#1
Ex-Tyrant of the IVANers


Joined: Dec 8, 2007
Occupation: Junior Scientist
Location: Not California
Interests: Physics and Astronomy, Exoplanets, Singing praise to Valpurus while smashing skulls with a bloody warhammer, Jogging
Posts: 2,920
Has anyone done any research into how resistances function? There's a page on the wiki, but it's not very definitive.
"Put more stuff in the... thing where... more stuff goes in."
Sep 22, 2016, 12:44 am
#2
Joined: Dec 3, 2007
Occupation: Chaos Weaver
Location: Standing between all life and death
Posts: 2,898
Well, there was this and this.
Uchuudonge wrote
creating stable chaos
making patterns where there should be none
sewing order into the chaos
you spit in the face of random numbers, of chaos
Sep 22, 2016, 1:24 am
#3
Joined: Dec 11, 2008
Posts: 1,770
I'm going to use a running example to make this easier to understand through all the code. *Bear with me.
I'll keep it in quote boxes:

Quote
You have 34 HP.
You are wearing a hardened leather armor and a hardened leather belt.
You are struck in the torso by a fireball for 30 FIRE damage!


The process is as follows:

When you get hit you take a set amount of damage first, which is then reduced by other factors such as resistance:
if(!PenetrateResistance)
    Damage -= (BodyPart->GetTotalResistance(Type) >> 1) + RAND() % ((BodyPart->GetTotalResistance(Type) >> 1) + 1);

Quote
30 Fire damage - (resistance calculation result)

First the formula finds your total resistance to the damage type (e.g. Fire) by checking the bodypart that was hit and the armor that bodypart has equipped.
How this is done exactly varies by bodypart.
For example, your head takes into account first the resistance of the head itself, then the resistance value of the helmet, then the resistance value of your body armor divided by two.
Your torso takes into account the resistance of your body armor and your belt.

int humanoidtorso::GetTotalResistance(int Type) const
{
  if(Master)
  {
    int Resistance = GetResistance(Type) + Master->GetGlobalResistance(Type);

    if(GetBodyArmor())
      Resistance += GetBodyArmor()->GetResistance(Type);

    if(GetBelt())
      Resistance += GetBelt()->GetResistance(Type);

    return Resistance;
  }
  else
    return GetResistance(Type);
}

Quote
You are wearing a Hardened Leather Armor and a Hardened Leather Belt.
Hardened Leather Armor has a fire resistance of 2.

Total fire resistance = 2 + 2 = 4

The value of resistance varies by the materials your armor and bodyparts are made from. This is determined solely by the materials' value in material.dat but may be modified by special equipment, such as a Ring of Fire Resistance which adds a flat bonus of 15 FR.

Once you have the total resistance of the bodypart we divide it by 2.

Quote
Total fire resistance of your torso was 4.
4 / 2 = 2

Now the exact same calculation is run again, and run through a modulo function against a random number between 1 and 99 (simplifying things here).
This means the first number is divided by the second and the remainder left over is the result. (e.g. 15 % 4 = 3 but 15 % 3 = 0)

This is to add a small degree of randomness to the damage.

Quote
Our result from the previous section was 2.
Now we run the same calculation as before, add 1 and then modulo it against a random number between 1 and 99.

RANDOM NUMBER % (2 + 1)

Say our random number was 65

65 % 3
= 2

Add both results together and we get the total damage mitigation.

Quote
Total from first section = 2
Total from second section = 2

Damage -= 2 + 2
Damage -= 4

Total fire damage was 30
Total fire mitigation was 4

TOTAL DAMAGE OVERALL = 26 FIRE DAMAGE
This probably killed the player.

I probably made a mistake somewhere in there so feel free to correct me.

(For reference, a wand of fireballs produces an explosion with damage 75 + RAND() % 25 - RAND() % 25 and not pure fire damage on impact. Explosions have their own convoluted code that involves splitting the total strength of the explosion between physical (shrapnel, shockwave) and fire damage (blast))
System would indicate in graphic if person is mounted on horse or not.
Same system also show if person mounted on boar, elephant, polar bear etc.
Or if person mounted on ass.
Ivan find mounting on ass funny.
Sep 22, 2016, 9:01 am
#4
Ex-Tyrant of the IVANers


Joined: Dec 8, 2007
Occupation: Junior Scientist
Location: Not California
Interests: Physics and Astronomy, Exoplanets, Singing praise to Valpurus while smashing skulls with a bloody warhammer, Jogging
Posts: 2,920
Well that's a pretty arcane formula for handling resistances. Thanks Azba.
"Put more stuff in the... thing where... more stuff goes in."
Sep 23, 2016, 12:11 am
#5
Joined: Dec 3, 2007
Occupation: Chaos Weaver
Location: Standing between all life and death
Posts: 2,898
4zb4 wrote
I probably made a mistake somewhere in there so feel free to correct me.

4zb4 wrote
Bare with me.

That should be "bear".
Uchuudonge wrote
creating stable chaos
making patterns where there should be none
sewing order into the chaos
you spit in the face of random numbers, of chaos
Sep 23, 2016, 12:58 am
#6
Joined: Dec 11, 2008
Posts: 1,770
chaostrom wrote
That should be "bear".

God damn it.
System would indicate in graphic if person is mounted on horse or not.
Same system also show if person mounted on boar, elephant, polar bear etc.
Or if person mounted on ass.
Ivan find mounting on ass funny.
Oct 7, 2016, 8:21 pm
#7
Joined: Mar 17, 2008
Occupation: Software developer
Location: Ohio
Interests: Physics
Posts: 67
4zb4 wrote
(For reference, a wand of fireballs produces an explosion with damage 75 + RAND() % 25 - RAND() % 25 and not pure fire damage on impact. Explosions have their own convoluted code that involves splitting the total strength of the explosion between physical (shrapnel, shockwave) and fire damage (blast))

Wand of fireballs does only fire damage. I didn't think my code was convoluted!

Oct 8, 2016, 2:04 am
#8
Joined: Dec 11, 2008
Posts: 1,770
Oh! My mistake.
System would indicate in graphic if person is mounted on horse or not.
Same system also show if person mounted on boar, elephant, polar bear etc.
Or if person mounted on ass.
Ivan find mounting on ass funny.
Jump to