• 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 Cast with direction

Tysoch86

New Member
Joined
Jan 8, 2016
Messages
81
Reaction score
1
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:
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
 
Just another question about this... The spell now casts properly, in the direction the character is facing, however, I seem to have the spell offset to a distance of 2 from the character.
So for example:

If the character(p) is facing north the spell strikes (x) away from the player by 2 spaces.


00000
0xxx0
00000
00p00

I would like to drop the distance down to just 1 square, like the old exori vis, only 3 squares in front of the player rather than just 1.



I know the spell editor is quite simple to use, but I tried to put the spell in how I desired and it didn't work out for me.
Thanks again,
-Tys
 
Back
Top