diff --git a/src/data/trainer-config.ts b/src/data/trainer-config.ts index 3722e7b93f5..368255c2631 100644 --- a/src/data/trainer-config.ts +++ b/src/data/trainer-config.ts @@ -187,7 +187,7 @@ export class TrainerConfig { public isBoss: boolean = false; public hasStaticParty: boolean = false; public useSameSeedForAllMembers: boolean = false; - public forceTeraOffType: boolean = false; + public forceTeraFirstSlot: boolean = false; public mixedBattleBgm: string; public battleBgm: string; public encounterBgm: string; @@ -474,8 +474,8 @@ export class TrainerConfig { return this; } - setForceTeraOffType(): TrainerConfig { - this.forceTeraOffType = true; + setForceTeraFirstSlot(): TrainerConfig { + this.forceTeraFirstSlot = true; return this; } @@ -727,7 +727,7 @@ export class TrainerConfig { this.setVictoryBgm("victory_gym"); this.setGenModifiersFunc(party => { const waveIndex = party[0].scene.currentBattle.waveIndex; - return getRandomTeraModifiers(party, waveIndex >= 100 ? 1 : 0, specialtyType, this.forceTeraOffType); + return getRandomTeraModifiers(party, waveIndex >= 100 ? 1 : 0, specialtyType, this.forceTeraFirstSlot); }); return this; @@ -784,7 +784,7 @@ export class TrainerConfig { this.setHasVoucher(true); this.setBattleBgm("battle_unova_elite"); this.setVictoryBgm("victory_gym"); - this.setGenModifiersFunc(party => getRandomTeraModifiers(party, 2, specialtyType, this.forceTeraOffType)); + this.setGenModifiersFunc(party => getRandomTeraModifiers(party, 2, specialtyType, this.forceTeraFirstSlot)); return this; } @@ -993,31 +993,24 @@ function getSpeciesFilterRandomPartyMemberFunc(speciesFilter: PokemonSpeciesFilt * Function to get random Tera modifiers for enemy trainers * @param party {@linkcode EnemyPokemon} enemy trainer party * @param count {@linkcode integer} how many Teras you want the trainer to have - * @param types {@linkcode Type} array of types the trainer should Tera to (usually just one) - * @param forceTeraOffType {@linkcode boolean} Whether Trainer should attempt to Terastalize off-type mons + * @param type {@linkcode Type} desired Tera type + * @param forceTeraFirstSlot {@linkcode boolean} Whether Trainer should attempt to Terastalize the mon in the first slot of signature species * @returns {@linkcode PersistentModifier} an array of Tera modifiers for the enemy party */ -function getRandomTeraModifiers(party: EnemyPokemon[], count: integer, type?: Type, forceTeraOffType?: boolean): PersistentModifier[] { +function getRandomTeraModifiers(party: EnemyPokemon[], count: integer, type?: Type, forceTeraFirstSlot?: boolean): PersistentModifier[] { const ret: PersistentModifier[] = []; const partyMemberIndexes = new Array(party.length).fill(null).map((_, i) => i); - //If "forceTeraOffType" is true, count how many off-type mons to look for - let offTypes = (forceTeraOffType && type) ? party.filter((p) => { - return p.isOfType(type); - }).length : 0; - const teras = Math.max(offTypes, count); - //Apply teras until you run out of party members or expected teras - for (let t = 0; t < Math.min(teras, party.length); t++) { - const randomIndex = offTypes > 0 ? - //If there's still an off-type to look for, find the first party index where the mon is not of the specialty type - party.findIndex((p, i) => { - if (partyMemberIndexes.includes(i) && p.isOfType(type)) { - --offTypes; - return true; - } - return false; - }) - //Otherwise, get a random party member index - : Utils.randSeedItem(partyMemberIndexes); + let t = 0; // Move this out of the for loop in case there's a forced tera slot + if (type && forceTeraFirstSlot) { // If there's a designated tera slot, essentially do an iteration of the for loop below with a set index and without checking count + const forcedTeraSlot = party.length - 1; + if (forcedTeraSlot && forcedTeraSlot >= 0) { + partyMemberIndexes.splice(partyMemberIndexes.indexOf(forcedTeraSlot), 1); + ret.push(modifierTypes.TERA_SHARD().generateType([], [type])!.withIdFromFunc(modifierTypes.TERA_SHARD).newModifier(party[forcedTeraSlot]) as PersistentModifier); // TODO: is the bang correct? + t++; + } + } + for (; t < Math.min(count, party.length); t++) { + const randomIndex = Utils.randSeedItem(partyMemberIndexes); partyMemberIndexes.splice(partyMemberIndexes.indexOf(randomIndex), 1); ret.push(modifierTypes.TERA_SHARD().generateType([], [Utils.randSeedItem(type ? [type] : party[randomIndex].getTypes())])!.withIdFromFunc(modifierTypes.TERA_SHARD).newModifier(party[randomIndex]) as PersistentModifier); // TODO: is the bang correct? } @@ -1067,7 +1060,7 @@ export const signatureSpecies: SignatureSpecies = { FANTINA: [Species.MISDREAVUS, Species.DRIFLOON, Species.DUSKULL], BYRON: [Species.SHIELDON, Species.BRONZOR, Species.ARON], CANDICE: [Species.SNEASEL, Species.SNOVER, Species.SNORUNT], - VOLKNER: [Species.SHINX, Species.JOLTEON, Species.REMORAID, Species.ELECTABUZZ], + VOLKNER: [Species.SHINX, Species.JOLTEON, Species.ELECTABUZZ], CILAN: [Species.PANSAGE, Species.FOONGUS, Species.MARACTUS], CHILI: [Species.PANSEAR, Species.DARUMAKA, Species.HEATMOR], CRESS: [Species.PANPOUR, Species.SLOWPOKE, Species.BASCULIN], @@ -1101,14 +1094,14 @@ export const signatureSpecies: SignatureSpecies = { PIERS: [Species.GALAR_ZIGZAGOON, Species.SCRAGGY, Species.INKAY], MARNIE: [Species.IMPIDIMP, Species.PURRLOIN, Species.MORPEKO], RAIHAN: [Species.DURALUDON, Species.TRAPINCH, Species.TURTONATOR], - KATY: [Species.NYMBLE, Species.TAROUNTULA, Species.TEDDIURSA], - BRASSIUS: [Species.SMOLIV, Species.BRAMBLIN, Species.SUDOWOODO], - IONO: [Species.TADBULB, Species.WATTREL, Species.MISDREAVUS], - KOFU: [Species.VELUZA, Species.WIGLETT, Species.CRABRAWLER], - LARRY: [Species.STARLY, Species.DUNSPARCE, Species.KOMALA], - RYME: [Species.GREAVARD, Species.SHUPPET, Species.MIMIKYU, Species.TOXTRICITY], - TULIP: [Species.GIRAFARIG, Species.FLITTLE, Species.RALTS, Species.FLABEBE], - GRUSHA: [Species.CETODDLE, Species.ALOLA_VULPIX, Species.CUBCHOO, Species.SWABLU], + KATY: [Species.TEDDIURSA, Species.NYMBLE, Species.TAROUNTULA], + BRASSIUS: [Species.SUDOWOODO, Species.SMOLIV, Species.BRAMBLIN], + IONO: [Species.MISDREAVUS, Species.TADBULB, Species.WATTREL], + KOFU: [Species.CRABRAWLER, Species.VELUZA, Species.WIGLETT], + LARRY: [Species.DUNSPARCE, Species.STARLY, Species.KOMALA], + RYME: [Species.TOXEL, Species.GREAVARD, Species.SHUPPET, Species.MIMIKYU], + TULIP: [Species.FLABEBE, Species.GIRAFARIG, Species.FLITTLE, Species.RALTS], + GRUSHA: [Species.SWABLU, Species.CETODDLE, Species.ALOLA_VULPIX, Species.CUBCHOO], LORELEI: [Species.JYNX, [Species.SLOWBRO, Species.GALAR_SLOWBRO], Species.LAPRAS, [Species.ALOLA_SANDSLASH, Species.CLOYSTER]], BRUNO: [Species.MACHAMP, Species.HITMONCHAN, Species.HITMONLEE, [Species.ALOLA_GOLEM, Species.GOLEM]], AGATHA: [Species.GENGAR, [Species.ARBOK, Species.WEEZING], Species.CROBAT, Species.ALOLA_MAROWAK], @@ -1399,7 +1392,7 @@ export const trainerConfigs: TrainerConfigs = { [TrainerType.GIOVANNI]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["GIOVANNI"], true, Type.GROUND).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), [TrainerType.FALKNER]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["FALKNER"], true, Type.FLYING).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), [TrainerType.BUGSY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BUGSY"], true, Type.BUG).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), - [TrainerType.WHITNEY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["WHITNEY"], false, Type.NORMAL).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym").setForceTeraOffType(), + [TrainerType.WHITNEY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["WHITNEY"], false, Type.NORMAL).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), [TrainerType.MORTY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["MORTY"], true, Type.GHOST).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), [TrainerType.CHUCK]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CHUCK"], true, Type.FIGHTING).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), [TrainerType.JASMINE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["JASMINE"], false, Type.STEEL).setBattleBgm("battle_johto_gym").setMixedBattleBgm("battle_johto_gym"), @@ -1421,7 +1414,7 @@ export const trainerConfigs: TrainerConfigs = { [TrainerType.FANTINA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["FANTINA"], false, Type.GHOST).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), [TrainerType.BYRON]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BYRON"], true, Type.STEEL).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), [TrainerType.CANDICE]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CANDICE"], false, Type.ICE).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.VOLKNER]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["VOLKNER"], true, Type.ELECTRIC).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym").setForceTeraOffType(), + [TrainerType.VOLKNER]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["VOLKNER"], true, Type.ELECTRIC).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), [TrainerType.CILAN]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CILAN"], true, Type.GRASS).setMixedBattleBgm("battle_unova_gym"), [TrainerType.CHILI]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CHILI"], true, Type.FIRE).setMixedBattleBgm("battle_unova_gym"), [TrainerType.CRESS]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["CRESS"], true, Type.WATER).setMixedBattleBgm("battle_unova_gym"), @@ -1455,14 +1448,14 @@ export const trainerConfigs: TrainerConfigs = { [TrainerType.PIERS]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["PIERS"], true, Type.DARK).setHasDouble("piers_marnie_double").setDoubleTrainerType(TrainerType.MARNIE).setDoubleTitle("gym_leader_double").setMixedBattleBgm("battle_galar_gym"), [TrainerType.MARNIE]: new TrainerConfig(++t).setName("Marnie").initForGymLeader(signatureSpecies["MARNIE"], false, Type.DARK).setHasDouble("marnie_piers_double").setDoubleTrainerType(TrainerType.PIERS).setDoubleTitle("gym_leader_double").setMixedBattleBgm("battle_galar_gym"), [TrainerType.RAIHAN]: new TrainerConfig(++t).setName("Raihan").initForGymLeader(signatureSpecies["RAIHAN"], true, Type.DRAGON).setMixedBattleBgm("battle_galar_gym"), - [TrainerType.KATY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["KATY"], false, Type.BUG).setMixedBattleBgm("battle_paldea_gym").setForceTeraOffType(), - [TrainerType.BRASSIUS]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BRASSIUS"], true, Type.GRASS).setMixedBattleBgm("battle_paldea_gym").setForceTeraOffType(), - [TrainerType.IONO]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["IONO"], false, Type.ELECTRIC).setMixedBattleBgm("battle_paldea_gym").setForceTeraOffType(), - [TrainerType.KOFU]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["KOFU"], true, Type.WATER).setMixedBattleBgm("battle_paldea_gym").setForceTeraOffType(), - [TrainerType.LARRY]: new TrainerConfig(++t).setName("Larry").initForGymLeader(signatureSpecies["LARRY"], true, Type.NORMAL).setMixedBattleBgm("battle_paldea_gym").setForceTeraOffType(), - [TrainerType.RYME]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["RYME"], false, Type.GHOST).setMixedBattleBgm("battle_paldea_gym").setForceTeraOffType(), - [TrainerType.TULIP]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["TULIP"], false, Type.PSYCHIC).setMixedBattleBgm("battle_paldea_gym").setForceTeraOffType(), - [TrainerType.GRUSHA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["GRUSHA"], true, Type.ICE).setMixedBattleBgm("battle_paldea_gym").setForceTeraOffType(), + [TrainerType.KATY]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["KATY"], false, Type.BUG).setMixedBattleBgm("battle_paldea_gym").setForceTeraFirstSlot(), + [TrainerType.BRASSIUS]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["BRASSIUS"], true, Type.GRASS).setMixedBattleBgm("battle_paldea_gym").setForceTeraFirstSlot(), + [TrainerType.IONO]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["IONO"], false, Type.ELECTRIC).setMixedBattleBgm("battle_paldea_gym").setForceTeraFirstSlot(), + [TrainerType.KOFU]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["KOFU"], true, Type.WATER).setMixedBattleBgm("battle_paldea_gym").setForceTeraFirstSlot(), + [TrainerType.LARRY]: new TrainerConfig(++t).setName("Larry").initForGymLeader(signatureSpecies["LARRY"], true, Type.NORMAL).setMixedBattleBgm("battle_paldea_gym").setForceTeraFirstSlot(), + [TrainerType.RYME]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["RYME"], false, Type.GHOST).setMixedBattleBgm("battle_paldea_gym").setForceTeraFirstSlot(), + [TrainerType.TULIP]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["TULIP"], false, Type.PSYCHIC).setMixedBattleBgm("battle_paldea_gym").setForceTeraFirstSlot(), + [TrainerType.GRUSHA]: new TrainerConfig(++t).initForGymLeader(signatureSpecies["GRUSHA"], true, Type.ICE).setMixedBattleBgm("battle_paldea_gym").setForceTeraFirstSlot(), [TrainerType.LORELEI]: new TrainerConfig((t = TrainerType.LORELEI)).initForEliteFour(signatureSpecies["LORELEI"], false, Type.ICE).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), [TrainerType.BRUNO]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["BRUNO"], true, Type.FIGHTING).setBattleBgm("battle_kanto_gym").setMixedBattleBgm("battle_kanto_gym"), @@ -1477,7 +1470,7 @@ export const trainerConfigs: TrainerConfigs = { [TrainerType.DRAKE]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["DRAKE"], true, Type.DRAGON).setMixedBattleBgm("battle_hoenn_elite"), [TrainerType.AARON]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["AARON"], true, Type.BUG).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), [TrainerType.BERTHA]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["BERTHA"], false, Type.GROUND).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), - [TrainerType.FLINT]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["FLINT"], true, Type.FIRE).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym").setForceTeraOffType(), + [TrainerType.FLINT]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["FLINT"], true, Type.FIRE).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), [TrainerType.LUCIAN]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["LUCIAN"], true, Type.PSYCHIC).setBattleBgm("battle_sinnoh_gym").setMixedBattleBgm("battle_sinnoh_gym"), [TrainerType.SHAUNTAL]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["SHAUNTAL"], false, Type.GHOST).setMixedBattleBgm("battle_unova_elite"), [TrainerType.MARSHAL]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["MARSHAL"], true, Type.FIGHTING).setMixedBattleBgm("battle_unova_elite"), @@ -1503,8 +1496,8 @@ export const trainerConfigs: TrainerConfigs = { [TrainerType.HASSEL]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["HASSEL"], true, Type.DRAGON).setMixedBattleBgm("battle_paldea_elite"), [TrainerType.CRISPIN]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["CRISPIN"], true, Type.FIRE).setMixedBattleBgm("battle_bb_elite"), [TrainerType.AMARYS]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["AMARYS"], false, Type.STEEL).setMixedBattleBgm("battle_bb_elite"), - [TrainerType.LACEY]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["LACEY"], false, Type.FAIRY).setMixedBattleBgm("battle_bb_elite").setForceTeraOffType(), - [TrainerType.DRAYTON]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["DRAYTON"], true, Type.DRAGON).setMixedBattleBgm("battle_bb_elite").setForceTeraOffType(), + [TrainerType.LACEY]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["LACEY"], false, Type.FAIRY).setMixedBattleBgm("battle_bb_elite").setForceTeraFirstSlot(), + [TrainerType.DRAYTON]: new TrainerConfig(++t).initForEliteFour(signatureSpecies["DRAYTON"], true, Type.DRAGON).setMixedBattleBgm("battle_bb_elite"), [TrainerType.BLUE]: new TrainerConfig((t = TrainerType.BLUE)).initForChampion(signatureSpecies["BLUE"], true).setBattleBgm("battle_kanto_champion").setMixedBattleBgm("battle_kanto_champion").setHasDouble("blue_red_double").setDoubleTrainerType(TrainerType.RED).setDoubleTitle("champion_double") .setPartyMemberFunc(0, getRandomPartyMemberFunc([Species.ALAKAZAM], TrainerSlot.TRAINER, true, p => {