• 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 0.X bonus full set

pisquila

New Member
Joined
Nov 14, 2023
Messages
11
Reaction score
3
Hello, Could someone help with a code where using the complete set (configurable) would give you a type of bonus...

Bonus EXP when you have the complete set:
+100 Hp
+100 Mp
+ 10 ML skill
(Configurable)

Note: you would only get the bonus if you had all the items complete!

If anyone can help, I would be grateful in advance.

It can be through the sourcer or script, but if you have the good will at the time and can do it through the sourcer, even better -

TFS 0.4 8.60
 
you can easily do it via movements just include script for the items check the players equipment slot and each time any item is moved track what items are on and once the items are complete then apply bonuses along with check onDeEquip that if any item is taken off the bonuses go off too you should not need any source changes to achieve this.
 
você pode fazer isso facilmente por meio de movimentos, basta incluir o script para os itens, verificar o slot de equipamento dos jogadores e cada vez que qualquer item for movido, rastrear quais itens estão lá e, quando os itens estiverem completos, aplicar bônus junto com a verificação onDeEquip para que, se algum item for retirado, os bônus também sejam desativados. Você não deve precisar de nenhuma alteração na fonte para conseguir isso.
Can you help with the script please?
 
Hello, Could someone help with a code where using the complete set (configurable) would give you a type of bonus...

Bonus EXP when you have the complete set:
+100 Hp
+100 Mp
+ 10 ML skill
(Configurable)

Note: you would only get the bonus if you had all the items complete!

If anyone can help, I would be grateful in advance.

It can be through the sourcer or script, but if you have the good will at the time and can do it through the sourcer, even better -

TFS 0.4 8.60
try this:

setBonus.lua
LUA:
--
-- Configuração do conjunto e dos bônus
local setItems = {2160, 2494, 2466} -- IDs dos itens do conjunto (modifique conforme seu conjunto)
local bonusHp = 100
local bonusMp = 100
local bonusMl = 10

-- Função para verificar se o jogador está usando o conjunto completo
function isWearingFullSet(cid)
    for _, itemId in ipairs(setItems) do
        local equipped = false
        for slot = CONST_SLOT_HEAD, CONST_SLOT_FEET do
            local item = getPlayerSlotItem(cid, slot)
            if item.itemid == itemId then
                equipped = true
                break
            end
        end
        if not equipped then
            return false
        end
    end
    return true
end

-- Função para aplicar os bônus
function applyBonuses(cid)
    doCreatureAddHealth(cid, bonusHp)
    doPlayerAddMana(cid, bonusMp)
    doPlayerAddMagLevel(cid, bonusMl)
end

-- Função para remover os bônus
function removeBonuses(cid)
    doCreatureAddHealth(cid, -bonusHp)
    doPlayerAddMana(cid, -bonusMp)
    doPlayerAddMagLevel(cid, -bonusMl)
end

-- Função para verificar o conjunto ao mudar de equipamento
function onEquipChange(cid)
    if isWearingFullSet(cid) then
        applyBonuses(cid)
    else
        removeBonuses(cid)
    end
    return true
end

-- Evento de login para checar o conjunto ao entrar no jogo
function onLogin(cid)
    if isWearingFullSet(cid) then
        applyBonuses(cid)
    end
    return true
end

on login.lua
registerCreatureEvent(cid, "SetBonus")

creaturescripts.xml
<event type="login" name="SetBonus" event="script" value="setBonus.lua"/>
 
This is the exact reason you guys need to stop using chatgpt to solve all your problems.

1) 'onEquipChange' - is not a regular function inside of tfs. Therefore, there is no trigger to activate it currently. You would want to trigger this from onEquip and onDeEquip, which is not currently shown.
2) instead of applying a temporary buff, this script is giving permanent changes to the character. This is not technically a problem, but the way it's currently scripted allows the players to get the bonus everytime they login, stacking the bonus. (and since it's permanent bonus, once it's stacked onto the player, it's very hard to undo, cuz you have no idea how many times it's stacked. Could be twice. Could be 100 times.)
3) 'isWearingFullSet' - looping from head to feet, includes the necklace, backpack and hand slots but occludes the ring and ammo slots. This should check for all the slots, not just 8 of them. Or, if the intended targets are head, armor, legs, feet - aka 'a full set', then this is checking additional area's that it shouldn't.

---
@Rolledstone had a decent idea, but you don't need to track items being moved. You only need to use onEquip and onDeEquip for this.
If you use permanent changes like the script above, you'll need a storage value to track if the buff has been given previously. If you use temporary buffs, then you'll need to have an additional onLogin script to reapply the buff, I think? Depends on your tfs version. Some of the older distro's trigger onEquip functions during the login process, and some don't.
 
Last edited by a moderator:
Back
Top