This commit is contained in:
parent
02510fd1d0
commit
6394f4eab3
@ -774,7 +774,7 @@ public abstract class Script : IDeepCloneable
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function allows a script to prevent a Pokémon from being affected by a volatile status condition.
|
/// This function allows a script to prevent a Pokémon from being affected by a volatile status condition.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void PreventVolatileAdd(Script script, ref bool preventVolatileAdd)
|
public virtual void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public interface IScriptSet : IEnumerable<ScriptContainer>
|
|||||||
/// <inheritdoc cref="IScriptSet"/>
|
/// <inheritdoc cref="IScriptSet"/>
|
||||||
public class ScriptSet : IScriptSet
|
public class ScriptSet : IScriptSet
|
||||||
{
|
{
|
||||||
private IScriptSource _source;
|
private readonly IScriptSource _source;
|
||||||
|
|
||||||
private readonly List<ScriptContainer> _scripts = [];
|
private readonly List<ScriptContainer> _scripts = [];
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ public class ScriptSet : IScriptSet
|
|||||||
if (!forceAdd)
|
if (!forceAdd)
|
||||||
{
|
{
|
||||||
var preventVolatileAdd = false;
|
var preventVolatileAdd = false;
|
||||||
_source.RunScriptHook(x => x.PreventVolatileAdd(script, ref preventVolatileAdd));
|
_source.RunScriptHook(x => x.PreventVolatileAdd(_source, script, ref preventVolatileAdd));
|
||||||
if (preventVolatileAdd)
|
if (preventVolatileAdd)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class InnerFocus : Script
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventVolatileAdd(Script script, ref bool preventVolatileAdd)
|
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
||||||
{
|
{
|
||||||
if (script is not FlinchEffect)
|
if (script is not FlinchEffect)
|
||||||
return;
|
return;
|
||||||
|
@ -11,7 +11,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
public class Oblivious : Script
|
public class Oblivious : Script
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventVolatileAdd(Script script, ref bool preventVolatileAdd)
|
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
||||||
{
|
{
|
||||||
preventVolatileAdd = script switch
|
preventVolatileAdd = script switch
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
|||||||
public class OwnTempo : Script
|
public class OwnTempo : Script
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventVolatileAdd(Script script, ref bool preventVolatileAdd)
|
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
||||||
{
|
{
|
||||||
if (script is Pokemon.Confusion)
|
if (script is Pokemon.Confusion)
|
||||||
preventVolatileAdd = true;
|
preventVolatileAdd = true;
|
||||||
|
@ -12,7 +12,7 @@ public class SafeguardEffect : Script
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void PreventVolatileAdd(Script script, ref bool preventVolatileAdd)
|
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
||||||
{
|
{
|
||||||
if (script.Category == ScriptCategory.Pokemon && script.Name == ScriptUtils.ResolveName<Confusion>())
|
if (script.Category == ScriptCategory.Pokemon && script.Name == ScriptUtils.ResolveName<Confusion>())
|
||||||
preventVolatileAdd = true;
|
preventVolatileAdd = true;
|
||||||
|
@ -3,5 +3,36 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
|
|||||||
[Script(ScriptCategory.Terrain, "electric_terrain")]
|
[Script(ScriptCategory.Terrain, "electric_terrain")]
|
||||||
public class ElectricTerrain : Script
|
public class ElectricTerrain : Script
|
||||||
{
|
{
|
||||||
// TODO: Implement Terrain
|
private static bool IsAffectedByTerrain(IPokemon pokemon) =>
|
||||||
|
!pokemon.IsFloating;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||||
|
{
|
||||||
|
if (!IsAffectedByTerrain(move.User))
|
||||||
|
return;
|
||||||
|
var type = move.GetHitData(target, hit).Type;
|
||||||
|
if (type?.Name == "electric")
|
||||||
|
basePower = basePower.MultiplyOrMax(1.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
||||||
|
ref bool preventStatus)
|
||||||
|
{
|
||||||
|
if (!IsAffectedByTerrain(pokemon))
|
||||||
|
return;
|
||||||
|
if (status == ScriptUtils.ResolveName<Status.Sleep>())
|
||||||
|
preventStatus = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
|
||||||
|
{
|
||||||
|
if (parent is IPokemon pokemon && !IsAffectedByTerrain(pokemon))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (script is Pokemon.YawnEffect)
|
||||||
|
preventVolatileAdd = true;
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,5 +3,46 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
|
|||||||
[Script(ScriptCategory.Terrain, "grassy_terrain")]
|
[Script(ScriptCategory.Terrain, "grassy_terrain")]
|
||||||
public class GrassyTerrain : Script
|
public class GrassyTerrain : Script
|
||||||
{
|
{
|
||||||
// TODO: Implement Terrain
|
private static bool IsAffectedByTerrain(IPokemon pokemon) =>
|
||||||
|
!pokemon.IsFloating;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||||
|
{
|
||||||
|
// It boosts the power of Grass-type moves used by affected Pokémon by 50% (regardless of whether the target of
|
||||||
|
// the move is affected by Grassy Terrain).
|
||||||
|
if (IsAffectedByTerrain(move.User))
|
||||||
|
{
|
||||||
|
var type = move.GetHitData(target, hit).Type;
|
||||||
|
if (type?.Name == "grass")
|
||||||
|
{
|
||||||
|
basePower = basePower.MultiplyOrMax(1.5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The power of Bulldoze, Earthquake, and Magnitude is halved against affected targets (regardless of whether the
|
||||||
|
// user of the move is affected by Grassy Terrain).
|
||||||
|
if (IsAffectedByTerrain(target))
|
||||||
|
{
|
||||||
|
var moveName = move.UseMove.Name;
|
||||||
|
if (moveName == "bulldoze" || moveName == "earthquake" || moveName == "magnitude")
|
||||||
|
{
|
||||||
|
basePower /= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnEndTurn(IScriptSource owner, IBattle battle)
|
||||||
|
{
|
||||||
|
// At the end of each turn, Grassy Terrain restores 1/16 of the maximum HP of each affected Pokémon.
|
||||||
|
foreach (var pokemon in battle.Sides.SelectMany(x => x.Pokemon).WhereNotNull())
|
||||||
|
{
|
||||||
|
if (!IsAffectedByTerrain(pokemon) || pokemon.IsFainted)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var healing = pokemon.MaxHealth / 16f;
|
||||||
|
pokemon.Heal((uint)healing);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,5 +3,26 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
|
|||||||
[Script(ScriptCategory.Terrain, "misty_terrain")]
|
[Script(ScriptCategory.Terrain, "misty_terrain")]
|
||||||
public class MistyTerrain : Script
|
public class MistyTerrain : Script
|
||||||
{
|
{
|
||||||
// TODO: Implement Terrain
|
private static bool IsAffectedByTerrain(IPokemon pokemon) =>
|
||||||
|
!pokemon.IsFloating;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||||
|
{
|
||||||
|
if (!IsAffectedByTerrain(target))
|
||||||
|
return;
|
||||||
|
if (move.GetHitData(target, hit).Type?.Name == "dragon")
|
||||||
|
{
|
||||||
|
basePower /= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted,
|
||||||
|
ref bool preventStatus)
|
||||||
|
{
|
||||||
|
if (!IsAffectedByTerrain(pokemon))
|
||||||
|
return;
|
||||||
|
preventStatus = true;
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,5 +3,34 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
|
|||||||
[Script(ScriptCategory.Terrain, "psychic_terrain")]
|
[Script(ScriptCategory.Terrain, "psychic_terrain")]
|
||||||
public class PsychicTerrain : Script
|
public class PsychicTerrain : Script
|
||||||
{
|
{
|
||||||
// TODO: Implement Terrain
|
private static bool IsAffectedByTerrain(IPokemon pokemon) =>
|
||||||
|
!pokemon.IsFloating;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||||
|
{
|
||||||
|
if (!IsAffectedByTerrain(move.User))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// It boosts the power of Psychic-type moves used by affected Pokémon by 50% (regardless of whether the target of
|
||||||
|
// the move is affected by Psychic Terrain).
|
||||||
|
var type = move.GetHitData(target, hit).Type;
|
||||||
|
if (type?.Name == "psychic")
|
||||||
|
{
|
||||||
|
basePower = basePower.MultiplyOrMax(1.5f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
|
||||||
|
{
|
||||||
|
if (!IsAffectedByTerrain(target))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Psychic Terrain prevents priority moves from affecting affected Pokémon.
|
||||||
|
if (move.MoveChoice.Priority > 0)
|
||||||
|
{
|
||||||
|
invulnerable = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user