ADDED: disable soundbased moveAtr, UPDATED: disable functionality and types

pull/751/head
Job Soltero 2024-05-11 13:35:11 -06:00
parent 03d68f877a
commit 88405ca9b2
5 changed files with 49 additions and 18 deletions

View File

@ -872,13 +872,13 @@ export class PostDefendMoveDisableAbAttr extends PostDefendAbAttr {
}
applyPostDefend(pokemon: Pokemon, passive: boolean, attacker: Pokemon, move: PokemonMove, hitResult: HitResult, args: any[]): boolean {
if (!attacker.summonData.disabledMove) {
if (attacker.summonData.disabledMoves.length === 0) {
if (move.getMove().checkFlag(MoveFlags.MAKES_CONTACT, attacker, pokemon) && (this.chance === -1 || pokemon.randSeedInt(100) < this.chance) && !attacker.isMax()) {
this.attacker = attacker;
this.move = move;
attacker.summonData.disabledMove = move.moveId;
attacker.summonData.disabledTurns = 4;
attacker.summonData.disabledMoves.push(move.moveId);
attacker.summonData.disabledTurns[move.moveId]=4;
return true;
}
}

View File

@ -2711,8 +2711,8 @@ export class DisableMoveAttr extends MoveEffectAttr {
return false;
const disabledMove = target.getMoveset()[moveIndex];
target.summonData.disabledMove = disabledMove.moveId;
target.summonData.disabledTurns = 4;
target.summonData.disabledMoves.push(disabledMove.moveId);
target.summonData.disabledTurns[disabledMove.moveId] = 4;
user.scene.queueMessage(getPokemonMessage(target, `'s ${disabledMove.getName()}\nwas disabled!`));
@ -2724,7 +2724,7 @@ export class DisableMoveAttr extends MoveEffectAttr {
getCondition(): MoveConditionFunc {
return (user, target, move) => {
if (target.summonData.disabledMove || target.isMax())
if (target.summonData.disabledMoves.length > 0 || target.isMax())
return false;
const moveQueue = target.getLastXMoves();
@ -2748,6 +2748,36 @@ export class DisableMoveAttr extends MoveEffectAttr {
}
}
export class DisableMovesWithSoundBasedFlagAtr extends MoveEffectAttr {
constructor() {
super(false);
}
apply(user: Pokemon, target: Pokemon, move: Move, args: any[]): boolean {
if (!super.apply(user, target, move, args))
return false;
const currentDisabledMovesLenght = target.summonData.disabledMoves.length;
const targetMoves = target.getMoveset();
targetMoves.forEach(move => {
if (move.getMove().hasFlag(MoveFlags.SOUND_BASED)) {
target.summonData.disabledMoves.push(move.moveId);
target.summonData.disabledTurns[move.moveId] = 2; }
});
if (currentDisabledMovesLenght != target.summonData.disabledMoves.length) {
user.scene.queueMessage(getPokemonMessage(target, `is now unable to use sound-based moves!`));
return true;
}
return false;
}
getTargetBenefitScore(user: Pokemon, target: Pokemon, move: Move): integer {
return -5;
}
}
export class FrenzyAttr extends MoveEffectAttr {
constructor() {
super(true, MoveEffectTrigger.HIT);
@ -6004,7 +6034,7 @@ export function initMoves() {
.target(MoveTarget.USER_AND_ALLIES)
.condition((user, target, move) => !![ user, user.getAlly() ].filter(p => p?.isActive()).find(p => !![ Abilities.PLUS, Abilities.MINUS].find(a => p.hasAbility(a, false)))),
new AttackMove(Moves.THROAT_CHOP, Type.DARK, MoveCategory.PHYSICAL, 80, 100, 15, 100, 0, 7)
.partial(),
.attr(DisableMovesWithSoundBasedFlagAtr),
new AttackMove(Moves.POLLEN_PUFF, Type.BUG, MoveCategory.SPECIAL, 90, 100, 15, -1, 0, 7)
.ballBombMove()
.partial(),

View File

@ -3234,8 +3234,8 @@ export interface AttackMoveResult {
export class PokemonSummonData {
public battleStats: integer[] = [ 0, 0, 0, 0, 0, 0, 0 ];
public moveQueue: QueuedMove[] = [];
public disabledMove: Moves = Moves.NONE;
public disabledTurns: integer = 0;
public disabledMoves: Moves[] = [];
public disabledTurns: { [index: string]: integer } = {};
public tags: BattlerTag[] = [];
public abilitySuppressed: boolean = false;
@ -3314,7 +3314,7 @@ export class PokemonMove {
}
isUsable(pokemon: Pokemon, ignorePp?: boolean): boolean {
if (this.moveId && pokemon.summonData?.disabledMove === this.moveId)
if (this.moveId && pokemon.summonData?.disabledMoves.includes(this.moveId))
return false;
return (ignorePp || this.ppUsed < this.getMovePp() || this.getMove().pp === -1) && !this.getMove().name.endsWith(' (N)');
}

View File

@ -1708,7 +1708,7 @@ export class CommandPhase extends FieldPhase {
// Decides between a Disabled, Not Implemented, or No PP translation message
const errorMessage =
playerPokemon.summonData.disabledMove === move.moveId ? 'battle:moveDisabled' :
playerPokemon.summonData.disabledMoves.includes(move.moveId) ? 'battle:moveDisabled' :
move.getName().endsWith(' (N)') ? 'battle:moveNotImplemented' : 'battle:moveNoPP';
const moveName = move.getName().replace(' (N)', ''); // Trims off the indicator
@ -2048,11 +2048,12 @@ export class TurnEndPhase extends FieldPhase {
const handlePokemon = (pokemon: Pokemon) => {
pokemon.lapseTags(BattlerTagLapseType.TURN_END);
if (pokemon.summonData.disabledMove && !--pokemon.summonData.disabledTurns) {
this.scene.pushPhase(new MessagePhase(this.scene, i18next.t('battle:notDisabled', { pokemonName: `${getPokemonPrefix(pokemon)}${pokemon.name}`, moveName: allMoves[pokemon.summonData.disabledMove].name })));
pokemon.summonData.disabledMove = Moves.NONE;
}
pokemon.disabledMoves.forEach(moveId => {
if (!--pokemon.disabledTurns[moveId]) {
this.scene.pushPhase(new MessagePhase(this.scene, i18next.t('battle:notDisabled', { pokemonName: `${getPokemonPrefix(pokemon)}${pokemon.name}`, moveName: allMoves[moveId].name })));
pokemon.disabledMoves.delete(moveId);
}
});
const hasUsableBerry = !!this.scene.findModifier(m => m instanceof BerryModifier && m.shouldApply([ pokemon ]), pokemon.isPlayer());
if (hasUsableBerry)
@ -2197,7 +2198,7 @@ export class MovePhase extends BattlePhase {
console.log(Moves[this.move.moveId]);
if (!this.canMove()) {
if (this.move.moveId && this.pokemon.summonData.disabledMove === this.move.moveId)
if (this.move.moveId && this.pokemon.summonData.disabledMoves.includes(this.move.moveId))
this.scene.queueMessage(`${this.move.getName()} is disabled!`);
return this.end();
}

View File

@ -113,7 +113,7 @@ export default class PokemonData {
if (!forHistory && source.summonData) {
this.summonData.battleStats = source.summonData.battleStats;
this.summonData.moveQueue = source.summonData.moveQueue;
this.summonData.disabledMove = source.summonData.disabledMove;
this.summonData.disabledMoves = source.summonData.disabledMoves;
this.summonData.disabledTurns = source.summonData.disabledTurns;
this.summonData.abilitySuppressed = source.summonData.abilitySuppressed;