Skip to content

Commit

Permalink
Merge branch 'beta' into formChangeLocale
Browse files Browse the repository at this point in the history
  • Loading branch information
Adri1 authored Sep 22, 2024
2 parents a862088 + 1c87532 commit cb8cf9c
Show file tree
Hide file tree
Showing 81 changed files with 784 additions and 313 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "berry_bush.png",
"image": "berries_abound_bush.png",
"format": "RGBA8888",
"size": {
"w": 49,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "mad_scientist_m.png",
"image": "dark_deal_scientist.png",
"format": "RGBA8888",
"size": {
"w": 46,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "b2w2_lady.png",
"image": "department_store_sale_lady.png",
"format": "RGBA8888",
"size": {
"w": 399,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "teacher.png",
"image": "field_trip_teacher.png",
"format": "RGBA8888",
"size": {
"w": 43,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "carnival_game.png",
"image": "fun_and_games_game.png",
"format": "RGBA8888",
"size": {
"w": 38,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "carnival_man.png",
"image": "fun_and_games_man.png",
"format": "RGBA8888",
"size": {
"w": 50,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "carnival_wobbuffet.png",
"image": "fun_and_games_wobbuffet.png",
"format": "RGBA8888",
"size": {
"w": 45,
Expand Down
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "chest_blue.png",
"image": "mysterious_chest_blue.png",
"format": "RGBA8888",
"size": {
"w": 54,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "chest_red.png",
"image": "mysterious_chest_red.png",
"format": "RGBA8888",
"size": {
"w": 54,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "warehouse_crate.png",
"image": "part_timer_crate.png",
"format": "RGBA8888",
"size": {
"w": 71,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "bait.png",
"image": "safari_zone_bait.png",
"format": "RGBA8888",
"size": {
"w": 14,
Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "mud.png",
"image": "safari_zone_mud.png",
"format": "RGBA8888",
"size": {
"w": 14,
Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "b2w2_veteran_m.png",
"image": "shady_vitamin_dealer.png",
"format": "RGBA8888",
"size": {
"w": 424,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "teleporter.png",
"image": "teleporting_hijinks_teleporter.png",
"format": "RGBA8888",
"size": {
"w": 74,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"textures": [
{
"image": "training_gear.png",
"image": "training_session_gear.png",
"format": "RGBA8888",
"size": {
"w": 76,
Expand Down
54 changes: 30 additions & 24 deletions src/battle-scene.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Phaser from "phaser";
import UI from "./ui/ui";
import Pokemon, { PlayerPokemon, EnemyPokemon } from "./field/pokemon";
import PokemonSpecies, { PokemonSpeciesFilter, allSpecies, getPokemonSpecies } from "./data/pokemon-species";
import Pokemon, { EnemyPokemon, PlayerPokemon } from "./field/pokemon";
import PokemonSpecies, { allSpecies, getPokemonSpecies, PokemonSpeciesFilter } from "./data/pokemon-species";
import { Constructor, isNullOrUndefined } from "#app/utils";
import * as Utils from "./utils";
import { Modifier, ModifierBar, ConsumablePokemonModifier, ConsumableModifier, PokemonHpRestoreModifier, TurnHeldItemTransferModifier, HealingBoosterModifier, PersistentModifier, PokemonHeldItemModifier, ModifierPredicate, DoubleBattleChanceBoosterModifier, FusePokemonModifier, PokemonFormChangeItemModifier, TerastallizeModifier, overrideModifiers, overrideHeldItems, PokemonIncrementingStatModifier, ExpShareModifier, ExpBalanceModifier, MultipleParticipantExpBonusModifier, PokemonExpBoosterModifier } from "./modifier/modifier";
import { ConsumableModifier, ConsumablePokemonModifier, DoubleBattleChanceBoosterModifier, ExpBalanceModifier, ExpShareModifier, FusePokemonModifier, HealingBoosterModifier, Modifier, ModifierBar, ModifierPredicate, MultipleParticipantExpBonusModifier, overrideHeldItems, overrideModifiers, PersistentModifier, PokemonExpBoosterModifier, PokemonFormChangeItemModifier, PokemonHeldItemModifier, PokemonHpRestoreModifier, PokemonIncrementingStatModifier, TerastallizeModifier, TurnHeldItemTransferModifier } from "./modifier/modifier";
import { PokeballType } from "./data/pokeball";
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets, populateAnims } from "./data/battle-anims";
import { Phase } from "./phase";
Expand All @@ -13,20 +13,9 @@ import { Arena, ArenaBase } from "./field/arena";
import { GameData } from "./system/game-data";
import { addTextObject, getTextColor, TextStyle } from "./ui/text";
import { allMoves } from "./data/move";
import {
ModifierPoolType,
getDefaultModifierTypeForTier,
getEnemyModifierTypesForWave,
getLuckString,
getLuckTextTint,
getModifierPoolForType,
getModifierType,
getPartyLuckValue,
modifierTypes, PokemonHeldItemModifierType
} from "./modifier/modifier-type";
import { getDefaultModifierTypeForTier, getEnemyModifierTypesForWave, getLuckString, getLuckTextTint, getModifierPoolForType, getModifierType, getPartyLuckValue, ModifierPoolType, modifierTypes, PokemonHeldItemModifierType } from "./modifier/modifier-type";
import AbilityBar from "./ui/ability-bar";
import { BlockItemTheftAbAttr, DoubleBattleChanceAbAttr, ChangeMovePriorityAbAttr, PostBattleInitAbAttr, applyAbAttrs, applyPostBattleInitAbAttrs } from "./data/ability";
import { allAbilities } from "./data/ability";
import { allAbilities, applyAbAttrs, applyPostBattleInitAbAttrs, BlockItemTheftAbAttr, ChangeMovePriorityAbAttr, DoubleBattleChanceAbAttr, PostBattleInitAbAttr } from "./data/ability";
import Battle, { BattleType, FixedBattleConfig } from "./battle";
import { GameMode, GameModes, getGameMode } from "./game-mode";
import FieldSpritePipeline from "./pipelines/field-sprite";
Expand All @@ -46,7 +35,7 @@ import UIPlugin from "phaser3-rex-plugins/templates/ui/ui-plugin";
import { addUiThemeOverrides } from "./ui/ui-theme";
import PokemonData from "./system/pokemon-data";
import { Nature } from "./data/nature";
import { SpeciesFormChangeManualTrigger, SpeciesFormChangeTimeOfDayTrigger, SpeciesFormChangeTrigger, pokemonFormChanges, FormChangeItem, SpeciesFormChange } from "./data/pokemon-forms";
import { FormChangeItem, pokemonFormChanges, SpeciesFormChange, SpeciesFormChangeManualTrigger, SpeciesFormChangeTimeOfDayTrigger, SpeciesFormChangeTrigger } from "./data/pokemon-forms";
import { FormChangePhase } from "./phases/form-change-phase";
import { getTypeRgb } from "./data/type";
import PokemonSpriteSparkleHandler from "./field/pokemon-sprite-sparkle-handler";
Expand Down Expand Up @@ -1081,6 +1070,11 @@ export default class BattleScene extends SceneBase {
p.destroy();
}

// If this is a ME, clear any residual visual sprites before reloading
if (this.currentBattle?.mysteryEncounter?.introVisuals) {
this.field.remove(this.currentBattle.mysteryEncounter?.introVisuals, true);
}

//@ts-ignore - allowing `null` for currentBattle causes a lot of trouble
this.currentBattle = null; // TODO: resolve ts-ignore

Expand Down Expand Up @@ -1111,6 +1105,8 @@ export default class BattleScene extends SceneBase {
this.trainer.setPosition(406, 186);
this.trainer.setVisible(true);

this.mysteryEncounterSaveData = new MysteryEncounterSaveData();

this.updateGameInfo();

if (reloadI18n) {
Expand Down Expand Up @@ -1146,6 +1142,13 @@ export default class BattleScene extends SceneBase {
}
}

getDoubleBattleChance(newWaveIndex: number, playerField: PlayerPokemon[]) {
const doubleChance = new Utils.IntegerHolder(newWaveIndex % 10 === 0 ? 32 : 8);
this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance);
playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, false, doubleChance));
return Math.max(doubleChance.value, 1);
}

newBattle(waveIndex?: integer, battleType?: BattleType, trainerData?: TrainerData, double?: boolean, mysteryEncounterType?: MysteryEncounterType): Battle | null {
const _startingWave = Overrides.STARTING_WAVE_OVERRIDE || startingWave;
const newWaveIndex = waveIndex || ((this.currentBattle?.waveIndex || (_startingWave - 1)) + 1);
Expand Down Expand Up @@ -1229,10 +1232,7 @@ export default class BattleScene extends SceneBase {

if (double === undefined && newWaveIndex > 1) {
if (newBattleType === BattleType.WILD && !this.gameMode.isWaveFinal(newWaveIndex)) {
const doubleChance = new Utils.IntegerHolder(newWaveIndex % 10 === 0 ? 32 : 8);
this.applyModifiers(DoubleBattleChanceBoosterModifier, true, doubleChance);
playerField.forEach(p => applyAbAttrs(DoubleBattleChanceAbAttr, p, null, false, doubleChance));
newDouble = !Utils.randSeedInt(doubleChance.value);
newDouble = !Utils.randSeedInt(this.getDoubleBattleChance(newWaveIndex, playerField));
} else if (newBattleType === BattleType.TRAINER) {
newDouble = newTrainer?.variant === TrainerVariant.DOUBLE;
}
Expand Down Expand Up @@ -3169,11 +3169,17 @@ export default class BattleScene extends SceneBase {
if (encounterCandidate.encounterTier !== tier) { // Encounter is in tier
return false;
}
const disabledModes = encounterCandidate.disabledGameModes;
if (disabledModes && disabledModes.length > 0
&& disabledModes.includes(this.gameMode.modeId)) { // Encounter is enabled for game mode
const disallowedGameModes = encounterCandidate.disallowedGameModes;
if (disallowedGameModes && disallowedGameModes.length > 0
&& disallowedGameModes.includes(this.gameMode.modeId)) { // Encounter is enabled for game mode
return false;
}
if (this.gameMode.modeId === GameModes.CHALLENGE) { // Encounter is enabled for challenges
const disallowedChallenges = encounterCandidate.disallowedChallenges;
if (disallowedChallenges && disallowedChallenges.length > 0 && this.gameMode.challenges.some(challenge => disallowedChallenges.includes(challenge.id))) {
return false;
}
}
if (!encounterCandidate.meetsRequirements(this)) { // Meets encounter requirements
return false;
}
Expand Down
19 changes: 16 additions & 3 deletions src/data/ability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,27 @@ export class BlockRecoilDamageAttr extends AbAttr {
}
}

/**
* Attribute for abilities that increase the chance of a double battle
* occurring.
* @see apply
*/
export class DoubleBattleChanceAbAttr extends AbAttr {
constructor() {
super(false);
}

apply(pokemon: Pokemon, passive: boolean, simulated: boolean, cancelled: Utils.BooleanHolder, args: any[]): boolean {
const doubleChance = (args[0] as Utils.IntegerHolder);
doubleChance.value = Math.max(doubleChance.value / 2, 1);
/**
* Increases the chance of a double battle occurring
* @param args [0] {@linkcode Utils.NumberHolder} for double battle chance
* @returns true if the ability was applied
*/
apply(_pokemon: Pokemon, _passive: boolean, _simulated: boolean, _cancelled: Utils.BooleanHolder, args: any[]): boolean {
const doubleBattleChance = args[0] as Utils.NumberHolder;
// This is divided because the chance is generated as a number from 0 to doubleBattleChance.value using Utils.randSeedInt
// A double battle will initiate if the generated number is 0
doubleBattleChance.value = doubleBattleChance.value / 4;

return true;
}
}
Expand Down
19 changes: 12 additions & 7 deletions src/data/battle-anims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,16 +743,21 @@ export abstract class BattleAnim {
public target: Pokemon | null;
public sprites: Phaser.GameObjects.Sprite[];
public bgSprite: Phaser.GameObjects.TileSprite | Phaser.GameObjects.Rectangle;
public playOnEmptyField: boolean;
/**
* Will attempt to play as much of an animation as possible, even if not all targets are on the field.
* Will also play the animation, even if the user has selected "Move Animations" OFF in Settings.
* Exclusively used by MEs atm, for visual animations at the start of an encounter.
*/
public playRegardlessOfIssues: boolean;

private srcLine: number[];
private dstLine: number[];

constructor(user?: Pokemon, target?: Pokemon, playOnEmptyField: boolean = false) {
constructor(user?: Pokemon, target?: Pokemon, playRegardlessOfIssues: boolean = false) {
this.user = user ?? null;
this.target = target ?? null;
this.sprites = [];
this.playOnEmptyField = playOnEmptyField;
this.playRegardlessOfIssues = playRegardlessOfIssues;
}

abstract getAnim(): AnimConfig | null;
Expand Down Expand Up @@ -829,7 +834,7 @@ export abstract class BattleAnim {
const user = !isOppAnim ? this.user! : this.target!; // TODO: are those bangs correct?
const target = !isOppAnim ? this.target! : this.user!;

if (!target?.isOnField() && !this.playOnEmptyField) {
if (!target?.isOnField() && !this.playRegardlessOfIssues) {
if (callback) {
callback();
}
Expand Down Expand Up @@ -896,7 +901,7 @@ export abstract class BattleAnim {
}
};

if (!scene.moveAnimations) {
if (!scene.moveAnimations && !this.playRegardlessOfIssues) {
return cleanUpAndComplete();
}

Expand Down Expand Up @@ -932,7 +937,7 @@ export abstract class BattleAnim {
const isUser = frame.target === AnimFrameTarget.USER;
if (isUser && target === user) {
continue;
} else if (this.playOnEmptyField && frame.target === AnimFrameTarget.TARGET && !target.isOnField()) {
} else if (this.playRegardlessOfIssues && frame.target === AnimFrameTarget.TARGET && !target.isOnField()) {
continue;
}
const sprites = spriteCache[isUser ? AnimFrameTarget.USER : AnimFrameTarget.TARGET];
Expand Down Expand Up @@ -1145,7 +1150,7 @@ export abstract class BattleAnim {
}
};

if (!scene.moveAnimations) {
if (!scene.moveAnimations && !this.playRegardlessOfIssues) {
return cleanUpAndComplete();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export const AbsoluteAvariceEncounter: MysteryEncounter =
.withOptionPhase(async (scene: BattleScene) => {
// Let it have the food
// Greedent joins the team, level equal to 2 below highest party member
const level = getHighestLevelPlayerPokemon(scene).level - 2;
const level = getHighestLevelPlayerPokemon(scene, false, true).level - 2;
const greedent = new EnemyPokemon(scene, getPokemonSpecies(Species.GREEDENT), level, TrainerSlot.NONE, false);
greedent.moveset = [new PokemonMove(Moves.THRASH), new PokemonMove(Moves.BODY_PRESS), new PokemonMove(Moves.STUFF_CHEEKS), new PokemonMove(Moves.SLACK_OFF)];
greedent.passive = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const AnOfferYouCantRefuseEncounter: MysteryEncounter =
MysteryEncounterBuilder.withEncounterType(MysteryEncounterType.AN_OFFER_YOU_CANT_REFUSE)
.withEncounterTier(MysteryEncounterTier.GREAT)
.withSceneWaveRangeRequirement(...CLASSIC_MODE_MYSTERY_ENCOUNTER_WAVES)
.withScenePartySizeRequirement(2, 6) // Must have at least 2 pokemon in party
.withScenePartySizeRequirement(2, 6, true) // Must have at least 2 pokemon in party
.withIntroSpriteConfigs([
{
spriteKey: Species.LIEPARD.toString(),
Expand Down Expand Up @@ -60,7 +60,7 @@ export const AnOfferYouCantRefuseEncounter: MysteryEncounter =
.withQuery(`${namespace}.query`)
.withOnInit((scene: BattleScene) => {
const encounter = scene.currentBattle.mysteryEncounter!;
const pokemon = getHighestStatTotalPlayerPokemon(scene, false);
const pokemon = getHighestStatTotalPlayerPokemon(scene, true, true);
const price = scene.getWaveMoneyAmount(10);

encounter.setDialogueToken("strongestPokemon", pokemon.getNameToRender());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const BerriesAboundEncounter: MysteryEncounter =
const { spriteKey, fileRoot } = getSpriteKeysFromPokemon(bossPokemon);
encounter.spriteConfigs = [
{
spriteKey: "berry_bush",
spriteKey: "berries_abound_bush",
fileRoot: "mystery-encounters",
x: 25,
y: -6,
Expand All @@ -102,7 +102,7 @@ export const BerriesAboundEncounter: MysteryEncounter =
];

// Get fastest party pokemon for option 2
const fastestPokemon = getHighestStatPlayerPokemon(scene, PERMANENT_STATS[Stat.SPD], true);
const fastestPokemon = getHighestStatPlayerPokemon(scene, PERMANENT_STATS[Stat.SPD], true, false);
encounter.misc.fastestPokemon = fastestPokemon;
encounter.misc.enemySpeed = bossPokemon.getStat(Stat.SPD);
encounter.setDialogueToken("fastestPokemon", fastestPokemon.getNameToRender());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,10 @@ export const BugTypeSuperfanEncounter: MysteryEncounter =
const onPokemonSelected = (pokemon: PlayerPokemon) => {
// Get Pokemon held items and filter for valid ones
const validItems = pokemon.getHeldItems().filter(item => {
return item instanceof BypassSpeedChanceModifier ||
return (item instanceof BypassSpeedChanceModifier ||
item instanceof ContactHeldItemTransferChanceModifier ||
(item instanceof AttackTypeBoosterModifier && (item.type as AttackTypeBoosterModifierType).moveType === Type.BUG);
(item instanceof AttackTypeBoosterModifier && (item.type as AttackTypeBoosterModifierType).moveType === Type.BUG)) &&
item.isTransferable;
});

return validItems.map((modifier: PokemonHeldItemModifier) => {
Expand Down
Loading

0 comments on commit cb8cf9c

Please sign in to comment.