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

Rescript of Spells

Jordan_August

New Member
Joined
Jul 24, 2012
Messages
122
Reaction score
4
I was curious if anyone could help me revamp these couple spells so they are compatible with 0.3.6. I'm pretty sure they are scripted for 1.0+ and id like to have a "ninja" voc on my 8.60. Just need a little help in doing so. They are originally located Spell - Ninja Vocation Spells if you would like to see how the spell is executed.

Lua:
local function targetEffect(cid)
    local player = Player(cid)
    if not player then
        return
    end
    local effect =  CONST_ANI_REDSTAR
    local orig = player:getPosition()
    local d1, d2 = {z = orig.z}, {z = orig.z}
    d1.x = orig.x - 5
    d2.x = orig.x + 5
    for i = -2, 2 do
        d1.y = orig.y + i
        d2.y = d1.y
        orig:sendDistanceEffect(d1, effect)
        orig:sendDistanceEffect(d2, effect)
    end
    d1.y = orig.y - 3
    d2.y = orig.y + 3
    for i = -4, 4 do
        d1.x = orig.x + i
        d2.x = d1.x
        orig:sendDistanceEffect(d1, effect)
        orig:sendDistanceEffect(d2, effect)
    end
end
local function backOldPosition(cid, oldPosition)
    local player = Player(cid)
    if not player then
        return
    end
 
    player:teleportTo(oldPosition)
    player:setGhostMode(false)
end
local function jumpEffect(cid, target)
    local player = Player(cid)
    if not player then
        return
    end
    local target = Creature(target)
    if target then
        player:getPosition():sendDistanceEffect(target:getPosition(), CONST_ANI_EXPLOSION)
    end
end
local function jumpOnTarget(cid, target, targetCount, oldPosition)
    local player = Player(cid)
    if not player then
        return
    end
    local target = Creature(target)
    if target then
        addEvent(targetEffect, 100, cid)
        player:teleportTo(target:getPosition())
        player:setGhostMode(true)
        doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -1, -100, CONST_ME_ASSASSIN)
        if targetCount == 0 then
            addEvent(backOldPosition, 400, cid, oldPosition)
        end
    end
end
local function extractRandomValuesFromTable(tbl) --By Printer(This will make sure not to select a value twice from the table)
    if #tbl == 0 then
        return false
    end
          return table.remove(tbl, math.random(#tbl))
end
function onCastSpell(creature, var)
    local targets = {}
    local playerPos = creature:getPosition()
    local spectators = Game.getSpectators(playerPos, false, false, 0, 10, 0, 10)
    for i = 1, #spectators do
        local specs = spectators[i]
        if specs ~= creature and not specs:isNpc() then
            targets[#targets+1] = specs
        end
    end
    if #targets == 0 then
        creature:sendCancelMessage('There is no targets in sight.')
        playerPos:sendMagicEffect(CONST_ME_POFF)
        return false
    end
    local targetCount = #targets
    for i = 1, #targets do
        local randTarget = extractRandomValuesFromTable(targets)
        addEvent(jumpOnTarget, i * 400, creature:getId(), randTarget:getId(), targetCount - i, playerPos)
        addEvent(jumpEffect, i * 300, creature:getId(), randTarget:getId())
    end
    return false
end

Lua:
local function sendDistanceEffectDelay(cid, fromPos, toPos, effect)
    local player = Player(cid)
    if not player then
        return
    end
    fromPos:sendDistanceEffect(toPos, effect)
end
local function ninjaJumpDash(cid, target, oldPos, lastJump, back)
    local player = Player(cid)
    if not player then
        return
    end
    local target = Creature(target)
    if not target then
        player:setGhostMode(false)
        return
    end
 
    if lastJump then
        player:setGhostMode(false)
    end
    if back then
        player:teleportTo(oldPos)
    else
        player:teleportTo(target:getPosition())
    end
    doTargetCombatHealth(cid, target, COMBAT_PHYSICALDAMAGE, -1, -100, CONST_ME_THUNDER)
end
function onCastSpell(creature, var)
    local cid = creature:getId()
    local playerPos = creature:getPosition()
    creature:setGhostMode(true)
    addEvent(ninjaJumpDash, 0, cid, target:getId(), playerPos, false, false)
    addEvent(sendDistanceEffectDelay, 100, cid, playerPos, target:getPosition(), CONST_ANI_ENERGY)
    addEvent(sendDistanceEffectDelay, 300, cid, target:getPosition(), playerPos, CONST_ANI_ENERGY)
    addEvent(ninjaJumpDash, 400, cid, target:getId(), playerPos, false, true)
    addEvent(ninjaJumpDash, 600, cid, target:getId(), playerPos, false, false)
    addEvent(sendDistanceEffectDelay, 700, cid, playerPos, target:getPosition(), CONST_ANI_ENERGY)
    addEvent(sendDistanceEffectDelay, 1000, cid, target:getPosition(), playerPos, CONST_ANI_ENERGY)
    addEvent(ninjaJumpDash, 1100, cid, target:getId(), playerPos, false, true)
    addEvent(ninjaJumpDash, 1300, cid, target:getId(), playerPos, false, false)
    addEvent(sendDistanceEffectDelay, 1400, cid, playerPos, target:getPosition(), CONST_ANI_ENERGY)
    addEvent(sendDistanceEffectDelay, 1700, cid, target:getPosition(), playerPos, CONST_ANI_ENERGY)
    addEvent(ninjaJumpDash, 1800, cid, target:getId(), playerPos, true, true)
    return false
end
 
Last edited:
Back
Top