From 0016494884c5add1d2deefa3f8c91888f95b0c1f Mon Sep 17 00:00:00 2001 From: Sterling Parker Date: Wed, 10 Oct 2018 15:38:31 -0600 Subject: [PATCH] Improved messaging system for messkit. --- modules/hunger/messkit.zsc | 53 +++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/modules/hunger/messkit.zsc b/modules/hunger/messkit.zsc index 9c4eb070..3b090cbd 100644 --- a/modules/hunger/messkit.zsc +++ b/modules/hunger/messkit.zsc @@ -1,4 +1,4 @@ -class UaS_MessKit : HDWoundFixer { +class UaS_MessKit : HDWeapon { UaS_HungerTracker tracker; int biteSize; int mealSize; @@ -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); } @@ -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. @@ -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"); @@ -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"); @@ -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"); @@ -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!"); } } @@ -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); + } }