Skip to content
6 changes: 4 additions & 2 deletions Content.IntegrationTests/Tests/VendingMachineRestockTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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<ADTVendingFoodNutrimentReductionComponent>(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);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using Robust.Shared.Random;
using Content.Shared.ADT.VendingMachines;
using Content.Shared.Stacks;
Expand All @@ -7,20 +8,27 @@
namespace Content.Server.Destructible.Thresholds.Behaviors
{
/// <summary>
/// Spawns a portion of the total items from one of the canRestock
/// Spawns a random amount of items from one of the canRestock
Comment thread
CrimeMoot marked this conversation as resolved.
/// inventory entries on a VendingMachineRestock component.
/// </summary>
[Serializable]
[DataDefinition]
public sealed partial class DumpRestockInventory: IThresholdBehavior
{
/// ADT-Tweak start
/// <summary>
/// The percent of each inventory entry that will be salvaged
/// upon destruction of the package.
/// </summary>
[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;

Expand All @@ -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<StackComponent>(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<TransformComponent>(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<TransformComponent>(spawned).LocalRotation = system.Random.NextAngle();
}
var spawned = system.EntityManager.SpawnEntity(entityId, xform.Coordinates.Offset(system.Random.NextVector2(-Offset, Offset)));
system.EntityManager.GetComponent<TransformComponent>(spawned).LocalRotation = system.Random.NextAngle();
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/VendingMachines/VendingMachineSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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<ReagentPrototype> NutrimentReagent = "Nutriment";
}
2 changes: 1 addition & 1 deletion Content.Shared/Nutrition/Components/HungerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public sealed partial class HungerComponent : Component
/// </summary>
/// <remarks>Any time this is modified, <see cref="HungerSystem.SetAuthoritativeHungerValue"/> should be called.</remarks>
[DataField("baseDecayRate"), ViewVariables(VVAccess.ReadWrite)]
public float BaseDecayRate = 0.01666666666f;
public float BaseDecayRate = 0.02491666666f; // ADT-Tweak > 49.5% 0.01666666666f;

/// <summary>
/// The actual amount at which <see cref="LastAuthoritativeHungerValue"/> decays.
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Nutrition/Components/ThirstComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment thread
CrimeMoot marked this conversation as resolved.

[ViewVariables(VVAccess.ReadWrite)]
[AutoNetworkedField]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/ADT/alerts/alerts.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ alerts-cold-comfy-name = Вы охлаждены
alerts-cold-comfy-desc = Вы чувствуете приятную прохладу по телу, старайтесь поддерживать это состояние как можно дольше.
alerts-adt-regenerative-core-name = Регенеративное ядро
alerts-adt-regenerative-core-desc = Чёрные щупальца скрепляют ваше тело. Раны затягиваются, а урон больше не замедляет вас.

2 changes: 1 addition & 1 deletion Resources/Prototypes/ADT/Body/Species/felinid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
id: MobFelinid
components:
- type: Hunger
baseDecayRate: 0.024
baseDecayRate: 0.03588
- type: Respirator
damage:
types:
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/ADT/Body/Species/novakid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
id: MobNovakid
components:
- type: Hunger
baseDecayRate: 0.025
baseDecayRate: 0.037375
lastAuthoritativeHungerValue: 400
thresholds:
Overfed: 400
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@
maxVol: 30
reagents:
- ReagentId: Nutriment
Quantity: 10
Quantity: 5
- ReagentId: Theobromine
Quantity: 3
- ReagentId: CocoaPowder
Expand Down Expand Up @@ -611,7 +611,7 @@
maxVol: 4
reagents:
- ReagentId: Nutriment
Quantity: 2.5
Quantity: 1.25
- ReagentId: Theobromine
Quantity: 0.75
- ReagentId: CocoaPowder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,17 @@
components:
- type: VendingMachine
pack: ADTIceCreamVendInventory
initialStockQuality: 0.33
dispenseOnHitChance: 0.25
dispenseOnHitThreshold: 2
offState: off
brokenState: broken
normalState: normal-unshaded
ejectState: eject-unshaded
denyState: deny-unshaded
priceMultiplier: 0.57 # ADT-Economy
ejectDelay: 1
- type: ADTVendingFoodNutrimentReduction
- type: DatasetVocalizer
dataset: IceCreammatAds
- type: SpeakOnUIClosed
Expand Down Expand Up @@ -326,6 +330,7 @@
denyState: deny-unshaded
initialStockQuality: 0.33
allForFree: true # ADT-Economy
- type: ADTVendingFoodNutrimentReduction

- type: entity
parent: VendingMachine
Expand Down
4 changes: 2 additions & 2 deletions Resources/Prototypes/Body/Species/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
maxVol: 30
reagents:
- ReagentId: Nutriment
Quantity: 10
Quantity: 5 # ADT-Tweak 10 > 5
- ReagentId: Theobromine
Quantity: 3
- ReagentId: CocoaPowder
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@
brokenState: broken
normalState: normal-unshaded
initialStockQuality: 0.33
- type: ADTVendingFoodNutrimentReduction # ADT-Tweak
- type: DatasetVocalizer
dataset: DiscountDansAds
- type: SpeakOnUIClosed
Expand Down Expand Up @@ -1104,6 +1105,7 @@
ejectState: eject-unshaded
denyState: deny-unshaded
initialStockQuality: 0.33
- type: ADTVendingFoodNutrimentReduction # ADT-Tweak
- type: DatasetVocalizer
dataset: GetmoreChocolateCorpAds
- type: SpeakOnUIClosed
Expand Down Expand Up @@ -1456,6 +1458,7 @@
brokenState: broken
normalState: normal-unshaded
initialStockQuality: 0.33
- type: ADTVendingFoodNutrimentReduction # ADT-Tweak
- type: DatasetVocalizer
dataset: ChangAds
- type: SpeakOnUIClosed
Expand Down
Loading