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

TFS 1.X+ Spell collision system

Decodde

New Member
Joined
Oct 8, 2018
Messages
31
Reaction score
0
Trying update the spell collision system made by ramza, to work with tfs 1.3


spells.lua
Code:
function checkColision(cid)   -- Function by Ramza (Ricardo Ianelli)
  if getCreatureTarget(cid) ~= 0 then
     setPlayerStorageValue(cid, 9001, 'casting')
   

     local ppos, enemy = getCreaturePosition(cid), getCreatureTarget(cid)
     local epos = getCreaturePosition(enemy)
    

     if getPlayerStorageValue(enemy, 9001) == 'casting' and getCreatureTarget(enemy) == cid then
        setPlayerStorageValue(enemy, 9001, 'colision')
        setPlayerStorageValue(cid, 9001, 'colision')
        if ppos.x > epos.x and ppos.y > epos.y then
           cpos = {x = ppos.x - ((ppos.x - epos.x) / 2), y = ppos.y - ((ppos.y - epos.y) / 2), z = ppos.z}
        elseif ppos.x > epos.x and ppos.y < epos.y then
           cpos = {x = ppos.x - ((ppos.x - epos.x) / 2), y = epos.y - ((epos.y - ppos.y) / 2), z = ppos.z}
        elseif ppos.x < epos.x and ppos.y < epos.y then
           cpos = {x = epos.x - ((epos.x - ppos.x) / 2), y = epos.y - ((epos.y - ppos.y) / 2), z = ppos.z}
        elseif ppos.x < epos.x and ppos.y > epos.y then
           cpos = {x = epos.x - ((epos.x - ppos.x) / 2), y = ppos.y - ((ppos.y - epos.y) / 2), z = ppos.z}
        end
     
        doSendDistanceShoot(ppos, cpos, CONST_ANI_ENERGY)
        doSendDistanceShoot(epos, cpos, CONST_ANI_ENERGYBALL)
       
        local value = math.random(1, 3)
        doSendMagicEffect(cpos, 27+value)             
        return true
     else
        return false
     end
  end

end


death_strike.lua
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)


local function spell(cid, var)
  if getPlayerStorageValue(cid, 9001) ~= 'colision' then
     doCreatureSay(cid, 'Strike!', TALKTYPE_ORANGE_1)
     setPlayerStorageValue(cid, 9001, nil)
     return doCombat(cid, combat, var)
  end
end


function onCastSpell(cid, var)
    checkColision(cid)
    doCreatureSay(cid, 'Energy...', TALKTYPE_ORANGE_1)
    addEvent(spell, 2000, cid, var)
end


Got that error on console each time i cast the spell:
wt.png
 
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)


local function spell(cid, var)
    if Player(cid) then
        if getPlayerStorageValue(cid, 9001) ~= 'colision' then
            doCreatureSay(cid, 'Strike!', TALKTYPE_ORANGE_1)
            setPlayerStorageValue(cid, 9001, nil)
            return doCombat(cid, combat, var)
        end
    end
end


function onCastSpell(cid, var)
    checkColision(cid)
    doCreatureSay(cid, 'Energy...', TALKTYPE_ORANGE_1)
    addEvent(spell, 2000, Player(cid):getId(), var)
end
 
Last edited:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)


local function spell(cid, var)
    if Player(cid) then
        if getPlayerStorageValue(cid, 9001) ~= 'colision' then
            doCreatureSay(cid, 'Strike!', TALKTYPE_ORANGE_1)
            setPlayerStorageValue(cid, 9001, nil)
            return doCombat(cid, combat, var)
        end
    end
end


function onCastSpell(cid, var)
    checkColision(cid)
    doCreatureSay(cid, 'Energy...', TALKTYPE_ORANGE_1)
    addEvent(spell, 2000, Player(cid):getId(), var)
end

Storages in TFS 1.3 does not work with strings anymore.
 
Code:
local casting = 1
local colision = 2

function checkColision(cid)   -- Function by Ramza (Ricardo Ianelli)
  if getCreatureTarget(cid) ~= 0 then
     setPlayerStorageValue(cid, 9001, casting)
   

     local ppos, enemy = getCreaturePosition(cid), getCreatureTarget(cid)
     local epos = getCreaturePosition(enemy)
   

     if getPlayerStorageValue(enemy, 9001) == casting and getCreatureTarget(enemy) == cid then
        setPlayerStorageValue(enemy, 9001, colision)
        setPlayerStorageValue(cid, 9001, colision)
        if ppos.x > epos.x and ppos.y > epos.y then
           cpos = {x = ppos.x - ((ppos.x - epos.x) / 2), y = ppos.y - ((ppos.y - epos.y) / 2), z = ppos.z}
        elseif ppos.x > epos.x and ppos.y < epos.y then
           cpos = {x = ppos.x - ((ppos.x - epos.x) / 2), y = epos.y - ((epos.y - ppos.y) / 2), z = ppos.z}
        elseif ppos.x < epos.x and ppos.y < epos.y then
           cpos = {x = epos.x - ((epos.x - ppos.x) / 2), y = epos.y - ((epos.y - ppos.y) / 2), z = ppos.z}
        elseif ppos.x < epos.x and ppos.y > epos.y then
           cpos = {x = epos.x - ((epos.x - ppos.x) / 2), y = ppos.y - ((ppos.y - epos.y) / 2), z = ppos.z}
        end
     
        doSendDistanceShoot(ppos, cpos, CONST_ANI_ENERGY)
        doSendDistanceShoot(epos, cpos, CONST_ANI_ENERGYBALL)
       
        local value = math.random(1, 3)
        doSendMagicEffect(cpos, 27+value)           
        return true
     else
        return false
     end
  end

end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)


local function spell(cid, var)
  if getPlayerStorageValue(cid, 9001) ~= 2 then
     doCreatureSay(cid, 'Strike!', TALKTYPE_ORANGE_1)
     setPlayerStorageValue(cid, 9001, 0)
     return doCombat(cid, combat, var)
  end
end


function onCastSpell(cid, var)
    checkColision(cid)
    doCreatureSay(cid, 'Energy...', TALKTYPE_ORANGE_1)
    addEvent(spell, 2000, cid.uid, var)
end
 
@Bogart hey bro thank ya for the help but still not working, i changed to the code you post

energy_strike.lua
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
combat:setFormula(COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
local function spell(cid, var)
  if getPlayerStorageValue(cid, 9001) ~= 2 then
     doCreatureSay(cid, 'Strike!', TALKTYPE_ORANGE_1)
     setPlayerStorageValue(cid, 9001, 0)
     return doCombat(cid, combat, var)
  end
end
function onCastSpell(cid, var)
    checkColision(cid)
    doCreatureSay(cid, 'Energy...', TALKTYPE_ORANGE_1)
    addEvent(spell, 2000, cid.uid, var)
end

spells.lua
 

Attachments

Last edited:
Back
Top