Bunch more moves, changes in how additional information for items works.
This commit is contained in:
38
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Metronome.cs
Normal file
38
Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Metronome.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Utils;
|
||||
using PkmnLib.Static.Utils;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "metronome")]
|
||||
public class Metronome : Script
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void ChangeMove(IMoveChoice choice, ref StringKey moveName)
|
||||
{
|
||||
var battleData = choice.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
|
||||
var library = choice.User.Library;
|
||||
var moveLibrary = library.StaticLibrary.Moves;
|
||||
|
||||
var retryCount = 0;
|
||||
while (true)
|
||||
{
|
||||
// Breaker for infinite loop. The odds that we'd accidentally roll a non-copyable move 100 times in a row
|
||||
// is extremely unlikely, unless the loaded move library only contains non-copyable moves.
|
||||
// This is a failsafe.
|
||||
if (retryCount > 100)
|
||||
throw new Exception("Metronome failed to find a valid move after 100 attempts.");
|
||||
var randomMove = moveLibrary.GetRandom(battleData.Battle.Random);
|
||||
if (!randomMove.CanCopyMove())
|
||||
{
|
||||
retryCount++;
|
||||
continue;
|
||||
}
|
||||
moveName = randomMove.Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user