From 51f51acc0849459d09053334380152022bf1673a Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Thu, 11 May 2023 23:03:05 -0400 Subject: [PATCH] Minor changes for double battles --- src/battle-phases.ts | 27 +++++++++++++++++++++------ src/modifier/modifier.ts | 8 +++++--- src/pokemon.ts | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/battle-phases.ts b/src/battle-phases.ts index 18b5b692ce7..8774eb76a6f 100644 --- a/src/battle-phases.ts +++ b/src/battle-phases.ts @@ -193,10 +193,10 @@ export class EncounterPhase extends BattlePhase { const battle = this.scene.currentBattle; - battle.enemyLevels.forEach((_, e) => { - const enemySpecies = this.scene.randomSpecies(battle.waveIndex, battle.enemyLevels[e], true); + battle.enemyLevels.forEach((level, e) => { + const enemySpecies = this.scene.randomSpecies(battle.waveIndex, level, true); if (!this.loaded) - battle.enemyField[e] = new EnemyPokemon(this.scene, enemySpecies, battle.enemyLevels[e]); + battle.enemyField[e] = new EnemyPokemon(this.scene, enemySpecies, level); const enemyPokemon = this.scene.getEnemyField()[e]; enemyPokemon.resetSummonData(); @@ -208,11 +208,16 @@ export class EncounterPhase extends BattlePhase { }); Promise.all(loadEnemyAssets).then(() => { - battle.enemyField.forEach(enemyPokemon => { + battle.enemyField.forEach((enemyPokemon, e) => { this.scene.field.add(enemyPokemon); if (this.scene.getPlayerPokemon().visible) this.scene.field.moveBelow(enemyPokemon, this.scene.getPlayerPokemon()); enemyPokemon.tint(0, 0.5); + if (battle.enemyField.length > 1) { + enemyPokemon.x += 32 * (e ? 1 : -1); + if (!e) + enemyPokemon.y += 8 * (e ? 1 : -1); + } }); if (!this.loaded) { @@ -239,7 +244,7 @@ export class EncounterPhase extends BattlePhase { const enemyField = this.scene.getEnemyField(); this.scene.tweens.add({ targets: [ this.scene.arenaEnemy, enemyField, this.scene.arenaPlayer, this.scene.trainer ].flat(), - x: (_target, _key, value, fieldIndex: integer) => fieldIndex < 2 ? value + 300 : value - 300, + x: (_target, _key, value, fieldIndex: integer) => fieldIndex < 1 + (enemyField.length) ? value + 300 : value - 300, duration: 2000, onComplete: () => { enemyField.forEach(enemyPokemon => { @@ -463,6 +468,16 @@ export class SummonPhase extends PartyMemberPokemonPhase { const playerPokemon = this.getPokemon(); + if (this.fieldIndex === 1) { + this.scene.tweens.add({ + targets: this.scene.getPlayerField(), + ease: 'Sine.easeOut', + duration: 250, + x: (_target, _key, value: number, fieldIndex: integer) => value + 32 * (fieldIndex ? 1 : -1), + y: (_target, _key, value: number, fieldIndex: integer) => value + 8 * (fieldIndex ? 1 : -1) + }); + } + pokeball.setVisible(true); this.scene.tweens.add({ targets: pokeball, @@ -1196,7 +1211,7 @@ abstract class MoveEffectPhase extends PokemonPhase { if (target.hp) applyPostDefendAbAttrs(PostDefendAbAttr, target, user, this.move, result); if (this.move.getMove().hasFlag(MoveFlags.MAKES_CONTACT)) - this.scene.applyModifiers(ContactHeldItemTransferChanceModifier, this.player, user); + this.scene.applyModifiers(ContactHeldItemTransferChanceModifier, this.player, user, target.getFieldIndex()); } } this.end(); diff --git a/src/modifier/modifier.ts b/src/modifier/modifier.ts index 80bc4b4c6a7..eefa53e139e 100644 --- a/src/modifier/modifier.ts +++ b/src/modifier/modifier.ts @@ -480,7 +480,8 @@ export class TurnHealModifier extends PokemonHeldItemModifier { if (pokemon.getHpRatio() < 1) { const scene = pokemon.scene; - scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.isPlayer(), Math.max(Math.floor(pokemon.getMaxHp() / 16) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true)); + scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.isPlayer(), pokemon.getFieldIndex(), + Math.max(Math.floor(pokemon.getMaxHp() / 16) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true)); } return true; @@ -509,7 +510,8 @@ export class HitHealModifier extends PokemonHeldItemModifier { if (pokemon.turnData.damageDealt && pokemon.getHpRatio() < 1) { const scene = pokemon.scene; - scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.isPlayer(), Math.max(Math.floor(pokemon.turnData.damageDealt / 8) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true)); + scene.unshiftPhase(new PokemonHealPhase(scene, pokemon.isPlayer(), pokemon.getFieldIndex(), + Math.max(Math.floor(pokemon.turnData.damageDealt / 8) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true)); } return true; @@ -1001,7 +1003,7 @@ export abstract class HeldItemTransferModifier extends PokemonHeldItemModifier { apply(args: any[]): boolean { const pokemon = args[0] as Pokemon; - const targetPokemon = pokemon.getOpponent(); + const targetPokemon = pokemon.getOpponent(args.length > 1 ? args[1] as integer : !pokemon.scene.currentBattle.double ? 0 : Utils.randInt(2)); if (!targetPokemon) return false; diff --git a/src/pokemon.ts b/src/pokemon.ts index 4ee2dea4c5b..1c8f891707e 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -21,7 +21,7 @@ import { BattlerTag, BattlerTagLapseType, BattlerTagType, TypeBoostTag, getBattl import { Species } from './data/species'; import { WeatherType } from './data/weather'; import { TempBattleStat } from './data/temp-battle-stat'; -import { ArenaTagType, GravityTag, WeakenMoveTypeTag } from './data/arena-tag'; +import { ArenaTagType, WeakenMoveTypeTag } from './data/arena-tag'; import { Biome } from './data/biome'; import { Abilities, Ability, BattleStatMultiplierAbAttr, BlockCritAbAttr, PreApplyBattlerTagAbAttr, StatusEffectImmunityAbAttr, TypeImmunityAbAttr, VariableMovePowerAbAttr, abilities, applyBattleStatMultiplierAbAttrs, applyPreApplyBattlerTagAbAttrs, applyPreAttackAbAttrs, applyPreDefendAbAttrs, applyPreSetStatusAbAttrs } from './data/ability'; import PokemonData from './system/pokemon-data';