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

[TFS 1.1] Outfit Bonuses

Anyone know why the outfit bonuses are reloaded when you are mounted and entering protection zone?
If i heal up to full heath (500hp) and the outfit give me 200hp and i leave the protection zone and have auto mount enabled i lose 200hp because the outfits bonuses are reloaded. :confused:
 
Check if you added all the necessary in the correct files. I have tfs 1.2 and it works perfect, with outfits and mounts. You can do whatever you want with it, its pretty simple, even for me, and i am a noob xD
 
Hello is possible add two stats for exemple:
Code:
    [128] = {[1] = {condition = mp}, [2] = {condition = magic}, [3] = {condition = {mp, magic}}},

and addons for vocation ?

[128] for knight
[129] for paladin
[130] for druid and sorcerer
 
Yes, its possible to add even 4 stats, you can add mount aswell.
For vocations you should make a new part like
Code:
if vocation X then
[128] ...
elseif vocation Y then
[129] ...
end
 
Yes, its possible to add even 4 stats, you can add mount aswell.
For vocations you should make a new part like
Code:
if vocation X then
[128] ...
elseif vocation Y then
[129] ...
end
I think is better do something like this:
Code:
[128] = {[vocationId] = {[1] = {condition = distance}, [2] = {condition = sword}, [3] = {condition = hp}}},
And then change this part:
Code:
local oldOutfit_t = outfitBonuses[old.lookType]
To something like this (Just an idea):
Code:
local oldOutfit_t = outfitBonuses[old.lookType][self:getVocation():getBase():getId()]

You may need to adapt the currentOutfit part also.
 
I think is better do something like this:
Code:
[128] = {[vocationId] = {[1] = {condition = distance}, [2] = {condition = sword}, [3] = {condition = hp}}},
And then change this part:
Code:
local oldOutfit_t = outfitBonuses[old.lookType]
To something like this (Just an idea):
Code:
local oldOutfit_t = outfitBonuses[old.lookType][self:getVocation():getBase():getId()]

You may need to adapt the currentOutfit part also.

Thanks for support, have this error

Code:
Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onChangeOutfit
data/events/scripts/creature.lua:53: attempt to index a nil value
stack traceback:
        [C]: in function '__index'
        data/events/scripts/creature.lua:53: in function <data/events/scripts/cr
eature.lua:37>
 
I didn't tried it, but I can't see why it shouldn't work... Post your line of code with the error maybe? :confused:
 
I didn't tried it, but I can't see why it shouldn't work... Post your line of code with the error maybe? :confused:

Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onChangeOutfit
data/events/scripts/creature.lua:48: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/events/scripts/creature.lua:48: in function <data/events/scripts/cr
eature.lua:33>


After change:
Code:
local oldOutfit_t = outfitBonuses[old.lookType][self:getVocation():getBase():getId()]

local mp = Condition(CONDITION_ATTRIBUTES)
mp:setParameter(CONDITION_PARAM_TICKS, -1)
mp:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, 110)

local magic = Condition(CONDITION_ATTRIBUTES)
magic:setParameter(CONDITION_PARAM_TICKS, -1)
magic:setParameter(CONDITION_PARAM_STAT_MAGICPOINTSPERCENT, 150)
magic:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, 110)

local hp = Condition(CONDITION_ATTRIBUTES)
hp:setParameter(CONDITION_PARAM_TICKS, -1)
hp:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 110)

local distance = Condition(CONDITION_ATTRIBUTES)
distance:setParameter(CONDITION_PARAM_TICKS, -1)
distance:setParameter(CONDITION_PARAM_SKILL_DISTANCEPERCENT, 150)
distance:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 110)

local sword = Condition(CONDITION_ATTRIBUTES)
sword:setParameter(CONDITION_PARAM_TICKS, -1)
sword:setParameter(CONDITION_PARAM_SKILL_MELEEPERCENT, 150)
sword:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 110)


oldOutfit = {}

outfitBonuses = {
[128] = {[4] = {[2] = {condition = hp}, [3] = {condition = sword}}},
[129] = {[3] = {[2] = {condition = hp}, [3] = {condition = distance}}},
[130] = {[1] = {[2] = {condition = mp}, [3] = {condition = magic}}}
}

function Creature:eek:nChangeOutfit(outfit)
if self:isPlayer() then
local getOutfit = self:getOutfit()
oldOutfit[self:getId()] = { --Colors (Head, Body, Legs, Feet) and lookTypeEx are unused, but I still keep them here because I'm stupid.
lookHead = getOutfit.lookHead;
lookBody = getOutfit.lookBody;
lookLegs = getOutfit.lookLegs;
lookFeet = getOutfit.lookFeet;
lookType = getOutfit.lookType;
lookTypeEx = getOutfit.lookTypeEx;
lookAddons = getOutfit.lookAddons;
lookMount = getOutfit.lookMount;
}

