Some Fixes

- HP ratio related checks (`getHpRatio`): Added rounding to 2 decimals for non-precise option.

- Hustle (`BattleStatMultiplierAbAttr`): added optional condition; Hustle now works only for physical attacks.

- Imposter (`PostSummonTransformAbAttr`): Switch in a double battle after both foes have been defeated no longer crashes the game.

- Sleep Talk (`RandomMovesetMoveAttr`): Single target moves no longer target allies.
This commit is contained in:
NxKarim 2024-04-30 01:33:18 -06:00
parent bd30dca47d
commit 3a892acaaf
4 changed files with 37 additions and 15 deletions

View File

@ -976,16 +976,19 @@ export class FieldMoveTypePowerBoostAbAttr extends FieldMovePowerBoostAbAttr {
export class BattleStatMultiplierAbAttr extends AbAttr {
private battleStat: BattleStat;
private multiplier: number;
private condition: PokemonAttackCondition;
constructor(battleStat: BattleStat, multiplier: number) {
constructor(battleStat: BattleStat, multiplier: number, condition?: PokemonAttackCondition) {
super(false);
this.battleStat = battleStat;
this.multiplier = multiplier;
this.condition = condition;
}
applyBattleStat(pokemon: Pokemon, passive: boolean, battleStat: BattleStat, statValue: Utils.NumberHolder, args: any[]): boolean | Promise<boolean> {
if (battleStat === this.battleStat) {
const move = (args[0] as Move);
if (battleStat === this.battleStat && (!this.condition || this.condition(pokemon, null, move))){
statValue.value *= this.multiplier;
return true;
}
@ -1428,10 +1431,17 @@ export class PostSummonTransformAbAttr extends PostSummonAbAttr {
applyPostSummon(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
const targets = pokemon.getOpponents();
let target: Pokemon;
if (targets.length > 1)
pokemon.scene.executeWithSeedOffset(() => target = Utils.randSeedItem(targets), pokemon.scene.currentBattle.waveIndex);
else
target = targets[0];
if(targets.length < 1){
return false;
}
if (targets.length > 1){
pokemon.scene.executeWithSeedOffset(() => target = Utils.randSeedItem(targets), pokemon.scene.currentBattle.waveIndex);
}
else{
target = targets[0];
}
pokemon.summonData.speciesForm = target.getSpeciesForm();
pokemon.summonData.fusionSpeciesForm = target.getFusionSpeciesForm();
@ -2642,8 +2652,8 @@ export function initAbilities() {
new Ability(Abilities.TRUANT, 3)
.attr(PostSummonAddBattlerTagAbAttr, BattlerTagType.TRUANT, 1, false),
new Ability(Abilities.HUSTLE, 3)
.attr(BattleStatMultiplierAbAttr, BattleStat.ATK, 1.5)
.attr(BattleStatMultiplierAbAttr, BattleStat.ACC, 0.8),
.attr(BattleStatMultiplierAbAttr, BattleStat.ATK, 1.5, (user, target, move) => move.category == MoveCategory.PHYSICAL)
.attr(BattleStatMultiplierAbAttr, BattleStat.ACC, 0.8, (user, target, move) => move.category == MoveCategory.PHYSICAL),
new Ability(Abilities.CUTE_CHARM, 3)
.attr(PostDefendContactApplyTagChanceAbAttr, 30, BattlerTagType.INFATUATED),
new Ability(Abilities.PLUS, 3)

View File

@ -3099,11 +3099,23 @@ export class RandomMovesetMoveAttr extends OverrideMoveEffectAttr {
const moveTargets = getMoveTargets(user, move.moveId);
if (!moveTargets.targets.length)
return false;
const targets = moveTargets.multiple || moveTargets.targets.length === 1
? moveTargets.targets
: moveTargets.targets.indexOf(target.getBattlerIndex()) > -1
? [ target.getBattlerIndex() ]
: [ moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ];
let selectTargets;
switch(true){
case (moveTargets.multiple || moveTargets.targets.length === 1): {
selectTargets = moveTargets.targets;
break;
}
case (moveTargets.targets.indexOf(target.getBattlerIndex()) > -1): {
selectTargets = [ target.getBattlerIndex() ];
break;
}
default: {
moveTargets.targets.splice(moveTargets.targets.indexOf(user.getAlly().getBattlerIndex()))
selectTargets = [ moveTargets.targets[user.randSeedInt(moveTargets.targets.length)] ];
break;
}
}
const targets = selectTargets;
user.getMoveQueue().push({ move: move.moveId, targets: targets, ignorePP: true });
user.scene.unshiftPhase(new MovePhase(user.scene, user, targets, moveset[moveIndex], true));
return true;

View File

@ -657,7 +657,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
getHpRatio(precise: boolean = false): number {
return precise
? this.hp / this.getMaxHp()
: ((this.hp / this.getMaxHp()) * 100) / 100;
: Math.round((this.hp / this.getMaxHp()) * 100) / 100;
}
generateGender(): void {

View File

@ -2547,7 +2547,7 @@ export class MoveEffectPhase extends PokemonPhase {
: 3 / (3 + Math.min(targetEvasionLevel.value - userAccuracyLevel.value, 6));
}
applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, user, BattleStat.ACC, accuracyMultiplier);
applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, user, BattleStat.ACC, accuracyMultiplier, this.move.getMove());
const evasionMultiplier = new Utils.NumberHolder(1);
applyBattleStatMultiplierAbAttrs(BattleStatMultiplierAbAttr, this.getTarget(), BattleStat.EVA, evasionMultiplier);