Merge branch 'main' of https://github.com/sp-tarkov/server-csharp into develop
This commit is contained in:
@@ -483,7 +483,10 @@ public class HideoutController(
|
||||
_inventoryHelper.RemoveItemByCount(pmcData, itemToDelete.Id, requiredCount, sessionID, output);
|
||||
|
||||
// Tools don't have a count
|
||||
if (requirement.Type != "Tool") requirement.Count -= (int)itemToDelete.Count;
|
||||
if (requirement.Type != "Tool")
|
||||
{
|
||||
requirement.Count -= (int)itemToDelete.Count;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
@@ -731,7 +734,7 @@ public class HideoutController(
|
||||
if (hoursCrafting / _hideoutConfig.HoursForSkillCrafting >= 1)
|
||||
{
|
||||
// Spent enough time crafting to get a bonus xp multiplier
|
||||
var multiplierCrafting = Math.Floor((double)hoursCrafting / _hideoutConfig.HoursForSkillCrafting);
|
||||
var multiplierCrafting = Math.Floor(hoursCrafting.Value / _hideoutConfig.HoursForSkillCrafting);
|
||||
craftingExpAmount += (int)(1 * multiplierCrafting);
|
||||
hoursCrafting -= _hideoutConfig.HoursForSkillCrafting * multiplierCrafting;
|
||||
}
|
||||
|
||||
@@ -82,9 +82,9 @@ public class ProfileController(
|
||||
Nickname = pmc.Info.Nickname,
|
||||
HasPassword = profile.ProfileInfo.Password != "",
|
||||
Side = pmc.Info.Side,
|
||||
CurrentLevel = (int)pmc.Info.Level,
|
||||
CurrentLevel = pmc.Info.Level,
|
||||
CurrentExperience = pmc.Info.Experience ?? 0,
|
||||
PreviousExperience = currlvl == 0 ? 0 : _profileHelper.GetExperience((int)currlvl),
|
||||
PreviousExperience = currlvl == 0 ? 0 : _profileHelper.GetExperience(currlvl.Value),
|
||||
NextLevel = xpToNextLevel,
|
||||
MaxLevel = maxLvl,
|
||||
Edition = profile.ProfileInfo?.Edition ?? "",
|
||||
|
||||
@@ -176,7 +176,7 @@ public class RagfairController
|
||||
if (searchRequest.BuildCount == 0)
|
||||
{
|
||||
var start = searchRequest.Page * searchRequest.Limit;
|
||||
var end = (int)Math.Min((double)((searchRequest.Page + 1) * searchRequest.Limit), result.Offers.Count);
|
||||
var end = Math.Min((searchRequest.Page.Value + 1) * searchRequest.Limit.Value, result.Offers.Count);
|
||||
result.Offers = result.Offers.Slice(start.Value, end - start.Value);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,9 @@ public class WeatherController(
|
||||
/// <returns></returns>
|
||||
public GetLocalWeatherResponseData GenerateLocal(string sessionId)
|
||||
{
|
||||
var result = new GetLocalWeatherResponseData()
|
||||
var result = new GetLocalWeatherResponseData
|
||||
{
|
||||
Season = (int)_seasonalEventService.GetActiveWeatherSeason(),
|
||||
Season = _seasonalEventService.GetActiveWeatherSeason(),
|
||||
Weather = []
|
||||
};
|
||||
|
||||
|
||||
@@ -463,27 +463,27 @@ public class BotGenerator(
|
||||
{
|
||||
Hydration = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)healthObj.Hydration.Min, (int)healthObj.Hydration.Max),
|
||||
Current = _randomUtil.GetDouble(healthObj.Hydration.Min.Value, healthObj.Hydration.Max.Value),
|
||||
Maximum = healthObj.Hydration.Max
|
||||
},
|
||||
Energy = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)healthObj.Energy.Min, (int)healthObj.Energy.Max),
|
||||
Current = _randomUtil.GetDouble(healthObj.Energy.Min.Value, healthObj.Energy.Max.Value),
|
||||
Maximum = healthObj.Energy.Max
|
||||
},
|
||||
Temperature = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)healthObj.Temperature.Min, (int)healthObj.Temperature.Max),
|
||||
Current = _randomUtil.GetDouble(healthObj.Temperature.Min.Value, healthObj.Temperature.Max.Value),
|
||||
Maximum = healthObj.Temperature.Max
|
||||
},
|
||||
BodyParts = new Dictionary<string, BodyPartHealth>()
|
||||
BodyParts = new Dictionary<string, BodyPartHealth>
|
||||
{
|
||||
{
|
||||
"Head", new BodyPartHealth
|
||||
{
|
||||
Health = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)bodyParts.Head.Min, (int)bodyParts.Head.Max),
|
||||
Current = _randomUtil.GetDouble(bodyParts.Head.Min.Value, bodyParts.Head.Max.Value),
|
||||
Maximum = Math.Round(bodyParts.Head.Max ?? 0)
|
||||
}
|
||||
}
|
||||
@@ -493,7 +493,7 @@ public class BotGenerator(
|
||||
{
|
||||
Health = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)bodyParts.Chest.Min, (int)bodyParts.Chest.Max),
|
||||
Current = _randomUtil.GetDouble(bodyParts.Chest.Min.Value, bodyParts.Chest.Max.Value),
|
||||
Maximum = Math.Round(bodyParts.Chest.Max ?? 0)
|
||||
}
|
||||
}
|
||||
@@ -503,7 +503,7 @@ public class BotGenerator(
|
||||
{
|
||||
Health = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)bodyParts.Stomach.Min, (int)bodyParts.Stomach.Max),
|
||||
Current = _randomUtil.GetDouble(bodyParts.Stomach.Min.Value, bodyParts.Stomach.Max.Value),
|
||||
Maximum = Math.Round(bodyParts.Stomach.Max ?? 0)
|
||||
}
|
||||
}
|
||||
@@ -513,7 +513,7 @@ public class BotGenerator(
|
||||
{
|
||||
Health = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)bodyParts.LeftArm.Min, (int)bodyParts.LeftArm.Max),
|
||||
Current = _randomUtil.GetDouble(bodyParts.LeftArm.Min.Value, bodyParts.LeftArm.Max.Value),
|
||||
Maximum = Math.Round(bodyParts.LeftArm.Max ?? 0)
|
||||
}
|
||||
}
|
||||
@@ -523,7 +523,7 @@ public class BotGenerator(
|
||||
{
|
||||
Health = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)bodyParts.RightArm.Min, (int)bodyParts.RightArm.Max),
|
||||
Current = _randomUtil.GetDouble(bodyParts.RightArm.Min.Value, bodyParts.RightArm.Max.Value),
|
||||
Maximum = Math.Round(bodyParts.RightArm.Max ?? 0)
|
||||
}
|
||||
}
|
||||
@@ -533,7 +533,7 @@ public class BotGenerator(
|
||||
{
|
||||
Health = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)bodyParts.LeftLeg.Min, (int)bodyParts.LeftLeg.Max),
|
||||
Current = _randomUtil.GetDouble(bodyParts.LeftLeg.Min.Value, bodyParts.LeftLeg.Max.Value),
|
||||
Maximum = Math.Round(bodyParts.LeftLeg.Max ?? 0)
|
||||
}
|
||||
}
|
||||
@@ -543,13 +543,13 @@ public class BotGenerator(
|
||||
{
|
||||
Health = new CurrentMinMax
|
||||
{
|
||||
Current = _randomUtil.GetInt((int)bodyParts.RightLeg.Min, (int)bodyParts.RightLeg.Max),
|
||||
Current = _randomUtil.GetDouble(bodyParts.RightLeg.Min.Value, bodyParts.RightLeg.Max.Value),
|
||||
Maximum = Math.Round(bodyParts.RightLeg.Max ?? 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
UpdateTime = 0, // 0 for pscav too
|
||||
UpdateTime = 0, // 0 for player-scav too
|
||||
Immortal = false
|
||||
};
|
||||
|
||||
@@ -557,7 +557,7 @@ public class BotGenerator(
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sum up body parts max hp values, return the bodypart collection with lowest value
|
||||
/// Sum up body parts max hp values, return the bodyPart collection with lowest value
|
||||
/// </summary>
|
||||
/// <param name="bodies">Body parts to sum up</param>
|
||||
/// <returns>Lowest hp collection</returns>
|
||||
@@ -629,7 +629,7 @@ public class BotGenerator(
|
||||
var skillToAdd = new BaseSkill
|
||||
{
|
||||
Id = kvp.Key,
|
||||
Progress = _randomUtil.GetInt((int)skill.Min, (int)skill.Max)
|
||||
Progress = _randomUtil.GetDouble(skill.Min.Value, skill.Max.Value)
|
||||
};
|
||||
|
||||
// Common skills have additional props
|
||||
|
||||
@@ -422,8 +422,8 @@ public class LocationLootGenerator(
|
||||
? [chosenItemWithChildren.Items[0]] // Strip children from parent
|
||||
: chosenItemWithChildren.Items;
|
||||
var itemSize = GetItemSize(items);
|
||||
var width = (int)itemSize.Width;
|
||||
var height = (int)itemSize.Height;
|
||||
var width = itemSize.Width;
|
||||
var height = itemSize.Height;
|
||||
|
||||
// look for open slot to put chosen item into
|
||||
var result = _containerHelper.FindSlotForItem(containerMap, width, height);
|
||||
@@ -555,7 +555,7 @@ public class LocationLootGenerator(
|
||||
/// </summary>
|
||||
/// <param name="containerTypeId">Container to get possible loot for</param>
|
||||
/// <param name="staticLootDist">staticLoot.json</param>
|
||||
/// <returns>ProbabilityObjectArray of item tpls + probabilty</returns>
|
||||
/// <returns>ProbabilityObjectArray of item tpls + probability</returns>
|
||||
protected ProbabilityObjectArray<string, float?> GetPossibleLootItemsForContainer(
|
||||
string containerTypeId,
|
||||
Dictionary<string, StaticLootDetails> staticLootDist)
|
||||
@@ -899,7 +899,7 @@ public class LocationLootGenerator(
|
||||
var stackCount =
|
||||
itemTemplate.Properties.StackMaxSize == 1
|
||||
? 1
|
||||
: _randomUtil.GetInt((int)itemTemplate.Properties.StackMinRandom, (int)itemTemplate.Properties.StackMaxRandom);
|
||||
: _randomUtil.GetInt(itemTemplate.Properties.StackMinRandom.Value, itemTemplate.Properties.StackMaxRandom.Value);
|
||||
|
||||
itemWithMods.Add(
|
||||
new Item
|
||||
@@ -997,7 +997,7 @@ public class LocationLootGenerator(
|
||||
// Edge case - some ammos e.g. flares or M406 grenades shouldn't be stacked
|
||||
var stackCount = itemTemplate.Properties.StackMaxSize == 1
|
||||
? 1
|
||||
: _randomUtil.GetInt((int)itemTemplate.Properties.StackMinRandom, (int)itemTemplate.Properties.StackMaxRandom);
|
||||
: _randomUtil.GetInt(itemTemplate.Properties.StackMinRandom.Value, itemTemplate.Properties.StackMaxRandom.Value);
|
||||
|
||||
rootItem.Upd = new Upd { StackObjectsCount = stackCount };
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ public class LootGenerator(
|
||||
var armorDetails = _itemHelper.GetItem(armorItem.Template).Value;
|
||||
var armorClass = armorDetails.Properties.ArmorClass;
|
||||
|
||||
return options.ArmorLevelWhitelist.Contains((int)armorClass.Value);
|
||||
return options.ArmorLevelWhitelist.Contains(armorClass.Value);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -341,11 +341,11 @@ public class LootGenerator(
|
||||
|
||||
if (options.ItemStackLimits.TryGetValue(item.Id, out var itemLimits))
|
||||
{
|
||||
min = itemLimits.Min;
|
||||
min = (int?)itemLimits.Min;
|
||||
max = (int?)itemLimits.Max;
|
||||
}
|
||||
|
||||
return _randomUtil.GetInt((int)(min ?? 1), max ?? 1);
|
||||
return _randomUtil.GetInt((min ?? 1), max ?? 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -138,7 +138,7 @@ public class RagfairOfferGenerator(
|
||||
User = CreateUserDataForFleaOffer(userID, isTrader),
|
||||
Root = items[0].Id,
|
||||
Items = itemsClone,
|
||||
ItemsCost = Math.Round((double)handbookHelper.GetTemplatePrice(items[0].Template)), // Handbook price
|
||||
ItemsCost = Math.Round(handbookHelper.GetTemplatePrice(items[0].Template)), // Handbook price
|
||||
Requirements = offerRequirements,
|
||||
RequirementsCost = Math.Round(singleItemListingPrice),
|
||||
SummaryCost = roubleListingPrice,
|
||||
@@ -316,8 +316,7 @@ public class RagfairOfferGenerator(
|
||||
return (long)databaseService.GetTrader(userID).Base.NextResupply;
|
||||
|
||||
// Generated fake-player offer
|
||||
return (long)Math.Round(
|
||||
(double)(time + randomUtil.GetInt((int)ragfairConfig.Dynamic.EndTimeSeconds.Min, (int)ragfairConfig.Dynamic.EndTimeSeconds.Max))
|
||||
return (long)Math.Round(time + randomUtil.GetDouble(ragfairConfig.Dynamic.EndTimeSeconds.Min.Value, ragfairConfig.Dynamic.EndTimeSeconds.Max.Value)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -374,9 +373,9 @@ public class RagfairOfferGenerator(
|
||||
// Limit to 1 offer when processing expired - like-for-like replacement
|
||||
var offerCount = isExpiredOffer
|
||||
? 1
|
||||
: randomUtil.GetInt((int)config.OfferItemCount.Min, (int)config.OfferItemCount.Max);
|
||||
: randomUtil.GetDouble(config.OfferItemCount.Min.Value, config.OfferItemCount.Max.Value);
|
||||
|
||||
/* TODO: ???????
|
||||
/* //TODO: ???????
|
||||
if (ProgramStatics.DEBUG && !ProgramStatics.COMPILED) {
|
||||
offerCount = 2;
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ public class RepeatableQuestRewardGenerator(
|
||||
{
|
||||
rewards.Success.Add(chosenWeapon.Value.Key);
|
||||
|
||||
// Subtract price of preset from item budget so we dont give player too much stuff
|
||||
itemRewardBudget -= (int)chosenWeapon.Value.Value;
|
||||
// Subtract price of preset from item budget so we don't give player too much stuff
|
||||
itemRewardBudget -= chosenWeapon.Value.Value;
|
||||
rewardIndex++;
|
||||
}
|
||||
}
|
||||
@@ -293,9 +293,7 @@ public class RepeatableQuestRewardGenerator(
|
||||
return Math.Floor(
|
||||
effectiveDifficulty *
|
||||
_mathUtil.Interp1(pmcLevel, levelsConfig, roublesConfig) *
|
||||
_randomUtil.GetDouble((double)(1 - rewardSpreadConfig), (double)(1 + rewardSpreadConfig)) ??
|
||||
0
|
||||
);
|
||||
_randomUtil.GetDouble((1d - rewardSpreadConfig.Value), 1d + rewardSpreadConfig.Value) ?? 0);
|
||||
}
|
||||
|
||||
private Dictionary<TemplateItem, int> GetRewardableItemsFromPoolWithinBudget(List<TemplateItem> itemPool,
|
||||
|
||||
@@ -24,14 +24,14 @@ public class BarrelInvetoryMagGen(
|
||||
public void Process(InventoryMagGen inventoryMagGen)
|
||||
{
|
||||
// Can't be done by _props.ammoType as grenade launcher shoots grenades with ammoType of "buckshot"
|
||||
double? randomisedAmmoStackSize = null;
|
||||
double? randomisedAmmoStackSize;
|
||||
if (inventoryMagGen.GetAmmoTemplate().Properties.StackMaxRandom == 1)
|
||||
// doesnt stack
|
||||
// Doesn't stack
|
||||
randomisedAmmoStackSize = _randomUtil.GetInt(3, 6);
|
||||
else
|
||||
randomisedAmmoStackSize = _randomUtil.GetInt(
|
||||
(int)inventoryMagGen.GetAmmoTemplate().Properties.StackMinRandom,
|
||||
(int)inventoryMagGen.GetAmmoTemplate().Properties.StackMaxRandom
|
||||
inventoryMagGen.GetAmmoTemplate().Properties.StackMinRandom.Value,
|
||||
inventoryMagGen.GetAmmoTemplate().Properties.StackMaxRandom.Value
|
||||
);
|
||||
|
||||
_botWeaponGeneratorHelper.AddAmmoIntoEquipmentSlots(
|
||||
|
||||
@@ -174,9 +174,9 @@ public class BotGeneratorHelper(
|
||||
|
||||
if (_randomUtil.GetChance100(randomizationValues.ChanceMaxResourcePercent)) return maxResource;
|
||||
|
||||
return _randomUtil.GetInt(
|
||||
(int)_randomUtil.GetPercentOfValue(randomizationValues.ResourcePercent, maxResource, 0),
|
||||
(int)maxResource
|
||||
return _randomUtil.GetDouble(
|
||||
_randomUtil.GetPercentOfValue(randomizationValues.ResourcePercent, maxResource, 0),
|
||||
maxResource
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public class BotHelper(
|
||||
|
||||
public bool RollChanceToBePmc(MinMax botConvertMinMax)
|
||||
{
|
||||
return _randomUtil.GetChance100(_randomUtil.GetInt((int)botConvertMinMax.Min, (int)botConvertMinMax.Max));
|
||||
return _randomUtil.GetChance100(_randomUtil.GetDouble(botConvertMinMax.Min.Value, botConvertMinMax.Max.Value));
|
||||
}
|
||||
|
||||
protected Dictionary<string, MinMax> GetPmcConversionValuesForLocation(string location)
|
||||
|
||||
@@ -63,7 +63,7 @@ public class BotWeaponGeneratorHelper(
|
||||
/// <returns>Numerical value of magazine count</returns>
|
||||
public int GetRandomizedMagazineCount(GenerationData magCounts)
|
||||
{
|
||||
return (int)_weightedRandomHelper.GetWeightedValue<double>(magCounts.Weights);
|
||||
return (int)_weightedRandomHelper.GetWeightedValue(magCounts.Weights);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1168,17 +1168,17 @@ public class ItemHelper(
|
||||
// Calculating child ExtraSize
|
||||
if (itemTemplate.Properties.ExtraSizeForceAdd ?? false)
|
||||
{
|
||||
forcedUp += (int)itemTemplate.Properties.ExtraSizeUp;
|
||||
forcedDown += (int)itemTemplate.Properties.ExtraSizeDown;
|
||||
forcedLeft += (int)itemTemplate.Properties.ExtraSizeLeft;
|
||||
forcedRight += (int)itemTemplate.Properties.ExtraSizeRight;
|
||||
forcedUp += itemTemplate.Properties.ExtraSizeUp.Value;
|
||||
forcedDown += itemTemplate.Properties.ExtraSizeDown.Value;
|
||||
forcedLeft += itemTemplate.Properties.ExtraSizeLeft.Value;
|
||||
forcedRight += itemTemplate.Properties.ExtraSizeRight.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
sizeUp = sizeUp < itemTemplate.Properties.ExtraSizeUp ? (int)itemTemplate.Properties.ExtraSizeUp : sizeUp;
|
||||
sizeDown = sizeDown < itemTemplate.Properties.ExtraSizeDown ? (int)itemTemplate.Properties.ExtraSizeDown : sizeDown;
|
||||
sizeLeft = sizeLeft < itemTemplate.Properties.ExtraSizeLeft ? (int)itemTemplate.Properties.ExtraSizeLeft : sizeLeft;
|
||||
sizeRight = sizeRight < itemTemplate.Properties.ExtraSizeRight ? (int)itemTemplate.Properties.ExtraSizeRight : sizeRight;
|
||||
sizeUp = sizeUp < itemTemplate.Properties.ExtraSizeUp ? itemTemplate.Properties.ExtraSizeUp.Value : sizeUp;
|
||||
sizeDown = sizeDown < itemTemplate.Properties.ExtraSizeDown ? itemTemplate.Properties.ExtraSizeDown.Value : sizeDown;
|
||||
sizeLeft = sizeLeft < itemTemplate.Properties.ExtraSizeLeft ? itemTemplate.Properties.ExtraSizeLeft.Value : sizeLeft;
|
||||
sizeRight = sizeRight < itemTemplate.Properties.ExtraSizeRight ? itemTemplate.Properties.ExtraSizeRight.Value : sizeRight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1379,11 +1379,11 @@ public class ItemHelper(
|
||||
(int)magazineCartridgeMaxCount
|
||||
);
|
||||
|
||||
if (magazineWithChildCartridges.Count() > 1) _logger.Warning($"Magazine {magTemplate.Name} already has cartridges defined, this may cause issues");
|
||||
if (magazineWithChildCartridges.Count > 1) _logger.Warning($"Magazine {magTemplate.Name} already has cartridges defined, this may cause issues");
|
||||
|
||||
// Loop over cartridge count and add stacks to magazine
|
||||
double? currentStoredCartridgeCount = 0;
|
||||
var location = 0;
|
||||
int currentStoredCartridgeCount = 0;
|
||||
int location = 0;
|
||||
while (currentStoredCartridgeCount < desiredStackCount)
|
||||
{
|
||||
// Get stack size of cartridges
|
||||
@@ -1392,7 +1392,7 @@ public class ItemHelper(
|
||||
|
||||
// Ensure we don't go over the max stackCount size
|
||||
var remainingSpace = desiredStackCount - currentStoredCartridgeCount;
|
||||
if (cartridgeCountToAdd > remainingSpace) cartridgeCountToAdd = (int)remainingSpace;
|
||||
if (cartridgeCountToAdd > remainingSpace) cartridgeCountToAdd = remainingSpace;
|
||||
|
||||
// Add cartridge item object into items array
|
||||
magazineWithChildCartridges.Add(
|
||||
@@ -1405,7 +1405,7 @@ public class ItemHelper(
|
||||
)
|
||||
);
|
||||
|
||||
currentStoredCartridgeCount += cartridgeCountToAdd;
|
||||
currentStoredCartridgeCount += cartridgeCountToAdd.Value;
|
||||
location++;
|
||||
}
|
||||
|
||||
@@ -1797,8 +1797,8 @@ public class ItemHelper(
|
||||
return ammoItemTemplate.Properties?.StackMaxSize == 1
|
||||
? 1
|
||||
: _randomUtil.GetInt(
|
||||
(int?)ammoItemTemplate.Properties?.StackMinRandom ?? 1,
|
||||
Math.Min((int?)ammoItemTemplate.Properties?.StackMaxRandom ?? 1, maxLimit)
|
||||
ammoItemTemplate.Properties?.StackMinRandom ?? 1,
|
||||
Math.Min(ammoItemTemplate.Properties?.StackMaxRandom ?? 1, maxLimit)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ public class QuestRewardHelper(
|
||||
// Add % bonus to existing StackObjectsCount
|
||||
var rewardItem = reward.Items[0];
|
||||
var newCurrencyAmount = Math.Floor((rewardItem.Upd.StackObjectsCount ?? 0) * (1 + bonusPercent / 100));
|
||||
rewardItem.Upd.StackObjectsCount = (int)newCurrencyAmount;
|
||||
rewardItem.Upd.StackObjectsCount = newCurrencyAmount;
|
||||
reward.Value = newCurrencyAmount;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TraderHelper(
|
||||
)
|
||||
{
|
||||
protected TraderConfig _traderConfig = _configServer.GetConfig<TraderConfig>();
|
||||
protected Dictionary<string, int?> _highestTraderPriceItems = new();
|
||||
protected Dictionary<string, double> _highestTraderPriceItems = new();
|
||||
protected List<string> _gameVersions = [GameEditions.EDGE_OF_DARKNESS, GameEditions.UNHEARD];
|
||||
|
||||
|
||||
@@ -449,9 +449,7 @@ public class TraderHelper(
|
||||
/// <returns>highest rouble cost for item</returns>
|
||||
public double GetHighestTraderPriceRouble(string tpl)
|
||||
{
|
||||
if (_highestTraderPriceItems is not null) return (double)_highestTraderPriceItems[tpl];
|
||||
|
||||
if (_highestTraderPriceItems is null) _highestTraderPriceItems = new Dictionary<string, int?>();
|
||||
if (_highestTraderPriceItems is not null) return _highestTraderPriceItems[tpl];
|
||||
|
||||
// Init dict and fill
|
||||
foreach (var traderName in Traders.TradersDictionary)
|
||||
@@ -463,7 +461,7 @@ public class TraderHelper(
|
||||
var traderAssorts = _databaseService.GetTrader(traderName.Value).Assort;
|
||||
if (traderAssorts is null) continue;
|
||||
|
||||
// Get all item assorts that have parentid of hideout (base item and not a mod of other item)
|
||||
// Get all item assorts that have parentId of hideout (base item and not a mod of other item)
|
||||
foreach (var item in traderAssorts.Items.Where(x => x.ParentId == "hideout"))
|
||||
{
|
||||
// Get barter scheme (contains cost of item)
|
||||
@@ -475,11 +473,14 @@ public class TraderHelper(
|
||||
: _handbookHelper.InRUB(barterScheme.Count ?? 1, barterScheme.Template);
|
||||
|
||||
// Existing price smaller in dict than current iteration, overwrite
|
||||
if ((_highestTraderPriceItems[item.Template] ?? 0) < roubleAmount) _highestTraderPriceItems[item.Template] = (int)roubleAmount;
|
||||
if (_highestTraderPriceItems[item.Template] < roubleAmount)
|
||||
{
|
||||
_highestTraderPriceItems[item.Template] = roubleAmount.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (double)_highestTraderPriceItems[tpl];
|
||||
return _highestTraderPriceItems[tpl];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -489,14 +490,14 @@ public class TraderHelper(
|
||||
/// <returns>Rouble price</returns>
|
||||
public double GetHighestSellToTraderPrice(string tpl)
|
||||
{
|
||||
// Find highest trader price for item
|
||||
// Find largest trader price for item
|
||||
var highestPrice = 1; // Default price
|
||||
foreach (var trader in Traders.TradersDictionary)
|
||||
{
|
||||
// Get trader and check buy category allows tpl
|
||||
var traderBase = _databaseService.GetTrader(trader.Value).Base;
|
||||
|
||||
// Skip traders that dont sell
|
||||
// Skip traders that don't sell
|
||||
if (traderBase is null || !_itemHelper.IsOfBaseclasses(tpl, traderBase.ItemsBuy.Category)) continue;
|
||||
|
||||
// Get loyalty level details player has achieved with this trader
|
||||
|
||||
@@ -154,11 +154,14 @@ public record Info
|
||||
public string? LowerNickname { get; set; }
|
||||
public string? Side { get; set; }
|
||||
public bool? SquadInviteRestriction { get; set; }
|
||||
|
||||
// Confirmed in client
|
||||
public int? PrestigeLevel { get; set; }
|
||||
public string? Voice { get; set; }
|
||||
public int? Level { get; set; }
|
||||
|
||||
///Experience the bot has gained
|
||||
//Experience the bot has gained
|
||||
// Confirmed in client
|
||||
public int? Experience { get; set; }
|
||||
|
||||
public List<Ban>? Bans { get; set; }
|
||||
@@ -166,6 +169,7 @@ public record Info
|
||||
public long? BannedUntil { get; set; }
|
||||
public bool? IsStreamerModeAvailable { get; set; }
|
||||
|
||||
// Confirmed in client
|
||||
[JsonConverter(typeof(StringToNumberFactoryConverter))]
|
||||
public int? RegistrationDate { get; set; }
|
||||
|
||||
|
||||
@@ -1119,10 +1119,10 @@ public record Props
|
||||
public string? RepairType { get; set; }
|
||||
|
||||
[JsonPropertyName("StackMinRandom")]
|
||||
public double? StackMinRandom { get; set; }
|
||||
public int? StackMinRandom { get; set; }
|
||||
|
||||
[JsonPropertyName("StackMaxRandom")]
|
||||
public double? StackMaxRandom { get; set; }
|
||||
public int? StackMaxRandom { get; set; }
|
||||
|
||||
[JsonPropertyName("ammoType")]
|
||||
public string? AmmoType { get; set; }
|
||||
|
||||
@@ -59,6 +59,7 @@ public record RagfairOffer
|
||||
[JsonPropertyName("buyRestrictionMax")]
|
||||
public int? BuyRestrictionMax { get; set; }
|
||||
|
||||
// Confirmed in client
|
||||
[JsonPropertyName("buyRestrictionCurrent")]
|
||||
public int? BuyRestrictionCurrent { get; set; }
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Core.Models.Enums;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Models.Spt.Weather;
|
||||
@@ -5,7 +6,7 @@ namespace Core.Models.Spt.Weather;
|
||||
public record GetLocalWeatherResponseData
|
||||
{
|
||||
[JsonPropertyName("season")]
|
||||
public int? Season { get; set; }
|
||||
public Season? Season { get; set; }
|
||||
|
||||
[JsonPropertyName("weather")]
|
||||
public List<Eft.Weather.Weather>? Weather { get; set; }
|
||||
|
||||
@@ -95,7 +95,7 @@ public class AirdropService(
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = "", // picked later
|
||||
Upd = new Upd()
|
||||
Upd = new Upd
|
||||
{
|
||||
SpawnedInSession = true,
|
||||
StackObjectsCount = 1
|
||||
|
||||
@@ -176,7 +176,7 @@ public class CircleOfCultistService(
|
||||
protected CircleCraftDetails GetCircleCraftingInfo(
|
||||
double rewardAmountRoubles,
|
||||
CultistCircleSettings circleConfig,
|
||||
DirectRewardSettings directRewardSettings = null
|
||||
DirectRewardSettings? directRewardSettings = null
|
||||
)
|
||||
{
|
||||
var result = new CircleCraftDetails
|
||||
@@ -580,7 +580,7 @@ public class CircleOfCultistService(
|
||||
var settings = _hideoutConfig.CultistCircle.CurrencyRewards[itemTpl];
|
||||
|
||||
// What % of the pool remaining should be rewarded as chosen currency
|
||||
var percentOfPoolToUse = _randomUtil.GetInt((int)settings.Min, (int)settings.Max);
|
||||
var percentOfPoolToUse = _randomUtil.GetDouble(settings.Min.Value, settings.Max.Value);
|
||||
|
||||
// Rouble amount of pool we want to reward as currency
|
||||
var roubleAmountToFill = _randomUtil.GetPercentOfValue(percentOfPoolToUse, rewardPoolRemaining);
|
||||
@@ -602,7 +602,7 @@ public class CircleOfCultistService(
|
||||
/// </summary>
|
||||
/// <param name="sessionId">Session id</param>
|
||||
/// <param name="pmcData">Profile of player who will be getting the rewards</param>
|
||||
/// <param name="rewardType">Do we return bonus items (hideout/task items)</param>
|
||||
/// <param name="craftingInfo">Do we return bonus items (hideout/task items)</param>
|
||||
/// <param name="cultistCircleConfig">Circle config</param>
|
||||
/// <returns>Array of tpls</returns>
|
||||
protected List<string> GetCultistCircleRewardPool(
|
||||
|
||||
@@ -157,9 +157,9 @@ public class FenceService(
|
||||
// We may need to find an alternative to nodes: delete root.location;
|
||||
root.Location = null;
|
||||
|
||||
var createAssort = new CreateFenceAssortsResult()
|
||||
var createAssort = new CreateFenceAssortsResult
|
||||
{ SptItems = [], BarterScheme = new Dictionary<string, List<List<BarterScheme>>>(), LoyalLevelItems = new Dictionary<string, int>() };
|
||||
createAssort.BarterScheme[root.Id] = [[new BarterScheme() { Count = cost, Template = Money.ROUBLES }]];
|
||||
createAssort.BarterScheme[root.Id] = [[new BarterScheme { Count = cost, Template = Money.ROUBLES }]];
|
||||
createAssort.SptItems.Add(clonedItems);
|
||||
createAssort.LoyalLevelItems[root.Id] = 1;
|
||||
|
||||
@@ -470,7 +470,7 @@ public class FenceService(
|
||||
var stackSize = rootItemToAdjust.Upd?.StackObjectsCount ?? 1;
|
||||
|
||||
// Get a random count of the chosen item to remove if its > 1
|
||||
var itemCountToRemove = randomUtil.GetInt(1, (int)stackSize);
|
||||
var itemCountToRemove = randomUtil.GetDouble(1, stackSize);
|
||||
|
||||
// Check if we're removing all or just part of the item
|
||||
var isEntireStackToBeRemoved = Math.Abs(itemCountToRemove - stackSize) < 0.1;
|
||||
@@ -571,10 +571,10 @@ public class FenceService(
|
||||
*/
|
||||
protected void CreateInitialFenceAssortGenerationValues()
|
||||
{
|
||||
var result = new FenceAssortGenerationValues()
|
||||
var result = new FenceAssortGenerationValues
|
||||
{
|
||||
Normal = new GenerationAssortValues() { Item = 0, WeaponPreset = 0, EquipmentPreset = 0 },
|
||||
Discount = new GenerationAssortValues() { Item = 0, WeaponPreset = 0, EquipmentPreset = 0 }
|
||||
Normal = new GenerationAssortValues { Item = 0, WeaponPreset = 0, EquipmentPreset = 0 },
|
||||
Discount = new GenerationAssortValues { Item = 0, WeaponPreset = 0, EquipmentPreset = 0 }
|
||||
};
|
||||
|
||||
result.Normal.Item = traderConfig.Fence.AssortSize;
|
||||
@@ -610,7 +610,7 @@ public class FenceService(
|
||||
*/
|
||||
protected TraderAssort CreateFenceAssortSkeleton()
|
||||
{
|
||||
return new TraderAssort()
|
||||
return new TraderAssort
|
||||
{
|
||||
Items = [],
|
||||
BarterScheme = new Dictionary<string, List<List<BarterScheme>>>(),
|
||||
@@ -626,7 +626,7 @@ public class FenceService(
|
||||
*/
|
||||
protected CreateFenceAssortsResult CreateAssorts(GenerationAssortValues itemCounts, int loyaltyLevel)
|
||||
{
|
||||
var result = new CreateFenceAssortsResult()
|
||||
var result = new CreateFenceAssortsResult
|
||||
{ SptItems = [], BarterScheme = new Dictionary<string, List<List<BarterScheme>>>(), LoyalLevelItems = new Dictionary<string, int>() };
|
||||
|
||||
var baseFenceAssortClone = _cloner.Clone(databaseService.GetTrader(Traders.FENCE).Assort);
|
||||
@@ -960,7 +960,7 @@ public class FenceService(
|
||||
assorts.BarterScheme[presetWithChildrenClone[0].Id] =
|
||||
[
|
||||
[
|
||||
new BarterScheme()
|
||||
new BarterScheme
|
||||
{
|
||||
Template = Money.ROUBLES,
|
||||
Count = Math.Round(itemPrice)
|
||||
@@ -1017,7 +1017,7 @@ public class FenceService(
|
||||
assorts.BarterScheme[presetWithChildrenClone[0].Id] =
|
||||
[
|
||||
[
|
||||
new BarterScheme()
|
||||
new BarterScheme
|
||||
{
|
||||
Template = Money.ROUBLES,
|
||||
Count = Math.Round(itemPrice)
|
||||
@@ -1079,7 +1079,7 @@ public class FenceService(
|
||||
itemHelper.AddUpdObjectToItem(modItemToAdjust);
|
||||
|
||||
if (modItemToAdjust.Upd.Repairable == null)
|
||||
modItemToAdjust.Upd.Repairable = new UpdRepairable()
|
||||
modItemToAdjust.Upd.Repairable = new UpdRepairable
|
||||
{
|
||||
Durability = modItemDbDetails.Properties.MaxDurability,
|
||||
MaxDurability = modItemDbDetails.Properties.MaxDurability
|
||||
@@ -1094,7 +1094,7 @@ public class FenceService(
|
||||
modItemToAdjust.SlotId == "mod_equipment_000" &&
|
||||
modItemToAdjust.Upd.Repairable.Durability < modItemDbDetails.Properties.MaxDurability)
|
||||
// Is damaged
|
||||
modItemToAdjust.Upd.FaceShield = new UpdFaceShield() { Hits = randomUtil.GetInt(1, 3) };
|
||||
modItemToAdjust.Upd.FaceShield = new UpdFaceShield { Hits = randomUtil.GetInt(1, 3) };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1181,8 +1181,8 @@ public class FenceService(
|
||||
return itemDbDetails.Properties.StackMaxSize == 1
|
||||
? 1
|
||||
: randomUtil.GetInt(
|
||||
(int)itemDbDetails.Properties.StackMinRandom,
|
||||
(int)itemDbDetails.Properties.StackMaxRandom
|
||||
itemDbDetails.Properties.StackMinRandom.Value,
|
||||
itemDbDetails.Properties.StackMaxRandom.Value
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1258,7 +1258,7 @@ public class FenceService(
|
||||
|
||||
// Randomise hp resource of med items
|
||||
if (itemDetails.Properties.MaxHpResource != null && (itemDetails.Properties.MaxHpResource ?? 0) > 0)
|
||||
itemToAdjust.Upd.MedKit = new UpdMedKit()
|
||||
itemToAdjust.Upd.MedKit = new UpdMedKit
|
||||
{ HpResource = randomUtil.GetInt(1, (int)itemDetails.Properties.MaxHpResource) };
|
||||
|
||||
// Randomise armor durability
|
||||
@@ -1273,7 +1273,7 @@ public class FenceService(
|
||||
itemDetails,
|
||||
traderConfig.Fence.ArmorMaxDurabilityPercentMinMax
|
||||
);
|
||||
itemToAdjust.Upd.Repairable = new UpdRepairable()
|
||||
itemToAdjust.Upd.Repairable = new UpdRepairable
|
||||
{ Durability = values.Durability, MaxDurability = values.MaxDurability };
|
||||
|
||||
return;
|
||||
@@ -1285,12 +1285,12 @@ public class FenceService(
|
||||
var weaponDurabilityLimits = traderConfig.Fence.WeaponDurabilityPercentMinMax;
|
||||
var maxDuraMin = weaponDurabilityLimits.Max.Min / 100 * itemDetails.Properties.MaxDurability;
|
||||
var maxDuraMax = weaponDurabilityLimits.Max.Max / 100 * itemDetails.Properties.MaxDurability;
|
||||
var chosenMaxDurability = randomUtil.GetInt((int)maxDuraMin, (int)maxDuraMax);
|
||||
var chosenMaxDurability = randomUtil.GetDouble(maxDuraMin.Value, maxDuraMax.Value);
|
||||
|
||||
var currentDuraMin = weaponDurabilityLimits.Current.Min / 100 * itemDetails.Properties.MaxDurability;
|
||||
var currentDuraMax = weaponDurabilityLimits.Current.Max / 100 * itemDetails.Properties.MaxDurability;
|
||||
var currentDurability = Math.Min(
|
||||
randomUtil.GetInt((int)currentDuraMin, (int)currentDuraMax),
|
||||
randomUtil.GetDouble(currentDuraMin.Value, currentDuraMax.Value),
|
||||
chosenMaxDurability
|
||||
);
|
||||
|
||||
@@ -1304,7 +1304,7 @@ public class FenceService(
|
||||
{
|
||||
itemToAdjust.Upd.RepairKit = new UpdRepairKit
|
||||
{
|
||||
Resource = randomUtil.GetInt(1, (int)itemDetails.Properties.MaxRepairResource)
|
||||
Resource = randomUtil.GetDouble(1, itemDetails.Properties.MaxRepairResource.Value)
|
||||
};
|
||||
|
||||
return;
|
||||
@@ -1316,7 +1316,7 @@ public class FenceService(
|
||||
{
|
||||
itemToAdjust.Upd.Key = new UpdKey
|
||||
{
|
||||
NumberOfUsages = randomUtil.GetInt(0, (int)itemDetails.Properties.MaximumNumberOfUsage - 1)
|
||||
NumberOfUsages = randomUtil.GetInt(0, itemDetails.Properties.MaximumNumberOfUsage.Value - 1)
|
||||
};
|
||||
|
||||
return;
|
||||
@@ -1326,7 +1326,7 @@ public class FenceService(
|
||||
if ((itemDetails.Properties.MaxResource ?? 0) > 0)
|
||||
{
|
||||
var resourceMax = itemDetails.Properties.MaxResource;
|
||||
var resourceCurrent = randomUtil.GetInt(1, (int)itemDetails.Properties.MaxResource);
|
||||
var resourceCurrent = randomUtil.GetInt(1, itemDetails.Properties.MaxResource.Value);
|
||||
|
||||
itemToAdjust.Upd.Resource = new UpdResource
|
||||
{ Value = resourceMax - resourceCurrent, UnitsConsumed = resourceCurrent };
|
||||
@@ -1334,9 +1334,9 @@ public class FenceService(
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a randomised current and max durabiltiy value for an armor item
|
||||
* Generate a randomised current and max durability value for an armor item
|
||||
* @param itemDetails Item to create values for
|
||||
* @param equipmentDurabilityLimits Max durabiltiy percent min/max values
|
||||
* @param equipmentDurabilityLimits Max durability percent min/max values
|
||||
* @returns Durability + MaxDurability values
|
||||
*/
|
||||
protected UpdRepairable GetRandomisedArmorDurabilityValues(
|
||||
@@ -1346,16 +1346,16 @@ public class FenceService(
|
||||
{
|
||||
var maxDuraMin = equipmentDurabilityLimits.Max.Min / 100 * itemDetails.Properties.MaxDurability;
|
||||
var maxDuraMax = equipmentDurabilityLimits.Max.Max / 100 * itemDetails.Properties.MaxDurability;
|
||||
var chosenMaxDurability = randomUtil.GetInt((int)maxDuraMin, (int)maxDuraMax);
|
||||
var chosenMaxDurability = randomUtil.GetDouble(maxDuraMin.Value, maxDuraMax.Value);
|
||||
|
||||
var currentDuraMin = equipmentDurabilityLimits.Current.Min / 100 * itemDetails.Properties.MaxDurability;
|
||||
var currentDuraMax = equipmentDurabilityLimits.Current.Max / 100 * itemDetails.Properties.MaxDurability;
|
||||
var chosenCurrentDurability = Math.Min(
|
||||
randomUtil.GetInt((int)currentDuraMin, (int)currentDuraMax),
|
||||
randomUtil.GetDouble(currentDuraMin.Value, currentDuraMax.Value),
|
||||
chosenMaxDurability
|
||||
);
|
||||
|
||||
return new UpdRepairable() { Durability = chosenCurrentDurability, MaxDurability = chosenMaxDurability };
|
||||
return new UpdRepairable { Durability = chosenCurrentDurability, MaxDurability = chosenMaxDurability };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1380,8 +1380,8 @@ public class FenceService(
|
||||
public long GetNextFenceUpdateTimestamp()
|
||||
{
|
||||
var time = timeUtil.GetTimeStamp();
|
||||
var UpdateSeconds = GetFenceRefreshTime();
|
||||
return time + UpdateSeconds;
|
||||
var updateSeconds = GetFenceRefreshTime();
|
||||
return time + updateSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Core.Helpers;
|
||||
using Core.Helpers;
|
||||
using SptCommon.Annotations;
|
||||
using Core.Models.Eft.Common;
|
||||
using Core.Models.Eft.Common.Tables;
|
||||
@@ -162,7 +162,7 @@ public class InsuranceService(
|
||||
|
||||
var traderMinReturnAsSeconds = trader.Insurance.MinReturnHour * TimeUtil.OneHourAsSeconds;
|
||||
var traderMaxReturnAsSeconds = trader.Insurance.MaxReturnHour * TimeUtil.OneHourAsSeconds;
|
||||
var randomisedReturnTimeSeconds = _randomUtil.GetInt((int)traderMinReturnAsSeconds, (int)traderMaxReturnAsSeconds);
|
||||
var randomisedReturnTimeSeconds = _randomUtil.GetDouble(traderMinReturnAsSeconds.Value, traderMaxReturnAsSeconds.Value);
|
||||
|
||||
// Check for Mark of The Unheard in players special slots (only slot item can fit)
|
||||
var globals = _databaseService.GetGlobals();
|
||||
@@ -173,14 +173,14 @@ public class InsuranceService(
|
||||
);
|
||||
if (hasMarkOfUnheard)
|
||||
// Reduce return time by globals multipler value
|
||||
randomisedReturnTimeSeconds *= (int)globals.Configuration.Insurance.CoefOfHavingMarkOfUnknown;
|
||||
randomisedReturnTimeSeconds *= globals.Configuration.Insurance.CoefOfHavingMarkOfUnknown.Value;
|
||||
|
||||
// EoD has 30% faster returns
|
||||
var editionModifier = globals.Configuration.Insurance.EditionSendingMessageTime[pmcData.Info.GameVersion];
|
||||
if (editionModifier is not null) randomisedReturnTimeSeconds *= (int)editionModifier.Multiplier;
|
||||
if (editionModifier is not null) randomisedReturnTimeSeconds *= editionModifier.Multiplier.Value;
|
||||
|
||||
// Calculate the final return time based on our bonus percent
|
||||
var finalReturnTimeSeconds = randomisedReturnTimeSeconds * (1.0 - insuranceReturnTimeBonusPercent);
|
||||
var finalReturnTimeSeconds = randomisedReturnTimeSeconds * (1d - insuranceReturnTimeBonusPercent);
|
||||
return _timeUtil.GetTimeStamp() + finalReturnTimeSeconds;
|
||||
}
|
||||
|
||||
|
||||
@@ -530,6 +530,8 @@ public class LocationLifecycleService
|
||||
_traderHelper.LevelUp(fenceId, pmcData);
|
||||
pmcData.TradersInfo[fenceId].LoyaltyLevel = Math.Max((int)pmcData.TradersInfo[fenceId].LoyaltyLevel, 1);
|
||||
|
||||
_logger.Debug($"COOP extract: {extractName} used");
|
||||
|
||||
// Copy updated fence rep values into scav profile to ensure consistency
|
||||
var scavData = _profileHelper.GetScavProfile(sessionId);
|
||||
scavData.TradersInfo[fenceId].Standing = pmcData.TradersInfo[fenceId].Standing;
|
||||
@@ -1004,7 +1006,7 @@ public class LocationLifecycleService
|
||||
MessageType.BTR_ITEMS_DELIVERY,
|
||||
messageId,
|
||||
items,
|
||||
(int)messageStoreTime
|
||||
messageStoreTime
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class MailSendService(
|
||||
if (items?.Count > 0)
|
||||
{
|
||||
details.Items.AddRange(items);
|
||||
details.ItemsMaxStorageLifetimeSeconds = (long?)maxStorageTimeSeconds;
|
||||
details.ItemsMaxStorageLifetimeSeconds = maxStorageTimeSeconds;
|
||||
}
|
||||
|
||||
if (systemData is not null)
|
||||
|
||||
@@ -82,7 +82,7 @@ public class PaymentService(
|
||||
}
|
||||
|
||||
// Track the total amount of all currencies.
|
||||
var totalCurrencyAmount = 0;
|
||||
var totalCurrencyAmount = 0d;
|
||||
|
||||
// Loop through each type of currency involved in the trade.
|
||||
foreach (var currencyTpl in currencyAmounts)
|
||||
@@ -90,10 +90,10 @@ public class PaymentService(
|
||||
if (currencyTpl.Value <= 0) continue;
|
||||
|
||||
var currencyAmount = currencyTpl.Value;
|
||||
totalCurrencyAmount += (int)currencyAmount;
|
||||
totalCurrencyAmount += currencyAmount.Value;
|
||||
|
||||
// Find money stacks in inventory and remove amount needed + update output object to inform client of changes
|
||||
AddPaymentToOutput(pmcData, currencyTpl.Key, (int)currencyAmount, sessionID, output);
|
||||
AddPaymentToOutput(pmcData, currencyTpl.Key, currencyAmount.Value, sessionID, output);
|
||||
|
||||
// If there are warnings, exit early.
|
||||
if (output.Warnings?.Count > 0) return;
|
||||
@@ -255,8 +255,8 @@ public class PaymentService(
|
||||
foreach (var moneyStack in moneyItemsInInventory) moneyStack.Upd ??= new Upd { StackObjectsCount = 1 };
|
||||
|
||||
var amountAvailable = moneyItemsInInventory.Aggregate(
|
||||
0,
|
||||
(accumulator, item) => (int)(accumulator + item.Upd.StackObjectsCount)
|
||||
0d,
|
||||
(accumulator, item) => (accumulator + item.Upd.StackObjectsCount.Value)
|
||||
);
|
||||
|
||||
// If no money in inventory or amount is not enough we return false
|
||||
@@ -264,7 +264,7 @@ public class PaymentService(
|
||||
{
|
||||
_logger.Error(
|
||||
_localisationService.GetText(
|
||||
"payment-not_enough_money_to_complete_transation",
|
||||
"payment-not_enough_money_to_complete_transation", // Typo, needs locale updated if fixed
|
||||
new
|
||||
{
|
||||
amountToPay = amountToPay,
|
||||
@@ -274,7 +274,7 @@ public class PaymentService(
|
||||
);
|
||||
_httpResponseUtil.AppendErrorToOutput(
|
||||
output,
|
||||
_localisationService.GetText("payment-not_enough_money_to_complete_transation_short", amountToPay),
|
||||
_localisationService.GetText("payment-not_enough_money_to_complete_transation_short", amountToPay), // Typo, needs locale updated if fixed
|
||||
BackendErrorCodes.UnknownTradingError
|
||||
);
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class TraderPurchasePersisterService(
|
||||
var purchaseDetails = purchaseKvP.Value;
|
||||
var resetTimeForItem =
|
||||
purchaseDetails.PurchaseTimestamp +
|
||||
_randomUtil.GetInt((int)traderUpdateDetails.Seconds.Min, (int)traderUpdateDetails.Seconds.Max);
|
||||
_randomUtil.GetDouble(traderUpdateDetails.Seconds.Min.Value, traderUpdateDetails.Seconds.Max.Value);
|
||||
if (resetTimeForItem < _timeUtil.GetTimeStamp())
|
||||
{
|
||||
// Item was purchased far enough in past a trader refresh would have occured, remove purchase record from profile
|
||||
|
||||
@@ -173,7 +173,7 @@ public class ProbabilityObjectArray<K, V> : List<ProbabilityObject<K, V>>
|
||||
for (var i = 0; i < drawCount; i++)
|
||||
{
|
||||
var rand = Random.Shared.NextDouble();
|
||||
var randomIndex = (int)probCumsum.FindIndex((x) => x > rand);
|
||||
var randomIndex = probCumsum.FindIndex((x) => x > rand);
|
||||
// We cannot put Math.random() directly in the findIndex because then it draws anew for each of its iteration
|
||||
if (removeAfterDraw || neverRemoveWhitelist.Contains(totals.keyArray[randomIndex]))
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Security.Cryptography;
|
||||
using SptCommon.Annotations;
|
||||
using Core.Models.Utils;
|
||||
using Core.Utils.Cloners;
|
||||
|
||||
Reference in New Issue
Block a user