First of all, hi! XD
I need some help with my little boss encounter script here. I'll post the code then explain what I wanted to do and what doesn't work :\
Code:
function OnSpawn(pUnit, Event)
pUnit:SendChatMessage(12,0,"I'm alive!")
pUnit:SpawnCreature(13442, 233.11, -344.07, 42.48, 5.28, 1216, 0)
end
function OnAttack(pUnit, Event)
pUnit:SendChatMessage(12,0,"Die!")
end
function OnDeath(pUnit, Event)
pUnit:SendChatMessage(12,0,"Ohno! I'm dead")
pUnitespawn(1,0)
pUnit:RemoveEvents()
pUnit:SpawnCreature(11947, 201.98, -358.67, 56.38, 5.55, 1214, 0)
end
RegisterUnitEvent(11949, 1, "OnAttack")
RegisterUnitEvent(11949, 4, "OnDeath")
RegisterUnitEvent(11949, 18, "OnSpawn")
The main idea is that when I spawn the boss, it says "I'm alive!" and it spawns one add (remember, this on spawn). So far so good.
Then when someone attacks the boss, it says "Die!". (nothing special, this works)
Now.. The problem occurs when the boss dies:
It despawns itself -> pUnitespawn(1,0) - works
It should remove the events (it should despawn the add which was spawned at the start) -> pUnit:RemoveEvents() - doesn't work
It spawns a secondary boss -> pUnit:SpawnCreature(bla bla) - works
So I have no idea why doesn't the add despawn when the boss dies...
The emulator world.exe shows no error.
Any idea what to do in order to despawn the add?
Thanks in advance :\