Advertisement
stoneharry

Untitled

Mar 11th, 2012
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | None | 0 0
  1.  
  2. ZG = {}
  3. ZG.VAR = {}
  4.  
  5. -- In this part of the script, I want to store some creatures as variables without collision, so this is how I do it:
  6.  
  7. function ZG.VAR.SetUpCreatures_Dragon(pUnit)
  8.  
  9.     -- Get the ID of the instance
  10.     local id = pUnit:GetInstanceID()
  11.     -- If the ID Is nil (not in a instance) then set it to 1
  12.     if id == nil then id = 1 end
  13.     -- Set up our table to be used
  14.     ZG[id] = ZG[id] or {VAR={}}
  15.    
  16.     -- Now we can create variables using this table as the primary key,
  17.     -- e.g, instead of local leader = pUnit:Spawn... We do:
  18.     ZG[id].VAR.leader = pUnit:SpawnCreature(36544, -11062, -2306, 145.9, 1.290404, 35, 0, 50429) -- Leader
  19.     ZG[id].VAR.addA = pUnit:SpawnCreature(4052, -11075, -2307, 145, 1.058709, 35, 0, 45212)
  20.     ZG[id].VAR.addB = pUnit:SpawnCreature(4052, -11066, -2311, 145.9, 1.184373, 35, 0, 45212)
  21.     ZG[id].VAR.addC = pUnit:SpawnCreature(4052, -11057, -2314, 147.3, 1.549583, 35, 0, 45212)
  22.     ZG[id].VAR.addD = pUnit:SpawnCreature(4052, -11049, -2311, 146.3, 2, 35, 0, 45212)
  23.  
  24. end
  25.  
  26. -- In this function I want to use the creatures I defined earlier, so I do:
  27.  
  28. function ZG.VAR.WhileNoPlayer_DoVisual(pUnit)
  29.     -- Get the instance and set up the table again just in case
  30.     local id = pUnit:GetInstanceID()
  31.     if id == nil then id = 1 end
  32.     ZG[id] = ZG[id] or {VAR={}}
  33.    
  34.     -- Retrieve our variables stored and use them
  35.     ZG[id].VAR.leader:ChannelSpell(48185, pUnit)
  36.     ZG[id].VAR.addA:ChannelSpell(49128, ZG[id].VAR.leader)
  37.     ZG[id].VAR.addB:ChannelSpell(49128, ZG[id].VAR.leader)
  38.     ZG[id].VAR.addC:ChannelSpell(49128, ZG[id].VAR.leader)
  39.     ZG[id].VAR.addD:ChannelSpell(49128, ZG[id].VAR.leader)
  40.    
  41.     -- If we wanted to not write this out every time, we could do:
  42.     local leader = ZG[id].VAR.leader
  43.    
  44.     leader:CastSpell(11) -- this is collision proof as it was stored in the table
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement