Skip to content
Merged
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
56 changes: 48 additions & 8 deletions src/Classes/ConfigTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
self.build = build

self.input = { }
self.placeholder = { }

self.sectionList = { }
self.varControls = { }
Expand Down Expand Up @@ -52,10 +53,14 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
self.build.buildFlag = true
end)
elseif varData.type == "count" or varData.type == "integer" or varData.type == "countAllowZero" then
control = new("EditControl", {"TOPLEFT",lastSection,"TOPLEFT"}, 234, 0, 90, 18, "", nil, varData.type == "integer" and "^%-%d" or "%D", 6, function(buf)
self.input[varData.var] = tonumber(buf)
self:AddUndoState()
self:BuildModList()
control = new("EditControl", {"TOPLEFT",lastSection,"TOPLEFT"}, 234, 0, 90, 18, "", nil, varData.type == "integer" and "^%-%d" or "%D", 6, function(buf, placeholder)
if placeholder then
self.placeholder[varData.var] = tonumber(buf)
else
self.input[varData.var] = tonumber(buf)
self:AddUndoState()
self:BuildModList()
end
self.build.buildFlag = true
end)
elseif varData.type == "list" then
Expand All @@ -66,10 +71,14 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
self.build.buildFlag = true
end)
elseif varData.type == "text" then
control = new("EditControl", {"TOPLEFT",lastSection,"TOPLEFT"}, 8, 0, 344, 118, "", nil, "^%C\t\n", nil, function(buf)
self.input[varData.var] = tostring(buf)
self:AddUndoState()
self:BuildModList()
control = new("EditControl", {"TOPLEFT",lastSection,"TOPLEFT"}, 8, 0, 344, 118, "", nil, "^%C\t\n", nil, function(buf, placeholder)
if placeholder then
self.placeholder[varData.var] = tostring(buf)
else
self.input[varData.var] = tostring(buf)
self:AddUndoState()
self:BuildModList()
end
self.build.buildFlag = true
end, 16)
else
Expand Down Expand Up @@ -223,6 +232,8 @@ local ConfigTabClass = newClass("ConfigTab", "UndoHandler", "ControlHost", "Cont
self.input[varData.var] = varData.defaultState
control.state = varData.defaultState
self.varControls[varData.var] = control
self.placeholder[varData.var] = varData.defaultPlaceholderState
control.placeholder = varData.defaultPlaceholderState
end
t_insert(self.controls, control)
t_insert(lastSection.varControlList, control)
Expand All @@ -243,6 +254,7 @@ function ConfigTabClass:Load(xml, fileName)
elseif node.attrib.string then
if node.attrib.name == "enemyIsBoss" then
self.input[node.attrib.name] = node.attrib.string:lower():gsub("(%l)(%w*)", function(a,b) return s_upper(a)..b end)
:gsub("Uber Atziri", "Boss"):gsub("Shaper", "Pinnacle"):gsub("Sirus", "Uber")
else
self.input[node.attrib.name] = node.attrib.string
end
Expand All @@ -252,6 +264,19 @@ function ConfigTabClass:Load(xml, fileName)
launch:ShowErrMsg("^1Error parsing '%s': 'Input' element missing number, string or boolean attribute", fileName)
return true
end
elseif node.elem == "Placeholder" then
if not node.attrib.name then
launch:ShowErrMsg("^1Error parsing '%s': 'Placeholder' element missing name attribute", fileName)
return true
end
if node.attrib.number then
self.placeholder[node.attrib.name] = tonumber(node.attrib.number)
elseif node.attrib.string then
self.input[node.attrib.name] = node.attrib.string
else
launch:ShowErrMsg("^1Error parsing '%s': 'Placeholder' element missing number", fileName)
return true
end
end
end
self:BuildModList()
Expand Down Expand Up @@ -294,13 +319,25 @@ function ConfigTabClass:Save(xml)
t_insert(xml, child)
end
end
for k, v in pairs(self.placeholder) do
local child = { elem = "Placeholder", attrib = { name = k } }
if type(v) == "number" then
child.attrib.number = tostring(v)
else
child.attrib.string = tostring(v)
end
t_insert(xml, child)
end
self.modFlag = false
end

function ConfigTabClass:UpdateControls()
for var, control in pairs(self.varControls) do
if control._className == "EditControl" then
control:SetText(tostring(self.input[var] or ""))
if self.placeholder[var] then
control:SetPlaceholder(tostring(self.placeholder[var]))
end
elseif control._className == "CheckBoxControl" then
control.state = self.input[var]
elseif control._className == "DropDownControl" then
Expand Down Expand Up @@ -394,6 +431,7 @@ function ConfigTabClass:BuildModList()
local enemyModList = new("ModList")
self.enemyModList = enemyModList
local input = self.input
local placeholder = self.placeholder
for _, varData in ipairs(varList) do
if varData.apply then
if varData.type == "check" then
Expand All @@ -403,6 +441,8 @@ function ConfigTabClass:BuildModList()
elseif varData.type == "count" or varData.type == "integer" or varData.type == "countAllowZero" then
if input[varData.var] and (input[varData.var] ~= 0 or varData.type == "countAllowZero") then
varData.apply(input[varData.var], modList, enemyModList, self.build)
elseif placeholder[varData.var] and (placeholder[varData.var] ~= 0 or varData.type == "countAllowZero") then
varData.apply(placeholder[varData.var], modList, enemyModList, self.build)
end
elseif varData.type == "list" then
if input[varData.var] then
Expand Down
30 changes: 25 additions & 5 deletions src/Classes/EditControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ function EditClass:SetText(text, notify)
self:ResetUndo()
end

function EditClass:SetPlaceholder(text, notify)
self.placeholder = tostring(text)
if notify and self.changeFunc then
self.changeFunc(self.placeholder, true)
end
end

function EditClass:IsMouseOver()
if not self:IsShown() then
return false
Expand Down Expand Up @@ -266,8 +273,13 @@ function EditClass:Draw(viewPort)
local marginB = self.controls.scrollBarH:IsShown() and 14 or 0
SetViewport(textX, textY, width - 4 - marginL - marginR, height - 4 - marginB)
if not self.hasFocus then
SetDrawColor(self.inactiveCol)
DrawString(-self.controls.scrollBarH.offset, -self.controls.scrollBarV.offset, "LEFT", textHeight, self.font, self.buf)
if self.buf == '' and self.placeholder then
SetDrawColor(self.disableCol)
DrawString(-self.controls.scrollBarH.offset, -self.controls.scrollBarV.offset, "LEFT", textHeight, self.font, self.placeholder)
else
SetDrawColor(self.inactiveCol)
DrawString(-self.controls.scrollBarH.offset, -self.controls.scrollBarV.offset, "LEFT", textHeight, self.font, self.buf)
end
SetViewport()
self:DrawControls(viewPort)
return
Expand Down Expand Up @@ -636,13 +648,21 @@ function EditClass:OnKeyUp(key)
if cur then
self:SetText(tostring(cur + (self.numberInc or 1)), true)
else
self:SetText("1", true)
if self.placeholder then
self:SetText(tostring(self.placeholder + (self.numberInc or 1)), true)
else
self:SetText("1", true)
end
end
elseif key == "WHEELDOWN" or key == "DOWN" then
if cur and (self.filter ~= "%D" or cur > 0 )then
if cur and (self.filter ~= "%D" or cur > 0)then
self:SetText(tostring(cur - (self.numberInc or 1)), true)
else
self:SetText("0", true)
if self.placeholder then
self:SetText(tostring(self.placeholder - (self.numberInc or 1)), true)
else
self:SetText("0", true)
end
end
end
elseif key == "WHEELUP" then
Expand Down
50 changes: 13 additions & 37 deletions src/Modules/CalcDefence.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ end

-- Calculate physical damage reduction from armour, float
function calcs.armourReductionF(armour, raw)
if armour == 0 and raw == 0 then
return 0
end
return (armour / (armour + raw * 5) * 100)
end

Expand Down Expand Up @@ -865,48 +868,21 @@ function calcs.defence(env, actor)
},
}
end
local enemyCritChance = env.configInput["enemyCritChance"] or 5
local enemyCritDamage = env.configInput["enemyCritDamage"] or 30
local enemyCritChance = env.configInput["enemyCritChance"] or env.configPlaceholder["enemyCritChance"] or 0
local enemyCritDamage = env.configInput["enemyCritDamage"] or env.configPlaceholder["enemyCritDamage"] or 0
Comment on lines +871 to +872
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this ever be 0 now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of order of initialization it will be nil for a first pass, but is instantly rebuilt so, no the value will never be zero but it errors due to nil value on initialization

output["EnemyCritEffect"] = 1 + enemyCritChance / 100 * (enemyCritDamage / 100) * (1 - output.CritExtraDamageReduction / 100)
for _, damageType in ipairs(dmgTypeList) do
local enemyDamageMult = calcLib.mod(enemyDB, nil, "Damage", damageType.."Damage", isElemental[damageType] and "ElementalDamage" or nil) --missing taunt from allies
local enemyDamage = env.configInput["enemy"..damageType.."Damage"]
local enemyPen = env.configInput["enemy"..damageType.."Pen"]
local sourceStr = enemyDamage == nil and "Default" or "Config"

if env.configInput["enemyIsBoss"] == "Uber Atziri" then -- random boss (not specificaly uber ziri)
if enemyDamage == nil then
enemyDamage = env.data.monsterDamageTable[env.enemyLevel] * 1.5 * data.misc.stdBossDPSMult
if damageType == "Chaos" then
enemyDamage = enemyDamage / 4
end
end
elseif env.configInput["enemyIsBoss"] == "Shaper" then
if enemyDamage == nil then
enemyDamage = env.data.monsterDamageTable[env.enemyLevel] * 1.5 * data.misc.shaperDPSMult
if damageType == "Chaos" then
enemyDamage = enemyDamage / 4
end
end
if enemyPen == nil and isElemental[damageType] then
enemyPen = data.misc.shaperPen
end
elseif env.configInput["enemyIsBoss"] == "Sirus" then
if enemyDamage == nil then
enemyDamage = env.data.monsterDamageTable[env.enemyLevel] * 1.5 * data.misc.sirusDPSMult
if damageType == "Chaos" then
enemyDamage = enemyDamage / 4
end
end
if enemyPen == nil and isElemental[damageType] then
enemyPen = data.misc.sirusPen
end
else
if enemyDamage == nil and damageType == "Physical" then
enemyDamage = env.data.monsterDamageTable[env.enemyLevel] * 1.5
end

if enemyDamage == nil and env.configPlaceholder["enemy"..damageType.."Damage"] then
enemyDamage = env.configPlaceholder["enemy"..damageType.."Damage"]
end
if enemyPen == nil and env.configPlaceholder["enemy"..damageType.."Pen"] then
enemyPen = env.configPlaceholder["enemy"..damageType.."Pen"]
end

enemyDamage = enemyDamage or 0
output[damageType.."EnemyPen"] = enemyPen or 0
output["totalEnemyDamageIn"] = output["totalEnemyDamageIn"] + enemyDamage
Expand Down Expand Up @@ -1090,7 +1066,7 @@ function calcs.defence(env, actor)
for _, damageType in ipairs(dmgTypeList) do
-- Calculate incoming damage multiplier
local resist = modDB:Flag(nil, "SelfIgnore"..damageType.."Resistance") and 0 or output[damageType.."ResistWhenHit"] or output[damageType.."Resist"]
local enemyPen = modDB:Flag(nil, "SelfIgnore"..damageType.."Resistance") and 0 or env.configInput["enemy"..damageType.."Pen"] or output[damageType.."EnemyPen"] or 0
local enemyPen = modDB:Flag(nil, "SelfIgnore"..damageType.."Resistance") and 0 or output[damageType.."EnemyPen"]
local takenFlat = modDB:Sum("BASE", nil, "DamageTaken", damageType.."DamageTaken", "DamageTakenWhenHit", damageType.."DamageTakenWhenHit")
if damageCategoryConfig == "Melee" or damageCategoryConfig == "Projectile" then
takenFlat = takenFlat + modDB:Sum("BASE", nil, "DamageTakenFromAttacks", damageType.."DamageTakenFromAttacks")
Expand Down Expand Up @@ -1752,7 +1728,7 @@ function calcs.defence(env, actor)

--survival time
do
local enemySkillTime = env.configInput.enemySpeed or 700
local enemySkillTime = env.configInput.enemySpeed or env.configPlaceholder.enemySpeed or 700
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, not sure if this will ever get to the 700 value

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

local enemyActionSpeed = calcs.actionSpeedMod(actor.enemy)
enemySkillTime = enemySkillTime / 1000 / enemyActionSpeed
output["EHPsurvivalTime"] = output["TotalNumberOfHits"] * enemySkillTime
Expand Down
1 change: 1 addition & 0 deletions src/Modules/CalcSetup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ function calcs.initEnv(build, mode, override, specEnv)
env.build = build
env.data = build.data
env.configInput = build.configTab.input
env.configPlaceholder = build.configTab.placeholder
env.calcsInput = build.calcsTab.input
env.mode = mode
env.spec = override.spec or build.spec
Expand Down
Loading