Hi everyone, I am trying to get this spell to cast in the direction my character is facing and am having some difficulty with it.
Here is the script:
And here is the .XML:
Any help would be appreciated
Thanks
-Tys
Here is the script:
Code:
-- SpellCreator generated.
-- =============== COMBAT VARS ===============
-- Areas/Combat for 100ms
local combat1_swing = createCombatObject()
setCombatParam(combat1_swing, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat1_swing, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1_swing, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat1_swing, COMBAT_PARAM_BLOCKSHIELD, true)
setCombatArea(combat1_swing,createCombatArea({{1},
{2}}))
setCombatFormula(combat1_swing, COMBAT_FORMULA_SKILL, 1, 1, 1, 1)
-- Areas/Combat for 0ms
local combat0_swing = createCombatObject()
setCombatParam(combat0_swing, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat0_swing, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat0_swing, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat0_swing, COMBAT_PARAM_BLOCKSHIELD, true)
setCombatArea(combat0_swing,createCombatArea({{0, 1},
{2, 0}}))
setCombatFormula(combat0_swing, COMBAT_FORMULA_SKILL, 1, 1, 1, 1)
-- Areas/Combat for 200ms
local combat2_swing = createCombatObject()
setCombatParam(combat2_swing, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatParam(combat2_swing, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2_swing, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat2_swing, COMBAT_PARAM_BLOCKSHIELD, true)
setCombatArea(combat2_swing,createCombatArea({{1, 0},
{0, 2}}))
setCombatFormula(combat2_swing, COMBAT_FORMULA_SKILL, 1, 1, 1, 1)
-- =============== CORE FUNCTIONS ===============
local function RunPart(c,cid,var,dirList,dirEmitPos,startDir) -- Part
if (isCreature(cid)) then
doCombat(cid, c, var)
if (dirList ~= nil) then -- Emit distance effects
local i = 2;
while (i < #dirList) do
if (startDir == 0) then -- N
doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i],y=dirEmitPos.y-dirList[i+1],z=dirEmitPos.z},dirList[1])
elseif (startDir == 2) then -- S
doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x+dirList[i],y=dirEmitPos.y+dirList[i+1],z=dirEmitPos.z},dirList[1])
elseif (startDir == 1) then -- E
doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x+dirList[i+1],y=dirEmitPos.y+dirList[i],z=dirEmitPos.z},dirList[1])
else -- W / Something weird happened
doSendDistanceShoot(dirEmitPos,{x=dirEmitPos.x-dirList[i+1],y=dirEmitPos.y-dirList[i],z=dirEmitPos.z},dirList[1])
end
i = i + 2
end
end
end
end
function onCastSpell(cid, var)
local startPos = Creature(cid):getDirection()
local startDir = Creature(cid):getDirection()
addEvent(RunPart,100,combat1_swing,cid.uid,var)
RunPart(combat0_swing,cid.uid,var)
addEvent(RunPart,200,combat2_swing,cid.uid,var)
return true
end
And here is the .XML:
Code:
<instant group="attack" spellid="178" name="Swing" words="libro" lvl="25" maglv="1" mana="0" exhaustion="1000" soul="10" prem="0" needlearn="0" casterTargetOrDirection="1" blockwalls="1" selftarget="1" aggressive="1" script="attack/Swing.lua">
<vocation id="2"/>
<vocation id="6"/>
<vocation id="7"/>
<vocation id="8"/>
<vocation id="14"/>
<vocation id="15"/>
<vocation id="16"/>
<vocation id="17"/>
<vocation id="18"/>
<vocation id="19"/>
<vocation id="20"/>
<vocation id="23"/>
</instant>
Any help would be appreciated
Thanks
-Tys