diff --git a/Assets/BossRoom/Scripts/Client/Game/Character/ClientInputSender.cs b/Assets/BossRoom/Scripts/Client/Game/Character/ClientInputSender.cs index 22aeca15a..e0f4f9dbe 100644 --- a/Assets/BossRoom/Scripts/Client/Game/Character/ClientInputSender.cs +++ b/Assets/BossRoom/Scripts/Client/Game/Character/ClientInputSender.cs @@ -225,7 +225,7 @@ private void PerformSkill(ActionType actionType, SkillTriggerStyle triggerStyle, if (GetActionRequestForTarget(hitTransform, actionType, triggerStyle, out ActionRequestData playerAction)) { - //Don't trigger our move logic for another 500ms. This protects us from moving just because we clicked on them to target them. + //Don't trigger our move logic for a while. This protects us from moving just because we clicked on them to target them. m_LastSentMove = Time.time + k_TargetMoveTimeout; ActionInputEvent?.Invoke(playerAction); @@ -233,7 +233,10 @@ private void PerformSkill(ActionType actionType, SkillTriggerStyle triggerStyle, } else if(actionType != ActionType.GeneralTarget ) { - // clicked on nothing... perform a "miss" attack on the spot they clicked on + // clicked on nothing... perform an "untargeted" attack on the spot they clicked on. + // (Different Actions will deal with this differently. For some, like archer arrows, this will fire an arrow + // in the desired direction. For others, like mage's bolts, this will fire a "miss" projectile at the spot clicked on.) + var data = new ActionRequestData(); PopulateSkillRequest(k_CachedHit[0].point, actionType, ref data); diff --git a/Assets/BossRoom/Scripts/Server/Game/Action/ActionPlayer.cs b/Assets/BossRoom/Scripts/Server/Game/Action/ActionPlayer.cs index 43257a1bc..5ecea282c 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Action/ActionPlayer.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Action/ActionPlayer.cs @@ -11,6 +11,8 @@ public class ActionPlayer { private ServerCharacter m_Parent; + private ServerCharacterMovement m_Movement; + private List m_Queue; private List m_NonBlockingActions; @@ -30,6 +32,7 @@ public class ActionPlayer public ActionPlayer(ServerCharacter parent) { m_Parent = parent; + m_Movement = parent.GetComponent(); m_Queue = new List(); m_NonBlockingActions = new List(); m_LastUsedTimestamps = new Dictionary(); @@ -134,6 +137,13 @@ private void StartAction() return; // ... so it's important not to try to do anything more here } + // if this Action is interruptible, that means movement should interrupt it... character needs to be stationary for this! + // So stop any movement that's already happening before we begin + if (m_Queue[0].Description.ActionInterruptible && !m_Movement.IsPerformingForcedMovement()) + { + m_Movement.CancelMove(); + } + // remember that we successfully used this Action! m_LastUsedTimestamps[m_Queue[0].Description.ActionTypeEnum] = Time.time; diff --git a/Assets/BossRoom/Scripts/Server/Game/Action/StealthModeAction.cs b/Assets/BossRoom/Scripts/Server/Game/Action/StealthModeAction.cs index ef4aef9d7..13479da3a 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Action/StealthModeAction.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Action/StealthModeAction.cs @@ -20,12 +20,6 @@ public override bool Start() { m_Parent.NetState.RecvDoActionClientRPC(Data); - // not allowed to walk while going stealthy! - var movement = m_Parent.GetComponent(); - if (!movement.IsPerformingForcedMovement()) - { - movement.CancelMove(); - } return true; } diff --git a/Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs b/Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs index 1c9e783e6..8fee9527c 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs @@ -108,7 +108,18 @@ private void OnClientMoveRequest(Vector3 targetPosition) { if (NetState.NetworkLifeState.Value == LifeState.Alive && !m_Movement.IsPerformingForcedMovement()) { - ClearActions(false); + // if we're currently playing an interruptible action, interrupt it! + if (m_ActionPlayer.GetActiveActionInfo(out ActionRequestData data)) + { + if (GameDataSource.Instance.ActionDataByType.TryGetValue(data.ActionTypeEnum, out ActionDescription description)) + { + if (description.ActionInterruptible) + { + m_ActionPlayer.ClearActions(false); + } + } + } + m_ActionPlayer.CancelRunningActionsByLogic(ActionLogic.Target, true); //clear target on move. m_Movement.SetMovementTarget(targetPosition); } @@ -118,19 +129,11 @@ private void OnLifeStateChanged(LifeState prevLifeState, LifeState lifeState) { if (lifeState != LifeState.Alive) { - ClearActions(true); + m_ActionPlayer.ClearActions(true); m_Movement.CancelMove(); } } - /// - /// Clear all active Actions. - /// - public void ClearActions(bool alsoClearNonBlockingActions) - { - m_ActionPlayer.ClearActions(alsoClearNonBlockingActions); - } - private void OnActionPlayRequest(ActionRequestData data) { if (!GameDataSource.Instance.ActionDataByType[data.ActionTypeEnum].IsFriendly) @@ -185,7 +188,7 @@ public void ReceiveHP(ServerCharacter inflicter, int HP) //that's handled by a separate function. if (NetState.HitPoints <= 0) { - ClearActions(false); + m_ActionPlayer.ClearActions(false); if (IsNpc) { diff --git a/Assets/BossRoom/Scripts/Shared/Data/ActionDescription.cs b/Assets/BossRoom/Scripts/Shared/Data/ActionDescription.cs index 9878284cb..bd679fd6e 100644 --- a/Assets/BossRoom/Scripts/Shared/Data/ActionDescription.cs +++ b/Assets/BossRoom/Scripts/Shared/Data/ActionDescription.cs @@ -71,7 +71,7 @@ public class ActionDescription : ScriptableObject [Tooltip("Prefab to spawn that will manage this action's input")] public BaseActionInput ActionInput; - [Tooltip("Is this Action interruptible by other action plays. Generally, actions with short exec times should not be interruptible in this way.")] + [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.")] public bool ActionInterruptible; [System.Serializable]