From cfe9e9885ca7f1eccf726c8e64f687718b72dbe2 Mon Sep 17 00:00:00 2001 From: Marek Sison Date: Mon, 6 May 2024 19:02:29 +0800 Subject: [PATCH 1/4] HOTFIX: changed StockpileDamageAttr to StockpilePowerAttr --- src/data/move.ts | 98 +++++++++++++++++++++++++----------------------- 1 file changed, 51 insertions(+), 47 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 1957aa931b6..7d2425cd566 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -647,50 +647,6 @@ export class RandomLevelDamageAttr extends FixedDamageAttr { return Math.max(Math.floor(user.level * (user.randSeedIntRange(50, 150) * 0.01)), 1); } } -export class StockpileDamageAttr extends FixedDamageAttr { - constructor() { - super(0); - } - - getDamage(user: Pokemon, target: Pokemon, move: Move): integer { - let ret = super.getTargetBenefitScore(user, target, move); - - let attackScore = 0; - - const effectiveness = target.getAttackTypeEffectiveness(Type.NORMAL); - attackScore = Math.pow(effectiveness - 1, 2) * effectiveness < 1 ? -2 : 2; - if (attackScore) { - const spAtk = new Utils.IntegerHolder(user.getBattleStat(Stat.SPATK, target)); - applyMoveAttrs(VariableAtkAttr, user, target, move, spAtk); - if (spAtk.value > user.getBattleStat(Stat.ATK, target)) { - const statRatio = user.getBattleStat(Stat.ATK, target) / spAtk.value; - if (statRatio <= 0.75) - attackScore *= 2; - else if (statRatio <= 0.875) - attackScore *= 1.5; - } - - const power = new Utils.NumberHolder(this.getPower(user, target, move)); - applyMoveAttrs(VariablePowerAttr, user, target, move, power); - - attackScore += Math.floor(power.value / 5); - } - - return attackScore; - } - - getPower(user: Pokemon, target: Pokemon, move: Move): number { - if (!!user.getTag(BattlerTagType.STOCKPILE_THREE)){ - return 300; - } else if (!!user.getTag(BattlerTagType.STOCKPILE_TWO)){ - return 200; - } else if (!!user.getTag(BattlerTagType.STOCKPILE_ONE)){ - return 100; - } else { - return 0; - } - } -} export class ModifiedDamageAttr extends MoveAttr { apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { @@ -1620,6 +1576,31 @@ export class GrowthStatChangeAttr extends StatChangeAttr { } } +export class StockpileStatChangeAttr extends StatChangeAttr { + constructor(move: string = "Stockpile") { + let l = 1; + + if (move === "Spit-Up" || move === "Swallow"){ + l = -1; + } + + super([ BattleStat.ATK, BattleStat.SPATK ], l, true); + } + + // apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise { + // if (!super.apply(user, target, move, args) || (this.condition && !this.condition(user, target, move))) + // return false; + + // if (move.chance < 0 || move.chance === 100 || user.randSeedInt(100) < move.chance) { + // const levels = this.getLevels(user); + // user.scene.unshiftPhase(new StatChangePhase(user.scene, (this.selfTarget ? user : target).getBattlerIndex(), this.selfTarget, this.stats, levels, this.showMessage)); + // return true; + // } + + // return false; + // } +} + export class HalfHpStatMaxAttr extends StatChangeAttr { constructor(stat: BattleStat) { super(stat, 12, true, null, false); @@ -2151,6 +2132,28 @@ export class WaterShurikenPowerAttr extends VariablePowerAttr { } } +export class StockpilePowerAttr extends VariablePowerAttr { + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + const power = args[0] as Utils.NumberHolder; + + power.value = this.getPower(user, target, move); + + return true; + } + + getPower(user: Pokemon, target: Pokemon, move: Move): number { + if (!!user.getTag(BattlerTagType.STOCKPILE_THREE)){ + return 300; + } else if (!!user.getTag(BattlerTagType.STOCKPILE_TWO)){ + return 200; + } else if (!!user.getTag(BattlerTagType.STOCKPILE_ONE)){ + return 100; + } else { + return 0; + } + } +} + export class VariableAtkAttr extends MoveAttr { constructor() { super(); @@ -4779,14 +4782,15 @@ export function initMoves() { .attr(StockpileOneAttr) .attr(StockpileTwoAttr) .attr(StockpileThreeAttr) - .attr(StatChangeAttr, [ BattleStat.DEF, BattleStat.SPDEF ], 1, true) + .attr(StockpileStatChangeAttr, 'Stockpile') .partial(), new AttackMove(Moves.SPIT_UP, Type.NORMAL, MoveCategory.SPECIAL, -1, 100, 10, -1, 0, 3) - .attr(StockpileDamageAttr) - .attr(StatChangeAttr, [ BattleStat.DEF, BattleStat.SPDEF ], -1, true) + .attr(StockpilePowerAttr) + .attr(StockpileStatChangeAttr, 'Spit-Up') .partial(), new SelfStatusMove(Moves.SWALLOW, Type.NORMAL, -1, 10, -1, 0, 3) .triageMove() + .attr(StockpileStatChangeAttr, 'Swallow') .unimplemented(), // mareksison/redmaverick616 ends working here new AttackMove(Moves.HEAT_WAVE, Type.FIRE, MoveCategory.SPECIAL, 95, 90, 10, 10, 0, 3) From bc2d232edb793e17b16211576f041bcece8fb94d Mon Sep 17 00:00:00 2001 From: Marek Sison Date: Mon, 6 May 2024 23:35:55 +0800 Subject: [PATCH 2/4] FEAT: Swallow implemented. Marked partial for testing --- src/data/move.ts | 76 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 15 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 7d2425cd566..4ab5d83b232 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -809,12 +809,43 @@ export class HealAttr extends MoveEffectAttr { Math.max(Math.floor(target.getMaxHp() * healRatio), 1), getPokemonMessage(target, ' regained\nhealth!'), true, !this.showAnim)); } + getHealRatio(h: number = -1){ + if (h > 0) + this.healRatio = h; + + return this.healRatio; + } + getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer { let score = ((1 - (this.selfTarget ? user : target).getHpRatio()) * 20) - this.healRatio * 10; return Math.round(score / (1 - this.healRatio / 2)); } } +export class StockpileHealAttr extends HealAttr { + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean { + const s = this.getStockpiles(user); + + this.getHealRatio(s > 2 ? 1 : (s * 0.25)); + + super.apply(user, target, move, args); + return true; + } + + getStockpiles(user: Pokemon): integer { + let s = 0; + const stock = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE]; + + for (let x = 0 ; x < stock.length ; x++){ + if (user.getTag(stock[x])){ + s++; + } + } + + return s; + } +} + export class SacrificialFullRestoreAttr extends SacrificialAttr { constructor() { super(); @@ -1587,18 +1618,26 @@ export class StockpileStatChangeAttr extends StatChangeAttr { super([ BattleStat.ATK, BattleStat.SPATK ], l, true); } - // apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise { - // if (!super.apply(user, target, move, args) || (this.condition && !this.condition(user, target, move))) - // return false; + apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean | Promise { + if (!super.apply(user, target, move, args)) + return false; + + this.levels = this.levels < 0 ? (this.getStockpiles(user) * -1) : 1; + return true; + } - // if (move.chance < 0 || move.chance === 100 || user.randSeedInt(100) < move.chance) { - // const levels = this.getLevels(user); - // user.scene.unshiftPhase(new StatChangePhase(user.scene, (this.selfTarget ? user : target).getBattlerIndex(), this.selfTarget, this.stats, levels, this.showMessage)); - // return true; - // } + getStockpiles(user: Pokemon): integer { + let s = 0; + const stock = [BattlerTagType.STOCKPILE_ONE, BattlerTagType.STOCKPILE_TWO, BattlerTagType.STOCKPILE_THREE]; - // return false; - // } + for (let x = 0 ; x < stock.length ; x++){ + if (user.getTag(stock[x])){ + s++; + } + } + + return s; + } } export class HalfHpStatMaxAttr extends StatChangeAttr { @@ -4774,10 +4813,6 @@ export function initMoves() { .target(MoveTarget.RANDOM_NEAR_ENEMY) .partial(), // mareksison/redmaverick616 starts working here - /** - * need to find a way to remove stat changes when stockpile is used - * need to find a way to remove stockpile when the relevant moves are used - */ new SelfStatusMove(Moves.STOCKPILE, Type.NORMAL, -1, 20, -1, 0, 3) .attr(StockpileOneAttr) .attr(StockpileTwoAttr) @@ -4787,11 +4822,22 @@ export function initMoves() { new AttackMove(Moves.SPIT_UP, Type.NORMAL, MoveCategory.SPECIAL, -1, 100, 10, -1, 0, 3) .attr(StockpilePowerAttr) .attr(StockpileStatChangeAttr, 'Spit-Up') + .attr(RemoveBattlerTagAttr, [ + BattlerTagType.STOCKPILE_ONE, + BattlerTagType.STOCKPILE_TWO, + BattlerTagType.STOCKPILE_THREE, + ], true) .partial(), new SelfStatusMove(Moves.SWALLOW, Type.NORMAL, -1, 10, -1, 0, 3) .triageMove() + .attr(StockpileHealAttr, 1) .attr(StockpileStatChangeAttr, 'Swallow') - .unimplemented(), + .attr(RemoveBattlerTagAttr, [ + BattlerTagType.STOCKPILE_ONE, + BattlerTagType.STOCKPILE_TWO, + BattlerTagType.STOCKPILE_THREE, + ], true) + .partial(), // mareksison/redmaverick616 ends working here new AttackMove(Moves.HEAT_WAVE, Type.FIRE, MoveCategory.SPECIAL, 95, 90, 10, 10, 0, 3) .attr(HealStatusEffectAttr, true, StatusEffect.FREEZE) From 37507322ec13cf5cba7dd108cc0e84bc8d7d975e Mon Sep 17 00:00:00 2001 From: Marek Sison Date: Mon, 6 May 2024 23:37:31 +0800 Subject: [PATCH 3/4] HOTFIX: removed stockpile from the pokemon class --- src/field/pokemon.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 5199811002f..36dc4265efc 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -81,7 +81,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { public luck: integer; public pauseEvolutions: boolean; public pokerus: boolean; - public stockpile: integer; public fusionSpecies: PokemonSpecies; public fusionFormIndex: integer; From 4653c2d33e36d77b90d9d0047b056bfddf43ba8b Mon Sep 17 00:00:00 2001 From: Marek Sison Date: Mon, 6 May 2024 23:38:13 +0800 Subject: [PATCH 4/4] HOTFIX: removed marking comments --- src/data/move.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 4ab5d83b232..a841faf6854 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -4812,7 +4812,6 @@ export function initMoves() { .soundBased() .target(MoveTarget.RANDOM_NEAR_ENEMY) .partial(), - // mareksison/redmaverick616 starts working here new SelfStatusMove(Moves.STOCKPILE, Type.NORMAL, -1, 20, -1, 0, 3) .attr(StockpileOneAttr) .attr(StockpileTwoAttr) @@ -4838,7 +4837,6 @@ export function initMoves() { BattlerTagType.STOCKPILE_THREE, ], true) .partial(), - // mareksison/redmaverick616 ends working here new AttackMove(Moves.HEAT_WAVE, Type.FIRE, MoveCategory.SPECIAL, 95, 90, 10, 10, 0, 3) .attr(HealStatusEffectAttr, true, StatusEffect.FREEZE) .attr(StatusEffectAttr, StatusEffect.BURN)