Advertisement
Rochet2

Untitled

Aug 15th, 2014
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. local guid = 123123
  2. local entry = 123123
  3. local waypoints = {
  4.     {-3961.6398925781, -13931.200195313, 100.61499786377},
  5.     {-3970.2331542969, -13918.111328125, 99.561378479004},
  6.     {-3970.2331542969, -13918.111328125, 99.561378479004},
  7.     {-3970.3566894531, -13903.979492188, 98.188903808594},
  8.     {-3981.5881347656, -13891.403320313, 94.978813171387},
  9.     {-3994.0207519531, -13869.020507813, 89.97811126709 },
  10.     {-4008.8317871094, -13867.951171875, 88.204963684082},
  11.     {-4013.8081054688, -13855.06640625,  88.315124511719},
  12.     {-4012.2021484375, -13823.783203125, 80.429740905762},
  13. }
  14.  
  15. local UNIT_NPC_EMOTESTATE = 83
  16. local function Emote(creature, emote)
  17.     creature:SetUInt32Value(UNIT_NPC_EMOTESTATE, emote)
  18. end
  19.  
  20. local function Move(creature, id)
  21.     creature:SendUnitSay(tostring(id), 0)
  22.     if(waypoints[id]) then
  23.         creature:SetData("wp", id)
  24.         creature:SetWalk(false)
  25.         creature:RegisterEvent(function() creature:MoveTo(id, table.unpack(waypoints[id])) end, 0, 1)
  26.     else
  27.         creature:SetData("wp", nil)
  28.         creature:DespawnOrUnsummon()
  29.     end
  30. end
  31.  
  32. local function EmoteAndContinue(creature, emote, delaysecs, wpid)
  33.     Emote(creature, emote)
  34.     creature:RegisterEvent(
  35.         function()
  36.             Emote(creature, 0)
  37.             if (not creature:IsInCombat()) then
  38.                 Move(creature, wpid)
  39.             end
  40.         end,
  41.     delaysecs*1000, 1)
  42. end
  43.  
  44. local function OnCombat(event, creature, unit)
  45.     creature:MoveExpire()
  46. end
  47.  
  48. local function OnReachHome(event, creature)
  49.     Move(creature, creature:GetData("wp"))
  50. end
  51.  
  52. local function OnWpReach(event, creature, _type, id)
  53.     if (_type ~= 8) then return end
  54.    
  55.     if (id == 4) then
  56.         EmoteAndContinue(creature, 3, math.random(5, 10), id+1)
  57.         return
  58.     elseif (id == 7) then
  59.         EmoteAndContinue(creature, 4, math.random(5, 10), id+1)
  60.         return
  61.     end
  62.    
  63.     Move(creature, id+1)
  64. end
  65.  
  66. local function OnSpawn(event, creature)
  67.     if (creature:GetGUIDLow() == guid) then
  68.         Move(creature, 1)
  69.     end
  70. end
  71.  
  72. RegisterCreatureEvent(entry, 1, OnCombat)
  73. RegisterCreatureEvent(entry, 5, OnSpawn)
  74. RegisterCreatureEvent(entry, 6, OnWpReach)
  75. RegisterCreatureEvent(entry, 24, OnReachHome)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement