From 691c3ca75fce03eb325a8f3dde3b581e560dc791 Mon Sep 17 00:00:00 2001 From: Kashargul <144968721+Kashargul@users.noreply.github.com> Date: Mon, 29 Jan 2024 00:00:25 +0100 Subject: [PATCH] porting healthbars from RS + mat fixes --- code/datums/observation/stat_set.dm | 9 ++ .../objects/items/weapons/material/shards.dm | 2 +- .../structures/stool_bed_chair_nest/bed.dm | 6 +- .../structures/stool_bed_chair_nest/stools.dm | 6 +- .../preference_setup/global/setting_datums.dm | 6 + .../client/preferences_toggle_procs.dm | 13 ++ .../modules/materials/materials/_materials.dm | 2 +- code/modules/mob/mob.dm | 1 + code/modules/tables/tables.dm | 4 +- code/modules/vore/chat_healthbars.dm | 113 +++++++++++++++++ .../vore/eating/bellymodes_datum_vr.dm | 116 +++++++++++++++++- code/modules/vore/eating/vorepanel_vr.dm | 6 + vorestation.dme | 1 + 13 files changed, 274 insertions(+), 11 deletions(-) create mode 100644 code/modules/vore/chat_healthbars.dm diff --git a/code/datums/observation/stat_set.dm b/code/datums/observation/stat_set.dm index b980d06ecc..6bc6ea45f0 100644 --- a/code/datums/observation/stat_set.dm +++ b/code/datums/observation/stat_set.dm @@ -22,3 +22,12 @@ GLOBAL_DATUM_INIT(stat_set_event, /decl/observ/stat_set, new) . = ..() if(stat != old_stat) GLOB.stat_set_event.raise_event(src, old_stat, new_stat) + + if(isbelly(src.loc)) + var/obj/belly/ourbelly = src.loc + if(!ourbelly.owner.client) + return + if(stat == CONSCIOUS) + to_chat(ourbelly.owner, "\The [src.name] is awake.") + else if(stat == UNCONSCIOUS) + to_chat(ourbelly.owner, "\The [src.name] has fallen unconscious!") diff --git a/code/game/objects/items/weapons/material/shards.dm b/code/game/objects/items/weapons/material/shards.dm index dbae1eead7..5432d46f32 100644 --- a/code/game/objects/items/weapons/material/shards.dm +++ b/code/game/objects/items/weapons/material/shards.dm @@ -50,7 +50,7 @@ if(W.has_tool_quality(TOOL_WELDER) && material.shard_can_repair) var/obj/item/weapon/weldingtool/WT = W.get_welder() if(WT.remove_fuel(0, user)) - material.place_sheet(loc) + material.place_sheet(loc, 1) qdel(src) return return ..() diff --git a/code/game/objects/structures/stool_bed_chair_nest/bed.dm b/code/game/objects/structures/stool_bed_chair_nest/bed.dm index 7a55f5db5b..94a076d8f8 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/bed.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/bed.dm @@ -155,7 +155,7 @@ /obj/structure/bed/proc/remove_padding() if(padding_material) - padding_material.place_sheet(get_turf(src)) + padding_material.place_sheet(get_turf(src), 1) padding_material = null update_icon() @@ -164,9 +164,9 @@ update_icon() /obj/structure/bed/proc/dismantle() - material.place_sheet(get_turf(src)) + material.place_sheet(get_turf(src), 1) if(padding_material) - padding_material.place_sheet(get_turf(src)) + padding_material.place_sheet(get_turf(src), 1) /obj/structure/bed/psych name = "psychiatrist's couch" diff --git a/code/game/objects/structures/stool_bed_chair_nest/stools.dm b/code/game/objects/structures/stool_bed_chair_nest/stools.dm index c22e3d5f1f..7240c4fb21 100644 --- a/code/game/objects/structures/stool_bed_chair_nest/stools.dm +++ b/code/game/objects/structures/stool_bed_chair_nest/stools.dm @@ -67,7 +67,7 @@ var/global/list/stool_cache = list() //haha stool /obj/item/weapon/stool/proc/remove_padding() if(padding_material) - padding_material.place_sheet(get_turf(src)) + padding_material.place_sheet(get_turf(src), 1) padding_material = null update_icon() @@ -104,9 +104,9 @@ var/global/list/stool_cache = list() //haha stool /obj/item/weapon/stool/proc/dismantle() if(material) - material.place_sheet(get_turf(src)) + material.place_sheet(get_turf(src), 1) if(padding_material) - padding_material.place_sheet(get_turf(src)) + padding_material.place_sheet(get_turf(src), 1) qdel(src) /obj/item/weapon/stool/attackby(obj/item/weapon/W as obj, mob/user as mob) diff --git a/code/modules/client/preference_setup/global/setting_datums.dm b/code/modules/client/preference_setup/global/setting_datums.dm index fd1ebc2ebc..437337f326 100644 --- a/code/modules/client/preference_setup/global/setting_datums.dm +++ b/code/modules/client/preference_setup/global/setting_datums.dm @@ -330,6 +330,12 @@ var/list/_client_preferences_by_type enabled_description = "On" disabled_description = "Off" +/datum/client_preference/vore_health_bars + description = "Vore Health Bars" + key = "VORE_HEALTH_BARS" + enabled_description = "Enabled" + disabled_description = "Disabled" + /datum/client_preference/runechat_mob description = "Runechat (Mobs)" key = "RUNECHAT_MOB" diff --git a/code/modules/client/preferences_toggle_procs.dm b/code/modules/client/preferences_toggle_procs.dm index 8ce75698ba..fb5f3d70c5 100644 --- a/code/modules/client/preferences_toggle_procs.dm +++ b/code/modules/client/preferences_toggle_procs.dm @@ -489,6 +489,19 @@ feedback_add_details("admin_verb","TSubtleSounds") +/client/verb/toggle_vore_health_bars() + set name = "Toggle Vore Health Bars" + set category = "Preferences" + set desc = "Toggle the display of vore related health bars" + + var/pref_path = /datum/client_preference/vore_health_bars + toggle_preference(pref_path) + SScharacter_setup.queue_preferences_save(prefs) + + to_chat(src, "Vore related health bars - [(is_preference_enabled(/datum/client_preference/vore_health_bars)) ? "Enabled" : "Disabled"]") + + feedback_add_details("admin_verb","TVoreHealthBars") + // Not attached to a pref datum because those are strict binary toggles /client/verb/toggle_examine_mode() set name = "Toggle Examine Mode" diff --git a/code/modules/materials/materials/_materials.dm b/code/modules/materials/materials/_materials.dm index be14faf62a..4c5bf68af3 100644 --- a/code/modules/materials/materials/_materials.dm +++ b/code/modules/materials/materials/_materials.dm @@ -322,7 +322,7 @@ var/list/name_to_material // General wall debris product placement. // Not particularly necessary aside from snowflakey cult girders. /datum/material/proc/place_dismantled_product(var/turf/target) - place_sheet(target) + place_sheet(target, 1) // Debris product. Used ALL THE TIME. /datum/material/proc/place_sheet(var/turf/target, amount) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index d8e0d5f3be..53a8372f3a 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -693,6 +693,7 @@ stat("Keys Held", keys2text(client.move_keys_held | client.mod_keys_held)) stat("Next Move ADD", dirs2text(client.next_move_dir_add)) stat("Next Move SUB", dirs2text(client.next_move_dir_sub)) + stat("Current size:", size_multiplier * 100) if(statpanel("MC")) stat("Location:", "([x], [y], [z]) [loc]") diff --git a/code/modules/tables/tables.dm b/code/modules/tables/tables.dm index 698feefe2f..2dcbf82290 100644 --- a/code/modules/tables/tables.dm +++ b/code/modules/tables/tables.dm @@ -305,13 +305,13 @@ var/list/table_icon_cache = list() var/obj/item/weapon/material/shard/S = null if(reinforced) if(reinforced.stack_type && (full_return || prob(20))) - reinforced.place_sheet(loc) + reinforced.place_sheet(loc, 1) else S = reinforced.place_shard(loc) if(S) shards += S if(material) if(material.stack_type && (full_return || prob(20))) - material.place_sheet(loc) + material.place_sheet(loc, 1) else S = material.place_shard(loc) if(S) shards += S diff --git a/code/modules/vore/chat_healthbars.dm b/code/modules/vore/chat_healthbars.dm new file mode 100644 index 0000000000..d3af9ea9a3 --- /dev/null +++ b/code/modules/vore/chat_healthbars.dm @@ -0,0 +1,113 @@ +//Health bars in the game window would be pretty challenging and I don't know how to do that, so I thought this would be a good alternative + +/mob/living/proc/chat_healthbar(var/mob/living/reciever, override = FALSE) + if(!reciever) //No one to send it to, don't bother + return + if(!reciever.client) //No one is home, don't bother + return + if(!override) //Did the person push the verb? Ignore the pref + if(!reciever.client.is_preference_enabled(/datum/client_preference/vore_health_bars)) + return + var/ourpercent = 0 + + if(ishuman(src)) //humans don't die or become unconcious at 0%, it's actually like -50% or something, so, let's pretend they have 50 more health than they do + ourpercent = ((health + 50) / (maxHealth + 50)) * 100 + else + ourpercent = (health / maxHealth) * 100 + + var/ourbar = "" + var/obj/belly/ourbelly = src.loc + var/which_var = "Health" + if(ourbelly.digest_mode == "Absorb" || ourbelly.digest_mode == "Drain") + ourpercent = round(((nutrition - 100) / 500) * 100) + which_var = "Nutrition" //It's secretly also a nutrition bar depending on your digest mode + + ourpercent = round(ourpercent) + + switch(ourpercent) //I thought about trying to do this in a more automated way but my brain isn't very large so enjoy my stupid switch statement + if(100) + ourbar = "|▓▓▓▓▓▓▓▓▓▓|" + if(95 to 99) + ourbar = "|▓▓▓▓▓▓▓▓▓▒|" + if(90 to 94) + ourbar = "|▓▓▓▓▓▓▓▓▓░|" + if(85 to 89) + ourbar = "|▓▓▓▓▓▓▓▓▒░|" + if(80 to 84) + ourbar = "|▓▓▓▓▓▓▓▓░░|" + if(75 to 79) + ourbar = "|▓▓▓▓▓▓▓▒░░|" + if(70 to 74) + ourbar = "|▓▓▓▓▓▓▓░░░|" + if(65 to 69) + ourbar = "|▓▓▓▓▓▓▒░░░|" + if(60 to 64) + ourbar = "|▓▓▓▓▓▓░░░░|" + if(55 to 59) + ourbar = "|▓▓▓▓▓▒░░░░|" + if(50 to 54) + ourbar = "|▓▓▓▓▓░░░░░|" + if(45 to 49) + ourbar = "|▓▓▓▓▒░░░░░|" + if(40 to 44) + ourbar = "|▓▓▓▓░░░░░░|" + if(35 to 39) + ourbar = "|▓▓▓▒░░░░░░|" + if(30 to 34) + ourbar = "|▓▓▓░░░░░░░|" + if(25 to 29) + ourbar = "|▓▓▒░░░░░░░|" + if(20 to 24) + ourbar = "|▓▓░░░░░░░░|" + if(15 to 19) + ourbar = "|▓▒░░░░░░░░|" + if(10 to 14) + ourbar = "|▓░░░░░░░░░|" + if(5 to 9) + ourbar = "|▒░░░░░░░░░|" + if(0) + ourbar = "|░░░░░░░░░░|" + else + ourbar = "!░░░░░░░░░░!" + + ourbar = "[ourbar] [which_var] - [src.name]" + + if(stat == UNCONSCIOUS) + ourbar = "[ourbar] - [span_orange("UNCONSCIOUS")]" + else if(stat == DEAD) + ourbar = "[ourbar] - [span_red("DEAD")]" + if(absorbed) + ourbar = span_purple("[ourbar] - ABSORBED") //Absorb is a little funny, I didn't want it to say 'absorbing ABSORBED' so we did it different + else if(ourpercent > 75) + ourbar = span_green("[ourbar] - [ourbelly.digest_mode]ing") + else if(ourpercent > 50) + ourbar = span_yellow("[ourbar] - [ourbelly.digest_mode]ing") + else if(ourpercent > 25) + ourbar = span_orange("[ourbar] - [ourbelly.digest_mode]ing") + else if(ourpercent > 0) + ourbar = span_red("[ourbar] - [ourbelly.digest_mode]ing") + else + ourbar = "[ourbar] - [ourbelly.digest_mode]ing" + + to_chat(reciever,ourbar) + +/mob/living/verb/print_healthbars() + set name = "Print Prey Healthbars" + set category = "Abilities" + + var/nuffin = TRUE + for(var/obj/belly/b in vore_organs) + if(!b.contents.len) + continue + var/belly_announce = FALSE //We only want to announce the belly once + for(var/thing as anything in b.contents) + if(!isliving(thing)) + continue + if(!belly_announce) + to_chat(src, "[b.digest_mode] - Within [b.name]:") //We only want to announce the belly if we found something + belly_announce = TRUE + var/mob/living/ourmob = thing + ourmob.chat_healthbar(src, TRUE) + nuffin = FALSE + if(nuffin) + to_chat(src, "There are no mobs within any of your bellies to print health bars for.") diff --git a/code/modules/vore/eating/bellymodes_datum_vr.dm b/code/modules/vore/eating/bellymodes_datum_vr.dm index b6a39fa96a..876cc5578e 100644 --- a/code/modules/vore/eating/bellymodes_datum_vr.dm +++ b/code/modules/vore/eating/bellymodes_datum_vr.dm @@ -40,6 +40,7 @@ GLOBAL_LIST_INIT(digest_modes, list()) return list("to_update" = TRUE, "soundToPlay" = sound(get_sfx("fancy_death_pred"))) // Deal digestion damage (and feed the pred) + var/old_health = L.health var/old_brute = L.getBruteLoss() var/old_burn = L.getFireLoss() var/old_oxy = L.getOxyLoss() @@ -59,6 +60,9 @@ GLOBAL_LIST_INIT(digest_modes, list()) var/offset = (1 + ((L.weight - 137) / 137)) // 130 pounds = .95 140 pounds = 1.02 var/difference = B.owner.size_multiplier / L.size_multiplier + + consider_healthbar(L, old_health, B.owner) + if(isrobot(B.owner)) var/mob/living/silicon/robot/R = B.owner R.cell.charge += 25 * damage_gain @@ -76,10 +80,15 @@ GLOBAL_LIST_INIT(digest_modes, list()) /datum/digest_mode/absorb/process_mob(obj/belly/B, mob/living/L) if(!L.absorbable || L.absorbed) return null + + var/old_nutrition = L.nutrition B.steal_nutrition(L) if(L.nutrition < 100) B.absorb_living(L) + consider_healthbar(L, old_nutrition, B.owner) return list("to_update" = TRUE) + else + consider_healthbar(L, old_nutrition, B.owner) /datum/digest_mode/unabsorb id = DM_UNABSORB @@ -95,7 +104,9 @@ GLOBAL_LIST_INIT(digest_modes, list()) noise_chance = 10 /datum/digest_mode/drain/process_mob(obj/belly/B, mob/living/L) + var/old_nutrition = L.nutrition B.steal_nutrition(L) + consider_healthbar(L, old_nutrition, B.owner) /datum/digest_mode/drain/shrink id = DM_SHRINK @@ -295,4 +306,107 @@ GLOBAL_LIST_INIT(digest_modes, list()) tempmode = DM_DIGEST // If not absorbable, are they digestible? Then digest. else tempmode = DM_DRAIN // Otherwise drain. - return tempmode \ No newline at end of file + return tempmode + +/datum/digest_mode/proc/consider_healthbar() + return + +/datum/digest_mode/digest/consider_healthbar(mob/living/L, old_health, mob/living/reciever) + + if(old_health <= L.health) + return + + var/old_percent + var/new_percent + + if(ishuman(L)) + old_percent = ((old_health + 50) / (L.maxHealth + 50)) * 100 + new_percent = ((L.health + 50) / (L.maxHealth + 50)) * 100 + else + old_percent = (old_health / L.maxHealth) * 100 + new_percent = (L.health / L.maxHealth) * 100 + + var/lets_announce = FALSE + if(new_percent <= 75 && old_percent > 75) + lets_announce = TRUE + else if(new_percent <= 50 && old_percent > 50) + lets_announce = TRUE + else if(new_percent <= 25 && old_percent > 25) + lets_announce = TRUE + else if(new_percent <= 5 && old_percent > 5) + lets_announce = TRUE + + if(lets_announce) + L.chat_healthbar(reciever) + L.chat_healthbar(L) + +/datum/digest_mode/heal/consider_healthbar(mob/living/L, old_health, mob/living/reciever) + + if(old_health >= L.health) + return + + var/old_percent + var/new_percent + + if(ishuman(L)) + old_percent = ((old_health + 50) / (L.maxHealth + 50)) * 100 + new_percent = ((L.health + 50) / (L.maxHealth + 50)) * 100 + else + old_percent = (old_health / L.maxHealth) * 100 + new_percent = (L.health / L.maxHealth) * 100 + + var/lets_announce = FALSE + if(new_percent >= 75 && old_percent < 75) + lets_announce = TRUE + else if(new_percent >= 50 && old_percent < 50) + lets_announce = TRUE + else if(new_percent >= 25 && old_percent < 25) + lets_announce = TRUE + else if(new_percent >= 5 && old_percent < 5) + lets_announce = TRUE + + if(lets_announce) + L.chat_healthbar(reciever) + L.chat_healthbar(L) + +/datum/digest_mode/absorb/consider_healthbar(mob/living/L, old_nutrition, mob/living/reciever) + if(old_nutrition <= L.nutrition) + return + + var/old_percent = ((old_nutrition - 100) / 500) * 100 + var/new_percent = ((L.nutrition - 100) / 500) * 100 + var/lets_announce = FALSE + if(new_percent <= 75 && old_percent > 75) + lets_announce = TRUE + else if(new_percent <= 50 && old_percent > 50) + lets_announce = TRUE + else if(new_percent <= 25 && old_percent > 25) + lets_announce = TRUE + else if(new_percent <= 0 && old_percent > 0) + lets_announce = TRUE + + if(lets_announce) + L.chat_healthbar(reciever) + L.chat_healthbar(L) + +/datum/digest_mode/drain/consider_healthbar(mob/living/L, old_nutrition, mob/living/reciever) + + if(old_nutrition <= L.nutrition) + return + + var/old_percent = ((old_nutrition - 100) / 500) * 100 + var/new_percent = ((L.nutrition - 100) / 500) * 100 + + var/lets_announce = FALSE + if(new_percent <= 75 && old_percent > 75) + lets_announce = TRUE + else if(new_percent <= 50 && old_percent > 50) + lets_announce = TRUE + else if(new_percent <= 25 && old_percent > 25) + lets_announce = TRUE + else if(new_percent <= 0 && old_percent > 0) + lets_announce = TRUE + + if(lets_announce) + L.chat_healthbar(reciever) + L.chat_healthbar(L) diff --git a/code/modules/vore/eating/vorepanel_vr.dm b/code/modules/vore/eating/vorepanel_vr.dm index a3f6c0ba37..a165060a8e 100644 --- a/code/modules/vore/eating/vorepanel_vr.dm +++ b/code/modules/vore/eating/vorepanel_vr.dm @@ -629,6 +629,9 @@ var/global/list/belly_colorable_only_fullscreens = list("a_synth_flesh_mono", if(!results || !results.len) results = list("You were unable to examine that. Tell a developer!") to_chat(user, jointext(results, "
")) + if(isliving(target)) + var/mob/living/ourtarget = target + ourtarget.chat_healthbar(user) return TRUE if("Use Hand") @@ -739,6 +742,9 @@ var/global/list/belly_colorable_only_fullscreens = list("a_synth_flesh_mono", if(!results || !results.len) results = list("You were unable to examine that. Tell a developer!") to_chat(user, jointext(results, "
")) + if(isliving(target)) + var/mob/living/ourtarget = target + ourtarget.chat_healthbar(user) return TRUE if("Eject") diff --git a/vorestation.dme b/vorestation.dme index cd1351f915..7882ecda0e 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -4113,6 +4113,7 @@ #include "code\modules\virus2\helpers.dm" #include "code\modules\virus2\isolator.dm" #include "code\modules\virus2\items_devices.dm" +#include "code\modules\vore\chat_healthbars.dm" #include "code\modules\vore\hook-defs_vr.dm" #include "code\modules\vore\mouseray.dm" #include "code\modules\vore\trycatch_vr.dm"