diff --git a/Libraries/Core/Controllers/LocationController.cs b/Libraries/Core/Controllers/LocationController.cs
index 0c2708ec..4b8a0342 100644
--- a/Libraries/Core/Controllers/LocationController.cs
+++ b/Libraries/Core/Controllers/LocationController.cs
@@ -61,13 +61,7 @@ public class LocationController(
///
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);
}
diff --git a/Libraries/Core/Generators/LootGenerator.cs b/Libraries/Core/Generators/LootGenerator.cs
index 92b0b67f..3e29b8da 100644
--- a/Libraries/Core/Generators/LootGenerator.cs
+++ b/Libraries/Core/Generators/LootGenerator.cs
@@ -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(
/// stack count
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);
}
///
@@ -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;
}
diff --git a/Libraries/Core/Services/AirdropService.cs b/Libraries/Core/Services/AirdropService.cs
index 8abe2d67..1683d61b 100644
--- a/Libraries/Core/Services/AirdropService.cs
+++ b/Libraries/Core/Services/AirdropService.cs
@@ -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(
///
/// Type of airdrop to get settings for
/// LootRequest
- 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();
itemBlacklist.UnionWith(lootSettingsByType.ItemBlacklist);
itemBlacklist.UnionWith(_itemFilterService.GetItemRewardBlacklist());
diff --git a/Libraries/Core/Services/ItemBaseClassService.cs b/Libraries/Core/Services/ItemBaseClassService.cs
index a8b2e3f6..b26f66b6 100644
--- a/Libraries/Core/Services/ItemBaseClassService.cs
+++ b/Libraries/Core/Services/ItemBaseClassService.cs
@@ -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");