diff --git a/medical/module/medical_wound.zsc b/medical/module/medical_wound.zsc index d852eb66..4c794fd8 100644 --- a/medical/module/medical_wound.zsc +++ b/medical/module/medical_wound.zsc @@ -9,6 +9,7 @@ class WoundInfo : thinker { int size; int infection; int pain; + int avgstat; bool clear; override void PostBeginPlay() { @@ -17,6 +18,7 @@ class WoundInfo : thinker { } void TickWound() { + UpdateAverageStatus(); timer = max(timer - 1, 0); pain = max(pain - 1, 0); pain = max(pain - painkiller / 20, 0); @@ -31,7 +33,7 @@ class WoundInfo : thinker { random[uas_wi](0, 15)) / 3; // Wound heals some points - if (toHeal >= AverageStatus()) { + if (toHeal >= avgstat) { if (open > 0) { open--; } if (cavity > 0) { cavity--; } if (dirty > 0) { dirty--; } @@ -40,11 +42,11 @@ class WoundInfo : thinker { } // Infection increases - if (toHeal <= (AverageStatus() + infection)) { + if (toHeal <= (avgstat + infection)) { infection = min(infection + 1, 100); } - if (AverageStatus() == 0) { + if (avgstat == 0) { clear = true; } timer = random[uas_wi](2,5) * (35 + open); @@ -59,78 +61,14 @@ class WoundInfo : thinker { // Status methods extend class WoundInfo { - int AverageStatus() { + void UpdateAverageStatus() { int retvalue, counted; if (dirty >= 0) { retvalue += dirty; counted++; } if (obstructed >= 0) { retvalue += obstructed; counted++;} if (cavity >= 0) { retvalue += cavity; counted++;} if (open >= 0) { retvalue += open; counted++;} //retvalue += infection; - retvalue /= counted; - return retvalue; - } - - string WoundStatus () { - string status; - if (open <= 0) { status = "The wound is "..statuscolor(open).."closed\c-,\nand cannot be treated further.\n"; return status; } - else { status = "The wound is "..statuscolor(open).."open\c-\n"; } - - status = status..numbstatus()..dirtystatus()..obstructstatus()..cavitystatus(); - - return status; - } - - string numbstatus() { - - if (painkiller >= 75) { return "It is "..statuscolor(100-painkiller).."numbed\c-\n"; } - if (painkiller >= 50) { return "It is "..statuscolor(100-painkiller).."mostly numbed\c-\n"; } - if (painkiller >= 25) { return "It is "..statuscolor(100-painkiller).."somewhat numbed\c-\n"; } - return "It is "..statuscolor(100-painkiller).."not numbed.\n"; - } - - string dirtystatus() { - if (dirty < 0) { return ""; } - if (dirty >= 65) { return "It is "..statuscolor(dirty).."filthy\n"; } - if (dirty >= 55) { return "It is "..statuscolor(dirty).."very dirty\n"; } - if (dirty >= 45) { return "It is "..statuscolor(dirty).."somewhat dirty\n"; } - if (dirty >= 35) { return "It is "..statuscolor(dirty).."a bit dirty\n"; } - if (dirty >= 25) { return "It is "..statuscolor(dirty).."almost clean\n"; } - if (dirty >= 15) { return "It is "..statuscolor(dirty).."acceptably clean\n"; } - return "It is "..statuscolor(dirty).."completely clean\n"; - } - - string obstructstatus() { - if (obstructed < 0) { return ""; } - if (obstructed >= 55) { return "There are "..statuscolor(obstructed).."many obstructions\n"; } - if (obstructed >= 45) { return "There are "..statuscolor(obstructed).."several obstructions\n"; } - if (obstructed >= 35) { return "There are "..statuscolor(obstructed).."a few obstructions\n"; } - if (obstructed >= 25) { return "There are "..statuscolor(obstructed).."some obstructions\n"; } - if (obstructed >= 15) { return "It appears "..statuscolor(obstructed).."mostly free of obstructions\n"; } - return "There are "..statuscolor(obstructed).."no apparent obstructions\n"; - } - - string cavitystatus() { - if (cavity < 0) { return ""; } - if (cavity >= 85) { return "There is "..statuscolor(cavity).."severe tissue damage\n"; } - if (cavity >= 65) { return "There is "..statuscolor(cavity).."significant tissue damage\n"; } - if (cavity >= 45) { return "There is "..statuscolor(cavity).."moderate tissue damage\n"; } - if (cavity >= 25) { return "There is "..statuscolor(cavity).."some tissue damage\n"; } - if (cavity >= 15) { return "There is "..statuscolor(cavity).."little tissue damage\n"; } - return "There is "..statuscolor(cavity).."no treatable tissue damage\n"; - } - - string statuscolor(int amount) { - if (amount >= 90) { return "\cm"; } // black - else if (amount >= 80) { return "\cr"; } // dark red - else if (amount >= 70) { return "\ca"; } // brick - else if (amount >= 60) { return "\cx"; } // fire - else if (amount >= 50) { return "\ci"; } // orange - else if (amount >= 40) { return "\ck"; } // yellow - else if (amount >= 30) { return "\cs"; } // dark brown - else if (amount >= 20) { return "\cq"; } // dark green - else if (amount >= 10) { return "\cd"; } // green - else if (amount >= 0) { return "\cd"; } // grey - return "\cj"; // white + avgstat = retvalue / counted; } } diff --git a/medical/module/traumakit/traumakit.zsc b/medical/module/traumakit/traumakit.zsc index 643367f4..e4beeba3 100644 --- a/medical/module/traumakit/traumakit.zsc +++ b/medical/module/traumakit/traumakit.zsc @@ -47,14 +47,10 @@ class UaS_TraumaKit : HDWeapon { override void DoEffect() { if (!(owner.player.readyweapon is 'UaS_TraumaKit')) { return; } - statusMessage = "--- \cyTrauma Kit\c- ---\n"; - - if (patient) { statusMessage = statusmessage.."Treating \cg"..patient.player.getusername().."\n\n"; } - else { statusMessage = statusmessage.."\n\n"; } + statusMessage = ""; // This is used for tools to display stuff SetHelpText(); SetPatient(); - WoundList(); CycleWounds(); CycleTools(); HandleSupplies(); @@ -83,10 +79,219 @@ class UaS_TraumaKit : HDWeapon { break; } - if (currentWound) { statusmessage = statusmessage..currentWound.WoundStatus().."\n"; } - TickMessages(); - A_WeaponMessage(statusMessage); + } + + override void DrawHUDStuff(HDStatusBar sb, HDWeapon hdw, HDPlayerPawn hpl) { + if (!patient) return; + // Floats for precision (also required for centering) + float textHeight = sb.pSmallFont.mFont.GetHeight(); + float padding = 2; + float padStep = textHeight + padding; + float halfStep = padStep / 2; + float baseOffset = (-7 * textHeight) + (-3 * padding); // Start calculating from center of screen? + + // Header + sb.DrawString( + sb.pSmallFont, + "--- \cyTrauma Kit\c- ---", + (0, baseOffset), + sb.DI_SCREEN_CENTER | sb.DI_TEXT_ALIGN_CENTER, + Font.CR_GRAY + ); + sb.DrawString( + sb.pSmallFont, + "Treating \cg" .. patient.player.GetUsername(), + (0, baseOffset + textHeight), + sb.DI_SCREEN_CENTER | sb.DI_TEXT_ALIGN_CENTER, + Font.CR_GRAY + ); + + // Wound List + int woundListOffsetX = -12; + float woundListOffsetY = baseOffset + (3 * textHeight) + (3 * padStep); + + if (wh.critWounds.Size() == 0) { + sb.DrawString( + sb.pSmallFont, + "No treatable wounds", + (0, woundListOffsetY), + sb.DI_SCREEN_CENTER | sb.DI_TEXT_ALIGN_CENTER, + Font.CR_GRAY + ); + } else { + Array wounds; + int idx = (currentWound)? wh.critWounds.Find(currentWound) : 0; + int loopMin = Min(idx - 2, wh.critWounds.Size() - 5); + int loopMax = Max(idx + 2, 4); + + // Compile list + for (int i = loopMin; i <= loopMax; i++) { + if (i < 0 || i > wh.critWounds.Size() - 1) continue; + + string textColor; + bool selected = (currentWound && i == idx); + if (wh.critWounds[i].avgstat >= 15) { + textColor = (selected)? "\ca" : "\cr"; // Red / Dark Red + } else { + textColor = (selected)? "\cd" : "\cq"; // Green / Dark Green + } + + string pointer = (selected)? " <" : ""; + wounds.push(textColor..wh.critWounds[i].description..pointer); + woundListOffsetY -= halfStep; + } + woundListOffsetY += halfStep; // accommodation + + // Top overflow dot + if (loopMin > 0) { + sb.DrawString( + sb.pSmallFont, + ". . .", + (woundListOffsetX, woundListOffsetY - padStep), + sb.DI_SCREEN_CENTER | sb.DI_TEXT_ALIGN_RIGHT, + Font.CR_GRAY + ); + } + + // The actual list + for (int i = 0; i < wounds.Size(); i++) { + sb.DrawString( + sb.pSmallFont, + wounds[i], + (woundListOffsetX, woundListOffsetY), + sb.DI_SCREEN_CENTER | sb.DI_TEXT_ALIGN_RIGHT + ); + + woundListOffsetY += padStep; + } + + // Bottom overflow dot + if (loopMax < wh.critWounds.Size() - 1) { + sb.DrawString( + sb.pSmallFont, + ". . .", + (woundListOffsetX, woundListOffsetY), + sb.DI_SCREEN_CENTER | sb.DI_TEXT_ALIGN_RIGHT, + Font.CR_GRAY + ); + } + } + + // Wound info + int woundInfoOffsetX = 12; + float woundInfoOffsetY = baseOffset + (3 * textHeight) + (3 * padStep); + if (currentWound) { + Array status; + + if (currentWound.open <= 0) { + status.Push("-The wound is "..GetStatusColor(currentWound.open).."closed\c-."); + } + else { + status.Push("-The wound is "..GetStatusColor(currentWound.open).."open"); + + string tmpStr; + + // Painkillers + tmpStr = "not numbed."; + if (currentWound.painkiller >= 75) tmpStr = "numbed"; + else if (currentWound.painkiller >= 50) tmpStr = "mostly numbed"; + else if (currentWound.painkiller >= 25) tmpStr = "somewhat numbed"; + + status.Push("-It is "..GetStatusColor(100 - currentWound.painkiller)..tmpStr); + woundInfoOffsetY -= halfStep; + + // Dirty + if (currentWound.dirty >= 0) { + tmpStr = "completely clean"; + if (currentWound.dirty >= 65) { tmpStr = "filthy"; } + else if (currentWound.dirty >= 55) { tmpStr = "very dirty"; } + else if (currentWound.dirty >= 45) { tmpStr = "somewhat dirty"; } + else if (currentWound.dirty >= 35) { tmpStr = "a bit dirty"; } + else if (currentWound.dirty >= 25) { tmpStr = "almost clean"; } + else if (currentWound.dirty >= 15) { tmpStr = "acceptably clean"; } + + status.Push("-It is "..GetStatusColor(currentWound.dirty)..tmpStr); + woundInfoOffsetY -= halfStep; + } + + // Obstructions + if (currentWound.obstructed >= 0) { + tmpStr = "no apparent obstructions"; + if (currentWound.obstructed >= 55) { tmpStr = "many obstructions"; } + else if (currentWound.obstructed >= 45) { tmpStr = "several obstructions"; } + else if (currentWound.obstructed >= 35) { tmpStr = "a few obstructions"; } + else if (currentWound.obstructed >= 25) { tmpStr = "some obstructions"; } + else if (currentWound.obstructed >= 15) { tmpStr = "very little obstructions"; } + + status.Push("-There are "..GetStatusColor(currentWound.obstructed)..tmpStr); + woundInfoOffsetY -= halfStep; + } + + // Cavity + if (currentWound.cavity >= 0) { + tmpStr = "no treatable tissue damage"; + if (currentWound.cavity >= 85) { tmpStr = "severe tissue damage"; } + else if (currentWound.cavity >= 65) { tmpStr = "significant tissue damage"; } + else if (currentWound.cavity >= 45) { tmpStr = "moderate tissue damage"; } + else if (currentWound.cavity >= 25) { tmpStr = "some tissue damage"; } + else if (currentWound.cavity >= 15) { tmpStr = "little tissue damage"; } + + status.Push("-There is "..GetStatusColor(currentWound.cavity)..tmpStr); + woundInfoOffsetY -= halfStep; + } + } + + for (int i = 0; i < status.Size(); i++) { + sb.DrawString( + sb.pSmallFont, + status[i], + (woundInfoOffsetX, woundInfoOffsetY), + sb.DI_SCREEN_CENTER | sb.DI_TEXT_ALIGN_LEFT, + Font.CR_GRAY + ); + + woundInfoOffsetY += padStep; + } + } else { + sb.DrawString( + sb.pSmallFont, + "-No wounds selected-", + (woundInfoOffsetX, woundInfoOffsetY), + sb.DI_SCREEN_CENTER | sb.DI_TEXT_ALIGN_LEFT, + Font.CR_DARKGRAY + ); + } + + // Tool info + float toolInfoOffset = baseOffset + (4 * textHeight) + (7 * padStep); + Array trueStatusMessage; + statusMessage.Split(trueStatusMessage, "\n"); // it just works + + for (int i = 0; i < trueStatusMessage.Size(); i++) { + sb.DrawString( + sb.pSmallFont, + trueStatusMessage[i], + (0, toolInfoOffset), + sb.DI_SCREEN_CENTER | sb.DI_TEXT_ALIGN_CENTER + ); + + toolInfoOffset += textHeight; + } + } + + ui string GetStatusColor(int amount) { + if (amount >= 90) { return "\cm"; } // Black + if (amount >= 80) { return "\cr"; } // Dark Red + if (amount >= 70) { return "\ca"; } // Brick + if (amount >= 60) { return "\cx"; } // Fire + if (amount >= 50) { return "\ci"; } // Orange + if (amount >= 40) { return "\ck"; } // Yellow + if (amount >= 30) { return "\cs"; } // Dark Brown + if (amount >= 20) { return "\cq"; } // Dark Green + if (amount >= 10) { return "\cd"; } // Green + if (amount >= 0) { return "\cd"; } // Grey (wait, isn't this green?) + return "\cj"; // White } // Somewhat copied from HD, largely rewritten @@ -142,37 +347,6 @@ class UaS_TraumaKit : HDWeapon { } } - void WoundList() { - if (wh.critwounds.size() == 0) { - statusmessage = statusmessage.."No treatable wounds\n\n"; - return; - } - int idx = 0; - if (currentWound) { - idx = wh.critwounds.Find(currentWound); - } - int loopmin = min(idx - 2, wh.critwounds.size() - 5); - int loopmax = max(idx + 2, 4); - if (loopmin > 0) { statusmessage = statusmessage..". . .\n"; } - else { statusmessage = statusmessage.."\n"; } - for (int i = loopmin; i <= loopmax; i++) { - if(i<0 || i > wh.critwounds.size()-1) { continue; } - string hilite; - if (currentWound && i == idx) { - if (currentWound.AverageStatus() >= 15) { hilite = "\ca"; } - else { hilite = "\cd"; } - } - else { - if (wh.critwounds[i].AverageStatus() >= 15) { hilite = "\cr"; } - else { hilite = "\cq"; } - } - statusmessage = statusmessage..hilite..wh.critwounds[i].description.."\n"; - } - if (loopmax < wh.critwounds.size() - 1) { statusmessage = statusmessage..". . .\n"; } - else { statusmessage = statusmessage.."\n"; } - statusmessage = statusmessage.."\n"; - } - void CycleWounds() { if (wh.critwounds.size() == 0) { return; } int idx = 0;