Code:
--[[
CREDITS TO M4ksiu for C++ version and all info needed!
]]
--[[
Macros
]]
-- Flag Enums
local OBJECT_END = 0x006
local UNIT_NPC_FLAGS = OBJECT_END + 0x028
local GAMEOBJECT_STATE = OBJECT_END + 0x008
local UNIT_NPC_EMOTESTATE = OBJECT_END + 0x0A3
local UNIT_FIELD_FLAGS = OBJECT_END + 0x028
local CHAT_MSG_MONSTER_YELL = 14
local CHAT_MSG_MONSTER_SAY = 12
local UNIT_FLAG_NOT_ATTACKABLE_2 = 0x00000002
-- Emotes, maybe to change to enums?
local EMOTE_ONESHOT_SALUTE = 66
local EMOTE_ONESHOT_NO = 274
local EMOTE_ONESHOT_TALK = 1
local EMOTE_ONESHOT_QUESTION = 6
local EMOTE_ONESHOT_POINT = 25
local EMOTE_ONESHOT_SHOUT = 22
local EMOTE_ONESHOT_ROAR = 15
local EMOTE_ONESHOT_CUSTOMSPELL05 = 406
local EMOTE_ONESHOT_READY1H = 45
--[[
Akama AI
]]
-- ID-s
local Creature_Akama = 22990
local Creature_DoorDummy = 30001
local AKAMA_DOOR_FAIL = 41271
local AKAMA_DOOR_OPEN = 41268
local DEATHSWORN_DOOR_OPEN = 41269
local GATE_FAILURE = 10390
local m_despawn = 41242 -- despawn spell
-- Local variables
local moved = false
local doors = false
local ScenePart = 1
function Akama.OnTalk(unit, event, player, pMisc)
if (player:IsInCombat() ~= true) then
unit:GossipCreateMenu(1, player, 0)
if(moved = false) then
unit:GossipMenuAddItem(0, "I'm ready, Akama.", 1)
else
unit:GossipMenuAddItem(0, "We're ready to face Illidan.", 2)
end
unit:GossipSendMenu(player)
end
end
function Akama.OnSelect(unit, event, player, id, intid, code)
if(intid == 1) then
moved = true
unit:CreateWaypoint(660.248596, 330.695679, 271.688110, 100, 256, 0)
unit:CreateWaypoint(671.172241, 353.273193, 271.689453, 100, 256, 0)
unit:CreateWaypoint(694.227783, 379.461365, 271.792145, 100, 256, 0)
unit:CreateWaypoint(724.159973, 373.263275, 282.614349, 100, 256, 0)
unit:CreateWaypoint(747.034973, 335.668274, 307.047150, 100, 256, 0)
unit:CreateWaypoint(755.477234, 304.194580, 312.167328, 100, 256, 0)
unit:CreateWaypoint(771.809753, 303.744873, 313.563507, 100, 256, 0)
-- After Doors parts:
unit:CreateWaypoint(778.550232, 304.515198, 318.818542, 100, 256, 0)
unit:CreateWaypoint(789.564697, 304.493652, 319.759583, 100, 256, 0)
unit:CreateWaypoint(799.598389, 295.776642, 319.760040, 100, 256, 0)
unit:CreateWaypoint(799.054016, 288.826660, 320.030334, 100, 256, 0)
unit:CreateWaypoint(794.595459, 262.302856, 341.463715, 100, 256, 0)
unit:CreateWaypoint(794.396973, 256.420471, 341.463715, 100, 256, 0)
unit:CreateWaypoint(783.355957, 250.460892, 341.463776, 100, 256, 0)
unit:CreateWaypoint(764.988098, 238.561462, 353.646484, 100, 256, 0)
unit:CreateWaypoint(749.337463, 236.288681, 352.997223, 100, 256, 0)
unit:CreateWaypoint(751.941528, 304.626221, 352.996124, 100, 256, 0)
unit:CreateWaypoint(747.236511, 304.922913, 352.996155, 100, 256, 0)
unit:CreateWaypoint(747.834106, 362.513977, 352.996155, 100, 256, 0)
-- End of waypoint part
unit:MoveToWaypoint(1)
unit:SetFieldFlags(UNIT_NPC_FLAGS, 0)
unit:GossipComplete()
unit:SetCombatCapable(1) -- I cannot enter combats
elseif(intid == 2) then
ForceWaypointMove(17)
end
end
function Akama.OnReachWp(unit,null,null,wp)
local p = wp + 1
if(doors = false) then
if(wp == 6) then
doors = true
unit:RegisterEvent("Akama.DoorsScenario", 1000, 1)
else
unit:MoveToWaypoint(p)
end
else
if(wp == 16) then
unit:SetFieldFlags(UNIT_NPC_FLAGS, 1)
elseif(wp == 17) then
unit:RegisterEvent("Akama.IllidanDialog", 1000, 1)
else
unit:MoveToWaypoint(p)
end
end
function Akama.DoorsScenario(unit)
local pDoorDummy = unit:GetCreatureNearestCoords( 771.5, 304.7, 319.0, Creature_DoorDummy)
local pGate = unit:GetGameObjectNearestCoords(774.7f, 304.6f, 314.85f, 185905);
if(ScenePart == 1) then
unit:SetFacing(6.248631)
ScenePart = 2
unit:RegisterEvent("Akama.DoorsScenario", 1000, 1)
elseif(ScenePart == 2) then
unit:Emote(EMOTE_ONESHOT_TALK)
unit:SendChatMessage(CHAT_MSG_MONSTER_SAY, 0, "The door is all that stands between us and the Betrayer. Stand aside, friends.")
ScenePart = 3
unit:RegisterEvent("Akama.DoorsScenario", 1000, 1)
elseif(ScenePart == 3) then
if(pDoorDummy ~= nil) then
unit:ChannelSpell( pDoorDummy:GetGUID(), AKAMA_DOOR_FAIL)
end
ScenePart = 4
unit:RegisterEvent("Akama.DoorsScenario", 1500, 1)
elseif(ScenePart == 4) then
unit:ChannelSpell( 0, 0)
ScenePart = 5
unit:RegisterEvent("Akama.DoorsScenario", 1500, 1)
elseif(ScenePart == 5) then
unit:SendChatMessage(CHAT_MSG_MONSTER_SAY, 0, "I cannot do this alone...")
unit:Emote(EMOTE_ONESHOT_NO)
unit:SpawnCreature(23410, 751.884705, 311.270050, 312.121185, 1012, 0)
unit:SpawnCreature(23411, 751.687744, 297.408600, 312.124817, 1012, 0)
local pUdalo = unit:GetCreatureNearestCoords( unit:GetX(), unit:GetY(), unit:GetZ(), 23410)
local pOlum == unit:GetCreatureNearestCoords( unit:GetX(), unit:GetY(), unit:GetZ(), 23411)
ScenePart = 6
unit:RegisterEvent("Akama.DoorsScenario", 1000, 1)
elseif(ScenePart == 6) then
pUdalo:SendChatMessage(CHAT_MSG_MONSTER_SAY, 0, "You are not alone, Akama.")
ScenePart = 7
unit:RegisterEvent("Akama.DoorsScenario", 1000, 1)
elseif(ScenePart == 7) then
pOlum:SendChatMessage(CHAT_MSG_MONSTER_SAY, 0, "Your people will always be with you.")
ScenePart = 8
unit:RegisterEvent("Akama.DoorsScenario", 1500, 1)
elseif(ScenePart == 8) then
unit:ChannelSpell( Creature_DoorDummy:GetGUID(), DEATHSWORN_DOOR_OPEN)
pUdalo:ChannelSpell( Creature_DoorDummy:GetGUID(), DEATHSWORN_DOOR_OPEN)
pOlum:ChannelSpell( Creature_DoorDummy:GetGUID(), DEATHSWORN_DOOR_OPEN)
ScenePart = 9
unit:RegisterEvent("Akama.DoorsScenario", 2200, 1)
elseif(ScenePart == 9) then
if(pGate ~= nil) then
pGate:SetFieldFlags(GAMEOBJECT_STATE, 0)
Creature_DoorDummy:CastSpell(GATE_FAILURE)
end
ScenePart = 10
unit:RegisterEvent("Akama.DoorsScenario", 1500, 1)
elseif(ScenePart == 10) then
unit:ChannelSpell( 0, 0)
pUdalo:ChannelSpell( 0, 0)
pOlum:ChannelSpell( 0, 0)
ScenePart = 11
unit:RegisterEvent("Akama.DoorsScenario", 1000, 1)
elseif(ScenePart == 11) then
unit:SendChatMessage(CHAT_MSG_MONSTER_SAY, 0, "I thank you for your aid, my brothers. Our people will be redeemed!")
unit:Emote(EMOTE_ONESHOT_SALUTE)
ScenePart = 12
unit:RegisterEvent("Akama.DoorsScenario", 1000, 1)
elseif(ScenePart == 12) then
pUdalo:Emote(EMOTE_ONESHOT_SALUTE)
pOlum:Emote(EMOTE_ONESHOT_SALUTE)
pUdalo:Despawn( 0, 0)
pOlum:Despawn( 0, 0)
--pUdalo = nil
--pOlum = nil
ScenePart = 12
unit:RegisterEvent("Akama.DoorsScenario", 1000, 1)
elseif(ScenePart == 13) then
unit:MoveToWaypoint(7)
ScenePart = 1
end
end
function Akama.IllidanDialog(unit)
local pIllidan = unit:GetCreatureNearestCoords(704.539001, 305.282013, 353.919006, 22917)
if(pIllidan == nil or pIllidan:IsDead())
unit:SendChatMessage(CHAT_MSG_MONSTER_SAY, 0, "Not this time my friends.")
unit:CastSpell(m_despawn)
unit:Despawn(0, 0)
else
if(ScenePart == 1) then
unit:SetFacing(3.126680)
ScenePart = 2
unit:RegisterEvent("Akama.IllidanDialog", 1000, 1)
elseif(ScenePart == 2) then
pIllidan:RemoveAura(39656)
ScenePart = 3
unit:RegisterEvent("Akama.IllidanDialog", 1000, 1)
elseif(ScenePart == 3) then
pIllidan:SendChatMessage(CHAT_MSG_MONSTER_YELL, 0, "Akama... your duplicity is hardly surprising. I should have slaughtered you and your malformed brethren long ago.")
pIllidan:PlaySoundToSet(11463)
pIllidan:Emote(EMOTE_ONESHOT_QUESTION)
ScenePart = 4
unit:RegisterEvent("Akama.IllidanDialog", 2500, 1)
elseif(ScenePart == 4) then
unit:SendChatMessage(CHAT_MSG_MONSTER_YELL, 0, "We've come to end your reign, Illidan. My people and all of Outland shall be free!")
unit:PlaySoundToSet(11389)
unit:Emote(EMOTE_ONESHOT_POINT)
ScenePart = 5
unit:RegisterEvent("Akama.IllidanDialog", 1100, 1)
elseif(ScenePart == 5) then
unit:Emote(EMOTE_ONESHOT_TALK)
ScenePart = 6
unit:RegisterEvent("Akama.IllidanDialog", 1200, 1)
elseif(ScenePart == 6) then
unit:Emote(EMOTE_ONESHOT_SALUTE)
ScenePart = 7
unit:RegisterEvent("Akama.IllidanDialog", 1200, 1)
elseif(ScenePart == 7) then
pIllidan:SendChatMessage(CHAT_MSG_MONSTER_YELL, 0, "Boldly said. But I remain unconvinced.")
pIllidan:PlaySoundToSet(11464)
pIllidan:Emote(EMOTE_ONESHOT_QUESTION)
ScenePart = 8
unit:RegisterEvent("Akama.IllidanDialog", 1800, 1)
elseif(ScenePart == 8) then
unit:SendChatMessage(CHAT_MSG_MONSTER_YELL, 0, "The time has come! The moment is at hand!")
unit:PlaySoundToSet(11380);
unit:Emote(EMOTE_ONESHOT_SHOUT)
ScenePart = 9
unit:RegisterEvent("Akama.IllidanDialog", 1400, 1)
elseif(ScenePart == 9) then
unit:Emote(EMOTE_ONESHOT_ROAR)
ScenePart = 10
unit:RegisterEvent("Akama.IllidanDialog", 1500, 1)
elseif(ScenePart == 10) then
pIllidan:SendChatMessage(CHAT_MSG_MONSTER_YELL, 0, "You are not prepared!")
pIllidan:PlaySoundToSet(11466)
pIllidan:Emote(EMOTE_ONESHOT_CUSTOMSPELL05)
pIllidan:SetFieldFlags(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_READY1H)
ScenePart = 11
unit:RegisterEvent("Akama.IllidanDialog", 500, 1)
elseif(ScenePart == 11) then
--Combat starts
unit:SetCombatCapable(0)
pIllidan:SetCombatCapable(0)
unit:AttackReaction(pIllidan, 500, 0)
pIllidan:AttackReaction(unit, 500, 0)
local pRightGate = GetGameObjectNearestCoords(745.07, 241.802, 354.292, 200000);
local pLeftGate = GetGameObjectNearestCoords(744.829, 369.276, 354.324, 200001);
if(pRightGate ~= nil) then
pRightGate:SetFieldFlags(GAMEOBJECT_STATE, 1)
end
if(pLeftGate ~= nil) then
pLeftGate:SetFieldFlags(GAMEOBJECT_STATE, 1)
end
end
end
RegisterUnitGossipEvent(Creature_Akama, 1, "Akama.OnTalk")
RegisterUnitGossipEvent(Creature_Akama, 2, "Akama.OnSelect")
RegisterUnitEvent(Creature_Akama, 19, "Akama.OnReachWp")
--[[
ILLIDAN STORMRAGE AI
]]
-- ID-s
local Creature_Illidan_Stormrage = 22917
-- Local variables
local phase = 1
function Illidan.OnSpawn(unit)
unit:CastSpell(39656)
unit:SetCombatCapable(1)
unit:SetFieldFlags(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_ATTACKABLE_2)
unit:SetFieldFlags(UNIT_FIELD_RANGEDATTACKTIME, 1800)
unit:SetFieldFlags(UNIT_NPC_EMOTESTATE, 0)
end
function Illidan.OnCombat(Unit, event, pMisc)
phase = 1
unit:RegisterAIUpdateEvent(1000)
end
function Illidan.AIUpdate(Unit)
end
RegisterUnitEvent(Creature_Illidan_Stormrage, 18, "Illidan.OnSpawn")
RegisterUnitEvent(Creature_Illidan_Stormrage, 19, "Illidan.OnCombat")
RegisterUnitEvent(Creature_Illidan_Stormrage, 21, "Illidan.AIUpdate")