Skip to content

Commit

Permalink
TODO List, task No.5 (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ntonio36 authored and AustinXII committed Dec 30, 2017
1 parent fa13537 commit 2ec87f8
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 110 deletions.
56 changes: 56 additions & 0 deletions index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,13 @@
<option value="4">4 hits</option>
<option value="5">5 hits</option>
</select>
<select class="stat-drops calc-trigger hide">
<option value="1">Once</option>
<option value="2">Twice</option>
<option value="3">3 times</option>
<option value="4">4 times</option>
<option value="5">5 times</option>
</select>
</div>
<div class="move2">
<select class="move-selector calc-trigger small-select"></select>
Expand All @@ -495,6 +502,13 @@
<option value="4">4 hits</option>
<option value="5">5 hits</option>
</select>
<select class="stat-drops calc-trigger hide">
<option value="1">Once</option>
<option value="2">Twice</option>
<option value="3">3 times</option>
<option value="4">4 times</option>
<option value="5">5 times</option>
</select>
</div>
<div class="move3">
<select class="move-selector calc-trigger small-select"></select>
Expand All @@ -514,6 +528,13 @@
<option value="4">4 hits</option>
<option value="5">5 hits</option>
</select>
<select class="stat-drops calc-trigger hide">
<option value="1">Once</option>
<option value="2">Twice</option>
<option value="3">3 times</option>
<option value="4">4 times</option>
<option value="5">5 times</option>
</select>
</div>
<div class="move4">
<select class="move-selector calc-trigger small-select"></select>
Expand All @@ -533,6 +554,13 @@
<option value="4">4 hits</option>
<option value="5">5 hits</option>
</select>
<select class="stat-drops calc-trigger hide">
<option value="1">Once</option>
<option value="2">Twice</option>
<option value="3">3 times</option>
<option value="4">4 times</option>
<option value="5">5 times</option>
</select>
</div>
</fieldset>
</div>
Expand Down Expand Up @@ -1107,6 +1135,13 @@
<option value="4">4 hits</option>
<option value="5">5 hits</option>
</select>
<select class="stat-drops calc-trigger hide">
<option value="1">Once</option>
<option value="2">Twice</option>
<option value="3">3 times</option>
<option value="4">4 times</option>
<option value="5">5 times</option>
</select>
</div>
<div class="move2">
<select class="move-selector calc-trigger small-select"></select>
Expand All @@ -1126,6 +1161,13 @@
<option value="4">4 hits</option>
<option value="5">5 hits</option>
</select>
<select class="stat-drops calc-trigger hide">
<option value="1">Once</option>
<option value="2">Twice</option>
<option value="3">3 times</option>
<option value="4">4 times</option>
<option value="5">5 times</option>
</select>
</div>
<div class="move3">
<select class="move-selector calc-trigger small-select"></select>
Expand All @@ -1145,6 +1187,13 @@
<option value="4">4 hits</option>
<option value="5">5 hits</option>
</select>
<select class="stat-drops calc-trigger hide">
<option value="1">Once</option>
<option value="2">Twice</option>
<option value="3">3 times</option>
<option value="4">4 times</option>
<option value="5">5 times</option>
</select>
</div>
<div class="move4">
<select class="move-selector calc-trigger small-select"></select>
Expand All @@ -1164,6 +1213,13 @@
<option value="4">4 hits</option>
<option value="5">5 hits</option>
</select>
<select class="stat-drops calc-trigger hide">
<option value="1">Once</option>
<option value="2">Twice</option>
<option value="3">3 times</option>
<option value="4">4 times</option>
<option value="5">5 times</option>
</select>
</div>
</fieldset>
</div>
Expand Down
69 changes: 54 additions & 15 deletions js/damage.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,15 @@ function getDamageResult(attacker, defender, move, field) {
var isRefrigerate = false;
var isGalvanize = false;
var isLiquidVoice = false;
var isNormalize = false;

if (!move.isZ) {
isAerilate = attacker.ability === "Aerilate" && move.type === "Normal";
isPixilate = attacker.ability === "Pixilate" && move.type === "Normal";
isRefrigerate = attacker.ability === "Refrigerate" && move.type === "Normal";
isGalvanize = attacker.ability === "Galvanize" && move.type === "Normal";
isLiquidVoice = attacker.ability === "Liquid Voice" && move.isSound;
isNormalize = attacker.ability === "Normalize" && move.type !== "Normal";
if (isAerilate) {
move.type = "Flying";
} else if (isGalvanize) {
Expand All @@ -135,8 +137,10 @@ function getDamageResult(attacker, defender, move, field) {
move.type = "Fairy";
} else if (isRefrigerate) {
move.type = "Ice";
} else if (attacker.ability === "Normalize") {
} else if (isNormalize) {
move.type = "Normal";
}
if (isGalvanize || isLiquidVoice || isPixilate || isRefrigerate || isAerilate || isNormalize) {
description.attackerAbility = attacker.ability;
}
}
Expand All @@ -154,7 +158,7 @@ function getDamageResult(attacker, defender, move, field) {
(defender.name === "Giratina-Origin" && defender.item === "Griseous Orb") ||
(defender.name.indexOf("Arceus") !== -1 && defender.item.indexOf("Plate") !== -1) ||
(defender.name.indexOf("Genesect") !== -1 && defender.item.indexOf("Drive") !== -1) ||
(defender.ability.indexOf("RKS System") !== -1 && defender.item.indexOf("Memory") !== -1) ||
(defender.ability === "RKS System" && defender.item.indexOf("Memory") !== -1) ||
(defender.item.indexOf(" Z") !== -1));

if (typeEffectiveness === 0 && move.name === "Thousand Arrows") {
Expand Down Expand Up @@ -545,8 +549,7 @@ function getDamageResult(attacker, defender, move, field) {
description.defenderAbility = defAbility;
}

if ((gen < 7 && defender.item === "Soul Dew" && (defender.name === "Latios" || defender.name === "Latias") && !hitsPhysical) ||
(defender.item === "Assault Vest" && !hitsPhysical) || defender.item === "Eviolite") {
if (gen < 7 && (!hitsPhysical && ["Latios","Latias"].indexOf(defender.name) !== -1 && defender.item === "Soul Dew") || defender.item === "Eviolite" || (!hitsPhysical && defender.item === "Assault Vest")) {
dfMods.push(0x1800);
description.defenderItem = defender.item;
}
Expand Down Expand Up @@ -607,7 +610,7 @@ function getDamageResult(attacker, defender, move, field) {
}
// the random factor is applied between the crit mod and the stab mod, so don't apply anything below this until we're inside the loop
var stabMod = 0x1000;
if (move.type === attacker.type1 || move.type === attacker.type2) {
if (isSTAB) {
if (attacker.ability === "Adaptability") {
stabMod = 0x2000;
description.attackerAbility = attacker.ability;
Expand All @@ -628,7 +631,7 @@ function getDamageResult(attacker, defender, move, field) {
finalMods.push(field.format !== "Singles" ? (gen >= 6 ? 0xAAC : 0xA8F) : 0x800);
description.isLightScreen = true;
}
if ((defAbility === "Multiscale" || defAbility === "Shadow Shield") && defender.curHP === defender.maxHP && !field.isSR && (!field.spikes || defender.type1 === "Flying" || defender.type2 === "Flying")) {
if (["Multiscale", "Shadow Shield"].indexOf(defAbility) !== -1 && defender.curHP === defender.maxHP && !field.isSR && (!field.spikes || defender.type1 === "Flying" || defender.type2 === "Flying")) {
finalMods.push(0x800);
description.defenderAbility = defAbility;
}
Expand Down Expand Up @@ -656,7 +659,7 @@ function getDamageResult(attacker, defender, move, field) {
finalMods.push(0x1800);
description.attackerAbility = attacker.ability;
}
if ((defAbility === "Solid Rock" || defAbility === "Filter" || defAbility === "Prism Armor") && typeEffectiveness > 1) {
if (["Solid Rock", "Filter", "Prism Armor"].indexOf(defAbility) !== -1 && typeEffectiveness > 1) {
finalMods.push(0xC00);
description.defenderAbility = defAbility;
}
Expand All @@ -680,14 +683,7 @@ function getDamageResult(attacker, defender, move, field) {

var damage = [];
for (var i = 0; i < 16; i++) {
damage[i] = Math.floor(baseDamage * (85 + i) / 100);
damage[i] = pokeRound(damage[i] * stabMod / 0x1000);
damage[i] = Math.floor(damage[i] * typeEffectiveness);
if (applyBurn) {
damage[i] = Math.floor(damage[i] / 2);
}
damage[i] = Math.max(1, damage[i]);
damage[i] = pokeRound(damage[i] * finalMod / 0x1000);
damage[i] = getFinalDamage(baseDamage, i, typeEffectiveness, applyBurn, stabMod, finalMod);

// is 2nd hit half BP? half attack? half damage range? keeping it as a flat multiplier until I know the specifics
if (attacker.ability === "Parental Bond" && move.hits === 1 && (field.format === "Singles" || !move.isSpread)) {
Expand All @@ -696,6 +692,39 @@ function getDamageResult(attacker, defender, move, field) {
description.attackerAbility = attacker.ability;
}
}
if (move.dropsStats) {
if (move.usedTimes > 1) {
description.moveTurns = 'over ' + move.usedTimes + ' turns';
}
var droppedStats = move.dropsStats;
var boostDrop = Math.max(-6, attacker.boosts[attackStat] - (droppedStats * move.usedTimes));
if (attacker.ability === "Contrary") {
boostDrop = Math.min(6, attacker.boosts[attackStat] + (droppedStats * move.usedTimes));
}
var hasWhiteHerb = attacker.item === "White Herb";
var usedWhiteHerb = false;
for (var times = 0; times < move.usedTimes; times++) {
var oldAttack = attack;
var newAttack = getModifiedStat(attacker.rawStats[attackStat], attacker.boosts[attackStat]);
damage = damage.map(function(affectedAmount) {
if (times || oldAttack !== newAttack) {
return affectedAmount + Math.floor(affectedAmount * newAttack / oldAttack);
}
return affectedAmount;
});
attacker.boosts[attackStat] = boostDrop;
if (hasWhiteHerb && boostDrop < 0 && !usedWhiteHerb) {
boostDrop += move.dropsStats;
attacker.boosts[attackStat] = boostDrop;
usedWhiteHerb = true;
description.attackerItem = attacker.item;
}
}
description.attackBoost = attacker.boosts[attackStat];
} else {
delete description.attackBoost;
attacker.boosts[attackStat] += -move.dropsStats;
}
return {"damage": damage, "description": buildDescription(description)};
}

Expand Down Expand Up @@ -831,3 +860,13 @@ function isGroundedForCalc(pokemon, field) {
function pokeRound(num) {
return (num % 1 > 0.5) ? Math.ceil(num) : Math.floor(num);
}

function getFinalDamage(baseAmount, i, effectiveness, isBurned, stabMod, finalMod) {
var damageAmount = Math.floor(
pokeRound(Math.floor(baseAmount * (85 + i) / 100) * stabMod / 0x1000) * effectiveness
);
if (isBurned) {
damageAmount = Math.floor(damageAmount / 2);
}
return pokeRound(Math.max(1, damageAmount * finalMod / 0x1000));
}
1 change: 1 addition & 0 deletions js/damage_rby.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function buildDescription(description) {
if (description.hits) {
output += "(" + description.hits + " hits) ";
}
output = appendIfSet(output, description.moveTurns);
output += "vs. ";
if (description.defenseBoost) {
if (description.defenseBoost > 0) {
Expand Down
43 changes: 4 additions & 39 deletions js/data/item_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ function getFlingPower(item) {
'Life Orb', 'Light Ball', 'Magnet', 'Metal Coat', 'Miracle Seed', 'Mystic Water', 'Never-Melt Ice',
'Razor Fang', 'Soul Dew', 'Spell Tag', 'Toxic Orb', 'Twisted Spoon'].indexOf(item) !== -1 ? 30 :
item.indexOf('Berry') !== -1 ||
['Air Baloon', 'Choice Band', 'Choice Scarf', 'Choice Specs', 'Destiny Knot', 'Electric Seed', 'Expert Belt', 'Focus Band',
['Air Balloon', 'Choice Band', 'Choice Scarf', 'Choice Specs', 'Destiny Knot', 'Electric Seed', 'Expert Belt', 'Focus Band',
'Focus Sash', 'Grassy Seed', 'Lagging tail', 'leftovers', 'Mental Herb', 'Metal Powder', 'Misty Seed',
'Muscle Band', 'Power Herb', 'Psychic Seed', 'Quick Powder', 'Reaper Cloth', 'Red Card', 'Ring Target',
'Shed Shell', 'Silk Scarf', 'Silver Powder', 'Smooth Rock', 'Soft Sand', 'Soothe Bell', 'White Herb',
Expand Down Expand Up @@ -465,43 +465,8 @@ function getTechnoBlast(item) {
}

function getMultiAttack(item) {
switch (item) {
case 'Bug Memory':
return 'Bug';
case 'Dark Memory':
return 'Dark';
case 'Dragon Memory':
return 'Dragon';
case 'Electric Memory':
return 'Electric';
case 'Fairy Memory':
return 'Fairy';
case 'Fighting Memory':
return 'Fighting';
case 'Fire Memory':
return 'Fire';
case 'Flying Memory':
return 'Flying';
case 'Ghost Memory':
return 'Ghost';
case 'Grass Memory':
return 'Grass';
case 'Ground Memory':
return 'Ground';
case 'Ice Memory':
return 'Ice';
case 'Poison Memory':
return 'Poison';
case 'Psychic Memory':
return 'Psychic';
case 'Rock Memory':
return 'Rock';
case 'Steel Memory':
return 'Steel';
case 'Water Memory':
return 'Water';
default:
return '';
if (item.indexOf("Memory") !== -1) {
return item.substring(0, item.indexOf(" "));
}
return '';
}

18 changes: 12 additions & 6 deletions js/data/move_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,8 @@ var MOVES_ADV = $.extend(true, {}, MOVES_GSC, {
'Overheat': {
bp: 140,
type: 'Fire',
category: 'Special'
category: 'Special',
dropsStats: 2
},
'Poison Fang': {
bp: 50,
Expand All @@ -1107,7 +1108,8 @@ var MOVES_ADV = $.extend(true, {}, MOVES_GSC, {
'Psycho Boost': {
bp: 140,
type: 'Psychic',
category: 'Special'
category: 'Special',
dropsStats: 2
},
'Recycle': {
bp: 0,
Expand Down Expand Up @@ -1194,7 +1196,8 @@ var MOVES_ADV = $.extend(true, {}, MOVES_GSC, {
bp: 120,
type: 'Fighting',
category: 'Physical',
makesContact: true
makesContact: true,
dropsStats: 1
},
'Tail Glow': {
bp: 0,
Expand Down Expand Up @@ -1400,7 +1403,8 @@ var MOVES_DPP = $.extend(true, {}, MOVES_ADV, {
'Draco Meteor': {
bp: 140,
type: 'Dragon',
category: 'Special'
category: 'Special',
dropsStats: 2
},
'Dragon Pulse': {
bp: 90,
Expand Down Expand Up @@ -1577,7 +1581,8 @@ var MOVES_DPP = $.extend(true, {}, MOVES_ADV, {
'Leaf Storm': {
bp: 140,
type: 'Grass',
category: 'Special'
category: 'Special',
dropsStats : 2
},
'Lunar Dance': {
bp: 0,
Expand Down Expand Up @@ -2901,7 +2906,8 @@ var MOVES_SM = $.extend(true, {}, MOVES_XY, {
type: 'Fairy',
category: 'Special',
hasSecondaryEffect: true,
zp: 195
zp: 195,
dropsStats: 2
},
'Fling': {zp: 100},
'Fly': {zp: 175},
Expand Down
Loading

2 comments on commit 2ec87f8

@AustinXII
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol i just realized you never added the damage calculation for past gens >_<

@scheibo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this needs to be backported to Gen 3 and 4 only - unless I'm mistaken there are no moves which drop offensive stats before Super Power was introduced in Gen 3

Please sign in to comment.