mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-03-30 14:38:43 +01:00
[Refactor] Add support for form and evolution specific passives (#5193)
* Add support for form and evolution specific passives * Update src/data/pokemon-species.ts --------- Co-authored-by: Amani H. <109637146+xsn34kzx@users.noreply.github.com> Co-authored-by: damocleas <damocleas25@gmail.com>
This commit is contained in:
parent
a9ffe03804
commit
6c845cc0d3
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,7 @@ import type { Variant, VariantSet } from "#app/data/variant";
|
|||||||
import { variantData } from "#app/data/variant";
|
import { variantData } from "#app/data/variant";
|
||||||
import { speciesStarterCosts, POKERUS_STARTER_COUNT } from "#app/data/balance/starters";
|
import { speciesStarterCosts, POKERUS_STARTER_COUNT } from "#app/data/balance/starters";
|
||||||
import { SpeciesFormKey } from "#enums/species-form-key";
|
import { SpeciesFormKey } from "#enums/species-form-key";
|
||||||
|
import { starterPassiveAbilities } from "#app/data/balance/passives";
|
||||||
|
|
||||||
export enum Region {
|
export enum Region {
|
||||||
NORMAL,
|
NORMAL,
|
||||||
@ -230,6 +231,31 @@ export abstract class PokemonSpeciesForm {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get the passive ability of a Pokemon species
|
||||||
|
* @param formIndex The form index to use, defaults to form for this species instance
|
||||||
|
* @returns The id of the ability
|
||||||
|
*/
|
||||||
|
getPassiveAbility(formIndex?: number): Abilities {
|
||||||
|
if (Utils.isNullOrUndefined(formIndex)) {
|
||||||
|
formIndex = this.formIndex;
|
||||||
|
}
|
||||||
|
let starterSpeciesId = this.speciesId;
|
||||||
|
while (!(starterSpeciesId in starterPassiveAbilities) || !(formIndex in starterPassiveAbilities[starterSpeciesId])) {
|
||||||
|
if (pokemonPrevolutions.hasOwnProperty(starterSpeciesId)) {
|
||||||
|
starterSpeciesId = pokemonPrevolutions[starterSpeciesId];
|
||||||
|
} else { // If we've reached the base species and still haven't found a matching ability, use form 0 if possible
|
||||||
|
if (0 in starterPassiveAbilities[starterSpeciesId]) {
|
||||||
|
return starterPassiveAbilities[starterSpeciesId][0];
|
||||||
|
} else {
|
||||||
|
console.log("No passive ability found for %s, using run away", this.speciesId);
|
||||||
|
return Abilities.RUN_AWAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return starterPassiveAbilities[starterSpeciesId][formIndex];
|
||||||
|
}
|
||||||
|
|
||||||
getLevelMoves(): LevelMoves {
|
getLevelMoves(): LevelMoves {
|
||||||
if (pokemonSpeciesFormLevelMoves.hasOwnProperty(this.speciesId) && pokemonSpeciesFormLevelMoves[this.speciesId].hasOwnProperty(this.formIndex)) {
|
if (pokemonSpeciesFormLevelMoves.hasOwnProperty(this.speciesId) && pokemonSpeciesFormLevelMoves[this.speciesId].hasOwnProperty(this.formIndex)) {
|
||||||
return pokemonSpeciesFormLevelMoves[this.speciesId][this.formIndex].slice(0);
|
return pokemonSpeciesFormLevelMoves[this.speciesId][this.formIndex].slice(0);
|
||||||
|
@ -11,7 +11,6 @@ import { HighCritAttr, HitsTagAttr, applyMoveAttrs, FixedDamageAttr, VariableAtk
|
|||||||
import type { PokemonSpeciesForm } from "#app/data/pokemon-species";
|
import type { PokemonSpeciesForm } from "#app/data/pokemon-species";
|
||||||
import { default as PokemonSpecies, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species";
|
import { default as PokemonSpecies, getFusedSpeciesName, getPokemonSpecies, getPokemonSpeciesForm } from "#app/data/pokemon-species";
|
||||||
import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters";
|
import { getStarterValueFriendshipCap, speciesStarterCosts } from "#app/data/balance/starters";
|
||||||
import { starterPassiveAbilities } from "#app/data/balance/passives";
|
|
||||||
import type { Constructor } from "#app/utils";
|
import type { Constructor } from "#app/utils";
|
||||||
import { isNullOrUndefined, randSeedInt, type nil } from "#app/utils";
|
import { isNullOrUndefined, randSeedInt, type nil } from "#app/utils";
|
||||||
import * as Utils from "#app/utils";
|
import * as Utils from "#app/utils";
|
||||||
@ -1401,11 +1400,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
|||||||
return allAbilities[this.customPokemonData.passive];
|
return allAbilities[this.customPokemonData.passive];
|
||||||
}
|
}
|
||||||
|
|
||||||
let starterSpeciesId = this.species.speciesId;
|
return allAbilities[this.species.getPassiveAbility(this.formIndex)];
|
||||||
while (pokemonPrevolutions.hasOwnProperty(starterSpeciesId)) {
|
|
||||||
starterSpeciesId = pokemonPrevolutions[starterSpeciesId];
|
|
||||||
}
|
|
||||||
return allAbilities[starterPassiveAbilities[starterSpeciesId]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,7 +20,6 @@ import { pokemonFormLevelMoves, pokemonSpeciesLevelMoves } from "#app/data/balan
|
|||||||
import type PokemonSpecies from "#app/data/pokemon-species";
|
import type PokemonSpecies from "#app/data/pokemon-species";
|
||||||
import { allSpecies, getPokemonSpeciesForm, getPokerusStarters } from "#app/data/pokemon-species";
|
import { allSpecies, getPokemonSpeciesForm, getPokerusStarters } from "#app/data/pokemon-species";
|
||||||
import { getStarterValueFriendshipCap, speciesStarterCosts, POKERUS_STARTER_COUNT } from "#app/data/balance/starters";
|
import { getStarterValueFriendshipCap, speciesStarterCosts, POKERUS_STARTER_COUNT } from "#app/data/balance/starters";
|
||||||
import { starterPassiveAbilities } from "#app/data/balance/passives";
|
|
||||||
import { Type } from "#enums/type";
|
import { Type } from "#enums/type";
|
||||||
import { GameModes } from "#app/game-mode";
|
import { GameModes } from "#app/game-mode";
|
||||||
import type { DexAttrProps, DexEntry, StarterMoveset, StarterAttributes, StarterPreferences } from "#app/system/game-data";
|
import type { DexAttrProps, DexEntry, StarterMoveset, StarterAttributes, StarterPreferences } from "#app/system/game-data";
|
||||||
@ -1844,7 +1843,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
if (!(passiveAttr & PassiveAttr.UNLOCKED)) {
|
if (!(passiveAttr & PassiveAttr.UNLOCKED)) {
|
||||||
const passiveCost = getPassiveCandyCount(speciesStarterCosts[this.lastSpecies.speciesId]);
|
const passiveCost = getPassiveCandyCount(speciesStarterCosts[this.lastSpecies.speciesId]);
|
||||||
options.push({
|
options.push({
|
||||||
label: `x${passiveCost} ${i18next.t("starterSelectUiHandler:unlockPassive")} (${allAbilities[starterPassiveAbilities[this.lastSpecies.speciesId]].name})`,
|
label: `x${passiveCost} ${i18next.t("starterSelectUiHandler:unlockPassive")} (${allAbilities[this.lastSpecies.getPassiveAbility()].name})`,
|
||||||
handler: () => {
|
handler: () => {
|
||||||
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= passiveCost) {
|
if (Overrides.FREE_CANDY_UPGRADE_OVERRIDE || candyCount >= passiveCost) {
|
||||||
starterData.passiveAttr |= PassiveAttr.UNLOCKED | PassiveAttr.ENABLED;
|
starterData.passiveAttr |= PassiveAttr.UNLOCKED | PassiveAttr.ENABLED;
|
||||||
@ -3295,7 +3294,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
|
|||||||
this.pokemonAbilityText.setShadowColor(this.getTextColor(!isHidden ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GOLD, true));
|
this.pokemonAbilityText.setShadowColor(this.getTextColor(!isHidden ? TextStyle.SUMMARY_ALT : TextStyle.SUMMARY_GOLD, true));
|
||||||
|
|
||||||
const passiveAttr = globalScene.gameData.starterData[species.speciesId].passiveAttr;
|
const passiveAttr = globalScene.gameData.starterData[species.speciesId].passiveAttr;
|
||||||
const passiveAbility = allAbilities[starterPassiveAbilities[this.lastSpecies.speciesId]];
|
const passiveAbility = allAbilities[this.lastSpecies.getPassiveAbility(formIndex)];
|
||||||
|
|
||||||
if (this.pokemonAbilityText.visible) {
|
if (this.pokemonAbilityText.visible) {
|
||||||
if (this.activeTooltip === "ABILITY") {
|
if (this.activeTooltip === "ABILITY") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user