Skip to content

Commit dc2bf95

Browse files
committed
Illusion working but without AI
1 parent 77d5baa commit dc2bf95

File tree

5 files changed

+81
-22
lines changed

5 files changed

+81
-22
lines changed

src/data/ability.ts

+58-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { Command } from "../ui/command-ui-handler";
2323
import { BerryModifierType } from "#app/modifier/modifier-type";
2424
import { getPokeballName } from "./pokeball";
2525
import { Species } from "./enums/species";
26+
import PokemonSpecies, { getPokemonSpecies } from "./pokemon-species";
2627
import { BattlerIndex } from "#app/battle";
2728

2829
export class Ability implements Localizable {
@@ -3476,14 +3477,61 @@ export class IceFaceMoveImmunityAbAttr extends MoveImmunityAbAttr {
34763477

34773478
export class IllusionAbAttr extends PreSummonAbAttr {
34783479

3480+
public trueName: string;
3481+
34793482
applyPreSummon(pokemon: Pokemon, passive: boolean, party: Pokemon[]) {
3480-
//pokemon.addTag(BattlerTagType.ILLUSIONED);
3481-
pokemon.name = party.slice(-1)[0].name;
3482-
console.log("AAAAAAAAAAAAAA");
3483-
return true;
3483+
3484+
//Case when Zoroark already used illusion one someone
3485+
if (!!pokemon.illusion.name) {
3486+
return false;
3487+
}
3488+
3489+
if (pokemon.hasTrainer()) {
3490+
const aliveParty: Pokemon[] = [];
3491+
for (const pkmn of party) {
3492+
if (pkmn.isAllowedInBattle()) {
3493+
aliveParty.push(pkmn);
3494+
}
3495+
}
3496+
const lastPokemon: Pokemon = aliveParty.slice(-1)[0];
3497+
3498+
pokemon.illusion = {active: true, species: lastPokemon.species, name: pokemon.name};
3499+
pokemon.name = lastPokemon.name;
3500+
return true;
3501+
} else {
3502+
console.log("ALLO");
3503+
const availables = [Species.ENTEI, Species.RAIKOU, Species.SUICUNE];
3504+
const randomIllusion: PokemonSpecies = getPokemonSpecies(availables[Math.floor(Math.random()*3)]);
3505+
pokemon.illusion = {active: true, species: randomIllusion, name: pokemon.name};
3506+
pokemon.name = randomIllusion.name;
3507+
}
34843508
}
3509+
}
3510+
3511+
export class IllusionBreakAbAttr extends PostDefendAbAttr {
34853512

3513+
applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: Move, hitResult: HitResult, args: any[]): boolean | Promise<boolean> {
3514+
if (hitResult > 4) {
3515+
return false;
3516+
}
3517+
pokemon.illusion.active = false;
3518+
//pokemon.summonData.speciesForm = pokemon.getSpeciesForm();
3519+
pokemon.name = pokemon.species.name;
3520+
pokemon.scene.playSound("PRSFX- Transform");
3521+
3522+
pokemon.loadAssets(false).then(() => pokemon.playAnim());
3523+
3524+
//pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` transformed\ninto ${target.name}!`));
3525+
return true;
3526+
}
3527+
}
34863528

3529+
export class IllusionAfterBattle extends PostBattleAbAttr {
3530+
applyPostBattle(pokemon: Pokemon, passive: boolean, args: any[]): boolean {
3531+
//Reset illusion
3532+
pokemon.illusion = {active: false};
3533+
return true;
3534+
}
34873535
}
34883536

34893537
function applyAbAttrsInternal<TAttr extends AbAttr>(attrType: { new(...args: any[]): TAttr },
@@ -4152,8 +4200,12 @@ export function initAbilities() {
41524200
new Ability(Abilities.ILLUSION, 5)
41534201
.attr(UncopiableAbilityAbAttr)
41544202
.attr(UnswappableAbilityAbAttr)
4155-
.attr(IllusionAbAttr, true)
4156-
.unimplemented(),
4203+
//The pokemon get the illusion when summon
4204+
.attr(IllusionAbAttr, false)
4205+
//The pokemon loses his illusion when he is damaged by a move
4206+
.conditionalAttr((pokemon) => pokemon.illusion.active, IllusionBreakAbAttr)
4207+
//Zoroark can do illusion again after a battle
4208+
.attr(IllusionAfterBattle),
41574209
new Ability(Abilities.IMPOSTER, 5)
41584210
.attr(PostSummonTransformAbAttr)
41594211
.attr(UncopiableAbilityAbAttr),

src/field/pokemon.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
6060
public id: integer;
6161
public name: string;
6262
public species: PokemonSpecies;
63+
public illusion: {active: boolean, species?: PokemonSpecies, name?: string};
6364
public formIndex: integer;
6465
public abilityIndex: integer;
6566
public passive: boolean;
@@ -123,6 +124,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
123124
const randAbilityIndex = Utils.randSeedInt(2);
124125

125126
this.species = species;
127+
this.illusion = {active: false};
128+
126129
this.pokeball = dataSource?.pokeball || PokeballType.POKEBALL;
127130
this.level = level;
128131
this.abilityIndex = abilityIndex !== undefined
@@ -431,7 +434,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
431434
if (back === undefined) {
432435
back = this.isPlayer();
433436
}
434-
return this.getSpeciesForm(ignoreOverride).getSpriteId(this.getGender(ignoreOverride) === Gender.FEMALE, this.formIndex, this.shiny, this.variant, back);
437+
return this.getSpeciesForm(ignoreOverride, true).getSpriteId(this.getGender(ignoreOverride) === Gender.FEMALE, this.formIndex, this.shiny, this.variant, back);
435438
}
436439

437440
getSpriteKey(ignoreOverride?: boolean): string {
@@ -477,14 +480,17 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
477480
return this.getFusionSpeciesForm(ignoreOverride).getIconId(this.getFusionGender(ignoreOverride) === Gender.FEMALE, this.fusionFormIndex, this.fusionShiny, this.fusionVariant);
478481
}
479482

480-
getSpeciesForm(ignoreOverride?: boolean): PokemonSpeciesForm {
483+
getSpeciesForm(ignoreOverride?: boolean, illusion?: boolean): PokemonSpeciesForm {
484+
//ICITO
485+
const species: PokemonSpecies = illusion && this.illusion.active ? this.illusion.species : this.species;
486+
481487
if (!ignoreOverride && this.summonData?.speciesForm) {
482488
return this.summonData.speciesForm;
483489
}
484-
if (!this.species.forms?.length) {
485-
return this.species;
490+
if (!species.forms?.length) {
491+
return species;
486492
}
487-
return this.species.forms[this.formIndex];
493+
return species.forms[this.formIndex];
488494
}
489495

490496
getFusionSpeciesForm(ignoreOverride?: boolean): PokemonSpeciesForm {
@@ -843,7 +849,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
843849
return this.getLevelMoves(1, true).map(lm => lm[1]).filter(lm => !this.moveset.filter(m => m.moveId === lm).length).filter((move: Moves, i: integer, array: Moves[]) => array.indexOf(move) === i);
844850
}
845851

846-
getTypes(includeTeraType = false, forDefend: boolean = false, ignoreOverride?: boolean): Type[] {
852+
getTypes(includeTeraType = false, forDefend: boolean = false, ignoreOverride?: boolean, illusion: boolean = true): Type[] {
847853
const types = [];
848854

849855
if (includeTeraType) {
@@ -857,7 +863,8 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
857863
if (!ignoreOverride && this.summonData?.types) {
858864
this.summonData.types.forEach(t => types.push(t));
859865
} else {
860-
const speciesForm = this.getSpeciesForm(ignoreOverride);
866+
//ILLUSION /!\
867+
const speciesForm = this.getSpeciesForm(ignoreOverride, !forDefend && illusion);
861868

862869
types.push(speciesForm.type1);
863870

src/overrides.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const IMMEDIATE_HATCH_EGGS_OVERRIDE: boolean = false;
3939
// default 1000
4040
export const STARTING_MONEY_OVERRIDE: integer = 10000000;
4141
export const POKEBALL_OVERRIDE: { active: boolean, pokeballs: PokeballCounts } = {
42-
active: false,
42+
active: true,
4343
pokeballs: {
4444
[PokeballType.POKEBALL]: 5,
4545
[PokeballType.GREAT_BALL]: 0,
@@ -56,7 +56,7 @@ export const POKEBALL_OVERRIDE: { active: boolean, pokeballs: PokeballCounts } =
5656
// forms can be found in pokemon-species.ts
5757
export const STARTER_FORM_OVERRIDE: integer = 0;
5858
// default 5 or 20 for Daily
59-
export const STARTING_LEVEL_OVERRIDE: integer = 60;
59+
export const STARTING_LEVEL_OVERRIDE: integer = 100;
6060
/**
6161
* SPECIES OVERRIDE
6262
* will only apply to the first starter in your party or each enemy pokemon
@@ -68,21 +68,21 @@ export const ABILITY_OVERRIDE: Abilities = Abilities.NONE;
6868
export const PASSIVE_ABILITY_OVERRIDE: Abilities = Abilities.NONE;
6969
export const STATUS_OVERRIDE: StatusEffect = StatusEffect.NONE;
7070
export const GENDER_OVERRIDE: Gender = null;
71-
export const MOVESET_OVERRIDE: Array<Moves> = [Moves.NIGHT_DAZE, Moves.FLAMETHROWER];
71+
export const MOVESET_OVERRIDE: Array<Moves> = [];
7272
export const SHINY_OVERRIDE: boolean = false;
7373
export const VARIANT_OVERRIDE: Variant = 0;
7474

7575
/**
7676
* OPPONENT / ENEMY OVERRIDES
7777
*/
7878

79-
export const OPP_SPECIES_OVERRIDE: Species | integer = 0;
80-
export const OPP_LEVEL_OVERRIDE: number = 0;
79+
export const OPP_SPECIES_OVERRIDE: Species | integer = Species.ZOROARK;
80+
export const OPP_LEVEL_OVERRIDE: number = 5;
8181
export const OPP_ABILITY_OVERRIDE: Abilities = Abilities.NONE;
8282
export const OPP_PASSIVE_ABILITY_OVERRIDE = Abilities.NONE;
8383
export const OPP_STATUS_OVERRIDE: StatusEffect = StatusEffect.NONE;
8484
export const OPP_GENDER_OVERRIDE: Gender = null;
85-
export const OPP_MOVESET_OVERRIDE: Array<Moves> = [];
85+
export const OPP_MOVESET_OVERRIDE: Array<Moves> = [Moves.PSYCHIC, Moves.AURA_SPHERE];
8686
export const OPP_SHINY_OVERRIDE: boolean = false;
8787
export const OPP_VARIANT_OVERRIDE: Variant = 0;
8888

src/phases.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ export class SummonPhase extends PartyMemberPokemonPhase {
13111311
super.start();
13121312
//ICITO
13131313
const pokemon = this.getPokemon();
1314-
const party = pokemon.isPlayer() ? this.scene.getParty() : this.scene.getEnemyParty();
1314+
const party: Pokemon[] = pokemon.isPlayer() ? this.scene.getParty() : this.scene.getEnemyParty();
13151315
applyPreSummonAbAttrs(PreSummonAbAttr, pokemon, party).then(() => this.preSummon());
13161316
}
13171317

src/ui/summary-ui-handler.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export default class SummaryUiHandler extends UiHandler {
302302
});
303303
this.pokemon.cry();
304304

305-
this.nameText.setText(this.pokemon.name);
305+
this.nameText.setText(this.pokemon.illusion.active ? this.pokemon.illusion.name : this.pokemon.name);
306306

307307
const isFusion = this.pokemon.isFusion();
308308

@@ -707,7 +707,7 @@ export default class SummaryUiHandler extends UiHandler {
707707
return typeIcon;
708708
};
709709

710-
const types = this.pokemon.getTypes(false, false, true);
710+
const types = this.pokemon.getTypes(false, false, true, false);
711711
profileContainer.add(getTypeIcon(0, types[0]));
712712
if (types.length > 1) {
713713
profileContainer.add(getTypeIcon(1, types[1]));

0 commit comments

Comments
 (0)