Implement hidden abilities and ability charm

This commit is contained in:
Flashfyre 2023-10-29 22:18:02 -04:00
parent d503834758
commit 2c17efca9b
8 changed files with 2008 additions and 1956 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 466 B

View File

@ -669,6 +669,7 @@ export const modifierTypes = {
(type, args) => new Modifiers.SwitchEffectTransferModifier(type, (args[0] as Pokemon).id), 'stick'), (type, args) => new Modifiers.SwitchEffectTransferModifier(type, (args[0] as Pokemon).id), 'stick'),
SHINY_CHARM: () => new ModifierType('Shiny Charm', 'Dramatically increases the chance of a wild Pokémon being shiny', (type, _args) => new Modifiers.ShinyRateBoosterModifier(type)), SHINY_CHARM: () => new ModifierType('Shiny Charm', 'Dramatically increases the chance of a wild Pokémon being shiny', (type, _args) => new Modifiers.ShinyRateBoosterModifier(type)),
ABILITY_CHARM: () => new ModifierType('Ability Charm', 'Dramatically increases the chance of a wild Pokémon having a hidden ability', (type, _args) => new Modifiers.HiddenAbilityRateBoosterModifier(type)),
MINI_BLACK_HOLE: () => new TurnHeldItemTransferModifierType('Mini Black Hole'), MINI_BLACK_HOLE: () => new TurnHeldItemTransferModifierType('Mini Black Hole'),
@ -770,6 +771,7 @@ const modifierPool = {
new WeightedModifierType(modifierTypes.BERRY_POUCH, 3), new WeightedModifierType(modifierTypes.BERRY_POUCH, 3),
new WeightedModifierType(modifierTypes.EXP_CHARM, 4), new WeightedModifierType(modifierTypes.EXP_CHARM, 4),
new WeightedModifierType(modifierTypes.OVAL_CHARM, 2), new WeightedModifierType(modifierTypes.OVAL_CHARM, 2),
new WeightedModifierType(modifierTypes.ABILITY_CHARM, 2),
new WeightedModifierType(modifierTypes.EXP_BALANCE, 1), new WeightedModifierType(modifierTypes.EXP_BALANCE, 1),
].map(m => { m.setTier(ModifierTier.ULTRA); return m; }), ].map(m => { m.setTier(ModifierTier.ULTRA); return m; }),
[ModifierTier.MASTER]: [ [ModifierTier.MASTER]: [

View File

@ -1050,6 +1050,30 @@ export class ExpBalanceModifier extends PersistentModifier {
} }
} }
export class HiddenAbilityRateBoosterModifier extends PersistentModifier {
constructor(type: ModifierType, stackCount?: integer) {
super(type, stackCount);
}
match(modifier: Modifier): boolean {
return modifier instanceof HiddenAbilityRateBoosterModifier;
}
clone(): HiddenAbilityRateBoosterModifier {
return new HiddenAbilityRateBoosterModifier(this.type, this.stackCount);
}
apply(args: any[]): boolean {
(args[0] as Utils.IntegerHolder).value *= Math.pow(2, -1 - this.getStackCount());
return true;
}
getMaxStackCount(): integer {
return 4;
}
}
export class ShinyRateBoosterModifier extends PersistentModifier { export class ShinyRateBoosterModifier extends PersistentModifier {
constructor(type: ModifierType, stackCount?: integer) { constructor(type: ModifierType, stackCount?: integer) {
super(type, stackCount); super(type, stackCount);

View File

@ -8,7 +8,7 @@ import * as Utils from './utils';
import { Type, TypeDamageMultiplier, getTypeDamageMultiplier } from './data/type'; import { Type, TypeDamageMultiplier, getTypeDamageMultiplier } from './data/type';
import { getLevelTotalExp } from './data/exp'; import { getLevelTotalExp } from './data/exp';
import { Stat } from './data/pokemon-stat'; import { Stat } from './data/pokemon-stat';
import { AttackTypeBoosterModifier, EnemyDamageBoosterModifier, EnemyDamageReducerModifier, PokemonBaseStatModifier, PokemonHeldItemModifier, ShinyRateBoosterModifier, SurviveDamageModifier, TempBattleStatBoosterModifier } from './modifier/modifier'; import { AttackTypeBoosterModifier, EnemyDamageBoosterModifier, EnemyDamageReducerModifier, HiddenAbilityRateBoosterModifier, PokemonBaseStatModifier, PokemonHeldItemModifier, ShinyRateBoosterModifier, SurviveDamageModifier, TempBattleStatBoosterModifier } from './modifier/modifier';
import { PokeballType } from './data/pokeball'; import { PokeballType } from './data/pokeball';
import { Gender } from './data/gender'; import { Gender } from './data/gender';
import { initMoveAnim, loadMoveAnimAssets } from './data/battle-anims'; import { initMoveAnim, loadMoveAnimAssets } from './data/battle-anims';
@ -74,6 +74,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
if (!species.isObtainable() && this.isPlayer()) if (!species.isObtainable() && this.isPlayer())
throw `Cannot create a player Pokemon for species '${species.name}'`; throw `Cannot create a player Pokemon for species '${species.name}'`;
const hiddenAbilityChance = new Utils.IntegerHolder(256);
if (!this.hasTrainer())
this.scene.applyModifiers(HiddenAbilityRateBoosterModifier, true, hiddenAbilityChance);
const hasHiddenAbility = !Utils.randSeedInt(hiddenAbilityChance.value);
const randAbilityIndex = Utils.randSeedInt(2);
this.name = species.name; this.name = species.name;
this.species = species; this.species = species;
this.battleInfo = this.isPlayer() this.battleInfo = this.isPlayer()
@ -81,7 +88,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
: new EnemyBattleInfo(scene); : new EnemyBattleInfo(scene);
this.pokeball = dataSource?.pokeball || PokeballType.POKEBALL; this.pokeball = dataSource?.pokeball || PokeballType.POKEBALL;
this.level = level; this.level = level;
this.abilityIndex = abilityIndex || (species.ability2 ? Utils.randInt(2) : 0); this.abilityIndex = abilityIndex || (species.abilityHidden && hasHiddenAbility ? species.abilityHidden : species.ability2 ? randAbilityIndex : 0);
this.formIndex = formIndex || 0; this.formIndex = formIndex || 0;
if (gender !== undefined) if (gender !== undefined)
this.gender = gender; this.gender = gender;
@ -110,8 +117,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
Utils.binToDec(Utils.decToBin(this.id).substring(20, 25)), Utils.binToDec(Utils.decToBin(this.id).substring(20, 25)),
Utils.binToDec(Utils.decToBin(this.id).substring(25, 30)) Utils.binToDec(Utils.decToBin(this.id).substring(25, 30))
]; ];
//} else
//this.id = parseInt(Utils.decToBin(this.ivs[Stat.HP]) + Utils.decToBin(this.ivs[Stat.ATK]) + Utils.decToBin(this.ivs[Stat.DEF]) + Utils.decToBin(this.ivs[Stat.SPATK]) + Utils.decToBin(this.ivs[Stat.SPDEF]) + Utils.decToBin(this.ivs[Stat.SPD]) + this.id.toString(2).slice(30));
if (this.gender === undefined) { if (this.gender === undefined) {
if (this.getSpeciesForm().malePercent === null) if (this.getSpeciesForm().malePercent === null)
@ -549,14 +554,14 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
}); });
if (attackMovePool.length) { if (attackMovePool.length) {
const moveIndex = Utils.randInt(attackMovePool.length); const moveIndex = Utils.randSeedInt(attackMovePool.length);
this.moveset.push(new PokemonMove(attackMovePool[moveIndex], 0, 0)); this.moveset.push(new PokemonMove(attackMovePool[moveIndex], 0, 0));
console.log(allMoves[attackMovePool[moveIndex]]); console.log(allMoves[attackMovePool[moveIndex]]);
movePool.splice(movePool.findIndex(m => m === attackMovePool[moveIndex]), 1); movePool.splice(movePool.findIndex(m => m === attackMovePool[moveIndex]), 1);
} }
while (movePool.length && this.moveset.length < 4) { while (movePool.length && this.moveset.length < 4) {
const moveIndex = Utils.randInt(movePool.length); const moveIndex = Utils.randSeedInt(movePool.length);
this.moveset.push(new PokemonMove(movePool[moveIndex], 0, 0)); this.moveset.push(new PokemonMove(movePool[moveIndex], 0, 0));
console.log(allMoves[movePool[moveIndex]]); console.log(allMoves[movePool[moveIndex]]);
movePool.splice(moveIndex, 1); movePool.splice(moveIndex, 1);