Skip to content

Commit

Permalink
Hunger: Add spoilrate for consumables
Browse files Browse the repository at this point in the history
  • Loading branch information
caligari87 committed Aug 18, 2021
1 parent 7239fa4 commit 6451246
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions hunger/module/consumable/consumable.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions hunger/module/consumable/consumable_base.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extend class UaS_Consumable {
int calories;
int fluid;
double bulk, diffbulk;
double spoilrate;
string description;
string opensound;
array<string> OpenText;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions hunger/module/consumable/consumable_misc.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}

Expand Down
1 change: 1 addition & 0 deletions hunger/module/hunger_tracker.zsc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 6451246

Please sign in to comment.