Replace all raw string comparisons with StringKey, source generator that creates cache keys for all names for Gen7 plugin
All checks were successful
Build / Build (push) Successful in 2m21s
All checks were successful
Build / Build (push) Successful in 2m21s
This commit is contained in:
@@ -9,8 +9,6 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "aftermath")]
|
||||
public class Aftermath : Script, IScriptOnIncomingHit, IScriptOnFaint
|
||||
{
|
||||
private static readonly StringKey DampAbilityName = new("damp");
|
||||
|
||||
private IExecutingMove? _lastAttack;
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -35,7 +33,7 @@ public class Aftermath : Script, IScriptOnIncomingHit, IScriptOnFaint
|
||||
// Aftermath does not trigger if a Pokémon with Damp is on the field
|
||||
var battle = user.BattleData.Battle;
|
||||
var hasDamp = battle.Sides.SelectMany(side => side.Pokemon).WhereNotNull()
|
||||
.Any(p => p.ActiveAbility?.Name == DampAbilityName);
|
||||
.Any(p => p.ActiveAbility?.Name == AbilityNames.Damp);
|
||||
if (hasDamp)
|
||||
return;
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ public class Anticipation : Script, IScriptOnOpponentSwitchIn
|
||||
// Either the move is super effective against the owner or
|
||||
typeLibrary.GetEffectiveness(move.MoveData.MoveType, _owner.Types) > 1.0f ||
|
||||
// the move is a OHKO move
|
||||
move.MoveData.SecondaryEffect?.Name == "one_hit_ko" ||
|
||||
move.MoveData.SecondaryEffect?.Name == MoveEffectNames.OneHitKo ||
|
||||
// the move is a self-destruct move
|
||||
move.MoveData.SecondaryEffect?.Name == "self_destruct" ||
|
||||
move.MoveData.SecondaryEffect?.Name == "explosion");
|
||||
move.MoveData.SecondaryEffect?.Name == MoveEffectNames.SelfDestruct ||
|
||||
move.MoveData.SecondaryEffect?.Name == MoveEffectNames.Explosion);
|
||||
|
||||
if (relevantMoves)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ public class AuraBreak : Script, IScriptCustomTrigger
|
||||
return;
|
||||
|
||||
var typeName = auraArgs.Move.UseMove.MoveType.Name;
|
||||
if (typeName == "dark" || typeName == "fairy")
|
||||
if (typeName == TypeNames.Dark || typeName == TypeNames.Fairy)
|
||||
{
|
||||
// Reverse the aura effect by reducing power by 25%
|
||||
auraArgs.AuraEffect *= 0.75f;
|
||||
|
||||
@@ -12,8 +12,8 @@ public class BattleBond : Script, IScriptChangeNumberOfHits, IScriptOnOpponentFa
|
||||
/// <inheritdoc />
|
||||
public void OnOpponentFaints(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (move.User.Species.Name == "greninja" && move.User.Form.Name != "ash" &&
|
||||
move.User.Species.TryGetForm("ash", out var ashForm))
|
||||
if (move.User.Species.Name == SpeciesNames.Greninja && move.User.Form.Name != FormNames.Ash &&
|
||||
move.User.Species.TryGetForm(FormNames.Ash, out var ashForm))
|
||||
{
|
||||
move.User.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User));
|
||||
move.User.ChangeForm(ashForm);
|
||||
@@ -23,14 +23,14 @@ public class BattleBond : Script, IScriptChangeNumberOfHits, IScriptOnOpponentFa
|
||||
/// <inheritdoc />
|
||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||
{
|
||||
if (move.UseMove.Name == "water_shuriken" && move.User.Form.Name == "ash")
|
||||
if (move.UseMove.Name == MoveNames.WaterShuriken && move.User.Form.Name == FormNames.Ash)
|
||||
basePower = 20;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeNumberOfHits(IMoveChoice choice, ref byte numberOfHits)
|
||||
{
|
||||
if (choice.ChosenMove.MoveData.Name == "water_shuriken" && choice.User.Form.Name == "ash")
|
||||
if (choice.ChosenMove.MoveData.Name == MoveNames.WaterShuriken && choice.User.Form.Name == FormNames.Ash)
|
||||
{
|
||||
numberOfHits = 3;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class Damp : Script, IScriptFailIncomingMove
|
||||
/// <inheritdoc />
|
||||
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
|
||||
{
|
||||
if (move.UseMove.Name == "self_destruct" || move.UseMove.Name == "explosion")
|
||||
if (move.UseMove.Name == MoveNames.SelfDestruct || move.UseMove.Name == MoveNames.Explosion)
|
||||
{
|
||||
fail = true;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class DarkAura : Script, IScriptChangeDamageModifier
|
||||
/// <inheritdoc />
|
||||
public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "dark")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Dark)
|
||||
{
|
||||
var auraModifier = 5448f / 4096f;
|
||||
var args = new CustomTriggers.ModifyAuraEffectArgs(move, target, hit, auraModifier);
|
||||
|
||||
@@ -19,17 +19,17 @@ public class Disguise : Script, IScriptChangeIncomingDamage
|
||||
return;
|
||||
if (source is not DamageSource.MoveDamage and not DamageSource.Confusion)
|
||||
return;
|
||||
if (pokemon.Form.Name == "busted" || pokemon.Form.Name == "totem-busted")
|
||||
if (pokemon.Form.Name == FormNames.Busted || pokemon.Form.Name == FormNames.TotemBusted)
|
||||
return;
|
||||
IForm form;
|
||||
if (pokemon.Form.Name == "default")
|
||||
if (pokemon.Form.Name == FormNames.Default)
|
||||
{
|
||||
if (!pokemon.Species.TryGetForm("busted", out form!))
|
||||
if (!pokemon.Species.TryGetForm(FormNames.Busted, out form!))
|
||||
return;
|
||||
}
|
||||
else if (pokemon.Form.Name == "totem-disguised")
|
||||
else if (pokemon.Form.Name == FormNames.TotemDisguised)
|
||||
{
|
||||
if (!pokemon.Species.TryGetForm("totem-busted", out form!))
|
||||
if (!pokemon.Species.TryGetForm(FormNames.TotemBusted, out form!))
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -26,11 +26,11 @@ public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IA
|
||||
public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
|
||||
{
|
||||
var hitType = move.GetHitData(target, hit).Type;
|
||||
if (hitType?.Name == "fire")
|
||||
if (hitType?.Name == TypeNames.Fire)
|
||||
{
|
||||
modifier *= 1.25f;
|
||||
}
|
||||
else if (hitType?.Name == "water")
|
||||
else if (hitType?.Name == TypeNames.Water)
|
||||
{
|
||||
modifier = 0;
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
|
||||
@@ -13,11 +13,11 @@ public class EffectSpore : Script, IScriptOnIncomingHit
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (move.User.Types.Any(x => x.Name == "grass"))
|
||||
if (move.User.Types.Any(x => x.Name == TypeNames.Grass))
|
||||
return;
|
||||
if (move.User.ActiveAbility?.Name == "effect_spore")
|
||||
if (move.User.ActiveAbility?.Name == AbilityNames.EffectSpore)
|
||||
return;
|
||||
if (move.User.HasHeldItem("safety_goggles"))
|
||||
if (move.User.HasHeldItem(ItemNames.SafetyGoggles))
|
||||
return;
|
||||
if (!move.GetHitData(target, hit).IsContact)
|
||||
return;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class FairyAura : Script, IScriptChangeDamageModifier
|
||||
/// <inheritdoc />
|
||||
public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "fairy")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Fairy)
|
||||
{
|
||||
var auraModifier = 5448f / 4096f;
|
||||
var args = new CustomTriggers.ModifyAuraEffectArgs(move, target, hit, auraModifier);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class FlashFire : Script, IScriptChangeIncomingEffectiveness
|
||||
public void ChangeIncomingEffectiveness(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
ref float effectiveness)
|
||||
{
|
||||
if (executingMove.GetHitData(target, hitIndex).Type?.Name != "fire")
|
||||
if (executingMove.GetHitData(target, hitIndex).Type?.Name != TypeNames.Fire)
|
||||
return;
|
||||
effectiveness = 0f;
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ public class FlowerGift : Script, IScriptOnWeatherChange
|
||||
return;
|
||||
if (weatherName != ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||
return;
|
||||
if (_pokemon.Species.Name != "cherrim")
|
||||
if (_pokemon.Species.Name != SpeciesNames.Cherrim)
|
||||
return;
|
||||
EventBatchId batchId = new();
|
||||
if (_pokemon.Species.TryGetForm("sunshine", out var form) && _pokemon.Form != form)
|
||||
if (_pokemon.Species.TryGetForm(FormNames.Sunshine, out var form) && _pokemon.Form != form)
|
||||
{
|
||||
_pokemon.ChangeForm(form, batchId);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class FlowerGift : Script, IScriptOnWeatherChange
|
||||
script.OnRemoved(_pokemon);
|
||||
}
|
||||
|
||||
if (_pokemon.Species.Name != "cherrim")
|
||||
if (_pokemon.Species.Name != SpeciesNames.Cherrim)
|
||||
return;
|
||||
|
||||
EventBatchId batchId = new();
|
||||
|
||||
@@ -12,7 +12,7 @@ public class Fluffy : Script, IScriptChangeDamageModifier
|
||||
/// <inheritdoc />
|
||||
public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "fire")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Fire)
|
||||
{
|
||||
modifier *= 2f;
|
||||
}
|
||||
|
||||
@@ -45,21 +45,21 @@ public class Forecast : Script, IScriptOnSwitchIn, IScriptOnWeatherChange
|
||||
|
||||
private static void ChangeForm(IPokemon pokemon, StringKey? weather)
|
||||
{
|
||||
if (pokemon.Species.Name != "castform")
|
||||
if (pokemon.Species.Name != SpeciesNames.Castform)
|
||||
return;
|
||||
|
||||
if (weather == ScriptUtils.ResolveName<Weather.HarshSunlight>() &&
|
||||
pokemon.Species.TryGetForm("sunny", out var sunnyForm) && pokemon.Form != sunnyForm)
|
||||
pokemon.Species.TryGetForm(FormNames.Sunny, out var sunnyForm) && pokemon.Form != sunnyForm)
|
||||
{
|
||||
pokemon.ChangeForm(sunnyForm);
|
||||
}
|
||||
else if (weather == ScriptUtils.ResolveName<Weather.Rain>() &&
|
||||
pokemon.Species.TryGetForm("rainy", out var rainyForm) && pokemon.Form != rainyForm)
|
||||
pokemon.Species.TryGetForm(FormNames.Rainy, out var rainyForm) && pokemon.Form != rainyForm)
|
||||
{
|
||||
pokemon.ChangeForm(rainyForm);
|
||||
}
|
||||
else if (weather == ScriptUtils.ResolveName<Weather.Hail>() &&
|
||||
pokemon.Species.TryGetForm("snowy", out var snowyForm) && pokemon.Form != snowyForm)
|
||||
pokemon.Species.TryGetForm(FormNames.Snowy, out var snowyForm) && pokemon.Form != snowyForm)
|
||||
{
|
||||
pokemon.ChangeForm(snowyForm);
|
||||
}
|
||||
|
||||
@@ -37,28 +37,64 @@ public class Forewarn : Script, IScriptOnSwitchIn
|
||||
});
|
||||
}
|
||||
|
||||
private static readonly Dictionary<StringKey, byte> FixedBasePowers = new()
|
||||
{
|
||||
// 150 BP: Specific moves
|
||||
[MoveNames.BlastBurn] = 150,
|
||||
[MoveNames.Eruption] = 150,
|
||||
[MoveNames.WaterSpout] = 150,
|
||||
[MoveNames.Fissure] = 150,
|
||||
[MoveNames.Guillotine] = 150,
|
||||
[MoveNames.HornDrill] = 150,
|
||||
[MoveNames.SheerCold] = 150,
|
||||
// 120 BP: Counter, Metal Burst, Mirror Coat
|
||||
[MoveNames.Counter] = 120,
|
||||
[MoveNames.MetalBurst] = 120,
|
||||
[MoveNames.MirrorCoat] = 120,
|
||||
// 80 BP: List of variable power and fixed-damage moves
|
||||
[MoveNames.CrushGrip] = 80,
|
||||
[MoveNames.DragonRage] = 80,
|
||||
[MoveNames.ElectroBall] = 80,
|
||||
[MoveNames.Endeavor] = 80,
|
||||
[MoveNames.FinalGambit] = 80,
|
||||
[MoveNames.Flail] = 80,
|
||||
[MoveNames.Fling] = 80,
|
||||
[MoveNames.Frustration] = 80,
|
||||
[MoveNames.GrassKnot] = 80,
|
||||
[MoveNames.GuardianOfAlola] = 80,
|
||||
[MoveNames.GyroBall] = 80,
|
||||
[MoveNames.HeatCrash] = 80,
|
||||
[MoveNames.HeavySlam] = 80,
|
||||
[MoveNames.HiddenPower] = 80,
|
||||
[MoveNames.LowKick] = 80,
|
||||
[MoveNames.NaturalGift] = 80,
|
||||
[MoveNames.NaturesMadness] = 80,
|
||||
[MoveNames.NightShade] = 80,
|
||||
[MoveNames.Present] = 80,
|
||||
[MoveNames.Psywave] = 80,
|
||||
[MoveNames.Punishment] = 80,
|
||||
[MoveNames.Return] = 80,
|
||||
[MoveNames.Reversal] = 80,
|
||||
[MoveNames.SeismicToss] = 80,
|
||||
[MoveNames.SonicBoom] = 80,
|
||||
[MoveNames.SpitUp] = 80,
|
||||
[MoveNames.SuperFang] = 80,
|
||||
[MoveNames.TrumpCard] = 80,
|
||||
[MoveNames.WringOut] = 80,
|
||||
// 20 BP: Stored Power, Power Trip
|
||||
[MoveNames.StoredPower] = 20,
|
||||
[MoveNames.PowerTrip] = 20,
|
||||
};
|
||||
|
||||
private static byte GetBasePower(IMoveData moveData)
|
||||
{
|
||||
// OHKO moves (handled by secondary effect)
|
||||
if (moveData.SecondaryEffect?.Name == "one_hit_ko")
|
||||
if (moveData.SecondaryEffect?.Name == MoveEffectNames.OneHitKo)
|
||||
return 150;
|
||||
|
||||
return moveData.Name.ToString() switch
|
||||
{
|
||||
// 150 BP: Specific moves
|
||||
"blast_burn" or "eruption" or "water_spout" or "fissure" or "guillotine" or "horn_drill"
|
||||
or "sheer_cold" => 150,
|
||||
// 120 BP: Counter, Metal Burst, Mirror Coat
|
||||
"counter" or "metal_burst" or "mirror_coat" => 120,
|
||||
// 80 BP: List of variable power and fixed-damage moves
|
||||
"crush_grip" or "dragon_rage" or "electro_ball" or "endeavor" or "final_gambit" or "flail" or "fling"
|
||||
or "frustration" or "grass_knot" or "guardian_of_alola" or "gyro_ball" or "heat_crash" or "heavy_slam"
|
||||
or "hidden_power" or "low_kick" or "natural_gift" or "natures_madness" or "night_shade" or "present"
|
||||
or "psywave" or "punishment" or "return" or "reversal" or "seismic_toss" or "sonic_boom" or "spit_up"
|
||||
or "super_fang" or "trump_card" or "wring_out" => 80,
|
||||
// 20 BP: Stored Power, Power Trip
|
||||
"stored_power" or "power_trip" => 20,
|
||||
_ => moveData.BasePower == 0 ? (byte)1 : moveData.BasePower,
|
||||
};
|
||||
if (FixedBasePowers.TryGetValue(moveData.Name, out var fixedBasePower))
|
||||
return fixedBasePower;
|
||||
|
||||
return moveData.BasePower == 0 ? (byte)1 : moveData.BasePower;
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ public class Galvanize : Script, IScriptChangeMoveType, IScriptChangeDamageModif
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
{
|
||||
if (typeIdentifier?.Name == "normal" &&
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("electric", out var electricType))
|
||||
if (typeIdentifier?.Name == TypeNames.Normal &&
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Electric, out var electricType))
|
||||
{
|
||||
typeIdentifier = electricType;
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class Galvanize : Script, IScriptChangeMoveType, IScriptChangeDamageModif
|
||||
/// <inheritdoc />
|
||||
public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "electric")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Electric)
|
||||
modifier *= 1.2f;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public class Heatproof : Script, IScriptChangeBasePower
|
||||
/// <inheritdoc />
|
||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "fire")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Fire)
|
||||
{
|
||||
basePower = (ushort)(basePower / 2);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class Justified : Script, IScriptOnIncomingHit
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name != "dark")
|
||||
if (move.GetHitData(target, hit).Type?.Name != TypeNames.Dark)
|
||||
return;
|
||||
|
||||
EventBatchId batchId = new();
|
||||
|
||||
@@ -11,7 +11,7 @@ public class LightningRod : Script, IScriptChangeIncomingTargets, IScriptChangeE
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
|
||||
{
|
||||
if (moveChoice.ChosenMove.MoveData.MoveType.Name == "electric" && targets.Count == 1)
|
||||
if (moveChoice.ChosenMove.MoveData.MoveType.Name == TypeNames.Electric && targets.Count == 1)
|
||||
{
|
||||
targets = [moveChoice.User];
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class LightningRod : Script, IScriptChangeIncomingTargets, IScriptChangeE
|
||||
/// <inheritdoc />
|
||||
public void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name != "electric")
|
||||
if (move.GetHitData(target, hit).Type?.Name != TypeNames.Electric)
|
||||
return;
|
||||
|
||||
effectiveness = 0f;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class LiquidVoice : Script, IScriptChangeMoveType
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
{
|
||||
if (move.UseMove.HasFlag(MoveFlags.Sound) &&
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("water", out var waterType))
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Water, out var waterType))
|
||||
{
|
||||
typeIdentifier = waterType;
|
||||
}
|
||||
|
||||
@@ -11,14 +11,14 @@ public class MagnetPull : Script, IScriptPreventOpponentRunAway, IScriptPreventO
|
||||
/// <inheritdoc />
|
||||
public void PreventOpponentRunAway(IFleeChoice choice, ref bool prevent)
|
||||
{
|
||||
if (choice.User.Types.Any(x => x.Name == "steel"))
|
||||
if (choice.User.Types.Any(x => x.Name == TypeNames.Steel))
|
||||
prevent = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PreventOpponentSwitch(ISwitchChoice choice, ref bool prevent)
|
||||
{
|
||||
if (choice.User.Types.Any(x => x.Name == "steel"))
|
||||
if (choice.User.Types.Any(x => x.Name == TypeNames.Steel))
|
||||
prevent = true;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,8 @@ public class Minus : Script, IScriptChangeOffensiveStatValue
|
||||
var battleData = move.User.BattleData;
|
||||
if (battleData is null)
|
||||
return;
|
||||
if (battleData.BattleSide.Pokemon.WhereNotNull().Any(x => x.IsUsable && x.ActiveAbility?.Name == "plus"))
|
||||
if (battleData.BattleSide.Pokemon.WhereNotNull()
|
||||
.Any(x => x.IsUsable && x.ActiveAbility?.Name == AbilityNames.Plus))
|
||||
{
|
||||
value = value.MultiplyOrMax(1.5f);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class MotorDrive : Script, IScriptIsInvulnerableToMove
|
||||
/// <inheritdoc />
|
||||
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
|
||||
{
|
||||
if (move.UseMove.MoveType.Name != "electric")
|
||||
if (move.UseMove.MoveType.Name != TypeNames.Electric)
|
||||
return;
|
||||
invulnerable = true;
|
||||
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
|
||||
@@ -8,72 +8,40 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "multitype")]
|
||||
public class Multitype : Script, IScriptOnAfterHeldItemChange
|
||||
{
|
||||
private static readonly Dictionary<StringKey, StringKey> PlateForms = new()
|
||||
{
|
||||
[ItemNames.FistPlate] = FormNames.ArceusFighting,
|
||||
[ItemNames.FlamePlate] = FormNames.ArceusFire,
|
||||
[ItemNames.ZapPlate] = FormNames.ArceusElectric,
|
||||
[ItemNames.DracoPlate] = FormNames.ArceusDragon,
|
||||
[ItemNames.DreadPlate] = FormNames.ArceusDark,
|
||||
[ItemNames.EarthPlate] = FormNames.ArceusGround,
|
||||
[ItemNames.IciclePlate] = FormNames.ArceusIce,
|
||||
[ItemNames.InsectPlate] = FormNames.ArceusBug,
|
||||
[ItemNames.IronPlate] = FormNames.ArceusSteel,
|
||||
[ItemNames.MeadowPlate] = FormNames.ArceusGrass,
|
||||
[ItemNames.MindPlate] = FormNames.ArceusPsychic,
|
||||
[ItemNames.PixiePlate] = FormNames.ArceusFairy,
|
||||
[ItemNames.SkyPlate] = FormNames.ArceusFlying,
|
||||
[ItemNames.SplashPlate] = FormNames.ArceusWater,
|
||||
[ItemNames.SpookyPlate] = FormNames.ArceusGhost,
|
||||
[ItemNames.StonePlate] = FormNames.ArceusRock,
|
||||
[ItemNames.ToxicPlate] = FormNames.ArceusPoison,
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
|
||||
{
|
||||
if (pokemon.Species.Name != "arceus")
|
||||
if (pokemon.Species.Name != SpeciesNames.Arceus)
|
||||
return;
|
||||
if (item is null && pokemon.Form.Name != "default")
|
||||
if (item is null && pokemon.Form.Name != FormNames.Default)
|
||||
{
|
||||
pokemon.ChangeForm(pokemon.Species.GetDefaultForm());
|
||||
}
|
||||
else if (item is not null && item.Name.ToString().EndsWith("_plate", StringComparison.OrdinalIgnoreCase))
|
||||
else if (item is not null && PlateForms.TryGetValue(item.Name, out var formName) &&
|
||||
pokemon.Species.TryGetForm(formName, out var form))
|
||||
{
|
||||
var platePrefix = item.Name.ToString().Replace("_plate", string.Empty, StringComparison.OrdinalIgnoreCase);
|
||||
switch (platePrefix)
|
||||
{
|
||||
case "fist" when pokemon.Species.TryGetForm("arceus_fighting", out var fightingForm):
|
||||
pokemon.ChangeForm(fightingForm);
|
||||
break;
|
||||
case "flame" when pokemon.Species.TryGetForm("arceus_fire", out var fireForm):
|
||||
pokemon.ChangeForm(fireForm);
|
||||
break;
|
||||
case "shock" when pokemon.Species.TryGetForm("arceus_electric", out var electricForm):
|
||||
pokemon.ChangeForm(electricForm);
|
||||
break;
|
||||
case "draco" when pokemon.Species.TryGetForm("arceus_dragon", out var dragonForm):
|
||||
pokemon.ChangeForm(dragonForm);
|
||||
break;
|
||||
case "dread" when pokemon.Species.TryGetForm("arceus_dark", out var darkForm):
|
||||
pokemon.ChangeForm(darkForm);
|
||||
break;
|
||||
case "earth" when pokemon.Species.TryGetForm("arceus_ground", out var groundForm):
|
||||
pokemon.ChangeForm(groundForm);
|
||||
break;
|
||||
case "icicle" when pokemon.Species.TryGetForm("arceus_ice", out var iceForm):
|
||||
pokemon.ChangeForm(iceForm);
|
||||
break;
|
||||
case "insect" when pokemon.Species.TryGetForm("arceus_bug", out var bugForm):
|
||||
pokemon.ChangeForm(bugForm);
|
||||
break;
|
||||
case "iron" when pokemon.Species.TryGetForm("arceus_steel", out var steelForm):
|
||||
pokemon.ChangeForm(steelForm);
|
||||
break;
|
||||
case "meadow" when pokemon.Species.TryGetForm("arceus_grass", out var grassForm):
|
||||
pokemon.ChangeForm(grassForm);
|
||||
break;
|
||||
case "mind" when pokemon.Species.TryGetForm("arceus_psychic", out var psychicForm):
|
||||
pokemon.ChangeForm(psychicForm);
|
||||
break;
|
||||
case "pixie" when pokemon.Species.TryGetForm("arceus_fairy", out var fairyForm):
|
||||
pokemon.ChangeForm(fairyForm);
|
||||
break;
|
||||
case "sky" when pokemon.Species.TryGetForm("arceus_flying", out var flyingForm):
|
||||
pokemon.ChangeForm(flyingForm);
|
||||
break;
|
||||
case "splash" when pokemon.Species.TryGetForm("arceus_water", out var waterForm):
|
||||
pokemon.ChangeForm(waterForm);
|
||||
break;
|
||||
case "spooky" when pokemon.Species.TryGetForm("arceus_ghost", out var ghostForm):
|
||||
pokemon.ChangeForm(ghostForm);
|
||||
break;
|
||||
case "stone" when pokemon.Species.TryGetForm("arceus_rock", out var rockForm):
|
||||
pokemon.ChangeForm(rockForm);
|
||||
break;
|
||||
case "toxic" when pokemon.Species.TryGetForm("arceus_poison", out var poisonForm):
|
||||
pokemon.ChangeForm(poisonForm);
|
||||
break;
|
||||
}
|
||||
pokemon.ChangeForm(form);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ public class Mummy : Script, IScriptOnIncomingHit
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (!move.GetHitData(target, hit).IsContact || move.User.ActiveAbility?.Name == "mummy" ||
|
||||
!move.Battle.Library.StaticLibrary.Abilities.TryGet("mummy", out var mummyAbility))
|
||||
if (!move.GetHitData(target, hit).IsContact || move.User.ActiveAbility?.Name == AbilityNames.Mummy ||
|
||||
!move.Battle.Library.StaticLibrary.Abilities.TryGet(AbilityNames.Mummy, out var mummyAbility))
|
||||
return;
|
||||
|
||||
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
|
||||
@@ -11,14 +11,14 @@ public class Normalize : Script, IScriptChangeMoveType, IScriptChangeBasePower
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
{
|
||||
if (move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("normal", out var normalType))
|
||||
if (move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Normal, out var normalType))
|
||||
typeIdentifier = normalType;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "normal")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Normal)
|
||||
basePower = (ushort)(basePower * 1.2f); // Boost Normal-type moves by 30%
|
||||
}
|
||||
}
|
||||
@@ -11,15 +11,15 @@ public class Pixilate : Script, IScriptChangeMoveType, IScriptChangeBasePower
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
{
|
||||
if (typeIdentifier?.Name == "normal" &&
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("fairy", out var fairyType))
|
||||
if (typeIdentifier?.Name == TypeNames.Normal &&
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Fairy, out var fairyType))
|
||||
typeIdentifier = fairyType;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "fairy")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Fairy)
|
||||
basePower = (ushort)(basePower * 1.2f); // Boost Normal-type moves by 30%
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,8 @@ public class Plus : Script, IScriptChangeOffensiveStatValue
|
||||
var battleData = move.User.BattleData;
|
||||
if (battleData is null)
|
||||
return;
|
||||
if (battleData.BattleSide.Pokemon.WhereNotNull().Any(x => x.IsUsable && x.ActiveAbility?.Name == "minus"))
|
||||
if (battleData.BattleSide.Pokemon.WhereNotNull()
|
||||
.Any(x => x.IsUsable && x.ActiveAbility?.Name == AbilityNames.Minus))
|
||||
{
|
||||
value = value.MultiplyOrMax(1.5f);
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ public class PowerConstruct : Script, IScriptOnEndTurn
|
||||
{
|
||||
if (_pokemon?.BattleData?.Battle == null)
|
||||
return;
|
||||
if (_pokemon.Species.Name != "zygarde")
|
||||
if (_pokemon.Species.Name != SpeciesNames.Zygarde)
|
||||
return;
|
||||
if (_pokemon.CurrentHealth > _pokemon.BoostedStats.Hp / 2)
|
||||
return;
|
||||
if (_pokemon.Form.Name != "10" || _pokemon.Form.Name != "50")
|
||||
if (_pokemon.Form.Name != FormNames._10 || _pokemon.Form.Name != FormNames._50)
|
||||
return;
|
||||
if (!_pokemon.Species.TryGetForm("complete", out var completeForm))
|
||||
if (!_pokemon.Species.TryGetForm(FormNames.Complete, out var completeForm))
|
||||
return;
|
||||
|
||||
_pokemon.ChangeForm(completeForm);
|
||||
|
||||
@@ -13,7 +13,7 @@ public class QuickFeet : Script, IScriptChangeSpeed
|
||||
{
|
||||
if (choice.User.StatusScript.IsEmpty)
|
||||
return;
|
||||
if (choice.User.StatusScript.Script?.Name == "paralyzed")
|
||||
if (choice.User.StatusScript.Script?.Name == ScriptUtils.ResolveName<Status.Paralyzed>())
|
||||
speed = speed.MultiplyOrMax(2);
|
||||
speed = speed.MultiplyOrMax(1.5f);
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ public class RksSystem : Script, IScriptOnAfterHeldItemChange
|
||||
/// <inheritdoc />
|
||||
public void OnAfterHeldItemChange(IPokemon pokemon, IItem? previous, IItem? item)
|
||||
{
|
||||
if (pokemon.Species.Name != "silvally")
|
||||
if (pokemon.Species.Name != SpeciesNames.Silvally)
|
||||
return;
|
||||
if (item is null && pokemon.Form.Name != "default")
|
||||
if (item is null && pokemon.Form.Name != FormNames.Default)
|
||||
{
|
||||
pokemon.ChangeForm(pokemon.Species.GetDefaultForm());
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Rattled : Script, IScriptOnIncomingHit
|
||||
var type = move.GetHitData(target, hit).Type;
|
||||
if (type is null)
|
||||
return;
|
||||
if (type.Value.Name != "bug" && type.Value.Name != "ghost" && type.Value.Name != "dark")
|
||||
if (type.Value.Name != TypeNames.Bug && type.Value.Name != TypeNames.Ghost && type.Value.Name != TypeNames.Dark)
|
||||
return;
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.ChangeStatBoost(Statistic.Speed, 1, true, false);
|
||||
|
||||
@@ -11,15 +11,15 @@ public class Refrigerate : Script, IScriptChangeMoveType, IScriptChangeBasePower
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
|
||||
{
|
||||
if (typeIdentifier?.Name == "normal" &&
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("ice", out var iceType))
|
||||
if (typeIdentifier?.Name == TypeNames.Normal &&
|
||||
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier(TypeNames.Ice, out var iceType))
|
||||
typeIdentifier = iceType;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "ice")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Ice)
|
||||
basePower = (ushort)(basePower * 1.2f); // Boost Normal-type moves by 30%
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,8 @@ public class SandForce : Script, IScriptChangeBasePower, IScriptCustomTrigger
|
||||
if (move.Battle.WeatherName == ScriptUtils.ResolveName<Weather.Sandstorm>())
|
||||
{
|
||||
var type = move.GetHitData(target, hit).Type;
|
||||
if (type != null &&
|
||||
(type.Value.Name == "rock" || type.Value.Name == "ground" || type.Value.Name == "steel"))
|
||||
if (type != null && (type.Value.Name == TypeNames.Rock || type.Value.Name == TypeNames.Ground ||
|
||||
type.Value.Name == TypeNames.Steel))
|
||||
{
|
||||
basePower = basePower.MultiplyOrMax(1.3f);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class SapSipper : Script, IScriptIsInvulnerableToMove
|
||||
/// <inheritdoc />
|
||||
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
|
||||
{
|
||||
if (move.GetHitData(target, 0).Type?.Name == "grass")
|
||||
if (move.GetHitData(target, 0).Type?.Name == TypeNames.Grass)
|
||||
{
|
||||
invulnerable = true;
|
||||
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
|
||||
@@ -29,15 +29,15 @@ public class Schooling : Script, IScriptOnEndTurn, IScriptOnSwitchIn
|
||||
if (pokemon is null)
|
||||
return;
|
||||
|
||||
if (pokemon.Species.Name != "wishiwashi" || pokemon.BattleData?.Battle == null)
|
||||
if (pokemon.Species.Name != SpeciesNames.Wishiwashi || pokemon.BattleData?.Battle == null)
|
||||
return;
|
||||
// If Wishiwashi has less than 25% health, change to Solo form
|
||||
if (pokemon.CurrentHealth < pokemon.MaxHealth / 4 && pokemon.Form.Name != "default")
|
||||
if (pokemon.CurrentHealth < pokemon.MaxHealth / 4 && pokemon.Form.Name != FormNames.Default)
|
||||
{
|
||||
pokemon.ChangeForm(pokemon.Species.GetDefaultForm());
|
||||
}
|
||||
else if (pokemon.CurrentHealth >= pokemon.MaxHealth / 4 && pokemon.Form.Name != "school" &&
|
||||
pokemon.Species.TryGetForm("school", out var schoolForm))
|
||||
else if (pokemon.CurrentHealth >= pokemon.MaxHealth / 4 && pokemon.Form.Name != FormNames.School &&
|
||||
pokemon.Species.TryGetForm(FormNames.School, out var schoolForm))
|
||||
{
|
||||
pokemon.ChangeForm(schoolForm);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ public class Scrappy : Script, IScriptChangeTypesForMove
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
var hitType = executingMove.GetHitData(target, hitIndex).Type;
|
||||
if (hitType?.Name != "normal" && hitType?.Name != "fighting")
|
||||
if (hitType?.Name != TypeNames.Normal && hitType?.Name != TypeNames.Fighting)
|
||||
return;
|
||||
if (types.Any(x => x.Name == "ghost"))
|
||||
types.RemoveAll(x => x.Name == "ghost");
|
||||
if (types.Any(x => x.Name == TypeNames.Ghost))
|
||||
types.RemoveAll(x => x.Name == TypeNames.Ghost);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ public class ShieldsDown : Script, IScriptOnEndTurn, IScriptOnSwitchIn
|
||||
if (pokemon is null)
|
||||
return;
|
||||
|
||||
if (pokemon.Species.Name != "minior" || pokemon.BattleData?.Battle == null)
|
||||
if (pokemon.Species.Name != SpeciesNames.Minior || pokemon.BattleData?.Battle == null)
|
||||
return;
|
||||
if (pokemon.CurrentHealth < pokemon.MaxHealth / 2 && pokemon.Form.Name.ToString().EndsWith("-meteor"))
|
||||
{
|
||||
@@ -35,7 +35,7 @@ public class ShieldsDown : Script, IScriptOnEndTurn, IScriptOnSwitchIn
|
||||
pokemon.Form.Name.ToString().EndsWith("-meteor") == false)
|
||||
{
|
||||
var baseFormName = pokemon.Form.Name;
|
||||
if (baseFormName == "default")
|
||||
if (baseFormName == FormNames.Default)
|
||||
baseFormName = "blue";
|
||||
var meteorFormName = baseFormName + "-meteor";
|
||||
if (pokemon.Species.TryGetForm(meteorFormName, out var meteorFormData))
|
||||
|
||||
@@ -13,11 +13,11 @@ public class StanceChange : Script, IScriptOnBeforeMove
|
||||
/// <inheritdoc />
|
||||
public void OnBeforeMove(IExecutingMove move)
|
||||
{
|
||||
if (move.User.Species.Name != "aegislash")
|
||||
if (move.User.Species.Name != SpeciesNames.Aegislash)
|
||||
return;
|
||||
|
||||
if (move.UseMove.Category is not (MoveCategory.Physical or MoveCategory.Special) ||
|
||||
move.User.Form.Name == "blade" || !move.User.Species.TryGetForm("blade", out var bladeForm))
|
||||
move.User.Form.Name == FormNames.Blade || !move.User.Species.TryGetForm(FormNames.Blade, out var bladeForm))
|
||||
return;
|
||||
EventBatchId batchId = new();
|
||||
move.Battle.EventHook.Invoke(new AbilityTriggerEvent(move.User)
|
||||
|
||||
@@ -12,7 +12,7 @@ public class Steelworker : Script, IScriptChangeOffensiveStatValue
|
||||
public void ChangeOffensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint defensiveStat,
|
||||
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "steel")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Steel)
|
||||
{
|
||||
value = value.MultiplyOrMax(1.5f);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class StormDrain : Script, IScriptChangeIncomingTargets, IScriptChangeEff
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
|
||||
{
|
||||
if (moveChoice.ChosenMove.MoveData.MoveType.Name == "water" && targets.Count == 1)
|
||||
if (moveChoice.ChosenMove.MoveData.MoveType.Name == TypeNames.Water && targets.Count == 1)
|
||||
{
|
||||
targets = [moveChoice.User];
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class StormDrain : Script, IScriptChangeIncomingTargets, IScriptChangeEff
|
||||
/// <inheritdoc />
|
||||
public void ChangeEffectiveness(IExecutingMove move, IPokemon target, byte hit, ref float effectiveness)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name != "water")
|
||||
if (move.GetHitData(target, hit).Type?.Name != TypeNames.Water)
|
||||
return;
|
||||
|
||||
effectiveness = 0f;
|
||||
|
||||
@@ -12,7 +12,7 @@ public class ThickFat : Script, IScriptChangeMoveDamage
|
||||
public void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
var type = move.GetHitData(target, hit).Type;
|
||||
if (type is not null && (type.Value.Name == "ice" || type.Value.Name == "fire"))
|
||||
if (type is not null && (type.Value.Name == TypeNames.Ice || type.Value.Name == TypeNames.Fire))
|
||||
{
|
||||
damage /= 2;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class VoltAbsorb : Script, IScriptIsInvulnerableToMove
|
||||
/// <inheritdoc />
|
||||
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
|
||||
{
|
||||
if (move.GetHitData(target, 0).Type?.Name != "electric")
|
||||
if (move.GetHitData(target, 0).Type?.Name != TypeNames.Electric)
|
||||
return;
|
||||
invulnerable = true;
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
|
||||
@@ -11,7 +11,7 @@ public class WaterAbsorb : Script, IScriptIsInvulnerableToMove
|
||||
/// <inheritdoc />
|
||||
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
|
||||
{
|
||||
if (move.GetHitData(target, 0).Type?.Name != "water")
|
||||
if (move.GetHitData(target, 0).Type?.Name != TypeNames.Water)
|
||||
return;
|
||||
invulnerable = true;
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
|
||||
@@ -18,14 +18,14 @@ public class WaterBubble : Script, IScriptChangeIncomingMoveDamage, IScriptChang
|
||||
/// <inheritdoc />
|
||||
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "fire")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Fire)
|
||||
damage /= 2;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name == "water")
|
||||
if (move.GetHitData(target, hit).Type?.Name == TypeNames.Water)
|
||||
damage *= 2;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public class WaterCompaction : Script, IScriptOnIncomingHit
|
||||
/// <inheritdoc />
|
||||
public void OnIncomingHit(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
if (move.GetHitData(target, hit).Type?.Name != "water")
|
||||
if (move.GetHitData(target, hit).Type?.Name != TypeNames.Water)
|
||||
return;
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.ChangeStatBoost(Statistic.Defense, 2, true, false);
|
||||
|
||||
@@ -19,14 +19,14 @@ public class ZenMode : Script, IScriptOnEndTurn, IScriptOnSwitchIn
|
||||
if (pokemon is null)
|
||||
return;
|
||||
|
||||
if (pokemon.Species.Name != "darmanitan" || pokemon.BattleData?.Battle == null)
|
||||
if (pokemon.Species.Name != SpeciesNames.Darmanitan || pokemon.BattleData?.Battle == null)
|
||||
return;
|
||||
if (pokemon.CurrentHealth < pokemon.MaxHealth / 2 && pokemon.Form.Name != "zen" &&
|
||||
pokemon.Species.TryGetForm("zen", out var zenForm))
|
||||
if (pokemon.CurrentHealth < pokemon.MaxHealth / 2 && pokemon.Form.Name != FormNames.Zen &&
|
||||
pokemon.Species.TryGetForm(FormNames.Zen, out var zenForm))
|
||||
{
|
||||
pokemon.ChangeForm(zenForm);
|
||||
}
|
||||
else if (pokemon.CurrentHealth >= pokemon.MaxHealth / 2 && pokemon.Form.Name == "zen")
|
||||
else if (pokemon.CurrentHealth >= pokemon.MaxHealth / 2 && pokemon.Form.Name == FormNames.Zen)
|
||||
{
|
||||
pokemon.ChangeForm(pokemon.Species.GetDefaultForm());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user