Advertisement
Guest User

Untitled

a guest
Jul 15th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.93 KB | None | 0 0
  1. -- The script was fixed and made working by Rochet2 of AcWeb
  2.  
  3. local T = {} -- The script saves info about whether the script is running in an instance or not
  4. Whitemane =
  5.  
  6. function Spawnzzz(pUnit, event)
  7.     Whitemane = pUnit
  8. end
  9.  
  10. -- First quest outside, it just gives the player some food and water
  11. function OnQuestAccept_Whitemane90000(event, pPlayer, QuestId, pUnit)
  12.     if QuestId == 90000 then
  13.         pPlayer:AddItem(159, 4)
  14.         pPlayer:AddItem(4540, 4)
  15.     end
  16. end
  17.  
  18. -- First quest inside
  19. function OnQuestComplete_Whitemane90001(event, pPlayer, QuestId, pUnit)
  20.     local ID = pUnit:GetInstanceID() -- Get the instance ID for the table that saves data for the spesific instances.
  21.     if(QuestId == 90001 and not T[ID]) then -- If the quest completed is 90001 and none of the other quests have been done and they are not running, then
  22.         local Whitemane = pPlayer:GetCreatureNearestCoords(199.408005, 121.653, 134.910004, 90010)
  23.         if(Whitemane) then --If the selected npc is Whitemane the script continues.
  24.             T[ID] = {1, true} -- Save that quest 1 was activated and that it is running. NOTE! The quests should be chained and the NPCs spawned to the right positions with the right quests
  25.             Whitemane:SetNPCFlags(4) -- Disable talking and make the NPC not be able to give or complete quests while walking and talking
  26.             Whitemane:SendChatMessage(12, 7, "Follow me.")
  27.             local Player = Whitemane:GetClosestPlayer()
  28.             Player:CastSpellOnTarget(5406, Whitemane:GetClosestPlayer())
  29.             Player:CastSpellOnTarget(49, Whitemane:GetClosestPlayer())
  30.             Whitemane:RegisterEvent("Move01_Whitemane90001", 1000, 1) --In 1 second "1000ms" the function "Move01_Whitemane" will run.
  31.         end
  32.     end
  33. end
  34.  
  35. function Move01_Whitemane90001(Whitemane, event)
  36.     Whitemane:MoveTo(199.556656, 108.91169, 128.522507, 4.753242)
  37.     Whitemane:RegisterEvent("Move02_Whitemane90001", 4000, 1)
  38. end
  39.  
  40. function Move02_Whitemane90001(Whitemane, event)
  41.     Whitemane:MoveTo(201.447388, 52.051525, 128.766281, 4.742254)
  42.     Whitemane:RegisterEvent("Move03_Whitemane90001", 24000, 1)
  43. end
  44.  
  45. function Move03_Whitemane90001(Whitemane, event)
  46.     Whitemane:MoveTo(209.785873, 51.152771, 128.840088, 6.267476)
  47.     Whitemane:RegisterEvent("Move04_Whitemane90001", 3000, 1)
  48. end
  49.  
  50. function Move04_Whitemane90001(Whitemane, event)
  51.     Whitemane:MoveTo(236.721359, 50.011505, 115.708603, 0.027489)
  52.     Whitemane:RegisterEvent("Move05_Whitemane90001", 12000, 1)
  53. end
  54.  
  55. function Move05_Whitemane90001(Whitemane, event)
  56.     Whitemane:MoveTo(233.375031, 41.485565, 115.707848, 4.374668)
  57.     Whitemane:RegisterEvent("Move06_Whitemane90001", 3000, 1)
  58. end
  59.  
  60. function Move06_Whitemane90001(Whitemane, event)
  61.     Whitemane:MoveTo(201.992569, 12.324375, 115.707878, 1.586526)
  62.     Whitemane:RegisterEvent("Talk01_Whitemane90001", 19000, 1)
  63. end
  64.  
  65. function Talk01_Whitemane90001(Whitemane, event)
  66.     Whitemane:SendChatMessage(12, 7, "Here we are, speak with me to begin your next test.")
  67.     Whitemane:SetNPCFlags(3) -- Set the NPC to be able to give quests and talk again.
  68.     T[Whitemane:GetInstanceID()][2] = false -- You can now launch the next quest
  69.     -- !!NOTE!! You can no longer start or restart quest 1.
  70. end
  71.  
  72.  
  73. -- Second quest
  74. function OnQuestAccept_Whitemane90002(event, pPlayer, QuestId, pUnit)
  75.     local ID = pUnit:GetInstanceID() -- Get the instance ID for the table that saves data for the spesific instances.
  76.     if(QuestId == 90002 and T[ID] and T[ID][1] == 1 and T[ID][2] == false) then -- If the quest accepted is 90002 and quest 90001 has been completed in the instance, then
  77.         T[ID] = {2, true, 0} -- Save that quest 2 was activated and that it is running. NOTE! The quests should be chained and the NPCs spawned to the right positions with the right quests. The 0 is for counting the killed undead, when it hits 5 the event finished down below.
  78.         pUnit:RegisterEvent("Quest01_Whitemane90002", 5000, 1) -- We use the questgiver (pUnit) to register events since we need him later to do stuff in the script
  79.     end
  80. end
  81.  
  82. function Quest01_Whitemane90002(Whitemane, event)
  83.     local Portal = Whitemane:SpawnCreature(37227, 200.697739, 59.384331, 115.708244, 1.576423, 694, 180000, 0, 0, 0, 1, 0) -- Spawns the portal
  84.     Whitemane:SendChatMessage(42, 0, "The undead are coming, prepare yourself!") -- Questgiver says
  85.     Whitemane:RegisterEvent("Spawn_Timer_Whitemane90002", 4000, 1) -- Spawns an NPC after 4 seconds
  86. end
  87.  
  88. function Spawn_Timer_Whitemane90002(Whitemane, event)
  89.     Whitemane:RegisterEvent("Spawn01_Whitemane90002", 13000, 5) -- Spawn an NPC after 13 seconds 4 times.
  90. end
  91.  
  92. function Spawn01_Whitemane90002(Whitemane, event) -- The function that spawns the NPCs
  93.     Whitemane:SpawnCreature(90012, 200.697739, 59.384331, 115.708244, 4.644086, 14, 120000, 0, 0, 0, 1, 0) -- Sets the spawned creature to the MindlessGhoul variable. (locally, so it will only exist in this function. The variable I mean.)
  94.     Whitemane:RegisterEvent("Move_Ghoul90002", 2000, 1)
  95. end
  96.  
  97. function Move_Ghoul90002(Whitemane, event) -- Sends the spawned Ghoul closer to Whitemane as to make the player engage combat
  98.     local Ghoul = Whitemane:GetCreatureNearestCoords(200.697739, 59.384331, 115.708244, 90012)
  99.     Ghoul:MoveTo(201.975159, 21.787292, 114.983719, 4.718697)
  100. end
  101.  
  102. function Spawn_On_Death(pUnit, event, pPlayer)
  103.     local ID = pUnit:GetInstanceID()
  104.     if(T[ID] and T[ID][1] == 2 and T[ID][2] == true and T[ID][3]) then
  105.         T[ID][3] = T[ID][3] + 1
  106.         if(T[ID][3] >= 5) then
  107.             local Whitemane = pPlayer:GetCreatureNearestCoords(201.992569, 12.324375, 115.707878, 90010)
  108.             local Portal = Whitemane:GetCreatureNearestCoords(200.697739, 59.384331, 115.708244, 37227)
  109.             Portal:Despawn(1000, 0)
  110.             Whitemane:SendChatMessage(12, 7, "On to the next test, follow me.")
  111.             local Player = Whitemane:GetClosestPlayer()
  112.             Player:CastSpellOnTarget(5406, Whitemane:GetClosestPlayer())
  113.             Player:CastSpellOnTarget(49, Whitemane:GetClosestPlayer())
  114.             Whitemane:SetNPCFlags(4) -- Disable talking and make the NPC not be able to give or complete quests while walking and talking
  115.             Whitemane:RegisterEvent("Move01_Whitemane90002", 1000, 1)
  116.         end
  117.     end
  118. end
  119.  
  120. function Move01_Whitemane90002(Whitemane, event)
  121.     Whitemane:MoveTo(247.740143, 37.573757, 115.717438, 0.002345)
  122.     Whitemane:RegisterEvent("Move02_Whitemane90002", 21000, 1)
  123. end
  124.  
  125. function Move02_Whitemane90002(Whitemane, event)
  126.     Whitemane:MoveTo(262.464417, 37.656471, 115.727440, 1.606948)
  127.     Whitemane:RegisterEvent("Move03_Whitemane90002", 6000, 1)
  128. end
  129.  
  130. function Move03_Whitemane90002(Whitemane, event)
  131.     Whitemane:MoveTo(262.334930, 60.696800, 109.974747, 1.598312)
  132.     Whitemane:RegisterEvent("Move04_Whitemane90002", 7000, 1)
  133. end
  134.  
  135. function Move04_Whitemane90002(Whitemane, event)
  136.     Whitemane:MoveTo(262.259644, 101.386047, 109.971985, 1.610067)
  137.     Whitemane:RegisterEvent("Move05_Whitemane90002", 20000, 1)
  138. end
  139.  
  140. function Move05_Whitemane90002(Whitemane, event)
  141.     Whitemane:SetNPCFlags(3)
  142.     Whitemane:SendChatMessage(12, 7, "Here we are, don't worry about the Necromancers they won't attack you for now...")
  143. end
  144.  
  145. -------------Everything Below here is untested and probably not working as intended-----------------
  146.  
  147. function OnQuestAccept_Whitemane90003(event, pPlayer, QuestId, pUnit)
  148.     if QuestId == 90003 then
  149.         local Whitemane = pPlayer:GetCreatureNearestCoords(262.259644, 101.386047, 109.971985, 90010)
  150.         Whitemane:SendChatMessage(42, 0, "The Necromancers have been released!")
  151.         Whitemane:SetFaction(11)
  152.         Whitemane:CastSpell(43202)
  153.         pUnit:RegisterEvent("Spawn_Timer_Whitemane90003", 5000, 1) -- We use the questgiver (pUnit) to register events since we need him later to do stuff in the script
  154.     end
  155. end
  156.  
  157. function Spawn_Timer_Whitemane90003(Whitemane, event)
  158.     Whitemane:RegisterEvent("Whitemane_Spell90003", 10000, 2)
  159.     Whitemane:RegisterEvent("Spawn_Whitemane90003", 2000, 20) -- Spawn an NPC after 2 seconds 19 times.
  160. end
  161.  
  162. function Whitemane_Spell90003(Whitemane, event)
  163.     Whitemane:FullCastSpell(26573)
  164. end
  165.  
  166. function Spawn_Whitemane90003(Whitemane, event)
  167. local choice = math.random(1,6)
  168. if choice ==1 then
  169.     Whitemane:SpawnCreature(90034, 246.671005, 81.976799, 110.250999, 0.931493, 14, 120000, 0, 0, 0, 1, 0)
  170.     local Minion = Whitemane:GetCreatureNearestCoords(246.671005, 81.976799, 110.250999, 90034)
  171.     Minion:ModThreat(Whitemane, 100)
  172. else if choice == 2 then
  173.     Whitemane:SpawnCreature(90034, 247.867828, 84.609749, 109.903709, 0.862092, 14, 120000, 0, 0, 0, 1, 0)
  174.     local Minion = Whitemane:GetCreatureNearestCoords(247.867828, 84.609749, 109.903709, 90034)
  175.     Minion:ModThreat(Whitemane, 100)
  176. else if choice == 3 then
  177.     Whitemane:SpawnCreature(90034, 247.351852, 101.655975, 110.166222, 6.175311, 14, 120000, 0, 0, 0, 1, 0)
  178.     local Minion = Whitemane:GetCreatureNearestCoords(247.351852, 101.655975, 110.166222, 90034)
  179.     Minion:ModThreat(Whitemane, 100)
  180. else if choice == 4 then
  181.     Whitemane:SpawnCreature(90034, 275.648315, 101.904953, 109.98517, 3.175088, 14, 120000, 0, 0, 0, 1, 0)
  182.     local Minion = Whitemane:GetCreatureNearestCoords(275.648315, 101.904953, 109.98517, 90034)
  183.     Minion:ModThreat(Whitemane, 100)
  184. else if choice == 5 then
  185.     Whitemane:SpawnCreature(90034, 246.627472, 118.120979, 110.091766, 5.504576, 14, 120000, 0, 0, 0, 1, 0)
  186.     local Minion = Whitemane:GetCreatureNearestCoords(246.627472, 118.120979, 110.091766, 90034)
  187.     Minion:ModThreat(Whitemane, 100)
  188. else if choice == 6 then
  189.     Whitemane:SpawnCreature(90034, 275.929443, 118.208099, 109.920647, 3.988760, 14, 120000, 0, 0, 0, 1, 0)
  190.     local Minion = Whitemane:GetCreatureNearestCoords(275.929443, 118.208099, 109.920647, 90034)
  191.     Minion:ModThreat(Whitemane, 100)
  192.  
  193. --[[
  194. function END_Whitemane90001(pUnit) -- DO NOT RUN THIS UNTIL THE PLAYER HAS FINISHED THE ENTIRE QUEST CHAIN
  195.     pUnit:Despawn(0, 0)
  196.     table.remove(T, ID) -- Quest chain can now be re-triggered
  197. end
  198. ]]
  199.  
  200. RegisterServerHook(14, "OnQuestAccept_Whitemane90000")
  201. RegisterServerHook(14, "OnQuestAccept_Whitemane90002")
  202. RegisterServerHook(14, "OnQuestAccept_Whitemane90003")
  203. RegisterServerHook(22, "OnQuestComplete_Whitemane90001")
  204. RegisterUnitEvent(90012, 4, "Spawn_On_Death")
  205. RegisterUnitEvent(90010, 18, "Spawnzzz") -- This allows the use of :RegisterEvent() for Whitemane
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement