• 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

everything is possible if you try hard enough
help
 
On TF2 1.2 thats not working. Getting some errors on login.lua i think
 
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
I have about 10 new outfits, can this script be put in a single one? or do I have to create a separate script each?
 
I'm using it, when I change it to increase magic level it works normally, but when I want to regenerate mana or health, I'm not successful, can anyone help?

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

function createRegenCondition(id, params)
    local condition = Condition(CONDITION_REGENERATION, 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 = {
    [{388, 289}] = createBonusCondition(1, {
        {param = CONDITION_PARAM_HEALTHGAIN, value = 1500},  -- Ganho de HP
            {param = CONDITION_PARAM_HEALTHTICKS, value = 100}  -- Intervalo de ticks (2000 milissegundos = 2 segundos)
        }
    ),
    [{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().lookMount)
    local newBonusCondition = getBonusCondition(outfit.lookMount)
    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
 
I'm using it, when I change it to increase magic level it works normally, but when I want to regenerate mana or health, I'm not successful, can anyone help?

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

function createRegenCondition(id, params)
    local condition = Condition(CONDITION_REGENERATION, 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 = {
    [{388, 289}] = createBonusCondition(1, {
        {param = CONDITION_PARAM_HEALTHGAIN, value = 1500},  -- Ganho de HP
            {param = CONDITION_PARAM_HEALTHTICKS, value = 100}  -- Intervalo de ticks (2000 milissegundos = 2 segundos)
        }
    ),
    [{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().lookMount)
    local newBonusCondition = getBonusCondition(outfit.lookMount)
    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
In line 26 do 'createRegenCondition' instead of 'createBonusCondition'
 
dentro de data/events/scripts/creature.lua (certifique-se de que onChangeOutfit esteja definido como 1 em events.xml)
Lua:
função createBonusCondition(id, params)
    condição local = Condição (CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condição:setParameter(CONDITION_PARAM_TICKS, -1)
    condição:setParameter(CONDITION_PARAM_SUBID, id)
    para i = 1, #params fazem
        parâmetro local = params[i].param
        valor local = params[i].valor
        condição:setParameter(parâmetro, valor)
    fim
    condição de devolução
fim

outfitBonuses = {
    [{128, 136}] = criarBonusCondition(1, {
            {parâmetro = CONDITION_PARAM_STAT_MAGICPOINTS, valor = 10},
            {parâmetro = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, valor = 110}
        }
    ),
    [{129, 137}] = criarBonusCondition(2, {
            {parâmetro = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, valor = 200}
        }
    )
}

função getBonusCondition(roupa)
    para roupas, bônus em pares(outfitBonuses) faça
        se tabela.contains(roupas, roupa) então
            bônus de retorno
        fim
    fim
    retorno nulo
fim

função Criatura:onChangeOutfit(outfit)
    se não for self:isPlayer() então
        retornar verdadeiro
    fim
    local anteriorBonusCondition = getBonusCondition(self:getOutfit().lookType)
    local newBonusCondition = getBonusCondition(outfit.lookType)
    se anteriorBonusCondition então
        self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition:getSubId())
    fim
    se novaBonusCondition então
        self:addCondition(newBonusCondition)
    fim
    retornar verdadeiro
fim[/código]

dentro de data/creaturescripts/scripts/login.lua (dentro da função onLogin)
[code=lua]
    - Bônus de roupa
    bônusCondição local = getBonusCondition(player:getOutfit().lookType)
    se bônusCondição então
        player:addCondition(bonusCondition)
    fim[/código]

como configurar: (já criei dois bônus para trajes de cidadão e caçador como exemplo)
[code=lua]outfitBonuses = {
    [{id de roupa masculina, id de roupa feminina}] = createBonusCondition(ID, parâmetros e valores)
}[/código]
o ID deve ser diferente para cada bônus, para que o script possa identificar entre as condições
no meu exemplo comecei com 1 para bônus de cidadão e usei 2 para caçador, se você continuasse iria 3, 4, 5, etc.
os parâmetros devem estar dentro de uma tabela, {param = some_condition_param, value = value_to_set}
aqui estão os parâmetros de condição disponíveis para tfs 1.2:
[código]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[/código]
[/QUOTE]

Seria possível converter a versão canário para revscript?
 
Back
Top