oserc
Advanced OT User
Hey boys and girls, all good?
I'm trying to create a custom spell for my server, it's a simple "arrow shower" (it shoots 2 bonus arrows on 2 different creatures that are near the main target, 1 sqm away max).
The script is written as follows:
Problem is: if I get in range of 1 sqm from the target, my char will get included in the table, even if I specifically have written not to do so ("v ~= cid then"). What I am doing wrong? Searched all forum for an answer and couldn't find any issue regarging this situation.
Plus, i would like to necessarily include the "main" target in table. If I use a spell on a mob with +3 creatures, sometimes the main target won't get hitted.
Any help?
BTW, I'm using TFS 1.4.1 (10.98), with Otclient Redemption 1.0.
I'm trying to create a custom spell for my server, it's a simple "arrow shower" (it shoots 2 bonus arrows on 2 different creatures that are near the main target, 1 sqm away max).
The script is written as follows:
Lua:
function onCastSpell(cid, var)
local formula = {
min = 10,
max = 15,
}
local player = Player(cid)
local playerpos = player:getPosition()
local target = player:getTarget()
local targetpos = target:getPosition()
local targets = {}
local x = 1
for x = targetpos.x - 1, targetpos.x + 1 do
for y = targetpos.y - 1, targetpos.y + 1 do
local v = getTopCreature({x=x, y=y, z=targetpos.z}).uid
if isPlayer(v) or isMonster(v) and v ~= cid then
table.insert(targets, v)
end
end
end
for i = 1, #targets do
if x <= 3 then
doTargetCombatHealth(cid, targets[i], COMBAT_PHYSICALDAMAGE, - formula.min, - formula.max, CONST_ME_HITAREA)
playerpos:sendDistanceEffect(getThingPos(targets[i]), CONST_ANI_ARROW)
x = x+1
end
end
end
Problem is: if I get in range of 1 sqm from the target, my char will get included in the table, even if I specifically have written not to do so ("v ~= cid then"). What I am doing wrong? Searched all forum for an answer and couldn't find any issue regarging this situation.
Plus, i would like to necessarily include the "main" target in table. If I use a spell on a mob with +3 creatures, sometimes the main target won't get hitted.
Any help?
BTW, I'm using TFS 1.4.1 (10.98), with Otclient Redemption 1.0.
Last edited: