stoneharry

Untitled

Apr 22nd, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.98 KB | None | 0 0
  1. local OBJECT_END = 0x0006
  2. local GAMEOBJECT_BYTES_1 = OBJECT_END + 0x000B
  3. local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
  4. local UNIT_FLAG_NOT_SELECTABLE = 0x02000000 -- 26    33554432  cannot select the unit
  5. local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044
  6. local UNIT_FIELD_BYTES_2 = OBJECT_END + 0x0074 -- Size: 1, Type: BYTES, Flags: PUBLIC
  7. -- 3rd boss flags
  8. local UNIT_FIELD_CHARMEDBY = OBJECT_END + 0x0006
  9. local UNIT_FIELD_CHARM = OBJECT_END + 0x0000
  10. local UNIT_FLAG_PVP_ATTACKABLE = 0x00000008
  11. local UNIT_FLAG_PLAYER_CONTROLLED_CREATURE = 0x01000000
  12. local UNIT_END = OBJECT_END + 0x008E
  13. local PLAYER_DUEL_TEAM = UNIT_END + 0x0008
  14. local PLAYER_DUEL_ARBITER = UNIT_END + 0x0000
  15.  
  16. --[[
  17.  
  18. "This kingdom belongs to the Scourge! Only the dead may enter."
  19.  
  20. "We are besieged. Strike out and bring back their corpses!"
  21.  
  22. "They hunger."
  23. "Dinner time, my pets."
  24.  
  25. "You were foolish to come."
  26. "As Anub'Arak commands!"
  27.  
  28. 14076   10  A_KRIKTHIRKILL01
  29. 14077   10  A_KRIKTHIRKILL02
  30. 14078   10  A_KRIKTHIRKILL03
  31. 14079   10  A_KRIKTHIRSENDGROUP01
  32. 14080   10  A_KRIKTHIRSENDGROUP02
  33. 14081   10  A_KRIKTHIRSENDGROUP03
  34. 14082   10  A_KRIKTHIRPREFIGHT01
  35. 14083   10  A_KRIKTHIRPREFIGHT02
  36. 14084   10  A_KRIKTHIRPREFIGHT03
  37. 14085   10  A_KRIKTHIRSWARM01
  38. 14086   10  A_KRIKTHIRSWARM02
  39. ]]
  40.  
  41. -- 3rd boss
  42.  
  43. function TOC.VAR.thirdbosseventsTOC(pUnit, Event)
  44.     if Event == 1 then
  45.         pUnit:SendChatMessage(14,0,"This kingdom belongs to the Scourge! Only the dead may enter.")
  46.         pUnit:PlaySoundToSet(14075)
  47.         pUnit:RegisterEvent("TOC.VAR.MindControlAPlayer", 5000, 1)
  48.         local object = pUnit:GetGameObjectNearestCoords(665.92, 143.5, 142.1, 195485)
  49.         object:SetByte(GAMEOBJECT_BYTES_1,0,1)
  50.     elseif Event == 2 then
  51.         pUnit:RemoveEvents()
  52.         local object = pUnit:GetGameObjectNearestCoords(665.92, 143.5, 142.1, 195485)
  53.         object:SetByte(GAMEOBJECT_BYTES_1,0,0)
  54.     elseif Event == 3 then
  55.    
  56.     elseif Event == 4 then
  57.         pUnit:RemoveEvents()
  58.         pUnit:SendChatMessage(14,0,"I should be grateful, but I long ago lost the capacity...")
  59.         pUnit:PlaySoundToSet(14087)
  60.         local object = pUnit:GetGameObjectNearestCoords(665.92, 143.5, 142.1, 195485)
  61.         object:SetByte(GAMEOBJECT_BYTES_1,0,0)
  62.         for _,plr in pairs(pUnit:GetInRangePlayers()) do
  63.             if plr:HasAura(45631) then -- mind controlled
  64.                 plr:RemoveAura(50224) -- sight visual
  65.                 plr:RemoveAura(45631) -- chains self
  66.                 local count = 0
  67.                 local faction = 0
  68.                 while count < 6 and faction == 0 do
  69.                     local plr = pUnit:GetRandomPlayer()
  70.                     if plr then
  71.                         if plr:GetName() ~= plrs:GetName() then
  72.                             faction = plr:GetFaction()
  73.                         end
  74.                     end
  75.                     count = count + 1
  76.                 end
  77.                 if faction ~= 0 then
  78.                     plr:SetFaction(faction)
  79.                 else
  80.                     plr:SetFaction(1) -- to hell with it
  81.                 end
  82.                 plr:SetPlayerLock(0)
  83.                 plr:SetUInt64Value(UNIT_FIELD_CHARMEDBY, 0)
  84.                 plr:SetUInt32Value(UNIT_FIELD_FLAGS, 0)
  85.                 plr:SetUInt32Value(PLAYER_DUEL_TEAM, 0)
  86.                 plr:SetUInt64Value(PLAYER_DUEL_ARBITER,0)
  87.                 plr:SetPlayerLock(0)
  88.             end
  89.         end
  90.     end
  91. end
  92.  
  93. function TOC.VAR.MindControlAPlayer(pUnit)
  94.     if pUnit:GetInRangePlayersCount() > 1 then
  95.         local plr = pUnit:GetRandomPlayer(0)
  96.         local count = 0
  97.         while plr == nil and count < 5 do
  98.             plr = pUnit:GetRandomPlayer(0)
  99.             count = count + 1
  100.         end
  101.         if plr then
  102.             local name = plr:GetName()
  103.             pUnit:SendChatMessage(14,0,"Hush-tak Hee-tah!")
  104.             pUnit:PlaySoundToSet(14078)
  105.             pUnit:SendChatMessage(42,0,name.." has been mind controlled!")
  106.             TOC.VAR.MindControlPlayer(plr, pUnit)
  107.         end
  108.     end
  109. end
  110.  
  111. function TOC.VAR.MindControlPlayer(plr, pUnit)
  112.     if pUnit:GetMainTank():GetName() == plr:GetName() then
  113.         local c = pUnit:GetRandomPlayer(7) -- not main tank
  114.         if c then
  115.             pUnit:ChangeTarget(c)
  116.         end
  117.     end
  118.     plr:CastSpell(50224) -- sight visual
  119.     plr:CastSpell(45631) -- chains self
  120.     plr:SetPlayerLock(1)
  121.     plr:SetUInt64Value(UNIT_FIELD_CHARMEDBY, pUnit)
  122.     plr:SetFaction(21)
  123.     plr:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED_CREATURE)
  124.     plr:SetUInt32Value(PLAYER_DUEL_TEAM, 1)
  125.     local found = false
  126.     for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  127.         if plrs:GetName() ~= plr:GetName() then
  128.             plrs:SetUInt32Value(PLAYER_DUEL_TEAM, 0)
  129.             plrs:SetUInt64Value(PLAYER_DUEL_ARBITER,plr)
  130.             if not found then
  131.                 found = true
  132.                 plr:SetUInt64Value(PLAYER_DUEL_ARBITER,plrs)
  133.             end
  134.         end
  135.     end
  136.     local count = 0
  137.     local b = nil
  138.     local nam = nil
  139.     while b == nil and count < 5 and nam == nil do
  140.         count = count + 1
  141.         b = pUnit:GetRandomPlayer(0)
  142.         if b then
  143.             if b:GetName() ~= plr:GetName() then
  144.                 nam = plr:GetName()
  145.             end
  146.         end
  147.     end
  148.     if b and nam then
  149.         plr:Unroot()
  150.         plr:AttackReaction(b, 250, 11)
  151.     end
  152.     local id = pUnit:GetInstanceID()
  153.     if id == nil then id = 1 end
  154.     TOC[id] = TOC[id] or {VAR={}}
  155.     TOC[id].VAR.class = plr:GetPlayerClass()
  156.     TOC[id].VAR.plr = plr
  157.     pUnit:RegisterEvent("TOC.VAR.MindControlPlayer_Actions", 5000, 0)
  158.     pUnit:RegisterEvent("TOC.VAR.MindControlPlayer_Reset", 16000, 1)
  159. end
  160.  
  161. function TOC.VAR.MindControlPlayer_Actions(pUnit)
  162.     local id = pUnit:GetInstanceID()
  163.     if id == nil then id = 1 end
  164.     TOC[id] = TOC[id] or {VAR={}}
  165.     if TOC[id].VAR.plr then
  166.         local count = 0
  167.         local b = nil
  168.         local target = nil
  169.         while b == nil and target == nil and count < 5 do
  170.             count = count + 1
  171.             b = pUnit:GetRandomPlayer(0)
  172.             if b:GetName() ~= TOC[id].VAR.plr:GetName() then
  173.                 target = b
  174.             end
  175.         end
  176.         if target then
  177.             TOC[id].VAR.class = string.lower(TOC[id].VAR.class)
  178.             if TOC[id].VAR.class == "warrior" then
  179.                 if math.random(1,2) == 1 then
  180.                     TOC[id].VAR.plr:StopMovement(4000)
  181.                     TOC[id].VAR.plr:FullCastSpellOnTarget(TOC.VAR.getWarriorSpell(), target)
  182.                 else
  183.                     TOC[id].VAR.plr:MovePlayerTo(target:GetX(), target:GetY(), target:GetZ(), 0, 4096)
  184.                 end
  185.             elseif TOC[id].VAR.class == "warlock" then
  186.                 if math.random(1,2) == 1 then
  187.                     TOC[id].VAR.plr:StopMovement(4000)
  188.                     TOC[id].VAR.plr:FullCastSpellOnTarget(TOC.VAR.getWarriorSpell(), target)
  189.                 else
  190.                     TOC[id].VAR.plr:MovePlayerTo(target:GetX(), target:GetY(), target:GetZ(), 0, 4096)
  191.                 end
  192.             elseif TOC[id].VAR.class == "shaman" then
  193.                 if math.random(1,2) == 1 then
  194.                     TOC[id].VAR.plr:StopMovement(4000)
  195.                     TOC[id].VAR.plr:FullCastSpellOnTarget(TOC.VAR.getWarriorSpell(), target)
  196.                 else
  197.                     TOC[id].VAR.plr:MovePlayerTo(target:GetX(), target:GetY(), target:GetZ(), 0, 4096)
  198.                 end
  199.             elseif TOC[id].VAR.class == "rogue" then
  200.                 if math.random(1,2) == 1 then
  201.                     TOC[id].VAR.plr:StopMovement(4000)
  202.                     TOC[id].VAR.plr:FullCastSpellOnTarget(TOC.VAR.getWarriorSpell(), target)
  203.                 else
  204.                     TOC[id].VAR.plr:MovePlayerTo(target:GetX(), target:GetY(), target:GetZ(), 0, 4096)
  205.                 end
  206.             elseif TOC[id].VAR.class == "priest" then
  207.                 if math.random(1,2) == 1 then
  208.                     TOC[id].VAR.plr:StopMovement(4000)
  209.                     TOC[id].VAR.plr:FullCastSpellOnTarget(TOC.VAR.getWarriorSpell(), target)
  210.                 else
  211.                     TOC[id].VAR.plr:MovePlayerTo(target:GetX(), target:GetY(), target:GetZ(), 0, 4096)
  212.                 end
  213.             elseif TOC[id].VAR.class == "paladin" then
  214.                 if math.random(1,2) == 1 then
  215.                     TOC[id].VAR.plr:StopMovement(4000)
  216.                     TOC[id].VAR.plr:FullCastSpellOnTarget(TOC.VAR.getWarriorSpell(), target)
  217.                 else
  218.                     TOC[id].VAR.plr:MovePlayerTo(target:GetX(), target:GetY(), target:GetZ(), 0, 4096)
  219.                 end
  220.             elseif TOC[id].VAR.class == "mage" then
  221.                 if math.random(1,2) == 1 then
  222.                     TOC[id].VAR.plr:StopMovement(4000)
  223.                     TOC[id].VAR.plr:FullCastSpellOnTarget(TOC.VAR.getWarriorSpell(), target)
  224.                 else
  225.                     TOC[id].VAR.plr:MovePlayerTo(target:GetX(), target:GetY(), target:GetZ(), 0, 4096)
  226.                 end
  227.             elseif TOC[id].VAR.class == "hunter" then
  228.                 if math.random(1,2) == 1 then
  229.                     TOC[id].VAR.plr:StopMovement(4000)
  230.                     TOC[id].VAR.plr:FullCastSpellOnTarget(TOC.VAR.getWarriorSpell(), target)
  231.                 else
  232.                     TOC[id].VAR.plr:MovePlayerTo(target:GetX(), target:GetY(), target:GetZ(), 0, 4096)
  233.                 end
  234.             elseif TOC[id].VAR.class == "druid" then
  235.                 if math.random(1,2) == 1 then
  236.                     TOC[id].VAR.plr:StopMovement(4000)
  237.                     TOC[id].VAR.plr:FullCastSpellOnTarget(TOC.VAR.getWarriorSpell(), target)
  238.                 else
  239.                     TOC[id].VAR.plr:MovePlayerTo(target:GetX(), target:GetY(), target:GetZ(), 0, 4096)
  240.                 end
  241.             end
  242.         end
  243.     end
  244. end
  245.  
  246. function TOC.VAR.getWarriorSpell()
  247.  
  248.     return 11
  249. end
  250.  
  251. function TOC.VAR.getWarlockSpell()
  252.  
  253.     return 11
  254. end
  255.  
  256. function TOC.VAR.getShamanSpell()
  257.  
  258.     return 11
  259. end
  260.  
  261. function TOC.VAR.getRogueSpell()
  262.  
  263.     return 11
  264. end
  265.  
  266. function TOC.VAR.getPriestSpell()
  267.  
  268.     return 11
  269. end
  270.  
  271. function TOC.VAR.getPaladinSpell()
  272.  
  273.     return 11
  274. end
  275.  
  276. function TOC.VAR.getMageSpell()
  277.  
  278.     return 11
  279. end
  280.  
  281. function TOC.VAR.getHunterSpell()
  282.  
  283.     return 11
  284. end
  285.  
  286. function TOC.VAR.getDruidSpell()
  287.  
  288.     return 11
  289. end
  290.  
  291. function TOC.VAR.MindControlPlayer_Reset(pUnit)
  292.     local id = pUnit:GetInstanceID()
  293.     if id == nil then id = 1 end
  294.     TOC[id] = TOC[id] or {VAR={}}
  295.     local plr = TOC[id].VAR.plr
  296.     if plr then
  297.         pUnit:SendChatMessageToPlayer(42,0,"You have broken free of Krik'thir's will!", plr)
  298.         plr:RemoveAura(50224) -- sight visual
  299.         plr:RemoveAura(45631) -- chains self
  300.         local count = 0
  301.         local faction = 0
  302.         while count < 6 and faction == 0 do
  303.             local plrs = pUnit:GetRandomPlayer(0)
  304.             if plrs then
  305.                 if plr:GetName() ~= plrs:GetName() then
  306.                     faction = plrs:GetFaction()
  307.                 end
  308.             end
  309.             count = count + 1
  310.         end
  311.         if faction ~= 0 then
  312.             plr:SetFaction(faction)
  313.         else
  314.             plr:SetFaction(1) -- to hell with it
  315.         end
  316.         plr:SetPlayerLock(0)
  317.         plr:SetUInt64Value(UNIT_FIELD_CHARMEDBY, 0)
  318.         plr:SetUInt32Value(UNIT_FIELD_FLAGS, 0)
  319.         plr:SetUInt32Value(PLAYER_DUEL_TEAM, 0)
  320.         plr:SetUInt64Value(PLAYER_DUEL_ARBITER,0)
  321.     end
  322.     for _,plrs in pairs(pUnit:GetInRangePlayers()) do
  323.         plrs:SetUInt64Value(PLAYER_DUEL_ARBITER,0)
  324.     end
  325.     TOC[id].VAR.class = nil
  326.     TOC[id].VAR.plr = nil
  327.     pUnit:RegisterEvent("TOC.VAR.MindControlAPlayer", 5000, 1)
  328. end
  329.  
  330. RegisterUnitEvent(252691, 1, "TOC.VAR.thirdbosseventsTOC")
  331. RegisterUnitEvent(252691, 2, "TOC.VAR.thirdbosseventsTOC")
  332. RegisterUnitEvent(252691, 3, "TOC.VAR.thirdbosseventsTOC")
  333. RegisterUnitEvent(252691, 4, "TOC.VAR.thirdbosseventsTOC")
Advertisement
Add Comment
Please, Sign In to add comment