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

Lua [TFS 1.0] [10.41] - How to script addon bonuses

xardas33

New Member
Joined
Jan 28, 2010
Messages
83
Reaction score
0
Hello all! I want ask you about help.
I want to create addon bonus system for my server.

The problem is I want to make - outfit without addons giving bonuses, outfit with first addon giving other bonuses, outfit with second addon giving other bonuses and outfit with full addons giving other bonuses.

Can anybody make an example script for that, or way to simple add bonuses?

Example make script:
Citizen outfit (+50 HP)
Citizen outfit first addon (+80 HP, +3% physical resistance)
Citizen outfit second addon (+70 HP, +15 speed)
Citizen outfit both addons (+100 HP, +5% physical resistance, +20 speed)

I just want to understand how to do that and later do my own bonuses for all outfits/addons.
 
Last edited:
At the moment you can't give bonuses by addons (there's no way to check if the player is USING them... Maybe I'm wrong?), but you can do it by outfits using conditions via globalevents.
 
Oh yeah, you can use getOutfit().lookAddons to check that... Sadly I don't know how you can check if the player changed the outfit... Maybe creating low timed conditions?
 
Code:
local hp = Condition(CONDITION_ATTRIBUTES)
hp:setParameter(CONDITION_PARAM_TICKS, 1000)
hp:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 150)

local distance = Condition(CONDITION_ATTRIBUTES)
distance:setParameter(CONDITION_PARAM_TICKS, 1000)
distance:setParameter(CONDITION_PARAM_SKILL_DISTANCEPERCENT, 150)

local sword = Condition(CONDITION_ATTRIBUTES)
sword:setParameter(CONDITION_PARAM_TICKS, 1000)
sword:setParameter(CONDITION_PARAM_SKILL_SWORDPERCENT, 150)

outfitBonus = {
   [133] = {[0] = {condition = none}, [1] = {condition = none}, [2] = {condition = none}, [3] = {condition = hp}},
   [134] = {[0] = {condition = distance}, [1] = {condition = none}, [2] = {condition = none}, [3] = {condition = sword}}
}

function onThink(interval, lastExecution)
    for _, p in ipairs(Game.getPlayers()) do
    local options = outfitBonus[p:getOutfit().lookType]  
        if options then
            for i=0, #options do
                if p:getOutfit().lookAddons == i then
                    if options[i] ~= nil and options[i].condition ~= nil then
                        p:addCondition(options[i].condition)
                    end
                end
            end
        end
    end
    return true
end

Poor coding and I don't know if this is the best way to achieve what you want.
You can also check this commit on GitHub.

And if someone can optimize the code please do it haha

PD: Those "condition none" don't exist, if you don't want to use the [X] addon just delete the option and won't be problems since is the code is checking if is nil.
 
Back
Top