working properly to block weather damage
parent
4b004356d2
commit
62f6ea27cb
|
@ -179,6 +179,17 @@ export function getWeatherDamageMessage(weatherType: WeatherType, pokemon: Pokem
|
|||
return null;
|
||||
}
|
||||
|
||||
export function getWeatherImmunityMessage(weatherType: WeatherType, pokemon: Pokemon): string {
|
||||
switch (weatherType) {
|
||||
case WeatherType.SANDSTORM:
|
||||
return getPokemonMessage(pokemon, ' is not affected by\nsandstorm due to its Safety Goggles!');
|
||||
case WeatherType.HAIL:
|
||||
return getPokemonMessage(pokemon, ' is not affected by\nhail due to its Safety Goggles!');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getWeatherClearMessage(weatherType: WeatherType): string {
|
||||
switch (weatherType) {
|
||||
case WeatherType.SUNNY:
|
||||
|
|
|
@ -923,7 +923,7 @@ export const modifierTypes = {
|
|||
(type, _args) => new Modifiers.PreserveBerryModifier(type)),
|
||||
|
||||
SAFETY_GOGGLES: () => new ModifierType('Safety Goggles', 'Prevents damage from weather and powder',
|
||||
(type, _args) => new Modifiers.WeatherChipImmunityModifier(type), "safety_goggles"),
|
||||
(type, _args) => new Modifiers.WeatherDamageImmunityModifier(type), "safety_goggles"),
|
||||
|
||||
FOCUS_BAND: () => new PokemonHeldItemModifierType('Focus Band', 'Adds a 10% chance to survive with 1 HP after being damaged enough to faint',
|
||||
(type, args) => new Modifiers.SurviveDamageModifier(type, (args[0] as Pokemon).id)),
|
||||
|
|
|
@ -918,17 +918,17 @@ export class PreserveBerryModifier extends PersistentModifier {
|
|||
}
|
||||
}
|
||||
|
||||
export class WeatherChipImmunityModifier extends PersistentModifier {
|
||||
export class WeatherDamageImmunityModifier extends PersistentModifier {
|
||||
constructor(type: ModifierType, stackCount?: integer) {
|
||||
super(type, stackCount);
|
||||
}
|
||||
|
||||
match(modifier: Modifier) {
|
||||
return modifier instanceof WeatherChipImmunityModifier;
|
||||
return modifier instanceof WeatherDamageImmunityModifier;
|
||||
}
|
||||
|
||||
clone() {
|
||||
return new WeatherChipImmunityModifier(this.type, this.stackCount);
|
||||
return new WeatherDamageImmunityModifier(this.type, this.stackCount);
|
||||
}
|
||||
|
||||
shouldApply(args: any[]): boolean {
|
||||
|
@ -936,8 +936,10 @@ export class WeatherChipImmunityModifier extends PersistentModifier {
|
|||
}
|
||||
|
||||
apply(args: any[]): boolean {
|
||||
if (!(args[1] as Utils.BooleanHolder).value)
|
||||
(args[1] as Utils.BooleanHolder).value = (args[0] as Pokemon).randSeedInt(this.getMaxStackCount(null)) < this.getStackCount();
|
||||
const pokemon = args[0] as Pokemon;
|
||||
if (pokemon.isPlayer()) {
|
||||
(args[1] as Utils.BooleanHolder).value = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, applyFilteredMov
|
|||
import { Mode } from './ui/ui';
|
||||
import { Command } from "./ui/command-ui-handler";
|
||||
import { Stat } from "./data/pokemon-stat";
|
||||
import { BerryModifier, ContactHeldItemTransferChanceModifier, EnemyAttackStatusEffectChanceModifier, EnemyPersistentModifier, EnemyStatusEffectHealChanceModifier, EnemyTurnHealModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, FlinchChanceModifier, FusePokemonModifier, HealingBoosterModifier, HitHealModifier, LapsingPersistentModifier, MapModifier, Modifier, MultipleParticipantExpBonusModifier, PersistentModifier, PokemonExpBoosterModifier, PokemonHeldItemModifier, PokemonInstantReviveModifier, SwitchEffectTransferModifier, TempBattleStatBoosterModifier, TurnHealModifier, TurnHeldItemTransferModifier, MoneyMultiplierModifier, MoneyInterestModifier, IvScannerModifier, LapsingPokemonHeldItemModifier, PokemonMultiHitModifier, PokemonMoveAccuracyBoosterModifier, overrideModifiers, overrideHeldItems } from "./modifier/modifier";
|
||||
import { BerryModifier, ContactHeldItemTransferChanceModifier, EnemyAttackStatusEffectChanceModifier, EnemyPersistentModifier, EnemyStatusEffectHealChanceModifier, EnemyTurnHealModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, FlinchChanceModifier, FusePokemonModifier, HealingBoosterModifier, HitHealModifier, LapsingPersistentModifier, MapModifier, Modifier, MultipleParticipantExpBonusModifier, PersistentModifier, PokemonExpBoosterModifier, PokemonHeldItemModifier, PokemonInstantReviveModifier, SwitchEffectTransferModifier, TempBattleStatBoosterModifier, TurnHealModifier, TurnHeldItemTransferModifier, MoneyMultiplierModifier, MoneyInterestModifier, IvScannerModifier, LapsingPokemonHeldItemModifier, PokemonMultiHitModifier, PokemonMoveAccuracyBoosterModifier, overrideModifiers, overrideHeldItems, WeatherDamageImmunityModifier } from "./modifier/modifier";
|
||||
import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler";
|
||||
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./data/pokeball";
|
||||
import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./data/battle-anims";
|
||||
|
@ -26,7 +26,7 @@ import { BattlerTagType } from "./data/enums/battler-tag-type";
|
|||
import { getPokemonMessage, getPokemonPrefix } from "./messages";
|
||||
import { Starter } from "./ui/starter-select-ui-handler";
|
||||
import { Gender } from "./data/gender";
|
||||
import { Weather, WeatherType, getRandomWeatherType, getTerrainBlockMessage, getWeatherDamageMessage, getWeatherLapseMessage } from "./data/weather";
|
||||
import { Weather, WeatherType, getRandomWeatherType, getTerrainBlockMessage, getWeatherDamageMessage, getWeatherImmunityMessage, getWeatherLapseMessage } from "./data/weather";
|
||||
import { TempBattleStat } from "./data/temp-battle-stat";
|
||||
import { ArenaTagSide, ArenaTrapTag, MistTag, TrickRoomTag } from "./data/arena-tag";
|
||||
import { ArenaTagType } from "./data/enums/arena-tag-type";
|
||||
|
@ -2905,10 +2905,17 @@ export class WeatherEffectPhase extends CommonAnimPhase {
|
|||
if (cancelled.value)
|
||||
return;
|
||||
|
||||
const damage = Math.ceil(pokemon.getMaxHp() / 16);
|
||||
const goggles = new Utils.BooleanHolder(false);
|
||||
this.scene.applyModifiers(WeatherDamageImmunityModifier, pokemon.isPlayer(), pokemon, goggles);
|
||||
|
||||
this.scene.queueMessage(getWeatherDamageMessage(this.weather.weatherType, pokemon));
|
||||
pokemon.damageAndUpdate(damage, HitResult.EFFECTIVE, false, false, true);
|
||||
if (goggles.value) {
|
||||
this.scene.queueMessage(getWeatherImmunityMessage(this.weather.weatherType, pokemon));
|
||||
} else {
|
||||
const damage = Math.ceil(pokemon.getMaxHp() / 16);
|
||||
|
||||
this.scene.queueMessage(getWeatherDamageMessage(this.weather.weatherType, pokemon));
|
||||
pokemon.damageAndUpdate(damage, HitResult.EFFECTIVE, false, false, true);
|
||||
}
|
||||
};
|
||||
|
||||
this.executeForAll((pokemon: Pokemon) => {
|
||||
|
|
Loading…
Reference in New Issue