function onCastSpell(cid, var)
local formula = {
min = (getPlayerLevel(cid)*7.5 + getPlayerMagLevel(cid)*8.5 + 60),
max = (getPlayerLevel(cid)*8.5 + getPlayerMagLevel(cid)*9.5 + 120),
}
local pos, creatures = getThingPos(cid), {}
for x = pos.x - 7, pos.x + 7 do
for y = pos.y - 5, pos.y + 5 do
local v = getTopCreature({x=x, y=y, z=pos.z}).uid
if isPlayer(v) or isMonster(v) and v ~= cid then
if isSightClear(getThingPos(cid), getThingPos(v), false) then
table.insert(creatures, v)
end
end
end
end
if #creatures > 0 then
for _, c in ipairs(creatures) do
if isCreature(c) then
doTargetCombatHealth(cid, c, COMBAT_ENERGYDAMAGE, - formula.min, - formula.max, 101)
end
end
return true
end
doSendMagicEffect(getCreaturePosition(cid), 2)
doPlayerSendCancel(cid, 'There isn\'t monsters or players near you or any creature isn\'t sight clear.')
return false
end
better code to get creatures (instead of manually iterating the area):LUA:function onCastSpell(cid, var) local formula = { min = (getPlayerLevel(cid)*7.5 + getPlayerMagLevel(cid)*8.5 + 60), max = (getPlayerLevel(cid)*8.5 + getPlayerMagLevel(cid)*9.5 + 120), } local pos, creatures = getThingPos(cid), {} for x = pos.x - 7, pos.x + 7 do for y = pos.y - 5, pos.y + 5 do local v = getTopCreature({x=x, y=y, z=pos.z}).uid if isPlayer(v) or isMonster(v) and v ~= cid then if isSightClear(getThingPos(cid), getThingPos(v), false) then table.insert(creatures, v) end end end end if #creatures > 0 then for _, c in ipairs(creatures) do if isCreature(c) then doTargetCombatHealth(cid, c, COMBAT_ENERGYDAMAGE, - formula.min, - formula.max, 101) end end return true end doSendMagicEffect(getCreaturePosition(cid), 2) doPlayerSendCancel(cid, 'There isn\'t monsters or players near you or any creature isn\'t sight clear.') return false end
If you want the shoot effect you should add doSendDistanceEffect under doSendMagicEffect.
I made it without the distance effect.
local creatures = {}
for _, id in pairs(getSpectators(getCreaturePosition(cid), 7, 5, false) or {}) do
if id ~= cid then
creatures[#creatures+ 1] = id
end
end
LUA:function onCastSpell(cid, var) local formula = { min = (getPlayerLevel(cid)*7.5 + getPlayerMagLevel(cid)*8.5 + 60), max = (getPlayerLevel(cid)*8.5 + getPlayerMagLevel(cid)*9.5 + 120), } local pos, creatures = getThingPos(cid), {} for x = pos.x - 7, pos.x + 7 do for y = pos.y - 5, pos.y + 5 do local v = getTopCreature({x=x, y=y, z=pos.z}).uid if isPlayer(v) or isMonster(v) and v ~= cid then if isSightClear(getThingPos(cid), getThingPos(v), false) then table.insert(creatures, v) end end end end if #creatures > 0 then for _, c in ipairs(creatures) do if isCreature(c) then doTargetCombatHealth(cid, c, COMBAT_ENERGYDAMAGE, - formula.min, - formula.max, 101) end end return true end doSendMagicEffect(getCreaturePosition(cid), 2) doPlayerSendCancel(cid, 'There isn\'t monsters or players near you or any creature isn\'t sight clear.') return false end
If you want the shoot effect you should add doSendDistanceEffect under doSendMagicEffect.
I made it without the distance effect.
function onCastSpell(cid, var)
local formula = {
min = (getPlayerLevel(cid)*7.5 + getPlayerMagLevel(cid)*8.5 + 60),
max = (getPlayerLevel(cid)*8.5 + getPlayerMagLevel(cid)*9.5 + 120),
}
local pos, creatures = getThingPos(cid), {}
for x = pos.x - 7, pos.x + 7 do
for y = pos.y - 5, pos.y + 5 do
local v = getTopCreature({x=x, y=y, z=pos.z}).uid
if isPlayer(v) or isMonster(v) and v ~= cid then
if isSightClear(getThingPos(cid), getThingPos(v), false) then
table.insert(creatures, v)
end
end
end
end
if #creatures > 0 then
for _, c in ipairs(creatures) do
if isCreature(c) then
doTargetCombatHealth(cid, c, COMBAT_PHYSICALDAMAGE, - formula.min, - formula.max, 101)
end
end
return true
end
doSendMagicEffect(getCreaturePosition(cid), 3)
doSendDistanceEffect(getCreaturePosition(cid), 3)
doPlayerSendCancel(cid, 'There isn\'t monsters or players near you or any creature isn\'t sight clear.')
return false
end
How can i use this to send distance effect to all targeted creatures? tried creatures:getPosition() but didnt work...Code:doSendDistanceShoot(frompos, topos, type[, player])