diff --git a/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs b/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs index 70bff34f637..cc293bbaf1b 100644 --- a/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs +++ b/Content.IntegrationTests/Tests/VendingMachineRestockTest.cs @@ -335,8 +335,10 @@ await server.WaitAssertion(() => if (!meta.Deleted && meta.EntityPrototype?.ID == "TestRamen") totalRamen++; - Assert.That(totalRamen, Is.EqualTo(2), - "Did not find enough ramen after destroying restock box."); + // ADT-Tweak start + Assert.That(totalRamen, Is.InRange(2, 5), + "Did not find the expected amount of ramen after destroying restock box."); + // ADT-Tweak end mapSystem.DeleteMap(testMap.MapId); }); diff --git a/Content.Server/ADT/VendingMachines/ADTVendingFoodNutrimentSystem.cs b/Content.Server/ADT/VendingMachines/ADTVendingFoodNutrimentSystem.cs new file mode 100644 index 00000000000..2c93b865be7 --- /dev/null +++ b/Content.Server/ADT/VendingMachines/ADTVendingFoodNutrimentSystem.cs @@ -0,0 +1,27 @@ +using Content.Shared.ADT.VendingMachines; +using Content.Shared.Chemistry.Components; +using Content.Shared.Chemistry.EntitySystems; + +namespace Content.Server.ADT.VendingMachines; + +public sealed class ADTVendingFoodNutrimentSystem : EntitySystem +{ + [Dependency] private readonly SharedSolutionContainerSystem _solution = default!; + + private const string FoodSolution = "food"; + + public void ReduceDispensedFood(EntityUid vendingMachine, EntityUid dispensed) + { + if (!TryComp(vendingMachine, out var reduction) + || !_solution.TryGetSolution(dispensed, FoodSolution, out var soln, out var food) + || soln is not { } solEnt || food is not { } solution) + return; + + var nutriment = solution.GetTotalPrototypeQuantity(reduction.NutrimentReagent); + if (nutriment <= 0) + return; + + _solution.RemoveReagent(solEnt, reduction.NutrimentReagent, nutriment * reduction.NutrimentMultiplier); + _solution.UpdateChemicals(solEnt); + } +} diff --git a/Content.Server/Destructible/Thresholds/Behaviors/DumpRestockInventory.cs b/Content.Server/Destructible/Thresholds/Behaviors/DumpRestockInventory.cs index 02eeb72b60b..091d9938d50 100644 --- a/Content.Server/Destructible/Thresholds/Behaviors/DumpRestockInventory.cs +++ b/Content.Server/Destructible/Thresholds/Behaviors/DumpRestockInventory.cs @@ -1,3 +1,4 @@ +using System.Linq; using Robust.Shared.Random; using Content.Shared.ADT.VendingMachines; using Content.Shared.Stacks; @@ -7,20 +8,27 @@ namespace Content.Server.Destructible.Thresholds.Behaviors { /// - /// Spawns a portion of the total items from one of the canRestock + /// Spawns a random amount of items from one of the canRestock /// inventory entries on a VendingMachineRestock component. /// [Serializable] [DataDefinition] public sealed partial class DumpRestockInventory: IThresholdBehavior { + /// ADT-Tweak start /// /// The percent of each inventory entry that will be salvaged /// upon destruction of the package. /// - [DataField("percent", required: true)] - public float Percent = 0.5f; + ///[DataField("percent", required: true)] + ///public float Percent = 0.5f; + [DataField("minCount")] + public int MinCount = 2; + + [DataField("maxCount")] + public int MaxCount = 5; + // ADT-Tweak end [DataField("offset")] public float Offset { get; set; } = 0.5f; @@ -35,25 +43,27 @@ public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause if (!system.PrototypeManager.TryIndex(randomInventory, out VendingMachineInventoryPrototype? packPrototype)) return; - foreach (var (entityId, count, _) in VendingMachineInventoryData.Flatten(packPrototype.StartingInventory)) // ADT-Tweak - { - var toSpawn = (int) Math.Round(count * Percent); + // ADT-Tweak start + var inventory = VendingMachineInventoryData.Flatten(packPrototype.StartingInventory).ToList(); // ADT-Tweak + if (inventory.Count == 0) + return; - if (toSpawn == 0) continue; + var count = system.Random.Next(MinCount, MaxCount + 1); + for (var i = 0; i < count; i++) + { + var (entityId, _, _) = system.Random.Pick(inventory); + // ADT-Tweak end if (EntityPrototypeHelpers.HasComponent(entityId, system.PrototypeManager, system.EntityManager.ComponentFactory)) { var spawned = system.EntityManager.SpawnEntity(entityId, xform.Coordinates.Offset(system.Random.NextVector2(-Offset, Offset))); - system.StackSystem.SetCount((spawned, null), toSpawn); + system.StackSystem.SetCount((spawned, null), 1); // ADT-Tweak system.EntityManager.GetComponent(spawned).LocalRotation = system.Random.NextAngle(); } else { - for (var i = 0; i < toSpawn; i++) - { - var spawned = system.EntityManager.SpawnEntity(entityId, xform.Coordinates.Offset(system.Random.NextVector2(-Offset, Offset))); - system.EntityManager.GetComponent(spawned).LocalRotation = system.Random.NextAngle(); - } + var spawned = system.EntityManager.SpawnEntity(entityId, xform.Coordinates.Offset(system.Random.NextVector2(-Offset, Offset))); + system.EntityManager.GetComponent(spawned).LocalRotation = system.Random.NextAngle(); } } } diff --git a/Content.Server/VendingMachines/VendingMachineSystem.cs b/Content.Server/VendingMachines/VendingMachineSystem.cs index 08915215b5e..7f275ba18df 100644 --- a/Content.Server/VendingMachines/VendingMachineSystem.cs +++ b/Content.Server/VendingMachines/VendingMachineSystem.cs @@ -58,6 +58,7 @@ public sealed class VendingMachineSystem : SharedVendingMachineSystem [Dependency] private readonly StackSystem _stackSystem = default!; [Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!; [Dependency] private readonly ADTVendingMachineReturnSystem _vendingReturn = default!; + [Dependency] private readonly ADTVendingFoodNutrimentSystem _adtFoodNutriment = default!; // ADT-Tweak [Dependency] private readonly CargoSystem _cargoSystem = default!; [Dependency] private readonly StationSystem _stationSystem = default!; //ADT-Economy-End @@ -650,6 +651,8 @@ protected override void EjectItem(EntityUid uid, VendingMachineComponent? vendCo { var ent = Spawn(vendComponent.NextItemToEject, spawnCoordinates); + _adtFoodNutriment.ReduceDispensedFood(uid, ent); + if (vendComponent.NextItemPaintColor is { } paintColor) _vendingReturn.PaintClothing(ent, paintColor); diff --git a/Content.Shared/ADT/VendingMachines/ADTVendingFoodNutrimentReductionComponent.cs b/Content.Shared/ADT/VendingMachines/ADTVendingFoodNutrimentReductionComponent.cs new file mode 100644 index 00000000000..9ce25ab97ca --- /dev/null +++ b/Content.Shared/ADT/VendingMachines/ADTVendingFoodNutrimentReductionComponent.cs @@ -0,0 +1,14 @@ +using Content.Shared.Chemistry.Reagent; +using Robust.Shared.Prototypes; + +namespace Content.Shared.ADT.VendingMachines; + +[RegisterComponent] +public sealed partial class ADTVendingFoodNutrimentReductionComponent : Component +{ + [DataField] + public float NutrimentMultiplier = 0.5f; + + [DataField] + public ProtoId NutrimentReagent = "Nutriment"; +} diff --git a/Content.Shared/Nutrition/Components/HungerComponent.cs b/Content.Shared/Nutrition/Components/HungerComponent.cs index c9f6ede7937..2c93104b03b 100644 --- a/Content.Shared/Nutrition/Components/HungerComponent.cs +++ b/Content.Shared/Nutrition/Components/HungerComponent.cs @@ -34,7 +34,7 @@ public sealed partial class HungerComponent : Component /// /// Any time this is modified, should be called. [DataField("baseDecayRate"), ViewVariables(VVAccess.ReadWrite)] - public float BaseDecayRate = 0.01666666666f; + public float BaseDecayRate = 0.02491666666f; // ADT-Tweak > 49.5% 0.01666666666f; /// /// The actual amount at which decays. diff --git a/Content.Shared/Nutrition/Components/ThirstComponent.cs b/Content.Shared/Nutrition/Components/ThirstComponent.cs index cbd26e6a5ec..d9588c90e8b 100644 --- a/Content.Shared/Nutrition/Components/ThirstComponent.cs +++ b/Content.Shared/Nutrition/Components/ThirstComponent.cs @@ -14,7 +14,7 @@ public sealed partial class ThirstComponent : Component [ViewVariables(VVAccess.ReadWrite)] [DataField("baseDecayRate")] [AutoNetworkedField] - public float BaseDecayRate = 0.1f; + public float BaseDecayRate = 0.1495f; // ADT-Tweak 49.5% > 0.1f; [ViewVariables(VVAccess.ReadWrite)] [AutoNetworkedField] diff --git a/Content.Shared/VendingMachines/SharedVendingMachineSystem.cs b/Content.Shared/VendingMachines/SharedVendingMachineSystem.cs index 40d3f294afa..2afe16fb799 100644 --- a/Content.Shared/VendingMachines/SharedVendingMachineSystem.cs +++ b/Content.Shared/VendingMachines/SharedVendingMachineSystem.cs @@ -439,11 +439,11 @@ private void AddInventoryFromPrototype(EntityUid uid, IEnumerable<(string Id, ui // losing the rest of the restock. //ADT-Economy-Start - entry.Amount = Math.Min(entry.Amount + amount, 3 * amount); + entry.Amount = Math.Max(entry.Amount, Math.Min(entry.Amount + restock, 3 * amount)); else { var price = GetEntryPrice(proto); - inventory.Add(id, new VendingMachineInventoryEntry(type, id, amount, price, amount, category)); + inventory.Add(id, new VendingMachineInventoryEntry(type, id, restock, price, amount, category)); } //ADT-Economy-End } diff --git a/Resources/Locale/ru-RU/ADT/alerts/alerts.ftl b/Resources/Locale/ru-RU/ADT/alerts/alerts.ftl index a499d0f4313..444c59c8fe0 100644 --- a/Resources/Locale/ru-RU/ADT/alerts/alerts.ftl +++ b/Resources/Locale/ru-RU/ADT/alerts/alerts.ftl @@ -10,3 +10,4 @@ alerts-cold-comfy-name = Вы охлаждены alerts-cold-comfy-desc = Вы чувствуете приятную прохладу по телу, старайтесь поддерживать это состояние как можно дольше. alerts-adt-regenerative-core-name = Регенеративное ядро alerts-adt-regenerative-core-desc = Чёрные щупальца скрепляют ваше тело. Раны затягиваются, а урон больше не замедляет вас. + diff --git a/Resources/Prototypes/ADT/Body/Species/felinid.yml b/Resources/Prototypes/ADT/Body/Species/felinid.yml index 78150490cfd..ab76ef74c3e 100644 --- a/Resources/Prototypes/ADT/Body/Species/felinid.yml +++ b/Resources/Prototypes/ADT/Body/Species/felinid.yml @@ -38,7 +38,7 @@ id: MobFelinid components: - type: Hunger - baseDecayRate: 0.024 + baseDecayRate: 0.03588 - type: Respirator damage: types: diff --git a/Resources/Prototypes/ADT/Body/Species/novakid.yml b/Resources/Prototypes/ADT/Body/Species/novakid.yml index 38ddad55247..8eee9b75a41 100644 --- a/Resources/Prototypes/ADT/Body/Species/novakid.yml +++ b/Resources/Prototypes/ADT/Body/Species/novakid.yml @@ -47,7 +47,7 @@ id: MobNovakid components: - type: Hunger - baseDecayRate: 0.025 + baseDecayRate: 0.037375 lastAuthoritativeHungerValue: 400 thresholds: Overfed: 400 diff --git a/Resources/Prototypes/ADT/Entities/Objects/Consumable/Food/snacks.yml b/Resources/Prototypes/ADT/Entities/Objects/Consumable/Food/snacks.yml index 1e1c2971a3d..1edef95c5b8 100644 --- a/Resources/Prototypes/ADT/Entities/Objects/Consumable/Food/snacks.yml +++ b/Resources/Prototypes/ADT/Entities/Objects/Consumable/Food/snacks.yml @@ -406,7 +406,7 @@ maxVol: 30 reagents: - ReagentId: Nutriment - Quantity: 10 + Quantity: 5 - ReagentId: Theobromine Quantity: 3 - ReagentId: CocoaPowder @@ -611,7 +611,7 @@ maxVol: 4 reagents: - ReagentId: Nutriment - Quantity: 2.5 + Quantity: 1.25 - ReagentId: Theobromine Quantity: 0.75 - ReagentId: CocoaPowder diff --git a/Resources/Prototypes/ADT/Entities/Structures/Machines/vending_machines.yml b/Resources/Prototypes/ADT/Entities/Structures/Machines/vending_machines.yml index 9d8044a83c7..5d212226047 100644 --- a/Resources/Prototypes/ADT/Entities/Structures/Machines/vending_machines.yml +++ b/Resources/Prototypes/ADT/Entities/Structures/Machines/vending_machines.yml @@ -205,6 +205,9 @@ components: - type: VendingMachine pack: ADTIceCreamVendInventory + initialStockQuality: 0.33 + dispenseOnHitChance: 0.25 + dispenseOnHitThreshold: 2 offState: off brokenState: broken normalState: normal-unshaded @@ -212,6 +215,7 @@ denyState: deny-unshaded priceMultiplier: 0.57 # ADT-Economy ejectDelay: 1 + - type: ADTVendingFoodNutrimentReduction - type: DatasetVocalizer dataset: IceCreammatAds - type: SpeakOnUIClosed @@ -326,6 +330,7 @@ denyState: deny-unshaded initialStockQuality: 0.33 allForFree: true # ADT-Economy + - type: ADTVendingFoodNutrimentReduction - type: entity parent: VendingMachine diff --git a/Resources/Prototypes/Body/Species/diona.yml b/Resources/Prototypes/Body/Species/diona.yml index 38486180420..376584906cd 100644 --- a/Resources/Prototypes/Body/Species/diona.yml +++ b/Resources/Prototypes/Body/Species/diona.yml @@ -80,9 +80,9 @@ types: Asphyxiation: -1.0 - type: Hunger - baseDecayRate: 0.0083 + baseDecayRate: 0.0124085 # ADT-Tweak: было 0.0083, стало > 0.0124085 - type: Thirst - baseDecayRate: 0.0083 + baseDecayRate: 0.0124085 # ADT-Tweak: было 0.0083, стало > 0.0124085 - type: Damageable damageModifierSet: Diona - type: Injurable diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/snacks.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/snacks.yml index 50fe766df96..a76cb6d7d55 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/snacks.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/snacks.yml @@ -145,7 +145,7 @@ maxVol: 30 reagents: - ReagentId: Nutriment - Quantity: 10 + Quantity: 5 # ADT-Tweak 10 > 5 - ReagentId: Theobromine Quantity: 3 - ReagentId: CocoaPowder @@ -191,6 +191,15 @@ - type: Item heldPrefix: energybar-open storedOffset: 0,-2 + # ADT-Tweak start + - type: SolutionContainerManager + solutions: + food: + maxVol: 30 + reagents: + - ReagentId: Nutriment + Quantity: 5 + # ADT-Tweak end - type: entity parent: FoodSnackBase diff --git a/Resources/Prototypes/Entities/Structures/Machines/vending_machines.yml b/Resources/Prototypes/Entities/Structures/Machines/vending_machines.yml index fe3d2cc448b..6b28d27e535 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/vending_machines.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/vending_machines.yml @@ -867,6 +867,7 @@ brokenState: broken normalState: normal-unshaded initialStockQuality: 0.33 + - type: ADTVendingFoodNutrimentReduction # ADT-Tweak - type: DatasetVocalizer dataset: DiscountDansAds - type: SpeakOnUIClosed @@ -1104,6 +1105,7 @@ ejectState: eject-unshaded denyState: deny-unshaded initialStockQuality: 0.33 + - type: ADTVendingFoodNutrimentReduction # ADT-Tweak - type: DatasetVocalizer dataset: GetmoreChocolateCorpAds - type: SpeakOnUIClosed @@ -1456,6 +1458,7 @@ brokenState: broken normalState: normal-unshaded initialStockQuality: 0.33 + - type: ADTVendingFoodNutrimentReduction # ADT-Tweak - type: DatasetVocalizer dataset: ChangAds - type: SpeakOnUIClosed