-
Notifications
You must be signed in to change notification settings - Fork 15
/
docs.txt
474 lines (383 loc) · 22 KB
/
docs.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
Open Raid is a library to share the player information while playing in a group or raid.
Install:
Place the library at your addon folder/libs/LibOpenRaid/
Inside LibOpenRaid there's 5 files.
Add <Include file="Libs\LibOpenRaid\lib.xml"/> to your libs.xml located in the root folder of the addon or
<Include file="LibOpenRaid\lib.xml"/> if it is located inside the Libs folder.
Close and open the game client.
Inside your lua file, get the library object, you need to do this in order to grab a reference of the library:
local openRaidLib = LibStub:GetLibrary("LibOpenRaid-1.0")
With this object, you can start querying the library for information.
Functions:
local sentRequest = openRaidLib.RequestAllData()
Request to all players in the group to send infomation on: cooldowns, gear and player data.
Instants after calling this, expect to receive several callbacks.
COOLDOWNS:
--get all cooldowns from all units
local allUnitsCooldowns = openRaidLib.GetAllUnitsCooldown()
allUnitsCooldowns = {
["playerName1"] = {[cooldownSpellId] = cooldownInfo, [cooldownSpellId] = cooldownInfo, ...}
["playerName2"] = {[cooldownSpellId] = cooldownInfo, [cooldownSpellId] = cooldownInfo, ...}
["playerName3"] = {[cooldownSpellId] = cooldownInfo, [cooldownSpellId] = cooldownInfo, ...}
}
--get all cooldowns from a single unit
local unitCooldows = openRaidLib.GetUnitCooldowns(unitId [,filter])
@unittId: "player", "target", "party2", "raid12", ...
@filter: "defensive-raid", "defensive-target", "defensive-personal", "ofensive", "utility", "interrupt"
can pass more than one filter separating by comma, example: "defensive-raid, defensive-target"
unitCooldows = {
[cooldownSpellId] = cooldownInfo,
[cooldownSpellId] = cooldownInfo,
[cooldownSpellId] = cooldownInfo,
}
--get a cooldownInfo of a single spell from any unit
local cooldownInfo = openRaidLib.GetUnitCooldownInfo(unitId, spellId)
--get cooldown timers to use with progress bar or cooldown frames, percent are normalized (0 to 1), timeLeft is seconds, minValue/maxValue/currentValue are in GetTime() time space, amount of charges
--minValue is the same as startTime, maxValue is the same as expirationTime, currentValue is GetTime()
--by using unitID and spellID
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromUnitSpellID(unitId, spellId)
--by using a cooldown info
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
--add spells to a custom filter
--to change the spells in the filter just call it again with different spells, spells not included in the new table are removed from the filter
--to remove the filter, call it with an empty table
@filterName: any string containing alphanumeric characters
@spells: a table containing spellIds {spellId, spellId, spellId, ...}
openRaidLib.AddCooldownFilter(filterName, spells)
--get a list of filters which a spell has, returns a table in map format: {[filterName] = true}
--@spellId: the ID of a spell
--@defaultFilterOnly (bool): if true only return built-in filters, example: "defensive-raid", "ofensive".
--@customFiltersOnly (bool): if true onlt return a list of custom filters where the spell was added.
local filterListArray = openRaidLib.GetSpellFilters(spellId, defaultFilterOnly, customFiltersOnly)
--request information about a spell for all units in the raid, units which has this cooldown will report back with a "CooldownUpdate" event
openRaidLib.RequestCooldownInfo(spellId)
EQUIPMENT:
local allPlayersGear = openRaidLib.GetAllUnitsGear()
allPlayersGear = {
["playerName1"] = playerGear,
["playerName2"] = playerGear,
["playerName3"] = playerGear,
}
local playerGear = openRaidLib.GetUnitGear(unitId)
playerGear = {
.durability = number
.ilevel = number
.noGems = {socketId}
.noEnchants = {socketId}
.weaponEnchant = number (oils)
.equippedGear = {
{
.slotId = number
.gemSlots = number
.itemLevel = number
.itemLink = string
.itemQuality = number
.itemId = number
.itemName = string
.enchantId = number
.gemId = number
.isTier = boolean
}
}
}
UNIT INFORMATION
local allUnitsInfo = openRaidLib.GetAllUnitsInfo()
allUnitsInfo = {
["unitName1"] = unitInfo,
["unitName2"] = unitInfo,
["unitName3"] = unitInfo,
}
local unitInfo = openRaidLib.GetUnitInfo(unitId)
unitInfo = {
.specId = number
.specName = string
.role = string
.renown = number
.covenantId = number
.talents = {talentId, talentId, talentId, ...}
.pvpTalents = {talentId, talentId, talentId}
.conduits = {spellId, conduitLevel, spellId, conduitLevel, spellId, conduitLevel, ...}
.class = string class eng name 'ROGUE'
.classId = number
.className = string class localized name
.name = string name without realm
.nameFull = string name with realm 'unitName-ServerName'
}
KEYSTONE
--send and receive mythic+ keystone information and works only in retail
--the event "KeystoneUpdate" is triggered on receive keystone info from another player
local allKeystoneInfo = openRaidLib.GetAllKeystonesInfo()
allKeystoneInfo = {
["unitName1"] = keystoneInfo,
["unitName2"] = keystoneInfo,
["unitName3"] = keystoneInfo,
}
--@mapID and @challengeMapID are the instanceMapID, also obtained with GetInstanceInfo(), can be used to retrive map name with GetRealZoneText(mapID)
--@mythicPlusMapID is used with C_ChallengeMode.GetMapUIInfo(mythicPlusMapID) to retrive the map name for the dungeon
--@classID: class id as number (1 to 12)
--@rating: mythic plus rating on the current season
local keystoneInfo = openRaidLib.GetKeystoneInfo(unitId)
keystoneInfo = {
.level = number,
.mapID = number,
.challengeMapID = number,
.classID = number,
.rating = number,
.mythicPlusMapID = number,
}
--request all online players in the guild to send their keystone information
--this call fails if the player isn't in a guild
local requestSent = openRaidLib.RequestKeystoneDataFromGuild()
--request to players in your party to send their keystone information
--this call fails if the player is in raid
local requestSent = openRaidLib.RequestKeystoneDataFromParty()
--request to players in your raid to send their keystone information
--this call fails if not in a raid group
local requestSent = openRaidLib.RequestKeystoneDataFromRaid()
FLASK and FOOD buffs
--@spellId: a regular spellId
local flaskInfo = openRaidLib.GetFlaskInfoBySpellId(spellId)
--@auraInfo: UnitAuraInfo -> https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo see C_UnitAuras.GetAuraDataBySlot()
local flaskTier = openRaidLib.GetFlaskTierFromAura(auraInfo)
--@spellId: a regular spellId
local foodInfo = openRaidLib.GetFoodInfoBySpellId(spellId)
--@auraInfo: UnitAuraInfo -> https://wowpedia.fandom.com/wiki/Struct_UnitAuraInfo see C_UnitAuras.GetAuraDataBySlot()
local foodTier = openRaidLib.GetFoodTierFromAura(auraInfo)
Callbacks:
===================================================================================================================================
"CooldownListUpdate": triggers when the lib received a list of cooldowns from another unit in the group.
@unitId: which unit got updated
@unitCooldows: list of cooldowns of the unit
@allUnitsCooldowns: a list of all players with their cooldowns
===================================================================================================================================
function MyAddonObject.OnReceiveCooldownListUpdate(unitId, unitCooldows, allUnitsCooldowns)
--regular iteration among the group
for i = 1, GetNumGroupMembers() do
local unitId = "raid"..i
local thisUnitCooldowns = openRaidLib.GetUnitCooldowns(unitId, "defensive-raid, defensive-target")
end
--using the 'unitCooldows' table passed for the updated unit
for spellId, cooldownInfo in pairs(unitCooldows) do
--minValue, maxValue, currentValue is the same as startTime, expirationTime, GetTime()
local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
--statusbar frame
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
statusbar:SetMinMaxValues(minValue, maxValue)
statusbar:SetValue(currentValue)
--cooldown frame
local cooldownFrame = CreateFrame("cooldown", "MyCooldownFrame", UIParent)
local startTime = minValue
CooldownFrame_Set(cooldownFrame, startTime, cooldownDuration, timeLeft > 0)
--or
cooldownFrame:SetCooldown(startTime, cooldownDuration)
end
--this event also passes a table with all player cooldowns
for unitName, unitCooldows in pairs(allUnitsCooldowns) do
for spellId, cooldownInfo in pairs(unitCooldows) do
--minValue, maxValue, currentValue is the same as startTime, expirationTime, GetTime()
local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
--statusbar frame
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
statusbar:SetMinMaxValues(0, 1)
statusbar:SetValue(normalizedPercent)
--cooldown frame
local cooldownFrame = CreateFrame("cooldown", "MyCooldownFrame", UIParent)
local startTime = minValue
CooldownFrame_Set(cooldownFrame, startTime, cooldownDuration, timeLeft > 0)
--or
cooldownFrame:SetCooldown(startTime, cooldownDuration)
end
end
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "CooldownListUpdate", "OnReceiveCooldownListUpdate")
===================================================================================================================================
"CooldownUpdate": triggered when an unit in the group uses a cooldown or the timeleft of a cooldown of an unit got an update
@unitId: which unit got the update
@spellId: id of the cooldown spell
@cooldownInfo: a table containing information about the cooldown time
@unitCooldows: list of cooldowns of the unit
@allUnitsCooldowns: a list of all players and their cooldowns
===================================================================================================================================
function MyAddonObject.OnReceiveCooldownUpdate(unitId, spellId, cooldownInfo, unitCooldows, allUnitsCooldowns)
--minValue, maxValue, currentValue is the same as startTime, expirationTime, GetTime()
local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
--statusbar frame
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
statusbar:SetMinMaxValues(minValue, maxValue)
statusbar:SetValue(currentValue)
--cooldown frame
local cooldownFrame = CreateFrame("cooldown", "MyCooldownFrame", UIParent)
local startTime = minValue
CooldownFrame_Set(cooldownFrame, startTime, cooldownDuration, timeLeft > 0)
--or
cooldownFrame:SetCooldown(startTime, cooldownDuration)
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "CooldownUpdate", "OnReceiveCooldownUpdate")
===================================================================================================================================
"CooldownAdded": triggered when an unit get a new cooldown
@unitId: which unit got the update
@spellId: id of the cooldown spell
@cooldownInfo: a table containing information about the cooldown time
@unitCooldows: list of cooldowns of the unit
@allUnitsCooldowns: a list of all players and their cooldowns
===================================================================================================================================
function MyAddonObject.OnUnitNewCooldown(unitId, spellId, cooldownInfo, unitCooldows, allUnitsCooldowns)
--minValue, maxValue, currentValue is the same as startTime, expirationTime, GetTime()
local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue, cooldownDuration = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
statusbar:SetMinMaxValues(minValue, maxValue)
statusbar:SetValue(currentValue)
--cooldown frame
local cooldownFrame = CreateFrame("cooldown", "MyCooldownFrame", UIParent)
local startTime = minValue
CooldownFrame_Set(cooldownFrame, startTime, cooldownDuration, timeLeft > 0)
--or
cooldownFrame:SetCooldown(startTime, cooldownDuration)
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "CooldownAdded", "OnUnitNewCooldown")
===================================================================================================================================
"CooldownRemoved": triggered when an unit lost a cooldown spell
@unitId: which unit got the update
@spellId: id of the cooldown spell
@unitCooldows: list of cooldowns of the unit
@allUnitsCooldowns: a list of all players and their cooldowns
===================================================================================================================================
function MyAddonObject.OnUnitLostCooldown(unitId, spellId, unitCooldows, allUnitsCooldowns)
--the unit lost a cooldown
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "CooldownRemoved", "OnUnitLostCooldown")
===================================================================================================================================
"CooldownListWipe": when the list of cooldowns get a wipe, usually when the player leave the group
===================================================================================================================================
function MyAddonObject.OnCooldownListWipe(allUnitsCooldowns)
--print("is nil:", next(allUnitsCooldowns))
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "CooldownListWipe", "OnCooldownListWipe")
Note: right after the wipe, player cooldowns get an update, so a callback "CooldownListUpdate" is triggered right after this event (on the same tick).
===================================================================================================================================
"GearUpdate": when received an update from a player with all information about the gear
===================================================================================================================================
function MyAddonObject.OnGearUpdate(unitId, unitGear, allUnitsGear)
local itemLevelNumber = unitGear.ilevel
local durabilityNumber = unitGear.durability
--hasWeaponEnchant is 1 have enchant or 0 is don't
local hasWeaponEnchantNumber = unitGear.weaponEnchant
local noEnchantTable = unitGear.noEnchants
local noGemsTable = unitGear.noGems
for index, slotIdWithoutEnchant in ipairs(noEnchantTable) do
end
for index, slotIdWithEmptyGemSocket in ipairs(noGemsTable) do
end
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "GearUpdate", "OnGearUpdate")
===================================================================================================================================
"GearDurabilityUpdate": when the gear durability of a player in the group changes
===================================================================================================================================
function MyAddonObject.OnGearDurabilityUpdate(unitId, durability, unitGear, allUnitsGear)
--print(UnitName(unitId) .. " durability is now " .. durability)
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "GearDurabilityUpdate", "OnGearDurabilityUpdate")
===================================================================================================================================
"GearListWipe": when the list of gear get a wipe, usually when the player leave the group
===================================================================================================================================
function MyAddonObject.OnGearListWiped(allUnitsGear)
--print("is nil:", next(allUnitsGear))
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "GearListWipe", "OnGearListWiped")
Note: right after the wipe, player gear information get an update, so a callback "GearUpdate" is triggered right after this event (on the same tick).
===================================================================================================================================
"UnitInfoUpdate": a unit in the group has been updated
===================================================================================================================================
function MyAddonObject.OnUnitUpdate(unitId, unitInfo, allUnitsInfo)
for unitName, unitInfo in pairs(allUnitsInfo) do
local specId = unitInfo.specId
local specName = unitInfo.specName
local role = unitInfo.role
local renown = unitInfo.renown
local covenantId = unitInfo.covenantId
local talents = unitInfo.talents
local pvpTalents = unitInfo.pvpTalents
local conduits = unitInfo.conduits
local class = unitInfo.class = string class eng name 'ROGUE'
local classId = unitInfo.classId = number
local className = unitInfo.className
local unitName = unitInfo.name = string name without realm
local unitNameFull = unitInfo.nameFull = string name with realm 'unitName-ServerName'
end
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "UnitInfoUpdate", "OnUnitUpdate")
===================================================================================================================================
"UnitInfoWipe": when the unit info got wipped, usually when the player leave the group
===================================================================================================================================
function MyAddonObject.OnUnitInfoWipe()
--all unit info got wiped
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "UnitInfoWipe", "OnUnitInfoWipe")
Note: a "UnitUpdate" callback is triggered right after this event to notify the player info is updated.
===================================================================================================================================
"TalentUpdate": when a unit changed a talent
===================================================================================================================================
function MyAddonObject.OnTalentUpdate(unitId, talents, unitInfo, allUnitsInfo)
for i = 1, 7 do
local talentId = talents[i]
local talentID, talentName, texture, selected, available = GetTalentInfoByID(talentId)
print(talentName)
end
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "TalentUpdate", "OnTalentUpdate")
===================================================================================================================================
"PvPTalentUpdate": when an unit changed a pvp talent
===================================================================================================================================
function MyAddonObject.OnPvPTalentUpdate(unitId, pvpTalents, unitInfo, allUnitsInfo)
for i = 1, 3 do
local talentId = pvpTalents[i]
local talentID, talentName, icon, selected, available, spellID, unlocked, row, column, known, grantedByAura = GetPvpTalentInfoByID(talentId)
print(talentName)
end
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "PvPTalentUpdate", "OnPvPTalentUpdate")
===================================================================================================================================
"UnitDeath": when an unit died
===================================================================================================================================
function MyAddonObject.OnUnitDeath(unitId)
print(UnitName(unitId) .. " died.")
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "UnitDeath", "OnUnitDeath")
===================================================================================================================================
"UnitAlive": when an unit revives
===================================================================================================================================
function MyAddonObject.OnUnitRess(unitId)
print(UnitName(unitId) .. " is alive.")
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "UnitAlive", "OnUnitRess")
===================================================================================================================================
"KeystoneUpdate": triggered when the list of keystones got an update
===================================================================================================================================
function MyAddonObject.OnKeystoneUpdate(unitName, keystoneInfo, allKeystoneInfo)
local mapName = C_ChallengeMode.GetMapUIInfo(keystoneInfo.mythicPlusMapID)
print(unitName .. " has a " .. keystoneInfo.level .. " keystone for map " .. mapName .. ".")
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "KeystoneUpdate", "OnKeystoneUpdate")
===================================================================================================================================
"KeystoneWipe": triggered after the call openRaidLib.WipeKeystoneData()
===================================================================================================================================
function MyAddonObject.OnKeystoneUpdate(allKeystoneInfo)
print("no keystone data:", next(allKeystoneInfo) == nil)
end
--registering the callback:
openRaidLib.RegisterCallback(MyAddonObject, "KeystoneWipe", "OnKeystoneWipe")