This commit is contained in:
parent
a5675024a4
commit
e5041ec5f0
@ -1,3 +1,4 @@
|
||||
using PkmnLib.Dynamic.Events;
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Dynamic.Models.Choices;
|
||||
using PkmnLib.Dynamic.ScriptHandling;
|
||||
@ -180,6 +181,7 @@ public static class TurnRunner
|
||||
var side = battle.Sides[itemChoice.TargetSide.Value];
|
||||
target = side.Pokemon[itemChoice.TargetPosition.Value];
|
||||
}
|
||||
battle.EventHook.Invoke(new ItemUseEvent(user, itemChoice.Item));
|
||||
itemChoice.Item.RunItemScript(battle.Library.ScriptResolver, target ?? user, battle.EventHook);
|
||||
}
|
||||
}
|
19
PkmnLib.Dynamic/Events/ItemUseEvent.cs
Normal file
19
PkmnLib.Dynamic/Events/ItemUseEvent.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using PkmnLib.Dynamic.Models;
|
||||
using PkmnLib.Static;
|
||||
|
||||
namespace PkmnLib.Dynamic.Events;
|
||||
|
||||
public record ItemUseEvent : IEventData
|
||||
{
|
||||
public ItemUseEvent(IPokemon pokemon, IItem itemUsed)
|
||||
{
|
||||
Pokemon = pokemon;
|
||||
ItemUsed = itemUsed;
|
||||
}
|
||||
|
||||
public IPokemon Pokemon { get; set; }
|
||||
public IItem ItemUsed { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public EventBatchId BatchId { get; init; }
|
||||
}
|
@ -535,13 +535,16 @@ public class BattleImpl : ScriptSource, IBattle
|
||||
}
|
||||
EventHook.Invoke(new CaptureAttemptEvent(target, attemptCapture, item));
|
||||
|
||||
if (!CanSlotBeFilled(sideIndex, position))
|
||||
if (attemptCapture.IsCaught)
|
||||
{
|
||||
Sides[sideIndex].MarkPositionAsUnfillable(position);
|
||||
}
|
||||
Sides[sideIndex].ForceClearPokemonFromField(position);
|
||||
if (!CanSlotBeFilled(sideIndex, position))
|
||||
{
|
||||
Sides[sideIndex].MarkPositionAsUnfillable(position);
|
||||
}
|
||||
Sides[sideIndex].ForceClearPokemonFromField(position);
|
||||
|
||||
ValidateBattleState();
|
||||
ValidateBattleState();
|
||||
}
|
||||
return attemptCapture;
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class Gen7CaptureLibrary : ICaptureLibrary
|
||||
}
|
||||
}
|
||||
}
|
||||
var success = shakes >= 3;
|
||||
var success = shakes >= 4;
|
||||
return new CaptureResult(success, shakes, false);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user