From 58e46a3ae14ff3c2c5d38a1c021628c8f2cd2751 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Sat, 6 Jan 2024 14:13:48 -0800 Subject: [PATCH] adjust NPC dash direction --- State/Thinker/DashDefensive.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/State/Thinker/DashDefensive.cs b/State/Thinker/DashDefensive.cs index d283aad..11a81e1 100644 --- a/State/Thinker/DashDefensive.cs +++ b/State/Thinker/DashDefensive.cs @@ -61,16 +61,16 @@ public partial class DashDefensive : AttackState // doc will still dash if you are farther than normal but // moving towards him - float distThreshold = 50 - (dot * 20); + float distThreshold = UseItemDistance - (dot * 20); // dash towards if lance in anticipate state // or just directly dash towards you if you are too far shouldDashTowards = (isTargetStunned || _dashedAway) && - swordState is State.Weapon.SwordAnticipateState || - dist > MaxDistanceToTarget; + (swordState is State.Weapon.SwordAnticipateState || + dist > MaxDistanceToTarget); shouldDashAway = dist < distThreshold && !isTargetStunned && - swordState is not State.Weapon.SwordAnticipateState; + swordState is State.Weapon.SwordIdleState; //if (!isTargetStunned && dist < 2500 && !_dashedAway) if (shouldDashAway && !shouldDashTowards) @@ -83,9 +83,14 @@ public partial class DashDefensive : AttackState } else if (shouldDashTowards && !shouldDashAway) { + // our required velocity is dependent on final distance to target + float maxVelocity = dist / 0.1f; + var dashSpeed = Mathf.Max(maxVelocity, + _originalDashModifier * NPC.Speed); + float ratio = dashSpeed / NPC.Speed; + _dashState.VelocityModifier = ratio; + // dash to player's predicted position - _dashState.VelocityModifier = _originalDashModifier * 1.75f; - var dashSpeed = _dashState.VelocityModifier * NPC.Speed; var newPos = Utils.Physics.PredictNewPosition( NPC.GlobalPosition, dashSpeed, @@ -100,6 +105,8 @@ public partial class DashDefensive : AttackState NPC.UseCurrentItem(); } } + + return null; } return PursueState ?? PassiveState;