Page 2 of 2

Re: how to spawn particle effect?

Posted: Fri Feb 20, 2015 12:31 pm
by bongobeat
thanks for help, I guess it is ok now:
I have included the "if ammo1 and ammo2 then", to avoid the nil issue
SpoilerShow
{
class = "FirearmAttack",
attackPower = 500,
cooldown = 0.4,
attackSound = "laser01",
ammo = "power",
jamChance = 0,
backfireChance = 0,
range = 15,
onAttack = function(self, champion, slot, chainIndex)
----
local ammo1 = champion:getItem(1)
local ammo2 = champion:getItem(2)
if ammo1 and ammo2 then
if ammo1.go.name == "ion_gun" and ammo2.go.name == "power_recharge"
or ammo2.go.name == "ion_gun" and ammo1.go.name == "power_recharge" then
----
local ion = spawn("ion_object",party.level,party.x,party.y,party.facing,party.elevation)
ion.projectile:setIgnoreEntity(party)

-- Set cast by champion so that experience is awarded for kills.
local ord = champion:getOrdinal()
ion.projectile:setCastByChampion(true)
-- When the 2.1.19 patch is released, uncomment the next line and delete the previous line.
-- ion.projectile:setCastByChampion(ord)

-- Simulate the position of a player-cast spell.
local left = nil
for i = 1,4 do
if party.party:getChampion(i):getOrdinal() == ord then
left = i == 1 or i == 3
break
end
end
local wpos = party:getWorldPosition()
local dx = nil
local dz = nil
if party.facing == 0 then
dx = left and -0.1 or 0.1
dz = -1
elseif party.facing == 1 then
dz = left and 0.1 or -0.1
dx = -1
elseif party.facing == 2 then
dx = left and 0.1 or -0.1
dz = 1
else -- party.facing == 3
dz = left and -0.1 or 0.1
dx = 1
end

ion:setWorldPosition(vec(wpos[1]+dx,wpos[2]+1.35,wpos[3]+dz))
end
end
end
},