Nowix93
New Member
- Joined
- Feb 25, 2017
- Messages
- 32
- Reaction score
- 0
TFS:1.3
Hello Everyone I would like if possible that someone help me with part of spell.
i want to create something to compare tabel from Game.getSpectators() to combat area.
I wrote somthing like this below i tried getPositions() too but effect the same
consol
part with contition stun(what i want compare)
all spell code
How can i do it?what i doing wrong? pls some tips
Hello Everyone I would like if possible that someone help me with part of spell.
i want to create something to compare tabel from Game.getSpectators() to combat area.
I wrote somthing like this below i tried getPositions() too but effect the same
consol
Code:
attempt to call method 'getPosition' (a nil value)
Lua:
function stuns(p)
local playerPos = p.player:getPosition()
local getTargets = Game.getSpectators(playerPos, false, false, 1, 1, 1, 1)
for j = 1, #getTargets do
target = getTargets[j]
local targetPos = target:getPosition()
for k, _ in ipairs(area) do
areas = area[k]
local areasPos = areas:getPosition()
if targetPos == areasPos then
if target.uid ~= p.player.uid then
if not targetPos:isNpc() then
if targetPos:isPlayer() then
print('nice')
end
end
end
end
end
end
end
Lua:
-- Delay between animations.
local animationDelay = 200
local stunDuration = 2000
local invANDcastDuration = 400
local combat = {}
-- cast
local cast = Condition(CONDITION_CAST)
cast:setParameter(CONDITION_PARAM_TICKS, invANDcastDuration)
cast:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_NONE)
-- invisible
local invisible = Condition(CONDITION_INVISIBLE)
invisible:setParameter(CONDITION_PARAM_TICKS, invANDcastDuration)
invisible:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
invisible:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
-- bleeding
local bleeding = Condition(CONDITION_BLEEDING)
bleeding:setParameter(CONDITION_PARAM_DELAYED, 10)
bleeding:addDamage(5, 1000, -50)
-- stun
local stun = Condition(CONDITION_STUN)
stun:setParameter(CONDITION_PARAM_TICKS, stunDuration)
stun:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BUBBLES)
-- Frames (1 = Area, 2 = Player, 3 = Player + Self Damaging)
local area = {
{
{0, 0, 0},
{0, 2, 0},
{0, 0, 0}
},
{
{0, 0, 0},
{0, 3, 0},
{0, 0, 0}
}
}
for i = 1, #area do
combat[i] = Combat()
combat[i]:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat[i]:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
end
function bleedmath(p)
math.randomseed(os.time())
local bleed = math.random(100)
--print(bleed)
if bleed < 30 then
p.combat[i]:addCondition(bleeding)
end
end
for x, _ in ipairs(area) do
combat[x]:setArea(createCombatArea(area[x]))
end
-- if Player then /2
function stuns(p)
local playerPos = p.player:getPosition()
local getTargets = Game.getSpectators(playerPos, false, false, 1, 1, 1, 1)
for j = 1, #getTargets do
target = getTargets[j]
local targetPos = target:getPosition()
for k, _ in ipairs(area) do
areas = area[k]
local areasPos = areas:getPosition()
if targetPos == areasPos then
if target.uid ~= p.player.uid then
if not targetPos:isNpc() then
if targetPos:isPlayer() then
print('nice')
end
end
end
end
end
end
end
--[[for _,target in pairs(getTargets) do
if target.uid ~= p.player.uid then
local targetPos = target:getPosition()
if targetPos == p.combat
local targetid = target:getId()
if not targetPos:isNpc() then
if targetPos:isPlayer() then
stunDuration = 10000
targetPos:addCondition(stun)
print(stunDuration, '1')
else
targetPos:addCondition(stun)
end
print(stunDuration, '2')
end
end
end
end]]
function executeCombat(p, i)
if not p.player then
return false
end
if not p.player:isPlayer() then
return false
end
p.combat[i]:execute(p.player, p.var)
end
function onCastSpell(player, var)
local p = {player = player, var = var, combat = combat}
-- Damage formula
local level = player:getLevel()
local maglevel = player:getMagicLevel()
local min = (level / 5) + (maglevel * 1.4) + 8
local max = (level / 5) + (maglevel * 2.2) + 14
doAddCondition(p.player, invisible)
doAddCondition(p.player, cast)
stuns(p)
print(stunDuration, '3')
--bleedmath(p)
for i = 1, #area do
combat[i]:setFormula(COMBAT_FORMULA_LEVELMAGIC, 0, -min, 0, -max)
if i == 1 then
combat[i]:execute(player, var)
else
addEvent(executeCombat, (animationDelay * i) - animationDelay, p, i)
end
end
stunDuration = 2000
return true
end
Last edited: