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

Solved [Help] Spells Doesn't follow me ..

hucko

Special Order
Joined
May 6, 2011
Messages
79
Reaction score
1
Yo Otlanders,

I have problem when i cast any spell .. it doesn't follow me

by the way, I'm using Spell Creator

Code:
-
-- SpellCreator generated.

-- =============== COMBAT VARS ===============
-- Areas/Combat for 0ms
local combat0_Brush_5 = createCombatObject()
setCombatParam(combat0_Brush_5, COMBAT_PARAM_EFFECT, CONST_ME_ICETORNADO)
setCombatParam(combat0_Brush_5, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)
setCombatParam(combat0_Brush_5, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatArea(combat0_Brush_5,createCombatArea({{1, 0, 1},
{0, 2, 0},
{1, 0, 1}}))
setCombatFormula(combat0_Brush_5, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, 0)

-- =============== CORE FUNCTIONS ===============
local function RunPart(c,cid,var,dirList,dirEmitPos) -- Part
   if (isCreature(cid)) then
     doCombat(cid, c, var)
     if (dirList ~= nil) then -- Emit distance effects
       local i = 2;
       while (i < #dirList) do
         doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i],y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1])
         i = i + 2
       end     
     end
   end
end

function onCastSpell(cid, var)
   local startPos = getCreaturePosition(cid)
   RunPart(combat0_Brush_5,cid,var)
   return true
end

No One have an idea for this ? ^_O
 
Last edited by a moderator:
i mean when i cast any " Custom Spell " which i created

and move to east SQM the spell still casting in west Sqm

i need it to follow me what ever i move xD

it's possible ?
 
You are only get the position when you cast the spell, you would need to get updates positions somehow.
local startPos = getCreaturePosition(cid) is only happening when you cast it, that means the position of the spell will be that one until it ends (until you cast it again).

I have no idea how to change that, never saw spells actually doing that.
 
0.3.6 ,

Is it full script ? -> yea it's full one i can give you anoter one

Code:
-- SpellCreator generated.

-- =============== COMBAT VARS ===============
-- Areas/Combat for 0ms
local combat0_Brush_6 = createCombatObject()
setCombatParam(combat0_Brush_6, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat0_Brush_6, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatArea(combat0_Brush_6,createCombatArea({{1, 1, 1},
{1, 2, 1},
{1, 1, 1}}))
setCombatFormula(combat0_Brush_6, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, 0)

-- Areas/Combat for 500ms
local combat5_Brush_6 = createCombatObject()
setCombatParam(combat5_Brush_6, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat5_Brush_6, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatArea(combat5_Brush_6,createCombatArea({{1, 1, 1},
{1, 2, 1},
{1, 1, 1}}))
setCombatFormula(combat5_Brush_6, COMBAT_FORMULA_LEVELMAGIC, 0, 0, 0, 0)

-- =============== CORE FUNCTIONS ===============
local function RunPart(c,cid,var,dirList,dirEmitPos) -- Part
   if (isCreature(cid)) then
     doCombat(cid, c, var)
     if (dirList ~= nil) then -- Emit distance effects
       local i = 2;
       while (i < #dirList) do
         doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i],y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1])
         i = i + 2
       end     
     end
   end
end

function onCastSpell(cid, var)
   local startPos = getCreaturePosition(cid)
   RunPart(combat0_Brush_6,cid,var)
   addEvent(RunPart,500,combat5_Brush_6,cid,var)
   return true
end
 
yeah. The problem here is that Var <- contains the position that the spell is triggered.
Easiest would probobally be to add selftarget="1" into the xml file. Otherwise you could construct your own "Variant".
local var = posToVariant(getCreaturePositon(cid)) the function name might not be correct, just check the luadoc for the function name otherwise.
Note that on the addEvent, the var needs to be updated everytime you add a new event.

Variant(or var) is bascially something that describes either a String, a Creature or a Position.
when using selftarget="1" in the xml file, it will send the creature, without it, the var is usually a position, often the position you casted it on, making it fixed on that exact location.
 
Back
Top