From 7a62b0427bd3fbf05b28ba35ef2d14430ea92f9c Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 11 Dec 2022 19:54:12 +0100 Subject: [PATCH] [MIRROR] Fixes Duplicate Integrity Message for Mechas [MDB IGNORE] (#18075) * Fixes Duplicate Integrity Message for Mechas (#71884) This PR is just made to fix duplication of examination texts when you looked on a mecha, for example if something met a certain threshold, it would say "It's heavily damaged" twice when you examined it. This PR just makes a new proc called on examine that's overridden by subtypes. I did it this way because mechas seemed to have their own logic/tiering system to determine how busted it was, and I didn't want to toy with the balance of the calculations should that matter. * Fixes Duplicate Integrity Message for Mechas Co-authored-by: san7890 --- code/modules/vehicles/_vehicle.dm | 17 ++++++++++----- code/modules/vehicles/mecha/_mecha.dm | 30 ++++++++++++++++----------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/code/modules/vehicles/_vehicle.dm b/code/modules/vehicles/_vehicle.dm index 86f92eba0de..874dbe52edd 100644 --- a/code/modules/vehicles/_vehicle.dm +++ b/code/modules/vehicles/_vehicle.dm @@ -58,14 +58,21 @@ . = ..() if(resistance_flags & ON_FIRE) . += span_warning("It's on fire!") - var/healthpercent = atom_integrity/max_integrity * 100 - switch(healthpercent) + . += generate_integrity_message() + +/// Returns a readable string of the vehicle's health for examining. Overridden by subtypes who want to be more verbose with their health messages. +/obj/vehicle/proc/generate_integrity_message() + var/examine_text = "" + var/integrity = atom_integrity/max_integrity * 100 + switch(integrity) if(50 to 99) - . += "It looks slightly damaged." + examine_text = "It looks slightly damaged." if(25 to 50) - . += "It appears heavily damaged." + examine_text = "It appears heavily damaged." if(0 to 25) - . += span_warning("It's falling apart!") + examine_text = span_warning("It's falling apart!") + + return examine_text /obj/vehicle/proc/is_key(obj/item/I) return istype(I, key_type) diff --git a/code/modules/vehicles/mecha/_mecha.dm b/code/modules/vehicles/mecha/_mecha.dm index c239b3c2bd9..5e09cf746cb 100644 --- a/code/modules/vehicles/mecha/_mecha.dm +++ b/code/modules/vehicles/mecha/_mecha.dm @@ -430,18 +430,6 @@ /obj/vehicle/sealed/mecha/examine(mob/user) . = ..() - var/integrity = atom_integrity*100/max_integrity - switch(integrity) - if(85 to 100) - . += "It's fully intact." - if(65 to 85) - . += "It's slightly damaged." - if(45 to 65) - . += "It's badly damaged." - if(25 to 45) - . += "It's heavily damaged." - else - . += "It's falling apart." if(LAZYLEN(flat_equipment)) . += "It's equipped with:" for(var/obj/item/mecha_parts/mecha_equipment/ME as anything in flat_equipment) @@ -461,6 +449,24 @@ . += span_warning("It looks like you can hit the pilot directly if you target the center or above.") break //in case user is holding two guns +/obj/vehicle/sealed/mecha/generate_integrity_message() + var/examine_text = "" + var/integrity = atom_integrity*100/max_integrity + + switch(integrity) + if(85 to 100) + examine_text = "It's fully intact." + if(65 to 85) + examine_text = "It's slightly damaged." + if(45 to 65) + examine_text = "It's badly damaged." + if(25 to 45) + examine_text = "It's heavily damaged." + else + examine_text = "It's falling apart." + + return examine_text + //processing internal damage, temperature, air regulation, alert updates, lights power use. /obj/vehicle/sealed/mecha/process(delta_time) if(internal_damage)