• 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 Need help with spells (TFS 1.4.2)

kite28

Member
Joined
May 15, 2012
Messages
69
Reaction score
5
Hello, I need help with the harness because I don't know what's wrong anymore. Not working . maybe writing new ones.

TFS 1.4.2

1. I need a directional spell. Whenever the character turns, a magical effect strikes a specific place, and in the script it is possible to change the position of the effect and the area of effect.

2. Aoe with one effect and aoe with many effect


This is my old script but no work.
Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_HITCOLOR, COLOR_TEAL)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -5.0, -1200, -5.0, -1400)

local condition = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 20000)
setConditionParam(condition, CONDITION_PARAM_SPEED, -400)
addCombatCondition(combat1, condition)

arr1 = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 3, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
}

local area1 = createCombatArea(arr1)
setCombatArea(combat1, area1)

function onCastSpell(cid, var)

local waittime = 1 -- Tempo de exhaustion
local storage = 8032

if exhaustion.check(cid, storage) then
return false
end

local p = getCreaturePosition(cid)
local x = {
[0] = {x=p.x+2, y=p.y-1, z=p.z},
[1] = {x=p.x+4, y=p.y+1, z=p.z},
[2] = {x=p.x+2, y=p.y+4, z=p.z},
[3] = {x=p.x-1, y=p.y+1, z=p.z}
}
local y = {
[0] = 91,    --
[1] = 89,    --prawo
[2] = 92,    --dol
[3] = 90    --lewo
}
pos = x[getCreatureLookDirection(cid)]
eff = y[getCreatureLookDirection(cid)]
doSendMagicEffect(pos, eff)
doCreatureSay(cid, "Katon Gokakyu no Jutsu", TALKTYPE_MONSTER)
exhaustion.set(cid, storage, waittime)
doCombat(cid, combat1, var)
end
Very thanks for help <3
 
Last edited:
I haven't tested it yet, but to convert an old script to the new version of TFS 1.4.2, you should look at the compat.lua file and identify the functions that need to be replaced. For example:

Replace createCombatObject() with Combat().
Replace setCombatParam() with combat:setParameter().
Replace setCombatFormula() with combat:setFormula().
Replace createCombatArea() with CombatArea().
Replace addDamageCondition() with condition:addDamage().
Replace setCombatCondition() with combat:addCondition().
Replace onCastSpell() with combat.onCastSpell().
Replace createConditionObject() with Condition().
Replace setConditionParam() with condition:setParameter().
And instead of doCombat(), use combat:execute(). This should help with conversion

Look for the function you want in compat.lua and see if it needs to be replaced. Replace and test. If errors appear, try again and do it correctly. This is how you will be able to convert the old scripts to work with the new version."


Lua:
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat1:setParameter(COMBAT_PARAM_HITCOLOR, COLOR_TEAL)
combat1:setFormula(COMBAT_FORMULA_LEVELMAGIC, -5.0, -1200, -5.0, -1400)

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 20000)
condition:setParameter(CONDITION_PARAM_SPEED, -400)
combat1:addCondition(condition)

local arr1 = {
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 1, 1, 1, 0, 0},
    {0, 0, 1, 1, 1, 0, 0},
    {0, 0, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 0, 0, 0},
    {0, 0, 0, 3, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0},
}

local area1 = createCombatArea(arr1)
combat1:setArea(area1)


local cooldownTable = {}

function onCastSpell(creature, variant)
    local cooldown = 1000 -- Cooldown time in milliseconds

    if cooldownTable[creature:getId()] and os.time() - cooldownTable[creature:getId()] < cooldown then
        creature:sendTextMessage(MESSAGE_INFO_DESCR, "You need to wait for the spell to cool down.")
        return false
    end

    local position = creature:getPosition()
    local x = {
        [0] = {x = position.x + 2, y = position.y - 1, z = position.z},
        [1] = {x = position.x + 4, y = position.y + 1, z = position.z},
        [2] = {x = position.x + 2, y = position.y + 4, z = position.z},
        [3] = {x = position.x - 1, y = position.y + 1, z = position.z}
    }
    local y = {
        [0] = 91, --
        [1] = 89, -- prawo
        [2] = 92, -- dol
        [3] = 90 -- lewo
    }
    local pos = x[creature:getDirection()]
    local magicEffect = y[creature:getDirection()]

    Position(pos):sendMagicEffect(magicEffect)

    creature:say("Katon Gokakyu no Jutsu", TALKTYPE_MONSTER)
    
    cooldownTable[creature:getId()] = os.time() + cooldown

    combat1:execute(creature, variant)
end
 
Resolve:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_HITCOLOR, COLOR_LIGHTBLUE)
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -3.0, -600, -3.0, -800)



arr1 = {
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 0, 0},
{0, 0, 1, 3, 1, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0},
}



local area1 = createCombatArea(arr1)
setCombatArea(combat1, area1)


local function onCastSpell1(parameters)
return isPlayer(parameters.cid) and doCombat(parameters.cid, combat1, parameters.var)
end


function onCastSpell(cid, var)
local p = getCreaturePosition(cid)
local x = {
[0] = {x=p.x+1, y=p.y-1, z=p.z},
[1] = {x=p.x+3, y=p.y+1, z=p.z},
[2] = {x=p.x+1, y=p.y+3, z=p.z},
[3] = {x=p.x-1, y=p.y+1, z=p.z}
}
local y = {
[0] = 78, --
[1] = 78, --prawo
[2] = 78, --dol
[3] = 78 --lewo
}
pos = x[getCreatureLookDirection(cid)]
eff = y[getCreatureLookDirection(cid)]
doSendMagicEffect(pos, eff)
local parameters = { cid = cid, var = var}
addEvent(onCastSpell1, 100, parameters)
return TRUE
end
But new problem with spell buff:
local tempo = 45 -- tempo em segundos.
local effect = {83} -- effect no player, caso queira apenas 1, basta remover os outros numeros.

local ml = 30 -- quantos ira aumentar o skill de ML
local skillfist = 0 -- quantos ira aumentar o skill de Fist
local skillsword = 0 -- quantos ira aumentar o skill de Sword
local skillaxe = 0 -- quantos ira aumentar o skill de Axe
local skillclub = 0 -- quantos ira aumentar o skill de Club
local skilldistance = 0 -- quantos ira aumentar o skill de Distance
local skillshield = 30 -- quantos ira aumentar o skill de Shield
local health = 1250 -- A cada 1 segundo quantos aumentar de vida
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, tempo*1000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, ml)
setConditionParam(condition, CONDITION_PARAM_SKILL_FIST, skillfist)
setConditionParam(condition, CONDITION_PARAM_SKILL_SWORD, skillsword)
setConditionParam(condition, CONDITION_PARAM_SKILL_AXE, skillaxe)
setConditionParam(condition, CONDITION_PARAM_SKILL_CLUB, skillclub)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCE, skilldistance)
setConditionParam(condition, CONDITION_PARAM_SKILL_SHIELD, skillshield)
setConditionParam(condition, CONDITION_PARAM_OUTFIT, outfit)
setCombatCondition(combat, condition)

local condition = createConditionObject(CONDITION_REGENERATION)
setConditionParam(condition, CONDITION_PARAM_SUBID, 1)
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setConditionParam(condition, CONDITION_PARAM_TICKS, tempo*1000)
setConditionParam(condition, CONDITION_PARAM_HEALTHGAIN, health)
setConditionParam(condition, CONDITION_PARAM_HEALTHTICKS, 1000)
setCombatCondition(combat, condition)

function magicEffect2828(tempo2,tempo3,cid)
if (isCreature(cid)) then
if getPlayerStorageValue(cid, 134453) > 0 and getCreatureCondition(cid, CONDITION_REGENERATION, 1) then
for i=1, #effect do
local position = {x=getPlayerPosition(cid).x+1, y=getPlayerPosition(cid).y, z=getPlayerPosition(cid).z}
doSendMagicEffect(position, effect)
end
end
end
end

function onCastSpell(cid, var)
local waittime = 165
local storage = 25895

if exhaustion.check(cid, storage) then
doPlayerSendChannelMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Aguarde ".. exhaustion.get(cid, storage) .. " segundos para usar o jutsu novamente.", TALKTYPE_CHANNEL_O, CHANNEL_SPELL)
return false
end

if getPlayerStorageValue(cid, 134453) ~= 1 or getCreatureCondition(cid, CONDITION_REGENERATION, 1) == false then
doCombat(cid, combat, var)
doPlayerSendTextMessage(cid,27,'Kurama gave you some chakra.')
doPlayerSay(cid, 'Kuramaaa!', TALKTYPE_ORANGE_1)
tempo2 = 0
while (tempo2 ~= (tempo*1000)) do
addEvent(magicEffect2828, tempo2, tempo2, tempo*1000, cid)
tempo2 = tempo2 + 300
end
setPlayerStorageValue(cid, 134453,1) -- storage verifica transformado, quando = 1 player esta transformado.
exhaustion.set(cid, storage, waittime)
else
doPlayerSendCancel(cid, "Sorry, you are transformed.")
end
end

Error:

Lua:
Lua Script Error: [Spell Interface]
data/spells/scripts/postacie/naruto/kurama chikara.lua:onCastSpell
data/spells/scripts/postacie/naruto/kurama chikara.lua:50: attempt to index global 'exhaustion' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/spells/scripts/postacie/naruto/kurama chikara.lua:50: in function <data/spells/scripts/postacie/naruto/kurama chikara.lua:46>
 
Lua:
local tempo = 45
local effect = {83}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local skillCondition = Condition(CONDITION_ATTRIBUTES)
skillCondition:setParameter(CONDITION_PARAM_TICKS, tempo * 1000)
skillCondition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 30)
skillCondition:setParameter(CONDITION_PARAM_SKILL_FIST, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_SWORD, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_AXE, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_CLUB, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_SHIELD, 30)
combat:addCondition(skillCondition)


local outfitCondition = Condition(CONDITION_OUTFIT)
outfitCondition:setOutfit({lookType = 128}) -- Set Naruto's transformation outfit ID.
outfitCondition:setTicks(tempo * 1000)
combat:addCondition(outfitCondition)

local regenCondition = Condition(CONDITION_REGENERATION)
regenCondition:setParameter(CONDITION_PARAM_SUBID, 1)
regenCondition:setParameter(CONDITION_PARAM_BUFF, true)
regenCondition:setParameter(CONDITION_PARAM_TICKS, tempo * 1000)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 1250)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(regenCondition)

local cooldownTime = 165
local lastCastTime = {}

function magicEffect2828(cid)
    local creature = Creature(cid)
    if creature then
        if creature:getStorageValue(134453) > 0 and getCreatureCondition(cid, CONDITION_REGENERATION, 1) then
            local position = creature:getPosition()
            for i = 1, #effect do
                position:sendMagicEffect(effect[i])
            end
        end
    end
end

function onCastSpell(cid, var)
    local storage = 25895

    if not lastCastTime[cid] or os.time() - lastCastTime[cid] >= cooldownTime then
        if Creature(cid):getStorageValue(134453) ~= 1 or getCreatureCondition(cid, CONDITION_REGENERATION, 1) == false then
            combat:execute(cid, var)
            Player(cid):sendTextMessage(MESSAGE_INFO_DESCR, 'Kurama gave you some chakra.')
            doCreatureSay(cid, 'Kuramaaa!', TALKTYPE_ORANGE_1)
            local tempo2 = 0
            local totalTempo = tempo * 1000
            while tempo2 < totalTempo do
                if Creature(cid) then
                    addEvent(magicEffect2828, tempo2, {cid = cid})
                else
                    break
                end
                tempo2 = tempo2 + 300
            end
            Creature(cid):setStorageValue(134453, 1)
            lastCastTime[cid] = os.time()
        else
            Player(cid):sendCancelMessage("Sorry, you are transformed.")
        end
    else
        local remainingCooldown = cooldownTime - (os.time() - lastCastTime[cid])
        Player(cid):sendChannelMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Please wait " .. remainingCooldown .. " seconds to use the jutsu again.", TALKTYPE_CHANNEL_O, CHANNEL_SPELL)
    end
end
 
Last edited:
Lua:
local tempo = 45
local effect = {83}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local skillCondition = Condition(CONDITION_ATTRIBUTES)
skillCondition:setParameter(CONDITION_PARAM_TICKS, tempo * 1000)
skillCondition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 30)
skillCondition:setParameter(CONDITION_PARAM_SKILL_FIST, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_SWORD, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_AXE, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_CLUB, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_SHIELD, 30)
combat:addCondition(skillCondition)


local outfitCondition = Condition(CONDITION_OUTFIT)
outfitCondition:setOutfit({lookType = 128}) -- Set Naruto's transformation outfit ID.
outfitCondition:setTicks(tempo * 1000)
combat:addCondition(outfitCondition)

local regenCondition = Condition(CONDITION_REGENERATION)
regenCondition:setParameter(CONDITION_PARAM_SUBID, 1)
regenCondition:setParameter(CONDITION_PARAM_BUFF, true)
regenCondition:setParameter(CONDITION_PARAM_TICKS, tempo * 1000)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 1250)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(regenCondition)

local cooldownTime = 165
local lastCastTime = {}

function magicEffect2828(cid)
    local creature = Creature(cid)
    if creature then
        if creature:getStorageValue(134453) > 0 and getCreatureCondition(cid, CONDITION_REGENERATION, 1) then
            local position = creature:getPosition()
            for i = 1, #effect do
                position:sendMagicEffect(effect[i])
            end
        end
    end
end

function onCastSpell(cid, var)
    local storage = 25895

    if not lastCastTime[cid] or os.time() - lastCastTime[cid] >= cooldownTime then
        if Creature(cid):getStorageValue(134453) ~= 1 or getCreatureCondition(cid, CONDITION_REGENERATION, 1) == false then
            combat:execute(cid, var)
            Player(cid):sendTextMessage(MESSAGE_INFO_DESCR, 'Kurama gave you some chakra.')
            doCreatureSay(cid, 'Kuramaaa!', TALKTYPE_ORANGE_1)
            local tempo2 = 0
            local totalTempo = tempo * 1000
            while tempo2 < totalTempo do
                if Creature(cid) then
                    addEvent(magicEffect2828, tempo2, {cid = cid})
                else
                    break
                end
                tempo2 = tempo2 + 300
            end
            Creature(cid):setStorageValue(134453, 1)
            lastCastTime[cid] = os.time()
        else
            Player(cid):sendCancelMessage("Sorry, you are transformed.")
        end
    else
        local remainingCooldown = cooldownTime - (os.time() - lastCastTime[cid])
        Player(cid):sendChannelMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Please wait " .. remainingCooldown .. " seconds to use the jutsu again.", TALKTYPE_CHANNEL_O, CHANNEL_SPELL)
    end
end
when i use no have a Outfit and no have any effect ;x
 
Okay, I fixed the effect so that it is displayed on the player during the effect, with life regeneration and an increase of more than 30 in Magic Level and 30 in Shielding, it's ok

see the GIF 🙂


Lua:
local tempo = 45
local effect = {80}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local skillCondition = Condition(CONDITION_ATTRIBUTES)
skillCondition:setParameter(CONDITION_PARAM_TICKS, tempo * 1000)
skillCondition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 30)
skillCondition:setParameter(CONDITION_PARAM_SKILL_FIST, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_SWORD, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_AXE, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_CLUB, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_SHIELD, 30)
combat:addCondition(skillCondition)

local outfitCondition = Condition(CONDITION_OUTFIT)
outfitCondition:setOutfit({lookType = 1128})
outfitCondition:setTicks(tempo * 1000)
combat:addCondition(outfitCondition)

local regenCondition = Condition(CONDITION_REGENERATION)
regenCondition:setParameter(CONDITION_PARAM_SUBID, 1)
regenCondition:setParameter(CONDITION_PARAM_BUFF, true)
regenCondition:setParameter(CONDITION_PARAM_TICKS, tempo * 1000)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 1250)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(regenCondition)

local cooldownTime = 165
local lastCastTime = {}

local function applyMagicEffect(cid)
    local creature = Creature(cid)
    if creature then
        local position = creature:getPosition()
        for i = 1, #effect do
            position:sendMagicEffect(effect[i])
        end
    end
end

function onCastSpell(cid, var)
    local storage = 25895

    if not lastCastTime[cid] or os.time() - lastCastTime[cid] >= cooldownTime then
        if Creature(cid):getStorageValue(134453) ~= 1 or getCreatureCondition(cid, CONDITION_REGENERATION, 1) == false then
            combat:execute(cid, var)
            Player(cid):sendTextMessage(MESSAGE_INFO_DESCR, 'Kurama gave you some chakra.')
            doCreatureSay(cid, 'Kuramaaa!', TALKTYPE_ORANGE_1)

            local tempo2 = 0
            local totalTempo = tempo * 1000
            while tempo2 < totalTempo do
                if Creature(cid) then
                    local delayedTempo = tempo2
                    addEvent(function() applyMagicEffect(cid) end, delayedTempo)
                else
                    break
                end
                tempo2 = tempo2 + 300
            end

          
            local player = Player(cid)
            if player then
                player:addSkillTries(SKILL_SHIELD, 1)
            end

            Creature(cid):setStorageValue(134453, 1)
            lastCastTime[cid] = os.time()
        else
            Player(cid):sendCancelMessage("Sorry, you are transformed.")
        end
    else
        local remainingCooldown = cooldownTime - (os.time() - lastCastTime[cid])
        Player(cid):sendChannelMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Wait " .. remainingCooldown .. " seconds to use the jutsu again.", TALKTYPE_CHANNEL_O, CHANNEL_SPELL)
    end
end
 
we didn't understand each other, I have to change the position of the effect and the outfit because they don't match ;x
Dude, just change the effect number you want here.

You can still simply search for that line and change the OUTFIT ID to whatever you want.


You can understand the script easily. 🤨
 
Now I understand... I solved it here, try there, it should be solved now

Lua:
local tempo = 45
local effect = {50}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

local skillCondition = Condition(CONDITION_ATTRIBUTES)
skillCondition:setParameter(CONDITION_PARAM_TICKS, tempo * 1000)
skillCondition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 30)
skillCondition:setParameter(CONDITION_PARAM_SKILL_FIST, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_SWORD, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_AXE, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_CLUB, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 0)
skillCondition:setParameter(CONDITION_PARAM_SKILL_SHIELD, 30)
combat:addCondition(skillCondition)

local outfitCondition = Condition(CONDITION_OUTFIT)
outfitCondition:setOutfit({lookType = 1128})
outfitCondition:setTicks(tempo * 1000)
combat:addCondition(outfitCondition)

local regenCondition = Condition(CONDITION_REGENERATION)
regenCondition:setParameter(CONDITION_PARAM_SUBID, 1)
regenCondition:setParameter(CONDITION_PARAM_BUFF, true)
regenCondition:setParameter(CONDITION_PARAM_TICKS, tempo * 1000)
regenCondition:setParameter(CONDITION_PARAM_HEALTHGAIN, 1250)
regenCondition:setParameter(CONDITION_PARAM_HEALTHTICKS, 1000)
combat:addCondition(regenCondition)

local cooldownTime = 165
local lastCastTime = {}

local function applyMagicEffect(cid)
    local creature = Creature(cid)
    if creature then
        local position = creature:getPosition()
        for i = 1, #effect do
            position:sendMagicEffect(effect[i], {x = position.x, y = position.y, z = position.z + 1})
        end
    end
end

function onCastSpell(cid, var)
    local storage = 25895

    if not lastCastTime[cid] or os.time() - lastCastTime[cid] >= cooldownTime then
        if Creature(cid):getStorageValue(134453) ~= 1 or getCreatureCondition(cid, CONDITION_REGENERATION, 1) == false then
            combat:execute(cid, var)
            Player(cid):sendTextMessage(MESSAGE_INFO_DESCR, 'Kurama gave you some chakra.')
            doCreatureSay(cid, 'Kuramaaa!', TALKTYPE_ORANGE_1)

            local tempo2 = 0
            local totalTempo = tempo * 1000
            while tempo2 < totalTempo do
                if Creature(cid) then
                    local delayedTempo = tempo2
                    addEvent(function() applyMagicEffect(cid) end, delayedTempo)
                else
                    break
                end
                tempo2 = tempo2 + 300
            end

            local player = Player(cid)
            if player then
                player:addSkillTries(SKILL_SHIELD, 1)
            end

            Creature(cid):setStorageValue(134453, 1)
            lastCastTime[cid] = os.time()
        else
            Player(cid):sendCancelMessage("Sorry, you are transformed.")
        end
    else
        local remainingCooldown = cooldownTime - (os.time() - lastCastTime[cid])
        Player(cid):sendChannelMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Wait " .. remainingCooldown .. " seconds to use the jutsu again.", TALKTYPE_CHANNEL_O, CHANNEL_SPELL)
    end
end
 
look for this line:
Lua:
local function applyMagicEffect(cid)
Just replace and test
Lua:
local function applyMagicEffect(cid)
    local creature = Creature(cid)
    if creature then
        local position = creature:getPosition()
        local direction = creature:getDirection()  -- Gets the player's current direction

        -- Determines new position based on current direction
        local newPosition = {
            x = position.x,
            y = position.y,
            z = position.z
        }

        -- Change position based on current direction
        if direction == NORTH then
            newPosition.y = newPosition.y - 1
        elseif direction == EAST then
            newPosition.x = newPosition.x + 1
        elseif direction == SOUTH then
            newPosition.y = newPosition.y + 1
        elseif direction == WEST then
            newPosition.x = newPosition.x - 1
        end

        for i = 1, #effect do
            position:sendMagicEffect(effect[i], newPosition)  -- Sends the effect to the new position
        end
    end
end
 
Back
Top