stoneharry

Untitled

May 19th, 2012
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.24 KB | None | 0 0
  1.  
  2. local vehicle = nil
  3.  
  4. local BadlandsInfo = {}
  5.  
  6. function BranIronbeard_Gossip(pUnit, event, player)
  7.     pUnit:GossipCreateMenu(5914, player, 0)
  8.     pUnit:GossipMenuAddItem(9, "Transport me to Angor Stronghold.", 11, 0)
  9.     pUnit:GossipMenuAddItem(0, "Nevermind.", 3, 0)
  10.     pUnit:GossipSendMenu(player)
  11. end
  12.  
  13. function BranIronbeard_Click(pUnit, event, player, id, intid, code)
  14.     if(intid == 11) then
  15.         player:GossipComplete()
  16.         pUnit:SpawnAndEnterVehicle(28312, 1000)
  17.         RegisterTimedEvent("EnterVehicle_Unit", 1500, 1, pUnit)
  18.         RegisterTimedEvent("EnterVehicle_Player", 2000, 1, player)
  19.     end
  20.     if(intid == 3) then
  21.         player:GossipComplete()
  22.     end
  23. end
  24.  
  25. function EnterVehicle_Unit(pUnit)
  26.     if pUnit ~= nil then
  27.         vehicle = pUnit:GetCreatureNearestCoords(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 28319) -- turret
  28.     end
  29. end
  30.  
  31. function EnterVehicle_Player(plr)
  32.     if vehicle ~= nil then
  33.         if plr ~= nil then
  34.             vehicle:AddPassenger(plr)
  35.         end
  36.     end
  37. end
  38.  
  39. RegisterUnitGossipEvent(69951, 1, "BranIronbeard_Gossip")
  40. RegisterUnitGossipEvent(69951, 2, "BranIronbeard_Click")
  41.  
  42.  
  43. function Badlands_QuestVehicle(pUnit, event)
  44.     pUnit:RegisterEvent("CheckForQuestStartbadlads", 5000, 0)
  45. end
  46.  
  47. function CheckForQuestStartbadlads(pUnit)
  48.     if vehicle ~= nil and pUnit:GetVehicleBase() ~= nil then
  49.         pUnit:RemoveEvents()
  50.         BadlandsInfo[tostring(pUnit)] = {
  51.             track = 1,
  52.             racecount = 1,
  53.             player = pUnit:GetClosestPlayer(),
  54.             vehicle = vehicle
  55.         }
  56.         vehicle = nil
  57.         pUnit:RegisterEvent("Balands_TrackGo", 3000, 1)
  58.     end
  59. end
  60.  
  61. RegisterUnitEvent(69951, 18, "Badlands_QuestVehicle")
  62.  
  63. BalandsLocations = {-- in format as x, y, z, o, registertime, optional message
  64.     {
  65.         {-6951, -2355, 240.8, 0, 7000, "Don't conserve ammunition; there are much more dangerous things to worry about out here."},
  66.         {-6986, -2390, 240.8, 0, 5000},
  67.         {-6961, -2455, 240.8, 0, 5000},
  68.         {-6920, -2515, 240.8, 0, 7000},
  69.         {-6837, -2580, 240.8, 0, 4500},
  70.         {-6832, -2589, 240.8, 0, 5500},
  71.         {-6785, -2633, 241.12, 0, 5500, "Were entering the Dustbowl, ready the turret!"},
  72.         {-6707, -2685, 241.7, 0, 7000},
  73.         {-6688, -2766, 241.7, 0, 7000},
  74.         {-6661, -2856, 242.7, 0, 8500},
  75.         {-6661, -2908, 241.5, 0, 5500},
  76.         {-6545, -3001, 255.8, 0, 13000},
  77.         {-6549.77, -3016.43, 258.96, 0, 500, "Approaching Angor Fortress now."},
  78.         {-6547.5, -3053.85, 267.3, 0, 3000},
  79.         {-6544, -3107.8, 266.3, 0, 6000},
  80.         {-6553, -3202, 249.7, 0, 8000},
  81.         {-6549, -3214, 247.4, 0, 500},
  82.         {-6550.6, -3210.2, 248.2, 0, 500},
  83.         {-6532.8, -3229, 245.5, 0, 500},
  84.         {-6518, -3230.9, 245.7, 0, 500},
  85.         {-6505, -3224.8, 248.3, 0, 500},
  86.         {-6482.95, -3220.82, 250.7, 0, 2000},
  87.         {-6450, -3208.4, 260, 0, 3000},
  88.         {-6399, -3168, 300, 0, 10000, "We're here!"},
  89.         {1, 1, 1, 1, 1, "Good luck."}
  90.     }
  91. }
  92.  
  93. function Balands_TrackGo(pUnit)
  94.     -- The message to be sent
  95.     --print(BadlandsInfo[tostring(pUnit)].racecount)
  96.     if BalandsLocations[BadlandsInfo[tostring(pUnit)].track][BadlandsInfo[tostring(pUnit)].racecount][6] ~= nil then
  97.         pUnit:SendChatMessage(12, 0, BalandsLocations[BadlandsInfo[tostring(pUnit)].track][BadlandsInfo[tostring(pUnit)].racecount][6])
  98.     end
  99.     if BadlandsInfo[tostring(pUnit)].racecount == #BalandsLocations[BadlandsInfo[tostring(pUnit)].track] then
  100.         -- Were done
  101.         if BadlandsInfo[tostring(pUnit)].player ~= nil then
  102.             BadlandsInfo[tostring(pUnit)].player:SendBroadcastMessage("Test complete")
  103.         end
  104.         if BadlandsInfo[tostring(pUnit)].vehicle ~= nil then
  105.             BadlandsInfo[tostring(pUnit)].vehicle:EjectAllPassengers()
  106.         end
  107.         pUnit:DismissVehicle()
  108.         pUnit:Despawn(1000, 1000)
  109.         return
  110.     end
  111.     pUnit:GetVehicleBase():MoveTo(BalandsLocations[BadlandsInfo[tostring(pUnit)].track][BadlandsInfo[tostring(pUnit)].racecount][1],BalandsLocations[BadlandsInfo[tostring(pUnit)].track][BadlandsInfo[tostring(pUnit)].racecount][2],BalandsLocations[BadlandsInfo[tostring(pUnit)].track][BadlandsInfo[tostring(pUnit)].racecount][3],BalandsLocations[BadlandsInfo[tostring(pUnit)].track][BadlandsInfo[tostring(pUnit)].racecount][4])
  112.     -- Register the event again (recursion)
  113.     pUnit:RegisterEvent("Balands_TrackGo", BalandsLocations[BadlandsInfo[tostring(pUnit)].track][BadlandsInfo[tostring(pUnit)].racecount][5], 1)
  114.     -- Add to the counter
  115.     BadlandsInfo[tostring(pUnit)].racecount = BadlandsInfo[tostring(pUnit)].racecount + 1
  116. end
Advertisement
Add Comment
Please, Sign In to add comment