Add support for ignoring headshots with specific modifiers
This commit is contained in:
@@ -4,7 +4,7 @@ function filterTable() {
|
|||||||
const table = document.getElementById('gun-stats');
|
const table = document.getElementById('gun-stats');
|
||||||
const tr = table.getElementsByTagName('tr');
|
const tr = table.getElementsByTagName('tr');
|
||||||
for (let i = 1; i < tr.length; i++) {
|
for (let i = 1; i < tr.length; i++) {
|
||||||
const td = tr[i].getElementsByTagName('td')[1];
|
const td = tr[i].getElementsByTagName('td')[0];
|
||||||
if (td) {
|
if (td) {
|
||||||
const txtValue = td.textContent || td.innerText;
|
const txtValue = td.textContent || td.innerText;
|
||||||
if (txtValue.toLowerCase().indexOf(filter) > -1) {
|
if (txtValue.toLowerCase().indexOf(filter) > -1) {
|
||||||
|
|||||||
+11
-4
@@ -5,6 +5,7 @@ let globalModifiers = []; // This will be populated by the modifiers
|
|||||||
let selectedGunTypes = []; // Track selected gun types for filtering
|
let selectedGunTypes = []; // Track selected gun types for filtering
|
||||||
let headshotMultiplier = 0; // Initialize Headshots as 0
|
let headshotMultiplier = 0; // Initialize Headshots as 0
|
||||||
let headshotBaseApplied = false; //Initialize Headshots Applied as false
|
let headshotBaseApplied = false; //Initialize Headshots Applied as false
|
||||||
|
let ignoreHeadshots = false;
|
||||||
|
|
||||||
// Function to fetch operatives data from JSON
|
// Function to fetch operatives data from JSON
|
||||||
function fetchOperativesData() {
|
function fetchOperativesData() {
|
||||||
@@ -265,19 +266,20 @@ function populateModifiers(modifiers) {
|
|||||||
modifiersContainer.addEventListener('change', applyModifiers);
|
modifiersContainer.addEventListener('change', applyModifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to apply the modifiers and recalculate damage, RPM, and reloadTime
|
|
||||||
function applyModifiers() {
|
function applyModifiers() {
|
||||||
if (!selectedWeapon) return;
|
if (!selectedWeapon) return;
|
||||||
// Base stats
|
const hasNVG = !!document.querySelector(
|
||||||
|
"#modifiers input[id='damage-item-multiplicative-nightvision']:checked"
|
||||||
|
);
|
||||||
let baseDamage = selectedWeapon.damage;
|
let baseDamage = selectedWeapon.damage;
|
||||||
let baseRpm = selectedWeapon.rpm;
|
let baseRpm = selectedWeapon.rpm;
|
||||||
let baseReloadTime = selectedWeapon.reload_time;
|
let baseReloadTime = selectedWeapon.reload_time;
|
||||||
// Modifiers initialization
|
|
||||||
let damageModifier = {additive: 0, multiplicative: 1};
|
let damageModifier = {additive: 0, multiplicative: 1};
|
||||||
let rpmModifier = {additive: 0, multiplicative: 1};
|
let rpmModifier = {additive: 0, multiplicative: 1};
|
||||||
let reloadTimeModifier = {additive: 0, multiplicative: 1};
|
let reloadTimeModifier = {additive: 0, multiplicative: 1};
|
||||||
headshotMultiplier = 0; // Reset headshot multiplier
|
headshotMultiplier = 0;
|
||||||
headshotBaseApplied = false;
|
headshotBaseApplied = false;
|
||||||
|
ignoreHeadshots = hasNVG;
|
||||||
|
|
||||||
// Function to process global modifiers
|
// Function to process global modifiers
|
||||||
function processModifier(mod) {
|
function processModifier(mod) {
|
||||||
@@ -413,6 +415,11 @@ function applyModifiers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier) {
|
function applyBuff(buff, rpmModifier, reloadTimeModifier, damageModifier) {
|
||||||
|
if (ignoreHeadshots &&
|
||||||
|
(buff.buffType === 'multiplicative-headshot' ||
|
||||||
|
buff.buffType === 'multiplicative-headshot-base')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {type, buffType, value} = buff;
|
const {type, buffType, value} = buff;
|
||||||
// Handle headshot multipliers
|
// Handle headshot multipliers
|
||||||
if (buffType === 'multiplicative-headshot-base' && !headshotBaseApplied) {
|
if (buffType === 'multiplicative-headshot-base' && !headshotBaseApplied) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "damage-item-multiplicative-nightvision",
|
"id": "damage-item-multiplicative-nightvision",
|
||||||
"label": "Night Vision Goggles (+50% damage)",
|
"label": "Night Vision Goggles (+50% damage) | Resets Headshot Multiplier",
|
||||||
"value": 1.5,
|
"value": 1.5,
|
||||||
"type": "multiplicative",
|
"type": "multiplicative",
|
||||||
"operatives": ""
|
"operatives": ""
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" type="image/x-icon" href="/static/img/TRL_Logo_Custom.jpg">
|
<link rel="icon" type="image/x-icon" href="/trlstats/static/img/TRL_Logo_Custom.jpg">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||||
<title>DPM/DPS Calculator</title>
|
<title>DPM/DPS Calculator</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user