More moves implemented
This commit is contained in:
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SleepTalk.cs
Normal file
34
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/SleepTalk.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.MoveVolatile;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "sleep_talk")]
|
||||
public class SleepTalk : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeMove(IMoveChoice choice, ref StringKey moveName)
|
||||
{
|
||||
if (!choice.User.HasStatus(ScriptUtils.ResolveName<Status.Sleep>()))
|
||||
{
|
||||
choice.Fail();
|
||||
return;
|
||||
}
|
||||
var battleData = choice.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
var moves = choice.User.Moves.WhereNotNull().Where(x => x.MoveData.CanCopyMove())
|
||||
.Where(x => x != choice.ChosenMove).OrderBy(_ => battleData.Battle.Random.GetInt()).FirstOrDefault();
|
||||
if (moves == null)
|
||||
{
|
||||
choice.Fail();
|
||||
return;
|
||||
}
|
||||
moveName = moves.MoveData.Name;
|
||||
choice.Volatile.Add(new BypassSleepVolatile());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user