108 lines
2.5 KiB
C#
108 lines
2.5 KiB
C#
using System;
|
|
using Dalamud.Game.ClientState.Objects.SubKinds;
|
|
using Dalamud.Game.ClientState.Objects.Types;
|
|
using Dalamud.Plugin.Ipc.Exceptions;
|
|
using Dalamud.Plugin.Services;
|
|
using Microsoft.Extensions.Logging;
|
|
using Questionable.External;
|
|
|
|
namespace Questionable.Controller.CombatModules;
|
|
|
|
internal sealed class BossModModule : ICombatModule, IDisposable
|
|
{
|
|
private readonly ILogger<BossModModule> _logger;
|
|
|
|
private readonly BossModIpc _bossModIpc;
|
|
|
|
private readonly Configuration _configuration;
|
|
|
|
private readonly IObjectTable _objectTable;
|
|
|
|
public BossModModule(ILogger<BossModModule> logger, BossModIpc bossModIpc, Configuration configuration, IObjectTable objectTable)
|
|
{
|
|
_logger = logger;
|
|
_bossModIpc = bossModIpc;
|
|
_configuration = configuration;
|
|
_objectTable = objectTable;
|
|
}
|
|
|
|
public bool CanHandleFight(CombatController.CombatData combatData)
|
|
{
|
|
if (_configuration.General.CombatModule != Configuration.ECombatModule.BossMod)
|
|
{
|
|
return false;
|
|
}
|
|
return _bossModIpc.IsSupported();
|
|
}
|
|
|
|
public bool Start(CombatController.CombatData combatData)
|
|
{
|
|
try
|
|
{
|
|
_logger.LogDebug("BossModModule.Start: SpawnType={SpawnType}, enabling Active preset", combatData.SpawnType);
|
|
if (!_bossModIpc.EnableAi(BossModIpc.EPreset.Active))
|
|
{
|
|
_logger.LogWarning("BossModModule.Start: failed to enable BossMod AI");
|
|
return false;
|
|
}
|
|
IPlayerCharacter localPlayer = _objectTable.LocalPlayer;
|
|
bool flag;
|
|
if (localPlayer != null)
|
|
{
|
|
byte? b = localPlayer.ClassJob.ValueNullable?.Role;
|
|
if (b.HasValue)
|
|
{
|
|
byte valueOrDefault = b.GetValueOrDefault();
|
|
if ((uint)(valueOrDefault - 3) <= 1u)
|
|
{
|
|
flag = true;
|
|
goto IL_00bd;
|
|
}
|
|
}
|
|
flag = false;
|
|
goto IL_00bd;
|
|
}
|
|
goto IL_012e;
|
|
IL_00bd:
|
|
bool flag2 = flag;
|
|
_logger.LogDebug("BossModModule.Start: isRanged={IsRanged}, job role={Role}", flag2, localPlayer.ClassJob.ValueNullable?.Role);
|
|
_bossModIpc.SetRangeStrategy(BossModIpc.EPreset.Active, flag2);
|
|
goto IL_012e;
|
|
IL_012e:
|
|
return true;
|
|
}
|
|
catch (IpcError exception)
|
|
{
|
|
_logger.LogWarning(exception, "Could not start combat");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool Stop()
|
|
{
|
|
try
|
|
{
|
|
_bossModIpc.DisableAi();
|
|
return true;
|
|
}
|
|
catch (IpcError exception)
|
|
{
|
|
_logger.LogWarning(exception, "Could not turn off combat");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void Update(IGameObject gameObject)
|
|
{
|
|
}
|
|
|
|
public bool CanAttack(IBattleNpc target)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Stop();
|
|
}
|
|
}
|