• 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.3] Buff Aura + MagicLevel

srunobantana

Member
Joined
Oct 24, 2021
Messages
42
Reaction score
19
How I want the spell to behave: When the player uses this ability, they will begin a transformation process. As they evolve, a unique aura will be added with each new form, reflecting Goku's growing power. Additionally, their Magic Level will increase by +5 with each transformation, demonstrating their rise to power. However, each transformation will intensify mana consumption. If the player does not have enough mana, the transformation will be canceled, and they will return to their original form, as Goku was before using the buff, without any additional consequences.

By Google translation

Current code:
It only includes the transformation process.
LUA:
local transformations = {918, 916, 915, 914, 913} -- Looktypes de cada transformação de Goku (Super Saiyan até Super Saiyan God)
local speeches = {
    "HAAAAA... HEEEEEE... HAAAAAAA!!!", -- Super Saiyan
    "HAAAAAAAAA!!!", -- Super Saiyan 2
    "HAAAAA... hEEE... HAAAAA... HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!!!", -- Super Saiyan 3
    "Super Saiyan 4!!!", -- Super Saiyan 4
    "GOD!!!" -- Super Saiyan God
}
local delay = 3000 -- Delay de 3 segundos entre cada transformação (em milissegundos)
local effects = {10, 11, 12, 13, 14} -- Efeitos visuais para adicionar no início de cada transformação
local epic_message = "O poder de Goku está se intensificando!" -- Mensagem épica (pode ser opcional)
local buff_duration = 10000 -- Duração da última transformação (10 segundos)

function onCastSpell(cid, var)
    -- Verifica se o jogador é válido
    if isPlayer(cid) then
        local initialOutfit = getCreatureOutfit(cid) -- Salva o looktype inicial do jogador

        -- Envia a mensagem épica para o jogador
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, epic_message)

        -- Inicia o processo de transformação
        for i = 1, #transformations do
            -- Adiciona efeito visual de transformação
            addEvent(function()
                doSendMagicEffect(getCreaturePosition(cid), effects[i])
            end, delay * (i - 1))

            -- Adiciona a fala de transformação com efeito de magia
            addEvent(function()
                -- Adiciona a fala com o efeito de magia (em cor laranja e tipo mágico)
                doCreatureSay(cid, speeches[i], TALKTYPE_MONSTER_SAY) -- Goku grita com efeito mágico
                doCreatureChangeOutfit(cid, {lookType = transformations[i]}) -- Muda o looktype para a transformação
            end, delay * (i - 1))

            -- Se for a última transformação, colocamos uma fala mais épica e definimos o tempo de duração da transformação final
            if i == #transformations then
                addEvent(function()
                    doSendMagicEffect(getCreaturePosition(cid), effects[i]) -- Efeito final da transformação
                    doCreatureSay(cid, "Agora, meu poder está além de tudo o que você já viu! Prepare-se!", TALKTYPE_MONSTER_SAY) -- Fala épica

                    -- Define o tempo da transformação final (10 segundos)
                    addEvent(function()
                        -- Restaura o looktype original após o tempo de 10 segundos
                        doCreatureChangeOutfit(cid, {lookType = initialOutfit.lookType}) -- Retorna ao looktype original
                    end, buff_duration) -- O buff dura 10 segundos
                end, delay * i)
            end
        end
    end
    return true
end
 
You can learn how to convert functions from TFS 0.x to 1.x correctly. Just follow data/lib/compat/compat.lua and read everything. For example, replace doCreatureChangeOutfit with creature:setOutfit or player:setOutfit. I've done everything in the script... you can try it out now.


LUA:
local transformations = {918, 916, 915, 914, 913} -- Looktypes de cada transformação de Goku (Super Saiyan até Super Saiyan God)
local speeches = {
    "HAAAAA... HEEEEEE... HAAAAAAA!!!", -- Super Saiyan
    "HAAAAAAAAA!!!", -- Super Saiyan 2
    "HAAAAA... hEEE... HAAAAA... HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!!!", -- Super Saiyan 3
    "Super Saiyan 4!!!", -- Super Saiyan 4
    "GOD!!!" -- Super Saiyan God
}
local delay = 3000 -- Delay de 3 segundos entre cada transformação (em milissegundos)
local effects = {10, 11, 12, 13, 14} -- Efeitos visuais para adicionar no início de cada transformação
local epic_message = "O poder de Goku está se intensificando!" -- Mensagem épica (pode ser opcional)
local buff_duration = 10000 -- Duração da última transformação (10 segundos)

function onCastSpell(creature, variant)
    local player = Player(creature)
    if not player then
        return false
    end

    local playerGuid = player:getGuid()
    local initialOutfit = player:getOutfit() -- Salva o looktype inicial do jogador

    -- Envia a mensagem épica para o jogador
    player:sendTextMessage(MESSAGE_INFO_DESCR, epic_message)

    -- Inicia o processo de transformação
    for i = 1, #transformations do
        -- Adiciona efeito visual de transformação
        addEvent(function()
            local player = Player(playerGuid)
            if not player then return end
            player:getPosition():sendMagicEffect(effects[i])
        end, delay * (i - 1))

        -- Adiciona a fala de transformação com efeito de magia
        addEvent(function()
            local player = Player(playerGuid)
            if not player then return end
            player:say(speeches[i], TALKTYPE_MONSTER_SAY) -- Goku grita com efeito mágico
            player:setOutfit({lookType = transformations[i]}) -- Muda o looktype para a transformação
        end, delay * (i - 1))

        -- Se for a última transformação, colocamos uma fala mais épica e definimos o tempo de duração da transformação final
        if i == #transformations then
            addEvent(function()
                local player = Player(playerGuid)
                if not player then return end
                player:getPosition():sendMagicEffect(effects[i]) -- Efeito final da transformação
                player:say("Agora, meu poder está além de tudo o que você já viu! Prepare-se!", TALKTYPE_MONSTER_SAY) -- Fala épica

                -- Define o tempo da transformação final (10 segundos)
                addEvent(function()
                    local player = Player(playerGuid)
                    if not player then return end
                    player:setOutfit(initialOutfit) -- Retorna ao looktype original
                end, buff_duration) -- O buff dura 10 segundos
            end, delay * i)
        end
    end
    return true
end
Post automatically merged:

After reading your message, I now understand what you want: mana consumption and transformation every 5 magic levels. So I created another script... Try it out.

LUA:
local transformations = {918, 916, 915, 914, 913} -- Looktypes de cada transformação de Goku (Super Saiyan até Super Saiyan God)
local speeches = {
    "HAAAAA... HEEEEEE... HAAAAAAA!!!", -- Super Saiyan
    "HAAAAAAAAA!!!", -- Super Saiyan 2
    "HAAAAA... hEEE... HAAAAA... HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!!!", -- Super Saiyan 3
    "Super Saiyan 4!!!", -- Super Saiyan 4
    "GOD!!!" -- Super Saiyan God
}
local effects = {10, 11, 12, 13, 14} -- Efeitos visuais para cada transformação
local manaCosts = {500, 700, 1000, 1500, 2000} -- Consumo de mana para cada transformação
local delay = 3000 -- Delay de 3 segundos entre transformações
local duration = 10000 -- Duração do buff após a última transformação (10 segundos)
local buffMagicLevel = 5 -- Aumento de nível de magia a cada transformação

 -- Inicia o processo de transformação
function onCastSpell(creature, variant)
    local player = Player(creature)
    if not player then
        return false
    end

    local playerGuid = player:getGuid()
    local initialOutfit = player:getOutfit()

    local function applyTransformation(stage)
        local player = Player(playerGuid)
        if not player then return end

        if player:getMana() < manaCosts[stage] then
            player:sendTextMessage(MESSAGE_STATUS_WARNING, "Você não tem mana suficiente para continuar a transformação.")
            player:setOutfit(initialOutfit)
            return
        end

        player:addMana(-manaCosts[stage])

       -- Adiciona efeito visual de transformação
        player:getPosition():sendMagicEffect(effects[stage])
        player:say(speeches[stage], TALKTYPE_MONSTER_SAY)
        player:setOutfit({ lookType = transformations[stage] })

        local magicBuff = Condition(CONDITION_ATTRIBUTES)
        magicBuff:setParameter(CONDITION_PARAM_TICKS, duration)
        magicBuff:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, buffMagicLevel * stage)
        player:addCondition(magicBuff)

       -- Se for a última transformação, colocamos uma fala mais épica e definimos o tempo de duração da transformação final
        if stage == #transformations then
            addEvent(function()
                local player = Player(playerGuid)
                if not player then return end
                player:getPosition():sendMagicEffect(effects[stage]) -- Efeito final da transformação
                player:say("Agora, meu poder está além de tudo o que você já viu! Prepare-se!", TALKTYPE_MONSTER_SAY) -- Fala épica

                -- Define o tempo da transformação final (10 segundos)
                addEvent(function()
                    local player = Player(playerGuid)
                    if not player then return end
                    player:setOutfit(initialOutfit) -- Retorna ao looktype original
                    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sua transformação acabou.")
                end, duration) -- O buff dura 10 segundos
            end, delay * stage)
        end
    end

    for i = 1, #transformations do
        addEvent(applyTransformation, delay * (i - 1), i)
    end

    return true
end
 
Last edited:
Back
Top