@@ -60,7 +60,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
60
60
public id : integer ;
61
61
public name : string ;
62
62
public species : PokemonSpecies ;
63
- public illusion : { active : boolean , species ?: PokemonSpecies , name ?: string } ;
63
+ public illusion : { active : boolean , available : boolean , species ?: PokemonSpecies , name ?: string , fusionSpecies ?: PokemonSpecies } ;
64
64
public formIndex : integer ;
65
65
public abilityIndex : integer ;
66
66
public passive : boolean ;
@@ -124,7 +124,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
124
124
const randAbilityIndex = Utils . randSeedInt ( 2 ) ;
125
125
126
126
this . species = species ;
127
- this . illusion = { active : false } ;
127
+ this . illusion = { active : false , available : true } ;
128
128
129
129
this . pokeball = dataSource ?. pokeball || PokeballType . POKEBALL ;
130
130
this . level = level ;
@@ -308,6 +308,29 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
308
308
}
309
309
}
310
310
311
+ generateIllusion ( pokemon : Pokemon , party : Pokemon [ ] ) : void {
312
+ if ( pokemon . hasTrainer ( ) ) {
313
+ const lastPokemon : Pokemon = party . slice ( - 1 ) [ 0 ] ;
314
+ const speciesId = lastPokemon . species . speciesId ;
315
+ pokemon . illusion = {
316
+ active : true ,
317
+ available : true ,
318
+ species : getPokemonSpecies ( speciesId ) ,
319
+ fusionSpecies : lastPokemon . fusionSpecies ,
320
+ name : pokemon . name
321
+ } ;
322
+ pokemon . name = lastPokemon . name ;
323
+ pokemon . loadAssets ( false ) . then ( ( ) => pokemon . playAnim ( ) ) ;
324
+ } else {
325
+ const availables = [ Species . ENTEI , Species . RAIKOU , Species . SUICUNE ] ;
326
+ const randomIllusion : PokemonSpecies = getPokemonSpecies ( availables [ Math . floor ( Math . random ( ) * 3 ) ] ) ;
327
+ pokemon . illusion = { active : true , available : true , species : randomIllusion , name : pokemon . name } ;
328
+ pokemon . name = randomIllusion . name ;
329
+ pokemon . loadAssets ( false ) . then ( ( ) => pokemon . playAnim ( ) ) ;
330
+ }
331
+
332
+ }
333
+
311
334
abstract isPlayer ( ) : boolean ;
312
335
313
336
abstract hasTrainer ( ) : boolean ;
@@ -322,7 +345,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
322
345
Promise . allSettled ( moveIds . map ( m => initMoveAnim ( this . scene , m ) ) )
323
346
. then ( ( ) => {
324
347
loadMoveAnimAssets ( this . scene , moveIds ) ;
325
- this . getSpeciesForm ( ) . loadAssets ( this . scene , this . getGender ( ) === Gender . FEMALE , this . formIndex , this . shiny , this . variant ) ;
348
+ this . getSpeciesForm ( false , true ) . loadAssets ( this . scene , this . getGender ( ) === Gender . FEMALE , this . formIndex , this . shiny , this . variant ) ;
326
349
if ( this . isPlayer ( ) || this . getFusionSpeciesForm ( ) ) {
327
350
this . scene . loadPokemonAtlas ( this . getBattleSpriteKey ( true , ignoreOverride ) , this . getBattleSpriteAtlasPath ( true , ignoreOverride ) ) ;
328
351
}
@@ -427,7 +450,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
427
450
}
428
451
429
452
getSpriteId ( ignoreOverride ?: boolean ) : string {
430
- return this . getSpeciesForm ( ignoreOverride ) . getSpriteId ( this . getGender ( ignoreOverride ) === Gender . FEMALE , this . formIndex , this . shiny , this . variant ) ;
453
+ return this . getSpeciesForm ( ignoreOverride , true ) . getSpriteId ( this . getGender ( ignoreOverride ) === Gender . FEMALE , this . formIndex , this . shiny , this . variant ) ;
431
454
}
432
455
433
456
getBattleSpriteId ( back ?: boolean , ignoreOverride ?: boolean ) : string {
@@ -438,7 +461,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
438
461
}
439
462
440
463
getSpriteKey ( ignoreOverride ?: boolean ) : string {
441
- return this . getSpeciesForm ( ignoreOverride ) . getSpriteKey ( this . getGender ( ignoreOverride ) === Gender . FEMALE , this . formIndex , this . shiny , this . variant ) ;
464
+ return this . getSpeciesForm ( ignoreOverride , false ) . getSpriteKey ( this . getGender ( ignoreOverride ) === Gender . FEMALE , this . formIndex , this . shiny , this . variant ) ;
442
465
}
443
466
444
467
getBattleSpriteKey ( back ?: boolean , ignoreOverride ?: boolean ) : string {
@@ -465,42 +488,42 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
465
488
}
466
489
467
490
getIconAtlasKey ( ignoreOverride ?: boolean ) : string {
468
- return this . getSpeciesForm ( ignoreOverride ) . getIconAtlasKey ( this . formIndex , this . shiny , this . variant ) ;
491
+ return this . getSpeciesForm ( ignoreOverride , true ) . getIconAtlasKey ( this . formIndex , this . shiny , this . variant ) ;
469
492
}
470
493
471
494
getFusionIconAtlasKey ( ignoreOverride ?: boolean ) : string {
472
- return this . getFusionSpeciesForm ( ignoreOverride ) . getIconAtlasKey ( this . fusionFormIndex , this . fusionShiny , this . fusionVariant ) ;
495
+ return this . getFusionSpeciesForm ( ignoreOverride , true ) . getIconAtlasKey ( this . fusionFormIndex , this . fusionShiny , this . fusionVariant ) ;
473
496
}
474
497
475
498
getIconId ( ignoreOverride ?: boolean ) : string {
476
- return this . getSpeciesForm ( ignoreOverride ) . getIconId ( this . getGender ( ignoreOverride ) === Gender . FEMALE , this . formIndex , this . shiny , this . variant ) ;
499
+ return this . getSpeciesForm ( ignoreOverride , true ) . getIconId ( this . getGender ( ignoreOverride ) === Gender . FEMALE , this . formIndex , this . shiny , this . variant ) ;
477
500
}
478
501
479
502
getFusionIconId ( ignoreOverride ?: boolean ) : string {
480
- return this . getFusionSpeciesForm ( ignoreOverride ) . getIconId ( this . getFusionGender ( ignoreOverride ) === Gender . FEMALE , this . fusionFormIndex , this . fusionShiny , this . fusionVariant ) ;
503
+ return this . getFusionSpeciesForm ( ignoreOverride , true ) . getIconId ( this . getFusionGender ( ignoreOverride ) === Gender . FEMALE , this . fusionFormIndex , this . fusionShiny , this . fusionVariant ) ;
481
504
}
482
505
483
- getSpeciesForm ( ignoreOverride ?: boolean , illusion ?: boolean ) : PokemonSpeciesForm {
484
- //ICITO
506
+ getSpeciesForm ( ignoreOverride ?: boolean , illusion : boolean = false ) : PokemonSpeciesForm {
485
507
const species : PokemonSpecies = illusion && this . illusion . active ? this . illusion . species : this . species ;
486
-
487
508
if ( ! ignoreOverride && this . summonData ?. speciesForm ) {
488
509
return this . summonData . speciesForm ;
489
510
}
511
+
490
512
if ( ! species . forms ?. length ) {
491
513
return species ;
492
514
}
493
515
return species . forms [ this . formIndex ] ;
494
516
}
495
517
496
- getFusionSpeciesForm ( ignoreOverride ?: boolean ) : PokemonSpeciesForm {
518
+ getFusionSpeciesForm ( ignoreOverride ?: boolean , illusion : boolean = false ) : PokemonSpeciesForm {
519
+ const fusionSpecies : PokemonSpecies = illusion && this . illusion . active ? ( this . illusion . fusionSpecies ?? this . illusion . species ) : this . fusionSpecies ;
497
520
if ( ! ignoreOverride && this . summonData ?. speciesForm ) {
498
521
return this . summonData . fusionSpeciesForm ;
499
522
}
500
- if ( ! this . fusionSpecies ?. forms ?. length || this . fusionFormIndex >= this . fusionSpecies ?. forms . length ) {
501
- return this . fusionSpecies ;
523
+ if ( ! fusionSpecies ?. forms ?. length || this . fusionFormIndex >= fusionSpecies ?. forms . length ) {
524
+ return fusionSpecies ;
502
525
}
503
- return this . fusionSpecies ?. forms [ this . fusionFormIndex ] ;
526
+ return fusionSpecies ?. forms [ this . fusionFormIndex ] ;
504
527
}
505
528
506
529
getSprite ( ) : Phaser . GameObjects . Sprite {
@@ -849,34 +872,31 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
849
872
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 ) ;
850
873
}
851
874
852
- getTypes ( includeTeraType = false , forDefend : boolean = false , ignoreOverride ?: boolean , illusion : boolean = true ) : Type [ ] {
853
- const types = [ ] ;
854
-
875
+ getTypes ( includeTeraType = false , forDefend : boolean = false , ignoreOverride ?: boolean , illusion : boolean | "AUTO" = "AUTO" ) : Type [ ] {
876
+ const types : Type [ ] = [ ] ;
855
877
if ( includeTeraType ) {
856
878
const teraType = this . getTeraType ( ) ;
857
879
if ( teraType !== Type . UNKNOWN ) {
858
880
types . push ( teraType ) ;
859
881
}
860
882
}
861
-
862
883
if ( ! types . length || ! includeTeraType ) {
863
884
if ( ! ignoreOverride && this . summonData ?. types ) {
864
885
this . summonData . types . forEach ( t => types . push ( t ) ) ;
865
886
} else {
866
- //ILLUSION /!\
867
- const speciesForm = this . getSpeciesForm ( ignoreOverride , ! forDefend && illusion ) ;
887
+ const doIllusion : boolean = illusion === "AUTO" ? ! forDefend : illusion ;
868
888
869
- types . push ( speciesForm . type1 ) ;
889
+ const speciesForm = this . getSpeciesForm ( ignoreOverride , doIllusion ) ;
870
890
871
- const fusionSpeciesForm = this . getFusionSpeciesForm ( ignoreOverride ) ;
891
+ types . push ( speciesForm . type1 ) ;
892
+ const fusionSpeciesForm = this . getFusionSpeciesForm ( ignoreOverride , doIllusion ) ;
872
893
if ( fusionSpeciesForm ) {
873
894
if ( fusionSpeciesForm . type2 !== null && fusionSpeciesForm . type2 !== speciesForm . type1 ) {
874
895
types . push ( fusionSpeciesForm . type2 ) ;
875
896
} else if ( fusionSpeciesForm . type1 !== speciesForm . type1 ) {
876
897
types . push ( fusionSpeciesForm . type1 ) ;
877
898
}
878
899
}
879
-
880
900
if ( types . length === 1 && speciesForm . type2 !== null ) {
881
901
types . push ( speciesForm . type2 ) ;
882
902
}
@@ -900,7 +920,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
900
920
types . splice ( index , 1 ) ;
901
921
}
902
922
}
903
-
904
923
return types ;
905
924
}
906
925
@@ -1087,10 +1106,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
1087
1106
return this . getAttackMoveEffectiveness ( source , move ) ;
1088
1107
}
1089
1108
1090
- getAttackMoveEffectiveness ( source : Pokemon , pokemonMove : PokemonMove ) : TypeDamageMultiplier {
1109
+ getAttackMoveEffectiveness ( source : Pokemon , pokemonMove : PokemonMove , illusion : boolean = false ) : TypeDamageMultiplier {
1091
1110
const move = pokemonMove . getMove ( ) ;
1092
1111
const typeless = move . hasAttr ( TypelessAttr ) ;
1093
- const typeMultiplier = new Utils . NumberHolder ( this . getAttackTypeEffectiveness ( move . type , source ) ) ;
1112
+ const typeMultiplier = new Utils . NumberHolder ( this . getAttackTypeEffectiveness ( move . type , source , undefined , illusion ) ) ;
1094
1113
const cancelled = new Utils . BooleanHolder ( false ) ;
1095
1114
applyMoveAttrs ( VariableMoveTypeMultiplierAttr , source , this , move , typeMultiplier ) ;
1096
1115
if ( ! typeless ) {
@@ -1102,11 +1121,11 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
1102
1121
return ( ! cancelled . value ? typeMultiplier . value : 0 ) as TypeDamageMultiplier ;
1103
1122
}
1104
1123
1105
- getAttackTypeEffectiveness ( moveType : Type , source ?: Pokemon , ignoreStrongWinds : boolean = false ) : TypeDamageMultiplier {
1124
+ getAttackTypeEffectiveness ( moveType : Type , source ?: Pokemon , ignoreStrongWinds : boolean = false , illusion : boolean = false ) : TypeDamageMultiplier {
1106
1125
if ( moveType === Type . STELLAR ) {
1107
1126
return this . isTerastallized ( ) ? 2 : 1 ;
1108
1127
}
1109
- const types = this . getTypes ( true , true ) ;
1128
+ const types = this . getTypes ( true , true , undefined , illusion ) ;
1110
1129
1111
1130
let multiplier = types . map ( defType => {
1112
1131
if ( source ) {
@@ -3434,7 +3453,7 @@ export class EnemyPokemon extends Pokemon {
3434
3453
if ( ( move . name . endsWith ( " (N)" ) || ! move . applyConditions ( this , target , move ) ) && ! [ Moves . SUCKER_PUNCH , Moves . UPPER_HAND , Moves . THUNDERCLAP ] . includes ( move . id ) ) {
3435
3454
targetScore = - 20 ;
3436
3455
} else if ( move instanceof AttackMove ) {
3437
- const effectiveness = target . getAttackMoveEffectiveness ( this , pokemonMove ) ;
3456
+ const effectiveness = target . getAttackMoveEffectiveness ( this , pokemonMove , true ) ;
3438
3457
if ( target . isPlayer ( ) !== this . isPlayer ( ) ) {
3439
3458
targetScore *= effectiveness ;
3440
3459
if ( this . isOfType ( move . type ) ) {
0 commit comments