Implement 2 abilities

This commit is contained in:
N1ghtz567 2023-12-22 18:08:37 -04:00
parent 7deab1c545
commit 53fb56391b
3 changed files with 66 additions and 38 deletions

View File

@ -25,7 +25,7 @@ import { Gender } from "./data/gender";
import { Weather, WeatherType, getRandomWeatherType, getWeatherDamageMessage, getWeatherLapseMessage } from "./data/weather"; import { Weather, WeatherType, getRandomWeatherType, getWeatherDamageMessage, getWeatherLapseMessage } from "./data/weather";
import { TempBattleStat } from "./data/temp-battle-stat"; import { TempBattleStat } from "./data/temp-battle-stat";
import { ArenaTagType, ArenaTrapTag, TrickRoomTag } from "./data/arena-tag"; import { ArenaTagType, ArenaTrapTag, TrickRoomTag } from "./data/arena-tag";
import { Abilities, CheckTrappedAbAttr, IgnoreOpponentStatChangesAbAttr, PostAttackAbAttr, PostDefendAbAttr, PostSummonAbAttr, PostTurnAbAttr, PostWeatherLapseAbAttr, PreWeatherDamageAbAttr, ProtectStatAbAttr, StatChangeMultiplierAbAttr, SuppressWeatherEffectAbAttr, applyAbAttrs, applyCheckTrappedAbAttrs, applyPostAttackAbAttrs, applyPostDefendAbAttrs, applyPostSummonAbAttrs, applyPostTurnAbAttrs, applyPostWeatherLapseAbAttrs, applyPreStatChangeAbAttrs, applyPreWeatherEffectAbAttrs } from "./data/ability"; import { Abilities, CheckTrappedAbAttr, IgnoreOpponentStatChangesAbAttr, PostAttackAbAttr, PostDefendAbAttr, PostSummonAbAttr, PostTurnAbAttr, PostWeatherLapseAbAttr, PreWeatherDamageAbAttr, ProtectStatAbAttr, RunSuccessAbAttr, StatChangeMultiplierAbAttr, SuppressWeatherEffectAbAttr, applyAbAttrs, applyCheckTrappedAbAttrs, applyPostAttackAbAttrs, applyPostDefendAbAttrs, applyPostSummonAbAttrs, applyPostTurnAbAttrs, applyPostWeatherLapseAbAttrs, applyPreStatChangeAbAttrs, applyPreWeatherEffectAbAttrs } from "./data/ability";
import { Unlockables, getUnlockableName } from "./system/unlockables"; import { Unlockables, getUnlockableName } from "./system/unlockables";
import { getBiomeKey } from "./arena"; import { getBiomeKey } from "./arena";
import { BattleType, BattlerIndex, TurnCommand } from "./battle"; import { BattleType, BattlerIndex, TurnCommand } from "./battle";
@ -1769,8 +1769,9 @@ export class MoveEffectPhase extends PokemonPhase {
if (--user.turnData.hitsLeft >= 1 && this.getTarget()?.isActive()) if (--user.turnData.hitsLeft >= 1 && this.getTarget()?.isActive())
this.scene.unshiftPhase(this.getNewHitPhase()); this.scene.unshiftPhase(this.getNewHitPhase());
else { else {
if (user.turnData.hitCount - Math.max(user.turnData.hitsLeft, 0) > 1) const hitsTotal = user.turnData.hitCount - Math.max(user.turnData.hitsLeft, 0);
this.scene.queueMessage(`Hit ${user.turnData.hitCount} time(s)!`); if (hitsTotal > 1)
this.scene.queueMessage(`Hit ${hitsTotal} time(s)!`);
this.scene.applyModifiers(HitHealModifier, this.player, user); this.scene.applyModifiers(HitHealModifier, this.player, user);
} }
} }
@ -3070,9 +3071,10 @@ export class AttemptRunPhase extends PokemonPhase {
const enemySpeed = enemyField.reduce((total: integer, enemyPokemon: Pokemon) => total + enemyPokemon.getStat(Stat.SPD), 0) / enemyField.length; const enemySpeed = enemyField.reduce((total: integer, enemyPokemon: Pokemon) => total + enemyPokemon.getStat(Stat.SPD), 0) / enemyField.length;
const escapeChance = (((playerPokemon.getStat(Stat.SPD) * 128) / enemySpeed) + (30 * this.scene.currentBattle.escapeAttempts++)) % 256; const escapeChance = new Utils.IntegerHolder((((playerPokemon.getStat(Stat.SPD) * 128) / enemySpeed) + (30 * this.scene.currentBattle.escapeAttempts++)) % 256);
applyAbAttrs(RunSuccessAbAttr, playerPokemon, null, escapeChance);
if (Utils.randInt(256) < escapeChance) { if (Utils.randInt(256) < escapeChance.value) {
this.scene.playSound('flee'); this.scene.playSound('flee');
this.scene.queueMessage('You got away safely!', null, true, 500); this.scene.queueMessage('You got away safely!', null, true, 500);

View File

@ -890,6 +890,14 @@ export class DoubleBerryEffectAbAttr extends AbAttr {
} }
} }
export class RunSuccessAbAttr extends AbAttr {
apply(pokemon: Pokemon, cancelled: Utils.BooleanHolder, args: any[]): boolean {
(args[0] as Utils.IntegerHolder).value = 256;
return true;
}
}
export class CheckTrappedAbAttr extends AbAttr { export class CheckTrappedAbAttr extends AbAttr {
applyCheckTrapped(pokemon: Pokemon, trapped: Utils.BooleanHolder, args: any[]): boolean { applyCheckTrapped(pokemon: Pokemon, trapped: Utils.BooleanHolder, args: any[]): boolean {
return false; return false;
@ -907,6 +915,14 @@ export class ArenaTrapAbAttr extends CheckTrappedAbAttr {
} }
} }
export class MaxMultiHitAbAttr extends AbAttr {
apply(pokemon: Pokemon, cancelled: Utils.BooleanHolder, args: any[]): boolean {
(args[0] as Utils.IntegerHolder).value = 0;
return true;
}
}
export class WeightMultiplierAbAttr extends AbAttr { export class WeightMultiplierAbAttr extends AbAttr {
private multiplier: integer; private multiplier: integer;
@ -1667,7 +1683,8 @@ export function initAbilities() {
new Ability(Abilities.EARLY_BIRD, "Early Bird (N)", "The Pokémon awakens from sleep twice as fast as other Pokémon.", 3), new Ability(Abilities.EARLY_BIRD, "Early Bird (N)", "The Pokémon awakens from sleep twice as fast as other Pokémon.", 3),
new Ability(Abilities.FLAME_BODY, "Flame Body", "Contact with the Pokémon may burn the attacker.", 3) new Ability(Abilities.FLAME_BODY, "Flame Body", "Contact with the Pokémon may burn the attacker.", 3)
.attr(PostDefendContactApplyStatusEffectAbAttr, 30, StatusEffect.BURN), .attr(PostDefendContactApplyStatusEffectAbAttr, 30, StatusEffect.BURN),
new Ability(Abilities.RUN_AWAY, "Run Away (N)", "Enables a sure getaway from wild Pokémon.", 3), new Ability(Abilities.RUN_AWAY, "Run Away", "Enables a sure getaway from wild Pokémon.", 3)
.attr(RunSuccessAbAttr),
new Ability(Abilities.KEEN_EYE, "Keen Eye", "Keen eyes prevent other Pokémon from lowering this Pokémon's accuracy.", 3) new Ability(Abilities.KEEN_EYE, "Keen Eye", "Keen eyes prevent other Pokémon from lowering this Pokémon's accuracy.", 3)
.attr(ProtectStatAbAttr, BattleStat.ACC), .attr(ProtectStatAbAttr, BattleStat.ACC),
new Ability(Abilities.HYPER_CUTTER, "Hyper Cutter", "The Pokémon's proud of its powerful pincers. They prevent other Pokémon from lowering its Attack stat.", 3) new Ability(Abilities.HYPER_CUTTER, "Hyper Cutter", "The Pokémon's proud of its powerful pincers. They prevent other Pokémon from lowering its Attack stat.", 3)
@ -1740,7 +1757,8 @@ export function initAbilities() {
new Ability(Abilities.POISON_HEAL, "Poison Heal (N)", "Restores HP if the Pokémon is poisoned instead of losing HP.", 4), new Ability(Abilities.POISON_HEAL, "Poison Heal (N)", "Restores HP if the Pokémon is poisoned instead of losing HP.", 4),
new Ability(Abilities.ADAPTABILITY, "Adaptability", "Powers up moves of the same type as the Pokémon.", 4) new Ability(Abilities.ADAPTABILITY, "Adaptability", "Powers up moves of the same type as the Pokémon.", 4)
.attr(StabBoostAbAttr), .attr(StabBoostAbAttr),
new Ability(Abilities.SKILL_LINK, "Skill Link (N)", "Maximizes the number of times multistrike moves hit.", 4), new Ability(Abilities.SKILL_LINK, "Skill Link", "Maximizes the number of times multistrike moves hit.", 4)
.attr(MaxMultiHitAbAttr),
new Ability(Abilities.HYDRATION, "Hydration (N)", "Heals status conditions if it's raining.", 4), new Ability(Abilities.HYDRATION, "Hydration (N)", "Heals status conditions if it's raining.", 4),
new Ability(Abilities.SOLAR_POWER, "Solar Power", "Boosts the Sp. Atk stat in harsh sunlight, but HP decreases every turn.", 4) new Ability(Abilities.SOLAR_POWER, "Solar Power", "Boosts the Sp. Atk stat in harsh sunlight, but HP decreases every turn.", 4)
.attr(PostWeatherLapseDamageAbAttr, 2, WeatherType.SUNNY, WeatherType.HARSH_SUN) .attr(PostWeatherLapseDamageAbAttr, 2, WeatherType.SUNNY, WeatherType.HARSH_SUN)

View File

@ -9,7 +9,7 @@ import { Type } from "./type";
import * as Utils from "../utils"; import * as Utils from "../utils";
import { WeatherType } from "./weather"; import { WeatherType } from "./weather";
import { ArenaTagType, ArenaTrapTag } from "./arena-tag"; import { ArenaTagType, ArenaTrapTag } from "./arena-tag";
import { Abilities, BlockRecoilDamageAttr, IgnoreContactAbAttr, applyAbAttrs } from "./ability"; import { Abilities, BlockRecoilDamageAttr, IgnoreContactAbAttr, MaxMultiHitAbAttr, applyAbAttrs } from "./ability";
import { PokemonHeldItemModifier } from "../modifier/modifier"; import { PokemonHeldItemModifier } from "../modifier/modifier";
import { BattlerIndex } from "../battle"; import { BattlerIndex } from "../battle";
import { Stat } from "./pokemon-stat"; import { Stat } from "./pokemon-stat";
@ -1583,15 +1583,19 @@ export class MultiHitAttr extends MoveAttr {
let hitTimes: integer; let hitTimes: integer;
switch (this.multiHitType) { switch (this.multiHitType) {
case MultiHitType._2_TO_5: case MultiHitType._2_TO_5:
const rand = Utils.randInt(16); {
if (rand >= 10) const rand = Utils.randInt(16);
hitTimes = 2; const hitValue = new Utils.IntegerHolder(rand);
else if (rand >= 4) applyAbAttrs(MaxMultiHitAbAttr, user, null, hitValue);
hitTimes = 3; if (hitValue.value >= 10)
else if (rand >= 2) hitTimes = 2;
hitTimes = 4; else if (hitValue.value >= 4)
else hitTimes = 3;
hitTimes = 5; else if (hitValue.value >= 2)
hitTimes = 4;
else
hitTimes = 5;
}
break; break;
case MultiHitType._2: case MultiHitType._2:
hitTimes = 2; hitTimes = 2;
@ -1604,27 +1608,31 @@ export class MultiHitAttr extends MoveAttr {
// TODO: Add power increase for every hit // TODO: Add power increase for every hit
break; break;
case MultiHitType._1_TO_10: case MultiHitType._1_TO_10:
const rand10 = Utils.randInt(90); {
if (rand10 >= 81) const rand = Utils.randInt(90);
hitTimes = 1; const hitValue = new Utils.IntegerHolder(rand);
else if (rand10 >= 73) applyAbAttrs(MaxMultiHitAbAttr, user, null, hitValue);
hitTimes = 2; if (hitValue.value >= 81)
else if (rand10 >= 66) hitTimes = 1;
hitTimes = 3; else if (hitValue.value >= 73)
else if (rand10 >= 60) hitTimes = 2;
hitTimes = 4; else if (hitValue.value>= 66)
else if (rand10 >= 54) hitTimes = 3;
hitTimes = 5; else if (hitValue.value >= 60)
else if (rand10 >= 49) hitTimes = 4;
hitTimes = 6; else if (hitValue.value >= 54)
else if (rand10 >= 44) hitTimes = 5;
hitTimes = 7; else if (hitValue.value >= 49)
else if (rand10 >= 40) hitTimes = 6;
hitTimes = 8; else if (hitValue.value >= 44)
else if (rand10 >= 36) hitTimes = 7;
hitTimes = 9; else if (hitValue.value >= 40)
else hitTimes = 8;
hitTimes = 10; else if (hitValue.value >= 36)
hitTimes = 9;
else
hitTimes = 10;
}
break; break;
} }
(args[0] as Utils.IntegerHolder).value = hitTimes; (args[0] as Utils.IntegerHolder).value = hitTimes;