Hello
I know there are few bugs and maybe it could be done in spell script, but I was experimenting and made it in talkaction.
Ok thats the script just make a word in talkactions.xml to trigger the script.
About the config:
interval is the time between the spell jumps in millisecs,exhaused should be clear,times is how often it jumps formula you can either select a min,max formula or base damage,storage is the storage where exhaused is save (must be unused),lvl,mlvl,manacost you should know what to do there,lockmove = wheather the player may move or not (1 or 0) while the spell is running,multicast is how often the spell should be casted if it is multicast,multichance is the chance for multicast,movetype = 0 means the spell move diagonal and = 1 means only straight,effect is the effects shown on the tile,distance is if a distance effect should be sent,disteffect is the distance effects shown only is distance is 1,damagetype = 2 is the damagetype. 2 means energy and 8 for example fire.
The spell starts at the position you stand and then randomly moves either straigh or diagonal and straigt to other tiles. The spell always jumps to a near tile. You can't use in PZ and it won't jump in PZ or in not walkable things.
REMEMBER IT'S ONLY TO PLAY AROUND AND SHOULD BE USED IN SERIOUS OTs
Known bugs:
-laggs hard if the player logs while spell is cast (maybe fixed)
-can cause lagg if you set to low interval or to high multicast or to high times.
I know there are few bugs and maybe it could be done in spell script, but I was experimenting and made it in talkaction.
Code:
function onSay(cid, words, param, channel)
local lvl,mlvl = getPlayerLevel(cid),getPlayerMagLevel(cid)
local config = {
interval = 500,
exhaused = 0,
times = 30,
formula = {["min"] = (lvl * 1 + 1 * mlvl + 10),["max"] = (lvl * 1 + 1.2 * mlvl + 50)},
storage = 6666,
lvl = 0,
mlvl = 0,
manacost = 0,
lockmove = 0,
multicast = 100,
multichance = 100,
movetype = 0,
effect = {37,48},
distance = 0,
disteffect = {4,35,7},
damagetype = 2
}
local c = config
if lvl < c.lvl then
doSendMagicEffect(getPlayerPosition(cid),2)
doPlayerSendCancel(cid,"You do not have enough level to use this spell.")
return false
end
if mlvl < c.mlvl then
doSendMagicEffect(getPlayerPosition(cid),2)
doPlayerSendCancel(cid,"Your magic level is too low.")
return false
end
if getPlayerMana(cid) < c.manacost then
doSendMagicEffect(getPlayerPosition(cid),2)
doPlayerSendCancel(cid,"You do not have enough mana.")
return false
end
local storage = getPlayerStorageValue(cid,c.storage)
if storage >= os.time() and storage >= 1 then
doSendMagicEffect(getPlayerPosition(cid),2)
doPlayerSendCancel(cid,"You are exhaused.")
return false
end
local pos = getPlayerPosition(cid)
if getTilePzInfo(pos) then
doSendMagicEffect(getPlayerPosition(cid),2)
doPlayerSendCancel(cid,"You cannot use this spell while you are in a protection zone.")
return false
end
doCreatureSetNoMove(cid,c.lockmove)
function getRandomPosition(pos,move)
local new = 0
if move == 0 then
new = {[1] = {x=pos.x+1,y=pos.y,z=pos.z,stackpos=0},[2] = {x=pos.x-1,y=pos.y,z=pos.z,stackpos=0},[3] = {x=pos.x,y=pos.y-1,z=pos.z,stackpos=0},[4] = {x=pos.x,y=pos.y+1,z=pos.z,stackpos=0},[5] = {x=pos.x+1,y=pos.y+1,z=pos.z,stackpos=0},[6] = {x=pos.x-1,y=pos.y+1,z=pos.z,stackpos=0},[7] = {x=pos.x+1,y=pos.y-1,z=pos.z,stackpos=0},[8] = {x=pos.x-1,y=pos.y-1,z=pos.z,stackpos=0}}
else
new = {[1] = {x=pos.x+1,y=pos.y,z=pos.z,stackpos=0},[2] = {x=pos.x-1,y=pos.y,z=pos.z,stackpos=0},[3] = {x=pos.x,y=pos.y-1,z=pos.z,stackpos=0},[4] = {x=pos.x,y=pos.y+1,z=pos.z,stackpos=0}}
end
local tab = {}
for i = 1,#new do
if getTileThingByPos(new[i]).uid > 0 then
if getTilePzInfo(new[i]) == FALSE and hasProperty(getThingFromPos(new[i]).uid,CONST_PROP_BLOCKINGANDNOTMOVEABLE) == FALSE then
tab[(#tab+1)] = new[i]
end
end
end
local rand = 0
if tab[1] then
rand = math.random(1,#tab)
end
if tab[rand] then
return tab[rand]
else
return false
end
end
local function doDamage(cid, type, pos, min, max, effect,times,interval,mover,dist,deffect)
times = times-1
for i = 2, #effect do
doSendMagicEffect(pos,effect[i])
end
if dist > 0 then
for i = 1,#deffect do
doSendDistanceShoot(getPlayerPosition(cid), pos, deffect[i])
end
end
doAreaCombatHealth(cid, type, pos, 0, min, max, effect[1])
if times >= 0 and getRandomPosition(pos,mover) ~= false and isPlayer(cid) == true then
addEvent(doDamage,interval,cid,type,getRandomPosition(pos,mover),min,max,effect,times,interval,mover,dist,deffect)
end
end
c.times = c.times-1
local chance = math.random(1,100)
if c.multichance >= chance and c.multicast > 1 then
for i = 1,c.multicast do
doDamage(cid, c.damagetype, pos, -c.formula["min"], -c.formula["max"], c.effect,c.times,c.interval,c.movetype,c.distance,c.disteffect)
end
else
doDamage(cid, c.damagetype, pos, -c.formula["min"], -c.formula["max"], c.effect,c.times,c.interval,c.movetype,c.distance,c.disteffect)
end
setPlayerStorageValue(cid,c.storage,(os.time()+c.exhaused))
addEvent(doCreatureSetNoMove, (c.interval*c.times), cid, 0)
doPlayerAddSpentMana(cid,c.manacost)
doPlayerAddMana(cid,-c.manacost)
return true and doCreatureSay(cid,words,1)
end
Ok thats the script just make a word in talkactions.xml to trigger the script.
About the config:
interval is the time between the spell jumps in millisecs,exhaused should be clear,times is how often it jumps formula you can either select a min,max formula or base damage,storage is the storage where exhaused is save (must be unused),lvl,mlvl,manacost you should know what to do there,lockmove = wheather the player may move or not (1 or 0) while the spell is running,multicast is how often the spell should be casted if it is multicast,multichance is the chance for multicast,movetype = 0 means the spell move diagonal and = 1 means only straight,effect is the effects shown on the tile,distance is if a distance effect should be sent,disteffect is the distance effects shown only is distance is 1,damagetype = 2 is the damagetype. 2 means energy and 8 for example fire.
The spell starts at the position you stand and then randomly moves either straigh or diagonal and straigt to other tiles. The spell always jumps to a near tile. You can't use in PZ and it won't jump in PZ or in not walkable things.
REMEMBER IT'S ONLY TO PLAY AROUND AND SHOULD BE USED IN SERIOUS OTs
Known bugs:
-laggs hard if the player logs while spell is cast (maybe fixed)
-can cause lagg if you set to low interval or to high multicast or to high times.
Last edited: