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