I recently started learning LUA and I've got some problems with a boss that I'm trying to make.
The code looks like this at the moment
Code:
--[[
Jahim boss fight (test)
]]
local NPC_ID = 100007
function NPC_OnCombat(Unit, Event)
Unit:RegisterEvent("Jahim_Trash", 3500, 0)
Unit:RegisterEvent("Jahim_FireNova", 10000, 0)
Unit:RegisterEvent("Imp_Spawn", 30000, 0)
end
function NPC_OnLeaveCombat(Unit, Event)
Unit:RemoveEvents()
end
function NPC_OnDeath(Unit, Event)
Unit:RemoveEvents()
end
function Jahim_Trash(Unit, Event)
Unit:CastSpellOnTarget(11976, Unit:GetMainTank())
end
function Jahim_FireNova(Unit, Event)
Unit:FullCastSpellOnTarget(30941, Unit:GetRandomPlayer(0))
if (Unit:GetRandomPlayer(0) ~= nil) then
Unit:FullCastSpellOnTarget(30941, Unit:GetRandomPlayer(0))
end
end
function Imp_Spawn(NPCID, x, y, z, o, faction, duration)
Unit:SpawnCreature(100008, -1119, 1741, 89, 4, 14, 0)
end
RegisterUnitEvent(NPC_ID, 1, NPC_OnCombat)
RegisterUnitEvent(NPC_ID, 2, NPC_OnLeaveCombat)
RegisterUnitEvent(NPC_ID, 4, NPC_OnDeath)
There are two main problems. First off all the Firenova spell is really buggy. Sometimes it dosen't do anything for the whole fight. Sometimes it uses it once or twice and then never again, and it always uses it double (I get hit twice instantly when I'm only suppost to get hit once). The second problem is that the Imp dosen't spawn.
When I spawn the Imp manually it dosen't do anything but auto-attack.
This is the code for the Imp.
Code:
--[[ Imp Script for Jahim Boss fight
]]
local NPC_ID = 100008
function NPC_OnCombat(Unit, Event)
Unit:RegisterEvent("Imp_FireBall", 3000, 0)
end
function NPC_OnDeath(Unit,Event)
Unit:RemoveEvents()
end
function NPC_OnLeaveCombat(Unit, Event)
Unit:Despawn(10, 0)
Unit:RemoveEvents()
end
function Imp_FireBall (Unit, Event)
Unit:CastSpellOnTarget(33793, Unit:GetRandomPlayer(0))
if (Unit:GetRandomPlayer(0) ~= nil) then
Unit:CastSpellOnTarget(33793, Unit:GetRandomPlayer(0))
end
RegisterUnitGossipEvent(NPC_ID, 4, NPC_OnDeath)
RegisterUnitGossipEvent(NPC_ID, 2, NPC_OnLeaveCombat)
RegisterUnitGossipEvent(NPC_ID, 1, NPC_OnCombat)
How can I fix these problems?