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

CreatureEvent [TFS 1.2] Outfit bonuses

Nvm i found the solution.
to use it for mounts just do as what @Delusion said and don't use the normal mount IDs you have to use the mount clientid for example
Crimson Ray
Clientid = 521 mountid = 33 you have to use 521 as Crimson ray mount id
Code:
    <mount id="33" clientid="521" name="Crimson Ray" speed="20" premium="yes" />
 
Last edited by a moderator:
Hello, i implemeneted your scripts everything was great, until one of the players told me about a bug that even if they don't have first or second addon they are getting the bonuses, i didn't realize,, i had to unlock all outfits, so am trying to find a way to do it but i don't know how, am checking, if you can suggest or help i would be grateful, thank you again for the script
 
Thanks working good, if someone want to also use it add this(line 9) in the function onChangeOutfit(outfit) so the regeneration will not be permament
Code:
function Creature:onChangeOutfit(outfit)
if not self:isPlayer() then
        return true
    end
    local previousBonusCondition = getBonusCondition(self:getOutfit().lookType)
    local newBonusCondition = getBonusCondition(outfit.lookType)
    if previousBonusCondition then
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition:getSubId())
        self:removeCondition(CONDITION_REGENERATION, CONDITIONID_DEFAULT, previousBonusCondition:getSubId()) <-- This line
    end
    if newBonusCondition then
        self:addCondition(newBonusCondition)
    end
    return true
end
Do you have onChangeOutfit set to enabled="1" in events.xml?
i wrote about that go and add regen condition and also
Lua:
self:removeCondition(CONDITION_HASTE, CONDITIONID_DEFAULT, previousBonusCondition:getSubId())
 
@Edit
I have error
Lua:
data/creaturescripts/scripts/login.lua:39: attempt to call global 'getBonusCondition' (a nil value)
stack traceback:
        [C]: in function 'getBonusCondition'
        data/creaturescripts/scripts/login.lua:39: in function <data/creaturescripts/scripts/login.lua:1>

Solved i forget add function..

Someone know how add addon?
 
Last edited:
i need to relog with the especific addon in order to get the bonus, how can i make this work just by changing the outfit ingame?
btw this is working g8 with 1.3


SO...I am using TFS 1.3 and it works just fine, wanna try more stuff out, not only the example so won't say it is working 100%, but the most important part for player comfort is the outfit wont change the given stats when I change outfits, just as "Dreww" said long ago.

Is there any way to solve that?? Will keep looking at it my self too when I get back home.

Thanks for the nice script and for the help in advance
 
hi i have no problem with the outfits.
It could be that you have to have the complete outfits.?
example to get the addons bonuses full addon
i tested in tfs 1.3
 
Last edited:
I have problem, when im in player, and change my outfit with Mlvl bonus +10 i got mlvl, but when i change to another outfit to get something else my level goin down. (With Citizen - +10mlv, Hunter - +200 hp and -10 mlvl.) how i can repair this?

Nevermind ~ Just go to your database and set MagLevel to 1 (propably will be in 0, but in client will be set in 10)
 
Last edited:
nice post, i have a question, how can i make this script but the players need both addons to receive that bonus?
 
This should let you do it with different bonuses for different addons. You need to change the code a bit though.

Create a lib file data/lib
Lua:
--[[
    addions[1] = no addons
    addons[2] = 1st addon unlocked
    addons[3] = 2nd addon unlocked
]]--

OUTFIT_BONUSES = {
    {116, 117} = {id = 1, -- +1 each id for new outfits
    addons = {[1] = nil, [2] = {CONDITION_MAGICLEVELPOINT, 5}, [3] = {CONDITION_HASTE, 25}}
    },
    {118, 119} = {id = 2,
    addons = {[1] = nil, [2] = {CONDITION_MAGICLEVELPOINT, 5}, [3] = {CONDITION_HASTE, 25}}
    }
}

function getBonusOutfit(outfit)
    for i, v in pairs(OUTFIT_BONUSES) do
        if outfit == i then
            return OUTFIT_BONUSES[i]
        end
    end
    return false
end


function createBonusCondition(bonus, addon)
    local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, bonus.id)
    for x = 1, addon do
        for i = 1, #bonus.addons[x] do
            local param = bonus.addons[x][1]
            local value = bonus.addons[x][2]
            condition:setParameter(param, value)
        end
    end
    return condition
end

function getBonusOutfitID(outfit)
    for outfits, bonus in pairs(OUTFIT_BONUSES) do
        if table.contains(outfits, outfit) then
            return bonus.id
        end
    end
    return nil
end

Then in data/events/creature onChangeOutfit
Lua:
function Creature:onChangeOutfit(outfit)
    if not self:isPlayer() then
        return true
    end
   
    local previousBonusCondition = getBonusOutfitID(self:getOutfit().lookType)
    if previousBonusCondition then
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition)
    end
   
    local bonusOutfit = getBonusOutfit(outfit)
    if bonusOutfit then
        local addons = 1
        if self:canWearOutfit(outfit, 2) then
            addons = 3
        elseif self:canWearOutfit(outfit, 1) then
            addons = 2
        end
       
        local newBonusCondition = createBonusCondition(bonusOutfit, addons)
        if newBonusCondition then
            self:addCondition(newBonusCondition)
        end
    end
    return true
end
 
inside of data/events/scripts/creature.lua (make sure onChangeOutfit is set to 1 in events.xml)
Lua:
function createBonusCondition(id, params)
    local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, id)
    for i = 1, #params do
        local param = params[i].param
        local value = params[i].value
        condition:setParameter(param, value)
    end
    return condition
end

outfitBonuses = {
    [{128, 136}] = createBonusCondition(1, {
            {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
            {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
        }
    ),
    [{129, 137}] = createBonusCondition(2, {
            {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
        }
    )
}

function getBonusCondition(outfit)
    for outfits, bonus in pairs(outfitBonuses) do
        if table.contains(outfits, outfit) then
            return bonus
        end
    end
    return nil
end

function Creature:onChangeOutfit(outfit)
    if not self:isPlayer() then
        return true
    end
    local previousBonusCondition = getBonusCondition(self:getOutfit().lookType)
    local newBonusCondition = getBonusCondition(outfit.lookType)
    if previousBonusCondition then
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition:getSubId())
    end
    if newBonusCondition then
        self:addCondition(newBonusCondition)
    end
    return true
end

inside of data/creaturescripts/scripts/login.lua (inside the onLogin function)
Lua:
    -- Outfit bonus
    local bonusCondition = getBonusCondition(player:getOutfit().lookType)
    if bonusCondition then
        player:addCondition(bonusCondition)
    end

how to configure: (i already created two bonuses for citizen and hunter outfits as an example)
Lua:
outfitBonuses = {
    [{male outfit id, female outfit id}] = createBonusCondition(ID, parameters & values)
}
the ID should be different for each bonus, so the script can identify between conditions
in my example i started from 1 for citizen bonus and used 2 for hunter, if you were to continue you would go 3, 4, 5, etc.
parameters should be inside a table, {param = some_condition_param, value = value_to_set}
here are the available condition params for tfs 1.2:
Code:
CONDITION_PARAM_OWNER
CONDITION_PARAM_TICKS
CONDITION_PARAM_HEALTHGAIN
CONDITION_PARAM_HEALTHTICKS
CONDITION_PARAM_MANAGAIN
CONDITION_PARAM_MANATICKS
CONDITION_PARAM_DELAYED
CONDITION_PARAM_SPEED
CONDITION_PARAM_LIGHT_LEVEL
CONDITION_PARAM_LIGHT_COLOR
CONDITION_PARAM_SOULGAIN
CONDITION_PARAM_SOULTICKS
CONDITION_PARAM_MINVALUE
CONDITION_PARAM_MAXVALUE
CONDITION_PARAM_STARTVALUE
CONDITION_PARAM_TICKINTERVAL
CONDITION_PARAM_FORCEUPDATE
CONDITION_PARAM_SKILL_MELEE
CONDITION_PARAM_SKILL_FIST
CONDITION_PARAM_SKILL_CLUB
CONDITION_PARAM_SKILL_SWORD
CONDITION_PARAM_SKILL_AXE
CONDITION_PARAM_SKILL_DISTANCE
CONDITION_PARAM_SKILL_SHIELD
CONDITION_PARAM_SKILL_FISHING
CONDITION_PARAM_STAT_MAXHITPOINTS
CONDITION_PARAM_STAT_MAXMANAPOINTS
CONDITION_PARAM_STAT_SOULPOINTS
CONDITION_PARAM_STAT_MAGICPOINTS
CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT
CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT
CONDITION_PARAM_STAT_SOULPOINTSPERCENT
CONDITION_PARAM_STAT_MAGICPOINTSPERCENT
CONDITION_PARAM_PERIODICDAMAGE
CONDITION_PARAM_SKILL_MELEEPERCENT
CONDITION_PARAM_SKILL_FISTPERCENT
CONDITION_PARAM_SKILL_CLUBPERCENT
CONDITION_PARAM_SKILL_SWORDPERCENT
CONDITION_PARAM_SKILL_AXEPERCENT
CONDITION_PARAM_SKILL_DISTANCEPERCENT
CONDITION_PARAM_SKILL_SHIELDPERCENT
CONDITION_PARAM_SKILL_FISHINGPERCENT
CONDITION_PARAM_BUFF_SPELL
CONDITION_PARAM_SUBID
CONDITION_PARAM_FIELD

it would be nice if they go down different bosnos for each vocation that uses the same outfit, Mage outifit of this magic level for the magicians and mana for paladin and knight and so on so if a knight uses the outifit he would not gain the magic levels that the magicians would gain but a different bonus. I hope you understood my thinking.
 
This should let you do it with different bonuses for different addons. You need to change the code a bit though.

Create a lib file data/lib
Lua:
--[[
    addions[1] = no addons
    addons[2] = 1st addon unlocked
    addons[3] = 2nd addon unlocked
]]--

OUTFIT_BONUSES = {
    {116, 117} = {id = 1, -- +1 each id for new outfits
    addons = {[1] = nil, [2] = {CONDITION_MAGICLEVELPOINT, 5}, [3] = {CONDITION_HASTE, 25}}
    },
    {118, 119} = {id = 2,
    addons = {[1] = nil, [2] = {CONDITION_MAGICLEVELPOINT, 5}, [3] = {CONDITION_HASTE, 25}}
    }
}

function getBonusOutfit(outfit)
    for i, v in pairs(OUTFIT_BONUSES) do
        if outfit == i then
            return OUTFIT_BONUSES[i]
        end
    end
    return false
end


function createBonusCondition(bonus, addon)
    local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, bonus.id)
    for x = 1, addon do
        for i = 1, #bonus.addons[x] do
            local param = bonus.addons[x][1]
            local value = bonus.addons[x][2]
            condition:setParameter(param, value)
        end
    end
    return condition
end

function getBonusOutfitID(outfit)
    for outfits, bonus in pairs(OUTFIT_BONUSES) do
        if table.contains(outfits, outfit) then
            return bonus.id
        end
    end
    return nil
end

Then in data/events/creature onChangeOutfit
Lua:
function Creature:onChangeOutfit(outfit)
    if not self:isPlayer() then
        return true
    end
  
    local previousBonusCondition = getBonusOutfitID(self:getOutfit().lookType)
    if previousBonusCondition then
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition)
    end
  
    local bonusOutfit = getBonusOutfit(outfit)
    if bonusOutfit then
        local addons = 1
        if self:canWearOutfit(outfit, 2) then
            addons = 3
        elseif self:canWearOutfit(outfit, 1) then
            addons = 2
        end
      
        local newBonusCondition = createBonusCondition(bonusOutfit, addons)
        if newBonusCondition then
            self:addCondition(newBonusCondition)
        end
    end
    return true
end
can you help me please, i put your script maybe im wrong, i made a lib in data/lib
and at lib.lua i put> dofile('data/lib/addons.lua')
and make me this error

Lua Script Error: [Main Interface]
data/global.lua
data/lib/addons.lua:8: '}' expected (to close '{' at line 7) near '='
stack traceback:
[C]: at 0x7ff687d6ef70
[C]: in function 'dofile'
data/lib/lib.lua:20: in main chunk
[C]: in function 'dofile'
data/global.lua:2: in main chunk
[Warning - ScriptingManager::loadScriptSystems] Can not load data/global.lua
> Loading lua libs


and a lot of errors.

im using an otservbr 1.3
 
This should let you do it with different bonuses for different addons. You need to change the code a bit though.

Create a lib file data/lib
Lua:
--[[
    addions[1] = no addons
    addons[2] = 1st addon unlocked
    addons[3] = 2nd addon unlocked
]]--

OUTFIT_BONUSES = {
    {116, 117} = {id = 1, -- +1 each id for new outfits
    addons = {[1] = nil, [2] = {CONDITION_MAGICLEVELPOINT, 5}, [3] = {CONDITION_HASTE, 25}}
    },
    {118, 119} = {id = 2,
    addons = {[1] = nil, [2] = {CONDITION_MAGICLEVELPOINT, 5}, [3] = {CONDITION_HASTE, 25}}
    }
}

function getBonusOutfit(outfit)
    for i, v in pairs(OUTFIT_BONUSES) do
        if outfit == i then
            return OUTFIT_BONUSES[i]
        end
    end
    return false
end


function createBonusCondition(bonus, addon)
    local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, bonus.id)
    for x = 1, addon do
        for i = 1, #bonus.addons[x] do
            local param = bonus.addons[x][1]
            local value = bonus.addons[x][2]
            condition:setParameter(param, value)
        end
    end
    return condition
end

function getBonusOutfitID(outfit)
    for outfits, bonus in pairs(OUTFIT_BONUSES) do
        if table.contains(outfits, outfit) then
            return bonus.id
        end
    end
    return nil
end

Then in data/events/creature onChangeOutfit
Lua:
function Creature:onChangeOutfit(outfit)
    if not self:isPlayer() then
        return true
    end
  
    local previousBonusCondition = getBonusOutfitID(self:getOutfit().lookType)
    if previousBonusCondition then
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition)
    end
  
    local bonusOutfit = getBonusOutfit(outfit)
    if bonusOutfit then
        local addons = 1
        if self:canWearOutfit(outfit, 2) then
            addons = 3
        elseif self:canWearOutfit(outfit, 1) then
            addons = 2
        end
      
        local newBonusCondition = createBonusCondition(bonusOutfit, addons)
        if newBonusCondition then
            self:addCondition(newBonusCondition)
        end
    end
    return true
end

[Warning - Events::load] Can not load script: creature.lua
data/events/scripts/creature.lua:4: '}' expected (to close '{' at line 3) near '='

Lua:
__picif = {}

OUTFIT_BONUSES = {
    {116, 117} = {
                    id = 1,
                    addons = {
                                [1] = nil,
                                [2] = {CONDITION_MAGICLEVELPOINT, 5},
                                [3] = {CONDITION_HASTE, 25}
                    },
    },
    {118, 119} = {
                    id = 2,
                    addons = {
                                [1] = nil,
                                [2] = {CONDITION_MAGICLEVELPOINT, 5},
                                [3] = {CONDITION_HASTE, 25}
                    },
    },
}

function getBonusOutfit(outfit)
    for i, v in pairs(OUTFIT_BONUSES) do
        if outfit == i then
            return OUTFIT_BONUSES[i]
        end
    end
    return false
end


function createBonusCondition(bonus, addon)
    local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, bonus.id)
    for x = 1, addon do
        for i = 1, #bonus.addons[x] do
            local param = bonus.addons[x][1]
            local value = bonus.addons[x][2]
            condition:setParameter(param, value)
        end
    end
    return condition
