Skip to content

Commit

Permalink
Hide config options that can be hidden by default behind conditions
Browse files Browse the repository at this point in the history
Config changes:

- Remove "Is your Crit Chance Lucky?" - The only sources can already be
  enabled with existing conditions and the lucky is implied after that
  (Blood Sacrament, Focus Mod, Dance with Death)
- Only show "# of times skill has chained" if there is condition behind
  it (Gloomfang for example)
- Only show "# of times skill has pierced" if there is condition behind
  it (Drillneck for example)
- Only show "melee distance to enemy" if there is stat that depends on
  melee proximity (Close Combat, Slayer for example)
- Only show "projectile travel distance if there is stat that depends on
  distance ramp (Point Blank, Longshot for example)
- Only show "is enemy bleeding" if there is condition behind it
  (Bloodletting for example)
- Only show "# of poison on enemy" if there is condition behind it (Vile
  Toxins for example)A
- Only show "is the enemy maimed" if there is condition behind it (Maim
  support for example)
- Only show "is enemy burning" if there is condition behind it
- Only show "is enemy ignited" if there is condition behind it
  (Snowforged for example)
- Only show "is enemy frozen" if there is condition behind it
  (NOTE: currently does nothing because its default condition in
  calcsetup)
- Only show "effect of shock" if enemy is shocked
- Only show "is enemy on consecrated ground" if there is condition
  behind it (Bottled Faith for example)
- Only show "disable ehp gain on block" if there are any on block
  effects

New functionality:

- ifStat and ifEnemyStat for PerStat and StatCondition config checks
- ifTagType for tag type config checks
- ifModList for list for ifMod checks
- config tab now supports multiple if checks at once

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
  • Loading branch information
deathbeam committed Feb 25, 2023
1 parent 7127369 commit a4815f2
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 74 deletions.
184 changes: 129 additions & 55 deletions src/Classes/ConfigTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,56 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
else
control = new("Control", {"TOPLEFT",lastSection,"TOPLEFT"}, 234, 0, 16, 16)
end

local shownFuncs = {}
control.shown = function()
local shown = true
for i, shownFunc in ipairs(shownFuncs) do
shown = shown and shownFunc()
end
return shown
end

local tooltipFuncs = {}
control.tooltipText = function()
local tooltipText = ""
local totalLen = #tooltipFuncs
for i, tooltipFunc in ipairs(tooltipFuncs) do
local curTooltipText = type(tooltipFunc) == "string" and tooltipFunc or tooltipFunc()
if curTooltipText and curTooltipText ~= "" then
if tooltipText ~= "" then
tooltipText = tooltipText .. "\n"
end
tooltipText = tooltipText .. curTooltipText
end
end
return tooltipText
end

if varData.tooltip then
t_insert(tooltipFuncs, varData.tooltip)
end
if varData.ifNode then
control.shown = function()
t_insert(shownFuncs, function()
if self.build.spec.allocNodes[varData.ifNode] then
return true
end
local node = self.build.spec.nodes[varData.ifNode]
if node and node.type == "Keystone" then
return self.build.calcsTab.mainEnv.keystonesAdded[node.dn]
end
end
control.tooltipText = function()
end)
t_insert(tooltipFuncs, function()
return "This option is specific to '"..self.build.spec.nodes[varData.ifNode].dn.."'."..(varData.tooltip and "\n"..varData.tooltip or "")
end
elseif varData.ifOption then
control.shown = function()
end)
end
if varData.ifOption then
t_insert(shownFuncs, function()
return self.input[varData.ifOption]
end
control.tooltipText = varData.tooltip
elseif varData.ifCond or varData.ifMinionCond or varData.ifEnemyCond then
control.shown = function()
end)
end
if varData.ifCond or varData.ifMinionCond or varData.ifEnemyCond then
t_insert(shownFuncs, function()
local mainEnv = self.build.calcsTab.mainEnv
if self.input[varData.var] then
if varData.implyCondList then
Expand All @@ -128,28 +158,27 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
else
return mainEnv.enemyConditionsUsed[varData.ifEnemyCond]
end
end
control.tooltipText = function()
end)
t_insert(tooltipFuncs, function()
if launch.devModeAlt then
local out = varData.tooltip or ""
local list
if varData.ifCond then
list = self.build.calcsTab.mainEnv.conditionsUsed[varData.ifCond]
elseif varData.ifMinionCond then
list = self.build.calcsTab.mainEnv.minionConditionsUsed[varData.ifMinionCond]
else
list = self.build.calcsTab.mainEnv.enemyConditionsUsed[varData.ifEnemyCond]
end
for _, mod in ipairs(list) do
out = (#out > 0 and out.."\n" or out) .. modLib.formatMod(mod) .. "|" .. mod.source
local out = ""
local list
if varData.ifCond then
list = self.build.calcsTab.mainEnv.conditionsUsed[varData.ifCond]
elseif varData.ifMinionCond then
list = self.build.calcsTab.mainEnv.minionConditionsUsed[varData.ifMinionCond]
else
list = self.build.calcsTab.mainEnv.enemyConditionsUsed[varData.ifEnemyCond]
end
for _, mod in ipairs(list) do
out = (#out > 0 and out.."\n" or out) .. modLib.formatMod(mod) .. "|" .. mod.source
end
return out
end
return out
else
return varData.tooltip
end
end
elseif varData.ifMult or varData.ifEnemyMult then
control.shown = function()
end)
end
if varData.ifMult or varData.ifEnemyMult then
t_insert(shownFuncs, function()
local mainEnv = self.build.calcsTab.mainEnv
if self.input[varData.var] then
if varData.implyCondList then
Expand All @@ -170,34 +199,82 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
else
return mainEnv.enemyMultipliersUsed[varData.ifEnemyMult]
end
end
control.tooltipText = function()
end)
t_insert(tooltipFuncs, function()
if launch.devModeAlt then
local out = varData.tooltip or ""
local out = ""
for _, mod in ipairs(self.build.calcsTab.mainEnv.multipliersUsed[varData.ifMult]) do
out = (#out > 0 and out.."\n" or out) .. modLib.formatMod(mod) .. "|" .. mod.source
end
return out
end
end)
end
if varData.ifStat or varData.ifEnemyStat then
t_insert(shownFuncs, function()
local mainEnv = self.build.calcsTab.mainEnv
if self.input[varData.var] then
if varData.implyCondList then
for _, implyCond in ipairs(varData.implyCondList) do
if (implyCond and mainEnv.conditionsUsed[implyCond]) then
return true
end
end
end
if (varData.implyCond and mainEnv.conditionsUsed[varData.implyCond]) or
(varData.implyMinionCond and mainEnv.minionConditionsUsed[varData.implyMinionCond]) or
(varData.implyEnemyCond and mainEnv.enemyConditionsUsed[varData.implyEnemyCond]) then
return true
end
end
if varData.ifStat then
return mainEnv.perStatsUsed[varData.ifStat]
else
return varData.tooltip
return mainEnv.enemyPerStatsUsed[varData.ifEnemyStat]
end
end
elseif varData.ifFlag then
control.shown = function()
end)
t_insert(tooltipFuncs, function()
if launch.devModeAlt then
local out = ""
for _, mod in ipairs(self.build.calcsTab.mainEnv.perStatsUsed[varData.ifStat]) do
out = (#out > 0 and out.."\n" or out) .. modLib.formatMod(mod) .. "|" .. mod.source
end
return out
end
end)
end
if varData.ifFlag then
t_insert(shownFuncs, function()
local skillModList = self.build.calcsTab.mainEnv.player.mainSkill.skillModList
local skillFlags = self.build.calcsTab.mainEnv.player.mainSkill.skillFlags
-- Check both the skill mods for flags and flags that are set via calcPerform
return skillFlags[varData.ifFlag] or skillModList:Flag(nil, varData.ifFlag)
end
control.tooltipText = varData.tooltip
elseif varData.ifMod then
control.shown = function()
end)
end
if varData.ifMod or varData.ifModList then
t_insert(shownFuncs, function()
local skillModList = self.build.calcsTab.mainEnv.player.mainSkill.skillModList
return skillModList:Sum(varData.ifModType or "BASE", nil, varData.ifMod) > 0
end
control.tooltipText = varData.tooltip
elseif varData.ifSkill or varData.ifSkillList then
control.shown = function()
if varData.ifModList then
for _, ifMod in ipairs(varData.ifModList) do
if skillModList:Sum(varData.ifModType or "BASE", nil, ifMod) > 0 then
return true
end
end
else
return skillModList:Sum(varData.ifModType or "BASE", nil, varData.ifMod) > 0
end
end)
end
if varData.ifTagType then
t_insert(shownFuncs, function()
if self.build.calcsTab.mainEnv.tagTypesUsed[varData.ifTagType] then
return true
end
return false
end)
end
if varData.ifSkill or varData.ifSkillList then
t_insert(shownFuncs, function()
if varData.ifSkillList then
for _, skillName in ipairs(varData.ifSkillList) do
if self.build.calcsTab.mainEnv.skillsUsed[skillName] then
Expand All @@ -207,10 +284,10 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
else
return self.build.calcsTab.mainEnv.skillsUsed[varData.ifSkill]
end
end
control.tooltipText = varData.tooltip
elseif varData.ifSkillFlag or varData.ifSkillFlagList then
control.shown = function()
end)
end
if varData.ifSkillFlag or varData.ifSkillFlagList then
t_insert(shownFuncs, function()
if varData.ifSkillFlagList then
for _, skillFlag in ipairs(varData.ifSkillFlagList) do
for _, activeSkill in ipairs(self.build.calcsTab.mainEnv.player.activeSkillList) do
Expand All @@ -228,10 +305,7 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
end
end
return false
end
control.tooltipText = varData.tooltip
else
control.tooltipText = varData.tooltip
end)
end
if varData.tooltipFunc then
control.tooltipFunc = varData.tooltipFunc
Expand Down Expand Up @@ -273,7 +347,7 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
innerTooltipFunc(tooltip, ...)
else
local tooltipText = control:GetProperty("tooltipText")
if tooltipText then
if tooltipText and tooltipText ~= '' then
tooltip:AddLine(14, tooltipText)
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/Classes/TooltipHost.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ function TooltipHostClass:DrawTooltip(x, y, width, height, viewPort, ...)
self.tooltip:Draw(x, y, width, height, viewPort)
else
local tooltipText = self.Object:GetProperty("tooltipText")
if tooltipText then
if tooltipText and tooltipText ~= '' then
self.tooltip:Clear()
self.tooltip:AddLine(14, tooltipText)
self.tooltip:Draw(x, y, width, height, viewPort)
end
end
end
end
1 change: 0 additions & 1 deletion src/Modules/CalcSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ function calcs.initModDB(env, modDB)
modDB:NewMod("TotemPlacementTime", "BASE", 0.6, "Base")
modDB:NewMod("BallistaPlacementTime", "BASE", 0.35, "Base")
modDB:NewMod("ActiveTotemLimit", "BASE", 1, "Base")
modDB:NewMod("MovementSpeed", "INC", -30, "Base", { type = "Condition", var = "Maimed" })
modDB:NewMod("DamageTaken", "INC", 10, "Base", ModFlag.Attack, { type = "Condition", var = "Intimidated"})
modDB:NewMod("DamageTaken", "INC", 10, "Base", ModFlag.Spell, { type = "Condition", var = "Unnerved"})
modDB:NewMod("Damage", "MORE", -10, "Base", { type = "Condition", var = "Debilitated"})
Expand Down
34 changes: 34 additions & 0 deletions src/Modules/Calcs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,9 @@ function calcs.buildOutput(build, mode)
env.minionConditionsUsed = { }
env.enemyConditionsUsed = { }
env.enemyMultipliersUsed = { }
env.perStatsUsed = { }
env.enemyPerStatsUsed = { }
env.tagTypesUsed = { }
local function addCond(out, var, mod)
if not out[var] then
out[var] = { }
Expand Down Expand Up @@ -502,8 +505,26 @@ function calcs.buildOutput(build, mode)
addMult(out, tag.var, mod)
end
end
local function addStat(out, var, mod)
if not out[var] then
out[var] = { }
end
t_insert(out[var], mod)
end
local function addStatTag(out, tag, mod)
if tag.varList then
for _, var in ipairs(tag.statList) do
addStat(out, var, mod)
end
elseif tag.stat then
addStat(out, tag.stat, mod)
end
end
local function addModTags(actor, mod)
for _, tag in ipairs(mod) do
if actor == env.player then
env.tagTypesUsed[tag.type] = true
end
if tag.type == "IgnoreCond" then
break
elseif tag.type == "Condition" then
Expand All @@ -522,6 +543,14 @@ function calcs.buildOutput(build, mode)
elseif tag.actor == "enemy" then
addMultTag(env.enemyMultipliersUsed, tag, mod)
end
elseif tag.type == "PerStat" or tag.type == "StatThreshold" then
if not tag.actor then
if actor == env.player then
addStatTag(env.perStatsUsed, tag, mod)
end
elseif tag.actor == "enemy" then
addStatTag(env.enemyPerStatsUsed, tag, mod)
end
end
end
end
Expand All @@ -536,6 +565,11 @@ function calcs.buildOutput(build, mode)
for _, mod in ipairs(activeSkill.baseSkillModList) do
addModTags(env.player, mod)
end
for _, mod in ipairs(activeSkill.skillModList) do
for _, tag in ipairs(mod) do
env.tagTypesUsed[tag.type] = true
end
end
if activeSkill.minion then
for _, activeSkill in pairs(activeSkill.minion.activeSkillList) do
for _, mod in ipairs(activeSkill.baseSkillModList) do
Expand Down
Loading

0 comments on commit a4815f2

Please sign in to comment.