• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Formulas TFS

Joined
Jul 25, 2007
Messages
382
Reaction score
38
I'm looking for the formulas that are used to calculate melee damage, dist damage, and how much armor reduces damage. Be great if anyone has them, I don't particularly want to dig through the source especially when I won't know what variables are being used etc.
 
Last edited:
Code:
function getDamageReduction(creature, damage, damType)
local damageReduction = 0
local armor = creature:getArmor()
local defence = creature:getDefense()
local resistance = creature:getResistance(damType)
    
    if armor > 0 then damageReduction = math.ceil(armor * 0.475) end
    if defence > 1 then
        if creature:isMonster() then
            damageReduction = damageReduction + math.floor(math.random(defence/2, defence))
        else
            local defenseSkill = creature:getEffectiveSkillLevel(SKILL_SHIELD)
            -- defenseFactor is missing from calculations, because seem like I can't get it without source edit
            damageReduction = damageReduction + math.ceil(defenseSkill * defence * 0.015 + defence * 0.1) -- * defenseFactor
        end
    end
    if resistance > 0 then damageReduction = damageReduction + percentage(damage, resistance) end
    return damageReduction
end
This is latest function I did for that matter, I'm also interested did I miss anything or can it be improved.
 
Back
Top