Fix tag cleanup after fainting

This commit is contained in:
Jakub Hanko 2024-05-17 15:44:12 +02:00
parent 83d76fd535
commit 86b4ab357c
No known key found for this signature in database
GPG Key ID: 775D427937A306CC
4 changed files with 22 additions and 13 deletions

View File

@ -2696,7 +2696,7 @@ export class FriendGuardAbAttr extends AbAttr {
if (!ally) {
return false;
}
ally.addTag(BattlerTagType.FRIEND_GUARD, 1, undefined, pokemon.id);
ally.addTag(BattlerTagType.FRIEND_GUARD, 0, undefined, pokemon.id);
return true;
}

View File

@ -1276,12 +1276,23 @@ export class CursedTag extends BattlerTag {
}
}
export class FriendGuardTag extends BattlerTag {
export class AuraTag extends BattlerTag {
constructor(tagType: BattlerTagType, sourceId: number) {
super(tagType, BattlerTagLapseType.CUSTOM, 0, undefined, sourceId);
}
lapse(pokemon: Pokemon, lapseType: BattlerTagLapseType): boolean {
const source = pokemon.scene.getPokemonById(this.sourceId);
return source.isActive(true);
}
}
export class ReceivedMoveDamageMultiplierTag extends AuraTag {
public powerMultiplier: number;
constructor() {
super(BattlerTagType.FRIEND_GUARD, BattlerTagLapseType.TURN_END, 1, undefined);
this.powerMultiplier = 0.75;
constructor(tagType: BattlerTagType, sourceId: number, powerMultiplier: number) {
super(tagType, sourceId);
this.powerMultiplier = powerMultiplier;
}
/**
@ -1406,7 +1417,7 @@ export function getBattlerTag(tagType: BattlerTagType, turnCount: integer, sourc
case BattlerTagType.MINIMIZED:
return new MinimizeTag();
case BattlerTagType.FRIEND_GUARD:
return new FriendGuardTag();
return new ReceivedMoveDamageMultiplierTag(tagType, sourceId, 0.75);
case BattlerTagType.NONE:
default:
return new BattlerTag(tagType, BattlerTagLapseType.CUSTOM, turnCount, sourceMove, sourceId);

View File

@ -19,7 +19,7 @@ import { pokemonEvolutions, pokemonPrevolutions, SpeciesFormEvolution, SpeciesEv
import { reverseCompatibleTms, tmSpecies, tmPoolTiers } from '../data/tms';
import { DamagePhase, FaintPhase, LearnMovePhase, ObtainStatusEffectPhase, StatChangePhase, SwitchSummonPhase } from '../phases';
import { BattleStat } from '../data/battle-stat';
import { BattlerTag, BattlerTagLapseType, EncoreTag, FriendGuardTag, HelpingHandTag, HighestStatBoostTag, TypeBoostTag, getBattlerTag } from '../data/battler-tags';
import { BattlerTag, BattlerTagLapseType, EncoreTag, ReceivedMoveDamageMultiplierTag, HelpingHandTag, HighestStatBoostTag, TypeBoostTag, getBattlerTag } from '../data/battler-tags';
import { BattlerTagType } from "../data/enums/battler-tag-type";
import { Species } from '../data/enums/species';
import { WeatherType } from '../data/weather';
@ -1454,13 +1454,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
this.scene.getField(true).map(p => applyPreAttackAbAttrs(FieldVariableMovePowerAbAttr, this, source, battlerMove, power));
applyPreDefendAbAttrs(ReceivedMoveDamageMultiplierAbAttr, this, source, battlerMove, cancelled, power);
const reducedDamageTag = this.getTag(BattlerTagType.FRIEND_GUARD) as FriendGuardTag;
console.log(this.findTags(t => true));
const reducedDamageTag = this.getTag(BattlerTagType.FRIEND_GUARD) as ReceivedMoveDamageMultiplierTag;
if (reducedDamageTag) {
console.log(power);
console.log(reducedDamageTag.powerMultiplier);
power.value *= reducedDamageTag.powerMultiplier;
console.log(power);
}
power.value *= typeChangeMovePowerMultiplier.value;

View File

@ -21,7 +21,7 @@ import { Biome } from "./data/enums/biome";
import { ModifierTier } from "./modifier/modifier-tier";
import { FusePokemonModifierType, ModifierPoolType, ModifierType, ModifierTypeFunc, ModifierTypeOption, PokemonModifierType, PokemonMoveModifierType, PokemonPpRestoreModifierType, PokemonPpUpModifierType, RememberMoveModifierType, TmModifierType, getDailyRunStarterModifiers, getEnemyBuffModifierForWave, getModifierType, getPlayerModifierTypeOptions, getPlayerShopModifierTypeOptionsForWave, modifierTypes, regenerateModifierPoolThresholds } from "./modifier/modifier-type";
import SoundFade from "phaser3-rex-plugins/plugins/soundfade";
import { BattlerTagLapseType, EncoreTag, HideSpriteTag as HiddenTag, ProtectedTag, TrappedTag } from "./data/battler-tags";
import { AuraTag, BattlerTagLapseType, EncoreTag, HideSpriteTag as HiddenTag, ProtectedTag, TrappedTag } from "./data/battler-tags";
import { BattlerTagType } from "./data/enums/battler-tag-type";
import { getPokemonMessage, getPokemonPrefix } from "./messages";
import { Starter } from "./ui/starter-select-ui-handler";
@ -2510,6 +2510,7 @@ export class MoveEffectPhase extends PokemonPhase {
}
const isProtected = !this.move.getMove().hasFlag(MoveFlags.IGNORE_PROTECT) && target.findTags(t => t instanceof ProtectedTag).find(t => target.lapseTag(t.tagType));
target.findTags(t => t instanceof AuraTag).forEach(t => target.lapseTag(t.tagType));
const firstHit = moveHistoryEntry.result !== MoveResult.SUCCESS;