shivaria
Active Member
- Joined
- Sep 2, 2009
- Messages
- 158
- Reaction score
- 36
can anyone help me with this? possibly converting to tfs 1.1 (10.77)
These are showing errors returning a nil value.
targetList = getSpectators(getCreaturePosition(target), 3, 3, false)
targets[1] = getNextTarget(p.target)
These are showing errors returning a nil value.
targetList = getSpectators(getCreaturePosition(target), 3, 3, false)
targets[1] = getNextTarget(p.target)
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -1, -1, -10)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 12)
local targetList = {}
local targets = {}
local time_ = 300
local effect = {}
function secondShot(target1, target2, p)
local var = positionToVariant(target2)
doSendDistanceShoot(target1, target2, 33)
doCombat(p.cid, combat, var)
end
function getNextTarget(target)
[COLOR=#ff0000]targetList = getSpectators(getCreaturePosition(target), 3, 3, false)[/COLOR]
return targetList[math.random(1, #targetList)]
end
function doBolt(p)
if p.check ~= nil then
doSendDistanceShoot(p.pos, p.targetPos, 33)
local list = getSpectators(p.targetPos, 3, 3, false)
[COLOR=#ff0000] targets[1] = getNextTarget(p.target)[/COLOR]
if next(list) then
for i = 1, #list do
targets[i+1] = getNextTarget(targets[i])
addEvent(secondShot, time_ * i, getCreaturePosition(targets[i]), getCreaturePosition(targets[i+1]), p)
end
end
else
p.check = 2
if p.targetDir % 2 == 0 then -- 0 / 2 = 0, 2 / 2 = 0
effect[1] = {x = p.pos.x -1, y = p.pos.y, z = p.pos.z} -- nwpos
effect[2] = {x = p.pos.x +1, y = p.pos.y, z = p.pos.z} -- nepos
else
effect[1] = {x = p.pos.x, y = p.pos.y +1, z = p.pos.z} -- wnpos
effect[2] = {x = p.pos.x, y = p.pos.y -1, z = p.pos.z} -- wspos
end
doSendDistanceShoot(p.pos, effect[1], 33)
doSendDistanceShoot(p.pos, effect[2], 33)
addEvent(doBolt, 100, p)
addEvent(doBolt, 100, p)
end
return true
end
function onCastSpell(cid, var)
local p = {}
local player = Player(cid)
p = {
cid = cid,
target = player:getTarget(),
targetPos = player:getTarget():getPosition(),
targetDir = player:getTarget():getDirection(),
pos = player:getPosition()
}
doBolt(p)
return true
end
[/code/>