• 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!

Shield and Armor formulas for 8.6 in weapons.xml

zezin009

Active Member
Joined
May 30, 2019
Messages
52
Reaction score
25
Hello everyone,

First of all i want to thanks for all this community!!! I always find things here when i need!
But this time i couldn't found, and i will be eternally greatfull if someone help me!
And i promisse i will collaborate making a good post after this!!!

I am making an 8.6 OTserver and i need to set a formula to reduce damage for my shields and amors
There's no .cpp file in version, that's why i'm having trouble since all the answers is about to do something with this archives
So I think the best way is to do some .lua script in weapons file
But how can i do a script for reduce damage with a shield and armors?
That's is really important to me because i want to equilibrate attacks and defenses with my own mathematical formulas, i just don't know how to write this...

I'm very greatfull, even if you can't do something, but is here listening to me.
Please, help me!!!
 
Do you know what TFS version you're using at all, how do you not have sources?
If you're looking to override the current damage reduction system, you must do it in sources. Your other option is to use an onStatsChange script (i'm assuming ancient TFS) to return false and send new damage to the target (that will already be mitigated from sources, so you're mitigating the damage twice in this case)
 
I'm using Global Server 0.1.7
I think is compatible with The Forgotten Server 0.3.6 because once i was having problems with liquids and selling things in amounts to npc's and then i found archives from this version of the TFS, putted them in my Global Server and it worked perfectly!

I found some scripts on internet using onStatsChange, but it was for the "reflecting damage spell/shield/anythingelse" script, and i couldn't have the ability to rewrite using this command to a shield or armor kind of script...
I prefer to rewrite every shield because i'll have more flexibility to recreate the items! I know that i must have the amount of damage taken and reduce it with the defense, skill and level variables...
I already changed the damage of my sword using weapons.xml and doing the "event="script" value="sword.lua"", wich means that i 'ignored' the rules of my source, so maybe it'll work with shields and armors too, since they are a "weaponType" in items.xml

I'm really thankfull for your care!
 
You're unable to script the behavior of shields or armor the way you're thinking through weapons.xml, they are not weapons. Here's what I meant:
Lua:
function onStatsChange(cid, attacker, type, combat, damage)
    -- avoid stack overflow
    if getCreatureStorageValue(cid, 11111) == 1 then
        doCreatureSetStorageValue(cid, 11111, -1)
        return true
    end
    local sumArmor = 0
    local sumDefense = 0
    for slot = 1, 10 do
        local item = getPlayerInventoryItem(cid, slot)
        if item and item.uid > 0 then
            sumArmor = sumArmor + getItemAttribute(item.uid, "armor")
            sumDefense = sumDefense + getItemAttribute(item.uid, "defense")
        end
    end
    damage = damage - (sumArmor * 3) -- example on reducing damage using armor
    doCreatureSetStorageValue(cid, 11111, 1) -- avoid stack overflow
    if type == STATSCHANGE_HEALTHLOSS then
        doTargetCombatHealth(attacker, cid, combat, -damage, -damage, 1)
    else
        doTargetCombatMana(attacker, cid, -damage, -damage, 1)
    end
    return false
end
Edit my example with whatever formulas you want to use to reduce damage.
 
Yeah, i think you're right..

The server doesn't recognize shield as a weapon...

I thinked about to colect data from my server about how much shieldskill and defense could reduce the damage to find the equation, but i will never get a good amount of information to have a precise formula...
Also the data from tibia-wiki or tibia-stats it's not comparable with my server...

What should i do?

By the way, thanks for your support, i liked the script so much! I tried to put something in my archives but it doesn't worked at all...
 
Where I do put that to work!?
You're unable to script the behavior of shields or armor the way you're thinking through weapons.xml, they are not weapons. Here's what I meant:
Lua:
function onStatsChange(cid, attacker, type, combat, damage)
    -- avoid stack overflow
    if getCreatureStorageValue(cid, 11111) == 1 then
        doCreatureSetStorageValue(cid, 11111, -1)
        return true
    end
    local sumArmor = 0
    local sumDefense = 0
    for slot = 1, 10 do
        local item = getPlayerInventoryItem(cid, slot)
        if item and item.uid > 0 then
            sumArmor = sumArmor + getItemAttribute(item.uid, "armor")
            sumDefense = sumDefense + getItemAttribute(item.uid, "defense")
        end
    end
    damage = damage - (sumArmor * 3) -- example on reducing damage using armor
    doCreatureSetStorageValue(cid, 11111, 1) -- avoid stack overflow
    if type == STATSCHANGE_HEALTHLOSS then
        doTargetCombatHealth(attacker, cid, combat, -damage, -damage, 1)
    else
        doTargetCombatMana(attacker, cid, -damage, -damage, 1)
    end
    return false
end
Edit my example with whatever formulas you want to use to reduce damage.
 
Last edited:
Back
Top