forked from aly/qstbak
muffin v7.5.12
This commit is contained in:
parent
3102923ce2
commit
911ed68baa
65 changed files with 2356 additions and 1539 deletions
|
|
@ -47,6 +47,10 @@ internal sealed class DeliveryNpcApproachExecutor(NavmeshIpc navmeshIpc, Movemen
|
|||
{
|
||||
return true;
|
||||
}
|
||||
if (Vector3.Distance(localPlayer.Position, _npcPosition) <= _interactionDistance + 0.5f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float num = MathF.Atan2(localPlayer.Position.X - _npcPosition.X, localPlayer.Position.Z - _npcPosition.Z);
|
||||
float num2 = MathF.Max(1f, _interactionDistance - 0.5f);
|
||||
for (int i = 0; i < 24; i++)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using LLib.GameData;
|
||||
using LLib.Inventory;
|
||||
using LLib.Shop;
|
||||
|
|
@ -73,27 +74,39 @@ internal sealed class DeliveryPlannerService
|
|||
return null;
|
||||
}
|
||||
uint supplyIndex = (uint)row.SatisfactionNpcParams[npcState.Rank].SupplyIndex;
|
||||
uint num = _supplyHelper.CalculateRequestedItems(supplyIndex, supplySeed)[(int)slot];
|
||||
if (num == uint.MaxValue)
|
||||
SubrowExcelSheet<SatisfactionSupply> subrowExcelSheet = _dataManager.GetSubrowExcelSheet<SatisfactionSupply>();
|
||||
if (TryGetLiveSupplyRow(npcIndex, slot, supplyIndex, out var supplyRow, out var hasLiveRequest))
|
||||
{
|
||||
_logger.LogDebug("No item predicted for NPC {NpcIndex} slot {Slot}", npcIndex, slot);
|
||||
return null;
|
||||
_logger.LogDebug("Using live requested item {ItemId} for NPC {NpcIndex} slot {Slot}", supplyRow.Item.RowId, npcIndex, slot);
|
||||
}
|
||||
if (!_dataManager.GetSubrowExcelSheet<SatisfactionSupply>().TryGetSubrow(supplyIndex, (ushort)num, out var subrow))
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("SatisfactionSupply subrow ({SupplyIndex}, {SubrowIndex}) not found", supplyIndex, num);
|
||||
return null;
|
||||
if (hasLiveRequest)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
uint num = _supplyHelper.CalculateRequestedItems(supplyIndex, supplySeed)[(int)slot];
|
||||
if (num == uint.MaxValue)
|
||||
{
|
||||
_logger.LogDebug("No item predicted for NPC {NpcIndex} slot {Slot}", npcIndex, slot);
|
||||
return null;
|
||||
}
|
||||
if (!subrowExcelSheet.TryGetSubrow(supplyIndex, (ushort)num, out supplyRow))
|
||||
{
|
||||
_logger.LogWarning("SatisfactionSupply subrow ({SupplyIndex}, {SubrowIndex}) not found", supplyIndex, num);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
uint rowId = subrow.Item.RowId;
|
||||
uint rowId = supplyRow.Item.RowId;
|
||||
ushort num2 = _configuration.CustomDeliveries.CollectabilityTier switch
|
||||
{
|
||||
Configuration.CustomDeliveryConfiguration.ECollectabilityTier.Low => subrow.CollectabilityLow,
|
||||
Configuration.CustomDeliveryConfiguration.ECollectabilityTier.Mid => subrow.CollectabilityMid,
|
||||
_ => subrow.CollectabilityHigh,
|
||||
Configuration.CustomDeliveryConfiguration.ECollectabilityTier.Low => supplyRow.CollectabilityLow,
|
||||
Configuration.CustomDeliveryConfiguration.ECollectabilityTier.Mid => supplyRow.CollectabilityMid,
|
||||
_ => supplyRow.CollectabilityHigh,
|
||||
};
|
||||
if (rowId == 0)
|
||||
{
|
||||
_logger.LogWarning("SatisfactionSupply subrow ({SupplyIndex}, {SubrowIndex}) has no item", supplyIndex, num);
|
||||
_logger.LogWarning("SatisfactionSupply row {SupplyIndex} has no item for slot {Slot}", supplyIndex, slot);
|
||||
return null;
|
||||
}
|
||||
int num3 = row.DeliveriesPerWeek - npcState.UsedDeliveries;
|
||||
|
|
@ -107,7 +120,7 @@ internal sealed class DeliveryPlannerService
|
|||
if (satisfactionRequired > 0)
|
||||
{
|
||||
Configuration.CustomDeliveryConfiguration.ECollectabilityTier collectabilityTier = _configuration.CustomDeliveries.CollectabilityTier;
|
||||
int num5 = _rewardCalculator.CalculateSatisfactionPerDelivery(subrow.Reward.RowId, subrow.IsBonus, collectabilityTier);
|
||||
int num5 = _rewardCalculator.CalculateSatisfactionPerDelivery(supplyRow.Reward.RowId, supplyRow.IsBonus, collectabilityTier);
|
||||
if (num5 > 0)
|
||||
{
|
||||
int num6 = (satisfactionRequired - npcState.SatisfactionCurrent + num5 - 1) / num5;
|
||||
|
|
@ -131,8 +144,8 @@ internal sealed class DeliveryPlannerService
|
|||
}
|
||||
if (_configuration.CustomDeliveries.ScripOvercapMode != Configuration.CustomDeliveryConfiguration.EScripOvercapMode.Ignore)
|
||||
{
|
||||
uint rowId2 = subrow.Reward.RowId;
|
||||
bool isBonus = subrow.IsBonus;
|
||||
uint rowId2 = supplyRow.Reward.RowId;
|
||||
bool isBonus = supplyRow.IsBonus;
|
||||
int num8 = _rewardCalculator.MaxDeliveriesBeforeOvercap(rowId2, isBonus, _configuration.CustomDeliveries.CollectabilityTier);
|
||||
if (num8 <= 0)
|
||||
{
|
||||
|
|
@ -201,6 +214,31 @@ internal sealed class DeliveryPlannerService
|
|||
return result;
|
||||
}
|
||||
|
||||
private unsafe bool TryGetLiveSupplyRow(int npcIndex, EDeliverySlot slot, uint supplyIndex, out SatisfactionSupply supplyRow, out bool hasLiveRequest)
|
||||
{
|
||||
hasLiveRequest = false;
|
||||
AgentSatisfactionSupply* ptr = AgentSatisfactionSupply.Instance();
|
||||
if (ptr != null && ptr->IsAgentActive() && ptr->NpcInfo.Valid && ptr->NpcInfo.Initialized && ptr->NpcInfo.Id == (uint)(npcIndex + 1))
|
||||
{
|
||||
uint id = ptr->Items[(int)slot].Id;
|
||||
if (id != 0)
|
||||
{
|
||||
hasLiveRequest = true;
|
||||
foreach (SatisfactionSupply item in _dataManager.GetSubrowExcelSheet<SatisfactionSupply>().Flatten())
|
||||
{
|
||||
if (item.RowId == supplyIndex && item.Item.RowId == id)
|
||||
{
|
||||
supplyRow = item;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_logger.LogWarning("Live requested item {ItemId} was not found in SatisfactionSupply row {SupplyIndex}", id, supplyIndex);
|
||||
}
|
||||
}
|
||||
supplyRow = default(SatisfactionSupply);
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsNpcUnlocked(int npcIndex)
|
||||
{
|
||||
if (!_dataManager.GetExcelSheet<SatisfactionNpc>().TryGetRow((uint)(npcIndex + 1), out var row))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
using LLib;
|
||||
using LLib.Shop;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
|
@ -89,6 +91,10 @@ internal sealed class SatisfactionSupplyTurnInExecutor(GameFunctions gameFunctio
|
|||
case EPhase.SelectSlot:
|
||||
if (_throttle.TryReset(0.5))
|
||||
{
|
||||
if (!PlanStillMatchesRequest())
|
||||
{
|
||||
return ETaskResult.RetryStep;
|
||||
}
|
||||
if (SatisfactionSupplyActions.IsNpcTradeReady())
|
||||
{
|
||||
logger.LogDebug("NpcTrade agent ready");
|
||||
|
|
@ -106,10 +112,18 @@ internal sealed class SatisfactionSupplyTurnInExecutor(GameFunctions gameFunctio
|
|||
}
|
||||
break;
|
||||
case EPhase.ConfirmTrade:
|
||||
if (_throttle.TryReset(0.5) && SatisfactionSupplyActions.TryConfirmTrade())
|
||||
if (_throttle.TryReset(0.5))
|
||||
{
|
||||
logger.LogDebug("Confirmed trade for slot {Slot}", base.Task.Slot);
|
||||
SetPhase(EPhase.WaitForCutsceneStart);
|
||||
if (!HasRemainingItems())
|
||||
{
|
||||
logger.LogWarning("Planned item {ItemId} is no longer available for turn-in", base.Task.ItemId);
|
||||
return ETaskResult.RetryStep;
|
||||
}
|
||||
if (SatisfactionSupplyActions.TryConfirmTrade())
|
||||
{
|
||||
logger.LogDebug("Confirmed trade for slot {Slot}", base.Task.Slot);
|
||||
SetPhase(EPhase.WaitForCutsceneStart);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EPhase.WaitForCutsceneStart:
|
||||
|
|
@ -192,6 +206,32 @@ internal sealed class SatisfactionSupplyTurnInExecutor(GameFunctions gameFunctio
|
|||
return SatisfactionSupplyActions.GetNpcState(base.Task.NpcIndex).UsedDeliveries > _lastUsedDeliveries;
|
||||
}
|
||||
|
||||
private unsafe bool PlanStillMatchesRequest()
|
||||
{
|
||||
AgentSatisfactionSupply* ptr = AgentSatisfactionSupply.Instance();
|
||||
if (ptr == null || !ptr->IsAgentActive() || !ptr->NpcInfo.Valid || !ptr->NpcInfo.Initialized)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
uint id = ptr->Items[(int)base.Task.Slot].Id;
|
||||
if (ptr->NpcInfo.Id == (uint)(base.Task.NpcIndex + 1) && id == base.Task.ItemId && HasRemainingItems())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
logger.LogWarning("Turn-in plan no longer matches live request: NPC {NpcIndex}, slot {Slot}, planned item {PlannedItemId}, live item {LiveItemId}", base.Task.NpcIndex, base.Task.Slot, base.Task.ItemId, id);
|
||||
return false;
|
||||
}
|
||||
|
||||
private unsafe bool HasRemainingItems()
|
||||
{
|
||||
InventoryManager* ptr = InventoryManager.Instance();
|
||||
if (ptr != null)
|
||||
{
|
||||
return ptr->GetInventoryItemCount(base.Task.ItemId, isHq: false, checkEquipped: true, checkArmory: true, (short)base.Task.Collectability) >= _remaining;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool ShouldInterruptOnDamage()
|
||||
{
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ using Questionable.Controller.Steps;
|
|||
|
||||
namespace Questionable.Controller.CustomDelivery;
|
||||
|
||||
internal sealed record SatisfactionSupplyTurnInTask(int NpcIndex, EDeliverySlot Slot, int DeliveryCount, uint NpcDataId) : ITask
|
||||
internal sealed record SatisfactionSupplyTurnInTask(int NpcIndex, EDeliverySlot Slot, int DeliveryCount, uint NpcDataId, uint ItemId, ushort Collectability) : ITask
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue