Fixed airdrops not containing loot
This commit is contained in:
@@ -61,13 +61,7 @@ public class LocationController(
|
||||
/// <returns></returns>
|
||||
public GetAirdropLootResponse? GetAirDropLoot(GetAirdropLootRequest? request)
|
||||
{
|
||||
if (request is null)
|
||||
{
|
||||
// client sometimes requests this after a raid has ended, just return null
|
||||
return null;
|
||||
}
|
||||
|
||||
if (request.ContainerId is not null)
|
||||
if (request?.ContainerId is not null)
|
||||
{
|
||||
return _airdropService.GenerateCustomAirdropLoot(request);
|
||||
}
|
||||
|
||||
@@ -280,8 +280,8 @@ public class LootGenerator(
|
||||
{
|
||||
var randomItem = _randomUtil.GetArrayValue(items);
|
||||
|
||||
var itemLimitCount = itemTypeCounts[randomItem.Parent];
|
||||
if (itemLimitCount is not null && itemLimitCount.Current > itemLimitCount.Max) {
|
||||
var itemLimitCount = itemTypeCounts.TryGetValue(randomItem.Parent, out var randomItemLimitCount);
|
||||
if (!itemLimitCount && randomItemLimitCount?.Current > randomItemLimitCount?.Max) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ public class LootGenerator(
|
||||
var newLootItem = new Item {
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = randomItem.Id,
|
||||
Upd = {
|
||||
Upd = new Upd {
|
||||
StackObjectsCount = 1,
|
||||
SpawnedInSession = true,
|
||||
},
|
||||
@@ -307,9 +307,9 @@ public class LootGenerator(
|
||||
newLootItem.Template = randomItem.Id;
|
||||
result.Add(newLootItem);
|
||||
|
||||
if (itemLimitCount is not null) {
|
||||
if (randomItemLimitCount is not null) {
|
||||
// Increment item count as it's in limit array
|
||||
itemLimitCount.Current++;
|
||||
randomItemLimitCount.Current++;
|
||||
}
|
||||
|
||||
// Item added okay
|
||||
@@ -324,7 +324,15 @@ public class LootGenerator(
|
||||
/// <returns>stack count</returns>
|
||||
protected int GetRandomisedStackCount(TemplateItem item, LootRequest options)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var min = item.Properties.StackMinRandom;
|
||||
var max = item.Properties.StackMaxSize;
|
||||
|
||||
if (options.ItemStackLimits.TryGetValue(item.Id, out var itemLimits)) {
|
||||
min = itemLimits.Min;
|
||||
max = (int?)itemLimits.Max;
|
||||
}
|
||||
|
||||
return _randomUtil.GetInt((int)(min ?? 1), max ?? 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -376,8 +384,8 @@ public class LootGenerator(
|
||||
}
|
||||
|
||||
// Check chosen preset hasn't exceeded spawn limit
|
||||
var itemLimitCount = itemTypeCounts[itemDbDetails.Value.Parent];
|
||||
if (itemLimitCount is not null && itemLimitCount.Current > itemLimitCount.Max) {
|
||||
var hasItemLimitCount = itemTypeCounts.TryGetValue(itemDbDetails.Value.Parent, out var itemLimitCount);
|
||||
if (!hasItemLimitCount && itemLimitCount?.Current > itemLimitCount?.Max) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public class AirdropService(
|
||||
_logger.Debug($"Chose: {airdropType} for airdrop loot");
|
||||
|
||||
// Common/weapon/etc
|
||||
var airdropConfig = GetAirdropLootConfigByType((AirdropTypeEnum)airdropType);
|
||||
var airdropConfig = GetAirdropLootConfigByType(airdropType);
|
||||
|
||||
// generate loot to put into airdrop crate
|
||||
var crateLoot = airdropConfig.UseForcedLoot.GetValueOrDefault(false)
|
||||
@@ -138,7 +138,7 @@ public class AirdropService(
|
||||
/// </summary>
|
||||
/// <param name="airdropType">Type of airdrop to get settings for</param>
|
||||
/// <returns>LootRequest</returns>
|
||||
protected AirdropLootRequest GetAirdropLootConfigByType(AirdropTypeEnum airdropType)
|
||||
protected AirdropLootRequest GetAirdropLootConfigByType(SptAirdropTypeEnum? airdropType)
|
||||
{
|
||||
var lootSettingsByType = _airdropConfig.Loot[airdropType.ToString()];
|
||||
if (lootSettingsByType is null) {
|
||||
@@ -146,6 +146,7 @@ public class AirdropService(
|
||||
_localisationService.GetText("location-unable_to_find_airdrop_drop_config_of_type", airdropType)
|
||||
);
|
||||
|
||||
// TODO: Get Radar airdrop to work. Atm Radar will default to common supply drop (mixed)
|
||||
// Default to common
|
||||
lootSettingsByType = _airdropConfig.Loot[AirdropTypeEnum.Common.ToString()];
|
||||
}
|
||||
@@ -153,8 +154,9 @@ public class AirdropService(
|
||||
// Get all items that match the blacklisted types and fold into item blacklist
|
||||
var itemTypeBlacklist = _itemFilterService.GetItemRewardBaseTypeBlacklist();
|
||||
var itemsMatchingTypeBlacklist = _itemHelper.GetItems()
|
||||
.Where((templateItem) => _itemHelper.IsOfBaseclasses(templateItem.Parent, itemTypeBlacklist))
|
||||
.Select((templateItem) => templateItem.Id);
|
||||
.Where(templateItem => !string.IsNullOrEmpty(templateItem.Parent))
|
||||
.Where(templateItem => _itemHelper.IsOfBaseclasses(templateItem.Parent, itemTypeBlacklist))
|
||||
.Select(templateItem => templateItem.Id);
|
||||
var itemBlacklist = new HashSet<string>();
|
||||
itemBlacklist.UnionWith(lootSettingsByType.ItemBlacklist);
|
||||
itemBlacklist.UnionWith(_itemFilterService.GetItemRewardBlacklist());
|
||||
|
||||
@@ -68,7 +68,7 @@ public class ItemBaseClassService(
|
||||
HydrateItemBaseClassCache();
|
||||
}
|
||||
|
||||
if (itemTpl is null)
|
||||
if (string.IsNullOrEmpty(itemTpl))
|
||||
{
|
||||
_logger.Warning("Unable to check itemTpl base class as value passed is null");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user