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
death_strike.lua
Got that error on console each time i cast the spell:
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: