mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-15 20:09:30 +02:00
Compare commits
3 Commits
2a0a49b6ab
...
3e046fba32
Author | SHA1 | Date | |
---|---|---|---|
|
3e046fba32 | ||
|
6c0253ada4 | ||
|
6321a4cd19 |
@ -27,13 +27,7 @@ import { UiInputs } from "#app/ui-inputs";
|
|||||||
import { biomeDepths, getBiomeName } from "#balance/biomes";
|
import { biomeDepths, getBiomeName } from "#balance/biomes";
|
||||||
import { pokemonPrevolutions } from "#balance/pokemon-evolutions";
|
import { pokemonPrevolutions } from "#balance/pokemon-evolutions";
|
||||||
import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#balance/starters";
|
import { FRIENDSHIP_GAIN_FROM_BATTLE } from "#balance/starters";
|
||||||
import {
|
import { initCommonAnims, initMoveAnim, loadCommonAnimAssets, loadMoveAnimAssets } from "#data/battle-anims";
|
||||||
initCommonAnims,
|
|
||||||
initMoveAnim,
|
|
||||||
loadCommonAnimAssets,
|
|
||||||
loadMoveAnimAssets,
|
|
||||||
populateAnims,
|
|
||||||
} from "#data/battle-anims";
|
|
||||||
import { allAbilities, allMoves, allSpecies, modifierTypes } from "#data/data-lists";
|
import { allAbilities, allMoves, allSpecies, modifierTypes } from "#data/data-lists";
|
||||||
import { battleSpecDialogue } from "#data/dialogue";
|
import { battleSpecDialogue } from "#data/dialogue";
|
||||||
import type { SpeciesFormChangeTrigger } from "#data/form-change-triggers";
|
import type { SpeciesFormChangeTrigger } from "#data/form-change-triggers";
|
||||||
@ -387,7 +381,6 @@ export class BattleScene extends SceneBase {
|
|||||||
const defaultMoves = [MoveId.TACKLE, MoveId.TAIL_WHIP, MoveId.FOCUS_ENERGY, MoveId.STRUGGLE];
|
const defaultMoves = [MoveId.TACKLE, MoveId.TAIL_WHIP, MoveId.FOCUS_ENERGY, MoveId.STRUGGLE];
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
populateAnims(),
|
|
||||||
this.initVariantData(),
|
this.initVariantData(),
|
||||||
initCommonAnims().then(() => loadCommonAnimAssets(true)),
|
initCommonAnims().then(() => loadCommonAnimAssets(true)),
|
||||||
Promise.all(defaultMoves.map(m => initMoveAnim(m))).then(() => loadMoveAnimAssets(defaultMoves, true)),
|
Promise.all(defaultMoves.map(m => initMoveAnim(m))).then(() => loadMoveAnimAssets(defaultMoves, true)),
|
||||||
|
@ -404,22 +404,18 @@ export const chargeAnims = new Map<ChargeAnim, AnimConfig | [AnimConfig, AnimCon
|
|||||||
export const commonAnims = new Map<CommonAnim, AnimConfig>();
|
export const commonAnims = new Map<CommonAnim, AnimConfig>();
|
||||||
export const encounterAnims = new Map<EncounterAnim, AnimConfig>();
|
export const encounterAnims = new Map<EncounterAnim, AnimConfig>();
|
||||||
|
|
||||||
export function initCommonAnims(): Promise<void> {
|
export async function initCommonAnims(): Promise<void> {
|
||||||
return new Promise(resolve => {
|
const commonAnimFetches: Promise<Map<CommonAnim, AnimConfig>>[] = [];
|
||||||
const commonAnimNames = getEnumKeys(CommonAnim);
|
for (const commonAnimName of getEnumKeys(CommonAnim)) {
|
||||||
const commonAnimIds = getEnumValues(CommonAnim);
|
const commonAnimId = CommonAnim[commonAnimName];
|
||||||
const commonAnimFetches: Promise<Map<CommonAnim, AnimConfig>>[] = [];
|
commonAnimFetches.push(
|
||||||
for (let ca = 0; ca < commonAnimIds.length; ca++) {
|
globalScene
|
||||||
const commonAnimId = commonAnimIds[ca];
|
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimName)}.json`)
|
||||||
commonAnimFetches.push(
|
.then(response => response.json())
|
||||||
globalScene
|
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))),
|
||||||
.cachedFetch(`./battle-anims/common-${toKebabCase(commonAnimNames[ca])}.json`)
|
);
|
||||||
.then(response => response.json())
|
}
|
||||||
.then(cas => commonAnims.set(commonAnimId, new AnimConfig(cas))),
|
await Promise.allSettled(commonAnimFetches);
|
||||||
);
|
|
||||||
}
|
|
||||||
Promise.allSettled(commonAnimFetches).then(() => resolve());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initMoveAnim(move: MoveId): Promise<void> {
|
export function initMoveAnim(move: MoveId): Promise<void> {
|
||||||
@ -1396,279 +1392,3 @@ export class EncounterBattleAnim extends BattleAnim {
|
|||||||
return this.oppAnim;
|
return this.oppAnim;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function populateAnims() {
|
|
||||||
const commonAnimNames = getEnumKeys(CommonAnim).map(k => k.toLowerCase());
|
|
||||||
const commonAnimMatchNames = commonAnimNames.map(k => k.replace(/_/g, ""));
|
|
||||||
const commonAnimIds = getEnumValues(CommonAnim);
|
|
||||||
const chargeAnimNames = getEnumKeys(ChargeAnim).map(k => k.toLowerCase());
|
|
||||||
const chargeAnimMatchNames = chargeAnimNames.map(k => k.replace(/_/g, " "));
|
|
||||||
const chargeAnimIds = getEnumValues(ChargeAnim);
|
|
||||||
const commonNamePattern = /name: (?:Common:)?(Opp )?(.*)/;
|
|
||||||
const moveNameToId = {};
|
|
||||||
// Exclude MoveId.NONE;
|
|
||||||
for (const move of getEnumValues(MoveId).slice(1)) {
|
|
||||||
// KARATE_CHOP => KARATECHOP
|
|
||||||
const moveName = MoveId[move].toUpperCase().replace(/_/g, "");
|
|
||||||
moveNameToId[moveName] = move;
|
|
||||||
}
|
|
||||||
|
|
||||||
const seNames: string[] = []; //(await fs.readdir('./public/audio/se/battle_anims/')).map(se => se.toString());
|
|
||||||
|
|
||||||
const animsData: any[] = []; //battleAnimRawData.split('!ruby/array:PBAnimation').slice(1); // TODO: add a proper type
|
|
||||||
for (let a = 0; a < animsData.length; a++) {
|
|
||||||
const fields = animsData[a].split("@").slice(1);
|
|
||||||
|
|
||||||
const nameField = fields.find(f => f.startsWith("name: "));
|
|
||||||
|
|
||||||
let isOppMove: boolean | undefined;
|
|
||||||
let commonAnimId: CommonAnim | undefined;
|
|
||||||
let chargeAnimId: ChargeAnim | undefined;
|
|
||||||
if (!nameField.startsWith("name: Move:") && !(isOppMove = nameField.startsWith("name: OppMove:"))) {
|
|
||||||
const nameMatch = commonNamePattern.exec(nameField)!; // TODO: is this bang correct?
|
|
||||||
const name = nameMatch[2].toLowerCase();
|
|
||||||
if (commonAnimMatchNames.indexOf(name) > -1) {
|
|
||||||
commonAnimId = commonAnimIds[commonAnimMatchNames.indexOf(name)];
|
|
||||||
} else if (chargeAnimMatchNames.indexOf(name) > -1) {
|
|
||||||
isOppMove = nameField.startsWith("name: Opp ");
|
|
||||||
chargeAnimId = chargeAnimIds[chargeAnimMatchNames.indexOf(name)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const nameIndex = nameField.indexOf(":", 5) + 1;
|
|
||||||
const animName = nameField.slice(nameIndex, nameField.indexOf("\n", nameIndex));
|
|
||||||
if (!moveNameToId.hasOwnProperty(animName) && !commonAnimId && !chargeAnimId) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const anim = commonAnimId || chargeAnimId ? new AnimConfig() : new AnimConfig();
|
|
||||||
if (anim instanceof AnimConfig) {
|
|
||||||
(anim as AnimConfig).id = moveNameToId[animName];
|
|
||||||
}
|
|
||||||
if (commonAnimId) {
|
|
||||||
commonAnims.set(commonAnimId, anim);
|
|
||||||
} else if (chargeAnimId) {
|
|
||||||
chargeAnims.set(chargeAnimId, !isOppMove ? anim : [chargeAnims.get(chargeAnimId) as AnimConfig, anim]);
|
|
||||||
} else {
|
|
||||||
moveAnims.set(
|
|
||||||
moveNameToId[animName],
|
|
||||||
!isOppMove ? (anim as AnimConfig) : [moveAnims.get(moveNameToId[animName]) as AnimConfig, anim as AnimConfig],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
for (let f = 0; f < fields.length; f++) {
|
|
||||||
const field = fields[f];
|
|
||||||
const fieldName = field.slice(0, field.indexOf(":"));
|
|
||||||
const fieldData = field.slice(fieldName.length + 1, field.lastIndexOf("\n")).trim();
|
|
||||||
switch (fieldName) {
|
|
||||||
case "array": {
|
|
||||||
const framesData = fieldData.split(" - - - ").slice(1);
|
|
||||||
for (let fd = 0; fd < framesData.length; fd++) {
|
|
||||||
anim.frames.push([]);
|
|
||||||
const frameData = framesData[fd];
|
|
||||||
const focusFramesData = frameData.split(" - - ");
|
|
||||||
for (let tf = 0; tf < focusFramesData.length; tf++) {
|
|
||||||
const values = focusFramesData[tf].replace(/ {6}- /g, "").split("\n");
|
|
||||||
const targetFrame = new AnimFrame(
|
|
||||||
Number.parseFloat(values[0]),
|
|
||||||
Number.parseFloat(values[1]),
|
|
||||||
Number.parseFloat(values[2]),
|
|
||||||
Number.parseFloat(values[11]),
|
|
||||||
Number.parseFloat(values[3]),
|
|
||||||
Number.parseInt(values[4]) === 1,
|
|
||||||
Number.parseInt(values[6]) === 1,
|
|
||||||
Number.parseInt(values[5]),
|
|
||||||
Number.parseInt(values[7]),
|
|
||||||
Number.parseInt(values[8]),
|
|
||||||
Number.parseInt(values[12]),
|
|
||||||
Number.parseInt(values[13]),
|
|
||||||
Number.parseInt(values[14]),
|
|
||||||
Number.parseInt(values[15]),
|
|
||||||
Number.parseInt(values[16]),
|
|
||||||
Number.parseInt(values[17]),
|
|
||||||
Number.parseInt(values[18]),
|
|
||||||
Number.parseInt(values[19]),
|
|
||||||
Number.parseInt(values[21]),
|
|
||||||
Number.parseInt(values[22]),
|
|
||||||
Number.parseInt(values[23]),
|
|
||||||
Number.parseInt(values[24]),
|
|
||||||
Number.parseInt(values[20]) === 1,
|
|
||||||
Number.parseInt(values[25]),
|
|
||||||
Number.parseInt(values[26]) as AnimFocus,
|
|
||||||
);
|
|
||||||
anim.frames[fd].push(targetFrame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "graphic": {
|
|
||||||
const graphic = fieldData !== "''" ? fieldData : "";
|
|
||||||
anim.graphic = graphic.indexOf(".") > -1 ? graphic.slice(0, fieldData.indexOf(".")) : graphic;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "timing": {
|
|
||||||
const timingEntries = fieldData.split("- !ruby/object:PBAnimTiming ").slice(1);
|
|
||||||
for (let t = 0; t < timingEntries.length; t++) {
|
|
||||||
const timingData = timingEntries[t]
|
|
||||||
.replace(/\n/g, " ")
|
|
||||||
.replace(/[ ]{2,}/g, " ")
|
|
||||||
.replace(/[a-z]+: ! '', /gi, "")
|
|
||||||
.replace(/name: (.*?),/, 'name: "$1",')
|
|
||||||
.replace(
|
|
||||||
/flashColor: !ruby\/object:Color { alpha: ([\d.]+), blue: ([\d.]+), green: ([\d.]+), red: ([\d.]+)}/,
|
|
||||||
"flashRed: $4, flashGreen: $3, flashBlue: $2, flashAlpha: $1",
|
|
||||||
);
|
|
||||||
const frameIndex = Number.parseInt(/frame: (\d+)/.exec(timingData)![1]); // TODO: is the bang correct?
|
|
||||||
let resourceName = /name: "(.*?)"/.exec(timingData)![1].replace("''", ""); // TODO: is the bang correct?
|
|
||||||
const timingType = Number.parseInt(/timingType: (\d)/.exec(timingData)![1]); // TODO: is the bang correct?
|
|
||||||
let timedEvent: AnimTimedEvent | undefined;
|
|
||||||
switch (timingType) {
|
|
||||||
case 0:
|
|
||||||
if (resourceName && resourceName.indexOf(".") === -1) {
|
|
||||||
let ext: string | undefined;
|
|
||||||
["wav", "mp3", "m4a"].every(e => {
|
|
||||||
if (seNames.indexOf(`${resourceName}.${e}`) > -1) {
|
|
||||||
ext = e;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
if (!ext) {
|
|
||||||
ext = ".wav";
|
|
||||||
}
|
|
||||||
resourceName += `.${ext}`;
|
|
||||||
}
|
|
||||||
timedEvent = new AnimTimedSoundEvent(frameIndex, resourceName);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
timedEvent = new AnimTimedAddBgEvent(frameIndex, resourceName.slice(0, resourceName.indexOf(".")));
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
timedEvent = new AnimTimedUpdateBgEvent(frameIndex, resourceName.slice(0, resourceName.indexOf(".")));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!timedEvent) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const propPattern = /([a-z]+): (.*?)(?:,|\})/gi;
|
|
||||||
let propMatch: RegExpExecArray;
|
|
||||||
while ((propMatch = propPattern.exec(timingData)!)) {
|
|
||||||
// TODO: is this bang correct?
|
|
||||||
const prop = propMatch[1];
|
|
||||||
let value: any = propMatch[2];
|
|
||||||
switch (prop) {
|
|
||||||
case "bgX":
|
|
||||||
case "bgY":
|
|
||||||
value = Number.parseFloat(value);
|
|
||||||
break;
|
|
||||||
case "volume":
|
|
||||||
case "pitch":
|
|
||||||
case "opacity":
|
|
||||||
case "colorRed":
|
|
||||||
case "colorGreen":
|
|
||||||
case "colorBlue":
|
|
||||||
case "colorAlpha":
|
|
||||||
case "duration":
|
|
||||||
case "flashScope":
|
|
||||||
case "flashRed":
|
|
||||||
case "flashGreen":
|
|
||||||
case "flashBlue":
|
|
||||||
case "flashAlpha":
|
|
||||||
case "flashDuration":
|
|
||||||
value = Number.parseInt(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (timedEvent.hasOwnProperty(prop)) {
|
|
||||||
timedEvent[prop] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!anim.frameTimedEvents.has(frameIndex)) {
|
|
||||||
anim.frameTimedEvents.set(frameIndex, []);
|
|
||||||
}
|
|
||||||
anim.frameTimedEvents.get(frameIndex)!.push(timedEvent); // TODO: is this bang correct?
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "position":
|
|
||||||
anim.position = Number.parseInt(fieldData);
|
|
||||||
break;
|
|
||||||
case "hue":
|
|
||||||
anim.hue = Number.parseInt(fieldData);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// biome-ignore lint/correctness/noUnusedVariables: used in commented code
|
|
||||||
const animReplacer = (k, v) => {
|
|
||||||
if (k === "id" && !v) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (v instanceof Map) {
|
|
||||||
return Object.fromEntries(v);
|
|
||||||
}
|
|
||||||
if (v instanceof AnimTimedEvent) {
|
|
||||||
v["eventType"] = v.getEventType();
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
};
|
|
||||||
|
|
||||||
const animConfigProps = ["id", "graphic", "frames", "frameTimedEvents", "position", "hue"];
|
|
||||||
const animFrameProps = [
|
|
||||||
"x",
|
|
||||||
"y",
|
|
||||||
"zoomX",
|
|
||||||
"zoomY",
|
|
||||||
"angle",
|
|
||||||
"mirror",
|
|
||||||
"visible",
|
|
||||||
"blendType",
|
|
||||||
"target",
|
|
||||||
"graphicFrame",
|
|
||||||
"opacity",
|
|
||||||
"color",
|
|
||||||
"tone",
|
|
||||||
"flash",
|
|
||||||
"locked",
|
|
||||||
"priority",
|
|
||||||
"focus",
|
|
||||||
];
|
|
||||||
const propSets = [animConfigProps, animFrameProps];
|
|
||||||
|
|
||||||
// biome-ignore lint/correctness/noUnusedVariables: used in commented code
|
|
||||||
const animComparator = (a: Element, b: Element) => {
|
|
||||||
let props: string[];
|
|
||||||
for (let p = 0; p < propSets.length; p++) {
|
|
||||||
props = propSets[p];
|
|
||||||
// @ts-expect-error TODO
|
|
||||||
const ai = props.indexOf(a.key);
|
|
||||||
if (ai === -1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// @ts-expect-error TODO
|
|
||||||
const bi = props.indexOf(b.key);
|
|
||||||
|
|
||||||
return ai < bi ? -1 : ai > bi ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*for (let ma of moveAnims.keys()) {
|
|
||||||
const data = moveAnims.get(ma);
|
|
||||||
(async () => {
|
|
||||||
await fs.writeFile(`../public/battle-anims/${Moves[ma].toLowerCase().replace(/\_/g, '-')}.json`, stringify(data, { replacer: animReplacer, cmp: animComparator, space: ' ' }));
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let ca of chargeAnims.keys()) {
|
|
||||||
const data = chargeAnims.get(ca);
|
|
||||||
(async () => {
|
|
||||||
await fs.writeFile(`../public/battle-anims/${chargeAnimNames[chargeAnimIds.indexOf(ca)].replace(/\_/g, '-')}.json`, stringify(data, { replacer: animReplacer, cmp: animComparator, space: ' ' }));
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let cma of commonAnims.keys()) {
|
|
||||||
const data = commonAnims.get(cma);
|
|
||||||
(async () => {
|
|
||||||
await fs.writeFile(`../public/battle-anims/common-${commonAnimNames[commonAnimIds.indexOf(cma)].replace(/\_/g, '-')}.json`, stringify(data, { replacer: animReplacer, cmp: animComparator, space: ' ' }));
|
|
||||||
})();
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
@ -5,10 +5,9 @@ import type { PokemonSpeciesForm } from "#data/pokemon-species";
|
|||||||
import { PokemonSpecies } from "#data/pokemon-species";
|
import { PokemonSpecies } from "#data/pokemon-species";
|
||||||
import { BiomeId } from "#enums/biome-id";
|
import { BiomeId } from "#enums/biome-id";
|
||||||
import { PartyMemberStrength } from "#enums/party-member-strength";
|
import { PartyMemberStrength } from "#enums/party-member-strength";
|
||||||
import type { SpeciesId } from "#enums/species-id";
|
import { SpeciesId } from "#enums/species-id";
|
||||||
import { PlayerPokemon } from "#field/pokemon";
|
|
||||||
import type { Starter } from "#ui/starter-select-ui-handler";
|
import type { Starter } from "#ui/starter-select-ui-handler";
|
||||||
import { randSeedGauss, randSeedInt, randSeedItem } from "#utils/common";
|
import { isNullOrUndefined, randSeedGauss, randSeedInt, randSeedItem } from "#utils/common";
|
||||||
import { getEnumValues } from "#utils/enums";
|
import { getEnumValues } from "#utils/enums";
|
||||||
import { getPokemonSpecies, getPokemonSpeciesForm } from "#utils/pokemon-utils";
|
import { getPokemonSpecies, getPokemonSpeciesForm } from "#utils/pokemon-utils";
|
||||||
|
|
||||||
@ -32,15 +31,9 @@ export function getDailyRunStarters(seed: string): Starter[] {
|
|||||||
() => {
|
() => {
|
||||||
const startingLevel = globalScene.gameMode.getStartingLevel();
|
const startingLevel = globalScene.gameMode.getStartingLevel();
|
||||||
|
|
||||||
if (/\d{18}$/.test(seed)) {
|
const eventStarters = getDailyEventSeedStarters(seed);
|
||||||
for (let s = 0; s < 3; s++) {
|
if (!isNullOrUndefined(eventStarters)) {
|
||||||
const offset = 6 + s * 6;
|
starters.push(...eventStarters);
|
||||||
const starterSpeciesForm = getPokemonSpeciesForm(
|
|
||||||
Number.parseInt(seed.slice(offset, offset + 4)) as SpeciesId,
|
|
||||||
Number.parseInt(seed.slice(offset + 4, offset + 6)),
|
|
||||||
);
|
|
||||||
starters.push(getDailyRunStarter(starterSpeciesForm, startingLevel));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,18 +65,7 @@ function getDailyRunStarter(starterSpeciesForm: PokemonSpeciesForm, startingLeve
|
|||||||
const starterSpecies =
|
const starterSpecies =
|
||||||
starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId);
|
starterSpeciesForm instanceof PokemonSpecies ? starterSpeciesForm : getPokemonSpecies(starterSpeciesForm.speciesId);
|
||||||
const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.formIndex;
|
const formIndex = starterSpeciesForm instanceof PokemonSpecies ? undefined : starterSpeciesForm.formIndex;
|
||||||
const pokemon = new PlayerPokemon(
|
const pokemon = globalScene.addPlayerPokemon(starterSpecies, startingLevel, undefined, formIndex);
|
||||||
starterSpecies,
|
|
||||||
startingLevel,
|
|
||||||
undefined,
|
|
||||||
formIndex,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
);
|
|
||||||
const starter: Starter = {
|
const starter: Starter = {
|
||||||
species: starterSpecies,
|
species: starterSpecies,
|
||||||
dexAttr: pokemon.getDexAttr(),
|
dexAttr: pokemon.getDexAttr(),
|
||||||
@ -145,6 +127,11 @@ const dailyBiomeWeights: BiomeWeights = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function getDailyStartingBiome(): BiomeId {
|
export function getDailyStartingBiome(): BiomeId {
|
||||||
|
const eventBiome = getDailyEventSeedBiome(globalScene.seed);
|
||||||
|
if (!isNullOrUndefined(eventBiome)) {
|
||||||
|
return eventBiome;
|
||||||
|
}
|
||||||
|
|
||||||
const biomes = getEnumValues(BiomeId).filter(b => b !== BiomeId.TOWN && b !== BiomeId.END);
|
const biomes = getEnumValues(BiomeId).filter(b => b !== BiomeId.TOWN && b !== BiomeId.END);
|
||||||
|
|
||||||
let totalWeight = 0;
|
let totalWeight = 0;
|
||||||
@ -169,3 +156,126 @@ export function getDailyStartingBiome(): BiomeId {
|
|||||||
// TODO: should this use `randSeedItem`?
|
// TODO: should this use `randSeedItem`?
|
||||||
return biomes[randSeedInt(biomes.length)];
|
return biomes[randSeedInt(biomes.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If this is Daily Mode and the seed is longer than a default seed
|
||||||
|
* then it has been modified and could contain a custom event seed. \
|
||||||
|
* Default seeds are always exactly 24 characters.
|
||||||
|
* @returns `true` if it is a Daily Event Seed.
|
||||||
|
*/
|
||||||
|
export function isDailyEventSeed(seed: string): boolean {
|
||||||
|
return globalScene.gameMode.isDaily && seed.length > 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expects the seed to contain `/starters\d{18}/`
|
||||||
|
* where the digits alternate between 4 digits for the species ID and 2 digits for the form index
|
||||||
|
* (left padded with `0`s as necessary).
|
||||||
|
* @returns An array of {@linkcode Starter}s, or `null` if no valid match.
|
||||||
|
*/
|
||||||
|
export function getDailyEventSeedStarters(seed: string): Starter[] | null {
|
||||||
|
if (!isDailyEventSeed(seed)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const starters: Starter[] = [];
|
||||||
|
const match = /starters(\d{4})(\d{2})(\d{4})(\d{2})(\d{4})(\d{2})/g.exec(seed);
|
||||||
|
|
||||||
|
if (!match || match.length !== 7) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 1; i < match.length; i += 2) {
|
||||||
|
const speciesId = Number.parseInt(match[i]) as SpeciesId;
|
||||||
|
const formIndex = Number.parseInt(match[i + 1]);
|
||||||
|
|
||||||
|
if (!getEnumValues(SpeciesId).includes(speciesId)) {
|
||||||
|
console.warn("Invalid species ID used for custom daily run seed starter:", speciesId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const starterForm = getPokemonSpeciesForm(speciesId, formIndex);
|
||||||
|
const startingLevel = globalScene.gameMode.getStartingLevel();
|
||||||
|
const starter = getDailyRunStarter(starterForm, startingLevel);
|
||||||
|
starters.push(starter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return starters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expects the seed to contain `/boss\d{4}\d{2}/`
|
||||||
|
* where the first 4 digits are the species ID and the next 2 digits are the form index
|
||||||
|
* (left padded with `0`s as necessary).
|
||||||
|
* @returns A {@linkcode PokemonSpeciesForm} to be used for the boss, or `null` if no valid match.
|
||||||
|
*/
|
||||||
|
export function getDailyEventSeedBoss(seed: string): PokemonSpeciesForm | null {
|
||||||
|
if (!isDailyEventSeed(seed)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = /boss(\d{4})(\d{2})/g.exec(seed);
|
||||||
|
if (!match || match.length !== 3) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const speciesId = Number.parseInt(match[1]) as SpeciesId;
|
||||||
|
const formIndex = Number.parseInt(match[2]);
|
||||||
|
|
||||||
|
if (!getEnumValues(SpeciesId).includes(speciesId)) {
|
||||||
|
console.warn("Invalid species ID used for custom daily run seed boss:", speciesId);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const starterForm = getPokemonSpeciesForm(speciesId, formIndex);
|
||||||
|
return starterForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expects the seed to contain `/biome\d{2}/` where the 2 digits are a biome ID (left padded with `0` if necessary).
|
||||||
|
* @returns The biome to use or `null` if no valid match.
|
||||||
|
*/
|
||||||
|
export function getDailyEventSeedBiome(seed: string): BiomeId | null {
|
||||||
|
if (!isDailyEventSeed(seed)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = /biome(\d{2})/g.exec(seed);
|
||||||
|
if (!match || match.length !== 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const startingBiome = Number.parseInt(match[1]) as BiomeId;
|
||||||
|
|
||||||
|
if (!getEnumValues(BiomeId).includes(startingBiome)) {
|
||||||
|
console.warn("Invalid biome ID used for custom daily run seed:", startingBiome);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return startingBiome;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expects the seed to contain `/luck\d{2}/` where the 2 digits are a number between `0` and `14`
|
||||||
|
* (left padded with `0` if necessary).
|
||||||
|
* @returns The custom luck value or `null` if no valid match.
|
||||||
|
*/
|
||||||
|
export function getDailyEventSeedLuck(seed: string): number | null {
|
||||||
|
if (!isDailyEventSeed(seed)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = /luck(\d{2})/g.exec(seed);
|
||||||
|
if (!match || match.length !== 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const luck = Number.parseInt(match[1]);
|
||||||
|
|
||||||
|
if (luck < 0 || luck > 14) {
|
||||||
|
console.warn("Invalid luck value used for custom daily run seed:", luck);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return luck;
|
||||||
|
}
|
||||||
|
@ -39,6 +39,7 @@ import {
|
|||||||
TrappedTag,
|
TrappedTag,
|
||||||
TypeImmuneTag,
|
TypeImmuneTag,
|
||||||
} from "#data/battler-tags";
|
} from "#data/battler-tags";
|
||||||
|
import { getDailyEventSeedBoss } from "#data/daily-run";
|
||||||
import { allAbilities, allMoves } from "#data/data-lists";
|
import { allAbilities, allMoves } from "#data/data-lists";
|
||||||
import { getLevelTotalExp } from "#data/exp";
|
import { getLevelTotalExp } from "#data/exp";
|
||||||
import {
|
import {
|
||||||
@ -6256,6 +6257,11 @@ export class EnemyPokemon extends Pokemon {
|
|||||||
this.species.forms[Overrides.OPP_FORM_OVERRIDES[speciesId]]
|
this.species.forms[Overrides.OPP_FORM_OVERRIDES[speciesId]]
|
||||||
) {
|
) {
|
||||||
this.formIndex = Overrides.OPP_FORM_OVERRIDES[speciesId];
|
this.formIndex = Overrides.OPP_FORM_OVERRIDES[speciesId];
|
||||||
|
} else if (globalScene.gameMode.isDaily && globalScene.gameMode.isWaveFinal(globalScene.currentBattle.waveIndex)) {
|
||||||
|
const eventBoss = getDailyEventSeedBoss(globalScene.seed);
|
||||||
|
if (!isNullOrUndefined(eventBoss)) {
|
||||||
|
this.formIndex = eventBoss.formIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dataSource) {
|
if (!dataSource) {
|
||||||
|
@ -3,7 +3,7 @@ import { CHALLENGE_MODE_MYSTERY_ENCOUNTER_WAVES, CLASSIC_MODE_MYSTERY_ENCOUNTER_
|
|||||||
import { globalScene } from "#app/global-scene";
|
import { globalScene } from "#app/global-scene";
|
||||||
import Overrides from "#app/overrides";
|
import Overrides from "#app/overrides";
|
||||||
import { allChallenges, type Challenge, copyChallenge } from "#data/challenge";
|
import { allChallenges, type Challenge, copyChallenge } from "#data/challenge";
|
||||||
import { getDailyStartingBiome } from "#data/daily-run";
|
import { getDailyEventSeedBoss, getDailyStartingBiome } from "#data/daily-run";
|
||||||
import { allSpecies } from "#data/data-lists";
|
import { allSpecies } from "#data/data-lists";
|
||||||
import type { PokemonSpecies } from "#data/pokemon-species";
|
import type { PokemonSpecies } from "#data/pokemon-species";
|
||||||
import { BiomeId } from "#enums/biome-id";
|
import { BiomeId } from "#enums/biome-id";
|
||||||
@ -15,6 +15,7 @@ import type { Arena } from "#field/arena";
|
|||||||
import { classicFixedBattles, type FixedBattleConfigs } from "#trainers/fixed-battle-configs";
|
import { classicFixedBattles, type FixedBattleConfigs } from "#trainers/fixed-battle-configs";
|
||||||
import { applyChallenges } from "#utils/challenge-utils";
|
import { applyChallenges } from "#utils/challenge-utils";
|
||||||
import { BooleanHolder, isNullOrUndefined, randSeedInt, randSeedItem } from "#utils/common";
|
import { BooleanHolder, isNullOrUndefined, randSeedInt, randSeedItem } from "#utils/common";
|
||||||
|
import { getPokemonSpecies } from "#utils/pokemon-utils";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
|
|
||||||
interface GameModeConfig {
|
interface GameModeConfig {
|
||||||
@ -211,6 +212,12 @@ export class GameMode implements GameModeConfig {
|
|||||||
|
|
||||||
getOverrideSpecies(waveIndex: number): PokemonSpecies | null {
|
getOverrideSpecies(waveIndex: number): PokemonSpecies | null {
|
||||||
if (this.isDaily && this.isWaveFinal(waveIndex)) {
|
if (this.isDaily && this.isWaveFinal(waveIndex)) {
|
||||||
|
const eventBoss = getDailyEventSeedBoss(globalScene.seed);
|
||||||
|
if (!isNullOrUndefined(eventBoss)) {
|
||||||
|
// Cannot set form index here, it will be overriden when adding it as enemy pokemon.
|
||||||
|
return getPokemonSpecies(eventBoss.speciesId);
|
||||||
|
}
|
||||||
|
|
||||||
const allFinalBossSpecies = allSpecies.filter(
|
const allFinalBossSpecies = allSpecies.filter(
|
||||||
s =>
|
s =>
|
||||||
(s.subLegendary || s.legendary || s.mythical) &&
|
(s.subLegendary || s.legendary || s.mythical) &&
|
||||||
|
@ -6,6 +6,7 @@ import Overrides from "#app/overrides";
|
|||||||
import { EvolutionItem, pokemonEvolutions } from "#balance/pokemon-evolutions";
|
import { EvolutionItem, pokemonEvolutions } from "#balance/pokemon-evolutions";
|
||||||
import { tmPoolTiers, tmSpecies } from "#balance/tms";
|
import { tmPoolTiers, tmSpecies } from "#balance/tms";
|
||||||
import { getBerryEffectDescription, getBerryName } from "#data/berry";
|
import { getBerryEffectDescription, getBerryName } from "#data/berry";
|
||||||
|
import { getDailyEventSeedLuck } from "#data/daily-run";
|
||||||
import { allMoves, modifierTypes } from "#data/data-lists";
|
import { allMoves, modifierTypes } from "#data/data-lists";
|
||||||
import { SpeciesFormChangeItemTrigger } from "#data/form-change-triggers";
|
import { SpeciesFormChangeItemTrigger } from "#data/form-change-triggers";
|
||||||
import { getNatureName, getNatureStatMultiplier } from "#data/nature";
|
import { getNatureName, getNatureStatMultiplier } from "#data/nature";
|
||||||
@ -2921,6 +2922,12 @@ export function getPartyLuckValue(party: Pokemon[]): number {
|
|||||||
const DailyLuck = new NumberHolder(0);
|
const DailyLuck = new NumberHolder(0);
|
||||||
globalScene.executeWithSeedOffset(
|
globalScene.executeWithSeedOffset(
|
||||||
() => {
|
() => {
|
||||||
|
const eventLuck = getDailyEventSeedLuck(globalScene.seed);
|
||||||
|
if (!isNullOrUndefined(eventLuck)) {
|
||||||
|
DailyLuck.value = eventLuck;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DailyLuck.value = randSeedInt(15); // Random number between 0 and 14
|
DailyLuck.value = randSeedInt(15); // Random number between 0 and 14
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
@ -2928,6 +2935,7 @@ export function getPartyLuckValue(party: Pokemon[]): number {
|
|||||||
);
|
);
|
||||||
return DailyLuck.value;
|
return DailyLuck.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventSpecies = timedEventManager.getEventLuckBoostedSpecies();
|
const eventSpecies = timedEventManager.getEventLuckBoostedSpecies();
|
||||||
const luck = Phaser.Math.Clamp(
|
const luck = Phaser.Math.Clamp(
|
||||||
party
|
party
|
||||||
|
Loading…
Reference in New Issue
Block a user