muffin v7.38.1
This commit is contained in:
parent
e5b98b3d57
commit
0336b9c9e9
12 changed files with 4618 additions and 4245 deletions
|
|
@ -29,6 +29,12 @@ internal sealed class ItemUseModule : ICombatModule
|
|||
|
||||
private DateTime _continueAt;
|
||||
|
||||
private bool _itemUsePending;
|
||||
|
||||
private DateTime _itemUsePendingUntil;
|
||||
|
||||
private int _lastKnownItemCount;
|
||||
|
||||
public ItemUseModule(IServiceProvider serviceProvider, ICondition condition, ILogger<ItemUseModule> logger)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
|
|
@ -49,13 +55,19 @@ internal sealed class ItemUseModule : ICombatModule
|
|||
return _delegate != null;
|
||||
}
|
||||
|
||||
public bool Start(CombatController.CombatData combatData)
|
||||
public unsafe bool Start(CombatController.CombatData combatData)
|
||||
{
|
||||
if (_delegate.Start(combatData))
|
||||
{
|
||||
_combatData = combatData;
|
||||
_isDoingRotation = true;
|
||||
_continueAt = DateTime.Now;
|
||||
if (_combatData?.CombatItemUse != null)
|
||||
{
|
||||
InventoryManager* ptr = InventoryManager.Instance();
|
||||
_lastKnownItemCount = ptr->GetInventoryItemCount(_combatData.CombatItemUse.ItemId, isHq: false, checkEquipped: true, checkArmory: true, 0);
|
||||
_itemUsePending = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -88,16 +100,29 @@ internal sealed class ItemUseModule : ICombatModule
|
|||
{
|
||||
if (_isDoingRotation)
|
||||
{
|
||||
if (InventoryManager.Instance()->GetInventoryItemCount(_combatData.CombatItemUse.ItemId, isHq: false, checkEquipped: true, checkArmory: true, 0) == 0)
|
||||
int inventoryItemCount = InventoryManager.Instance()->GetInventoryItemCount(_combatData.CombatItemUse.ItemId, isHq: false, checkEquipped: true, checkArmory: true, 0);
|
||||
if (_itemUsePending)
|
||||
{
|
||||
_isDoingRotation = false;
|
||||
_delegate.Stop();
|
||||
if (DateTime.Now < _itemUsePendingUntil)
|
||||
{
|
||||
_logger.LogDebug("Item use pending; ignoring temporary inventory count={Count}", inventoryItemCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
_itemUsePending = false;
|
||||
}
|
||||
}
|
||||
else if (ShouldUseItem(nextTarget))
|
||||
if (!_itemUsePending && inventoryItemCount == 0)
|
||||
{
|
||||
_isDoingRotation = false;
|
||||
_delegate.Stop();
|
||||
_logger.LogInformation("Using item {ItemId}", _combatData.CombatItemUse.ItemId);
|
||||
return;
|
||||
}
|
||||
_lastKnownItemCount = inventoryItemCount;
|
||||
if (ShouldUseItem(nextTarget))
|
||||
{
|
||||
_itemUsePending = true;
|
||||
_itemUsePendingUntil = DateTime.Now.AddSeconds(3.0);
|
||||
AgentInventoryContext.Instance()->UseItem(_combatData.CombatItemUse.ItemId, InventoryType.Invalid, 0u, 0);
|
||||
_continueAt = DateTime.Now.AddSeconds(2.0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue