Pathfinding to get in melee/cast range shouldn't count as 'combat complete'
This commit is contained in:
parent
25f985c132
commit
cc89a5550f
@ -30,6 +30,7 @@ internal sealed class CombatController : IDisposable
|
||||
private readonly ILogger<CombatController> _logger;
|
||||
|
||||
private CurrentFight? _currentFight;
|
||||
private bool _wasInCombat;
|
||||
|
||||
public CombatController(
|
||||
IEnumerable<ICombatModule> combatModules,
|
||||
@ -57,7 +58,7 @@ internal sealed class CombatController : IDisposable
|
||||
|
||||
public bool Start(CombatData combatData)
|
||||
{
|
||||
Stop();
|
||||
Stop("Starting combat");
|
||||
|
||||
var combatModule = _combatModules.FirstOrDefault(x => x.IsLoaded);
|
||||
if (combatModule == null)
|
||||
@ -76,11 +77,13 @@ internal sealed class CombatController : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <returns>true if still in combat, false otherwise</returns>
|
||||
public bool Update()
|
||||
public EStatus Update()
|
||||
{
|
||||
if (_currentFight == null || _movementController.IsPathfinding || _movementController.IsPathRunning)
|
||||
return false;
|
||||
if (_currentFight == null)
|
||||
return EStatus.Complete;
|
||||
|
||||
if (_movementController.IsPathfinding || _movementController.IsPathRunning)
|
||||
return EStatus.Moving;
|
||||
|
||||
var target = _targetManager.Target;
|
||||
if (target != null)
|
||||
@ -121,7 +124,15 @@ internal sealed class CombatController : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
return _condition[ConditionFlag.InCombat];
|
||||
if (_condition[ConditionFlag.InCombat])
|
||||
{
|
||||
_wasInCombat = true;
|
||||
return EStatus.InCombat;
|
||||
}
|
||||
else if (_wasInCombat)
|
||||
return EStatus.Complete;
|
||||
else
|
||||
return EStatus.InCombat;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "RedundantJumpStatement")]
|
||||
@ -263,8 +274,9 @@ internal sealed class CombatController : IDisposable
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
public void Stop(string label)
|
||||
{
|
||||
using var scope = _logger.BeginScope(label);
|
||||
if (_currentFight != null)
|
||||
{
|
||||
_logger.LogInformation("Stopping current fight");
|
||||
@ -272,14 +284,15 @@ internal sealed class CombatController : IDisposable
|
||||
}
|
||||
|
||||
_currentFight = null;
|
||||
_wasInCombat = false;
|
||||
}
|
||||
|
||||
private void TerritoryChanged(ushort territoryId) => Stop();
|
||||
private void TerritoryChanged(ushort territoryId) => Stop("TerritoryChanged");
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_clientState.TerritoryChanged -= TerritoryChanged;
|
||||
Stop();
|
||||
Stop("Dispose");
|
||||
}
|
||||
|
||||
private sealed class CurrentFight
|
||||
@ -297,4 +310,11 @@ internal sealed class CombatController : IDisposable
|
||||
|
||||
public HashSet<int> CompletedComplexDatas { get; } = new();
|
||||
}
|
||||
|
||||
public enum EStatus
|
||||
{
|
||||
InCombat,
|
||||
Moving,
|
||||
Complete,
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ internal sealed class QuestController
|
||||
{
|
||||
Stop("HP = 0");
|
||||
_movementController.Stop();
|
||||
_combatController.Stop();
|
||||
_combatController.Stop("HP = 0");
|
||||
}
|
||||
}
|
||||
else if (_keyState[VirtualKey.ESCAPE])
|
||||
@ -146,7 +146,7 @@ internal sealed class QuestController
|
||||
{
|
||||
Stop("ESC pressed");
|
||||
_movementController.Stop();
|
||||
_combatController.Stop();
|
||||
_combatController.Stop("ESC pressed");
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,7 +376,7 @@ internal sealed class QuestController
|
||||
_taskQueue.Clear();
|
||||
|
||||
_yesAlreadyIpc.RestoreYesAlready();
|
||||
_combatController.Stop();
|
||||
_combatController.Stop("ClearTasksInternal");
|
||||
}
|
||||
|
||||
public void Stop(string label, bool continueIfAutomatic = false)
|
||||
@ -535,7 +535,7 @@ internal sealed class QuestController
|
||||
}
|
||||
|
||||
_movementController.Stop();
|
||||
_combatController.Stop();
|
||||
_combatController.Stop("Execute next step");
|
||||
|
||||
var newTasks = _taskFactories
|
||||
.SelectMany(x =>
|
||||
|
@ -103,7 +103,7 @@ internal static class Combat
|
||||
|
||||
public ETaskResult Update()
|
||||
{
|
||||
if (combatController.Update())
|
||||
if (combatController.Update() != CombatController.EStatus.Complete)
|
||||
return ETaskResult.StillRunning;
|
||||
|
||||
// if our quest step has any completion flags, we need to check if they are set
|
||||
@ -125,7 +125,7 @@ internal static class Combat
|
||||
return ETaskResult.StillRunning;
|
||||
else
|
||||
{
|
||||
combatController.Stop();
|
||||
combatController.Stop("Combat task complete");
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user