Skip to content
Merged

Beta8 #120

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ globals = {
"C_PlayerInfo",
"C_TradeSkillUI",
"GetItemLevelColor",
"GetAverageItemLevel",
"GetTexCoordsForRoleSmallCircle",
"FormatShortDate",
"BreakUpLargeNumbers",
"HelpTip",
"BattlePassSplashFrame",
"C_BattlePass",
Expand Down
86 changes: 86 additions & 0 deletions Core/API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ local GetTalentTabInfo = GetTalentTabInfo
local RequestBattlefieldScoreData = RequestBattlefieldScoreData
local UnitGroupRolesAssigned = UnitGroupRolesAssigned
local UnitHasVehicleUI = UnitHasVehicleUI
local UnitExists = UnitExists
local UnitGUID = UnitGUID
local UnitThreatSituation = UnitThreatSituation
local IsInInstance = IsInInstance
local IsInGroup = IsInGroup
local IsInRaid = IsInRaid
local IsSpellKnown = IsSpellKnown
local GetNumRaidMembers = GetNumRaidMembers
local GetNumPartyMembers = GetNumPartyMembers
local GetPartyAssignment = GetPartyAssignment

local MAX_TALENT_TABS = MAX_TALENT_TABS
local NONE = NONE
Expand Down Expand Up @@ -109,6 +117,78 @@ function E:GetTalentSpecInfo(isInspect)
return specIdx, specName, specIcon
end

E.GroupRoles = {}
E.GroupUnitsByRole = {
TANK = {},
HEALER = {},
DAMAGER = {},
NONE = {}
}

function E:UnitTankedByGroup(unit)
for _, unitToken in next, E.GroupUnitsByRole.TANK do
if E:GetThreatSituation(unit, unitToken) == 3 then
return unitToken
end
end
end

function E:GetThreatSituation(unit, feedbackUnit)
if not unit or not UnitExists(unit) then return end

if feedbackUnit and feedbackUnit ~= unit and UnitExists(feedbackUnit) then
return UnitThreatSituation(feedbackUnit, unit)
else
return UnitThreatSituation(unit)
end
end

function E:PARTY_MEMBERS_CHANGED()
local isInGroup = IsInGroup()
E.IsInGroup = isInGroup

wipe(E.GroupRoles)

for _, units in next, E.GroupUnitsByRole do
wipe(units)
end

if E.IsInGroup then
for i = 1, GetNumPartyMembers() do
local unit = "party"..i
local guid = UnitGUID(unit)
local role = guid and ((GetPartyAssignment("MAINTANK", unit) and "TANK" or "NONE") or UnitGroupRolesAssigned(unit))
if role then
E.GroupRoles[guid] = role
E.GroupUnitsByRole[role][guid] = unit
end
end
end
end

function E:RAID_ROSTER_UPDATE()
local isInRaid = IsInRaid()
E.IsInGroup = isInRaid

wipe(E.GroupRoles)

for _, units in next, E.GroupUnitsByRole do
wipe(units)
end

if E.IsInGroup then
for i = 1, GetNumRaidMembers() do
local unit = "raid"..i
local guid = UnitGUID(unit)
local role = guid and ((GetPartyAssignment("MAINTANK", unit) and "TANK" or "NONE") or UnitGroupRolesAssigned(unit))
if role then
E.GroupRoles[guid] = role
E.GroupUnitsByRole[role][guid] = unit
end
end
end
end

function E:CheckRole(event)
local talentTree = self:GetTalentSpecInfo()
local role
Expand All @@ -127,6 +207,8 @@ function E:CheckRole(event)

if not role then role = "Melee" end

self.myrole = self:GetPlayerRole()

if self.Role ~= role then
self.Role = role
self.TalentTree = talentTree
Expand Down Expand Up @@ -472,6 +554,10 @@ end
function E:LoadAPI()
self:RegisterEvent("PLAYER_LEVEL_UP")
self:RegisterEvent("PLAYER_ENTERING_WORLD")
self:RegisterEvent("PARTY_MEMBERS_CHANGED")
self:RegisterEvent("RAID_ROSTER_UPDATE")
self:PARTY_MEMBERS_CHANGED()
self:RAID_ROSTER_UPDATE()
self:RegisterEvent("SPELL_UPDATE_USABLE", "CheckRole")
self:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED", "CheckRole")
self:RegisterEvent("PLAYER_TALENT_UPDATE", "CheckRole")
Expand Down
40 changes: 39 additions & 1 deletion Core/Animation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ local random, next, unpack, strsub = random, next, unpack, strsub

E.AnimShake = {{-9,7,-7,12}, {-5,9,-9,5}, {-5,7,-7,5}, {-9,9,-9,9}, {-5,7,-7,5}, {-9,7,-9,5}}
E.AnimShakeH = {-5,5,-2,5,-2,5}
E.AnimElastic = {
function(anim) anim:Stop() anim.elastic[2]:Play() end,
function(anim) anim:Stop() if anim.loop then anim.elastic[1]:Play() end end,
function(anim) anim:Stop() anim.elastic[4]:Play() end,
function(anim) anim:Stop() if anim.loop then anim.elastic[3]:Play() end end
}

function E:FlashLoopFinished(requested)
if not requested then self:Play() end
Expand Down Expand Up @@ -63,6 +69,22 @@ function E:SetUpAnimGroup(obj, Type, ...)
shake.path[4]:SetOrder(4)
shake.path[5]:SetOrder(5)
shake.path[6]:SetOrder(6)
elseif Type == "Elastic" then
local width, height, duration, loop = ...
local elastic = _G.CreateAnimationGroup(obj)
obj.elastic = elastic

for i = 1, 4 do
local anim = elastic:CreateAnimation(i < 3 and "width" or "height")
anim:SetChange((i==1 and width*0.45) or (i==2 and width) or (i==3 and height*0.45) or height)
anim:SetEasing("inout-elastic")
anim:SetDuration(duration)
anim:SetScript("OnFinished", E.AnimElastic[i])
anim.elastic = elastic
anim.loop = loop

elastic[i] = anim
end
else
local x, y, duration, customName = ...
if not customName then customName = "anim" end
Expand Down Expand Up @@ -291,4 +313,20 @@ function E:UIFrameFadeRemoveFrame(frame)

FADEFRAMES[frame] = nil
end
end
end

function E:Elasticize(obj, width, height)
if not obj.elastic then
E:SetUpAnimGroup(obj, "Elastic", width or obj:GetWidth(), height or obj:GetHeight(), 2, false)
end

obj.elastic[1]:Play()
obj.elastic[3]:Play()
end

function E:StopElasticize(obj)
if obj.elastic then
obj.elastic[1]:Stop(true)
obj.elastic[3]:Stop(true)
end
end
Loading
Loading