Add support for ignoring headshots with specific modifiers

This commit is contained in:
IM23a-spirgif
2025-05-17 20:39:30 +02:00
parent 6202b5394d
commit d31e436949
4 changed files with 14 additions and 7 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ function filterTable() {
const table = document.getElementById('gun-stats');
const tr = table.getElementsByTagName('tr');
for (let i = 1; i < tr.length; i++) {
const td = tr[i].getElementsByTagName('td')[1];
const td = tr[i].getElementsByTagName('td')[0];
if (td) {
const txtValue = td.textContent || td.innerText;
if (txtValue.toLowerCase().indexOf(filter) > -1) {
+11 -4
View File
@@ -5,6 +5,7 @@ let globalModifiers = []; // This will be populated by the modifiers
let selectedGunTypes = []; // Track selected gun types for filtering
let headshotMultiplier = 0; // Initialize Headshots as 0
let headshotBaseApplied = false; //Initialize Headshots Applied as false
let ignoreHeadshots = false;
// Function to fetch operatives data from JSON
function fetchOperativesData() {
@@ -265,19 +266,20 @@ function populateModifiers(modifiers) {
modifiersContainer.addEventListener('change', applyModifiers);
}
// Function to apply the modifiers and recalculate damage, RPM, and reloadTime
function applyModifiers() {
if (!selectedWeapon) return;
// Base stats
const hasNVG = !!document.querySelector(
"#modifiers input[id='damage-item-multiplicative-nightvision']:checked"
);
let baseDamage = selectedWeapon.damage;
let baseRpm = selectedWeapon.rpm;
let baseReloadTime = selectedWeapon.reload_time;
// Modifiers initialization
let damageModifier = {additive: 0, multiplicative: 1};
let rpmModifier = {additive: 0, multiplicative: 1};
let reloadTimeModifier = {additive: 0, multiplicative: 1};
headshotMultiplier = 0; // Reset headshot multiplier
headshotMultiplier = 0;
headshotBaseApplied = false;
ignoreHeadshots = hasNVG;
// Function to process global modifiers
function processModifier(mod) {
@@ -413,6 +415,11 @@ function applyModifiers() {
}
function applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier) {
if (ignoreHeadshots &&
(buff.buffType === 'multiplicative-headshot' ||
buff.buffType === 'multiplicative-headshot-base')) {
return;
}
const {type, buffType, value} = buff;
// Handle headshot multipliers
if (buffType === 'multiplicative-headshot-base' && !headshotBaseApplied) {
+1 -1
View File
@@ -61,7 +61,7 @@
},
{
"id": "damage-item-multiplicative-nightvision",
"label": "Night Vision Goggles (+50% damage)",
"label": "Night Vision Goggles (+50% damage) | Resets Headshot Multiplier",
"value": 1.5,
"type": "multiplicative",
"operatives": ""