Skip to content

Commit

Permalink
Improved messaging system for messkit.
Browse files Browse the repository at this point in the history
  • Loading branch information
caligari87 committed Oct 10, 2018
1 parent 985f4ff commit 0016494
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions modules/hunger/messkit.zsc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class UaS_MessKit : HDWoundFixer {
class UaS_MessKit : HDWeapon {
UaS_HungerTracker tracker;
int biteSize;
int mealSize;
Expand Down Expand Up @@ -120,17 +120,17 @@ class UaS_MessKit : HDWoundFixer {
DisplayStatus();
if(!getcvar("hd_helptext")) return;
string message = "\cjMESS KIT\c-\n\n\n";
if(CVar.GetCVar('UaS_HungerAutoselect', invoker.owner.player).GetBool()) { message = message.."Hold Fire to eat and drink.\n\n"; }
if(CVar.GetCVar('UaS_HungerAutoselect', invoker.owner.player).GetBool()) { message = message.."Hold \caFire\cu to eat and drink.\n\n"; }
else {
message = message.."Hold Fire to eat,\n";
message = message.."and AltFire to drink.\n\n";
message = message.."Hold \caFire\cu to eat,\n";
message = message.."and \caAltFire\cu to drink.\n\n";
}
message = message.."Reload opens a new ration.\n\n";
message = message.."AltReload opens a water ration.\n\n";
message = message.."Unload dumps the current ration,\n";
message = message.."\caReload\cu opens a new ration.\n\n";
message = message.."\caAltReload\cu opens a water ration.\n\n";
message = message.."\caUnload\cu dumps the current ration,\n";
message = message.."discarding all remaining contents\n\n\n";
message = message.."Food Rations: "..invoker.owner.countinv("UaS_FoodRation").."\n";
message = message.."Water Rations: "..invoker.owner.countinv("UaS_WaterRation").."\n";
//message = message.."Food Rations: "..invoker.owner.countinv("UaS_FoodRation").."\n";
//message = message.."Water Rations: "..invoker.owner.countinv("UaS_WaterRation").."\n";
A_WeaponMessage(message, 175);
}

Expand All @@ -141,7 +141,7 @@ class UaS_MessKit : HDWoundFixer {

//Check if anything's left at all
if(invoker.mealSize <=0 && invoker.drinkSize <=0) {
A_WeaponMessage("Nothing to eat or drink!\n\nHave you opened a ration?", 175);
TrackerStatusMessage("Nothing to eat or drink!\nHave you opened a ration?");
}

// If CVar set, prioritize depending on which one the player needs more.
Expand All @@ -162,14 +162,14 @@ class UaS_MessKit : HDWoundFixer {
invoker.tracker = UaS_HungerTracker(FindInventory("UaS_HungerTracker", false));
if(type == 1 && invoker.mealSize > 0) {
if(invoker.tracker.calories >= 2500) {
A_WeaponMessage("You're full.\nCouldn't eat another bite.", 175);
TrackerStatusMessage("You're full.\nCouldn't eat another bite.");
return ResolveState("nope");
}
return ResolveState("Scoop");
}
if(type == 2 && invoker.drinkSize > 0) {
if(invoker.tracker.water >= 2500) {
A_WeaponMessage("You're full.\nCouldn't drink another drop.", 175);
TrackerStatusMessage("You're full.\nCouldn't drink another drop.");
return ResolveState("nope");
}
A_PlaySound("misc/smallslop");
Expand Down Expand Up @@ -199,7 +199,7 @@ class UaS_MessKit : HDWoundFixer {
invoker.mealSize -= clamp(chunk, 0, invoker.biteSize);
invoker.tracker.calories += clamp(chunk, 0, invoker.biteSize);
invoker.biteSize -= clamp(chunk, 0, invoker.biteSize);
A_WeaponMessage(string.format("%s\n\n\nFood left: %i\nWater left: %i", invoker.flavor, invoker.mealSize, invoker.drinkSize), 175);
TrackerStatusMessage("Eating...");
return ResolveState(null);
}
return ResolveState("Swallow");
Expand All @@ -213,7 +213,7 @@ class UaS_MessKit : HDWoundFixer {
invoker.sipsize += 1;
invoker.tracker.water += 1;
invoker.drinksize -= 1;
A_WeaponMessage(string.format("%s\n\n\nFood left: %i\nWater left: %i", invoker.flavor, invoker.mealSize, invoker.drinkSize), 175);
TrackerStatusMessage("Drinking...");
if(invoker.drinksize <= 0 || invoker.sipSize > random(25,50) * invoker.speedFactor) {
invoker.sipsize = 0;
return ResolveState("Swallow");
Expand All @@ -230,14 +230,14 @@ class UaS_MessKit : HDWoundFixer {
A_PlaySound("imp/melee");
invoker.mealSize += random(5, 10) * 25;
//invoker.flavor = RandomFlavor();
A_WeaponMessage(string.format("%s\n\n\nFood left: %i\nWater left: %i", invoker.flavor, invoker.mealSize, invoker.drinkSize), 175);
TrackerStatusMessage("Opened Food Ration!");
}
else {
A_WeaponMessage("Your plate is full!", 175);
TrackerStatusMessage("Your plate is full!");
}
}
else {
A_WeaponMessage("You have no more food rations!", 175);
TrackerStatusMessage("You have no more food rations!");
}
}

Expand All @@ -248,25 +248,36 @@ class UaS_MessKit : HDWoundFixer {
invoker.owner.TakeInventory("UaS_WaterRation",1);
A_PlaySound("misc/smallslop");
invoker.drinkSize += random(40, 50) * 5;
A_WeaponMessage(string.format("%s\n\n\nFood left: %i\nWater left: %i", invoker.flavor, invoker.mealSize, invoker.drinkSize), 175);
TrackerStatusMessage();
}
else {
A_WeaponMessage("Your cup is full!", 175);
TrackerStatusMessage("Your cup is full!");
}
}
else {
A_WeaponMessage("You have no more water rations!", 175);
TrackerStatusMessage("You have no more water rations!");
}
}

//Toss opened ration
void UaS_TossOpened(bool force = false) {
if((drinkSize > 0 || mealSize > 0) && force == false) { return; }
if(owner.getcvar("hd_helptext") && (mealsize > 0 || drinkSize > 0)) { A_WeaponMessage("Tossed leftovers. No 5-second rule here.", 175); }
if(owner.getcvar("hd_helptext") && (mealsize > 0 || drinkSize > 0)) { TrackerStatusMessage("Tossed leftovers. No 5-second rule here."); }
biteSize = 0;
mealSize = 0;
drinksize = 0;
sipsize = 0;
flavor = "";
}

action void TrackerStatusMessage(string status = "") {
string message = "\cj"..status.."\n\n";
message = message.."\cc--Plate--\cu\n";
message = message.."\cbFood left: "..invoker.mealSize.."\cu\n";
message = message.."\cnWater left: "..invoker.drinkSize.."\cu\n\n";
message = message.."\cc--Supplies--\cu\n";
message = message.."Food Rations: "..invoker.owner.countinv("UaS_FoodRation").."\n";
message = message.."Water Rations: "..invoker.owner.countinv("UaS_WaterRation").."\n";
A_WeaponMessage(message);
}
}

0 comments on commit 0016494

Please sign in to comment.