I'm gonna explain everything like this.
I make a mob that is like a Warrior and one that is like a Shaman I give them both same Faction flag.
I want the Shaman to heal the Warrior or himself when either he or the warrior goes under a certain % hp this is what I managed to do for the Shaman.
The following script don't have the correct spells used but it will be modified l8r, its more like a "test" script, and I haven't yet made the Shaman nor Warrior MOB, using a Bear mob atm ;D
Code:
function HordeShaman_OnCombat(pUnit, event)
pUnit:SendChatMessage(12, 0, "Raaawwh!")
pUnit:RegisterEvent("LesserHealHorde", 2000, 0)
pUnit:RegisterEvent("ChainHealHorde", 5000, 0)
end
function LesserHealHorde(pUnit, event)
if pUnit:GetHealthPct() >= 40 then
local friend = Unit:GetRandomFriend()
pUnit:FullCastSpellOnTarget(25840,friend)
end
end
function ChainHealHorde(pUnit, event)
if pUnit:GetHealthPct() <= 50 then
local friend = Unit:GetRandomFriend()
pUnit:FullCastSpellOnTarget(25840,friend)
end
end
function HordeShaman_OnLeaveCombat(pUnit, event)
pUnit:RemoveEvents()
end
function HordeShaman_OnKilledTarget(pUnit, event)
pUnit:SendChatMessage(12, 0, "May the spirits forgive you")
end
function HordeShaman_OnDied(pUnit, event)
pUnit:RemoveEvents()
end
RegisterUnitEvent(24633, 1, "HordeShaman_OnCombat")
RegisterUnitEvent(24633, 2, "HordeShaman_OnLeaveCombat")
RegisterUnitEvent(24633, 3, "HordeShaman_OnKilledTarget")
RegisterUnitEvent(24633, 4, "HordeShaman_OnDied")
In my console I get the following error
Code:
Calling 'GetRandomFriend' on bad self (Unit expected, got table)
2x+rep to anyone who solve this!