This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Battle;
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Side;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
@@ -11,8 +12,28 @@ public class FutureSight : Script, IScriptStopBeforeMove
|
||||
var battleData = move.User.BattleData;
|
||||
if (battleData == null)
|
||||
return;
|
||||
battleData.Battle.Volatile.Add(new FutureSightEffect(move.MoveChoice));
|
||||
var battle = battleData.Battle;
|
||||
var moveChoice = move.MoveChoice;
|
||||
|
||||
prevent = true;
|
||||
|
||||
if (IsTargetAlreadySetToBeHit(battle, moveChoice.TargetSide, moveChoice.TargetPosition))
|
||||
{
|
||||
moveChoice.Fail();
|
||||
return;
|
||||
}
|
||||
|
||||
if (battle.Volatile.TryGet<FutureSightEffect>(out var effect))
|
||||
effect.AddStrike(moveChoice);
|
||||
else
|
||||
battle.Volatile.Add(new FutureSightEffect(moveChoice));
|
||||
}
|
||||
|
||||
private static bool IsTargetAlreadySetToBeHit(IBattle battle, byte side, byte position)
|
||||
{
|
||||
if (battle.Volatile.TryGet<FutureSightEffect>(out var futureSight) && futureSight.HasStrikeAt(side, position))
|
||||
return true;
|
||||
var doomDesire = battle.Sides[side].VolatileScripts.Get<DoomDesireEffect>();
|
||||
return doomDesire != null && doomDesire.HasTarget(position);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user