(feature/Prototypes) add Faction Reputation trigger (#42)

This commit is contained in:
NoM0Re
2025-04-15 15:16:57 +02:00
committed by GitHub
parent fd3324e9b7
commit 6fc121a17a
15 changed files with 1526 additions and 13 deletions
-1
View File
@@ -2388,4 +2388,3 @@ L["Zoom"] = "Zoom"
--[[Translation missing --]]
L["Zoom Animation"] = "Zoom Animation"
L["Zul'Gurub"] = "Zul'Gurub"
-1
View File
@@ -1545,7 +1545,6 @@ L["Zoom"] = "Zoom"
L["Zoom Animation"] = "Zoom Animation"
L["Zul'Gurub"] = "Zul'Gurub"
-- Make missing translations available
setmetatable(WeakAuras.L, {__index = function(self, key)
self[key] = (key or "")
-1
View File
@@ -1491,4 +1491,3 @@ L["Zone Name"] = "Nombre de zona"
L["Zoom"] = "Zoom"
L["Zoom Animation"] = "Animación de zoom"
L["Zul'Gurub"] = "Zul'Gurub"
-1
View File
@@ -1492,4 +1492,3 @@ L["Zone Name"] = "Nombre de zona"
L["Zoom"] = "Zoom"
L["Zoom Animation"] = "Animación de zoom"
L["Zul'Gurub"] = "Zul'Gurub"
-1
View File
@@ -2178,4 +2178,3 @@ L["Zoom"] = "Zoom"
--[[Translation missing --]]
L["Zoom Animation"] = "Zoom Animation"
L["Zul'Gurub"] = "Zul'Gurub"
-1
View File
@@ -2687,4 +2687,3 @@ L["Zoom"] = "Zoom"
L["Zoom Animation"] = "Zoom Animation"
--[[Translation missing --]]
L["Zul'Gurub"] = "Zul'Gurub"
-1
View File
@@ -1548,4 +1548,3 @@ L["Zone Name"] = "지역 이름"
L["Zoom"] = "확대"
L["Zoom Animation"] = "확대 애니메이션"
L["Zul'Gurub"] = "줄구룹"
-1
View File
@@ -2612,4 +2612,3 @@ L["Zoom"] = "Zoom"
L["Zoom Animation"] = "Zoom Animation"
--[[Translation missing --]]
L["Zul'Gurub"] = "Zul'Gurub"
-1
View File
@@ -1546,4 +1546,3 @@ L["Zone Name"] = "Название игровой зоны"
L["Zoom"] = "Масштаб"
L["Zoom Animation"] = "Анимация масштаба"
L["Zul'Gurub"] = "Зул'Гуруб"
File diff suppressed because it is too large Load Diff
-1
View File
@@ -1543,4 +1543,3 @@ L["Zone Name"] = "地图名称"
L["Zoom"] = "缩放"
L["Zoom Animation"] = "缩放动画"
L["Zul'Gurub"] = "祖尔格拉布"
-1
View File
@@ -1522,4 +1522,3 @@ L["Zone Name"] = "區域名稱"
L["Zoom"] = "縮放"
L["Zoom Animation"] = "縮放動畫"
L["Zul'Gurub"] = "祖爾格拉布"
+6
View File
@@ -975,6 +975,7 @@ function Private.Modernize(data, oldSnapshot)
["Conditions"] = "unit",
["Spell Known"] = "spell",
["Cooldown Ready (Item)"] = "item",
["Faction Reputation"] = "unit",
["Pet Behavior"] = "unit",
["Range Check"] = "unit",
["Character Stats"] = "unit",
@@ -1839,6 +1840,11 @@ function Private.Modernize(data, oldSnapshot)
"deficit",
"maxhealth",
},
["Faction Reputation"] = {
"value",
"total",
"percentRep",
},
["Location"] = {
"zone",
"subzone",
+169
View File
@@ -1865,6 +1865,175 @@ Private.event_prototypes = {
automaticrequired = true,
progressType = "none"
},
["Faction Reputation"] = {
type = "unit",
progressType = "static",
events = {
["events"] = {
"UPDATE_FACTION",
}
},
internal_events = {"WA_DELAYED_PLAYER_ENTERING_WORLD"},
force_events = "UPDATE_FACTION",
name = L["Faction Reputation"],
statesParameter = "one",
automaticrequired = true,
init = function(trigger)
local ret = [=[
local useWatched = %s
local factionID = useWatched and Private.ExecEnv.GetWatchedFactionId() or %q
local minValue, maxValue, currentValue
local factionData = Private.ExecEnv.GetFactionDataByID(factionID)
if not factionData then return end;
local name, description = factionData.name, factionData.description
local standingID = factionData.reaction
local hasRep = factionData.isHeaderWithRep
local barMin, barMax, barValue = factionData.currentReactionThreshold, factionData.nextReactionThreshold, factionData.currentStanding
local atWarWith, canToggleAtWar, isHeader, isCollapsed, isWatched, isChild = factionData.atWarWith, factionData. canToggleAtWar, factionData.isHeader, factionData.isCollapsed, factionData.isWatched, factionData.isChild
minValue, maxValue, currentValue = barMin, barMax, barValue
local standing
if tonumber(standingID) then
standing = GetText("FACTION_STANDING_LABEL"..standingID, UnitSex("player"))
end
local isCapped = standingID == 8 and currentValue >= 42999
]=]
return ret:format(trigger.use_watched and "true" or "false", trigger.factionID or 0)
end,
args = {
{
name = "progressType",
hidden = true,
init = "'static'",
store = true,
test = "true"
},
{
name = "watched",
display = L["Use Watched Faction"],
type = "toggle",
test = "true",
reloadOptions = true,
},
{
name = "factionID",
display = L["Faction"],
required = true,
type = "select",
itemControl = "Dropdown-Currency",
values = Private.GetReputations,
headers = Private.GetReputationsHeaders,
sorted = true,
sortOrder = function()
local sorted = Private.GetReputationsSorted()
local sortOrder = {}
for key, value in pairs(Private.GetReputations()) do
tinsert(sortOrder, key)
end
table.sort(sortOrder, function(aKey, bKey)
local aValue = sorted[aKey]
local bValue = sorted[bKey]
return aValue < bValue
end)
return sortOrder
end,
conditionType = "select",
enable = function(trigger)
return not trigger.use_watched
end,
reloadOptions = true,
test = "true",
},
{
name = "name",
display = L["Faction Name"],
type = "string",
store = true,
hidden = "true",
init = "name",
test = "true"
},
{
name = "value",
display = L["Reputation"],
type = "number",
store = true,
init = [[currentValue - minValue]],
conditionType = "number",
progressTotal = "total",
multiEntry = {
operator = "and",
limit = 2
},
},
{
name = "total",
display = L["Total Reputation"],
type = "number",
store = true,
init = [[maxValue - minValue]],
conditionType = "number",
noProgressSource = true,
multiEntry = {
operator = "and",
limit = 2
},
},
{
name = "percentRep",
display = L["Reputation (%)"],
type = "number",
init = "total ~= 0 and (value / total) * 100 or nil",
store = true,
conditionType = "number",
noProgressSource = true,
multiEntry = {
operator = "and",
limit = 2
},
},
{
name = "standing",
display = L["Standing"],
type = "string",
init = "standing",
store = true,
hidden = "true",
test = "true"
},
{
name = "standingId",
display = L["Standing"],
type = "select",
values = function()
local ret = {}
for i = 1, 8 do
ret[i] = GetText("FACTION_STANDING_LABEL"..i, UnitSex("player"))
end
return ret
end,
init = "standingID",
store = true,
conditionType = "select",
},
{
name = "capped",
display = L["Capped"],
type = "tristate",
init = "isCapped",
conditionType = "bool",
store = true,
},
{
name = "atWar",
display = L["At War"],
type = "tristate",
init = "atWarWith",
conditionType = "bool",
store = true,
},
}
},
["Experience"] = {
type = "unit",
progressType = "static",
+299 -1
View File
@@ -1607,7 +1607,7 @@ function Private.ExecEnv.GetTotalCountCurrencies(currencyID)
end
local function InitializeCurrencies()
if Private.discovered_currencies then
if Private.discovered_currencies and next(Private.discovered_currencies) then
return
end
Private.discovered_currencies = {}
@@ -1664,6 +1664,124 @@ Private.GetDiscoveredCurrenciesHeaders = function()
return Private.discovered_currencies_headers
end
Private.ExecEnv.GetFactionDataByIndex = function(index)
local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(index)
return {
factionID = name and Private.faction_to_id[name] or 0,
name = name,
description = description,
reaction = standingID,
currentReactionThreshold = barMin,
nextReactionThreshold = barMax,
currentStanding = barValue,
atWarWith = atWarWith or false,
canToggleAtWar = canToggleAtWar,
isChild = isChild,
isHeader = isHeader,
isHeaderWithRep = hasRep,
isCollapsed = isCollapsed,
isWatched = isWatched,
}
end
Private.ExecEnv.GetFactionDataByID = function(ID)
local factionName = ID and Private.id_to_faction[ID]
if factionName then
for index = 1, GetNumFactions() do
local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(index)
if name == factionName then
return {
factionID = ID,
name = name,
description = description,
reaction = standingID,
currentReactionThreshold = barMin,
nextReactionThreshold = barMax,
currentStanding = barValue,
atWarWith = atWarWith or false,
canToggleAtWar = canToggleAtWar,
isChild = isChild,
isHeader = isHeader,
isHeaderWithRep = hasRep,
isCollapsed = isCollapsed,
isWatched = isWatched,
}
end
end
end
end
Private.ExecEnv.GetWatchedFactionId = function()
local factionName = GetWatchedFactionInfo()
return factionName and Private.faction_to_id[factionName]
end
local function InitializeReputations()
if Private.reputations and next(Private.reputations) then
return
end
Private.reputations = {}
Private.reputations_sorted = {}
Private.reputations_headers = {}
-- Dynamic expansion of all collapsed headers
local collapsed = {}
local index = 1
while index <= GetNumFactions() do
local factionData = Private.ExecEnv.GetFactionDataByIndex(index)
if factionData and factionData.isHeader and factionData.isCollapsed then
ExpandFactionHeader(index)
collapsed[factionData.name] = true
end
index = index + 1
end
-- Process all faction data
for i = 1, GetNumFactions() do
local factionData = Private.ExecEnv.GetFactionDataByIndex(i)
if factionData then
if factionData.currentStanding > 0 or not factionData.isHeader then
local factionID = factionData.factionID
if factionID then
Private.reputations[factionID] = factionData.name
Private.reputations_sorted[factionID] = i
end
else
local name = factionData.name
if name then
Private.reputations[name] = name
Private.reputations_sorted[name] = i
Private.reputations_headers[name] = true
end
end
end
end
-- Collapse headers back to their original state
for i = GetNumFactions(), 1, -1 do
local factionData = Private.ExecEnv.GetFactionDataByIndex(i)
if factionData and collapsed[factionData.name] then
CollapseFactionHeader(i)
end
end
end
Private.GetReputations = function()
InitializeReputations()
return Private.reputations
end
Private.GetReputationsSorted = function()
InitializeReputations()
return Private.reputations_sorted
end
Private.GetReputationsHeaders = function()
InitializeReputations()
return Private.reputations_headers
end
Private.combatlog_raid_mark_check_type = {
[0] = RAID_TARGET_NONE,
"|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcon_1:14|t " .. RAID_TARGET_1, -- Star
@@ -3464,6 +3582,186 @@ WeakAuras.StopMotion.animation_types = {
progress = L["Progress"]
}
Private.id_to_faction = {
["21"] = L["Booty Bay"],
["47"] = L["Ironforge"],
["54"] = L["Gnomeregan"],
["59"] = L["Thorium Brotherhood"],
["67"] = L["Horde"],
["68"] = L["Undercity"],
["69"] = L["Darnassus"],
["70"] = L["Syndicate"],
["72"] = L["Stormwind"],
["76"] = L["Orgrimmar"],
["81"] = L["Thunder Bluff"],
["87"] = L["Bloodsail Buccaneers"],
["92"] = L["Gelkis Clan Centaur"],
["93"] = L["Magram Clan Centaur"],
["270"] = L["Zandalar Tribe"],
["349"] = L["Ravenholdt"],
["369"] = L["Gadgetzan"],
["469"] = L["Alliance"],
["470"] = L["Ratchet"],
["509"] = L["The League of Arathor"],
["510"] = L["The Defilers"],
["529"] = L["Argent Dawn"],
["530"] = L["Darkspear Trolls"],
["576"] = L["Timbermaw Hold"],
["577"] = L["Everlook"],
["589"] = L["Wintersaber Trainers"],
["609"] = L["Cenarion Circle"],
["729"] = L["Frostwolf Clan"],
["730"] = L["Stormpike Guard"],
["749"] = L["Hydraxian Waterlords"],
["809"] = L["Shen'dralar"],
["889"] = L["Warsong Outriders"],
["890"] = L["Silverwing Sentinels"],
["909"] = L["Darkmoon Faire"],
["910"] = L["Brood of Nozdormu"],
["911"] = L["Silvermoon City"],
["922"] = L["Tranquillien"],
["930"] = L["Exodar"],
["932"] = L["The Aldor"],
["933"] = L["The Consortium"],
["934"] = L["The Scryers"],
["935"] = L["The Sha'tar"],
["941"] = L["The Mag'har"],
["942"] = L["Cenarion Expedition"],
["946"] = L["Honor Hold"],
["947"] = L["Thrallmar"],
["967"] = L["The Violet Eye"],
["970"] = L["Sporeggar"],
["978"] = L["Kurenai"],
["989"] = L["Keepers of Time"],
["990"] = L["The Scale of the Sands"],
["1011"] = L["Lower City"],
["1012"] = L["Ashtongue Deathsworn"],
["1015"] = L["Netherwing"],
["1031"] = L["Sha'tari Skyguard"],
["1037"] = L["Alliance Vanguard"],
["1038"] = L["Ogri'la"],
["1050"] = L["Valiance Expedition"],
["1052"] = L["Horde Expedition"],
["1064"] = L["The Taunka"],
["1067"] = L["The Hand of Vengeance"],
["1068"] = L["Explorers' League"],
["1073"] = L["The Kalu'ak"],
["1077"] = L["Shattered Sun Offensive"],
["1085"] = L["Warsong Offensive"],
["1090"] = L["Kirin Tor"],
["1091"] = L["The Wyrmrest Accord"],
["1094"] = L["The Silver Covenant"],
["1098"] = L["Knights of the Ebon Blade"],
["1104"] = L["Frenzyheart Tribe"],
["1105"] = L["The Oracles"],
["1106"] = L["Argent Crusade"],
["1119"] = L["The Sons of Hodir"],
["1124"] = L["The Sunreavers"],
["1126"] = L["The Frostborn"],
["1133"] = L["Bilgewater Cartel"],
["1134"] = L["Gilneas"],
["1135"] = L["The Earthen Ring"],
["1156"] = L["The Ashen Verdict"],
["1158"] = L["Guardians of Hyjal"],
["1171"] = L["Therazane"],
["1172"] = L["Dragonmaw Clan"],
["1173"] = L["Ramkahen"],
["1174"] = L["Wildhammer Clan"],
["1177"] = L["Baradin's Wardens"],
["1178"] = L["Hellscream's Reach"],
["10000"] = L["Winterfin Retreat"],
}
Private.faction_to_id = {
[L["Booty Bay"]] = 21,
[L["Ironforge"]] = 47,
[L["Gnomeregan"]] = 54,
[L["Thorium Brotherhood"]] = 59,
[L["Horde"]] = 67,
[L["Undercity"]] = 68,
[L["Darnassus"]] = 69,
[L["Syndicate"]] = 70,
[L["Stormwind"]] = 72,
[L["Orgrimmar"]] = 76,
[L["Thunder Bluff"]] = 81,
[L["Bloodsail Buccaneers"]] = 87,
[L["Gelkis Clan Centaur"]] = 92,
[L["Magram Clan Centaur"]] = 93,
[L["Zandalar Tribe"]] = 270,
[L["Ravenholdt"]] = 349,
[L["Gadgetzan"]] = 369,
[L["Alliance"]] = 469,
[L["Ratchet"]] = 470,
[L["The League of Arathor"]] = 509,
[L["The Defilers"]] = 510,
[L["Argent Dawn"]] = 529,
[L["Darkspear Trolls"]] = 530,
[L["Timbermaw Hold"]] = 576,
[L["Everlook"]] = 577,
[L["Wintersaber Trainers"]] = 589,
[L["Cenarion Circle"]] = 609,
[L["Frostwolf Clan"]] = 729,
[L["Stormpike Guard"]] = 730,
[L["Hydraxian Waterlords"]] = 749,
[L["Shen'dralar"]] = 809,
[L["Warsong Outriders"]] = 889,
[L["Silverwing Sentinels"]] = 890,
[L["Darkmoon Faire"]] = 909,
[L["Brood of Nozdormu"]] = 910,
[L["Silvermoon City"]] = 911,
[L["Tranquillien"]] = 922,
[L["Exodar"]] = 930,
[L["The Aldor"]] = 932,
[L["The Consortium"]] = 933,
[L["The Scryers"]] = 934,
[L["The Sha'tar"]] = 935,
[L["The Mag'har"]] = 941,
[L["Cenarion Expedition"]] = 942,
[L["Honor Hold"]] = 946,
[L["Thrallmar"]] = 947,
[L["The Violet Eye"]] = 967,
[L["Sporeggar"]] = 970,
[L["Kurenai"]] = 978,
[L["Keepers of Time"]] = 989,
[L["The Scale of the Sands"]] = 990,
[L["Lower City"]] = 1011,
[L["Ashtongue Deathsworn"]] = 1012,
[L["Netherwing"]] = 1015,
[L["Sha'tari Skyguard"]] = 1031,
[L["Alliance Vanguard"]] = 1037,
[L["Ogri'la"]] = 1038,
[L["Valiance Expedition"]] = 1050,
[L["Horde Expedition"]] = 1052,
[L["The Taunka"]] = 1064,
[L["The Hand of Vengeance"]] = 1067,
[L["Explorers' League"]] = 1068,
[L["The Kalu'ak"]] = 1073,
[L["Shattered Sun Offensive"]] = 1077,
[L["Warsong Offensive"]] = 1085,
[L["Kirin Tor"]] = 1090,
[L["The Wyrmrest Accord"]] = 1091,
[L["The Silver Covenant"]] = 1094,
[L["Knights of the Ebon Blade"]] = 1098,
[L["Frenzyheart Tribe"]] = 1104,
[L["The Oracles"]] = 1105,
[L["Argent Crusade"]] = 1106,
[L["The Sons of Hodir"]] = 1119,
[L["The Sunreavers"]] = 1124,
[L["The Frostborn"]] = 1126,
[L["Bilgewater Cartel"]] = 1133,
[L["Gilneas"]] = 1134,
[L["The Earthen Ring"]] = 1135,
[L["The Ashen Verdict"]] = 1156,
[L["Guardians of Hyjal"]] = 1158,
[L["Therazane"]] = 1171,
[L["Dragonmaw Clan"]] = 1172,
[L["Ramkahen"]] = 1173,
[L["Wildhammer Clan"]] = 1174,
[L["Baradin's Wardens"]] = 1177,
[L["Hellscream's Reach"]] = 1178,
[L["Winterfin Retreat"]] = 10000,
}
do
local classData = {
DEATHKNIGHT = {