stoneharry

Untitled

May 19th, 2012
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 32.19 KB | None | 0 0
  1. ------------------------------------------------------------------------------------------------------------------------------------------------
  2. --[[
  3.     Main Event Handler
  4.         By Stoneharry
  5. ]]
  6. -------------------------------------------------------------------------------------------------------
  7. -- Variable Decleration  ------------------------------------------------------------------------------
  8. -------------------------------------------------------------------------------------------------------
  9.  
  10. local Selection = nil           -- Our control unit
  11. local DoorA = nil               -- Main gate
  12. local DoorB = nil               -- Second gate
  13. local Guard = nil               -- Guard that comes
  14. local Amount = 0                -- The amount of prisoners rescued, starts at 0 and automatically counts up
  15. local Ready = false             -- When ready this will automatically go to true (when all requirements to move on is met)
  16. local door_a = nil              -- Doors of the main cooridor
  17. local door_b = nil              -- Doors of the main cooridor
  18. local door_c = nil              -- Doors of the main cooridor
  19. local door_d = nil              -- Doors of the main cooridor
  20. local door_e = nil              -- Doors of the main cooridor
  21. local npc_a = nil               -- Prisoner to release
  22. local npc_b = nil               -- Prisoner to release
  23. local npc_c = nil               -- Prisoner to release
  24. local Grim = nil                -- Grim Ironbeard, the guy who kills the prisoner
  25. local COUNT_DOWN = 0            -- Time till bomb explodes, used for counting message to display
  26. local DISTANCE_HANDLER = nil    -- The npc to handle the bomb explosion
  27. --[[
  28.     Map:
  29.     gates a-e are triggered by levers
  30.     a-c = npc's in them
  31.     d = has pile of rocks which need to be blown up by bombs from warden
  32.                     _________
  33.                     ¦ start ¦
  34.                     ¦__   __¦
  35.         To Stormwind  _¦ ¦_
  36.                 ^   b¦_   _¦a
  37.         ______¦      ¦____¦ ¦_
  38.         ¦_____    __d¦_   _¦c           ___________
  39.               ¦__¦       ¦_¦       __    ¦           ¦
  40.                     ___ e ___   ¦  ¦   ¦           ¦
  41.                     ¦      ¦___¦  ¦___¦           ¦
  42.                     ¦___________    ___   warden   ¦
  43.                                 ¦  ¦   ¦           ¦
  44.                                 ¦__¦   ¦           ¦
  45.                                        ¦___________¦
  46. ]]
  47. ------------------------------------------------------------------------------------------------------------------------------------------------
  48. -- Part A: Following the lead of the prisoner you were stuck with ------------------------------------------------------------------------------
  49. ------------------------------------------------------------------------------------------------------------------------------------------------
  50. -------------------------------------------------------------------------------------------------------
  51. -- The Prisoner ---------------------------------------------------------------------------------------
  52. -------------------------------------------------------------------------------------------------------
  53.  
  54. function Bodyguard_Onspawn(pUnit, Event)
  55.     pUnit:RegisterEvent("wait_a_sec_body", 1000, 0)
  56. end
  57.  
  58. function wait_a_sec_body(pUnit)
  59.     local plr = pUnit:GetClosestPlayer()
  60.     if plr ~= nil then
  61.         if plr:GetSelection() ~= nil then
  62.             if plr:GetSelection():GetEntry() == 170611 then
  63.             pUnit:RemoveEvents()
  64.             Selection = pUnit
  65.             Selection:SetFaction(35)
  66.             Selection:SendChatMessage(12,0,"Ah, so you're awake "..plr:GetName()..", it's about time. The warden will be here soon, don't give him any reason to make your life difficult.")
  67.             Selection:SpawnCreature(46921, -12.8, 102.3, -39.134, 4.75, 15, 0)
  68.             end
  69.         end
  70.     end
  71. end
  72.  
  73. RegisterUnitEvent(170611, 18, "Bodyguard_Onspawn")
  74.  
  75. -- Warden
  76.  
  77. function Warden_OnSpawn(pUnit, Event)
  78.     pUnit:RegisterEvent("HangONAMo", 1000, 1)
  79. end
  80.  
  81. function HangONAMo(pUnit)
  82.     pUnit:MoveTo(-12.7, 79.5, -39.134, 0)
  83.     pUnit:EquipWeapons(1975, 0, 0)
  84.     pUnit:RegisterEvent("zzHangONAMo", 9000, 1)
  85. end
  86.  
  87. function zzHangONAMo(pUnit)
  88.     DoorA:SetByte(0x0006+0x000B,0,0) -- Open
  89.     pUnit:RegisterEvent("zzzHangONAMo", 2000, 1)
  90. end
  91.  
  92. function zzzHangONAMo(pUnit)
  93.     pUnit:MoveTo(-12.6, 72.3, -39.134, 0)
  94.     pUnit:RegisterEvent("zzzzHangONAMo", 2500, 1)
  95. end
  96.  
  97. function zzzzHangONAMo(pUnit)
  98.     pUnit:SendChatMessage(12,0,"So you worthless scum, how much longer do you think you will survive in here? There is no way to escape, nobody has ever escaped from here.")
  99.     pUnit:Emote(1,3000)
  100.     pUnit:RegisterEvent("zzzzHangONAMoemote", 3001, 1)
  101.     pUnit:RegisterEvent("zzzzHangONAMoemotetw", 6000, 1)
  102.     pUnit:RegisterEvent("zzzzHangONAMoemotetwzzz", 9100, 1)
  103.     pUnit:RegisterEvent("zzzzHangONAMoemotzzetwzzz", 14100, 1)
  104. end
  105.  
  106. function zzzzHangONAMoemote(pUnit)
  107.     pUnit:Emote(5, 2000)
  108. end
  109.  
  110. function zzzzHangONAMoemotetw(pUnit)
  111.     pUnit:Emote(11, 3000)
  112. end
  113.  
  114. function zzzzHangONAMoemotetwzzz(pUnit)
  115.     pUnit:ReturnToSpawnPoint()
  116. end
  117.  
  118. function zzzzHangONAMoemotzzetwzzz(pUnit, Event)
  119.     DoorA:SetByte(0x0006+0x000B,0,1) -- Close
  120.     Selection:RegisterEvent("X_EAJOEAT", 7001, 1)
  121.     pUnit:Despawn(5000, 0)
  122. end
  123.  
  124. -- Prisoner
  125.  
  126. function X_EAJOEAT(pUnit)
  127.     Selection:Emote(23, 2500)
  128.     Selection:SendChatMessage(12,0,"He didn't notice that the key was missing!")
  129.     Selection:RegisterEvent("aeogueajgoea", 4000, 1)
  130. end
  131.  
  132. function aeogueajgoea(pUnit)
  133.     Selection:MoveTo(-10.8, 67.4, -39.134, 0)
  134.     Selection:RegisterEvent("aeogueajzzgoea", 1500, 1)
  135. end
  136.  
  137. function aeogueajzzgoea(pUnit)
  138.     Selection:Emote(69, 5000)
  139.     Selection:RegisterEvent("aeogueazzjzzgoea", 5000, 1)
  140.     Selection:RegisterEvent("aeogueazzjzzgosssea", 7400, 1)
  141. end
  142.  
  143. function aeogueazzjzzgoea(pUnit)
  144.     DoorB:SetByte(0x0006+0x000B,0,0) -- Open
  145. end
  146.  
  147. function aeogueazzjzzgosssea(pUnit)
  148.     Selection:Emote(4, 2500)
  149.     Selection:SendChatMessage(12,0,"I'm good!")
  150.     Selection:SetMovementFlags(1)
  151.     Selection:RegisterEvent("testjeszzztS", 4200, 1)
  152.     Selection:RegisterEvent("testjeszzzzztS", 6000, 1)
  153.     Selection:RegisterEvent("testjeszzzzztSzz", 10000, 1)
  154. end
  155.  
  156. function testjeszzztS(pUnit)
  157.     Selection:SendChatMessage(12,0,"I'll distract the guard and you hit him from behind!")
  158.     Selection:MoveTo(-12.62, 70.4, -39.134, 1.4)
  159. end
  160.  
  161. function testjeszzzzztS(pUnit)
  162.     Selection:MoveTo(-12.6, 73.6, -39.2, 1.5)
  163. end
  164.  
  165. function testjeszzzzztSzz(pUnit)
  166.     Selection:SendChatMessage(14,0,"Oi! Check out some of this!")
  167.     Selection:Emote(5, 2000)
  168.     Selection:RegisterEvent("testjeszzzzztzzzSzz", 3001, 1)
  169. end
  170.  
  171. function testjeszzzzztzzzSzz(pUnit)
  172.     Selection:Emote(10, 30000)
  173.     Selection:SpawnCreature(325811, -12.31, 99.48, -39.134, 4.68556, 15, 0)
  174. end
  175.  
  176. -- Warden
  177.  
  178. RegisterUnitEvent(46921, 18, "Warden_OnSpawn")
  179.  
  180. function Warden_Oncombat(pUnit, Event)
  181.     pUnit:RemoveEvents()
  182.     pUnit:SendChatMessage(12,0,"You dare attack me?!")
  183.     DoorA:SetByte(0x0006+0x000B,0,1) -- Close
  184.     Selection:RegisterEvent("Bodyguard_Onspawn", 10000, 1)
  185.     pUnit:Despawn(10000, 0)
  186. end
  187.  
  188. RegisterUnitEvent(46921, 1, "Warden_Oncombat")
  189.  
  190. -- Guard that comes running
  191.  
  192. function Guard_On_Spawn_Prison_Watch(pUnit, Event)
  193.     pUnit:RegisterEvent("Hangonasecond_eaojte_prisonguard",1000,1)
  194. end
  195.  
  196. function Hangonasecond_eaojte_prisonguard(pUnit)
  197.     pUnit:EquipWeapons(1817,1200,0)
  198.     pUnit:SendChatMessage(14,0,"What are you doing out of your cell! Get back in there!")
  199.     Selection:SendChatMessage(15,0,"He's coming, hit him from behind when he comes in!")
  200.     pUnit:SetMovementFlags(1)
  201.     pUnit:MoveTo(-12.4, 82.14, -39.134, 0)
  202.     pUnit:RegisterEvent("DOOR_SPAM_TEHE", 4000, 1)
  203.     pUnit:RegisterEvent("DOOR_SPAM_TzzEHE", 6000, 1)
  204.     pUnit:RegisterEvent("eaghipheaaaengzz_testjs_zgjo", 9000, 1)
  205. end
  206.  
  207. function DOOR_SPAM_TEHE(pUnit)
  208.     DoorA:SetByte(0x0006+0x000B,0,0) -- Open
  209. end
  210.  
  211. function DOOR_SPAM_TzzEHE(pUnit)
  212.     pUnit:AttackReaction(Selection, 1, 0)
  213. end
  214.  
  215. function eaghipheaaaengzz_testjs_zgjo(pUnit)
  216.     Selection:CastSpellOnTarget(5165, pUnit)
  217.     Selection:SendChatMessage(12,0,"Finish him!")
  218.     Guard = pUnit
  219.     Selection:RegisterEvent("Check_For_Death_Tehe_Tehe_tehe", 2500, 0)
  220. end
  221.  
  222. function Check_For_Death_Tehe_Tehe_tehe(pUnit)
  223.     if Guard:IsAlive() == false then
  224.     Selection:RemoveEvents()
  225.     Selection:Emote(16, 3000)
  226.     Selection:RegisterEvent("etsutiea_eahitea_equip_weapons", 1500, 1)
  227.     Selection:RegisterEvent("etsutiea_eahitea_equip_weapozzns", 4000, 1)
  228.     end
  229. end
  230.  
  231. -- Prisoner
  232.  
  233. function etsutiea_eahitea_equip_weapons(pUnit)
  234.     Selection:EquipWeapons(1817,1200,0)
  235.     Guard:EquipWeapons(0,0,0)
  236. end
  237.  
  238. function etsutiea_eahitea_equip_weapozzns(pUnit)
  239.     Guard = nil
  240.     Selection:SendChatMessage(12, 0, "Free the rest of the prisoners and get yourself a weapon; once you have done that come get me so we can get out of here.")
  241.     Selection:SetMovementFlags(0)
  242.     Selection:MoveTo(-12.6, 80.35, -39.134, 0)
  243.     Selection:SetNPCFlags(1) -- talkable
  244.     Selection:RegisterEvent("Check_For_Whether_We_Can_Move_On_SELEC", 4000, 0)
  245. end
  246.  
  247. RegisterUnitEvent(325811, 18, "Guard_On_Spawn_Prison_Watch")
  248.  
  249. -------------------------------------------------------------------------------------------------------
  250. -- Prisoner's Gossip ----------------------------------------------------------------------------------
  251. -------------------------------------------------------------------------------------------------------
  252.  
  253. function zzzWolly_On_Gossip(pUnit, event, player)
  254.     pUnit:GossipCreateMenu(738, player, 0)
  255.     if Amount == 3 and player:HasItem(25228) then
  256.     pUnit:GossipMenuAddItem(0, "I have rescued all the prisoners and got a weapon.", 246, 0)
  257.     end
  258.     pUnit:GossipMenuAddItem(0, "Were not ready yet.", 250, 0)
  259.     pUnit:GossipSendMenu(player)
  260. end
  261.  
  262.  
  263. function zzzWolly_Gossip_Submenus(pUnit, event, player, id, intid, code)
  264.     if(intid == 246) then
  265.     Amount = 0
  266.     Selection:SetNPCFlags(2) -- 0 is bugged so quest flags (untalkable)
  267.     Ready = true
  268.     player:GossipComplete()
  269.     end
  270.     if(intid == 250) then
  271.     player:GossipComplete()
  272.     end
  273. end
  274.  
  275. RegisterUnitGossipEvent(170611, 1, "zzzWolly_On_Gossip")
  276. RegisterUnitGossipEvent(170611, 2, "zzzWolly_Gossip_Submenus")
  277.  
  278. -------------------------------------------------------------------------------------------------------
  279. -- Prisoner Jailbreak ---------------------------------------------------------------------------------
  280. -------------------------------------------------------------------------------------------------------
  281.  
  282. function Check_For_Whether_We_Can_Move_On_SELEC(pUnit)
  283.     if Ready == true then
  284.     Ready = false
  285.     Selection:RemoveEvents()
  286.     Selection:SendChatMessage(12,0,"Right, let's do this.")
  287.     Selection:Emote(5, 2000)
  288.     Selection:RegisterEvent("move_on_to_next_part_Opening_last_Gate", 3000, 1)
  289.     end
  290. end
  291.  
  292. function move_on_to_next_part_Opening_last_Gate(pUnit)
  293.     Selection:SetMovementFlags(1)
  294.     Selection:MoveTo(-12.5, 128.3, -39.134, 0)
  295.     Selection:RegisterEvent("emote_open_Gate_ten_seconds", 10000, 1)
  296. end
  297.  
  298. function emote_open_Gate_ten_seconds(pUnit)
  299.     Selection:Emote(25, 2000)
  300.     Selection:RegisterEvent("esojtosetes_Esijgosi_zeigjz_zojte", 3000, 1)
  301. end
  302.  
  303. function esojtosetes_Esijgosi_zeigjz_zojte(pUnit)
  304.     Selection:SendChatMessage(12,0,"We need to get some dynamite so we can blow our way out of here. I believe there was some stored further in, once we have it we will need to return back here and blow open the spare cell.")
  305.     Selection:Emote(1,7000)
  306.     Selection:RegisterEvent("delay_a_sec_sec_Sec_te_hge_esi", 10000, 1)
  307. end
  308.  
  309. function delay_a_sec_sec_Sec_te_hge_esi(pUnit)
  310.     Selection:SendChatMessage(14,0,"Attack!")
  311.     Selection:Emote(15,3000)
  312.     door_e:SetByte(0x0006+0x000B,0,0) -- Open
  313.     Selection:RegisterEvent("eojsog_zeojt_prison_attack_warden_boo_Hoo", 3500, 1)
  314.     --Selection:RegisterEvent("ezojsog_zeojt_prison_attack_warden_boo_Hooz", 5000, 1)
  315. end
  316.  
  317. function eojsog_zeojt_prison_attack_warden_boo_Hoo(pUnit)
  318.     Selection:MoveTo(-12.8, 146.8, -40.384, 0)
  319.     Selection:SetFaction(1857)
  320.     --Grim:FullCastSpellOnTarget(11, Selection)
  321.     Grim:SendChatMessage(12,0,"Bring it, ye' wee' ninny's.")
  322.     Grim:AttackReaction(Selection, 100, 0)
  323.     npc_a:AttackReaction(Grim, 100, 0)
  324.     npc_b:AttackReaction(Grim, 100, 0)
  325.     npc_c:AttackReaction(Grim, 100, 0)
  326.     Selection:SetHealth(10)
  327. end
  328.  
  329. --[[function ezojsog_zeojt_prison_attack_warden_boo_Hooz(pUnit)
  330.     if Selection:IsAlive() then
  331.     Guard:FullCastSpellOnTarget(11, Selection)
  332.     end
  333. end]]
  334.  
  335. -- Grim Ironbeard
  336.  
  337. function Define_On_SPawn_Grim_Ironbeard(pUnit, Event)
  338.     Grim = pUnit
  339. end
  340.  
  341. function Define_On_DEAD_Grim_Ironbeard(pUnit)
  342.     if npc_a:IsAlive() then
  343.     npc_a:CastSpell(11)
  344.     end
  345.     if npc_b:IsAlive() then
  346.     npc_b:CastSpell(11)
  347.     end
  348.     if npc_c:IsAlive() then
  349.     npc_c:CastSpell(11)
  350.     end
  351.     if Selection:IsAlive() then
  352.     Selection:CastSpell(11)
  353.     end
  354. end
  355.  
  356. RegisterUnitEvent(157211, 18, "Define_On_SPawn_Grim_Ironbeard")
  357. RegisterUnitEvent(157211, 4, "Define_On_DEAD_Grim_Ironbeard")
  358.  
  359. -------------------------------------------------------------------------------------------------------
  360. -- First Two Gates ------------------------------------------------------------------------------------
  361. -------------------------------------------------------------------------------------------------------
  362.  
  363. function zzzCPEACAE_Cage_asdasd_OnUseZXC(pMisc, event)
  364.     -- Unclickable
  365.     pMisc:SetUInt32Value(0x0006+0x0003,0x1)
  366.     DoorB = pMisc
  367. end
  368.  
  369. RegisterGameObjectEvent(184393, 2, "zzzCPEACAE_Cage_asdasd_OnUseZXC")
  370.  
  371. function gzzzCPEACAE_Cage_asdasd_OnUseZXC(pMisc, event)
  372.     pMisc:SetUInt32Value(0x0006+0x0003,0x1)
  373.     DoorA = pMisc
  374. end
  375.  
  376. RegisterGameObjectEvent(18936, 2, "gzzzCPEACAE_Cage_asdasd_OnUseZXC")
  377.  
  378. -------------------------------------------------------------------------------------------------------
  379. -- Gates in first coordior and levers -----------------------------------------------------------------
  380. -------------------------------------------------------------------------------------------------------
  381.  
  382. --[[
  383. Map:
  384. gates a-e are triggered by levers
  385. a-c = npc's in them
  386.     _________
  387.     ¦ start ¦
  388.     ¦__   __¦
  389.       _¦ ¦_
  390.     b¦_   _¦a
  391.       _¦ ¦_
  392.     d¦_   _¦c
  393.        ¦_¦
  394.         e
  395. ]]
  396.  
  397. -- Doors
  398.  
  399. function door_goes_untargetablesojgs_a(pMisc, event)
  400.     door_a = pMisc
  401.     pMisc:SetUInt32Value(0x0006+0x0003,0x1) -- Unclickable
  402. end
  403.  
  404. function door_goes_untargetablesojgs_b(pMisc, event)
  405.     door_b = pMisc
  406.     pMisc:SetUInt32Value(0x0006+0x0003,0x1) -- Unclickable
  407. end
  408.  
  409. function door_goes_untargetablesojgs_c(pMisc, event)
  410.     door_c = pMisc
  411.     pMisc:SetUInt32Value(0x0006+0x0003,0x1) -- Unclickable
  412. end
  413.  
  414. function door_goes_untargetablesojgs_d(pMisc, event)
  415.     door_d = pMisc
  416.     pMisc:SetUInt32Value(0x0006+0x0003,0x1) -- Unclickable
  417. end
  418.  
  419. function door_goes_untargetablesojgs_e(pMisc, event)
  420.     door_e = pMisc
  421.     pMisc:SetUInt32Value(0x0006+0x0003,0x1) -- Unclickable
  422. end
  423.  
  424. RegisterGameObjectEvent(189361, 2, "door_goes_untargetablesojgs_a") -- a
  425. RegisterGameObjectEvent(189362, 2, "door_goes_untargetablesojgs_b") -- b
  426. RegisterGameObjectEvent(189363, 2, "door_goes_untargetablesojgs_c") -- c
  427. RegisterGameObjectEvent(189364, 2, "door_goes_untargetablesojgs_d") -- d
  428. RegisterGameObjectEvent(189365, 2, "door_goes_untargetablesojgs_e") -- e
  429.  
  430. function gameobject_door_stuck_open(pMisc, event)
  431.     pMisc:SetUInt32Value(0x0006+0x0003,0x1) -- Unclickable
  432.     pMisc:SetByte(0x0006+0x000B,0,0) -- Open
  433. end
  434.  
  435. RegisterGameObjectEvent(189366, 2, "gameobject_door_stuck_open")
  436.  
  437. function ffgameobject_door_stuck_open(pMisc, event)
  438.     pMisc:SetUInt32Value(0x0006+0x0003,0x1) -- Unclickable
  439. end
  440.  
  441. RegisterGameObjectEvent(189367, 2, "ffgameobject_door_stuck_open")
  442.  
  443. -- Levers
  444.  
  445. function lever_goes_untargetablesojgs_a(pMisc, Event)
  446.     door_a:SetByte(0x0006+0x000B,0,0) -- Open
  447.     npc_a:SendChatMessage(12,0,"I am in your debt.")
  448.     npc_a:SetUnitToFollow(npc_a:GetClosestPlayer(), 5, 1)
  449.     Amount = Amount + 1
  450.     RegisterTimedEvent("Reset_Door_A_Tehe_Test_A", 20000, 1)
  451. end
  452.  
  453. function Reset_Door_A_Tehe_Test_A(pMisc)
  454.     door_a:SetByte(0x0006+0x000B,0,1) -- Close
  455. end
  456.  
  457. RegisterGameObjectEvent(905671, 4, "lever_goes_untargetablesojgs_a") -- a
  458.  
  459. function lever_goes_untargetablesojgs_b(pMisc, Event)
  460.     door_b:SetByte(0x0006+0x000B,0,0) -- Open
  461.     npc_b:SendChatMessage(12,0,"I'll help!")
  462.     npc_b:SetUnitToFollow(npc_b:GetClosestPlayer(), 1.5, 1)
  463.     Amount = Amount + 1
  464.     RegisterTimedEvent("Reset_Door_A_Tehe_Test_b", 20000, 1)
  465. end
  466.  
  467. function Reset_Door_A_Tehe_Test_b(pMisc)
  468.     door_b:SetByte(0x0006+0x000B,0,1) -- Close
  469. end
  470.  
  471. RegisterGameObjectEvent(905672, 4, "lever_goes_untargetablesojgs_b") -- b
  472.  
  473. function lever_goes_untargetablesojgs_c(pMisc, Event)
  474.     door_c:SetByte(0x0006+0x000B,0,0) -- Open
  475.     npc_c:SendChatMessage(12,0,"Finally!")
  476.     npc_c:SetUnitToFollow(npc_c:GetClosestPlayer(), 3, 1)
  477.     Amount = Amount + 1
  478.     RegisterTimedEvent("Reset_Door_A_Tehe_Test_c", 20000, 1)
  479. end
  480.  
  481. function Reset_Door_A_Tehe_Test_c(pMisc)
  482.     door_c:SetByte(0x0006+0x000B,0,1) -- Close
  483. end
  484.  
  485. RegisterGameObjectEvent(905673, 4, "lever_goes_untargetablesojgs_c") -- c
  486.  
  487. function lever_goes_untargetablesojgs_d(pMisc, Event)
  488.     door_d:SetByte(0x0006+0x000B,0,0) -- Open
  489.     RegisterTimedEvent("Reset_Door_A_Tehe_Test_d", 20000, 1)
  490. end
  491.  
  492. function Reset_Door_A_Tehe_Test_d(pMisc)
  493.     door_d:SetByte(0x0006+0x000B,0,1) -- Close
  494. end
  495.  
  496. RegisterGameObjectEvent(905674, 4, "lever_goes_untargetablesojgs_d") -- d
  497.  
  498. --[[function lever_goes_untargetablesojgs_e(pMisc, Event)
  499.     door_e:SetByte(0x0006+0x000B,0,0) -- Open
  500.     RegisterLuaEvent("Reset_Door_A_Tehe_Test_e", 20000, 1)
  501. end
  502.  
  503. function Reset_Door_A_Tehe_Test_e(pMisc)
  504.     door_e:SetByte(0x0006+0x000B,0,1) -- Close
  505. end
  506.  
  507. RegisterGameObjectEvent(905675, 4, "lever_goes_untargetablesojgs_e") -- e]]
  508.  
  509. -- Creatures
  510.  
  511. function onspawndefine_npca(pUnit, Event)
  512.     npc_a = pUnit
  513. end
  514.  
  515. function onspawndefine_npcb(pUnit, Event)
  516.     npc_b = pUnit
  517. end
  518.  
  519. function onspawndefine_npcc(pUnit, Event)
  520.     npc_c = pUnit
  521. end
  522.  
  523. RegisterUnitEvent(40000,18,"onspawndefine_npca")
  524. RegisterUnitEvent(40002,18,"onspawndefine_npcb")
  525. RegisterUnitEvent(40003,18,"onspawndefine_npcc")
  526.  
  527. ------------------------------------------------------------------------------------------------------------------------------------------------
  528. -- Part B: Killing the Warden and escaping -----------------------------------------------------------------------------------------------------
  529. ------------------------------------------------------------------------------------------------------------------------------------------------
  530.  
  531. -------------------------------------------------------------------------------------------------------
  532. -- Warden Fight ---------------------------------------------------------------------------------------
  533. -------------------------------------------------------------------------------------------------------
  534.  
  535. function Warden_For_Real_Fight_On_Spawn(pUnit, Event)
  536.     pUnit:RegisterEvent("Delay_a_sec_while_we_set_to_unattackable", 1000, 1)
  537. end
  538.  
  539. function Delay_a_sec_while_we_set_to_unattackable(pUnit)
  540.     pUnit:SetFaction(35)
  541.     pUnit:RegisterEvent("Check_For_Players_And_So_On", 1000, 0)
  542. end
  543.  
  544. function Check_For_Players_And_So_On(pUnit)
  545.     local plr = pUnit:GetClosestPlayer()
  546.     if plr ~= nil then
  547.         if pUnit:GetDistance(plr) < 11 then
  548.         pUnit:SendChatMessage(12,0,"Looks like I'm going to have to deal with you personally.")
  549.         pUnit:RemoveEvents()
  550.         pUnit:RegisterEvent("Delay_A_Sec_Tzkkzoed", 5000, 1)
  551.         end
  552.     end
  553. end
  554.  
  555. function Delay_A_Sec_Tzkkzoed(pUnit)
  556.     pUnit:SendChatMessage(12,0,"See, while I've been watching over this prison, I've picked up a few tricks of my own!")
  557.     pUnit:RegisterEvent("Delay_A_bit_more_sigh_sigH_eeit", 6000, 1)
  558.     pUnit:RegisterEvent("Delay_A_bit_more_sigh_sigH_eeitzzg", 6500, 1)
  559.     pUnit:RegisterEvent("Delay_A_bit_more_sigh_sigH_eeitzzgggd", 7500, 1)
  560. end
  561.  
  562. function Delay_A_bit_more_sigh_sigH_eeit(pUnit)
  563.     pUnit:CastSpellOnTarget(34806, pUnit:GetClosestPlayer())
  564. end
  565.  
  566. function Delay_A_bit_more_sigh_sigH_eeitzzg(pUnit)
  567.     pUnit:CastSpell(33916)
  568. end
  569.  
  570. function Delay_A_bit_more_sigh_sigH_eeitzzgggd(pUnit)
  571.     pUnit:RemoveAura(33915)
  572.     pUnit:RemoveAura(33916)
  573.     pUnit:SetFaction(21)
  574. end
  575.  
  576. RegisterUnitEvent(46922, 18, "Warden_For_Real_Fight_On_Spawn")
  577.  
  578. -------------------------------------------------------------------------------------------------------
  579. -- Rock rubble that gets blown up using dynamite ------------------------------------------------------
  580. -------------------------------------------------------------------------------------------------------
  581.  
  582. function ffdzzzCPEACAE_Cage_asdasd_OnUseZXC(pMisc, event, player)
  583.     if player:HasItem(18588) then
  584.     player:CastSpell(74648) --boom
  585.     player:RemoveItem(18588, 1)
  586.     pMisc:SetByte(LCF.GAMEOBJECT_BYTES_1,0,1) -- Close
  587.     else
  588.     pMisc:SetByte(LCF.GAMEOBJECT_BYTES_1,0,0) -- Open
  589.     player:SendAreaTriggerMessage("|CFFff0000You do not have any Dynamite!|R")
  590.     end
  591. end
  592.  
  593. RegisterGameObjectEvent(146085, 4, "ffdzzzCPEACAE_Cage_asdasd_OnUseZXC")
  594.  
  595. -------------------------------------------------------------------------------------------------------
  596. -- Stormwind Mage ------------------------------------------------------
  597. -------------------------------------------------------------------------------------------------------
  598.  
  599. function tyzzzWolly_On_Gossip(pUnit, event, player)
  600.     pUnit:GossipCreateMenu(758, player, 0)
  601.     pUnit:GossipMenuAddItem(0, "Get me out of here!", 24, 0)
  602.     pUnit:GossipMenuAddItem(0, "I still have things to do.", 25, 0)
  603.     pUnit:GossipSendMenu(player)
  604. end
  605.  
  606.  
  607. function tyzzzWolly_Gossip_Submenus(pUnit, event, player, id, intid, code)
  608.     if(intid == 24) then
  609.     player:GossipComplete()
  610.     player:Teleport(0, -8322, 532, 122.3)
  611.     player:CastSpell(64446)
  612.     end
  613.     if(intid == 25) then
  614.     player:GossipComplete()
  615.     end
  616. end
  617.  
  618. RegisterUnitGossipEvent(184531, 1, "tyzzzWolly_On_Gossip")
  619. RegisterUnitGossipEvent(184531, 2, "tyzzzWolly_Gossip_Submenus")
  620.  
  621. -------------------------------------------------------------------------------------------------------
  622. -- Equipment Manager ----------------------------------------------------------------------------------
  623. -------------------------------------------------------------------------------------------------------
  624. --  Credits to Neglected for pointing out GetEquippedItemBySlot returns the item object and not the entry
  625.  
  626. function Every_so_Often_Check_what_items_player_Has_and_if_he_matches_all_then_continue(...)
  627.     for a, plrs in pairs(GetPlayersInMap(35)) do
  628.         if plrs ~= nil then
  629.             if plrs:GetEquippedItemBySlot(0) ~= nil and plrs:GetEquippedItemBySlot(2) ~= nil and plrs:GetEquippedItemBySlot(4) ~= nil and plrs:GetEquippedItemBySlot(6) ~= nil and plrs:GetEquippedItemBySlot(7) ~= nil and plrs:GetEquippedItemBySlot(9) ~= nil and plrs:GetEquippedItemBySlot(18) ~= nil then
  630.                 if plrs:GetEquippedItemBySlot(0):GetEntryId() == 12427 then -- Head
  631.                 --plrs:SendBroadcastMessage("HEAD : 1")        
  632.                     if plrs:GetEquippedItemBySlot(2):GetEntryId() == 12428 then -- Shoulder
  633.                     --plrs:SendBroadcastMessage("Shoulder : 2")
  634.                         if plrs:GetEquippedItemBySlot(4):GetEntryId() == 12422 then -- Chest
  635.                         --plrs:SendBroadcastMessage("Chest : 3")
  636.                             if plrs:GetEquippedItemBySlot(6):GetEntryId() == 12429 then -- Legs
  637.                             --plrs:SendBroadcastMessage("Legs : 4")
  638.                                 if plrs:GetEquippedItemBySlot(7):GetEntryId() == 12426 then -- Feet
  639.                                 --plrs:SendBroadcastMessage("Feet : 5")
  640.                                     if plrs:GetEquippedItemBySlot(9):GetEntryId() == 29600 then -- Gloves
  641.                                     --plrs:SendBroadcastMessage("Gloves : 6")
  642.                                         if plrs:GetEquippedItemBySlot(18):GetEntryId() == 11364 then -- Tabard
  643.                                         plrs:SetFaction(21)
  644.                                         else
  645.                                         plrs:SetFaction(1)
  646.                                         end
  647.                                     else
  648.                                     plrs:SetFaction(1)
  649.                                     end
  650.                                 else
  651.                                 plrs:SetFaction(1)
  652.                                 end
  653.                             else
  654.                             plrs:SetFaction(1)
  655.                             end
  656.                         else
  657.                         plrs:SetFaction(1)
  658.                         end
  659.                     else
  660.                     plrs:SetFaction(1)
  661.                     end
  662.                 else
  663.                 plrs:SetFaction(1)
  664.                 end
  665.             end
  666.         end
  667.     end
  668. end
  669.  
  670. RegisterTimedEvent("Every_so_Often_Check_what_items_player_Has_and_if_he_matches_all_then_continue", 5000, 0)
  671.  
  672. -------------------------------------------------------------------------------------------------------
  673. -- Priest - When entering Stormwind  ------------------------------------------------------------------
  674. -------------------------------------------------------------------------------------------------------
  675.  
  676. function PRISET_DETECTS_YOU_RAGERAGERAGE(pUnit)
  677.     pUnit:RegisterEvent("Detect_Players_For_Changing_Factions_yet_Again", 1500, 0)
  678. end
  679.  
  680. function Detect_Players_For_Changing_Factions_yet_Again(pUnit)
  681.     local player = pUnit:GetClosestPlayer()
  682.     if player ~= nil then
  683.     pUnit:SendChatMessage(12,0,"Wait a minute, your no member of the Alliance! An escaped prisoner, get him!")
  684.     pUnit:RemoveEvents()
  685.     pUnit:RegisterEvent("give_him_a_second_to_read_it_and_for_reactions_etc", 1500, 1)
  686.     SetDBCSpellVar(1245, "c_is_flags", 0x01000)
  687.     SetDBCSpellVar(11549, "c_is_flags", 0x01000)
  688.     player:CastSpell(1245)
  689.     player:CastSpell(11549)
  690.     end
  691. end
  692.  
  693. function give_him_a_second_to_read_it_and_for_reactions_etc(pUnit)
  694.     local player = pUnit:GetClosestPlayer()
  695.     if player ~= nil then
  696.     pUnit:FullCastSpellOnTarget(585, player)
  697.     player:SetFaction(1)
  698.     end
  699. end
  700.  
  701. RegisterUnitEvent(150121,18, "PRISET_DETECTS_YOU_RAGERAGERAGE")
  702.  
  703. -------------------------------------------------------------------------------------------------------
  704. -- King of Stormwind  ---------------------------------------------------------------------------------
  705. -------------------------------------------------------------------------------------------------------
  706.  
  707. function King_Of_Stormwind_Is_Looking_For_people_to_be_a_victim_of(pUnit, Event)
  708.     pUnit:SetFaction(35)
  709.     pUnit:RegisterEvent("Seen_anyone_yet_QuestionMark", 1500, 0)
  710. end
  711.  
  712. function Seen_anyone_yet_QuestionMark(pUnit)
  713.     pUnit:SetFaction(35)
  714.     local pla = pUnit:GetClosestPlayer()
  715.     if pla ~= nil then
  716.         if pla:GetDistanceYards(pUnit) < 7 then
  717.         pUnit:RemoveEvents()
  718.         pUnit:SendChatMessage(12,0,"So, you've made it this. How much longer do you seriously think this is going to go on for? A prisoner escaping and killing the king? You know it's not going to happen.")
  719.         pUnit:Emote(1,6000)
  720.         pUnit:RegisterEvent("OH_WE_FOUND_SOMEONE_CHAT_THEM_UP_KING", 8000, 1)
  721.         pUnit:RegisterEvent("OH_WE_FOUND_SOMEONE_CHAT_THEM_UP_KING_Attack", 11000, 1)
  722.         end
  723.     end
  724. end
  725.  
  726. function OH_WE_FOUND_SOMEONE_CHAT_THEM_UP_KING(pUnit)
  727.     pUnit:SendChatMessage(12,0,"This ends now, prisoner, prepare to die!")
  728.     pUnit:Emote(5,2000)
  729. end
  730.  
  731. function OH_WE_FOUND_SOMEONE_CHAT_THEM_UP_KING_Attack(pUnit)
  732.     pUnit:SetFaction(21)
  733. end
  734.  
  735. RegisterUnitEvent(29611,18,"King_Of_Stormwind_Is_Looking_For_people_to_be_a_victim_of")
  736.  
  737. -------------------------------------------------------------------------------------------------------
  738. -- Blowing your way out of the keep -------------------------------------------------------------------
  739. -------------------------------------------------------------------------------------------------------
  740.  
  741.  
  742. function DEBUG_BLOW_UP_GATE_ITEM(item, event, player)
  743.     DEBUG_BLOW_UP_GATE_ITEMtata(item, player)
  744. end
  745.  
  746. function DEBUG_BLOW_UP_GATE_ITEMtata(item, player)
  747.     DISTANCE_HANDLER = player:GetCreatureNearestCoords(-8538.5, 455.72, 104.6, 50)
  748.     if DISTANCE_HANDLER ~= nil then
  749.         local Distance = roundNum(DISTANCE_HANDLER:GetDistanceYards(player), 0)
  750.         if Distance < 7 then
  751.         player:RemoveItem(4378, 1)
  752.         DISTANCE_HANDLER:SpawnGameObject(1934000, -8538.5, 455.72, 104.6, 0, 0, 1)
  753.         DISTANCE_HANDLER:GetGameObjectNearestCoords(-8538.5, 455.72, 104.6, 1934000):SetScale(1)
  754.         COUNT_DOWN = 6
  755.         --DISTANCE_HANDLER:RegisterEvent("renamedfunctionTest", 1000, 0)
  756.         RegisterTimedEvent("renamedfunctionTest", 1000, 6) -- Thanks to Dynashock for suggesting to use a TimedEvent since gameobject on spawn and handling through npc was basically... ****ed up and wouldn't call
  757.         else
  758.         player:SendAreaTriggerMessage("|CFFff0000You are "..Distance.." yards away!|R")
  759.         end
  760.     end
  761. end
  762.  
  763. RegisterItemGossipEvent(4378, 1, "DEBUG_BLOW_UP_GATE_ITEM")
  764.  
  765. -----------------------------------------------------------------------------
  766. -- Rounding Numbers
  767. -- example: roundNum(5.6)
  768. function roundNum(val, decimal)
  769.     if (decimal) then
  770.         return math.floor(((val * 10^decimal) + 0.5) / (10^decimal))
  771.     else
  772.         return math.floor(val+0.5)
  773.     end
  774. end
  775. ----------------------------------------------------------------------------
  776.  
  777. function renamedfunctionTest(pUnit)
  778.     COUNT_DOWN = COUNT_DOWN - 1
  779.     if COUNT_DOWN == 0 then
  780.     --DISTANCE_HANDLER:RemoveEvents()
  781.     DISTANCE_HANDLER:CastSpellAoF(-8538.5, 455.72, 104.6, 69689)
  782.     DISTANCE_HANDLER:GetGameObjectNearestCoords(-8540.5, 457.8, 104.3, 190727):SetUInt32Value(0x0006+0x0003,0x400) -- destroy destructable object
  783.     DISTANCE_HANDLER:GetGameObjectNearestCoords(-8538.5, 455.72, 104.6, 1934000):Despawn(1,0)
  784.     else
  785.         if COUNT_DOWN == 1 then
  786.         local plr = DISTANCE_HANDLER:GetClosestPlayer()
  787.             if plr ~= nil then
  788.             plr:SendAreaTriggerMessage("|CFFff0000The bomb will explode in "..COUNT_DOWN.." second!|R")
  789.             end
  790.         else
  791.         local plr = DISTANCE_HANDLER:GetClosestPlayer()
  792.             if plr ~= nil then
  793.             plr:SendAreaTriggerMessage("|CFFff0000The bomb will explode in "..COUNT_DOWN.." seconds!|R")
  794.             end
  795.         end
  796.     end
  797. end
  798.  
  799.  
  800. -------------------------------------------------------------------------------------------------------
  801. -- Destructable Objects Testing - Works like a charm  -------------------------------------------------
  802. -------------------------------------------------------------------------------------------------------
  803.  
  804. --[[
  805. local test = nil
  806.  
  807. function destryctabeobjectest(pMisc, event)
  808.     test = pMisc
  809. end
  810.  
  811. RegisterGameObjectEvent(193070, 2, "destryctabeobjectest")
  812.  
  813. local abc = nil
  814.  
  815. function destryctabeobjectest(pMisc, event)
  816.     abc = pMisc
  817. end
  818.  
  819. RegisterGameObjectEvent(190377, 2, "destryctabeobjectest")
  820.  
  821.  
  822. function flight_path_reality_system(event, plr, message, type, language)
  823.     local message = string.lower(message)
  824.     if message == "#hurt" then
  825.     test:SetUInt32Value(0x0006+0x0003,0x200) -- damaged
  826.     end
  827.     if message == "#destroy" then
  828.     test:SetUInt32Value(0x0006+0x0003,0x400) -- destroy
  829.     end
  830.     if message == "#rebuild" then
  831.     test:RemoveFlag(0x0006+0x0003,0x400)
  832.     test:RemoveFlag(0x0006+0x0003,0x200)
  833.     end
  834.     if message == "#a" then
  835.     abc:SetUInt32Value(0x0006+0x0003,0x200) -- damaged
  836.     end
  837.     if message == "#b" then
  838.     abc:SetUInt32Value(0x0006+0x0003,0x400) -- destroy
  839.     end
  840.     if message == "#c" then
  841.     abc:RemoveFlag(0x0006+0x0003,0x400)
  842.     abc:RemoveFlag(0x0006+0x0003,0x200)
  843.     end
  844. end
  845.  
  846. RegisterServerHook(16, "flight_path_reality_system")
  847. ]]
  848. --[[
  849.     GO_FLAG_DAMAGED         = 0x200,
  850.     GO_FLAG_DESTROYED       = 0x400,
  851. ]]
  852.  
  853. -------------------------------------------------------------------------------------------------------
  854. -- The Ending Sequence -------------------------------------------------------------------
  855. -------------------------------------------------------------------------------------------------------
  856.  
  857. function ENDING_GOSSIP_MENU(pUnit, event, player) -- Let the player decide to finish it - they have to interact, not automatic wtf is going on.
  858.     pUnit:GossipCreateMenu(759, player, 0)
  859.     pUnit:GossipMenuAddItem(0, "I'm ready.", 424, 0)
  860.     if pUnit == 0 then
  861.     pUnit:GossipMenuAddItem(4, "[DEBUG]", 424, 0) -- Random menu so that only one can show up
  862.     end
  863.     pUnit:GossipSendMenu(player)
  864. end
  865.  
  866.  
  867. function ENDING_GOSSIP_MENU_Submenus(pUnit, event, player, id, intid, code)
  868.     if(intid == 424) then
  869.     player:GossipComplete()
  870.     player:SetPlayerLock(1)
  871.     player:MovePlayerTo(-8546.86, 466.17, 104.55, 0, 0)
  872.     DISTANCE_HANDLER:GetGameObjectNearestCoords(-8540.5, 457.8, 104.3, 190727):RemoveFlag(0x0006+0x0003,0x400) -- Rebuilds the concrete wall, for visual appear more than anything else.
  873.     DISTANCE_HANDLER:SendChatMessage(42,0,"Well done, you've completed the game!")
  874.     RegisterTimedEvent("DISCONECT_PLAYER_AND_KILL_HIS_CHARACTER", 10000, 1, player)
  875.     end
  876. end
  877.  
  878. function DISCONECT_PLAYER_AND_KILL_HIS_CHARACTER(player)
  879.     player:SoftDisconnect()
  880.     CharDBQuery("DELETE FROM corpses")
  881.     CharDBQuery("DELETE FROM playeritems")
  882.     CharDBQuery("DELETE FROM gm_tickets")
  883.     CharDBQuery("DELETE FROM playerpets")
  884.     CharDBQuery("DELETE FROM playerpetspells")
  885.     CharDBQuery("DELETE FROM tutorials")
  886.     CharDBQuery("DELETE FROM questlog")
  887.     CharDBQuery("DELETE FROM playercooldowns")
  888.     CharDBQuery("DELETE FROM mailbox")
  889.     CharDBQuery("DELETE FROM social_friends")
  890.     CharDBQuery("DELETE FROM social_ignores")
  891.     CharDBQuery("DELETE FROM character_achievement WHERE achievement NOT IN (457, 467, 466, 465, 464, 463, 462, 461, 460, 459, 458, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1415, 1414, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1463, 1400, 456, 1402)")
  892.     CharDBQuery("DELETE FROM character_achievement_progress")
  893.     CharDBQuery("DELETE FROM characters")
  894. end
  895.  
  896. RegisterUnitGossipEvent(205611, 1, "ENDING_GOSSIP_MENU")
  897. RegisterUnitGossipEvent(205611, 2, "ENDING_GOSSIP_MENU_Submenus")
  898.  
  899. ------------------------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment