From 174a6f75a5bebfaeeaae01794e9e4d99f365a0c6 Mon Sep 17 00:00:00 2001 From: MistakeNot4892 Date: Tue, 16 Aug 2022 22:09:36 +1000 Subject: [PATCH] Attempting to make bandages work on animals. --- code/__defines/mobs.dm | 1 - code/game/objects/items/stacks/medical.dm | 8 +++- code/modules/mob/living/simple_mob/defense.dm | 44 +++++++++++++------ .../mob/living/simple_mob/harvesting.dm | 39 +++++++++++----- .../mob/living/simple_mob/simple_mob.dm | 2 +- .../simple_mob/subtypes/animal/sif/sif.dm | 2 +- 6 files changed, 67 insertions(+), 29 deletions(-) diff --git a/code/__defines/mobs.dm b/code/__defines/mobs.dm index 589d529bee..b3b8924a17 100644 --- a/code/__defines/mobs.dm +++ b/code/__defines/mobs.dm @@ -348,7 +348,6 @@ // More refined version of SA_* ""intelligence"" seperators. // Now includes bitflags, so to target two classes you just do 'MOB_CLASS_ANIMAL|MOB_CLASS_HUMANOID' #define MOB_CLASS_NONE 0 // Default value, and used to invert for _ALL. - #define MOB_CLASS_PLANT 1 // Unused at the moment. #define MOB_CLASS_ANIMAL 2 // Animals and beasts like spiders, saviks, and bears. #define MOB_CLASS_HUMANOID 4 // Non-robotic humanoids, including /simple_mob and /carbon/humans and their alien variants. diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index fe897ed2b5..6ad8d1bbe0 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -16,6 +16,10 @@ var/upgrade_to // The type path this stack can be upgraded to. /obj/item/stack/medical/attack(mob/living/carbon/M as mob, mob/user as mob) + + if(istype(M, /mob/living/simple_mob)) + return 1 // We handle this in simplemob attackby. + if (!istype(M)) to_chat(user, "\The [src] cannot be applied to [M]!") return 1 @@ -129,7 +133,7 @@ if(used >= available) to_chat(user, "You run out of [src]!") break - + if (W.current_stage <= W.max_bleeding_stage) user.visible_message("\The [user] bandages \a [W.desc] on [M]'s [affecting.name].", \ "You bandage \a [W.desc] on [M]'s [affecting.name]." ) @@ -157,7 +161,7 @@ apply_sounds = list('sound/effects/rip1.ogg','sound/effects/rip2.ogg') drop_sound = 'sound/items/drop/gloves.ogg' pickup_sound = 'sound/items/pickup/gloves.ogg' - + heal_brute = 1 upgrade_to = /obj/item/stack/medical/advanced/bruise_pack /obj/item/stack/medical/bruise_pack/attack(mob/living/carbon/M as mob, mob/user as mob) diff --git a/code/modules/mob/living/simple_mob/defense.dm b/code/modules/mob/living/simple_mob/defense.dm index 2d75ed5faf..792bc3a996 100644 --- a/code/modules/mob/living/simple_mob/defense.dm +++ b/code/modules/mob/living/simple_mob/defense.dm @@ -57,20 +57,36 @@ // When somoene clicks us with an item in hand /mob/living/simple_mob/attackby(var/obj/item/O, var/mob/user) - if(istype(O, /obj/item/stack/medical)) - if(stat != DEAD) - // This could be done better. - var/obj/item/stack/medical/MED = O - if(health < getMaxHealth()) - if(MED.amount >= 1) - adjustBruteLoss(-MED.heal_brute) - MED.amount -= 1 - if(MED.amount <= 0) - qdel(MED) - visible_message("\The [user] applies the [MED] on [src].") - else - var/datum/gender/T = gender_datums[src.get_visible_gender()] - to_chat(user, "\The [src] is dead, medical items won't bring [T.him] back to life.") // the gender lookup is somewhat overkill, but it functions identically to the obsolete gender macros and future-proofs this code + + if(istype(O, /obj/item/stack/medical) && (mob_class & (MOB_CLASS_HUMANOID|MOB_CLASS_ANIMAL))) + + var/datum/gender/T = gender_datums[get_visible_gender()] + if(stat == DEAD) + to_chat(user, SPAN_WARNING("\The [src] is dead, medical items won't bring [T.him] back to life.")) + return + + var/obj/item/stack/medical/MED = O + if(health >= getMaxHealth()) + to_chat(user, SPAN_WARNING("\The [src] does not need medical treatment.")) + return + + if(!((MED.heal_burn && getFireLoss()) || (MED.heal_brute && getBruteLoss()))) + to_chat(user, SPAN_WARNING("\The [MED] does not seem appropriate to treat \the [src].")) + return + + if(MED.get_amount() < 1) + to_chat(user, SPAN_WARNING("You do not have enough of \the [MED] to treat \the [src].")) + return + + if(length(MED.apply_sounds)) + playsound(user, pick(MED.apply_sounds), 25) + + if(do_mob(user, src, 1 SECOND) && MED.get_amount() >= 1 && health < getMaxHealth()) + heal_organ_damage(MED.heal_brute * 5, MED.heal_burn * 5) + visible_message(SPAN_NOTICE("\The [user] applies \the [MED] to \the [src].")) + MED.use(1) + return + if(can_butcher(user, O)) //if the animal can be butchered, do so and return. It's likely to be gibbed. harvest(user, O) return diff --git a/code/modules/mob/living/simple_mob/harvesting.dm b/code/modules/mob/living/simple_mob/harvesting.dm index 0a8f3ee23d..1fb78da09d 100644 --- a/code/modules/mob/living/simple_mob/harvesting.dm +++ b/code/modules/mob/living/simple_mob/harvesting.dm @@ -17,7 +17,7 @@ /mob/living/simple_mob/examine(mob/user) . = ..() - if(user && (get_dist(user, src) <= 3)) + if(user && (isobserver(user) || get_dist(user, src) <= 3)) var/datum/gender/G = gender_datums[get_visible_gender()] if(stat == DEAD) @@ -32,16 +32,35 @@ else . += SPAN_NOTICE("It can be [harvest_verb] now.") - var/percent_health = health / maxHealth - if(percent_health >= 1) - . += SPAN_NOTICE("[G.He] [G.is] uninjured.") - else if(percent_health >= 0.7) - . += SPAN_WARNING("[G.He] [G.is] mildly injured.") - else if(percent_health >= 0.4) - . += SPAN_WARNING("[G.He] [G.is] moderately injured.") - else - . += SPAN_DANGER("[G.He] [G.is] badly injured.") + var/damage_strings = list() + var/percent_brute = getBruteLoss() / getMaxHealth() + if(percent_brute > 0.6) + damage_strings += SPAN_DANGER("maimed bloody") + else if(percent_brute > 0.3) + damage_strings += SPAN_WARNING("cut and bruised") + else if(percent_brute > 0) + damage_strings += "lightly bruised" + var/percent_burn = getFireLoss() / getMaxHealth() + if(percent_burn > 0.6) + damage_strings += SPAN_DANGER("severely burned") + else if(percent_burn > 0.3) + damage_strings += SPAN_WARNING("covered in burns") + else if(percent_burn > 0) + damage_strings += "mildly burned" + + if(!length(damage_strings)) + var/percent_health = health / getMaxHealth() + if(percent_health >= 1) + . += SPAN_NOTICE("uninjured") + else if(percent_health >= 0.7) + . += "mildly injured" + else if(percent_health >= 0.4) + . += SPAN_WARNING("moderately injured") + else + . += SPAN_DANGER("badly injured") + + . += "[G.He] [G.is] [english_list(damage_strings)]." /mob/living/simple_mob/proc/livestock_harvest(var/obj/item/tool, var/mob/living/user) if(!LAZYLEN(harvest_results)) // Might be a unique interaction of an object using the proc to do something weird, or just someone's a donk. diff --git a/code/modules/mob/living/simple_mob/simple_mob.dm b/code/modules/mob/living/simple_mob/simple_mob.dm index fb70e181f8..74ae0ca991 100644 --- a/code/modules/mob/living/simple_mob/simple_mob.dm +++ b/code/modules/mob/living/simple_mob/simple_mob.dm @@ -254,7 +254,7 @@ /mob/living/simple_mob/Stat() ..() if(statpanel("Status") && show_stat_health) - stat(null, "Health: [round((health / getMaxHealth()) * 100)]%") + stat("Health:", "[round((health / getMaxHealth()) * 100)]%") /mob/living/simple_mob/lay_down() ..() diff --git a/code/modules/mob/living/simple_mob/subtypes/animal/sif/sif.dm b/code/modules/mob/living/simple_mob/subtypes/animal/sif/sif.dm index 7b739e465c..7a2da54b5d 100644 --- a/code/modules/mob/living/simple_mob/subtypes/animal/sif/sif.dm +++ b/code/modules/mob/living/simple_mob/subtypes/animal/sif/sif.dm @@ -11,7 +11,7 @@ // Healing threshold for grafadreka healing spit effect. var/sap_heal_threshold = 1 - var/const/scarification_period = 0.15 + var/const/scarification_period = 0.25 /mob/living/simple_mob/animal/sif/Stat() . = ..()