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
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue