Skip to content

Commit

Permalink
Improve logic for if a weapon can roll a damage type
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan committed Jun 23, 2024
1 parent b82aaa9 commit b2b1d6d
Showing 1 changed file with 46 additions and 34 deletions.
80 changes: 46 additions & 34 deletions rivencalc.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,52 +391,64 @@ function calculateStats()

function addStatCompatInfo(div, weaponData, tag, buff)
{
let incompatible = false;
if (tag == "WeaponProjectileSpeedMod"
&& weaponData?.compatibilityTags
&& !weaponData.compatibilityTags.find(x => x == "PROJECTILE")
)
if (weaponData)
{
incompatible = true;
}
if (tag in upgradeTagToDamageType)
{
const damageType = upgradeTagToDamageType[tag];
if (!weaponHasInnateDamage(weaponData, damageType))
let incompatible = false;
if (tag == "WeaponProjectileSpeedMod"
&& weaponData.compatibilityTags
&& !weaponData.compatibilityTags.find(x => x == "PROJECTILE")
)
{
incompatible = true;
}
if (tag in upgradeTagToDamageType)
{
const isPhysical = (damageType == "DT_IMPACT" || damageType == "DT_PUNCTURE" || damageType == "DT_SLASH");
if (isPhysical || !buff)
const damageType = upgradeTagToDamageType[tag];
if (!weaponCanRollDamageType(weaponData, damageType))
{
incompatible = true;
const isPhysical = (damageType == "DT_IMPACT" || damageType == "DT_PUNCTURE" || damageType == "DT_SLASH");
if (isPhysical || !buff)
{
incompatible = true;
}
}
}
}
if (incompatible)
{
let span = document.createElement("span");
span.textContent = "ⓘ";
span.className = "text-body-emphasis";
span.title = "This stat can currently not be rolled on the selected weapon.";
div.appendChild(span);
if (incompatible)
{
let span = document.createElement("span");
span.textContent = "ⓘ";
span.className = "text-body-emphasis";
span.title = "This stat can currently not be rolled on the selected weapon.";
div.appendChild(span);

span = document.createElement("span");
span.textContent = " ";
div.appendChild(span);
span = document.createElement("span");
span.textContent = " ";
div.appendChild(span);
}
}
}

function weaponHasInnateDamage(weaponData, damageType)
// Test vectors for rollable physicals

// Weapons with projectile:
// - Aeolak: Impact, Puncture, Slash.
// - Acceltra: Impact.
// - Hystrix: Puncture.
// Weapons without projectile:
// - Braton: Impact, Puncture, Slash.
// - Bronco: Impact.
// - Lex: Puncture.

function weaponCanRollDamageType(weaponData, damageType)
{
if (weaponData
&& weaponData.behaviors
&& weaponData.behaviors[0]
&& weaponData.behaviors[0].projectile
&& weaponData.behaviors[0].projectile.attack
)
const behavior = weaponData.behaviors[0];
const damageTable = behavior.projectile?.attack ? behavior.projectile.attack : behavior.impact;
if (damageType in damageTable)
{
return (damageType in weaponData.behaviors[0].projectile.attack);
const totalDamage = Object.values(damageTable).reduce((a, b) => a + b, 0);
return (damageTable[damageType] / totalDamage) > 0.15;
}
return true;
return false;
}

function getBuffValue(rivenType, tag, tagValue, omegaAttenuation, lvl, buffs, curses)
Expand Down

0 comments on commit b2b1d6d

Please sign in to comment.