change parry to use stagger instead of direct stun
parent
fc5ea41e3a
commit
341f5137eb
|
@ -27,7 +27,7 @@ public partial class Character : CharacterBody2D, IFaction
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public CharacterStats Stats { get; private set; }
|
public CharacterStats Stats { get; protected set; }
|
||||||
|
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void HealthChangedEventHandler(Events.HealthChangedArgs args);
|
public delegate void HealthChangedEventHandler(Events.HealthChangedArgs args);
|
||||||
|
@ -115,7 +115,7 @@ public partial class Character : CharacterBody2D, IFaction
|
||||||
|
|
||||||
if (Stats is not null)
|
if (Stats is not null)
|
||||||
{
|
{
|
||||||
Stats.Stagger += (double time) =>
|
Stats.Stagger += (double time, float staggerDamage) =>
|
||||||
{
|
{
|
||||||
Stun(time);
|
Stun(time);
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,7 +42,6 @@ public sealed partial class Player : Character
|
||||||
[Export]
|
[Export]
|
||||||
public AnimationTree AnimationTree { get; private set; }
|
public AnimationTree AnimationTree { get; private set; }
|
||||||
|
|
||||||
[Export]
|
|
||||||
public new PlayerStats Stats { get; private set; }
|
public new PlayerStats Stats { get; private set; }
|
||||||
|
|
||||||
public InteractionRay InteractionRay { get; private set; }
|
public InteractionRay InteractionRay { get; private set; }
|
||||||
|
@ -54,8 +53,10 @@ public sealed partial class Player : Character
|
||||||
_characterEffects = GetNode<Node2D>("%CharacterEffects");
|
_characterEffects = GetNode<Node2D>("%CharacterEffects");
|
||||||
_targetTracer = GetNode<TargetTracer>("%TargetTracer");
|
_targetTracer = GetNode<TargetTracer>("%TargetTracer");
|
||||||
|
|
||||||
|
base.Stats = GetNode<PlayerStats>("Stats");
|
||||||
|
Stats = (PlayerStats)base.Stats;
|
||||||
|
|
||||||
base._Ready();
|
base._Ready();
|
||||||
Stats = GetNode<PlayerStats>("Stats");
|
|
||||||
|
|
||||||
Inventory.UsedItem += (Items.Item item) =>
|
Inventory.UsedItem += (Items.Item item) =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,5 +10,7 @@ public interface IParryable
|
||||||
|
|
||||||
public ulong ParryTimeOrigin { get; }
|
public ulong ParryTimeOrigin { get; }
|
||||||
|
|
||||||
public void Stun();
|
public float BlockForce { get; }
|
||||||
|
|
||||||
|
public void Stun(float blockForce);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,9 @@ public partial class Sword : Weapon, IParryable
|
||||||
|
|
||||||
public ulong ParryTimeOrigin { get; protected set; }
|
public ulong ParryTimeOrigin { get; protected set; }
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
public float BlockForce { get; set; } = 1;
|
||||||
|
|
||||||
private Tween _currentTween;
|
private Tween _currentTween;
|
||||||
|
|
||||||
private AnimationNodeStateMachinePlayback _playback;
|
private AnimationNodeStateMachinePlayback _playback;
|
||||||
|
@ -214,7 +217,7 @@ public partial class Sword : Weapon, IParryable
|
||||||
{
|
{
|
||||||
// our character was parried
|
// our character was parried
|
||||||
ParryParticles.CloneOnWorld<GpuParticles2D>().EmitOneShot();
|
ParryParticles.CloneOnWorld<GpuParticles2D>().EmitOneShot();
|
||||||
Stun();
|
Stun(otherParryable.BlockForce);
|
||||||
|
|
||||||
if (otherParryable is Sword sword)
|
if (otherParryable is Sword sword)
|
||||||
{
|
{
|
||||||
|
@ -235,12 +238,13 @@ public partial class Sword : Weapon, IParryable
|
||||||
/// Stuns the wepaon holder. This is unique to swords and melee weapons
|
/// Stuns the wepaon holder. This is unique to swords and melee weapons
|
||||||
/// if they can parry.
|
/// if they can parry.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Stun()
|
public void Stun(float blockForce)
|
||||||
{
|
{
|
||||||
IsParried = true;
|
IsParried = true;
|
||||||
AnimationPlayer.SpeedScale = 0.25f;
|
Character.Stats.AddStaggerDamage(Damage * blockForce);
|
||||||
Character.Stun(2);
|
|
||||||
GetNode<AudioStreamPlayer2D>("ParrySound")
|
// optionally play parry sound
|
||||||
|
GetNode<AudioStreamPlayer2D>("ParrySound")?
|
||||||
.OnWorld()
|
.OnWorld()
|
||||||
.WithPitchDeviation(0.125f)
|
.WithPitchDeviation(0.125f)
|
||||||
.PlayOneShot();
|
.PlayOneShot();
|
||||||
|
|
|
@ -25,9 +25,13 @@ public partial class SwordBlockState : WeaponState
|
||||||
|
|
||||||
private bool _isAlternate = false;
|
private bool _isAlternate = false;
|
||||||
|
|
||||||
|
private float _oldBlockForce;
|
||||||
|
|
||||||
public override WeaponState Enter(IState<WeaponState> prevState)
|
public override WeaponState Enter(IState<WeaponState> prevState)
|
||||||
{
|
{
|
||||||
Sword.EnableParry(ulong.MaxValue);
|
Sword.EnableParry(ulong.MaxValue);
|
||||||
|
_oldBlockForce = Sword.BlockForce;
|
||||||
|
Sword.BlockForce *= 4;
|
||||||
|
|
||||||
_useDuration = Sword.UseAltTime;
|
_useDuration = Sword.UseAltTime;
|
||||||
_attackDuration = Sword.AttackAltTime;
|
_attackDuration = Sword.AttackAltTime;
|
||||||
|
@ -55,6 +59,12 @@ public partial class SwordBlockState : WeaponState
|
||||||
|
|
||||||
public override void Exit(IState<WeaponState> nextState)
|
public override void Exit(IState<WeaponState> nextState)
|
||||||
{
|
{
|
||||||
|
if (nextState == IdleState)
|
||||||
|
{
|
||||||
|
Sword.AnimationPlayer.Play("RESET");
|
||||||
|
}
|
||||||
|
|
||||||
|
Sword.BlockForce = _oldBlockForce;
|
||||||
Deattack();
|
Deattack();
|
||||||
HasBlocked = false;
|
HasBlocked = false;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +81,6 @@ public partial class SwordBlockState : WeaponState
|
||||||
|
|
||||||
if ((_useDuration -= delta) <= 0)
|
if ((_useDuration -= delta) <= 0)
|
||||||
{
|
{
|
||||||
Sword.AnimationPlayer.Play("RESET");
|
|
||||||
return IdleState;
|
return IdleState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ public partial class StunEffect : ColorRect
|
||||||
{
|
{
|
||||||
Events.EventBus.Instance.PlayerStun += () =>
|
Events.EventBus.Instance.PlayerStun += () =>
|
||||||
{
|
{
|
||||||
GD.Print("PLAYER STUNNED!!!");
|
|
||||||
GetNode<AnimationPlayer>("AnimationPlayer").Play("tighten");
|
GetNode<AnimationPlayer>("AnimationPlayer").Play("tighten");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public partial class CharacterStats : Node
|
||||||
public double MaxStagger { get; set; } = 25;
|
public double MaxStagger { get; set; } = 25;
|
||||||
|
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void StaggerEventHandler(double time);
|
public delegate void StaggerEventHandler(double time, float damage);
|
||||||
|
|
||||||
public bool ShouldStagger => StaggerDamage.Value >= MaxStagger;
|
public bool ShouldStagger => StaggerDamage.Value >= MaxStagger;
|
||||||
|
|
||||||
|
@ -42,10 +42,12 @@ public partial class CharacterStats : Node
|
||||||
|
|
||||||
public void AddStaggerDamage(float damage)
|
public void AddStaggerDamage(float damage)
|
||||||
{
|
{
|
||||||
StaggerDamage.Value += damage * StaggerCoefficient;
|
float delta = damage * (float)StaggerCoefficient;
|
||||||
|
StaggerDamage.Value += delta;
|
||||||
if (StaggerDamage.Value >= MaxStagger)
|
if (StaggerDamage.Value >= MaxStagger)
|
||||||
{
|
{
|
||||||
EmitSignal(SignalName.Stagger, 1);
|
EmitSignal(SignalName.Stagger, 1, delta);
|
||||||
|
StaggerDamage.Value = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue