from retail

This commit is contained in:
Bunny67
2020-07-11 00:19:17 +03:00
parent bbb4ac1c37
commit 6a7003b535
27 changed files with 2317 additions and 647 deletions
+422 -97
View File
@@ -12,6 +12,7 @@ local UnitClass, UnitHealth, UnitHealthMax, UnitName, UnitPower, UnitPowerMax =
local GetSpellInfo, GetItemInfo, GetItemCount, GetItemIcon = GetSpellInfo, GetItemInfo, GetItemCount, GetItemIcon
local GetShapeshiftFormInfo, GetShapeshiftForm = GetShapeshiftFormInfo, GetShapeshiftForm
local GetRuneCooldown, UnitCastingInfo, UnitChannelInfo = GetRuneCooldown, UnitCastingInfo, UnitChannelInfo
local UnitDetailedThreatSituation, UnitThreatSituation = UnitDetailedThreatSituation, UnitThreatSituation
local WeakAuras = WeakAuras
local L = WeakAuras.L
@@ -74,6 +75,17 @@ end
LibRangeCheck:RegisterCallback(LibRangeCheck.CHECKERS_CHANGED, RangeCacheUpdate)
function WeakAuras.UnitDetailedThreatSituation(unit1, unit2)
local ok, aggro, status, threatpct, rawthreatpct, threatvalue = pcall(UnitDetailedThreatSituation, unit1, unit2)
if ok then
return aggro, status, threatpct, rawthreatpct, threatvalue
end
end
local constants = {
nameRealmFilterDesc = L[" Filter formats: 'Name', 'Name-Realm', '-Realm'. \n\nSupports multiple entries, separated by commas\n"],
}
WeakAuras.function_strings = {
count = [[
return function(count)
@@ -718,15 +730,31 @@ WeakAuras.load_prototype = {
},
{
name = "name",
display = L["Player Name"],
type = "tristatestring",
init = "arg"
hidden = true,
init = "arg",
test = "true"
},
{
name = "realm",
display = L["Realm"],
type = "tristatestring",
init = "arg"
hidden = true,
init = "arg",
test = "true"
},
{
name = "namerealm",
display = L["Player Name/Realm"],
type = "string",
test = "nameRealmChecker:Check(player, realm)",
preamble = "local nameRealmChecker = WeakAuras.ParseNameCheck(%q)",
desc = constants.nameRealmFilterDesc,
},
{
name = "namerealmblack",
display = L["Blacklisted Player Name/Realm"],
type = "string",
test = "not nameRealmBlacklistChecker:Check(player, realm)",
preamble = "local nameRealmBlacklistChecker = WeakAuras.ParseNameCheck(%q)",
desc = constants.nameRealmFilterDesc,
},
{
name = "class",
@@ -927,6 +955,10 @@ WeakAuras.event_prototypes = {
local result = {}
AddUnitEventForEvents(result, unit, "UNIT_LEVEL")
AddUnitEventForEvents(result, unit, "UNIT_FACTION")
AddUnitEventForEvents(result, unit, "UNIT_NAME_UPDATE")
if trigger.use_ignoreDead or trigger.use_ignoreDisconnected then
AddUnitEventForEvents(result, unit, "UNIT_FLAGS")
end
return result;
end,
internal_events = function(trigger)
@@ -946,6 +978,7 @@ WeakAuras.event_prototypes = {
unit = string.lower(unit)
local smart = %s
local extraUnit = %q;
local name, realm = WeakAuras.UnitNameWithRealm(unit)
]=];
ret = ret .. unitHelperFunctions.SpecificUnitCheck(trigger)
@@ -980,9 +1013,32 @@ WeakAuras.event_prototypes = {
name = "name",
display = L["Name"],
type = "string",
init = "UnitName(unit)",
store = true,
conditionType = "string"
hidden = true,
test = "true"
},
{
name = "realm",
display = L["Realm"],
type = "string",
store = true,
hidden = true,
test = "true"
},
{
name = "namerealm",
display = L["Unit Name/Realm"],
type = "string",
preamble = "local nameRealmChecker = WeakAuras.ParseNameCheck(%q)",
test = "nameRealmChecker:Check(name, realm)",
conditionType = "string",
conditionPreamble = function(input)
return WeakAuras.ParseNameCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.name, state.realm)
end,
operator_types = "none",
},
{
name = "class",
@@ -1002,11 +1058,31 @@ WeakAuras.event_prototypes = {
store = true,
conditionType = "select"
},
{
name = "ignoreDead",
display = WeakAuras.newFeatureString .. L["Ignore Dead"],
type = "toggle",
width = WeakAuras.doubleWidth,
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end,
init = "not UnitIsDeadOrGhost(unit)"
},
{
name = "ignoreDisconnected",
display = WeakAuras.newFeatureString .. L["Ignore Disconnected"],
type = "toggle",
width = WeakAuras.doubleWidth,
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end,
init = "UnitIsConnected(unit)"
},
{
name = "hostility",
display = L["Hostility"],
type = "select",
init = "WeakAuras.GetPlayerReaciton(unit)",
init = "WeakAuras.GetPlayerReaction(unit)",
values = "hostility_types",
store = true,
conditionType = "select",
@@ -1058,6 +1134,10 @@ WeakAuras.event_prototypes = {
local unit = trigger.unit
local result = {}
AddUnitEventForEvents(result, unit, "UNIT_HEALTH")
AddUnitEventForEvents(result, unit, "UNIT_NAME_UPDATE")
if trigger.use_ignoreDead or trigger.use_ignoreDisconnected then
AddUnitEventForEvents(result, unit, "UNIT_FLAGS")
end
return result
end,
internal_events = function(trigger)
@@ -1072,6 +1152,7 @@ WeakAuras.event_prototypes = {
trigger.unit = trigger.unit or "player";
local ret = [=[
unit = string.lower(unit)
local name, realm = WeakAuras.UnitNameWithRealm(unit)
local smart = %s
]=];
@@ -1132,9 +1213,33 @@ WeakAuras.event_prototypes = {
name = "name",
display = L["Unit Name"],
type = "string",
init = "UnitName(unit)",
store = true,
conditionType = "string"
hidden = true,
test = "true"
},
{
name = "realm",
display = L["Realm"],
type = "string",
store = true,
hidden = true,
test = "true"
},
{
name = "namerealm",
display = L["Unit Name/Realm"],
type = "string",
preamble = "local nameRealmChecker = WeakAuras.ParseNameCheck(%q)",
test = "nameRealmChecker:Check(name, realm)",
conditionType = "string",
conditionPreamble = function(input)
return WeakAuras.ParseNameCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.name, state.realm)
end,
operator_types = "none",
desc = constants.nameRealmFilterDesc,
},
{
name = "npcId",
@@ -1153,6 +1258,26 @@ WeakAuras.event_prototypes = {
store = true,
conditionType = "select"
},
{
name = "ignoreDead",
display = WeakAuras.newFeatureString .. L["Ignore Dead"],
type = "toggle",
width = WeakAuras.doubleWidth,
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end,
init = "not UnitIsDeadOrGhost(unit)"
},
{
name = "ignoreDisconnected",
display = WeakAuras.newFeatureString .. L["Ignore Disconnected"],
type = "toggle",
width = WeakAuras.doubleWidth,
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end,
init = "UnitIsConnected(unit)"
},
{
name = "name",
hidden = true,
@@ -1184,6 +1309,11 @@ WeakAuras.event_prototypes = {
AddUnitEventForEvents(result, unit, "UNIT_MAXRUNIC_POWER")
AddUnitEventForEvents(result, unit, "UNIT_DISPLAYPOWER")
AddUnitEventForEvents(result, unit, "UNIT_HAPPINESS")
AddUnitEventForEvents(result, unit, "UNIT_NAME_UPDATE")
if trigger.use_ignoreDead or trigger.use_ignoreDisconnected then
AddUnitEventForEvents(result, unit, "UNIT_FLAGS")
end
return result;
end,
@@ -1200,6 +1330,7 @@ WeakAuras.event_prototypes = {
trigger.unit = trigger.unit or "player";
local ret = [=[
unit = string.lower(unit)
local name, realm = WeakAuras.UnitNameWithRealm(unit)
local smart = %s
local powerType = %s;
local unitPowerType = UnitPowerType(unit);
@@ -1290,9 +1421,33 @@ WeakAuras.event_prototypes = {
name = "name",
display = L["Unit Name"],
type = "string",
init = "UnitName(unit)",
store = true,
conditionType = "string"
hidden = true,
test = "true"
},
{
name = "realm",
display = L["Realm"],
type = "string",
store = true,
hidden = true,
test = "true"
},
{
name = "namerealm",
display = L["Unit Name/Realm"],
type = "string",
preamble = "local nameRealmChecker = WeakAuras.ParseNameCheck(%q)",
test = "nameRealmChecker:Check(name, realm)",
conditionType = "string",
conditionPreamble = function(input)
return WeakAuras.ParseNameCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.name, state.realm)
end,
operator_types = "none",
desc = constants.nameRealmFilterDesc,
},
{
name = "npcId",
@@ -1311,6 +1466,26 @@ WeakAuras.event_prototypes = {
store = true,
conditionType = "select"
},
{
name = "ignoreDead",
display = WeakAuras.newFeatureString .. L["Ignore Dead"],
type = "toggle",
width = WeakAuras.doubleWidth,
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end,
init = "not UnitIsDeadOrGhost(unit)"
},
{
name = "ignoreDisconnected",
display = WeakAuras.newFeatureString .. L["Ignore Disconnected"],
type = "toggle",
width = WeakAuras.doubleWidth,
enable = function(trigger)
return trigger.unit == "group" or trigger.unit == "raid" or trigger.unit == "party"
end,
init = "UnitIsConnected(unit)"
},
{
hidden = true,
test = "WeakAuras.UnitExistsFixed(unit, smart) and specificUnitCheck"
@@ -1341,7 +1516,8 @@ WeakAuras.event_prototypes = {
init = "arg",
hidden = "true",
test = "true",
store = true
store = true,
display = L["Source GUID"]
},
{
name = "sourceUnit",
@@ -1415,7 +1591,8 @@ WeakAuras.event_prototypes = {
init = "arg",
hidden = "true",
test = "true",
store = true
store = true,
display = L["Destination GUID"]
},
{
name = "destUnit",
@@ -4401,26 +4578,42 @@ WeakAuras.event_prototypes = {
},
["Threat Situation"] = {
type = "status",
events = {
["unit_events"] = {
["player"] = {"UNIT_THREAT_SITUATION_UPDATE"}
}
},
internal_events = function(trigger)
events = function(trigger)
local result = {}
AddUnitChangeInternalEvents(trigger.unit, result)
if trigger.threatUnit and trigger.threatUnit ~= "none" then
AddUnitEventForEvents(result, trigger.threatUnit, "UNIT_THREAT_LIST_UPDATE")
else
AddUnitEventForEvents(result, "player", "UNIT_THREAT_SITUATION_UPDATE")
end
return result
end,
force_events = "UNIT_THREAT_SITUATION_UPDATE",
internal_events = function(trigger)
local result = {}
if trigger.threatUnit and trigger.threatUnit ~= "none" then
AddUnitChangeInternalEvents(trigger.threatUnit, result)
end
return result
end,
force_events = "UNIT_THREAT_LIST_UPDATE",
name = L["Threat Situation"],
init = function(trigger)
local ret = [[
local status = UnitThreatSituation('player', %s) or -1;
local aggro = status == 2 or status == 3;
local unit = %s
local ok = true
local aggro, status, threatpct, rawthreatpct, threatvalue, threattotal
if unit then
aggro, status, threatpct, rawthreatpct, threatvalue = WeakAuras.UnitDetailedThreatSituation('player', unit)
threattotal = (threatvalue or 0) * 100 / (threatpct or 1)
else
status = UnitThreatSituation('player')
aggro = status == 2 or status == 3
threatpct, rawthreatpct, threatvalue, threattotal = 100, 100, 0, 100
end
]];
return ret:format(trigger.threatUnit and trigger.threatUnit ~= "none" and "[["..trigger.threatUnit.."]]" or "nil");
end,
canHaveDuration = true,
statesParameter = "one",
args = {
{
name = "threatUnit",
@@ -4435,17 +4628,68 @@ WeakAuras.event_prototypes = {
name = "status",
display = L["Status"],
type = "select",
values = "unit_threat_situation_types"
values = "unit_threat_situation_types",
store = true,
conditionType = "select"
},
{
name = "aggro",
display = L["Aggro"],
type = "tristate"
store = true,
conditionType = "bool",
},
{
name = "threatpct",
display = L["Threat Percent"],
desc = L["Your threat on the mob as a percentage of the amount required to pull aggro. Will pull aggro at 100."],
type = "number",
store = true,
conditionType = "number",
enable = function(trigger) return trigger.threatUnit ~= "none" end,
},
{
name = "rawthreatpct",
display = L["Raw Threat Percent"],
desc = L["Your threat as a percentage of the tank's current threat."],
type = "number",
store = true,
conditionType = "number",
enable = function(trigger) return trigger.threatUnit ~= "none" end,
},
{
name = "threatvalue",
display = L["Threat Value"],
desc = L["Your total threat on the mob."],
type = "number",
store = true,
conditionType = "number",
enable = function(trigger) return trigger.threatUnit ~= "none" end,
},
{
name = "value",
hidden = true,
init = "threatvalue",
store = true,
test = "true"
},
{
name = "total",
hidden = true,
init = "threattotal",
store = true,
test = "true"
},
{
name = "progressType",
hidden = true,
init = "'static'",
store = true,
test = "true"
},
{
hidden = true,
test = "status ~= -1"
},
test = "status ~= nil and ok"
}
},
automaticrequired = true
},
@@ -4483,6 +4727,7 @@ WeakAuras.event_prototypes = {
AddUnitEventForEvents(result, unit, "UNIT_SPELLCAST_NOT_INTERRUPTIBLE")
AddUnitEventForEvents(result, unit, "UNIT_SPELLCAST_INTERRUPTED")
AddUnitEventForEvents(result, unit, "UNIT_TARGET")
AddUnitEventForEvents(result, unit, "UNIT_NAME_UPDATE")
return result
end,
internal_events = function(trigger)
@@ -4499,6 +4744,11 @@ WeakAuras.event_prototypes = {
trigger.unit = trigger.unit or "player";
local ret = [=[
unit = string.lower(unit)
local destUnit = unit .. '-target'
local sourceName, sourceRealm = WeakAuras.UnitNameWithRealm(unit)
local destName, destRealm = WeakAuras.UnitNameWithRealm(destUnit)
destName = destName or ""
destRealm = destRealm or ""
local smart = %s
local remainingCheck = %s
local inverseTrigger = %s
@@ -4678,18 +4928,43 @@ WeakAuras.event_prototypes = {
{
name = "sourceName",
display = L["Caster Name"],
type = "string",
store = true,
hidden = true,
test = "true",
init = "UnitName(unit)",
enable = function(trigger) return not trigger.use_inverse end,
},
{
name = "sourceRealm",
display = L["Caster Realm"],
type = "string",
store = true,
hidden = true,
test = "true",
enable = function(trigger) return not trigger.use_inverse end,
},
{
name = "sourceNameRealm",
display = L["Source Unit Name/Realm"],
type = "string",
preamble = "local sourceNameRealmChecker = WeakAuras.ParseNameCheck(%q)",
test = "sourceNameRealmChecker:Check(sourceName, sourceRealm)",
conditionType = "string",
conditionPreamble = function(input)
return WeakAuras.ParseNameCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.sourceName, state.sourceRealm)
end,
operator_types = "none",
enable = function(trigger) return not trigger.use_inverse end,
desc = constants.nameRealmFilterDesc,
},
{
name = "destUnit",
display = L["Caster's Target "],
type = "unit",
values = "actual_unit_types_with_specific",
init = "unit .. '-target'",
conditionType = "unit",
conditionTest = function(state, unit, op)
return state and state.show and state.destUnit and ((UnitIsUnit(state.destUnit, unit) == 1 and true or false) == (op == "=="))
@@ -4701,12 +4976,38 @@ WeakAuras.event_prototypes = {
{
name = "destName",
display = L["Name of Caster's Target"],
type = "string",
store = true,
hidden = true,
test = "true",
init = "UnitName(destUnit)",
enable = function(trigger) return not trigger.use_inverse end,
},
{
name = "destRealm",
display = L["Realm of Caster's Target"],
type = "string",
store = true,
hidden = true,
test = "true",
enable = function(trigger) return not trigger.use_inverse end,
},
{
name = "destNameRealm",
display = L["Name/Realm of Caster's Target"],
type = "string",
preamble = "local destNameRealmChecker = WeakAuras.ParseNameCheck(%q)",
test = "destNameRealmChecker:Check(destName, destRealm)",
conditionType = "string",
conditionPreamble = function(input)
return WeakAuras.ParseNameCheck(input)
end,
conditionTest = function(state, needle, op, preamble)
return preamble:Check(state.destName, state.destRealm)
end,
operator_types = "none",
enable = function(trigger) return not trigger.use_inverse end,
desc = constants.nameRealmFilterDesc,
},
{
name = "inverse",
display = L["Inverse"],
@@ -5336,7 +5637,7 @@ WeakAuras.event_prototypes = {
name = "range",
display = L["Distance"],
type = "number",
operator_types_without_equal = true,
operator_types = "without_equal",
test = "triggerResult",
conditionType = "number",
conditionTest = function(state, needle, needle2)
@@ -5360,97 +5661,121 @@ WeakAuras.event_prototypes["BigWigs Timer"] = nil
WeakAuras.dynamic_texts = {
["p"] = {
func = function(state, region)
if not state then return "" end
get = function(state)
if not state then return nil end
if state.progressType == "static" then
return state.value or ""
return state.value or nil
end
if state.progressType == "timed" then
if not state.expirationTime or not state.duration then
return ""
return nil
end
local remaining = state.expirationTime - GetTime();
local duration = state.duration;
local remainingStr = "";
if remaining == math.huge then
remainingStr = " ";
elseif remaining > 60 then
remainingStr = string.format("%i:", math.floor(remaining / 60));
remaining = remaining % 60;
remainingStr = remainingStr..string.format("%02i", remaining);
elseif remaining > 0 then
local progressPrecision = region.progressPrecision and math.abs(region.progressPrecision) or 1
-- remainingStr = remainingStr..string.format("%."..(data.progressPrecision or 1).."f", remaining);
if progressPrecision == 4 and remaining <= 3 then
remainingStr = remainingStr..string.format("%.1f", remaining);
elseif progressPrecision == 5 and remaining <= 3 then
remainingStr = remainingStr..string.format("%.2f", remaining);
elseif (progressPrecision == 4 or progressPrecision == 5) and remaining > 3 then
remainingStr = remainingStr..string.format("%d", remaining);
else
remainingStr = remainingStr..string.format("%.".. progressPrecision .."f", remaining);
end
else
remainingStr = " ";
end
return remainingStr
return remaining >= 0 and remaining or nil
end
end,
func = function(remaining, state, progressPrecision)
progressPrecision = progressPrecision or 1
if not state or state.progressType ~= "timed" then
return remaining
end
if type(remaining) ~= "number" then
return ""
end
local remainingStr = "";
if remaining == math.huge then
remainingStr = " ";
elseif remaining > 60 then
remainingStr = string.format("%i:", math.floor(remaining / 60));
remaining = remaining % 60;
remainingStr = remainingStr..string.format("%02i", remaining);
elseif remaining > 0 then
if progressPrecision == 4 and remaining <= 3 then
remainingStr = remainingStr..string.format("%.1f", remaining);
elseif progressPrecision == 5 and remaining <= 3 then
remainingStr = remainingStr..string.format("%.2f", remaining);
elseif progressPrecision == 6 and remaining <= 3 then
remainingStr = remainingStr..string.format("%.3f", remaining);
elseif (progressPrecision == 4 or progressPrecision == 5 or progressPrecision == 6) and remaining > 3 then
remainingStr = remainingStr..string.format("%d", remaining);
else
remainingStr = remainingStr..string.format("%.".. progressPrecision .."f", remaining);
end
else
remainingStr = " ";
end
return remainingStr
end
},
["t"] = {
func = function(state, region)
get = function(state)
if not state then return "" end
if state.progressType == "static" then
return state.total or ""
return state.total, false
end
if state.progressType == "timed" then
if not state.duration then
return ""
return nil
end
-- Format a duration time string
local durationStr = "";
local duration = state.duration
if math.abs(duration) == math.huge or tostring(duration) == "nan" then
durationStr = " ";
elseif duration > 60 then
durationStr = string.format("%i:", math.floor(duration / 60));
duration = duration % 60;
durationStr = durationStr..string.format("%02i", duration);
elseif duration > 0 then
local totalPrecision = region.totalPrecision and math.abs(region.totalPrecision) or 1
if totalPrecision == 4 and duration <= 3 then
durationStr = durationStr..string.format("%.1f", duration);
elseif totalPrecision == 5 and duration <= 3 then
durationStr = durationStr..string.format("%.2f", duration);
elseif (totalPrecision == 4 or totalPrecision == 5) and duration > 3 then
durationStr = durationStr..string.format("%d", duration);
else
durationStr = durationStr..string.format("%."..totalPrecision.."f", duration);
end
else
durationStr = " ";
end
return durationStr
return state.duration, true
end
end,
func = function(duration, state, totalPrecision)
if state.progressType ~= "timed" then
return duration
end
if type(duration) ~= "number" then
return ""
end
local durationStr = "";
if math.abs(duration) == math.huge or tostring(duration) == "nan" then
durationStr = " ";
elseif duration > 60 then
durationStr = string.format("%i:", math.floor(duration / 60));
duration = duration % 60;
durationStr = durationStr..string.format("%02i", duration);
elseif duration > 0 then
if totalPrecision == 4 and duration <= 3 then
durationStr = durationStr..string.format("%.1f", duration);
elseif totalPrecision == 5 and duration <= 3 then
durationStr = durationStr..string.format("%.2f", duration);
elseif totalPrecision == 6 and duration <= 3 then
durationStr = durationStr..string.format("%.3f", duration);
elseif (totalPrecision == 4 or totalPrecision == 5 or totalPrecision == 6) and duration > 3 then
durationStr = durationStr..string.format("%d", duration);
else
durationStr = durationStr..string.format("%."..totalPrecision.."f", duration);
end
else
durationStr = " ";
end
return durationStr
end
},
["n"] = {
func = function(state)
if not state then return "" end
return state.name or state.id
get = function(state)
return state.name or state.id or "", true
end,
func = function(v)
return v
end
},
["i"] = {
func = function(state)
if not state or not state.icon then return "|TInterface\\Icons\\INV_Misc_QuestionMark:12:12:0:0:64:64:4:60:4:60|t" end
return "|T".. state.icon ..":12:12:0:0:64:64:4:60:4:60|t"
get = function(state)
return state.icon or "Interface\\Icons\\INV_Misc_QuestionMark"
end,
func = function(v)
return "|T".. v ..":12:12:0:0:64:64:4:60:4:60|t"
end
},
["s"] = {
func = function(state)
get = function(state)
if not state or state.stacks == 0 then return "" end
return state.stacks
end,
func = function(v)
return v
end
}
};