Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TrashMobs = {FrostGiant={}}; -- Don't pollute global namespace
- local L = TrashMobs; -- indexed global variables are cheaper than non-indexed ones.
- -- Mob;
- -- Casts Mortal Strike (43441) on Main Target - every 8 sec
- -- Charges (56104) a random target - 15 sec
- function L.FrostGiant.OnCombat(pUnit)
- L.FrostGiant[pUnit:GetGUID()] = { m_lastTarget = nil; };
- pUnit:RegisterEvent(
- function(pUnit)
- if pUnit ~= nil and pUnit:GetMainTank() ~= nil then
- pUnit:CastSpellOnTarget( pUnit:GetMainTank(), 43441 );
- end
- end, 8000, 0
- );
- pUnit:RegisterEvent(
- function(pUnit)
- -- the following REALLY isn't necessary unlses you absolutely positively do not want it to cast on the previous target.
- local i= 0;
- local t = pUnit:GetRandomPlayer(7);
- while t:GetName() == L.FrostGiant[pUnit:GetGUID()].m_lastTarget do
- t = pUnit:GetRandomPlayer(7);
- i = i +1;
- if i > 3 then -- if 3 iterations and no new player, break and cast on mt
- t = pUnit:GetMainTank();
- break;
- end
- end
- if pUnit ~= nil and t ~= nil then
- pUnit:CastSpellOnTarget( t, 56104 );
- end
- end, 15000, 0
- );
- end
- function L.FrostGiant.OnLeaveCombat(pUnit)
- pUnit:RemoveEvents();
- L.FrostGiant[pUnit:GetGUID()] = nil;
- end
- function L.FrostGiant.OnDeath(pUnit)
- pUnit:RemoveEvents();
- L.FrostGiant[pUnit:GetGUID()] = nil;
- end
- RegisterUnitEvent(90098, 1, L.FrostGiant.OnCombat);
- RegisterUnitEvent(90098, 2, L.FrostGiant.OnLeaveCombat);
- RegisterUnitEvent(90098, 4, L.FrostGiant.OnDeath);
Add Comment
Please, Sign In to add comment