end

function getBonusOutfitID(outfit)
    for outfits, bonus in pairs(OUTFIT_BONUSES) do
        if table.contains(outfits, outfit) then
            return bonus.id
        end
    end
    return nil
end

function Creature:onChangeOutfit(outfit)
    if not self:isPlayer() then
        return true
    end
  
    local previousBonusCondition = getBonusOutfitID(self:getOutfit().lookType)
    if previousBonusCondition then
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition)
    end
  
    local bonusOutfit = getBonusOutfit(outfit)
    if bonusOutfit then
        local addons = 1
        if self:canWearOutfit(outfit, 2) then
            addons = 3
        elseif self:canWearOutfit(outfit, 1) then
            addons = 2
        end
      
        local newBonusCondition = createBonusCondition(bonusOutfit, addons)
        if newBonusCondition then
            self:addCondition(newBonusCondition)
        end
    end
    return true
end
 
Lua:
OUTFIT_BONUSES = {
    [{116, 117}] = {
                    id = 1,
                    addons = {
                                [1] = nil,
                                [2] = {CONDITION_MAGICLEVELPOINT, 5},
                                [3] = {CONDITION_HASTE, 25}
                    }
    },
    [{118, 119}] = {
                    id = 2,
                    addons = {
                                [1] = nil,
                                [2] = {CONDITION_MAGICLEVELPOINT, 5},
                                [3] = {CONDITION_HASTE, 25}
                    }
    }
}
 
inside of data/events/scripts/creature.lua (make sure onChangeOutfit is set to 1 in events.xml)
Lua:
function createBonusCondition(id, params)
    local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, id)
    for i = 1, #params do
        local param = params[i].param
        local value = params[i].value
        condition:setParameter(param, value)
    end
    return condition
end

