• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Defense and armour

Polperia

Member
Joined
Apr 10, 2011
Messages
35
Reaction score
8
Location
Spain
Hello all

So its 2024 and i still dont understand how defense and armor works.

Can someone explain me it detailed?

We have helmet, armor, legs, boots, shield... shielding...

How we calculate our defense?

How does this value work when we receive damage?

Please, tjis doesnt let me sleep.

Thanks
 
Some time ago, I read some great articles from Gorak on Tibia stats and maybe its ones of the formulas used in old ots.. I couldn't find them on the current tibia-stats page but thanks to web archive org i founded.

These are old formulas, and maybe in TibiaWiki are uptodate so you can validate both options

Distance Formula:

Shield:

Armor:
 
Some time ago, I read some great articles from Gorak on Tibia stats and maybe its ones of the formulas used in old ots.. I couldn't find them on the current tibia-stats page but thanks to web archive org i founded.

These are old formulas, and maybe in TibiaWiki are uptodate so you can validate both options

Distance Formula:

Shield:

Armor:

Hello!

I haven't see your reply before.

Could you please explain me the difference between shield and armour?

I see them quite the same.

Thanks in advice!

Edit 1: I tried using inspect element to see the javascript code, but I didnt see any formula there.
 
Last edited:
Well, they aren't...

Shield only apply when you are attacked by two monsters or less... But armor is for every income damage.

I still don't know how the source code makes that difference, but in my project I decided only to work with armor, because is simplier... Is easy to find the formula for reduced damage by quantity of armor, and it's easy to change it!

If you be capable of understand how shield works, please share with me in this topic! I would be amazed =)

C ya!
 
Hello!

This is my understand doing test with a character level 8.
All scenarios under monster rotworm, damage maximum 40.
The shielding is 15.

Factor: defense => 0.1
Damage formula since 7.X servers taken from other post here:
Rotworm skill: 30
Rotworm damage: 20
30*(20*0.05)+(20*0.5) ==> 40

Scenario 1:
Equipped only steel shield, so defense goes from 0 to 21.
Maximum damage from rotworm: 26.

My defense calculation to get that value must be splitted in 2, min and max:
Min: 21-1*0.9/2 => 17.9
Max: 21-1*0.9 => 8.45

So we now that our defense will be a random number between 8.45 till 17.9

Now I understood that damage also has minimum and maximum.
Min: 40/2 => 20
Max: 40 => 40

Now we can play with our numbers in excel and we know that we need an unique random number between 8.45 and 17.9.
I want to clarify that i dont know if they round or floor these values.
If they floor, we must minus in 1. If they round, we must plus 1.



Now I play with some random defense numbers, the higher, less damage we take, the smaller, more damage we take.

Considering that Rotworm deals 40, and our defense random number is 15:
40 - 14 => 26 damage received.

So at this point, the monster between 20 and 40, his random damage in that turn was 40.
If my random number from min and max defense is 14, we just need to quit 14 to 40.

Scenario 2:

I have added a leather helmet to this equation, same level, same skills, in defense mode.
I noticed some random sparks yellow almost 1 spark each 20 hits aprox, you all guarantee that armor block it, i can confirm it.

Now I have some questions:
What goes first in calculation? armor or defense?


If someone knows how it works, feel free to add it, so we will have a better summarize post.
Post automatically merged:

Well, they aren't...

Shield only apply when you are attacked by two monsters or less... But armor is for every income damage.

I still don't know how the source code makes that difference, but in my project I decided only to work with armor, because is simplier... Is easy to find the formula for reduced damage by quantity of armor, and it's easy to change it!

If you be capable of understand how shield works, please share with me in this topic! I would be amazed =)

C ya!
One point of shield is the following:
Shield can have 2 valours:
1- Shield as defense counter for shield in use, example: steel shield has defense 21. Our shield will be 21.
2- Shield as skill: the amount of our shielding skill level.

The fact is:

A lot of people mention about how armour, defense and shield works.
But there is a complex question:

How these 3 stuffs works together to calculate the damage?
Once we know it, we know everything.

Thats all i could recopilate. I have spent like 24h non sleep to get this conclusion doing formulas in excel, afk for hours receiving damage from monster, swaping between eq, no eq, shield...

Hope a great god coder here explain to coummunity how the formulas work together...


EDIT 1: I noticed defense and armor are executed in the same code block, creature.cpp:

BlockType_t Creature::blockHit(Creature* attacker, CombatType_t combatType, int32_t& damage,
bool checkDefense /* = false /, bool checkArmor / = false */)
{
BlockType_t blockType = BLOCK_NONE;

if(isImmune(combatType))
{
damage = 0;
blockType = BLOCK_IMMUNITY;
}
else if(checkDefense || checkArmor)
{
bool hasDefense = false;
if(blockCount > 0)
{
--blockCount;
hasDefense = true;
}

if(checkDefense && hasDefense)
{
int32_t maxDefense = getDefense();
int32_t minDefense = maxDefense / 2;
damage -= random_range(minDefense, maxDefense);
if(damage <= 0)
{
damage = 0;
blockType = BLOCK_DEFENSE;
checkArmor = false;
}
}

if(checkArmor)
{
int32_t armorValue = getArmor();
int32_t minArmorReduction = 0;
int32_t maxArmorReduction = 0;
if(armorValue > 1)
{
minArmorReduction = (int32_t)std::ceil(armorValue * 0.475);
maxArmorReduction = (int32_t)std::ceil(((armorValue * 0.475) - 1) + minArmorReduction);
}
else if(armorValue == 1)
{
minArmorReduction = 1;
maxArmorReduction = 1;
}

damage -= random_range(minArmorReduction, maxArmorReduction);
if(damage <= 0)
{
damage = 0;
blockType = BLOCK_ARMOR;
}
}

if(hasDefense && blockType != BLOCK_NONE)
onBlockHit(blockType);
}

if(attacker)
{
attacker->onAttackedCreature(this);
attacker->onAttackedCreatureBlockHit(this, blockType);
}

onAttacked();
return blockType;
}
 
Last edited:
Man, the input damage is not used to calculate shield reduction and armor reduction... But both of them create a reduction factor. For example:

input damage = 40
shield block = -10 (always)
armor block = -5 (always)

output damage (resulting damage) = 40 - 10 - 5 = 25
or maybe... with input damage = 7 we'll have >>>> 7 - 10 - 5 = -8, but it'll be considered 0...

They sum up together... Of course you can have more block because of shield skill or more shield defense depending on your item.

If you want to scheme up something that takes account the income damage, you should work on percentage reducion, you know? All those protection earth, or protection physical in % values... Then, the higher the damage, the higher the reduction! This you can work on lua scripts, outsider your source code, which is easier.

For example:
fire damage = 100
shield block = -10
armor block = -5
protection fire = -20% * dmg = -20

then... 100 - 10 - 5 - 20 = 65

or maybe, with fire damage = 30
we'll have... 30 - 10 - 5 - 6 = 9

You see in source code?
damage -= random_range(minDefense, maxDefense) [for shield]
damage -= random_range(minArmorReduction, maxArmorReduction) [for armor]

The block reduction don't have anything with the damage itself, because...

int32_t maxDefense = getDefense();
int32_t minDefense = maxDefense / 2; [for shield]

minArmorReduction = (int32_t)std::ceil(armorValue * 0.475);
maxArmorReduction = (int32_t)std::ceil(((armorValue * 0.475) - 1) + minArmorReduction); [for armor]

Hope it helps.
 
Last edited:
Back
Top