local old = oldOutfit[self:getId()]
local oldOutfit_t = outfitBonuses[old.lookType][self:getVocation():getBase():getId()]
if oldOutfit_t and oldOutfit_t[old.lookAddons] then
local oldCondition = oldOutfit_t[old.lookAddons].condition
if type(oldCondition) == "table" then
for _, condition in pairs(oldCondition) do
self:removeCondition(condition:getType(), condition:getId())
end
else
self:removeCondition(oldCondition:getType(), oldCondition:getId())
end
end

local currentOutfit = outfitBonuses[outfit.lookType]
if currentOutfit and currentOutfit[outfit.lookAddons] then
local newCondition = currentOutfit[outfit.lookAddons].condition
if type(newCondition) == "table" then
for _, condition in pairs(newCondition) do
self:addCondition(condition)
end
else
self:addCondition(newCondition)
end
end
end
return true
end


Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onChangeOutfit
data/events/scripts/creature.lua:48: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/events/scripts/creature.lua:48: in function <data/events/scripts/cr
eature.lua:33>

After remove :getBase()
 
Last edited:
Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onChangeOutfit
data/events/scripts/creature.lua:48: attempt to index a nil value
stack traceback:
[C]: in function '__index'
data/events/scripts/creature.lua:48: in function <data/events/scripts/cr
eature.lua:33>
I'm using an early release of TFS 1.2 (Technically is still 1.1) and your code works fine (You forgot to change the currentOutfit, but that's have nothing to do with your error)...
Are you sure that you didn't changed anything else? Or which TFS version are you currently using?
 
I'm using an early release of TFS 1.2 (Technically is still 1.1) and your code works fine (You forgot to change the currentOutfit, but that's have nothing to do with your error)...
Are you sure that you didn't changed anything else? Or which TFS version are you currently using?

removed this line from you script
Code:
hp:setParameter(CONDITION_PARAM_SUBID, 100)

last test on windows 7 tfs 1.2



new test on dedicated server linux tfs 1.2
used original script no changes
change line
Code:
local oldOutfit_t = outfitBonuses[old.lookType][self:getVocation():getBase():getId()]

Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onChangeOutfit
data/events/scripts/creature.lua:43: attempt to index field '?' (a nil value)
stack traceback:
[C]: in function '__index'
data/events/scripts/creature.lua:43: in function <data/events/scripts/creature.lua:28>

remove :getBase()

Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onChangeOutfit
data/events/scripts/creature.lua:43: attempt to index field '?' (a nil value)
stack traceback:
[C]: in function '__index'
data/events/scripts/creature.lua:43: in function <data/events/scripts/creature.lua:28>

Thank you all for help, I made this script and solve my problem

function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
if not player:isKnight() then
player:say('Only Knight can use this item', TALKTYPE_MONSTER_SAY)
return true
end
if(getPlayerStorageValue(cid, 41418752) < 1) then

player:addOutfitAddon(632, 3)
player:addOutfitAddon(633, 3)
setPlayerStorageValue(cid, 41418752, 1)
Item(item.uid):remove(1)
player:say('You have won the bonus addon of his vocation', TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_STUN)
else
player:say('You already have this addon', TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(CONST_ME_POFF)
end

return true
end
 
Can't seem to get resistances to work...I'm not sure what I'm doing wrong. Skills and hp/mp attr are working fine and I get no errors but I still take full dmg from fire fields with 20% resist fire. If anyone could look at my scripts and tell me what I'm doing wrong?
creature.lua events
Code:
local hp = Condition(CONDITION_ATTRIBUTES)
hp:setParameter(CONDITION_PARAM_TICKS, -1)
hp:setParameter(CONDITION_PARAM_SUBID, 100)
hp:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 100)

local distance = Condition(CONDITION_ATTRIBUTES)
distance:setParameter(CONDITION_PARAM_TICKS, -1)
distance:setParameter(CONDITION_PARAM_SUBID, 101)
distance:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 5)

local melee = Condition(CONDITION_ATTRIBUTES)
melee:setParameter(CONDITION_PARAM_TICKS, -1)
melee:setParameter(CONDITION_PARAM_SUBID, 102)
melee:setParameter(CONDITION_PARAM_SKILL_MELEE, 3)

local magic = Condition(CONDITION_ATTRIBUTES)
magic:setParameter(CONDITION_PARAM_TICKS, -1)
magic:setParameter(CONDITION_PARAM_SUBID, 103)
magic:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 3)

local resistFire = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 120)

local resistIce = Condition(CONDITION_ATTRIBUTES)
resistIce:setParameter(CONDITION_PARAM_TICKS, -1)
resistIce:setParameter(CONDITION_PARAM_SUBID, 124)

local resistEarth = Condition(CONDITION_ATTRIBUTES)
resistEarth:setParameter(CONDITION_PARAM_TICKS, -1)
resistEarth:setParameter(CONDITION_PARAM_SUBID, 121)

local resistDeath = Condition(CONDITION_ATTRIBUTES)
resistDeath:setParameter(CONDITION_PARAM_TICKS, -1)
resistDeath:setParameter(CONDITION_PARAM_SUBID, 123)

local resistPhysical = Condition(CONDITION_ATTRIBUTES)
resistPhysical:setParameter(CONDITION_PARAM_TICKS, -1)
resistPhysical:setParameter(CONDITION_PARAM_SUBID, 125)

local resistEnergy = Condition(CONDITION_ATTRIBUTES)
resistEnergy:setParameter(CONDITION_PARAM_TICKS, -1)
resistEnergy:setParameter(CONDITION_PARAM_SUBID, 122)


oldOutfit = {}

outfitBonuses = {
    [128] = {[3] = {condition = hp}}, --citzien
    [129] = {[3] = {condition = distance}}, --hunter
    [130] = {[3] = {condition = magic, resistFire}}, --mage
    [131] = {[3] = {condition = {melee, hp}}} --knight
}
login.lua creaturescripts --This is at the very bottom of the script
Code:
    --Addon Bonuses--
    player:setOutfit(player:getOutfit())
   
    player:registerEvent("resist")
   
    return true
   
   
   
end
resist.lua creaturescripts
Code:
local resists = { 

{120, COMBAT_FIREDAMAGE, 20},
{121, COMBAT_EARTHDAMAGE, 20},
{122, COMBAT_ENERGYDAMAGE, 20},
{123, COMBAT_DEATHDAMAGE, 20},
{124, COMBAT_ICEDAMAGE, 20},
{125, COMBAT_PHYSICALDAMAGE, 20},
{126, COMBAT_HEALING, -10},

 } -- {subId, damageType, resistancePercent}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    for i = 1, #resists do
        if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, resists[i][1]) then
            if primaryType == resists[i][2] then
                primaryDamage = (primaryDamage - (primaryDamage * (resists[i][3] / 100)))
            end
            if secondaryType == resists[i][2] then
                secondaryDamage = (secondaryDamage - (secondaryDamage * (resists[i][3] / 100)))
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end
creaturescripts.xml
Code:
<event type="healthchange" name="resist" script="resist.lua"/>
 
Hello ppl, who know how make:

1. Speed for outfit
2. Crit from new 10.98 version.
3. Mana steal from new 10.98 version.
4. hp steal from new 10.98 version.
 
This is how we did it on Gunzodus (now we use different system - bonus packs), I will post a code soon.
The lua code is little bit messy because you need to define all those conditions for every skill.

HTML:
<outfit type="1" looktype="128" name="Citizen" premium="0" unlocked="1" speed="10" maxhealth="100" enabled="1" />
    <outfit type="1" looktype="129" name="Hunter" premium="0" unlocked="1" skilldist="3" enabled="1" />
    <outfit type="1" looktype="130" name="Mage" premium="0" unlocked="1" maxmana="200" maxhealth="100" maglevel="4" enabled="1" />
    <outfit type="1" looktype="131" name="Knight" premium="0" unlocked="1" skillsword="3" enabled="1" />
    <outfit type="1" looktype="132" name="Nobleman" premium="0" unlocked="1" skillclub="3" enabled="1" />
    <outfit type="1" looktype="133" name="Summoner" premium="0" unlocked="1" maxmana="100" maglevel="2" enabled="1" />
    <outfit type="1" looktype="134" name="Warrior" premium="0" unlocked="1" skillsword="3" enabled="1" />
    <outfit type="1" looktype="143" name="Barbarian" premium="0" unlocked="1" skillaxe="3" enabled="1" />
    <outfit type="1" looktype="144" name="Druid" premium="0" unlocked="1" maglevel="2" enabled="1" />
    <outfit type="1" looktype="145" name="Wizard" premium="0" unlocked="1" maxmana="100" maglevel="1" enabled="1" />
    <outfit type="1" looktype="146" name="Oriental" premium="0" unlocked="1" maxhealth="120" maxmana="200" speed="15" enabled="1" />
 
Back
Top