outfitBonuses = {
    [{128, 136}] = createBonusCondition(1, {
            {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
            {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
        }
    ),
    [{129, 137}] = createBonusCondition(2, {
            {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
        }
    )
}

function getBonusCondition(outfit)
    for outfits, bonus in pairs(outfitBonuses) do
        if table.contains(outfits, outfit) then
            return bonus
        end
    end
    return nil
end

function Creature:onChangeOutfit(outfit)
    if not self:isPlayer() then
        return true
    end
    local previousBonusCondition = getBonusCondition(self:getOutfit().lookType)
    local newBonusCondition = getBonusCondition(outfit.lookType)
    if previousBonusCondition then
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition:getSubId())
    end
    if newBonusCondition then
        self:addCondition(newBonusCondition)
    end
    return true
end

inside of data/creaturescripts/scripts/login.lua (inside the onLogin function)
Lua:
    -- Outfit bonus
    local bonusCondition = getBonusCondition(player:getOutfit().lookType)
    if bonusCondition then
        player:addCondition(bonusCondition)
    end

how to configure: (i already created two bonuses for citizen and hunter outfits as an example)
Lua:
outfitBonuses = {
    [{male outfit id, female outfit id}] = createBonusCondition(ID, parameters & values)
}
the ID should be different for each bonus, so the script can identify between conditions
in my example i started from 1 for citizen bonus and used 2 for hunter, if you were to continue you would go 3, 4, 5, etc.
parameters should be inside a table, {param = some_condition_param, value = value_to_set}
here are the available condition params for tfs 1.2:
Code:
CONDITION_PARAM_OWNER
CONDITION_PARAM_TICKS
CONDITION_PARAM_HEALTHGAIN
CONDITION_PARAM_HEALTHTICKS
CONDITION_PARAM_MANAGAIN
CONDITION_PARAM_MANATICKS
CONDITION_PARAM_DELAYED
CONDITION_PARAM_SPEED
CONDITION_PARAM_LIGHT_LEVEL
CONDITION_PARAM_LIGHT_COLOR
CONDITION_PARAM_SOULGAIN
CONDITION_PARAM_SOULTICKS
CONDITION_PARAM_MINVALUE
CONDITION_PARAM_MAXVALUE
CONDITION_PARAM_STARTVALUE
CONDITION_PARAM_TICKINTERVAL
CONDITION_PARAM_FORCEUPDATE
CONDITION_PARAM_SKILL_MELEE
CONDITION_PARAM_SKILL_FIST
CONDITION_PARAM_SKILL_CLUB
CONDITION_PARAM_SKILL_SWORD
CONDITION_PARAM_SKILL_AXE
CONDITION_PARAM_SKILL_DISTANCE
CONDITION_PARAM_SKILL_SHIELD
CONDITION_PARAM_SKILL_FISHING
CONDITION_PARAM_STAT_MAXHITPOINTS
CONDITION_PARAM_STAT_MAXMANAPOINTS
CONDITION_PARAM_STAT_SOULPOINTS
CONDITION_PARAM_STAT_MAGICPOINTS
CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT
CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT
CONDITION_PARAM_STAT_SOULPOINTSPERCENT
CONDITION_PARAM_STAT_MAGICPOINTSPERCENT
CONDITION_PARAM_PERIODICDAMAGE
CONDITION_PARAM_SKILL_MELEEPERCENT
CONDITION_PARAM_SKILL_FISTPERCENT
CONDITION_PARAM_SKILL_CLUBPERCENT
CONDITION_PARAM_SKILL_SWORDPERCENT
CONDITION_PARAM_SKILL_AXEPERCENT
CONDITION_PARAM_SKILL_DISTANCEPERCENT
CONDITION_PARAM_SKILL_SHIELDPERCENT
CONDITION_PARAM_SKILL_FISHINGPERCENT
CONDITION_PARAM_BUFF_SPELL
CONDITION_PARAM_SUBID
CONDITION_PARAM_FIELD
as for only for full outfit?
 
inside of data/events/scripts/creature.lua (make sure onChangeOutfit is set to 1 in events.xml)
Lua:
function createBonusCondition(id, params)
    local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, id)
    for i = 1, #params do
        local param = params[i].param
        local value = params[i].value
        condition:setParameter(param, value)
    end
    return condition
end

outfitBonuses = {
    [{128, 136}] = createBonusCondition(1, {
            {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
            {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
        }
    ),
    [{129, 137}] = createBonusCondition(2, {
            {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
        }
    )
}

function getBonusCondition(outfit)
    for outfits, bonus in pairs(outfitBonuses) do
        if table.contains(outfits, outfit) then
            return bonus
        end
    end
    return nil
end

function Creature:onChangeOutfit(outfit)
    if not self:isPlayer() then
        return true
    end
    local previousBonusCondition = getBonusCondition(self:getOutfit().lookType)
    local newBonusCondition = getBonusCondition(outfit.lookType)
    if previousBonusCondition then
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition:getSubId())
    end
    if newBonusCondition then
        self:addCondition(newBonusCondition)
    end
    return true
end

inside of data/creaturescripts/scripts/login.lua (inside the onLogin function)
Lua:
    -- Outfit bonus
    local bonusCondition = getBonusCondition(player:getOutfit().lookType)
    if bonusCondition then
        player:addCondition(bonusCondition)
    end

how to configure: (i already created two bonuses for citizen and hunter outfits as an example)
Lua:
outfitBonuses = {
    [{male outfit id, female outfit id}] = createBonusCondition(ID, parameters & values)
}
the ID should be different for each bonus, so the script can identify between conditions
in my example i started from 1 for citizen bonus and used 2 for hunter, if you were to continue you would go 3, 4, 5, etc.
parameters should be inside a table, {param = some_condition_param, value = value_to_set}
here are the available condition params for tfs 1.2:
Code:
CONDITION_PARAM_OWNER
CONDITION_PARAM_TICKS
CONDITION_PARAM_HEALTHGAIN
CONDITION_PARAM_HEALTHTICKS
CONDITION_PARAM_MANAGAIN
CONDITION_PARAM_MANATICKS
CONDITION_PARAM_DELAYED
CONDITION_PARAM_SPEED
CONDITION_PARAM_LIGHT_LEVEL
CONDITION_PARAM_LIGHT_COLOR
CONDITION_PARAM_SOULGAIN
CONDITION_PARAM_SOULTICKS
CONDITION_PARAM_MINVALUE
CONDITION_PARAM_MAXVALUE
CONDITION_PARAM_STARTVALUE
CONDITION_PARAM_TICKINTERVAL
CONDITION_PARAM_FORCEUPDATE
CONDITION_PARAM_SKILL_MELEE
CONDITION_PARAM_SKILL_FIST
CONDITION_PARAM_SKILL_CLUB
CONDITION_PARAM_SKILL_SWORD
CONDITION_PARAM_SKILL_AXE
CONDITION_PARAM_SKILL_DISTANCE
CONDITION_PARAM_SKILL_SHIELD
CONDITION_PARAM_SKILL_FISHING
CONDITION_PARAM_STAT_MAXHITPOINTS
CONDITION_PARAM_STAT_MAXMANAPOINTS
CONDITION_PARAM_STAT_SOULPOINTS
CONDITION_PARAM_STAT_MAGICPOINTS
CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT
CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT
CONDITION_PARAM_STAT_SOULPOINTSPERCENT
CONDITION_PARAM_STAT_MAGICPOINTSPERCENT
CONDITION_PARAM_PERIODICDAMAGE
CONDITION_PARAM_SKILL_MELEEPERCENT
CONDITION_PARAM_SKILL_FISTPERCENT
CONDITION_PARAM_SKILL_CLUBPERCENT
CONDITION_PARAM_SKILL_SWORDPERCENT
CONDITION_PARAM_SKILL_AXEPERCENT
CONDITION_PARAM_SKILL_DISTANCEPERCENT
CONDITION_PARAM_SKILL_SHIELDPERCENT
CONDITION_PARAM_SKILL_FISHINGPERCENT
CONDITION_PARAM_BUFF_SPELL
CONDITION_PARAM_SUBID
CONDITION_PARAM_FIELD
ites good scripts and work fine
i have added it in outfits xml
female
<outfit type="0" looktype="126" name="Legend" premium="0" unlocked="1" enabled="1" />
male
<outfit type="1" looktype="127" name="Legend" premium="0" unlocked="1" enabled="1" />
But I encountered a problem that all players can use this addons legend
I want to make it special for those who don't have Legend addon and will get it by in-game purchase to enjoy its features
Please help and thanks in advance
 
ites good scripts and work fine
i have added it in outfits xml
female
<outfit type="0" looktype="126" name="Legend" premium="0" unlocked="1" enabled="1" />
male
<outfit type="1" looktype="127" name="Legend" premium="0" unlocked="1" enabled="1" />
But I encountered a problem that all players can use this addons legend
I want to make it special for those who don't have Legend addon and will get it by in-game purchase to enjoy its features
Please help and thanks in advance
Just
Lua:
unlocked="1"
change to
Lua:
unlocked="0"
You can use simple script onUse to give addon and sell it on shop :p
 
inside of data/events/scripts/creature.lua (make sure onChangeOutfit is set to 1 in events.xml)
Lua:
function createBonusCondition(id, params)
    local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, id)
    for i = 1, #params do
        local param = params[i].param
        local value = params[i].value
        condition:setParameter(param, value)
    end
    return condition
end

outfitBonuses = {
    [{128, 136}] = createBonusCondition(1, {
            {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
            {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
        }
    ),
    [{129, 137}] = createBonusCondition(2, {
            {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
        }
    )
}

function getBonusCondition(outfit)
    for outfits, bonus in pairs(outfitBonuses) do
        if table.contains(outfits, outfit) then
            return bonus
        end
    end
    return nil
end

function Creature:onChangeOutfit(outfit)
    if not self:isPlayer() then
        return true
    end
    local previousBonusCondition = getBonusCondition(self:getOutfit().lookType)
    local newBonusCondition = getBonusCondition(outfit.lookType)
    if previousBonusCondition then
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition:getSubId())
    end
    if newBonusCondition then
        self:addCondition(newBonusCondition)
    end
    return true
end

inside of data/creaturescripts/scripts/login.lua (inside the onLogin function)
Lua:
    -- Outfit bonus
    local bonusCondition = getBonusCondition(player:getOutfit().lookType)
    if bonusCondition then
        player:addCondition(bonusCondition)
    end

how to configure: (i already created two bonuses for citizen and hunter outfits as an example)
Lua:
outfitBonuses = {
    [{male outfit id, female outfit id}] = createBonusCondition(ID, parameters & values)
}
the ID should be different for each bonus, so the script can identify between conditions
in my example i started from 1 for citizen bonus and used 2 for hunter, if you were to continue you would go 3, 4, 5, etc.
parameters should be inside a table, {param = some_condition_param, value = value_to_set}
here are the available condition params for tfs 1.2:
Code:
CONDITION_PARAM_OWNER
CONDITION_PARAM_TICKS
CONDITION_PARAM_HEALTHGAIN
CONDITION_PARAM_HEALTHTICKS
CONDITION_PARAM_MANAGAIN
CONDITION_PARAM_MANATICKS
CONDITION_PARAM_DELAYED
CONDITION_PARAM_SPEED
CONDITION_PARAM_LIGHT_LEVEL
CONDITION_PARAM_LIGHT_COLOR
CONDITION_PARAM_SOULGAIN
CONDITION_PARAM_SOULTICKS
CONDITION_PARAM_MINVALUE
CONDITION_PARAM_MAXVALUE
CONDITION_PARAM_STARTVALUE
CONDITION_PARAM_TICKINTERVAL
CONDITION_PARAM_FORCEUPDATE
CONDITION_PARAM_SKILL_MELEE
CONDITION_PARAM_SKILL_FIST
CONDITION_PARAM_SKILL_CLUB
CONDITION_PARAM_SKILL_SWORD
CONDITION_PARAM_SKILL_AXE
CONDITION_PARAM_SKILL_DISTANCE
CONDITION_PARAM_SKILL_SHIELD
CONDITION_PARAM_SKILL_FISHING
CONDITION_PARAM_STAT_MAXHITPOINTS
CONDITION_PARAM_STAT_MAXMANAPOINTS
CONDITION_PARAM_STAT_SOULPOINTS
CONDITION_PARAM_STAT_MAGICPOINTS
CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT
CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT
CONDITION_PARAM_STAT_SOULPOINTSPERCENT
CONDITION_PARAM_STAT_MAGICPOINTSPERCENT
CONDITION_PARAM_PERIODICDAMAGE
CONDITION_PARAM_SKILL_MELEEPERCENT
CONDITION_PARAM_SKILL_FISTPERCENT
CONDITION_PARAM_SKILL_CLUBPERCENT
CONDITION_PARAM_SKILL_SWORDPERCENT
CONDITION_PARAM_SKILL_AXEPERCENT
CONDITION_PARAM_SKILL_DISTANCEPERCENT
CONDITION_PARAM_SKILL_SHIELDPERCENT
CONDITION_PARAM_SKILL_FISHINGPERCENT
CONDITION_PARAM_BUFF_SPELL
CONDITION_PARAM_SUBID
CONDITION_PARAM_FIELD
is it possible to modify this script so that the player earns the bonus with the amount of addons he has complete regardless of which addon it is?

example:

I have 2 full addons Citizen and Hunter I will get +5 Magic Level.
the other player has Beggar and Jester he will also get +5 Magic Level.

He doesn't need to be using that addon to receive the bonus, just have the full addon.
 
is it possible to modify this script so that the player earns the bonus with the amount of addons he has complete regardless of which addon it is?

example:

I have 2 full addons Citizen and Hunter I will get +5 Magic Level.
the other player has Beggar and Jester he will also get +5 Magic Level.

He doesn't need to be using that addon to receive the bonus, just have the full addon.
everything is possible if you try hard enough
 
Back
Top