Skip to content

Commit

Permalink
Counterattack/Me First support added, other minor tweaks
Browse files Browse the repository at this point in the history
-Support for Counter, Mirror Coat, Metal Burst, Comeuppance, and Me First has been added! It might end up being a bit buggy, so we'll see if it sticks.
-Added some more cases for Typeless damage (Struggle, Beat Up, Future Sight, Doom Desire) and prevent Typeless Pokemon from getting STAB on Typeless moves
-Removed all Gigantamax Pokemon for SV National Dex since Dynamax isn't a thing for Gen 9 on Showdown as far as I know
-Changed the wording in a few places: moves that double in BP and results for Status moves and no damage
-Added a file of all titan bosses in SV for a potential boss damage calc
  • Loading branch information
nerd-of-now authored and kunyi731 committed Dec 27, 2023
1 parent 6a3026f commit d7e1ac9
Show file tree
Hide file tree
Showing 10 changed files with 663 additions and 254 deletions.
16 changes: 8 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ <h4 class="panel-title">宝可梦#1</h4>
</select>
<select class="move-double calc-trigger hide">
<option value="0">正常威力</option>
<option value="1">翻倍</option>
<option value="1">2倍威力</option>
</select>
<select class="move-hits2 calc-trigger hide">
<option value="1">1次命中</option>
Expand Down Expand Up @@ -446,7 +446,7 @@ <h4 class="panel-title">宝可梦#1</h4>
</select>
<select class="move-double calc-trigger hide">
<option value="0">正常威力</option>
<option value="1">翻倍</option>
<option value="1">2倍威力</option>
</select>
<select class="move-hits2 calc-trigger hide">
<option value="1">1次命中</option>
Expand Down Expand Up @@ -503,7 +503,7 @@ <h4 class="panel-title">宝可梦#1</h4>
</select>
<select class="move-double calc-trigger hide">
<option value="0">正常威力</option>
<option value="1">翻倍</option>
<option value="1">2倍威力</option>
</select>
<select class="move-hits2 calc-trigger hide">
<option value="1">1次命中</option>
Expand Down Expand Up @@ -560,7 +560,7 @@ <h4 class="panel-title">宝可梦#1</h4>
</select>
<select class="move-double calc-trigger hide">
<option value="0">正常威力</option>
<option value="1">翻倍</option>
<option value="1">2倍威力</option>
</select>
<select class="move-hits2 calc-trigger hide">
<option value="1">1次命中</option>
Expand Down Expand Up @@ -1168,7 +1168,7 @@ <h4 class="panel-title">宝可梦#2</h4>
</select>
<select class="move-double calc-trigger hide">
<option value="0">正常威力</option>
<option value="1">翻倍</option>
<option value="1">2倍威力</option>
</select>
<select class="move-hits2 calc-trigger hide">
<option value="1">1次命中</option>
Expand Down Expand Up @@ -1225,7 +1225,7 @@ <h4 class="panel-title">宝可梦#2</h4>
</select>
<select class="move-double calc-trigger hide">
<option value="0">正常威力</option>
<option value="1">翻倍</option>
<option value="1">2倍威力</option>
</select>
<select class="move-hits2 calc-trigger hide">
<option value="1">1次命中</option>
Expand Down Expand Up @@ -1282,7 +1282,7 @@ <h4 class="panel-title">宝可梦#2</h4>
</select>
<select class="move-double calc-trigger hide">
<option value="0">正常威力</option>
<option value="1">翻倍</option>
<option value="1">2倍威力</option>
</select>
<select class="move-hits2 calc-trigger hide">
<option value="1">1次命中</option>
Expand Down Expand Up @@ -1339,7 +1339,7 @@ <h4 class="panel-title">宝可梦#2</h4>
</select>
<select class="move-double calc-trigger hide">
<option value="0">正常威力</option>
<option value="1">翻倍</option>
<option value="1">2倍威力</option>
</select>
<select class="move-hits2 calc-trigger hide">
<option value="1">1次命中</option>
Expand Down
6 changes: 3 additions & 3 deletions script_res/ap_calc.css
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ select.ability-supreme, select.ability-proto-quark {
select.toxic-counter {
width: 4.5em;
}
.move-selector, .move-bp, .move-type, .move-cat, .move-hits, .move-double, .move-hits2, .move-hits3, .move-pledge, .move-10hits, .move-lastRespRageFist {
.move-selector, .move-bp, .move-type, .move-cat, .move-hits, .move-double, .move-hits2, .move-hits3, .move-pledge, .move-10hits, .move-linearAddedBP, .move-opponent {
font-size: 0.9em;
}
.move-selector {
Expand All @@ -214,10 +214,10 @@ select.toxic-counter {
.poke-info input.move-bp {
width: 2em;
}
.move-cat/*, .move-hits*/, .move-lastRespRageFist {
.move-cat, .move-linearAddedBP {
width: 4em;
}
.move-hits, .move-double, .move-hits2, .move-hits3, .move-pledge, .move-10hits {
.move-hits, .move-double, .move-hits2, .move-hits3, .move-pledge, .move-10hits, .move-opponent {
width: 4.6em;
}
.abilityToggle, .ability-advanced{
Expand Down
16 changes: 8 additions & 8 deletions script_res/ap_calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,12 @@ $(".move-selector").change(function() {
if (move.linearAddBP) moveGroupObj.children(".move-linearAddedBP").show();
else moveGroupObj.children(".move-linearAddedBP").hide();

//if (move.usesOppMoves) {
// getOppMoves($(this).closest(".poke-info").attr("id"), moveGroupObj);
// moveGroupObj.children(".move-opponent").show();
//} else {
// moveGroupObj.children(".move-opponent").hide();
//}
if (move.usesOppMoves) { //for when the attacker's moves change
getOppMoves($(this).closest(".poke-info").attr("id"), moveGroupObj);
moveGroupObj.children(".move-opponent").show();
} else {
moveGroupObj.children(".move-opponent").hide();
}

if (move.isTripleHit) {
moveGroupObj.children(".move-hits3").show();
Expand All @@ -521,7 +521,7 @@ $(".move-selector").change(function() {

//SLOPPY WAY OF HANDLING
glaiveRushCheck(moveGroupObj);
//getOppMoves($(this).closest(".poke-info").attr("id"));
getOppMoves($(this).closest(".poke-info").attr("id")); //for when the defender's moves change
});

function getOppMoves(pokID, moveGroupObj) {
Expand Down Expand Up @@ -1035,7 +1035,7 @@ function getMoveDetails(moveInfo, maxMon) {
tripleHits: (defaultDetails.isTripleHit && !moveInfo.find(".move-z").prop("checked") && !maxMon) ? ~~moveInfo.find(".move-hits3").val() : 0,
combinePledge: (moveName.includes(" Pledge") && !moveInfo.find(".move-z").prop("checked") && !maxMon) ? moveInfo.find(".move-pledge").val() : 0,
timesAffected: (defaultDetails.linearAddBP && !moveInfo.find(".move-z").prop("checked") && !maxMon) ? ~~moveInfo.find(".move-linearAddedBP").val() : 0,
//usedOppMove: ~~moveInfo.find(".move-opponent").val(),
usedOppMove: moveInfo.find(".move-opponent option:selected").text(),
});
}

Expand Down
138 changes: 81 additions & 57 deletions script_res/damage_MASTER.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ function buildDescription(description) {
// translated
output += "[" + translate_ability("Flower Gift") + "] ";
}
if (description.meFirst) {
output += "Me First ";
}
output += description.moveName + " ";
if (description.moveBP && description.moveType) {
//output += "(" + description.moveBP + " BP " + description.moveType + ") ";
Expand Down Expand Up @@ -128,7 +131,7 @@ function buildDescription(description) {
}
output = appendIfSet(output, description.HPEVs);
if (description.defenseEVs) {
output += " / " + description.defenseEVs + " ";
output += "/ " + description.defenseEVs + " ";
}
//output = appendIfSet(output, description.defenderItem);
// translated
Expand Down Expand Up @@ -631,6 +634,9 @@ function checkMoveTypeChange(move, field, attacker) {
move.type = "Grass";
}
}
else if ((move.name == "Struggle" && gen >= 2) || (['Beat Up', 'Future Sight', 'Doom Desire'].indexOf(move.name) != -1 && gen <= 4)) {
move.type = 'Typeless';
}
}

function checkConditionalPriority(move, terrain) {
Expand Down Expand Up @@ -768,15 +774,16 @@ function NaturePower(move, field, moveDescName) { //Rename Nature Power to its a
return [move, moveDescName];
}

//function checkMeFirst(move, moveDescName) {
// var meFirstZ = move.isZ;
// move.name = move.usedOppMove;
// move = moves[move.usedOppMove];
// move.isMeFirst = true;
// move.isZ = meFirstZ;
// moveDescName = move.name;
// return GET_DAMAGE_HANDLER(attacker, defender, counteredMove, field);
//}
function checkMeFirst(move, moveDescName) {
var meFirstZ = move.isZ;
moveName = move.usedOppMove;
move = moves[move.usedOppMove];
move.name = moveName;
move.isMeFirst = true;
move.isZ = meFirstZ;
moveDescName = move.name;
return [move, moveDescName];
}

function statusMoves(move, attacker, defender, description) {
if (move.name === "Pain Split" && attacker.item !== "Assault Vest") {
Expand Down Expand Up @@ -941,30 +948,43 @@ function immunityChecks(move, attacker, defender, field, description, defAbility
}

//Special Cases
function setDamage(move, attacker, defender, description, isQuarteredByProtect) {
function setDamage(move, attacker, defender, description, isQuarteredByProtect, field) {
var isParentBond = attacker.ability === "Parental Bond";
//a. Counterattacks (Counter, Mirror Coat, Metal Burst, Comeuppance, Bide)
//if (['Counter', 'Mirror Coat', 'Metal Burst', 'Comeuppance'].indexOf(move.name) !== -1) {
// var counteredMove = moves[move.usedOppMove];
// counteredMove.hits = 1;
// //if move can be countered (nested if)
// if (counteredMove.category !== 'Status') {
// counteredResult = GET_DAMAGE_HANDLER(defender, attacker, counteredMove, field);
// if (['Counter', 'Mirror Coat'].indexOf(move.name) !== -1 && move.category == counteredMove.category) {
// for (i = 0; i < counteredResult.damage.length(); i++) {
// counteredResult.damage[i] *= 2;
// }
// counteredResult.description = 'Countered '
// }
// else {
// for (i = 0; i < counteredResult.damage.length(); i++) {
// counteredResult.damage[i] = floor(counteredResult.damage[i] * 1.5);
// }
// }
// return counteredResult;
// }
// //Bide ain't being added it's too niche
//}
if (['Counter', 'Mirror Coat', 'Metal Burst', 'Comeuppance'].indexOf(move.name) !== -1) {
var moveName = move.usedOppMove ? move.usedOppMove : '(No Move)';
var counteredMove = moves[moveName];
counteredMove.name = moveName;
counteredMove.hits = 1;
if (counteredMove.isTripleHit)
counteredMove.tripleHit3 = true;
else if (defender.ability === 'Parental Bond' && (field.format === "Singles" || !counteredMove.isSpread))
defender.isChild = true;
//if move can be countered (nested if)
if (counteredMove.category !== 'Status') {
counteredResult = GET_DAMAGE_HANDLER(defender, attacker, counteredMove, field);
if (['Counter', 'Mirror Coat'].indexOf(move.name) !== -1 && move.category == counteredMove.category) {
for (i = 0; i < counteredResult.damage.length; i++) {
counteredResult.damage[i] *= 2;
}
counteredResult.description = '2x ' + move.name + ' (' + counteredResult.description + ') vs. ' + description.HPEVs + ' ' + description.defenderName;
}
else if (['Metal Burst', 'Comeuppance'].indexOf(move.name) !== -1) {
for (i = 0; i < counteredResult.damage.length; i++) {
counteredResult.damage[i] = Math.floor(counteredResult.damage[i] * 1.5);
}
counteredResult.description = '1.5x ' + move.name + ' (' + counteredResult.description + ') vs. ' + description.HPEVs + ' ' + description.defenderName;
}
else {
return { "damage": [0], "description": buildDescription(description) };
}
return counteredResult;
}
else {
return { "damage": [0], "description": buildDescription(description) };
}
//Bide ain't being added it's too niche
}

//b. Defender HP Dependent (Super Fang/Nature's Madness/Ruination, Guardian of Alola)
var def_curHP;
Expand Down Expand Up @@ -1419,6 +1439,8 @@ function calcBPMods(attacker, defender, field, move, description, ateIzeBoosted,
//n. Me First
if (move.isMeFirst) {
bpMods.push(0x1800);
description.meFirst = true;
move.isMeFirst = false;
}

//o. Knock Off
Expand Down Expand Up @@ -1825,37 +1847,39 @@ function calcGeneralMods(baseDamage, move, attacker, defender, defAbility, field
//see GENERAL MODS CONTINUED for further comments

var stabMod = 0x1000;
if (!attacker.isTerastalize) {
if (move.type === attacker.type1 || move.type === attacker.type2 || (move.combinePledge && move.combinePledge !== move.name)) {
if (attacker.ability === "Adaptability") {
stabMod = 0x2000;
description.attackerAbility = attacker.ability;
} else {
stabMod = 0x1800;
}
} else if ((attacker.ability === "Protean" || attacker.ability == "Libero") && (gen !== 9 || attacker.abilityOn)) {
stabMod = 0x1800;
description.attackerAbility = attacker.ability;
}
}
else {
if (pokedex[attacker.name]) { //catches any potential issues when switching between sv dex and national dex with a terastalized mon
if (move.type === attacker.tera_type && (pokedex[attacker.name].t1 === attacker.tera_type || pokedex[attacker.name].t2 === attacker.tera_type)) {
if (move.type !== 'Typeless') { //Typeless moves cannot get stab even if the user is Typeless
if (!attacker.isTerastalize) {
if (move.type === attacker.type1 || move.type === attacker.type2 || (move.combinePledge && move.combinePledge !== move.name)) {
if (attacker.ability === "Adaptability") {
stabMod = 0x2400;
description.attackerAbility = attacker.ability;
} else {
stabMod = 0x2000;
}
}
else if ((move.type !== attacker.tera_type && (pokedex[attacker.name].t1 === move.type || pokedex[attacker.name].t2 === move.type))
|| move.type === attacker.tera_type) {
if (attacker.ability === "Adaptability" && move.type === attacker.tera_type) {
stabMod = 0x2000;
description.attackerAbility = attacker.ability;
} else {
stabMod = 0x1800;
}
} else if ((attacker.ability === "Protean" || attacker.ability == "Libero") && (gen !== 9 || attacker.abilityOn)) {
stabMod = 0x1800;
description.attackerAbility = attacker.ability;
}
}
else {
if (pokedex[attacker.name]) { //catches any potential issues when switching between sv dex and national dex with a terastalized mon
if (move.type === attacker.tera_type && (pokedex[attacker.name].t1 === attacker.tera_type || pokedex[attacker.name].t2 === attacker.tera_type)) {
if (attacker.ability === "Adaptability") {
stabMod = 0x2400;
description.attackerAbility = attacker.ability;
} else {
stabMod = 0x2000;
}
}
else if ((move.type !== attacker.tera_type && (pokedex[attacker.name].t1 === move.type || pokedex[attacker.name].t2 === move.type))
|| move.type === attacker.tera_type) {
if (attacker.ability === "Adaptability" && move.type === attacker.tera_type) {
stabMod = 0x2000;
description.attackerAbility = attacker.ability;
} else {
stabMod = 0x1800;
}
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion script_res/damage_SV.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ function GET_DAMAGE_SV(attacker, defender, move, field) {

if (move.name == "Nature Power" && attacker.item !== 'Assault Vest')
[move, moveDescName] = NaturePower(move, field, moveDescName);
else if (move.name == 'Me First' && !move.isMeFirst && attacker.item !== 'Assault Vest')
[move, moveDescName] = checkMeFirst(move, moveDescName);

if (move.isZ || move.isSignatureZ)
[move, isQuarteredByProtect, moveDescName] = ZMoves(move, field, attacker, isQuarteredByProtect, moveDescName);
Expand Down Expand Up @@ -125,7 +127,7 @@ function GET_DAMAGE_SV(attacker, defender, move, field) {

description.HPEVs = defender.HPEVs + " HP";

setDamageBuildDesc = setDamage(move, attacker, defender, description, isQuarteredByProtect);
setDamageBuildDesc = setDamage(move, attacker, defender, description, isQuarteredByProtect, field);
if (setDamageBuildDesc !== -1) return setDamageBuildDesc;

if (move.hits > 1) {
Expand Down
6 changes: 3 additions & 3 deletions script_res/ko_chance.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ function getKOChanceText(damage, move, defender, field, isBadDreams) {
if (move.name == "Pain Split" && !move.painMax) {
return 'The battlers shared their pain!';
}
if (move.category == "Status") {
return 'Might as well Thunderbolt a Landorus';
if (move.category == "Status" && move.name != 'Me First') {
return "It's a status move, it won't deal damage.";
}
if (damage[damage.length-1] === 0) {
if (field.weather === "Harsh Sun" && move.type === "Water") {
return 'the Water-Type attack evaporated in the harsh sunlight';
} else if (field.weather === "Heavy Rain" && move.type === "Fire") {
return 'the Fire-Type attack fizzled out in the heavy rain';
}
return '[The Smooth Taste Of] IMMUNE';
return 'No damage for you';
}
var hasSitrus = defender.item === 'Sitrus Berry';
var hasFigy = defender.item === 'Figy Berry' || defender.item === 'Aguav Berry' || defender.item === 'Iapapa Berry' || defender.item === 'Mago Berry' || defender.item === 'Wiki Berry';
Expand Down
Loading

0 comments on commit d7e1ac9

Please sign in to comment.