From 936ba43a5584e33118f4b0767046af74cfcc2ff1 Mon Sep 17 00:00:00 2001 From: Shiva Devarajan Date: Fri, 27 Dec 2024 15:17:10 -0500 Subject: [PATCH 1/4] Remove drop stats check and add knock off check --- calc/src/mechanics/gen56.ts | 17 ++++++++++++----- calc/src/mechanics/gen789.ts | 17 ++++++++++++----- calc/src/move.ts | 2 +- src/js/shared_controls.js | 7 +------ 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/calc/src/mechanics/gen56.ts b/calc/src/mechanics/gen56.ts index 8000d4823..0ff24f4cf 100644 --- a/calc/src/mechanics/gen56.ts +++ b/calc/src/mechanics/gen56.ts @@ -371,12 +371,12 @@ export function calculateBWXY( desc.attackBoost = move.named('Foul Play') ? defender.boosts[attackStat] : attacker.boosts[attackStat]; - if ((move.dropsStats && move.timesUsed! > 1) || move.hits > 1) { + if (move.timesUsed! > 1 || move.hits > 1) { // store boosts so intermediate boosts don't show. const origDefBoost = desc.defenseBoost; const origAtkBoost = desc.attackBoost; let numAttacks = 1; - if (move.dropsStats && move.timesUsed! > 1) { + if (move.timesUsed! > 1) { desc.moveTurns = `over ${move.timesUsed} turns`; numAttacks = move.timesUsed!; } else { @@ -393,7 +393,7 @@ export function calculateBWXY( hasAteAbilityTypeChange = hasAteAbilityTypeChange && attacker.hasAbility('Aerilate', 'Galvanize', 'Pixilate', 'Refrigerate'); - if ((move.dropsStats && move.timesUsed! > 1)) { + if (move.timesUsed! > 1) { // Adaptability does not change between hits of a multihit, only between turns stabMod = getStabMod(attacker, move, desc); } @@ -600,7 +600,8 @@ export function calculateBasePowerBWXY( desc, basePower, hasAteAbilityTypeChange, - turnOrder + turnOrder, + hit ); basePower = OF16(Math.max(1, pokeRound((basePower * chainMods(bpMods, 41, 2097152)) / 4096))); @@ -616,7 +617,8 @@ export function calculateBPModsBWXY( desc: RawDesc, basePower: number, hasAteAbilityTypeChange: boolean, - turnOrder: string + turnOrder: string, + hit: number ) { const bpMods = []; @@ -637,6 +639,11 @@ export function calculateBPModsBWXY( resistedKnockOffDamage = !!(item.megaEvolves && defender.name.includes(item.megaEvolves)); } + // Resist knock off damage if your item was already knocked off + if (!resistedKnockOffDamage && hit > 0 && !defender.hasAbility('Sticky Hold')) { + resistedKnockOffDamage = true; + } + // Use BasePower after moves with custom BP to determine if Technician should boost if ((attacker.hasAbility('Technician') && basePower <= 60) || diff --git a/calc/src/mechanics/gen789.ts b/calc/src/mechanics/gen789.ts index 6c063f690..819ee1625 100644 --- a/calc/src/mechanics/gen789.ts +++ b/calc/src/mechanics/gen789.ts @@ -676,13 +676,13 @@ export function calculateSMSSSV( desc.attackBoost = move.named('Foul Play') ? defender.boosts[attackStat] : attacker.boosts[attackStat]; - if ((move.dropsStats && move.timesUsed! > 1) || move.hits > 1) { + if (move.timesUsed! > 1 || move.hits > 1) { // store boosts so intermediate boosts don't show. const origDefBoost = desc.defenseBoost; const origAtkBoost = desc.attackBoost; let numAttacks = 1; - if (move.dropsStats && move.timesUsed! > 1) { + if (move.timesUsed! > 1) { desc.moveTurns = `over ${move.timesUsed} turns`; numAttacks = move.timesUsed!; } else { @@ -701,7 +701,7 @@ export function calculateSMSSSV( hasAteAbilityTypeChange = hasAteAbilityTypeChange && attacker.hasAbility('Aerilate', 'Galvanize', 'Pixilate', 'Refrigerate', 'Normalize'); - if ((move.dropsStats && move.timesUsed! > 1)) { + if (move.timesUsed! > 1) { // Adaptability does not change between hits of a multihit, only between turns preStellarStabMod = getStabMod(attacker, move, desc); // Hack to make Tera Shell with multihit moves, but not over multiple turns @@ -1004,7 +1004,8 @@ export function calculateBasePowerSMSSSV( desc, basePower, hasAteAbilityTypeChange, - turnOrder + turnOrder, + hit ); basePower = OF16(Math.max(1, pokeRound((basePower * chainMods(bpMods, 41, 2097152)) / 4096))); if ( @@ -1028,7 +1029,8 @@ export function calculateBPModsSMSSSV( desc: RawDesc, basePower: number, hasAteAbilityTypeChange: boolean, - turnOrder: string + turnOrder: string, + hit: number ) { const bpMods = []; @@ -1061,6 +1063,11 @@ export function calculateBPModsSMSSSV( resistedKnockOffDamage = !!item.megaEvolves && defender.name.includes(item.megaEvolves); } + // Resist knock off damage if your item was already knocked off + if (!resistedKnockOffDamage && hit > 0 && !defender.hasAbility('Sticky Hold')) { + resistedKnockOffDamage = true; + } + if ((move.named('Facade') && attacker.hasStatus('brn', 'par', 'psn', 'tox')) || (move.named('Brine') && defender.curHP() <= defender.maxHP() / 2) || (move.named('Venoshock') && defender.hasStatus('psn', 'tox')) || diff --git a/calc/src/move.ts b/calc/src/move.ts index 47526a57d..bc3f9a24f 100644 --- a/calc/src/move.ts +++ b/calc/src/move.ts @@ -133,7 +133,7 @@ export class Move implements State.Move { if (data.self?.boosts && data.self.boosts[stat] && data.self.boosts[stat]! < 0) { this.dropsStats = Math.abs(data.self.boosts[stat]!); } - this.timesUsed = (this.dropsStats && options.timesUsed) || 1; + this.timesUsed = options.timesUsed || 1; this.secondaries = data.secondaries; // For the purposes of the damage formula only 'allAdjacent' and 'allAdjacentFoes' matter, so we // simply default to 'any' for the others even though they may not actually be 'any'-target diff --git a/src/js/shared_controls.js b/src/js/shared_controls.js index f12eef1a2..a19381d8b 100644 --- a/src/js/shared_controls.js +++ b/src/js/shared_controls.js @@ -521,8 +521,6 @@ $(".move-selector").change(function () { moveGroupObj.children(".move-crit").prop("checked", move.willCrit === true); var stat = move.category === 'Special' ? 'spa' : 'atk'; - var dropsStats = - move.self && move.self.boosts && move.self.boosts[stat] && move.self.boosts[stat] < 0; if (Array.isArray(move.multihit) || (!isNaN(move.multihit) && move.multiaccuracy)) { moveGroupObj.children(".stat-drops").hide(); moveGroupObj.children(".move-hits").empty(); @@ -548,12 +546,9 @@ $(".move-selector").change(function () { } moveGroupObj.children(".move-hits").val(moveHits); - } else if (dropsStats) { - moveGroupObj.children(".move-hits").hide(); - moveGroupObj.children(".stat-drops").show(); } else { moveGroupObj.children(".move-hits").hide(); - moveGroupObj.children(".stat-drops").hide(); + moveGroupObj.children(".stat-drops").show(); } moveGroupObj.children(".move-z").prop("checked", false); }); From 650e10626332b45188823072ca900eb26a581c23 Mon Sep 17 00:00:00 2001 From: Shiva Devarajan Date: Fri, 27 Dec 2024 15:24:15 -0500 Subject: [PATCH 2/4] Change to 1-index --- calc/src/mechanics/gen56.ts | 2 +- calc/src/mechanics/gen789.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/calc/src/mechanics/gen56.ts b/calc/src/mechanics/gen56.ts index 0ff24f4cf..896f8bff0 100644 --- a/calc/src/mechanics/gen56.ts +++ b/calc/src/mechanics/gen56.ts @@ -640,7 +640,7 @@ export function calculateBPModsBWXY( } // Resist knock off damage if your item was already knocked off - if (!resistedKnockOffDamage && hit > 0 && !defender.hasAbility('Sticky Hold')) { + if (!resistedKnockOffDamage && hit > 1 && !defender.hasAbility('Sticky Hold')) { resistedKnockOffDamage = true; } diff --git a/calc/src/mechanics/gen789.ts b/calc/src/mechanics/gen789.ts index 819ee1625..7c8aee0e3 100644 --- a/calc/src/mechanics/gen789.ts +++ b/calc/src/mechanics/gen789.ts @@ -1064,7 +1064,7 @@ export function calculateBPModsSMSSSV( } // Resist knock off damage if your item was already knocked off - if (!resistedKnockOffDamage && hit > 0 && !defender.hasAbility('Sticky Hold')) { + if (!resistedKnockOffDamage && hit > 1 && !defender.hasAbility('Sticky Hold')) { resistedKnockOffDamage = true; } From 69ffbc0ca41f6e3e364018083f0e03d89d0d7aed Mon Sep 17 00:00:00 2001 From: Shiva Devarajan Date: Mon, 6 Jan 2025 23:16:38 -0500 Subject: [PATCH 3/4] Remove dropStats from all gens --- calc/src/mechanics/gen3.ts | 2 +- calc/src/mechanics/gen4.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/calc/src/mechanics/gen3.ts b/calc/src/mechanics/gen3.ts index b2d42f4a2..07da95a2b 100644 --- a/calc/src/mechanics/gen3.ts +++ b/calc/src/mechanics/gen3.ts @@ -165,7 +165,7 @@ export function calculateADV( result.damage[i - 85] = Math.max(1, Math.floor((baseDamage * i) / 100)); } - if ((move.dropsStats && move.timesUsed! > 1) || move.hits > 1) { + if (move.timesUsed! > 1 || move.hits > 1) { // store boosts so intermediate boosts don't show. const origDefBoost = desc.defenseBoost; const origAtkBoost = desc.attackBoost; diff --git a/calc/src/mechanics/gen4.ts b/calc/src/mechanics/gen4.ts index f8b6d3318..0c95ec116 100644 --- a/calc/src/mechanics/gen4.ts +++ b/calc/src/mechanics/gen4.ts @@ -279,7 +279,7 @@ export function calculateDPP( } result.damage = damage; - if ((move.dropsStats && move.timesUsed! > 1) || move.hits > 1) { + if (move.timesUsed! > 1 || move.hits > 1) { // store boosts so intermediate boosts don't show. const origDefBoost = desc.defenseBoost; const origAtkBoost = desc.attackBoost; From b8d3cb3e3bacd23f7445b9eaee957933bd389e70 Mon Sep 17 00:00:00 2001 From: Shiva Devarajan Date: Mon, 6 Jan 2025 23:16:54 -0500 Subject: [PATCH 4/4] Rename stat-drops to move-times --- src/honkalculate.template.html | 8 ++++---- src/index.template.html | 16 ++++++++-------- src/js/shared_controls.js | 8 ++++---- src/oms.template.html | 16 ++++++++-------- src/randoms.template.html | 16 ++++++++-------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/honkalculate.template.html b/src/honkalculate.template.html index 84edb5140..d5d5f973d 100644 --- a/src/honkalculate.template.html +++ b/src/honkalculate.template.html @@ -509,7 +509,7 @@ - > @@ -545,7 +545,7 @@ - > @@ -581,7 +581,7 @@ - > @@ -617,7 +617,7 @@ - > diff --git a/src/index.template.html b/src/index.template.html index c832aa94b..50a4e1394 100644 --- a/src/index.template.html +++ b/src/index.template.html @@ -570,7 +570,7 @@ - > @@ -606,7 +606,7 @@ - > @@ -642,7 +642,7 @@ - > @@ -678,7 +678,7 @@ - > @@ -1488,7 +1488,7 @@ - > @@ -1524,7 +1524,7 @@ - > @@ -1560,7 +1560,7 @@ - > @@ -1596,7 +1596,7 @@ - > diff --git a/src/js/shared_controls.js b/src/js/shared_controls.js index a19381d8b..631aaf586 100644 --- a/src/js/shared_controls.js +++ b/src/js/shared_controls.js @@ -522,7 +522,7 @@ $(".move-selector").change(function () { var stat = move.category === 'Special' ? 'spa' : 'atk'; if (Array.isArray(move.multihit) || (!isNaN(move.multihit) && move.multiaccuracy)) { - moveGroupObj.children(".stat-drops").hide(); + moveGroupObj.children(".move-times").hide(); moveGroupObj.children(".move-hits").empty(); if (!isNaN(move.multihit)) { for (var i = 1; i <= move.multihit; i++) { @@ -548,7 +548,7 @@ $(".move-selector").change(function () { moveGroupObj.children(".move-hits").val(moveHits); } else { moveGroupObj.children(".move-hits").hide(); - moveGroupObj.children(".stat-drops").show(); + moveGroupObj.children(".move-times").show(); } moveGroupObj.children(".move-z").prop("checked", false); }); @@ -1133,7 +1133,7 @@ function getMoveDetails(moveInfo, opts) { var isCrit = moveInfo.find(".move-crit").prop("checked"); var isStellarFirstUse = moveInfo.find(".move-stellar").prop("checked"); var hits = +moveInfo.find(".move-hits").val(); - var timesUsed = +moveInfo.find(".stat-drops").val(); + var timesUsed = +moveInfo.find(".move-times").val(); var timesUsedWithMetronome = moveInfo.find(".metronome").is(':visible') ? +moveInfo.find(".metronome").val() : 1; var overrides = { basePower: +moveInfo.find(".move-bp").val(), @@ -1142,7 +1142,7 @@ function getMoveDetails(moveInfo, opts) { if (moveName === 'Tera Blast') { // custom logic for stellar type tera blast var isStellar = opts.teraType === 'Stellar'; - var statDrops = moveInfo.find('.stat-drops'); + var statDrops = moveInfo.find('.move-times'); var dropsStats = statDrops.is(':visible'); if (isStellar !== dropsStats) { // update stat drop dropdown here diff --git a/src/oms.template.html b/src/oms.template.html index 5c57c0e3b..50b3205d2 100644 --- a/src/oms.template.html +++ b/src/oms.template.html @@ -568,7 +568,7 @@ - > @@ -604,7 +604,7 @@ - > @@ -640,7 +640,7 @@ - > @@ -676,7 +676,7 @@ - > @@ -1485,7 +1485,7 @@ - > @@ -1521,7 +1521,7 @@ - > @@ -1557,7 +1557,7 @@ - > @@ -1593,7 +1593,7 @@ - > diff --git a/src/randoms.template.html b/src/randoms.template.html index 18517a2d4..f01f69bb7 100644 --- a/src/randoms.template.html +++ b/src/randoms.template.html @@ -578,7 +578,7 @@ - > @@ -614,7 +614,7 @@ - > @@ -650,7 +650,7 @@ - > @@ -686,7 +686,7 @@ - > @@ -1456,7 +1456,7 @@ - > @@ -1492,7 +1492,7 @@ - > @@ -1528,7 +1528,7 @@ - > @@ -1564,7 +1564,7 @@ - >