Skip to content

Commit 2835dbe

Browse files
authored
Bugfix: Add move-check timeout to untargeted Actions [GOMPS-467] (#273)
* Adds move-check timeout to untargeted Actions [GOMPS-467] * new approach: only abort interruptible actions * Subtly change meaning of ActionInterruptible boolean to mean "don't move while performing it" * comment tweaks * better comment
1 parent 0b14663 commit 2835dbe

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

Assets/BossRoom/Scripts/Client/Game/Character/ClientInputSender.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,18 @@ private void PerformSkill(ActionType actionType, SkillTriggerStyle triggerStyle,
225225

226226
if (GetActionRequestForTarget(hitTransform, actionType, triggerStyle, out ActionRequestData playerAction))
227227
{
228-
//Don't trigger our move logic for another 500ms. This protects us from moving just because we clicked on them to target them.
228+
//Don't trigger our move logic for a while. This protects us from moving just because we clicked on them to target them.
229229
m_LastSentMove = Time.time + k_TargetMoveTimeout;
230230

231231
ActionInputEvent?.Invoke(playerAction);
232232
m_NetworkCharacter.RecvDoActionServerRPC(playerAction);
233233
}
234234
else if(actionType != ActionType.GeneralTarget )
235235
{
236-
// clicked on nothing... perform a "miss" attack on the spot they clicked on
236+
// clicked on nothing... perform an "untargeted" attack on the spot they clicked on.
237+
// (Different Actions will deal with this differently. For some, like archer arrows, this will fire an arrow
238+
// in the desired direction. For others, like mage's bolts, this will fire a "miss" projectile at the spot clicked on.)
239+
237240
var data = new ActionRequestData();
238241
PopulateSkillRequest(k_CachedHit[0].point, actionType, ref data);
239242

Assets/BossRoom/Scripts/Server/Game/Action/ActionPlayer.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public class ActionPlayer
1111
{
1212
private ServerCharacter m_Parent;
1313

14+
private ServerCharacterMovement m_Movement;
15+
1416
private List<Action> m_Queue;
1517

1618
private List<Action> m_NonBlockingActions;
@@ -30,6 +32,7 @@ public class ActionPlayer
3032
public ActionPlayer(ServerCharacter parent)
3133
{
3234
m_Parent = parent;
35+
m_Movement = parent.GetComponent<ServerCharacterMovement>();
3336
m_Queue = new List<Action>();
3437
m_NonBlockingActions = new List<Action>();
3538
m_LastUsedTimestamps = new Dictionary<ActionType, float>();
@@ -134,6 +137,13 @@ private void StartAction()
134137
return; // ... so it's important not to try to do anything more here
135138
}
136139

140+
// if this Action is interruptible, that means movement should interrupt it... character needs to be stationary for this!
141+
// So stop any movement that's already happening before we begin
142+
if (m_Queue[0].Description.ActionInterruptible && !m_Movement.IsPerformingForcedMovement())
143+
{
144+
m_Movement.CancelMove();
145+
}
146+
137147
// remember that we successfully used this Action!
138148
m_LastUsedTimestamps[m_Queue[0].Description.ActionTypeEnum] = Time.time;
139149

Assets/BossRoom/Scripts/Server/Game/Action/StealthModeAction.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ public override bool Start()
2020
{
2121
m_Parent.NetState.RecvDoActionClientRPC(Data);
2222

23-
// not allowed to walk while going stealthy!
24-
var movement = m_Parent.GetComponent<ServerCharacterMovement>();
25-
if (!movement.IsPerformingForcedMovement())
26-
{
27-
movement.CancelMove();
28-
}
2923
return true;
3024
}
3125

Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,18 @@ private void OnClientMoveRequest(Vector3 targetPosition)
108108
{
109109
if (NetState.NetworkLifeState.Value == LifeState.Alive && !m_Movement.IsPerformingForcedMovement())
110110
{
111-
ClearActions(false);
111+
// if we're currently playing an interruptible action, interrupt it!
112+
if (m_ActionPlayer.GetActiveActionInfo(out ActionRequestData data))
113+
{
114+
if (GameDataSource.Instance.ActionDataByType.TryGetValue(data.ActionTypeEnum, out ActionDescription description))
115+
{
116+
if (description.ActionInterruptible)
117+
{
118+
m_ActionPlayer.ClearActions(false);
119+
}
120+
}
121+
}
122+
112123
m_ActionPlayer.CancelRunningActionsByLogic(ActionLogic.Target, true); //clear target on move.
113124
m_Movement.SetMovementTarget(targetPosition);
114125
}
@@ -118,19 +129,11 @@ private void OnLifeStateChanged(LifeState prevLifeState, LifeState lifeState)
118129
{
119130
if (lifeState != LifeState.Alive)
120131
{
121-
ClearActions(true);
132+
m_ActionPlayer.ClearActions(true);
122133
m_Movement.CancelMove();
123134
}
124135
}
125136

126-
/// <summary>
127-
/// Clear all active Actions.
128-
/// </summary>
129-
public void ClearActions(bool alsoClearNonBlockingActions)
130-
{
131-
m_ActionPlayer.ClearActions(alsoClearNonBlockingActions);
132-
}
133-
134137
private void OnActionPlayRequest(ActionRequestData data)
135138
{
136139
if (!GameDataSource.Instance.ActionDataByType[data.ActionTypeEnum].IsFriendly)
@@ -185,7 +188,7 @@ public void ReceiveHP(ServerCharacter inflicter, int HP)
185188
//that's handled by a separate function.
186189
if (NetState.HitPoints <= 0)
187190
{
188-
ClearActions(false);
191+
m_ActionPlayer.ClearActions(false);
189192

190193
if (IsNpc)
191194
{

Assets/BossRoom/Scripts/Shared/Data/ActionDescription.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public class ActionDescription : ScriptableObject
7171
[Tooltip("Prefab to spawn that will manage this action's input")]
7272
public BaseActionInput ActionInput;
7373

74-
[Tooltip("Is this Action interruptible by other action plays. Generally, actions with short exec times should not be interruptible in this way.")]
74+
[Tooltip("Is this Action interruptible by other action-plays or by movement? (Implicitly stops movement when action starts.) Generally, actions with short exec times should not be interruptible in this way.")]
7575
public bool ActionInterruptible;
7676

7777
[System.Serializable]

0 commit comments

Comments
 (0)