Skip to content

Commit 1b5c74f

Browse files
author
LocalIdentity
committed
Fix crash on trying to use Trarthan Cannon
We assumed that all crossbows would have the reload time stats but this new base type doesn't have it Added checks to CalcOffence to make sure that value exists now Also add proper support for the weapon implicit so all ammo skills can't be used with it
1 parent 6c6bf54 commit 1b5c74f

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/Modules/CalcActiveSkill.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,14 @@ local function checkAsThoughWeaponTypes(weaponData, weaponTypes)
271271
end
272272

273273
-- Get weapon flags and info for given weapon
274-
local function getWeaponFlags(env, weaponData, weaponTypes)
274+
local function getWeaponFlags(env, weaponData, weaponTypes, gemTags)
275275
local info = env.data.weaponTypeInfo[weaponData.type]
276276
if not info then
277277
return
278278
end
279+
if weaponData.cannotUseGemTag and gemTags and gemTags[weaponData.cannotUseGemTag] then
280+
return nil, info
281+
end
279282
if weaponTypes then
280283
for _, types in ipairs(weaponTypes) do
281284
if not types[weaponData.type] and
@@ -379,6 +382,7 @@ function calcs.buildActiveSkillModList(env, activeSkill)
379382
local skillTypes = activeSkill.skillTypes
380383
local activeEffect = activeSkill.activeEffect
381384
local activeGrantedEffect = activeEffect.grantedEffect
385+
local gemTags = activeEffect.gemData and activeEffect.gemData.tags
382386
local activeStatSet, skillFlags
383387
if env.mode == "CALCS" then
384388
activeStatSet = activeEffect.statSetCalcs.statSet
@@ -461,7 +465,7 @@ function calcs.buildActiveSkillModList(env, activeSkill)
461465
t_insert(weaponTypes, skillEffect.grantedEffect.weaponTypes)
462466
end
463467
end
464-
local weapon1Flags, weapon1Info = getWeaponFlags(env, activeSkill.actor.weaponData1, weaponTypes)
468+
local weapon1Flags, weapon1Info = getWeaponFlags(env, activeSkill.actor.weaponData1, weaponTypes, gemTags)
465469
if not weapon1Flags and activeSkill.summonSkill then
466470
-- Minion skills seem to ignore weapon types
467471
weapon1Flags, weapon1Info = ModFlag[env.data.weaponTypeInfo["None"].flag], env.data.weaponTypeInfo["None"]
@@ -483,7 +487,7 @@ function calcs.buildActiveSkillModList(env, activeSkill)
483487
activeSkill.disableReason = "Main Hand weapon is not usable with this skill"
484488
end
485489
if not skillTypes[SkillType.MainHandOnly] and not skillFlags.forceMainHand then
486-
local weapon2Flags, weapon2Info = getWeaponFlags(env, activeSkill.actor.weaponData2, weaponTypes)
490+
local weapon2Flags, weapon2Info = getWeaponFlags(env, activeSkill.actor.weaponData2, weaponTypes, gemTags)
487491
if weapon2Flags then
488492
if skillTypes[SkillType.DualWieldRequiresDifferentTypes] and (activeSkill.actor.weaponData1.type == activeSkill.actor.weaponData2.type) then
489493
-- Skill requires a different compatible off hand weapon to main hand weapon

src/Modules/CalcOffence.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ end
282282
---@return number
283283
local function calcCrossbowReloadTime(weaponData, boltSkill)
284284
local baseReloadTime = weaponData.ReloadTime
285+
if not baseReloadTime then
286+
return
287+
end
285288

286289
local reloadTimeMulti = calcLib.mod(boltSkill.skillModList, boltSkill.skillCfg, "ReloadSpeed", "Speed" )
287290
return baseReloadTime / reloadTimeMulti
@@ -2861,7 +2864,7 @@ function calcs.offence(env, actor, activeSkill)
28612864
output.Speed = m_min(output.Speed, data.misc.ServerTickRate * output.Repeats)
28622865
end
28632866
-- Crossbows: Adjust attack speed values for Crossbow skills that need to reload
2864-
if skillData.reloadTime then
2867+
if skillData.reloadTime and skillData.reloadTime > 0 then
28652868
output.FiringRate = output.Speed
28662869
output.BoltCount = skillData.boltCount
28672870
output.EffectiveBoltCount = output.BoltCount
@@ -2907,7 +2910,7 @@ function calcs.offence(env, actor, activeSkill)
29072910
-- Crossbows: adjust breakdown to account for effect of reload time, bolt count, etc.
29082911
-- note: if we are ever allowed to dual wield crossbows, this will need to be adjusted
29092912
-- TODO: properly reflect effects of "SkillAttackTime" mods in the breakdown. (This is also not currently done in the standard breakdown.Speed calculation)
2910-
if output.ReloadTime then
2913+
if output.ReloadTime and source.ReloadTime then
29112914
globalBreakdown.FiringRate = { }
29122915
breakdown.multiChain(globalBreakdown.FiringRate, {
29132916
base = { "%.2f ^8(base)", 1 / baseTime },

src/Modules/ModParser.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,7 @@ local specialModList = {
34163416
} end,
34173417
["has (%d+) sockets?"] = function(num) return { mod("SocketCount", "BASE", num) } end,
34183418
["no physical damage"] = { mod("WeaponData", "LIST", { key = "PhysicalMin" }), mod("WeaponData", "LIST", { key = "PhysicalMax" }), mod("WeaponData", "LIST", { key = "PhysicalDPS" }) },
3419+
["cannot load or fire ammunition"] = { mod("WeaponData", "LIST", { key = "cannotUseGemTag", value = "ammunition" }) },
34193420
["has (%d+)%% increased elemental damage"] = function(num) return { mod("LocalElementalDamage", "INC", num) } end,
34203421
["all attacks with this weapon are critical hits"] = { mod("WeaponData", "LIST", { key = "CritChance", value = 100 }) },
34213422
["this weapon's critical hit chance is (%d+)%%"] = function(num) return { mod("WeaponData", "LIST", { key = "CritChance", value = num }) } end,

0 commit comments

Comments
 (0)