@@ -1267,12 +1267,6 @@ describe("TestTriggers", function()
12671267 end )
12681268
12691269 describe (" The Monastery Bell" , function ()
1270- before_each (function ()
1271- -- Isolate player-generated blocks unless the case specifies an attacking enemy.
1272- build .configTab .input .enemySpeed = 0
1273- build .configTab :BuildModList ()
1274- end )
1275-
12761270 local function equipUnique (category , name , slot )
12771271 local items = data .uniques [category ]
12781272 local index = isValueInArrayPred (items , function (raw ) return raw :sub (1 , # name + 1 ) == name .. " \n " end )
@@ -1284,12 +1278,19 @@ describe("TestTriggers", function()
12841278 runCallback (" OnFrame" )
12851279 end
12861280
1287- local function allocateReliquarianBell ()
1281+ local bellNodeId = 26055
1282+ local function selectReliquarian ()
12881283 local spec = build .spec
12891284 spec :SelectClass (spec .tree .classNameMap .Scion )
12901285 spec :SelectAscendClass (spec .tree .ascendNameMap .Reliquarian .ascendClassId )
1291- spec :AllocNode (spec .nodes [26055 ])
1292- assert .is_not_nil (spec .allocNodes [26055 ])
1286+ assert .are .equal (" The Monastery Bell" , spec .nodes [bellNodeId ].dn )
1287+ build .buildFlag = true
1288+ runCallback (" OnFrame" )
1289+ end
1290+
1291+ local function allocateBellNode ()
1292+ build .spec :AllocNode (build .spec .nodes [bellNodeId ])
1293+ assert .is_not_nil (build .spec .allocNodes [bellNodeId ])
12931294 build .buildFlag = true
12941295 runCallback (" OnFrame" )
12951296 end
@@ -1298,7 +1299,8 @@ describe("TestTriggers", function()
12981299 local matches = 0
12991300 runCallback (" OnFrame" )
13001301 for groupIndex , group in ipairs (build .skillsTab .socketGroupList ) do
1301- for skillIndex , skill in ipairs (group .displaySkillList or {}) do
1302+ -- A disabled group keeps its last skill list
1303+ for skillIndex , skill in ipairs (group .enabled and group .displaySkillList or {}) do
13021304 if skill .activeEffect .grantedEffect .name == name then
13031305 matches = matches + 1
13041306 if matches == (occurrence or 1 ) then
@@ -1321,175 +1323,192 @@ describe("TestTriggers", function()
13211323 build .buildFlag = true
13221324 end
13231325
1324- it (" triggers Shield Shatter from the item and the passive while respecting hit chance" , function ()
1326+ -- The trigger simulation counts a whole number of triggers over 1000 attacks
1327+ local function assertRate (expected , actual )
1328+ assert .are .near (expected , actual , expected * 0.002 )
1329+ end
1330+
1331+ for _ , name in ipairs ({ " Festering Resentment" , " Svalinn" }) do
1332+ it (" keeps the usual block assumptions for " .. name .. " without the Bell or a shield attack to block with" , function ()
1333+ local slot , hasShatter
1334+ selectReliquarian ()
1335+ if name == " Svalinn" then
1336+ equipUnique (" shield" , name , " Weapon 2" )
1337+ slot = " Weapon 2"
1338+ else
1339+ equipUnique (" dagger" , name , " Weapon 1" )
1340+ equipUnique (" shield" , " Shattershard" , " Weapon 2" )
1341+ slot , hasShatter = " Weapon 1" , true
1342+ end
1343+ setCustomMods (" Your Hits can't be Evaded" )
1344+ build .skillsTab :PasteSocketGroup (" Slot: " .. slot .. " \n Arc 20/0 1\n Arc 20/0 1\n " )
1345+ build .skillsTab :PasteSocketGroup (" Tempest Shield 20/0 1\n " )
1346+
1347+ local function triggerRates ()
1348+ local rates = {}
1349+ local arc = selectSkill (" Arc" )
1350+ -- Blocks come as often as the trigger's cooldown allows and alternate between both spells
1351+ assert .are .near (1 / 0.264 , arc .TriggerRateCap , 1e-6 )
1352+ assert .are .near (arc .TriggerRateCap / 2 , arc .SkillTriggerRate , 1e-6 )
1353+ rates .firstArc , rates .secondArc = arc .SkillTriggerRate , selectSkill (" Arc" , 2 ).SkillTriggerRate
1354+ local tempestShield = selectSkill (" Tempest Shield" )
1355+ assert .are .equal (tempestShield .TriggerRateCap , tempestShield .SkillTriggerRate )
1356+ rates .tempestShield = tempestShield .SkillTriggerRate
1357+ if hasShatter then
1358+ local shatter = selectSkill (" Shield Shatter" )
1359+ assert .are .near (1 / shatter .Duration , shatter .SkillTriggerRate , 1e-6 )
1360+ rates .shatter = shatter .SkillTriggerRate
1361+ end
1362+ return rates
1363+ end
1364+
1365+ local usual = triggerRates ()
1366+ build .skillsTab :PasteSocketGroup (" Shield Charge 20/0 1\n " )
1367+ local _ , chargeGroup = selectSkill (" Shield Charge" )
1368+ assert .are .same (usual , triggerRates ())
1369+
1370+ -- Retaliation skills and attacks that do not use the shield are no source of blocks
1371+ chargeGroup .enabled = false
1372+ build .skillsTab :PasteSocketGroup (" Smite 20/0 1\n " )
1373+ build .skillsTab :PasteSocketGroup (" Shield of Light 20/0 1\n " )
1374+ allocateBellNode ()
1375+ assert .are .same (usual , triggerRates ())
1376+ end )
1377+ end
1378+
1379+ it (" triggers Shield Shatter with each shield attack that hits" , function ()
13251380 equipUnique (" shield" , " Shattershard" , " Weapon 2" )
1381+ selectReliquarian ()
13261382 setCustomMods (" Your Hits can't be Evaded" )
1327- build .skillsTab :PasteSocketGroup (" Shield Charge 20/0 1\n Faster Attacks 20/0 1\n " )
1328- local normal = selectSkill (" Shield Shatter" )
1329- assert .are .near (1 / normal .Duration , normal .SkillTriggerRate , 1e-6 )
1383+ build .skillsTab :PasteSocketGroup (" Shield Charge 20/0 1\n " )
1384+ local usual = selectSkill (" Shield Shatter" )
13301385
13311386 equipUnique (" mace" , " The Monastery Bell" , " Weapon 1" )
1332- local charge , chargeGroup = selectSkill (" Shield Charge" )
1387+ local charge = selectSkill (" Shield Charge" )
13331388 local shatter = selectSkill (" Shield Shatter" )
1334- assert .are .near (charge .Speed , shatter .SkillTriggerRate , 1e-6 )
1335- assert .are .near (normal .Duration , shatter .Duration , 1e-6 )
1389+ assert .True (shatter .SkillTriggerRate > 4 * usual .SkillTriggerRate )
1390+ assertRate (charge .Speed , shatter .SkillTriggerRate )
1391+ assert .are .equal (usual .Duration , shatter .Duration )
13361392
1337- allocateReliquarianBell ()
1338- assert .are .near (charge .Speed , selectSkill (" Shield Shatter" ).SkillTriggerRate , 1e-6 )
1393+ -- Attacking faster blocks proportionally more often
1394+ setCustomMods (" Your Hits can't be Evaded\n 100% increased Attack Speed" )
1395+ local fasterCharge = selectSkill (" Shield Charge" )
1396+ local fasterShatter = selectSkill (" Shield Shatter" )
1397+ assert .True (fasterCharge .Speed > 1.5 * charge .Speed )
1398+ assertRate (shatter .SkillTriggerRate * fasterCharge .Speed / charge .Speed , fasterShatter .SkillTriggerRate )
1399+
1400+ -- Attacks that miss do not block
1401+ setCustomMods (" 100% increased Attack Speed" )
1402+ local evadedCharge = selectSkill (" Shield Charge" )
1403+ assert .True (evadedCharge .HitChance > 0 and evadedCharge .HitChance < 100 )
1404+ assert .are .equal (fasterCharge .Speed , evadedCharge .Speed )
1405+ assertRate (fasterShatter .SkillTriggerRate * evadedCharge .HitChance / 100 , selectSkill (" Shield Shatter" ).SkillTriggerRate )
1406+
1407+ -- The Reliquarian passive has the same modifier as the mace
1408+ setCustomMods (" Your Hits can't be Evaded" )
13391409 build .itemsTab .slots [" Weapon 1" ]:SetSelItemId (0 )
1340- build .configTab .input .enemyBlockChance = 50
1341- build .configTab :BuildModList ()
1342- build .buildFlag = true
1343- assert .are .near (charge .Speed / 2 , selectSkill (" Shield Shatter" ).SkillTriggerRate , 1e-6 )
1344-
1345- build .configTab .input .enemyBlockChance = 100
1346- build .configTab :BuildModList ()
1347- build .buildFlag = true
1348- assert .are .equal (0 , selectSkill (" Shield Shatter" ).SkillTriggerRate )
1349-
1350- chargeGroup .enabled = false
1351- build .skillsTab :PasteSocketGroup (" Smite 20/0 1\n " )
1352- local fallback = selectSkill (" Shield Shatter" )
1353- assert .is_nil (fallback .ShieldAttackBlockRate )
1354- assert .are .equal (0 , fallback .SkillTriggerRate )
1355- build .configTab .input .enemySpeed = 700
1356- build .configTab :BuildModList ()
13571410 build .buildFlag = true
1358- local incoming = selectSkill (" Shield Shatter" )
1359- assert .True (incoming .SkillTriggerRate > 0 )
1360- assert .True (incoming .SkillTriggerRate <= 1 / incoming .Duration )
1411+ assert .are .equal (usual .SkillTriggerRate , selectSkill (" Shield Shatter" ).SkillTriggerRate )
1412+ local preview = build .calcsTab .calcs .getMiscCalculator (build )({ addNodes = { [build .spec .nodes [bellNodeId ]] = true } })
1413+ allocateBellNode ()
1414+ local passive = selectSkill (" Shield Shatter" )
1415+ assertRate (selectSkill (" Shield Charge" ).Speed , passive .SkillTriggerRate )
1416+ assert .are .equal (passive .SkillTriggerRate , preview .SkillTriggerRate )
13611417 end )
13621418
1363- it (" reports recovery from Bell blocks once per use of a repeating shield attack" , function ()
1419+ it (" blocks once per use of a repeating shield attack and uses the attack that blocks most often " , function ()
13641420 equipUnique (" mace" , " The Monastery Bell" , " Weapon 1" )
1365- equipUnique (" shield" , " Aegis Aurora " , " Weapon 2" )
1366- setCustomMods (" Your Hits can't be Evaded\n Recover 100 Life when you Block \n Recover 5% of your maximum Mana when you Block \n Recover 100 Energy Shield when you Block Spell Damage " )
1367- build .skillsTab :PasteSocketGroup (" Smite 20/0 1\n " )
1368- local normal = selectSkill (" Smite " )
1369- assert . is_nil ( normal . ShieldAttackBlockRate )
1421+ equipUnique (" shield" , " Shattershard " , " Weapon 2" )
1422+ setCustomMods (" Your Hits can't be Evaded" )
1423+ build .skillsTab :PasteSocketGroup (" Shield Crush 20/0 1\n " )
1424+ local _ , crushGroup = selectSkill (" Shield Crush " )
1425+ local single = selectSkill ( " Shield Shatter " ). SkillTriggerRate
13701426
1427+ -- Multistrike attacks faster, but its two repeats belong to the same use
13711428 build .skillsTab :PasteSocketGroup (" Shield Crush 20/0 1\n Multistrike 20/0 1\n " )
1372- local crush = selectSkill (" Shield Crush" )
1373- assert .are .equal (3 , crush .Repeats )
1374- assert .are .near (crush .Speed / crush .Repeats , crush .ShieldAttackBlockRate , 1e-6 )
1375- assert .are .equal (100 , crush .LifeOnBlock )
1376- assert .True (crush .ManaOnBlock > 0 )
1377- assert .True (crush .EnergyShieldOnBlock > 0 )
1378- assert .are .equal (100 , crush .EnergyShieldOnSpellBlock )
1379- assert .are .near (crush .LifeOnBlock * crush .ShieldAttackBlockRate , crush .ShieldAttackLifeOnBlockRate , 1e-6 )
1380- assert .are .near (crush .ManaOnBlock * crush .ShieldAttackBlockRate , crush .ShieldAttackManaOnBlockRate , 1e-6 )
1381- assert .are .near (crush .EnergyShieldOnBlock * crush .ShieldAttackBlockRate , crush .ShieldAttackESOnBlockRate , 1e-6 )
1382- assert .are .equal (0 , crush .LifeOnHit )
1383- assert .are .equal (normal .EffectiveBlockChance , crush .EffectiveBlockChance )
1384- assert .are .near (normal .TotalEHP , crush .TotalEHP , 1e-6 )
1385- end )
1429+ crushGroup .enabled = false
1430+ local repeating = selectSkill (" Shield Crush" )
1431+ assert .are .equal (3 , repeating .Repeats )
1432+ local shatter = selectSkill (" Shield Shatter" )
1433+ assert .True (shatter .SkillTriggerRate < single )
1434+ assertRate (repeating .Speed / 3 , shatter .SkillTriggerRate )
13861435
1387- for _ , name in ipairs ({ " Festering Resentment" , " Svalinn" }) do
1388- it (" respects the cooldown and spell rotation of " .. name , function ()
1389- local slot
1390- if name == " Festering Resentment" then
1391- equipUnique (" dagger" , name , " Weapon 1" )
1392- equipUnique (" shield" , " Shattershard" , " Weapon 2" )
1393- allocateReliquarianBell ()
1394- slot = " Weapon 1"
1395- else
1396- equipUnique (" mace" , " The Monastery Bell" , " Weapon 1" )
1397- equipUnique (" shield" , name , " Weapon 2" )
1398- slot = " Weapon 2"
1399- end
1400- setCustomMods (" Your Hits can't be Evaded\n 100% increased Attack Speed" )
1401- build .skillsTab :PasteSocketGroup (" Shield Charge 20/0 1\n Faster Attacks 20/0 1\n " )
1402- build .skillsTab :PasteSocketGroup (" Slot: " .. slot .. " \n Arc 20/0 1\n " )
1403- local oneSpell = selectSkill (" Arc" )
1404- assert .True (oneSpell .ShieldAttackBlockRate > oneSpell .TriggerRateCap )
1405- assert .are .near (oneSpell .ShieldAttackBlockRate / 2 , oneSpell .SkillTriggerRate , 1e-6 )
1406-
1407- build .skillsTab :PasteSocketGroup (" Slot: " .. slot .. " \n Fireball 20/0 1\n " )
1408- build .configTab .input .enemyBlockChance = 50
1409- build .configTab :BuildModList ()
1410- local arc = selectSkill (" Arc" )
1411- local fireball = selectSkill (" Fireball" )
1412- assert .are .near (oneSpell .ShieldAttackBlockRate / 2 , arc .ShieldAttackBlockRate , 1e-6 )
1413- assert .are .near (arc .ShieldAttackBlockRate / 2 , arc .SkillTriggerRate , 1e-6 )
1414- assert .are .near (arc .ShieldAttackBlockRate , arc .SkillTriggerRate + fireball .SkillTriggerRate , 1e-6 )
1415- end )
1416- end
1436+ crushGroup .enabled = true
1437+ build .buildFlag = true
1438+ assert .are .equal (single , selectSkill (" Shield Shatter" ).SkillTriggerRate )
1439+ end )
14171440
1418- it (" counts shield throws independently of the displayed Trarthus skill part" , function ()
1441+ it (" counts one block per shield throw regardless of the displayed Trarthus skill part" , function ()
14191442 equipUnique (" mace" , " The Monastery Bell" , " Weapon 1" )
14201443 equipUnique (" shield" , " Shattershard" , " Weapon 2" )
1421- setCustomMods (" Your Hits can't be Evaded\n 100% increased Attack Speed " )
1444+ setCustomMods (" Your Hits can't be Evaded" )
14221445 local name = " Spectral Shield Throw of Trarthus"
14231446 build .skillsTab :PasteSocketGroup (name .. " 20/0 1\n " )
14241447 local shield , group = selectSkill (name )
1448+ local rate = selectSkill (" Shield Shatter" ).SkillTriggerRate
1449+ assertRate (shield .Speed , rate )
14251450 group .gemList [1 ].skillPart = 2
14261451 build .buildFlag = true
14271452 local shards = selectSkill (name )
1428- assert .True (shards .HitSpeed ~= shield .Speed )
1429- assert .are .near (shield .Speed , shards .ShieldAttackBlockRate , 1e-6 )
1430- assert .are .near (shield .Speed , selectSkill (" Shield Shatter" ).SkillTriggerRate , 1e-6 )
1431- -- Repeated Bell hits keep the Shatter buff active and prevent ordinary blocks.
1432- build .configTab .input .enemySpeed = 700
1433- build .configTab :BuildModList ()
1434- build .buildFlag = true
1435- assert .are .near (shield .Speed , selectSkill (" Shield Shatter" ).SkillTriggerRate , 1e-6 )
1453+ assert .are .equal (shield .Speed , shards .Speed )
1454+ assert .True (shards .HitSpeed > shards .Speed )
1455+ assert .are .equal (rate , selectSkill (" Shield Shatter" ).SkillTriggerRate )
14361456 end )
14371457
1438- it (" keeps misses on the attack timeline and shares Arc's cooldown across socket groups" , function ()
1439- equipUnique (" mace" , " The Monastery Bell" , " Weapon 1" )
1440- equipUnique (" shield" , " Svalinn" , " Weapon 2" )
1441- setCustomMods (" Your Hits can't be Evaded\n 300% increased Attack Speed" )
1442- build .skillsTab :PasteSocketGroup (" Shield Charge 20/0 1\n " )
1443- build .skillsTab :PasteSocketGroup (" Slot: Weapon 2\n Arc 20/0 1\n " )
1444- local function arcRate (enemyBlock )
1445- build .configTab .input .enemyBlockChance = enemyBlock
1446- build .configTab :BuildModList ()
1447- build .buildFlag = true
1448- return selectSkill (" Arc" ).SkillTriggerRate
1449- end
1450- local half = arcRate (50 )
1451- local fewerHits = arcRate (53 )
1452- assert .True (half > fewerHits and fewerHits > 0 )
1453- local single = arcRate (0 )
1454- build .skillsTab :PasteSocketGroup (" Slot: Weapon 2\n Arc 20/0 1\n " )
1455- local first = selectSkill (" Arc" )
1456- local second = selectSkill (" Arc" , 2 )
1457- assert .True (first .SkillTriggerRate > 0 and second .SkillTriggerRate > 0 )
1458- assert .are .near (single , first .SkillTriggerRate + second .SkillTriggerRate , 1e-6 )
1459- assert .True (single <= first .TriggerRateCap )
1460- end )
1458+ for _ , name in ipairs ({ " Festering Resentment" , " Svalinn" }) do
1459+ it (" respects the cooldown and spell rotation of " .. name , function ()
1460+ local slot
1461+ if name == " Svalinn" then
1462+ equipUnique (" mace" , " The Monastery Bell" , " Weapon 1" )
1463+ equipUnique (" shield" , name , " Weapon 2" )
1464+ slot = " Weapon 2"
1465+ else
1466+ equipUnique (" dagger" , name , " Weapon 1" )
1467+ equipUnique (" shield" , " Shattershard" , " Weapon 2" )
1468+ selectReliquarian ()
1469+ allocateBellNode ()
1470+ slot = " Weapon 1"
1471+ end
1472+ setCustomMods (" Your Hits can't be Evaded" )
1473+ build .skillsTab :PasteSocketGroup (" Shield Charge 20/0 1\n " )
1474+ build .skillsTab :PasteSocketGroup (" Slot: " .. slot .. " \n Arc 20/0 1\n " )
1475+ local charge = selectSkill (" Shield Charge" )
1476+ local arc , spellGroup = selectSkill (" Arc" )
1477+ -- Each block triggers the spell while blocks are further apart than the cooldown
1478+ assert .True (charge .Speed < arc .TriggerRateCap )
1479+ assertRate (charge .Speed , arc .SkillTriggerRate )
1480+
1481+ -- Blocks during the cooldown are wasted
1482+ setCustomMods (" Your Hits can't be Evaded\n 300% increased Attack Speed" )
1483+ local fastCharge = selectSkill (" Shield Charge" )
1484+ local fastArc = selectSkill (" Arc" )
1485+ assert .True (fastCharge .Speed > 2 * fastArc .TriggerRateCap )
1486+ assert .True (fastArc .SkillTriggerRate > arc .SkillTriggerRate )
1487+ assert .True (fastArc .SkillTriggerRate <= fastArc .TriggerRateCap )
1488+
1489+ -- Spells in the same item take turns
1490+ setCustomMods (" Your Hits can't be Evaded" )
1491+ spellGroup .enabled = false
1492+ build .skillsTab :PasteSocketGroup (" Slot: " .. slot .. " \n Arc 20/0 1\n Fireball 20/0 1\n " )
1493+ assertRate (charge .Speed / 2 , selectSkill (" Arc" ).SkillTriggerRate )
1494+ assertRate (charge .Speed / 2 , selectSkill (" Fireball" ).SkillTriggerRate )
1495+ end )
1496+ end
14611497
1462- it (" adds incoming blocks to Tempest Shield discharges independently of its activation cooldown" , function ()
1498+ it (" discharges Tempest Shield with each block regardless of its activation cooldown" , function ()
14631499 equipUnique (" mace" , " The Monastery Bell" , " Weapon 1" )
14641500 equipUnique (" shield" , " Svalinn" , " Weapon 2" )
14651501 setCustomMods (" Your Hits can't be Evaded\n 300% increased Attack Speed" )
14661502 build .skillsTab :PasteSocketGroup (" Tempest Shield 20/0 1\n " )
1503+ local usual = selectSkill (" Tempest Shield" )
1504+ assert .True (usual .SkillTriggerRate < 1 )
1505+
14671506 build .skillsTab :PasteSocketGroup (" Shield Charge 20/0 1\n " )
1468- build .skillsTab :PasteSocketGroup (" Slot: Weapon 2\n Arc 20/0 1\n " )
1469- local bell = selectSkill (" Tempest Shield" )
1470- assert .True (bell .ShieldAttackBlockRate > 5 )
1471- assert .are .near (bell .ShieldAttackBlockRate , bell .SkillTriggerRate , 1e-6 )
1472- assert .are .near (bell .SkillTriggerRate , bell .Speed , 1e-6 )
1473-
1474- build .configTab .input .enemySpeed = 1000
1475- build .configTab .input .enemyDamageType = " Spell"
1476- build .configTab :BuildModList ()
1477- build .buildFlag = true
1478- local mixed = selectSkill (" Tempest Shield" )
1479- local incoming = mixed .EffectiveSpellBlockChance / 100
1480- assert .True (incoming > 0 )
1481- assert .are .near (bell .SkillTriggerRate + incoming , mixed .SkillTriggerRate , 1e-6 )
1482- build .configTab .input .enemyBlockChance = 100
1483- build .configTab :BuildModList ()
1484- build .buildFlag = true
1485- local blocked = selectSkill (" Tempest Shield" )
1486- assert .are .equal (0 , blocked .ShieldAttackBlockRate )
1487- assert .are .near (incoming , blocked .SkillTriggerRate , 1e-6 )
1488- assert .are .near (incoming , selectSkill (" Arc" ).SkillTriggerRate , 1e-6 )
1489- build .configTab .input .enemyDamageType = " DamageOverTime"
1490- build .configTab :BuildModList ()
1491- build .buildFlag = true
1492- assert .are .equal (0 , selectSkill (" Tempest Shield" ).SkillTriggerRate )
1507+ local charge = selectSkill (" Shield Charge" )
1508+ local tempestShield = selectSkill (" Tempest Shield" )
1509+ assert .True (charge .Speed > 5 )
1510+ assertRate (charge .Speed , tempestShield .SkillTriggerRate )
1511+ assert .are .equal (usual .Cooldown , tempestShield .Cooldown )
14931512 end )
14941513 end )
14951514
0 commit comments