This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
[Script(ScriptCategory.Side, "mist")]
|
||||
|
||||
44
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpikesEffect.cs
Normal file
44
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpikesEffect.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
[Script(ScriptCategory.Side, "spikes")]
|
||||
public class SpikesEffect : Script
|
||||
{
|
||||
private int _layers = 1;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Stack()
|
||||
{
|
||||
if (_layers < 3)
|
||||
_layers++;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
if (pokemon.IsFloating)
|
||||
return;
|
||||
|
||||
var modifier = _layers switch
|
||||
{
|
||||
1 => 1 / 16f,
|
||||
2 => 3 / 16f,
|
||||
3 => 1 / 4f,
|
||||
_ => throw new ArgumentOutOfRangeException(),
|
||||
};
|
||||
var damage = (uint)(pokemon.MaxHealth * modifier);
|
||||
|
||||
EventBatchId eventBatch = new();
|
||||
pokemon.Damage(damage, DamageSource.Misc, eventBatch);
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new DialogEvent("spikes_damage", new Dictionary<string, object>
|
||||
{
|
||||
{ "pokemon", pokemon },
|
||||
})
|
||||
{
|
||||
BatchId = eventBatch,
|
||||
});
|
||||
}
|
||||
}
|
||||
33
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpotlightEffect.cs
Normal file
33
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/SpotlightEffect.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections.Generic;
|
||||
using PkmnLib.Dynamic.Models.BattleFlow;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
public class SpotlightEffect : Script
|
||||
{
|
||||
private readonly byte _position;
|
||||
private readonly IBattleSide _side;
|
||||
|
||||
public SpotlightEffect(IBattleSide side, byte position)
|
||||
{
|
||||
_side = side;
|
||||
_position = position;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
|
||||
{
|
||||
if (!TargetResolver.IsValidTarget(_side.Index, _position, moveChoice.ChosenMove.MoveData.Target,
|
||||
moveChoice.User))
|
||||
return;
|
||||
if (_side.Pokemon[_position] == null)
|
||||
return;
|
||||
targets = [_side.Pokemon[_position]!];
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnEndTurn(IBattle battle)
|
||||
{
|
||||
RemoveSelf();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
[Script(ScriptCategory.Side, "stealth_rock")]
|
||||
public class StealthRockEffect : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
var typeLibrary = pokemon.Library.StaticLibrary.Types;
|
||||
var effectiveness = 1.0f;
|
||||
if (typeLibrary.TryGetTypeIdentifier("rock", out var rockType))
|
||||
{
|
||||
effectiveness = typeLibrary.GetEffectiveness(rockType, pokemon.Types);
|
||||
}
|
||||
var damage = (uint)(pokemon.MaxHealth / 8f * effectiveness);
|
||||
EventBatchId batchId = new();
|
||||
pokemon.Damage(damage, DamageSource.Misc, batchId);
|
||||
pokemon.BattleData?.Battle.EventHook.Invoke(new DialogEvent("stealth_rock_damage",
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "pokemon", pokemon },
|
||||
}));
|
||||
}
|
||||
}
|
||||
13
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/StickyWebEffect.cs
Normal file
13
Plugins/PkmnLib.Plugin.Gen7/Scripts/Side/StickyWebEffect.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
[Script(ScriptCategory.Side, "sticky_web")]
|
||||
public class StickyWebEffect : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void OnSwitchIn(IPokemon pokemon, byte position)
|
||||
{
|
||||
if (pokemon.IsFloating)
|
||||
return;
|
||||
pokemon.ChangeStatBoost(Statistic.Speed, -1, false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user