300 lines
14 KiB
Plaintext
300 lines
14 KiB
Plaintext
|
|
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"
|
|
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
|
|
--by using unitID and spellID
|
|
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromUnitSpellID(unitId, spellId)
|
|
--by using a cooldown info
|
|
local isReady, normalizedPercent, timeLeft, charges, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
|
|
|
|
|
|
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)
|
|
}
|
|
|
|
|
|
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'
|
|
}
|
|
|
|
|
|
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)
|
|
--using the 'unitCooldows' table passed for the updated unit
|
|
for spellId, cooldownInfo in pairs(unitCooldows) do
|
|
local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
|
|
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
|
|
statusbar:SetMinMaxValues(minValue, maxValue)
|
|
statusbar:SetValue(currentValue)
|
|
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
|
|
local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
|
|
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
|
|
statusbar:SetMinMaxValues(0, 1)
|
|
statusbar:SetValue(normalizedPercent)
|
|
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 updated
|
|
@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)
|
|
local isReady, timeLeft, charges, normalizedPercent, minValue, maxValue, currentValue = openRaidLib.GetCooldownStatusFromCooldownInfo(cooldownInfo)
|
|
local statusbar = CreateFrame("statusbar", "MyStatusBar", UIParent)
|
|
statusbar:SetMinMaxValues(minValue, maxValue)
|
|
statusbar:SetValue(currentValue)
|
|
end
|
|
|
|
--registering the callback:
|
|
openRaidLib.RegisterCallback(MyAddonObject, "CooldownUpdate", "OnReceiveCooldownUpdate")
|
|
|
|
===================================================================================================================================
|
|
"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")
|
|
|