From 64512469a272ad904c8da09cac2486a3a86080f4 Mon Sep 17 00:00:00 2001 From: Sterling Parker Date: Wed, 18 Aug 2021 17:32:23 -0600 Subject: [PATCH] Hunger: Add spoilrate for consumables --- hunger/module/consumable/consumable.zsc | 1 + hunger/module/consumable/consumable_base.zsc | 2 ++ hunger/module/consumable/consumable_misc.zsc | 4 ++-- hunger/module/hunger_tracker.zsc | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hunger/module/consumable/consumable.zsc b/hunger/module/consumable/consumable.zsc index 989a9783..5da88138 100644 --- a/hunger/module/consumable/consumable.zsc +++ b/hunger/module/consumable/consumable.zsc @@ -8,6 +8,7 @@ class UaS_Consumable : HDWeapon abstract { UaS_Consumable.Calories 0; // Calories / kCals provided by this consumable UaS_Consumable.Fluid 0; // Milliliteres of hydration provided by this consumable UaS_Consumable.Bulk 0; // Bulk Units, also influences number of "swallows" when consumed + UaS_Consumable.SpoilRate 1.0; // 2.0 == twice as fast, 0.5 == half as fast UaS_Consumable.Description ""; // Description shown to player UaS_Consumable.OpenSound "UaS/FoodOpen"; // Sound played when opening packaged food item //+UaS_Consumable.RESEALABLE; diff --git a/hunger/module/consumable/consumable_base.zsc b/hunger/module/consumable/consumable_base.zsc index 1746f461..6a1669a6 100644 --- a/hunger/module/consumable/consumable_base.zsc +++ b/hunger/module/consumable/consumable_base.zsc @@ -3,6 +3,7 @@ extend class UaS_Consumable { int calories; int fluid; double bulk, diffbulk; + double spoilrate; string description; string opensound; array OpenText; @@ -12,6 +13,7 @@ extend class UaS_Consumable { property Calories: calories; property Fluid: fluid; property Bulk: bulk; + property SpoilRate: spoilrate; flagdef RESEALABLE: ConsumableFlags, 0; flagdef DRINKABLE: ConsumableFlags, 1; flagdef PACKAGED: ConsumableFlags, 2; diff --git a/hunger/module/consumable/consumable_misc.zsc b/hunger/module/consumable/consumable_misc.zsc index 95ed4468..e7330d17 100644 --- a/hunger/module/consumable/consumable_misc.zsc +++ b/hunger/module/consumable/consumable_misc.zsc @@ -42,7 +42,7 @@ extend class UaS_Consumable { } void DoSpoilage() { - // spoilage over time, chances every minute + // spoilage over time, chances every proc // 10% major contamination +5 // 10% minor contamination +2 // 20% basic spoilage +1 @@ -56,7 +56,7 @@ extend class UaS_Consumable { } // additional point possible if already spoiling, even if closed. if (random(0,100) <= weaponstatus[UGCS_SPOILAGE]) { weaponstatus[UGCS_SPOILAGE]++; } - weaponstatus[UGCS_LASTSPOILTIME] += (35*60); + weaponstatus[UGCS_LASTSPOILTIME] += (35*60) / spoilrate; } } diff --git a/hunger/module/hunger_tracker.zsc b/hunger/module/hunger_tracker.zsc index 5ec3c54a..a12a2232 100644 --- a/hunger/module/hunger_tracker.zsc +++ b/hunger/module/hunger_tracker.zsc @@ -83,6 +83,7 @@ class UaS_HungerTracker : Inventory { debugtype.appendformat(" \cesick %i\c- ", sick); } + // Do starvation effects int starving = int((hydro + energy) / 10); if (starving < 0 && UaS_HungerStarvation) { o.fatigue = max(o.fatigue, abs(starving));