(feature/Prototypes) add Faction Reputation trigger (#42)
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user