Minor changes for double battles

This commit is contained in:
Flashfyre 2023-05-11 23:03:05 -04:00
parent c123119d48
commit 51f51acc08
3 changed files with 27 additions and 10 deletions

View File

@ -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();

View File

@ -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;

View File

@ -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';