From 58b000ae060011f01a438799e35858bc82794894 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 14 Feb 2024 23:25:12 -0500 Subject: [PATCH] Make G-Max Pokemon larger scaled --- src/battle-phases.ts | 7 ++++++- src/battle-scene.ts | 10 ++++++++++ src/pokemon.ts | 5 +++-- src/ui/battle-info.ts | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 66b60a155..7e11e625e 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -543,6 +543,7 @@ export class EncounterPhase extends BattlePhase { if (enemyPokemon.isShiny()) this.scene.validateAchv(achvs.SEE_SHINY); }); + this.scene.updateFieldScale(); if (showEncounterMessage) this.scene.ui.showText(this.getEncounterMessage(), null, () => this.end(), 1500); else @@ -945,6 +946,7 @@ export class SummonPhase extends PartyMemberPokemonPhase { } addPokeballOpenParticles(this.scene, pokemon.x, pokemon.y - 16, pokemon.pokeball); this.scene.updateModifiers(this.player); + this.scene.updateFieldScale(); pokemon.showInfo(); pokemon.playAnim(); pokemon.setVisible(true); @@ -952,11 +954,12 @@ export class SummonPhase extends PartyMemberPokemonPhase { pokemon.setScale(0.5); pokemon.tint(getPokeballTintColor(pokemon.pokeball)); pokemon.untint(250, 'Sine.easeIn'); + this.scene.updateFieldScale(); this.scene.tweens.add({ targets: pokemon, duration: 250, ease: 'Sine.easeIn', - scale: 1, + scale: pokemon.getSpriteScale(), onComplete: () => { pokemon.cry(); pokemon.getSprite().clearTint(); @@ -1100,6 +1103,8 @@ export class ReturnPhase extends SwitchSummonPhase { pokemon.resetTurnData(); pokemon.resetSummonData(); + this.scene.updateFieldScale(); + this.scene.triggerPokemonFormChange(pokemon, SpeciesFormChangeActiveTrigger); } } diff --git a/src/battle-scene.ts b/src/battle-scene.ts index 87c583fb1..c16aaf9d5 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -884,6 +884,16 @@ export default class BattleScene extends Phaser.Scene { return this.arena; } + updateFieldScale(): Promise { + return new Promise(resolve => { + const fieldScale = Math.floor(Math.pow(1 / this.getField().filter(p => p?.isActive()) + .map(p => p.getSpriteScale()) + .reduce((highestScale: number, scale: number) => highestScale = Math.max(scale, highestScale), 0), 0.7) * 40 + ) / 40; + this.setFieldScale(fieldScale).then(() => resolve()); + }); + } + setFieldScale(scale: number, instant: boolean = false): Promise { return new Promise(resolve => { scale *= 6; diff --git a/src/pokemon.ts b/src/pokemon.ts index 1aa3147d8..9edc208de 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -400,7 +400,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } getSpriteScale(): number { - if (this.species.speciesId === Species.ETERNATUS && this.formIndex) + const formKey = this.getFormKey(); + if (formKey.indexOf(SpeciesFormKey.GIGANTAMAX) > -1 || formKey.indexOf(SpeciesFormKey.ETERNAMAX) > -1) return 1.5; return 1; } @@ -1266,7 +1267,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.loadAssets().then(() => { this.calculateStats(); this.scene.updateModifiers(this.isPlayer(), true); - this.updateInfo().then(() => resolve()); + Promise.all([ this.updateInfo(), this.scene.updateFieldScale() ]).then(() => resolve()); }); }); } diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index 34de92bb9..04c8705ee 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -324,7 +324,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container { let nameSizeTest = addTextObject(this.scene, 0, 0, displayName, TextStyle.BATTLE_INFO); nameTextWidth = nameSizeTest.displayWidth; - while (nameTextWidth > 60 - ((pokemon.gender !== Gender.GENDERLESS ? 6 : 0) + (pokemon.fusionSpecies ? 6 : 0) + (pokemon.isShiny() ? 8 : 0) + (Math.min(pokemon.level.toString().length, 3) - 3) * 8)) { + while (nameTextWidth > (this.player || !this.boss ? 60 : 98) - ((pokemon.gender !== Gender.GENDERLESS ? 6 : 0) + (pokemon.fusionSpecies ? 6 : 0) + (pokemon.isShiny() ? 8 : 0) + (Math.min(pokemon.level.toString().length, 3) - 3) * 8)) { displayName = `${displayName.slice(0, displayName.endsWith('.') ? -2 : -1).trimEnd()}.`; nameSizeTest.setText(displayName); nameTextWidth = nameSizeTest.displayWidth;