Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ZG = {}
- ZG.VAR = {}
- -- In this part of the script, I want to store some creatures as variables without collision, so this is how I do it:
- function ZG.VAR.SetUpCreatures_Dragon(pUnit)
- -- Get the ID of the instance
- local id = pUnit:GetInstanceID()
- -- If the ID Is nil (not in a instance) then set it to 1
- if id == nil then id = 1 end
- -- Set up our table to be used
- ZG[id] = ZG[id] or {VAR={}}
- -- Now we can create variables using this table as the primary key,
- -- e.g, instead of local leader = pUnit:Spawn... We do:
- ZG[id].VAR.leader = pUnit:SpawnCreature(36544, -11062, -2306, 145.9, 1.290404, 35, 0, 50429) -- Leader
- ZG[id].VAR.addA = pUnit:SpawnCreature(4052, -11075, -2307, 145, 1.058709, 35, 0, 45212)
- ZG[id].VAR.addB = pUnit:SpawnCreature(4052, -11066, -2311, 145.9, 1.184373, 35, 0, 45212)
- ZG[id].VAR.addC = pUnit:SpawnCreature(4052, -11057, -2314, 147.3, 1.549583, 35, 0, 45212)
- ZG[id].VAR.addD = pUnit:SpawnCreature(4052, -11049, -2311, 146.3, 2, 35, 0, 45212)
- end
- -- In this function I want to use the creatures I defined earlier, so I do:
- function ZG.VAR.WhileNoPlayer_DoVisual(pUnit)
- -- Get the instance and set up the table again just in case
- local id = pUnit:GetInstanceID()
- if id == nil then id = 1 end
- ZG[id] = ZG[id] or {VAR={}}
- -- Retrieve our variables stored and use them
- ZG[id].VAR.leader:ChannelSpell(48185, pUnit)
- ZG[id].VAR.addA:ChannelSpell(49128, ZG[id].VAR.leader)
- ZG[id].VAR.addB:ChannelSpell(49128, ZG[id].VAR.leader)
- ZG[id].VAR.addC:ChannelSpell(49128, ZG[id].VAR.leader)
- ZG[id].VAR.addD:ChannelSpell(49128, ZG[id].VAR.leader)
- -- If we wanted to not write this out every time, we could do:
- local leader = ZG[id].VAR.leader
- leader:CastSpell(11) -- this is collision proof as it was stored in the table
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement