Skip to content

Commit

Permalink
Toggle weapon before parry (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebuckle authored Jun 16, 2020
1 parent a664a6b commit 690656d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Components/ParryAndRiposte.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,29 @@
using Kingmaker.UnitLogic.Mechanics.Actions;
using Kingmaker.UnitLogic.Mechanics.Components;
using static CallOfTheWild.Helpers;
using static Derring_Do.ThrowAnything;

namespace Derring_Do
{
[ComponentName("Swashbuckler Parry and Riposte")]
[AllowedOn(typeof(BlueprintBuff))]
public class SwashbucklerParryAndRiposte : OwnedGameLogicComponent<UnitDescriptor>, IGlobalRulebookHandler<RuleAttackRoll>, IRulebookHandler<RuleAttackRoll>, IGlobalRulebookSubscriber
{
private bool did_swap = false;

public void OnEventAboutToTrigger(RuleAttackRoll evt)
{
if (evt.Target.Descriptor.Resources.GetResourceAmount(resource) < cost)
{
return;
}

if ((base.Owner.Body.PrimaryHand.Weapon.Blueprint.Category == WeaponCategory.Dagger || base.Owner.Body.PrimaryHand.Weapon.Blueprint.Category == WeaponCategory.Starknife) && base.Owner.Body.PrimaryHand.Weapon.Blueprint.IsRanged)
{
ThrowAnything.toggleThrown(base.Owner.Body.PrimaryHand.Weapon, evt.Initiator);
did_swap = true;
}

if (!evt.Weapon.Blueprint.IsMelee || evt.Parry != null || !base.Owner.Unit.IsEnemy(evt.Initiator))
{
return;
Expand All @@ -50,6 +60,7 @@ public void OnEventAboutToTrigger(RuleAttackRoll evt)
}
}
*/

evt.TryParry(base.Owner.Unit, base.Owner.Body.PrimaryHand.Weapon, 0);
if (evt.Parry == null)
{
Expand All @@ -66,6 +77,11 @@ public void OnEventAboutToTrigger(RuleAttackRoll evt)

public void OnEventDidTrigger(RuleAttackRoll evt)
{
if (did_swap)
{
ThrowAnything.toggleThrown(base.Owner.Body.PrimaryHand.Weapon, evt.Initiator);
}
did_swap = false;
RuleAttackRoll.ParryData parry = evt.Parry;
if (((parry != null) ? parry.Initiator : null) != base.Owner.Unit)
{
Expand Down

0 comments on commit 690656d

Please sign in to comment.