Advertisement
Mordred

Scarlet Monastery

Aug 18th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 35.14 KB | None | 0 0
  1. -- by Mordred
  2.  
  3. local SM = {{Flag = {[0] = 0.39, [1] = 0.172, [2] = 0.13}},
  4. traineeid =                 38000,
  5. dogid =                     38001,
  6. armoredtraineeid =          38002,
  7. houndmasterrokyrid =        38003,
  8. commandermarladecoyid =     38004,
  9. commandermarlaburnedid =    38005,
  10. commadermarlafirewaveid =   38006,
  11. commandermarlafireballid =  38007,
  12. commandermarladummyid =     38008,
  13. scarletcommandermarlaid =   38009,
  14. herod =                     #####}
  15.  
  16. ------------------------ NPC CHAT FUNCTION --------------------------
  17.  
  18. --[[
  19.     Pattern:
  20.     tablename = {"dummy text",12,                       -> at first the string, then the type (language is always 0(general))
  21.                 "dummy text",12,
  22.                 "dummy text",14,                        -> length of the string for time until next chat bubble (min. time of 3sec and max time of 10sec)
  23.                 "dummy text",14,
  24.                 "dummy text",12}
  25.     local time = SM.NPCTalkSequence(Unit,tablename)     -> returns total length of the sequence
  26. --]]
  27.  
  28. function SM.NPCTalkSequence(Unit, Table)
  29.     if not Unit then return; end
  30.     if not Table then return; end
  31.     local maxtentrys = table.getn(Table)
  32.     if maxtentrys < 4 then print("Must be at least 2 strings and 2 numbers in the table!") return end
  33.     local maxtime = 0
  34.     Unit:SendChatMessage(Table[2],0,Table[1])
  35.     for i=3,maxtentrys,2 do
  36.         local timecoef = 0
  37.         local checktime = string.len(Table[i-2])*100-string.len(Table[i-2])*50
  38.         if checktime < 3000 then timecoef = 3000; else timecoef = checktime; end if (timecoef) > 10000 then timecoef = 10000; end
  39.         maxtime = maxtime + timecoef
  40.         Unit:RegisterEvent(function() Unit:SendChatMessage(Table[i+1],0,Table[i]) end, maxtime, 1)
  41.     end
  42.     local timecoef = 0
  43.     local checktime = string.len(Table[maxtentrys-1])*100-string.len(Table[maxtentrys-1])*50
  44.     if checktime < 3000 then timecoef = 3000; else timecoef = checktime; end if (timecoef) > 10000 then timecoef = 10000; end
  45.     maxtime = maxtime + timecoef
  46.     return maxtime
  47. end
  48.  
  49. ------------------------- NPC MOVE FUNCTION -------------------------
  50.  
  51. --[[   How to register with MovePath
  52.  
  53. local PathIDs = {
  54. {x,y,z,delay,flag[,function called, delayed function]},
  55. {...},
  56. ...
  57. {...},
  58. {x,y,z,delay,flag[,function called, delayed function]},
  59. {x,y,z,delay,Restartflag[,function called, delayed function]}}
  60.  
  61. SM.StartPath(Unit, PathIDs)
  62.  
  63. --MovePath commands--
  64. StartPath(unit, path table)                                                                             -> Starts the Path with the unit and the table with the containing informations.
  65. ChangePathNode(path table, PathNode, [X],[Y],[Z],[Delay],[Flag],[function called],[delayed function])   -> Changes the properties of the PathNode, but only the given ones and returns true if successfully changed or false if failed.
  66. SetRestartFlag(path table, true/false)                                                                  -> Changes the RestartFlag of the last PathNode to true/false and returns true if successfully changed or false if failed.
  67. AddPathNode(path table, PathNode, X, Y, Z, Delay, Flag, function called, delayed function)              -> Adds a new PathNode to the table with the given informations and returns true if successfully added or false if failed.
  68. RemovePathNode(path table, PathNode)                                                                    -> Removes a PathNode from the table and returns true if successfully removed or false if failed.
  69.  
  70. --]]
  71. -- Flags: 0=Walk; 1=Run; (2=Fly bugged, never lands again)
  72. -- Restartflag: false/true
  73.  
  74. function SM.StartPath(Unit, Table)
  75.     local x = Table[1][1]; local y = Table[1][2]; local z = Table[1][3]
  76.     Unit:SetMovementFlags(Table[1][5])
  77.     local rTime = ((Unit:CalcToDistance(x,y,z)*SM.Flag[Table[1][5]])*1000) - ((Unit:CalcToDistance(x,y,z)*80) - (Unit:CalcToDistance(x,y,z)*5))
  78.     if rTime < 100 then
  79.         SM.PathPoints(Unit, Table, 1)
  80.     else
  81.         Unit:RegisterEvent(function() SM.PathPoints( Unit, Table, 1 ) end,rTime,1)
  82.     end
  83.     Unit:MoveTo(x,y,z,0)
  84. end
  85.  
  86. function SM.PathPoints(Unit, Table, PathNum)
  87.     local x = Table[PathNum][1]; local y = Table[PathNum][2]; local z = Table[PathNum][3]
  88.     local rTime = ((Unit:CalcToDistance(x,y,z)*SM.Flag[Table[PathNum][5]])*1000) - ((Unit:CalcToDistance(x,y,z)*80) - (Unit:CalcToDistance(x,y,z)*5))
  89.     if rTime < 150 then
  90.         if (Table[PathNum][6]~=nil) then
  91.             _G[Table[PathNum][6]](Unit, PathNum)
  92.         end
  93.         if (PathNum<table.getn(Table)) and Unit:IsInWorld() then
  94.             if (Table[PathNum][4]~=0) then
  95.                 Unit:RegisterEvent(function() SM.DelayMove( Unit, Table, PathNum ) end,Table[PathNum][4],1)
  96.             else
  97.                 Unit:SetMovementFlags(Table[PathNum][5])
  98.                 local x = Table[PathNum+1][1]; local y = Table[PathNum+1][2]; local z = Table[PathNum+1][3]
  99.                 local rTime = ((Unit:CalcToDistance(x,y,z)*SM.Flag[Table[PathNum][5]])*1000) - ((Unit:CalcToDistance(x,y,z)*80) - (Unit:CalcToDistance(x,y,z)*5))
  100.                 if rTime < 100 then
  101.                     SM.PathPoints(Unit, Table, PathNum+1)
  102.                 else
  103.                     Unit:RegisterEvent(function() SM.PathPoints( Unit, Table, PathNum+1 ) end,rTime,1)
  104.                 end
  105.                 Unit:MoveTo(x,y,z,0)
  106.             end
  107.         elseif Table[PathNum][5] then
  108.             SM.StartPath(Unit, Table)
  109.         end
  110.     else
  111.         Unit:RegisterEvent(function() SM.PathPoints( Unit, Table, PathNum ) end,rTime,1)
  112.         if not Unit:IsCreatureMoving() then Unit:MoveTo(x,y,z,0) end
  113.     end
  114. end
  115.  
  116. function SM.DelayMove(Unit, Table, PathNum)
  117.     if (Table[PathNum][7]~=nil) then
  118.         _G[Table[PathNum][7]](Unit, PathNum)
  119.     end
  120.     Unit:SetMovementFlags(Table[PathNum][5])
  121.     local x = Table[PathNum+1][1]; local y = Table[PathNum+1][2]; local z = Table[PathNum+1][3]
  122.     Unit:MoveTo(x,y,z,0)
  123.     local rTime = ((Unit:CalcToDistance(x,y,z)*SM.Flag[Table[PathNum][5]])*1000) - ((Unit:CalcToDistance(x,y,z)*80) - (Unit:CalcToDistance(x,y,z)*5))
  124.     if rTime < 100 then
  125.         SM.PathPoints(Unit, Table, PathNum+1)
  126.     else
  127.         Unit:RegisterEvent(function() SM.PathPoints( Unit, Table, PathNum+1 ) end,rTime,1)
  128.     end
  129. end
  130.  
  131. function SM.ChangePathNode(Table, PathNum, X,Y,Z,Delay,Flag,FuncCalled,DelayFunc)
  132.     if Table and PathNum then
  133.         if X then if type(X)~="number" then return false, type(X); end
  134.             Table[PathNum][1] = X
  135.         end if Y then if type(Y)~="number" then return false, type(Y); end
  136.             Table[PathNum][2] = Y
  137.         end if Z then if type(Z)~="number" then return false, type(Z); end
  138.             Table[PathNum][3] = Z
  139.         end if Delay then if type(Delay)~="number" then return false, type(Delay); end
  140.             Table[PathNum][4] = Delay
  141.         end if Flag and PathNum~=getn(Table) then if type(Flag)~="number" then return false type(Flag); end
  142.             Table[PathNum][5] = Flag
  143.         end if FuncCalled then if type(FuncCalled)~="string" then return false, type(FuncCalled); end
  144.             Table[PathNum][6] = FuncCalled
  145.         end if DelayFunc then if type(DelayFunc)~="string" then return false, type(DelayFunc); end
  146.             Table[PathNum][7] = DelayFunc
  147.         end
  148.         return true;
  149.     else return false, false; end
  150. end
  151.  
  152. function SM.SetRestartFlag(Table, Boolean)
  153.     if Table~=nil then
  154.         if type(Boolean)=="boolean" then
  155.             Table[getn[Table]][5] = Boolean
  156.             return true;
  157.         else return false, type(Boolean); end
  158.     else return false, false; end
  159. end
  160.  
  161. function SM.AddPathNode(Table, PathNum, X,Y,Z,Delay,Flag,FuncCalled,DelayFunc)
  162.     if Table~=nil then
  163.         if PathNum<=getn(Table) then
  164.             table.insert(Table, PathNum, {X,Y,Z,Delay,Flag,FuncCalled,DelayFunc})
  165.             return true;
  166.         else return false, getn(Table); end
  167.     else return false, false; end
  168. end
  169.  
  170. function SM.RemovePathNode(Table, PathNum)
  171.     if Table~=nil then
  172.         if type(PathNum)=="number" then
  173.             table.remove(Table, PathNum)
  174.             return true;
  175.         else return false; end
  176.     else return false; end
  177. end
  178.  
  179. ----------------------------Entering Event----------------------------
  180.  
  181. function SM.Trainees_OnSpawn(Unit)
  182.     local iID = Unit:GetInstanceID()
  183.     if not iID then error("This NPC is not in an instance!") end
  184.    
  185.     Unit:DisableCombat(true)
  186.     Unit:DisableMelee(true)
  187.     Unit:DisableTargeting(true)
  188.     Unit:SetUInt32Value(59,256)
  189.     Unit:SetMovementFlags(1)
  190.     Unit:Emote(431, 3000)
  191.    
  192.     Unit:RegisterEvent(function()
  193.         Unit:MoveTo(151.179,-1.87,18.01,3.173)
  194.         local rnd = math.random(4)
  195.         if rnd==1 then
  196.             local rnd = math.random(4)
  197.             if rnd==1 then
  198.                 Unit:MonsterYell("Quick! Get to the commanders! Intruders entered our monastery!")
  199.             elseif rnd==2 then
  200.                 Unit:MonsterYell("Intruders entered our monastery! Run!")
  201.             elseif rnd==3 then
  202.                 Unit:MonsterYell("Watch out! He has a weapon!")
  203.             else
  204.                 Unit:MonsterSay("They don't look friendly, we better get help here quickly.")
  205.             end
  206.         end
  207.         local diff = IS.Spawned[iID].diff
  208.         if diff==2 then
  209.             Unit:RegisterEvent(function()
  210.                 if Unit:IsAlive() then
  211.                     local dog = Unit:SpawnCreature(SM.dogid, Unit:GetSpawnX(),Unit:GetSpawnY(),Unit:GetSpawnZ(),Unit:GetSpawnO(), 14, 0,  0,0,0,1,0)
  212.                     dog:TeleportCreature(Unit:GetX(),Unit:GetY(),Unit:GetZ())
  213.                     Unit:RegisterEvent(function()
  214.                             dog:MoveTo(Unit:GetSpawnX(),Unit:GetSpawnY(),Unit:GetSpawnZ(),Unit:GetSpawnO())
  215.                         end, 1000, 1)
  216.                 end end, 8000, 1)
  217.         elseif diff==4 then
  218.             Unit:RegisterEvent(function()
  219.                 if Unit:IsAlive() then
  220.                     local dog = Unit:SpawnCreature(SM.armoredtraineeid, Unit:GetSpawnX(),Unit:GetSpawnY(),Unit:GetSpawnZ(),Unit:GetSpawnO(), 14, 0,  0,0,0,1,0)
  221.                     dog:TeleportCreature(Unit:GetX(),Unit:GetY(),Unit:GetZ())
  222.                     dog:SetMovementFlags(1)
  223.                     Unit:RegisterEvent(function()
  224.                             dog:MoveTo(Unit:GetSpawnX(),Unit:GetSpawnY(),Unit:GetSpawnZ(),Unit:GetSpawnO())
  225.                         end, 1000, 1)
  226.                 end end, 8500, 1)
  227.         end
  228.         Unit:Despawn(10000,0)
  229.     end, 1000, 1)
  230. end
  231.  
  232. RegisterUnitEvent(SM.traineeid, 18, SM.Trainees_OnSpawn)
  233.  
  234. ----------------------------------------------------------------------
  235. --                                                                  --
  236. --                                                                  --
  237. -------------<sideboss>-----1st Boss-----Houndmaster Rokyr------------
  238.  
  239. SM.HR = {dogs = {},
  240.         Spells = {
  241. -- Spells which the boss and his minions will use
  242. revive = 51920,
  243. mendpettrigger = 60957,
  244. mendpet = 15870,
  245. freepettrigger = 54350,
  246. freepet = 59752,
  247. freezingtrap = 60192,
  248. freezingtrigger = 60888,
  249. petenragetrigger = 46731,
  250. petenrage = 15061,
  251. invincible = 52075}}
  252.  
  253. function SM.HR.OnSpawn(Unit)
  254.     Unit:DisableCombat(true)
  255.     Unit:DisableMelee(true)
  256.     Unit:DisableTargeting(true)
  257.     Unit:CastSpell(SM.HR.Spells.invincible)
  258.    
  259.     Unit:RegisterEvent(SM.HR.AreaBossTrigger, 2000, 0)
  260. end
  261.  
  262. function SM.HR.AreaBossTrigger(Unit)
  263.     local iID = Unit:GetInstanceID()
  264.     if not iID then error("This NPC is not in an instance!") end
  265.     local plrs = GetPlayersInInstance(44, iID)
  266.     if plrs then
  267.         local AreaCheck = true
  268.         for num,plr in pairs(plrs) do
  269.             if not ( plr:GetX()>171 and plr:GetX()<190 and plr:GetY()<-109 and plr:GetY()>-141 ) then
  270.                 AreaCheck = false
  271.             end
  272.         end
  273.         if AreaCheck then
  274.             Unit:RemoveEvents()
  275.             local RokyrTalk = {"Who are you?",12,
  276.                                 "What are you doing here?",12,
  277.                                 "Oh, I see. We got some intruders here.",12,
  278.                                 "Why has no one informed me yet!?", 14,
  279.                                 "It's time to play, my babies!",14}
  280.             local timer = SM.NPCTalkSequence(Unit,RokyrTalk)
  281.             Unit:Emote(27,timer+2000)
  282.             Unit:RegisterEvent(function()
  283.                     SM.HR.dogs[iID] = {}
  284.                     local diff = IS.Spawned[iID].diff
  285.                     for i=1, diff, 1 do
  286.                         local dog = Unit:SpawnCreature(SM.dogid,189.702,-103.948,18.677,3.1289,14,0,  0,0,0,1,0)
  287.                         dog:SetMovementFlags(1)
  288.                         LCF:RegisterLuaEvent(tostring(dog), function()
  289.                                 dog:MoveTo((Unit:GetX()-2)+math.random(4),(Unit:GetY()+2)-math.random(4),Unit:GetZ(), Unit:GetO())
  290.                             end, 1000, 1)
  291.                         table.insert(SM.HR.dogs[iID], dog)
  292.                     end
  293.                     Unit:RegisterEvent(SM.HR.DogAlive_and_Area_Check, 3000, 1)
  294.                     Unit:RegisterEvent(SM.HR.RandomSpellTrigger, 6000, 1)
  295.                     if diff~=4 then
  296.                         Unit:RemoveAura(SM.HR.Spells.invincible)
  297.                     end
  298.                 end, timer, 1)
  299.         end
  300.     end
  301. end
  302.  
  303. function SM.HR.RandomSpellTrigger(Unit)
  304.     local srnd = math.random(3)
  305.     if srnd==1 then
  306.         Unit:FullCastSpell(SM.HR.Spells.mendpettrigger)
  307.     elseif srnd==2 then
  308.         Unit:CastSpell(SM.HR.Spells.petenragetrigger)
  309.     else
  310.         Unit:CastSpell(SM.HR.Spells.freepettrigger)
  311.     end
  312. end
  313.  
  314. function SM.HR.RandomDogSelectionCast(Unit, Spell)
  315.     local iID = Unit:GetInstanceID()
  316.     if not iID then error("This NPC is not in an instance!") end
  317.  
  318.     local drnd = math.random(table.getn(SM.HR.dogs[iID]))
  319.     if type(SM.HR.dogs[iID][drnd])=="table" then
  320.         for num,unt in pairs(SM.HR.dogs[iID]) do
  321.             if type(unt)~="table" then
  322.                 drnd = num
  323.                 break;
  324.             end
  325.         end
  326.     end
  327.    
  328.     Unit:RegisterEvent(SM.HR.RandomSpellTrigger, 5000, 1)
  329.     if SM.HR.dogs[iID][drnd]~="table" then
  330.         SM.HR.dogs[iID][drnd]:CastSpell(Spell)
  331.     end
  332. end
  333.  
  334. function SM.HR.EnragePetTriggerSpell(index, Spell)
  335.     local Unit = Spell:GetCaster()
  336.    
  337.     if Unit:IsPlayer() then return; end
  338.     if Unit:GetEntry()~=SM.houndmasterrokyrid then return; end
  339.    
  340.     SM.HR.RandomDogSelectionCast(Unit, SM.HR.Spells.petenrage)
  341. end
  342.  
  343. function SM.HR.MendPetTriggerSpell(index, Spell)
  344.     local Unit = Spell:GetCaster()
  345.    
  346.     if Unit:IsPlayer() then return; end
  347.     if Unit:GetEntry()~=SM.houndmasterrokyrid then return; end
  348.    
  349.     SM.HR.RandomDogSelectionCast(Unit, SM.HR.Spells.mendpet)
  350. end
  351.  
  352. function SM.HR.FreePetTriggerSpell(index, Spell)
  353.     local Unit = Spell:GetCaster()
  354.    
  355.     if Unit:IsPlayer() then return; end
  356.     if Unit:GetEntry()~=SM.houndmasterrokyrid then return; end
  357.    
  358.     SM.HR.RandomDogSelectionCast(Unit, SM.HR.Spells.freepet)
  359. end
  360.  
  361. RegisterDummySpell(SM.HR.Spells.mendpettrigger, SM.HR.MendPetTriggerSpell)
  362. RegisterDummySpell(SM.HR.Spells.freepettrigger, SM.HR.FreePetTriggerSpell)
  363. RegisterDummySpell(SM.HR.Spells.petenragetrigger, SM.HR.EnragePetTriggerSpell)
  364.  
  365. function SM.HR.DogAlive_and_Area_Check(Unit)
  366.     local iID = Unit:GetInstanceID()
  367.     if not iID then error("This NPC is not in an instance!") end
  368.     local plrs = GetPlayersInInstance(44, iID)
  369.     local diff = IS.Spawned[iID].diff
  370.     if plrs then
  371.         local AreaCheck = false
  372.         for num,plr in pairs(plrs) do
  373.             if not ( plr:GetX()>171 and plr:GetX()<190 and plr:GetY()<-109 and plr:GetY()>-141 ) then
  374.                 AreaCheck = true
  375.             end
  376.         end
  377.         if AreaCheck then
  378.             Unit:RemoveEvents()
  379.             Unit:Despawn(0,10000)
  380.             if SM.HR.dogs[iID] then
  381.                 for num,dog in pairs(SM.HR.dogs[iID]) do
  382.                     dog:Despawn(0,0)
  383.                 end
  384.             end
  385.             return;
  386.         end
  387.     end
  388.    
  389.     --
  390.    
  391.     local deadcheck = true
  392.     if SM.HR.dogs[iID] then
  393.         for num,dog in pairs(SM.HR.dogs[iID]) do
  394.             if type(dog)~="table" then
  395.                 if dog:IsAlive() then
  396.                     deadcheck = false
  397.                 else
  398.                     local x = dog:GetX(); local y = dog:GetY(); local z = dog:GetZ(); local o = dog:GetO();
  399.                     dog:Despawn(2000,0)
  400.                     SM.HR.dogs[iID][num] = {x,y,z,o}
  401.                 end
  402.             end
  403.         end
  404.     end
  405.    
  406.     if deadcheck then
  407.         Unit:RemoveEvents()
  408.         Unit:FullCastSpell(SM.HR.Spells.revive)
  409.         if diff==4 then
  410.             Unit:RemoveAura(SM.HR.Spells.invincible)
  411.         end
  412.     else
  413.         if diff==2 or diff==4 then
  414.             local frnd = math.random(100)
  415.             if frnd<=5 then
  416.                 Unit:RemoveEvents()
  417.                 Unit:FullCastSpell(SM.HR.Spells.freezingtrigger)
  418.             else
  419.                 Unit:RegisterEvent(SM.HR.DogAlive_and_Area_Check, 2000, 1)
  420.             end
  421.         end
  422.     end
  423. end
  424.  
  425. function SM.HR.ReviveSpell(index, Spell)
  426.     local Unit = Spell:GetCaster()
  427.    
  428.     if Unit:IsPlayer() then return; end
  429.     if Unit:GetEntry()~=SM.houndmasterrokyrid then return; end
  430.    
  431.     local iID = Unit:GetInstanceID()
  432.     if not iID then error("This NPC is not in an instance!") end
  433.     local diff = IS.Spawned[iID].diff
  434.    
  435.     if SM.HR.dogs[iID] then
  436.         local new = {}
  437.         for num,dog in pairs(SM.HR.dogs[iID]) do
  438.             if type(dog)=="table" then
  439.                 local dawg = Unit:SpawnCreature(SM.dogid,dog[1],dog[2],dog[3],dog[4],14,0,  0,0,0,1,0)
  440.                 dawg:CastSpell(51920)
  441.                 table.insert(new, dawg)
  442.             end
  443.         end
  444.         SM.HR.dogs[iID] = new
  445.     end
  446.    
  447.     if diff==4 then
  448.         Unit:CastSpell(SM.HR.Spells.invincible)
  449.     end
  450.    
  451.     Unit:RegisterEvent(SM.HR.DogAlive_and_Area_Check, 2000, 1)
  452.     Unit:RegisterEvent(SM.HR.RandomSpellTrigger, 5000, 1)
  453. end
  454.  
  455. RegisterDummySpell(SM.HR.Spells.revive, SM.HR.ReviveSpell)
  456.  
  457. function SM.HR.FreezingTrap(index, Spell)
  458.     local Unit = Spell:GetCaster()
  459.    
  460.     if Unit:IsPlayer() then return; end
  461.     if Unit:GetEntry()~=SM.houndmasterrokyrid then return; end
  462.    
  463.     local iID = Unit:GetInstanceID()
  464.     if not iID then error("This NPC is not in an instance!") end
  465.     local plrs = GetPlayersInInstance(44, iID)
  466.     if plrs then
  467.         local prnd = math.random(table.getn(plrs))
  468.         Unit:CastSpellAoF(plrs[prnd]:GetX(), plrs[prnd]:GetY(), plrs[prnd]:GetZ(), SM.HR.Spells.freezingtrap)
  469.     end
  470.     Unit:RegisterEvent(SM.HR.DogAlive_and_Area_Check, 2000, 1)
  471.     Unit:RegisterEvent(SM.HR.RandomSpellTrigger, 5000, 1)
  472. end
  473.  
  474. RegisterDummySpell(SM.HR.Spells.freezingtrigger, SM.HR.FreezingTrap)
  475.  
  476. function SM.HR.OnLeave(Unit)
  477.     local iID = Unit:GetInstanceID()
  478.     if not iID then error("This NPC is not in an instance!") end
  479.     Unit:RemoveEvents()
  480.    
  481.     if SM.HR.dogs[iID] then
  482.         for num,dog in pairs(SM.HR.dogs[iID]) do
  483.             if type(dog)~="table" then
  484.                 dog:Despawn(0,0)
  485.             end
  486.         end
  487.     end
  488.    
  489.     SM.HR.OnSpawn(Unit)
  490. end
  491.  
  492. function SM.HR.OnDied(Unit)
  493.     local iID = Unit:GetInstanceID()
  494.     if not iID then error("This NPC is not in an instance!") end
  495.     local diff = IS.Spawned[iID].diff
  496.     Unit:RemoveEvents()
  497.    
  498.     if SM.HR.dogs[iID] then
  499.         for num,dog in pairs(SM.HR.dogs[iID]) do
  500.             if type(dog)=="table" then
  501.                 local dawg = Unit:SpawnCreature(SM.dogid,dog[1],dog[2],dog[3],dog[4],14,0,  0,0,0,1,0)
  502.                 dawg:CastSpell(51920)
  503.                 if diff~=4 then
  504.                     dawg:DisableCombat(true)
  505.                     dawg:DisableTargeting(true)
  506.                     dawg:DisableMelee(true)
  507.                     LCF:RegisterLuaEvent(tostring(dawg), function()
  508.                             dawg:MoveTo(189.702,-103.948,18.677,3.1289)
  509.                         end, 1000, 1)
  510.                     dawg:Despawn(6000,0)
  511.                 else
  512.                     LCF:RegisterLuaEvent(tostring(dawg), function()
  513.                             dawg:CastSpell(SM.HR.Spells.petenrage)
  514.                         end, 1000, 1)
  515.                 end
  516.             else
  517.                 local dawg = dog:SpawnCreature(SM.dogid,dog:GetX(),dog:GetY(),dog:GetZ(),dog:GetO(),14,0,  0,0,0,1,0)
  518.                 if diff~=4 then
  519.                     dawg:SetMovementFlags(1)
  520.                     dawg:DisableCombat(true)
  521.                     dawg:DisableTargeting(true)
  522.                     dawg:DisableMelee(true)
  523.                     LCF:RegisterLuaEvent(tostring(dawg), function()
  524.                             dawg:MoveTo(189.702,-103.948,18.677,3.1289)
  525.                         end, 1000, 1)
  526.                     dawg:Despawn(6000,0)
  527.                 else
  528.                     LCF:RegisterLuaEvent(tostring(dawg), function()
  529.                             dawg:CastSpell(SM.HR.Spells.petenrage)
  530.                         end, 1000, 1)
  531.                 end
  532.             end
  533.         end
  534.     end
  535.    
  536.     local RokyrTalk = {"Damn it!",12,
  537.                         "Maybe you've defeated me, but don't think it will get any easier...",12,
  538.                         "The scarlet monastery will be ready!",14,
  539.                         "The commanders... are... ready!",14}
  540.     local timer = SM.NPCTalkSequence(Unit,RokyrTalk)
  541.    
  542.     LCF:RegisterLuaEvent(tostring(Unit), function()
  543.             local iID = Unit:GetInstanceID()
  544.             if not iID then error("This NPC is not in an instance!") end
  545.             local dogs = IS.Spawned[iID][3]
  546.             if dogs then
  547.                 for num,dog in pairs(dogs) do
  548.                     dog:Despawn(1000,0)
  549.                 end
  550.             end
  551.         end,timer,1,Unit)
  552. end
  553.  
  554. RegisterUnitEvent(SM.houndmasterrokyrid, 2, SM.HR.OnLeave)
  555. RegisterUnitEvent(SM.houndmasterrokyrid, 4, SM.HR.OnDied)
  556. RegisterUnitEvent(SM.houndmasterrokyrid, 18, SM.HR.OnSpawn)
  557.  
  558. ----------------------------------------------------------------------
  559. --                                                                  --
  560. --                                                                  --
  561. -----------------2nd Boss-----Scarlet Commander Marla-----------------
  562.  
  563. SM.SCM = {decoys = {},
  564.         firewall = {},
  565.         flames = {},
  566.         target = {},
  567.         healthcheck = {},
  568.         Spells = {
  569. -- Spells which the boss and his minions will use
  570. decoydestroy = 34602,
  571. firewave = 43113,
  572. fireballtrigger = 60958,
  573. fireball = 29473,
  574. fireballtarget = 43313,
  575. fireballexplosion = 52146,
  576. fireballdamage = 47721,
  577. whirlwind = 54797,
  578. lightfirechannel = 45576,
  579. lightfirepath = 42344,
  580. burningaura = 59216,
  581. invincible = 52075},
  582.  
  583.         Objects = {
  584. -- Gameobjects which are used while the boss
  585. wall = 180322,
  586. firewall = 186859}}
  587.  
  588. function SM.SCM.OnSpawn(Unit)
  589.     local iID = Unit:GetInstanceID()
  590.     if not iID then error("This NPC is not in an instance!") end
  591.    
  592.     Unit:DisableCombat(true)
  593.     Unit:DisableMelee(true)
  594.     Unit:DisableTargeting(true)
  595.     Unit:CastSpell(SM.SCM.Spells.invincible)
  596.    
  597.     SM.SCM.decoys[iID] = {}
  598.     table.insert(SM.SCM.decoys[iID], Unit:SpawnCreature(SM.commandermarladecoyid,222,-101.97,18.5,1.53,14,0,  0,0,0,1,0))
  599.     table.insert(SM.SCM.decoys[iID], Unit:SpawnCreature(SM.commandermarladecoyid,228,-101.97,18.5,1.53,14,0,  0,0,0,1,0))
  600.     table.insert(SM.SCM.decoys[iID], Unit:SpawnCreature(SM.commandermarladecoyid,225,-104.97,18.5,1.53,14,0,  0,0,0,1,0))
  601.     table.insert(SM.SCM.decoys[iID], Unit:SpawnCreature(SM.commandermarladecoyid,225,-98.97,18.5,1.53,14,0,  0,0,0,1,0))
  602.    
  603.     for num,dec in pairs(SM.SCM.decoys[iID]) do
  604.         dec:DisableCombat(true)
  605.         dec:DisableMelee(true)
  606.         dec:DisableTargeting(true)
  607.         dec:SetUInt32Value(59,256)
  608.         dec:SetMovementFlags(1)
  609.     end
  610.    
  611.     Unit:RegisterEvent(SM.SCM.AreaBossTrigger, 2000, 0)
  612. end
  613.  
  614. function SM.SCM.AreaBossTrigger(Unit)
  615.     local iID = Unit:GetInstanceID()
  616.     if not iID then error("This NPC is not in an instance!") end
  617.     local plrs = GetPlayersInInstance(44, iID)
  618.    
  619.     Unit:MoveTo(267.445-math.random(4), -98.08+math.random(4), 18.67938, 3.145)
  620.    
  621.     if plrs then
  622.         local AreaCheck = false
  623.        
  624.         for num,plr in pairs(plrs) do
  625.             if plr:GetX()>216 and plr:GetY()<-90 and plr:GetY()>-116 then
  626.                 AreaCheck = true
  627.             end
  628.         end
  629.        
  630.         if AreaCheck then
  631.             Unit:RemoveEvents()
  632.             Unit:ReturnToSpawnPoint()
  633.             local plrsForBoss = {}
  634.            
  635.             for num,plr in pairs(plrs) do
  636.                 if plr:IsAlive() then
  637.                     if plr:GetX()>216 and plr:GetX()<233 and plr:GetY()<-68 and plr:GetY()>-116 then
  638.                         table.insert(plrsForBoss, plr)
  639.                     end
  640.                 else
  641.                     table.remove(plrs, num)
  642.                 end
  643.             end
  644.            
  645.             for num,plr in pairs(plrsForBoss) do
  646.                 plr:MovePlayerTo(223.198+math.random(4),-98-math.random(4),18.578,0,4096)
  647.             end
  648.            
  649.             for num,unt in pairs(SM.SCM.decoys[iID]) do
  650.                 unt:MoveTo(261.398+math.random(2), -99-math.random(2), 18.678, 0)
  651.             end
  652.            
  653.             Unit:RegisterEvent(function()
  654.                     for num,plr in pairs(plrsForBoss) do
  655.                         plr:MovePlayerTo(247.52+math.random(4),-98-math.random(4),18.578,0,4096)
  656.                     end
  657.                 end, 2000, 1)
  658.                
  659.             local MarlaTalk = {"What!? Intruders!? In my chamber!?", 14,
  660.                                 "I will crush them with my mace!", 14,
  661.                                 "You traitorous pack can die now.", 12}
  662.             local timer = SM.NPCTalkSequence(Unit,MarlaTalk)
  663.            
  664.             SM.SCM.firewall[iID] = {}
  665.             Unit:RegisterEvent(function()
  666.                     table.insert(SM.SCM.firewall[iID], Unit:SpawnGameObject(SM.SCM.Objects.firewall, 232.89,-100.1,18.678,3.149,0,_, 1,0))
  667.                     table.insert(SM.SCM.firewall[iID], Unit:SpawnGameObject(SM.SCM.Objects.firewall, 286.56,-99.95,31.495,0,0,_, 1,0))
  668.                     for i=1, 2, 1 do
  669.                         SM.SCM.firewall[iID][i]:SetUnclickable()
  670.                     end
  671.                    
  672.                     Unit:CastSpell(SM.SCM.Spells.decoydestroy)
  673.                     Unit:RegisterEvent(function()
  674.                             Unit:DisableCombat(false)
  675.                             Unit:DisableTargeting(false)
  676.                             Unit:DisableMelee(false)
  677.                             Unit:RemoveAura(SM.SCM.Spells.invincible)
  678.                            
  679.                             Unit:RegisterEvent(SM.SCM.EventChoosing, 5000, 1)
  680.                         end, 2500, 1)
  681.                 end, timer-2000, 1)
  682.         end
  683.     end
  684. end
  685.  
  686. function SM.SCM.DecoyDestroyOpeningEvent(index, Spell)
  687.     local Unit = Spell:GetCaster()
  688.    
  689.     if Unit:IsPlayer() then return; end
  690.     if Unit:GetEntry()~=SM.scarletcommandermarlaid then return; end
  691.    
  692.     local iID = Unit:GetInstanceID()
  693.     if not iID then error("This NPC is not in an instance!") end
  694.    
  695.     local diff = IS.Spawned[iID].diff
  696.    
  697.     for num,unt in pairs(SM.SCM.decoys[iID]) do
  698.         Unit:Kill(unt)
  699.         if diff==4 then
  700.             unt:SpawnCreature(SM.commandermarlaburnedid, Unit:GetX(), Unit:GetY(), Unit:GetZ(), Unit:GetO(),14,0,  0,0,0,1,0)
  701.         end
  702.         unt:Despawn(0,0)
  703.     end
  704.     if diff~=1 then
  705.         Unit:SpawnCreature(SM.commadermarlafirewaveid, Unit:GetX(), Unit:GetY(), Unit:GetZ(), Unit:GetO(),35,0,  0,0,0,1,0)
  706.     end
  707. end
  708.  
  709. function SM.SCM.BurnedOnSpawn(Unit)
  710.     Unit:CastSpell(SM.SCM.Spells.burningaura)
  711. end
  712.  
  713. RegisterUnitEvent(SM.commandermarlaburnedid, 18, SM.SCM.BurnedOnSpawn)
  714.  
  715. function SM.SCM.FireWaveOnSpawn(Unit)
  716.     local iID = Unit:GetInstanceID()
  717.     if not iID then error("This NPC is not in an instance!") end
  718.    
  719.     local plrs = GetPlayersInInstance(44, iID)
  720.    
  721.     Unit:SetUInt32Value(59, 33554432)
  722.     Unit:RegisterEvent(function()
  723.             Unit:CastSpell(SM.SCM.Spells.firewave)
  724.         end, 200, 1)
  725.     Unit:RegisterEvent(function()
  726.             Unit:MoveTo(223.82,-100.1,18.01,0)
  727.             Unit:RegisterEvent(function()
  728.                     if not plrs then return; end
  729.                     for num,plr in pairs(plrs) do
  730.                         if plr:GetX()>Unit:GetX() and plr:GetX()<255 and plr:GetY()>-96 and plr:GetY()<-104 then
  731.                             if diff==2 and plr:GetHealthPct()>30 then
  732.                                 plr:SetHealthPct(plr:GetHealthPct()/2)
  733.                             else
  734.                                 Unit:Kill(plr)
  735.                             end
  736.                         end
  737.                     end
  738.                 end, 200, 10)
  739.             Unit:Despawn(2100,0)
  740.         end, 1000, 1)
  741. end
  742.  
  743. RegisterUnitEvent(SM.commadermarlafirewaveid, 18, SM.SCM.FireWaveOnSpawn)
  744.  
  745. RegisterDummySpell(SM.SCM.Spells.decoydestroy, SM.SCM.DecoyDestroyOpeningEvent)
  746.  
  747. function SM.SCM.OnLeave(Unit)
  748.     local iID = Unit:GetInstanceID()
  749.     if not iID then error("This NPC is not in an instance!") end
  750.    
  751.     SM.SCM.healthcheck[iID] = nil
  752.     Unit:RemoveAura(SM.SCM.Spells.burningaura)
  753.     Unit:ModifyRunSpeed(6)
  754.    
  755.     Unit:RemoveEvents()
  756.     for num, wall in pairs(SM.SCM.firewall[iID]) do
  757.         wall:Despawn(0,0)
  758.     end
  759.     SM.SCM.OnSpawn(Unit)
  760. end
  761.  
  762. function SM.SCM.EventChoosing(Unit)
  763.     local iID = Unit:GetInstanceID()
  764.     if not iID then error("This NPC is not in an instance!") end
  765.    
  766.     local diff = IS.Spawned[iID].diff
  767.    
  768.     if Unit:GetHealthPct()<50 and not SM.SCM.healthcheck[iID] then
  769.         Unit:DisableMelee(true)
  770.         SM.SCM.healthcheck[iID] = true
  771.         Unit:CastSpell(SM.SCM.Spells.burningaura)
  772.         local MarlaTalk = {"Argh! It burns!", 14,
  773.                             "Make it stop!", 14}
  774.         local timer = SM.NPCTalkSequence(Unit,MarlaTalk)
  775.         Unit:RegisterEvent(function() Unit:SetScale(1.5) end, 2000, 1)
  776.         Unit:RegisterEvent(function()
  777.                 Unit:DisableMelee(false)
  778.                 Unit:ModifyRunSpeed(5)
  779.                 Unit:RegisterEvent(SM.SCM.EventChoosing, 5000, 1)
  780.             end, timer, 1)
  781.            
  782.         Unit:RegisterEvent(SM.SCM.HealthCheckEnding, 2000, 0)
  783.         return;
  784.     end
  785.    
  786.     local rnd = 1
  787.     if not (diff~=2 and diff~=4) then
  788.         rnd = math.random(100)
  789.     end
  790.    
  791.     if rnd<95 then
  792.         rnd = 1
  793.         if SM.SCM.healthcheck[iID] then
  794.             rnd = math.random(2)
  795.         end
  796.        
  797.         local plrs = Unit:GetInRangePlayers()
  798.         for num,plr in pairs(plrs) do if plr:IsDead() then table.remove(plrs, num) end end
  799.         if not plrs then Unit:RemoveEvents() Unit:Despawn(0,10000) end
  800.         local rPlr = math.random(table.getn(plrs))
  801.        
  802.         if rnd==1 then
  803.             SM.SCM.target[iID] = plrs[rPlr]:SpawnCreature(SM.commandermarlafireballid, plrs[rPlr]:GetX(), plrs[rPlr]:GetY(), plrs[rPlr]:GetZ(), plrs[rPlr]:GetO(),35,0,  0,0,0,1,0)
  804.            
  805.             Unit:DisableMelee(true)
  806.             Unit:FullCastSpell(SM.SCM.Spells.fireballtrigger)
  807.         else
  808.             Unit:MoveJump(plrs[rPlr]:GetX(), plrs[rPlr]:GetY()+1, plrs[rPlr]:GetZ())
  809.             Unit:RegisterEvent(function()
  810.                     Unit:DisableMelee(true)
  811.                     Unit:CastSpell(SM.SCM.Spells.whirlwind)
  812.                     Unit:RegisterEvent(function()
  813.                             Unit:DisableMelee(false)
  814.                         end, 2000, 1)
  815.                     Unit:RegisterEvent(SM.SCM.EventChoosing, 5000, 1)
  816.                 end, ((Unit:GetDistance(plrs[rPlr])*3.2-(Unit:GetDistance(plrs[rPlr])-210))+1000), 1)
  817.         end
  818.     else
  819.         SM.SCM.flames[iID] = {}
  820.         Unit:MoveJump(255.135,-100.03,18.678)
  821.         Unit:DisableMelee(true)
  822.         local rnd = math.random(3)
  823.         if rnd==1 then
  824.             Unit:MonsterYell("Now feel the heat of the light that burns in me!")
  825.         elseif rnd==2 then
  826.             Unit:MonsterYell("Feel the burning light!")
  827.         else
  828.             Unit:MonsterYell("Fire burn my foes!")
  829.         end
  830.        
  831.         Unit:RegisterEvent(function()
  832.                 local plrs = Unit:GetInRangePlayers()
  833.                 for num,plr in pairs(plrs) do if plr:IsDead() then table.remove(plrs, num) end end
  834.                 if not plrs then Unit:RemoveEvents() Unit:Despawn(0,10000) end
  835.                
  836.                 for num,plr in pairs(plrs) do
  837.                     plr:MoveKnockback(Unit:GetX(), Unit:GetY(), Unit:GetZ(), 1, 3)
  838.                 end
  839.                 Unit:RegisterEvent(function()
  840.                         Unit:CastSpell(SM.SCM.Spells.lightfirechannel)
  841.                         local tick = 1
  842.                         Unit:RegisterEvent(function()
  843.                                 for num,plr in pairs(plrs) do
  844.                                     if plr:GetZ()<21 and plr:GetDistanceYards(Unit)<tick then
  845.                                         Unit:Kill(plr)
  846.                                     end
  847.                                 end
  848.                                
  849.                                 if tick==1 then
  850.                                     table.insert(SM.SCM.flames[iID], Unit:SpawnCreature(SM.commandermarladummyid, Unit:GetX(), Unit:GetY(), Unit:GetZ(), Unit:GetO(),35,0,  0,0,0,1,0))
  851.                                     SM.SCM.flames[iID][1]:SetUInt32Value(59, 33554432)
  852.                                 elseif tick<15 then
  853.                                     SM.SCM.flames[iID][1]:SetScale(tick*0.1667)
  854.                                 end
  855.                                
  856.                                 if tick==15 then
  857.                                     SM.SCM.flames[iID][1]:SetScale(tick)
  858.                                     tick = 1
  859.                                     Unit:EnableMoveFly()
  860.                                     table.insert(SM.SCM.flames[iID], Unit:SpawnCreature(SM.commandermarladummyid, Unit:GetX()+15, Unit:GetY(), Unit:GetZ(), 0, 35, 0,  0,0,0,1,0))
  861.                                     table.insert(SM.SCM.flames[iID], Unit:SpawnCreature(SM.commandermarladummyid, Unit:GetX()-15, Unit:GetY(), Unit:GetZ(), 0, 35, 0,  0,0,0,1,0))
  862.                                     table.insert(SM.SCM.flames[iID], Unit:SpawnCreature(SM.commandermarladummyid, Unit:GetX(), Unit:GetY()+15, Unit:GetZ(), 0, 35, 0,  0,0,0,1,0))
  863.                                     table.insert(SM.SCM.flames[iID], Unit:SpawnCreature(SM.commandermarladummyid, Unit:GetX(), Unit:GetY()-15, Unit:GetZ(), 0, 35, 0,  0,0,0,1,0))
  864.                                     for i=2, 5, 1 do
  865.                                         SM.SCM.flames[iID][i]:SetUInt32Value(59, 33554432)
  866.                                     end
  867.                                    
  868.                                     Unit:RegisterEvent(function()
  869.                                             for num,plr in pairs(plrs) do
  870.                                                 if plr:GetZ()<(21+tick) then
  871.                                                     Unit:Kill(plr)
  872.                                                 end
  873.                                             end
  874.                                            
  875.                                             if tick<6 then
  876.                                                 for i=6, 9, 1 do
  877.                                                     SM.SCM.flames[iID][i]:SetScale(tick/2)
  878.                                                 end
  879.                                             elseif tick==7 and diff==4 and Unit:GetHealthPct()<50 then
  880.                                                 local rPlr = math.random(table.getn(plrs))
  881.                                                 SM.SCM.target[iID] = plrs[rPlr]:SpawnCreature(SM.commandermarlafireballid, plrs[rPlr]:GetX(), plrs[rPlr]:GetY(), plrs[rPlr]:GetZ(), plrs[rPlr]:GetO(),35,0,  0,0,0,1,0)
  882.                                                
  883.                                                 Unit:FullCastSpell(SM.SCM.Spells.fireballtrigger)
  884.                                             end
  885.                                            
  886.                                             Unit:MoveKnockback(Unit:GetX(), Unit:GetY(), Unit:GetZ()+1, 1, 1)
  887.                                             if tick==7 then
  888.                                                 Unit:RemoveAura(SM.SCM.Spells.lightfirechannel)
  889.                                                 Unit:DisableMelee(false)
  890.                                                 Unit:Land()
  891.                                                 Unit:MoveKnockback(Unit:GetX(), Unit:GetY(), Unit:GetZ()-6, 1, 1)
  892.                                                
  893.                                                 for num,unt in pairs(SM.SCM.flames[iID]) do
  894.                                                     unt:Despawn(0,0)
  895.                                                 end
  896.                                                 SM.SCM.flames[iID] = nil
  897.                                                
  898.                                                 Unit:RegisterEvent(SM.SCM.EventChoosing, 5000, 1)
  899.                                             end
  900.                                            
  901.                                             tick = tick + 1
  902.                                         end, 1000, 7)
  903.                                 end
  904.                                
  905.                                 tick = tick + 1
  906.                             end, 200, 15)
  907.                     end, 3000, 1)
  908.             end, (Unit:CalcToDistance(255.135,-100.03,18.678)*100), 1)
  909.     end
  910. end
  911.  
  912. function SM.SCM.FireballSpellTrigger(index, Spell)
  913.     local Unit = Spell:GetCaster()
  914.    
  915.     if Unit:IsPlayer() then return; end
  916.     if Unit:GetEntry()~=SM.scarletcommandermarlaid then return; end
  917.    
  918.     local iID = Unit:GetInstanceID()
  919.     if not iID then error("This NPC is not in an instance!") end
  920.    
  921.     local diff = IS.Spawned[iID].diff
  922.    
  923.     local target = SM.SCM.target[iID]
  924.     if not target then return; end
  925.     local plrs = target:GetInRangePlayers()
  926.     for num,plr in pairs(plrs) do if plr:IsDead() then table.remove(plrs, num) end end
  927.     if not plrs then target:Despawn(0,0) end
  928.    
  929.     Unit:CastSpellOnTarget(SM.SCM.Spells.fireball, target)
  930.     Unit:RegisterEvent(function()
  931.             if target then
  932.                 target:RemoveAura(SM.SCM.Spells.fireballtarget)
  933.                 target:CastSpell(SM.SCM.Spells.fireballexplosion)
  934.                 for num,plr in pairs(plrs) do
  935.                     if plr:GetDistanceYards(target)<=3 then
  936.                         Unit:Kill(plr)
  937.                     end
  938.                 end
  939.                 target:RegisterEvent(function() target:Despawn(0,0) SM.SCM.target[iID] = nil; end, 3000, 1)
  940.             end
  941.             Unit:RegisterEvent(SM.SCM.EventChoosing, 5000, 1)
  942.         end, (Unit:GetDistance(target)*1.5), 1)
  943.     Unit:DisableMelee(false)
  944. end
  945. RegisterDummySpell(SM.SCM.Spells.fireballtrigger, SM.SCM.FireballSpellTrigger)
  946.  
  947. RegisterUnitEvent(SM.commandermarladummyid, 18, function(Unit) Unit:CastSpell(SM.SCM.Spells.lightfirepath) end)
  948. RegisterUnitEvent(SM.commandermarlafireballid, 18, function(Unit) Unit:CastSpell(SM.SCM.Spells.fireballtarget) Unit:SetUInt32Value(59, 33554432) end)
  949.  
  950. function SM.SCM.HealthCheckEnding(Unit)
  951.     local iID = Unit:GetInstanceID()
  952.     if not iID then error("This NPC is not in an instance!") end
  953.    
  954.     if Unit:GetHealthPct()<=5 then
  955.         Unit:RemoveEvents()
  956.         Unit:CancelSpell()
  957.         Unit:CastSpell(SM.SCM.Spells.invincible)
  958.         Unit:Emote(68, 15000)
  959.        
  960.         if SM.SCM.target[iID] then
  961.             SM.SCM.target[iID]:Despawn(0,0)
  962.         end
  963.        
  964.         Unit:DisableMelee(true)
  965.         local MarlaTalk = {"It hurts so much!", 14,
  966.                             "I can't take it anymore!", 14}
  967.         local timer = SM.NPCTalkSequence(Unit,MarlaTalk)
  968.        
  969.         Unit:RegisterEvent(function() Unit:Emote(391,1000) end, timer-1000, 1)
  970.         Unit:RegisterEvent(function()
  971.                 local plrs = Unit:GetInRangePlayers()
  972.                 if not plrs then Unit:Despawn(0,0) end
  973.                 plrs[1]:Kill(Unit)
  974.                
  975.                 for num,wall in pairs(SM.SCM.firewall[iID]) do
  976.                     wall:Despawn(0,0)
  977.                 end
  978.                 SM.SCM.firewall[iID] = nil
  979.                
  980.                 if SM.SCM.flames[iID] then
  981.                     for num,flame in pairs(SM.SCM.flames[iID]) do
  982.                         flame:Despawn(0,0)
  983.                     end
  984.                     SM.SCM.flames[iID] = nil
  985.                 end
  986.                 SM.SCM.healthcheck[iID] = nil
  987.             end, timer, 1)
  988.     else
  989.         Unit:SetHealthPct(Unit:GetHealthPct()-1)
  990.     end
  991. end
  992.  
  993. function SM.SCM.BurnedKnightOnSpawn(Unit)
  994.     Unit:CastSpell(SM.SCM.Spells.burningaura)
  995.     Unit:SetHealthPct(75)
  996. end
  997.  
  998. RegisterUnitEvent(SM.commandermarlaburnedid, 18, SM.SCM.BurnedKnightOnSpawn)
  999.  
  1000. function SM.SCM.OnDied(Unit)
  1001.     Unit:RemoveEvents()
  1002.     Unit:RegisterEvent(function()
  1003.             local herod = Unit:SpawnCreature(SM.herod, X###, Y###, Z###, O###, 14, 0,  0,0,0,1,0)
  1004.         end, 10000, 1)
  1005. end
  1006.  
  1007. RegisterUnitEvent(SM.scarletcommandermarlaid, 2, SM.SCM.OnLeave)
  1008. RegisterUnitEvent(SM.scarletcommandermarlaid, 4, SM.SCM.OnDied)
  1009. RegisterUnitEvent(SM.scarletcommandermarlaid, 18, SM.SCM.OnSpawn)
  1010.  
  1011. ----------------------------------------------------------------------
  1012. --                                                                  --
  1013. --                                                                  --
  1014. --------------------------3rd Boss-----Herod--------------------------
  1015.  
  1016. SM.SCM = {firewall = {},
  1017.         Spells = {
  1018. -- Spells which the boss and his minions will use
  1019. invincible = 52075},
  1020.  
  1021.         Objects = {
  1022. -- Gameobjects which are used while the boss
  1023. }}
  1024.  
  1025. function SM.H.OnSpawn(Unit)
  1026.     Unit:DisableCombat(true)
  1027.     Unit:DisableMelee(true)
  1028.     Unit:DisableTargeting(true)
  1029.     Unit:CastSpell(SM.H.Spells.invincible)
  1030.     Unit:SetMovementFlags(1)
  1031.    
  1032.     Unit:RegisterEvent(SM.H.AreaBossTrigger, 2000, 0)
  1033. end
  1034.  
  1035. function SM.H.AreaBossTrigger(Unit)
  1036.     local iID = Unit:GetInstanceID()
  1037.     if not iID then error("This NPC is not in an instance!") end
  1038.     local plrs = GetPlayersInInstance(44, iID)
  1039.     if plrs then
  1040.         local AreaCheck = false
  1041.         for num,plr in pairs(plrs) do
  1042.             if plr:GetX()>X### and plr:GetX()<X### and plr:GetY()<-Y### and plr:GetY()>-Y### then
  1043.                 AreaCheck = true
  1044.                 break;
  1045.             end
  1046.         end
  1047.         if AreaCheck then
  1048.             Unit:RemoveEvents()
  1049.             local HerodTalk = {"What's the meaning of this noise?",12,
  1050.                                 "Marla!",14,
  1051.                                 "You will pay for what you've done to my Marla!",14,
  1052.                                 "Burn in righteous fire!", 14}
  1053.             local timer = SM.NPCTalkSequence(Unit,HerodTalk)
  1054.             Unit:Emote(27,timer)
  1055.             Unit:RegisterEvent(SM.H.OpeningScene, timer, 1)
  1056.         end
  1057.     end
  1058. end
  1059.  
  1060. function SM.H.OpeningScene(Unit)
  1061.    
  1062. end
  1063.  
  1064. function SM.H.OnLeave(Unit)
  1065.    
  1066. end
  1067.  
  1068. RegisterUnitEvent(SM.herod, 2, SM.H.OnLeave)
  1069. RegisterUnitEvent(SM.herod, 4, function(Unit) Unit:RemoveEvents() end)
  1070. RegisterUnitEvent(SM.herod, 18, SM.H.OnSpawn)
  1071.  
  1072. ----------------------------------------------------------------------
  1073. --                                                                  --
  1074. --                                                                  --
  1075. ----------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement