From 40e69789c877d70b083ab38a2d4299e307e3ea81 Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Sun, 7 May 2023 17:05:19 -0400 Subject: [PATCH] Add run logic and forest background --- public/images/arenas/forest_a.png | Bin 651 -> 1534 bytes public/images/arenas/forest_b.png | Bin 1370 -> 2798 bytes public/images/arenas/forest_bg.png | Bin 633 -> 642 bytes src/battle-phases.ts | 48 ++++++++++++++++++++++++++--- src/battle-scene.ts | 4 +-- src/battle.ts | 1 + 6 files changed, 47 insertions(+), 6 deletions(-) diff --git a/public/images/arenas/forest_a.png b/public/images/arenas/forest_a.png index 707c151dc389b34981d62de0ec96ee8d8687c903..a19c6568caab765bf9da5d257acba60d3c6928b9 100644 GIT binary patch delta 1383 zcmV-t1(^Da1^x?=BYyw^b5ch_0Itp)=>Px#1ZP1_K>z@;j|==^1pojAj!8s8RCr$P z+iQyzbsWI)F|}Q<6`HAG+Y&+;K8Zj<3L)rO4-eervbVwhoFfA!1&PJDP`J`R%;lhvz^;~yL^Kg+gL;HF>CTrSR?{Gsn>pYa%E z{+zeXFv}0RZ@t92;<>p$OR;WPN)E<8xz-a;O|=^~ zYW?PalmHI1oo+IEVX^xG%WX{^jQL0U)u(5B{@%StdZ8J=f2N4xg{ce0PsO?FopwtV zre5(2bASC?T>NJGq2=@Qs4qKgq;efQ_HXSO{cigJD``y~jCp!`?Z-dM>1GHsd~MOI z>leToR#*;eGJq*Um=Qeo{;|0u zZyhP$?`O~ee};(QcXz)n#y5|Z(`}kz>lL-w=lY%0Zu8FGy}w|aIRXp&Ufp z_czMdvF@fpV%tUl8AWUQE^z!Y$B1T__=WoQzClG;()Oum=O3>Y2a0zNzg_*LqgQ0M zPL7vh%14aAn(Et15xiWc--s>ei~ZPld;NmPrn9%Jf4N}wThk-J5D|*_#YnAbF{i@K zIG+0QR5AVh@6}XM?7I3wxxJL@IDO`H`P}c6Ib`74MwRvWHGke~xfJun&ogu{R{MAB zPG{6PeeHTN_vUlu>p>a)F{;+gL3!l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0E6qrn&%rg3AzXzymao8QxIq0gmav0Vh@;Z zE$puLd(1Z7z3!9j^{1cbGBkz#k8hA+WZA?ba6-sI!JDB`2c2{5>A!E9G80l5nIiR^ z88+#_Rn1{yjucavpxWRt?Rr9k4!6LGA`YgMNFbMiDUyjJg%cu2h|~M|?Nd7kg_BHR zM--{rO-Kb=#peh%5yeeXvyY$CGyuCK**0Gnt_MXCHqP}#MvzONTInd9hFSx4sj~oB z#DA@2$7e25@nR^{%?*5_(Oi~P { this.scene.arenaEnemy.setX(this.scene.arenaNextEnemy.x); + this.scene.arenaEnemy.setAlpha(1); this.scene.arenaNextEnemy.setX(this.scene.arenaNextEnemy.x - 300); enemyPokemon.untint(100, 'Sine.easeOut'); enemyPokemon.cry(); @@ -326,6 +327,7 @@ export class SwitchBiomePhase extends BattlePhase { this.scene.arenaPlayer.setTexture(playerTexture); this.scene.arenaPlayer.setAlpha(1); this.scene.arenaEnemy.setTexture(enemyTexture); + this.scene.arenaEnemy.setAlpha(1); this.scene.arenaNextEnemy.setTexture(enemyTexture); this.scene.arenaBgTransition.setVisible(false); this.scene.arenaPlayerTransition.setVisible(false); @@ -632,9 +634,8 @@ export class CommandPhase extends FieldPhase { break; case Command.BALL: case Command.POKEMON: - return false; case Command.RUN: - return true; + return false; } return this.isPlayerDelayed(); @@ -695,6 +696,8 @@ export class CommandPhase extends FieldPhase { }, null, true); break; case Command.RUN: + this.scene.unshiftPhase(new AttemptRunPhase(this.scene)); + success = true; //this.scene.unshiftPhase(new MoveAnimTestPhase(this.scene)); //success = true; break; @@ -1420,19 +1423,21 @@ export class MessagePhase extends BattlePhase { private text: string; private callbackDelay: integer; private prompt: boolean; + private promptDelay: integer; - constructor(scene: BattleScene, text: string, callbackDelay?: integer, prompt?: boolean) { + constructor(scene: BattleScene, text: string, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer) { super(scene); this.text = text; this.callbackDelay = callbackDelay; this.prompt = prompt; + this.promptDelay = promptDelay; } start() { super.start(); - this.scene.ui.showText(this.text, null, () => this.end(), this.callbackDelay || (this.prompt ? 0 : 1500), this.prompt); + this.scene.ui.showText(this.text, null, () => this.end(), this.callbackDelay || (this.prompt ? 0 : 1500), this.prompt, this.promptDelay); } end() { @@ -2102,6 +2107,41 @@ export class AttemptCapturePhase extends BattlePhase { } } +export class AttemptRunPhase extends BattlePhase { + constructor(scene: BattleScene) { + super(scene); + } + + start() { + super.start(); + + const playerPokemon = this.scene.getPlayerPokemon(); + const enemyPokemon = this.scene.getEnemyPokemon(); + + const escapeChance = (((playerPokemon.stats[Stat.SPD] * 128) / enemyPokemon.stats[Stat.SPD]) + (30 * this.scene.currentBattle.escapeAttempts++)) % 256; + + if (Utils.randInt(256) < escapeChance) { + this.scene.sound.play('flee'); + this.scene.queueMessage('You got away safely!', null, true, 500); + + this.scene.tweens.add({ + targets: [ this.scene.arenaEnemy, enemyPokemon ], + alpha: 0, + duration: 250, + ease: 'Sine.easeIn' + }); + + enemyPokemon.hp = 0; + + this.scene.pushPhase(new BattleEndPhase(this.scene)); + this.scene.newBattle(); + } else + this.scene.queueMessage('You can\'t escape!', null, true); + + this.end(); + } +} + export class SelectModifierPhase extends BattlePhase { constructor(scene: BattleScene) { super(scene); diff --git a/src/battle-scene.ts b/src/battle-scene.ts index ecfe9082d..d093c2638 100644 --- a/src/battle-scene.ts +++ b/src/battle-scene.ts @@ -689,8 +689,8 @@ export default class BattleScene extends Phaser.Scene { this.currentPhase.start(); } - queueMessage(message: string, callbackDelay?: integer, prompt?: boolean) { - this.unshiftPhase(new MessagePhase(this, message, callbackDelay, prompt)); + queueMessage(message: string, callbackDelay?: integer, prompt?: boolean, promptDelay?: integer) { + this.unshiftPhase(new MessagePhase(this, message, callbackDelay, prompt, promptDelay)); } populatePhaseQueue(): void { diff --git a/src/battle.ts b/src/battle.ts index c56f7d752..474b7a249 100644 --- a/src/battle.ts +++ b/src/battle.ts @@ -7,6 +7,7 @@ export class Battle { public enemyPokemon: EnemyPokemon; public turn: integer; public playerParticipantIds: Set = new Set(); + public escapeAttempts: integer = 0; constructor(waveIndex: integer) { this.waveIndex = waveIndex;