From 206bc57557110413f590d96846d050b12342f825 Mon Sep 17 00:00:00 2001 From: Cthulhu80 <122310258+Cthulhu80@users.noreply.github.com> Date: Sun, 31 Dec 2023 06:04:06 -0800 Subject: [PATCH] Fixes zombies being able to use huds / zombie code refactor (#5313) # About the pull request Fixes zombies being able to use tech huds, applies to sec, medical and sl huds.Fixes #4309. Also did a little refactoring for some of the zombie code while I was at it. There is also another bug which was found and fixed, basically whenever mobs removed their huds it still displayed the examine text for that hud type. # Explain why it's good for the game my immersion is ruined when I can modify sec records as a zombie. # Changelog :cl: fix: fixes the associated examine text being displayed for different hud types even when removed. balance: slightly increases zombie infection rate in dead mobs refactor: refactored some zombie code. /:cl: --------- Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com> --- code/datums/diseases/black_goo.dm | 172 ++++++++++-------- code/datums/mob_hud.dm | 2 - .../mob/living/carbon/human/examine.dm | 14 +- .../mob/living/carbon/human/species/zombie.dm | 9 +- 4 files changed, 106 insertions(+), 91 deletions(-) diff --git a/code/datums/diseases/black_goo.dm b/code/datums/diseases/black_goo.dm index 7ee83f4def9c..183cdadf17aa 100644 --- a/code/datums/diseases/black_goo.dm +++ b/code/datums/diseases/black_goo.dm @@ -1,4 +1,12 @@ //Disease Datum +#define ZOMBIE_INFECTION_STAGE_ONE 1 +#define ZOMBIE_INFECTION_STAGE_TWO 2 +#define ZOMBIE_INFECTION_STAGE_THREE 3 +#define SLOW_INFECTION_RATE 1 +#define FAST_INFECTION_RATE 7 +#define STAGE_LEVEL_THRESHOLD 360 +#define MESSAGE_COOLDOWN_TIME 1 MINUTES + /datum/disease/black_goo name = "Black Goo" max_stages = 3 @@ -16,117 +24,117 @@ longevity = 500 //the virus tend to die before the dead is turn into zombie this should fix it. stage_prob = 0//no randomness - /// whether we're currently transforming the host into a zombie. - var/zombie_transforming = 0 - /// tells a dead infectee their stage, so they can know when-abouts they'll revive + /// boolean value to determine if the mob is currently transforming into a zombie. + var/zombie_is_transforming = FALSE + + /// variable to keep track of the stage level, used to prevent the stage message from being displayed more than once for any given stage. var/stage_counter = 0 //new variables to handle infection progression inside a stage. - /// variable that contain accumulated virus progression for an host. + /// variable that contains accumulated virus progression for a host. Iterates to a value above 360 and is then reset. var/stage_level = 0 - /// variable that handle passive increase of the virus of an host. - var/infection_rate = 1 - ///the number of stage level needed to pass another stage. - var/stage_level_check = 360 + /// variable that handles passive increase of the virus of a host. + var/infection_rate = SLOW_INFECTION_RATE - /// cooldown between each check to see if we display a symptome idea is to get 60s between symptome atleast. - var/message_cooldown_time = 1 MINUTES + /// cooldown for the living mob's symptom messages COOLDOWN_DECLARE(goo_message_cooldown) /datum/disease/black_goo/stage_act() ..() - if(!ishuman(affected_mob)) return - var/mob/living/carbon/human/H = affected_mob + if(!ishuman_strict(affected_mob)) + return + var/mob/living/carbon/human/infected_mob = affected_mob - // check if your already a zombie or in the process of being transform into one... - if(iszombie(H)) + if(iszombie(infected_mob)) return - // check if dead - if(H.stat == DEAD) - infection_rate = 4 + // infection rate is faster for dead mobs + if(infected_mob.stat == DEAD) + infection_rate = FAST_INFECTION_RATE - // check if he isn't dead - if(H.stat != DEAD) - infection_rate = 1 + // standard infection rate for living mobs + if(infected_mob.stat != DEAD) + infection_rate = SLOW_INFECTION_RATE - // here we add the new infection rate to the stage level. stage_level += infection_rate - // we want to check if we have reach enough stage level to gain a stage 3 stage of 6 min if you get it once. - if(stage_level >= stage_level_check) + // resets the stage_level once it passes the threshold. + if(stage_level >= STAGE_LEVEL_THRESHOLD) stage++ - stage_level -= stage_level_check + stage_level = stage_level % STAGE_LEVEL_THRESHOLD switch(stage) - if(1) - if(H.stat == DEAD && stage_counter != stage) - to_chat(H, SPAN_CENTERBOLD("Your zombie infection is now at stage one! Zombie transformation begins at stage three.")) + if(ZOMBIE_INFECTION_STAGE_ONE) + if(infected_mob.stat == DEAD && stage_counter != stage) + to_chat(infected_mob, SPAN_CENTERBOLD("Your zombie infection is now at stage one! Zombie transformation begins at stage three.")) stage_counter = stage - if (!COOLDOWN_FINISHED(src, goo_message_cooldown)) - return - COOLDOWN_START(src, goo_message_cooldown, message_cooldown_time) - - switch(rand(0, 100)) - if(0 to 25) + // dead mobs should not have symptoms, because... they are dead. + if(infected_mob.stat != DEAD) + if (!COOLDOWN_FINISHED(src, goo_message_cooldown)) return - if(25 to 75) - to_chat(affected_mob, SPAN_DANGER("You feel warm...")) - stage_level += 9 - if(75 to 95) - to_chat(affected_mob, SPAN_DANGER("Your throat is really dry...")) - stage_level += 18 - if(95 to 100) - to_chat(affected_mob, SPAN_DANGER("You can't trust them...")) - stage_level += 36 - - if(2) - if(H.stat == DEAD && stage_counter != stage) - to_chat(H, SPAN_CENTERBOLD("Your zombie infection is now at stage two! Zombie transformation begins at stage three.")) + COOLDOWN_START(src, goo_message_cooldown, MESSAGE_COOLDOWN_TIME) + + switch(rand(0, 100)) + if(0 to 25) + return + if(25 to 75) + to_chat(infected_mob, SPAN_DANGER("You feel warm...")) + stage_level += 9 + if(75 to 95) + to_chat(infected_mob, SPAN_DANGER("Your throat is really dry...")) + stage_level += 18 + if(95 to 100) + to_chat(infected_mob, SPAN_DANGER("You can't trust them...")) + stage_level += 36 + + if(ZOMBIE_INFECTION_STAGE_TWO) + if(infected_mob.stat == DEAD && stage_counter != stage) + to_chat(infected_mob, SPAN_CENTERBOLD("Your zombie infection is now at stage two! Zombie transformation begins at stage three.")) stage_counter = stage - if (!COOLDOWN_FINISHED(src, goo_message_cooldown)) - return - COOLDOWN_START(src, goo_message_cooldown, message_cooldown_time) - - switch(rand(0, 100)) - if(0 to 25) + if(infected_mob.stat != DEAD) + if (!COOLDOWN_FINISHED(src, goo_message_cooldown)) return - if(25 to 50) - to_chat(affected_mob, SPAN_DANGER("You can't trust them...")) - stage_level += 5 - if(50 to 75) - to_chat(affected_mob, SPAN_DANGER("You feel really warm...")) - stage_level += 9 - if(75 to 85) - to_chat(affected_mob, SPAN_DANGER("Your throat is really dry...")) - stage_level += 18 - if(85 to 95) - H.vomit_on_floor() - stage_level += 36 - if(95 to 100) - to_chat(affected_mob, SPAN_DANGER("You cough up some black fluid...")) - stage_level += 42 - - if(3) - //check if your already a zombie just return to avoid weird stuff... if for some weird reason first filter deoesn't work... - if(iszombie(H)) + COOLDOWN_START(src, goo_message_cooldown, MESSAGE_COOLDOWN_TIME) + + switch(rand(0, 100)) + if(0 to 25) + return + if(25 to 50) + to_chat(infected_mob, SPAN_DANGER("You can't trust them...")) + stage_level += 5 + if(50 to 75) + to_chat(infected_mob, SPAN_DANGER("You feel really warm...")) + stage_level += 9 + if(75 to 85) + to_chat(infected_mob, SPAN_DANGER("Your throat is really dry...")) + stage_level += 18 + if(85 to 95) + infected_mob.vomit_on_floor() + stage_level += 36 + if(95 to 100) + to_chat(infected_mob, SPAN_DANGER("You cough up some black fluid...")) + stage_level += 42 + + if(ZOMBIE_INFECTION_STAGE_THREE) + //check if the mob is already a zombie and just return to avoid weird stuff, edge case if zombie_is_transforming deoesn't work. + if(iszombie(infected_mob)) return - if(H.stat == DEAD && stage_counter != stage) - to_chat(H, SPAN_CENTERBOLD("Your zombie infection is now at stage three! Zombie transformation begin!")) + if(infected_mob.stat == DEAD && stage_counter != stage) + to_chat(infected_mob, SPAN_CENTERBOLD("Your zombie infection is now at stage three! Zombie transformation begin!")) stage_counter = stage hidden = list(0,0) - if(!zombie_transforming) - zombie_transform(H) - H.next_move_slowdown = max(H.next_move_slowdown, 2) + if(!zombie_is_transforming) + zombie_transform(infected_mob) + infected_mob.next_move_slowdown = max(infected_mob.next_move_slowdown, 2) /datum/disease/black_goo/proc/zombie_transform(mob/living/carbon/human/human) set waitfor = 0 - zombie_transforming = TRUE + zombie_is_transforming = TRUE human.vomit_on_floor() human.adjust_effect(5, STUN) sleep(20) @@ -143,7 +151,7 @@ human.set_species(SPECIES_ZOMBIE) stage = 3 human.faction = FACTION_ZOMBIE - zombie_transforming = FALSE + zombie_is_transforming = FALSE /obj/item/weapon/zombie_claws @@ -298,3 +306,11 @@ for(var/i=1; i <= storage_slots; i++) new /obj/item/reagent_container/food/drinks/bottle/black_goo(src) return + +#undef ZOMBIE_INFECTION_STAGE_ONE +#undef ZOMBIE_INFECTION_STAGE_TWO +#undef ZOMBIE_INFECTION_STAGE_THREE +#undef STAGE_LEVEL_THRESHOLD +#undef SLOW_INFECTION_RATE +#undef FAST_INFECTION_RATE +#undef MESSAGE_COOLDOWN_TIME diff --git a/code/datums/mob_hud.dm b/code/datums/mob_hud.dm index e4ec3acc1410..778ec2b75a36 100644 --- a/code/datums/mob_hud.dm +++ b/code/datums/mob_hud.dm @@ -33,10 +33,8 @@ GLOBAL_LIST_INIT_TYPED(huds, /datum/mob_hud, list( /datum/mob_hud/proc/remove_hud_from(mob/user, source) if(length(hudusers[user]) && (source in hudusers[user])) hudusers[user] -= source - if(length(hudusers[user])) return FALSE - for(var/mob/target in hudmobs) remove_from_single_hud(user, target) diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm index 62fbd1da09fa..77f33b999924 100644 --- a/code/modules/mob/living/carbon/human/examine.dm +++ b/code/modules/mob/living/carbon/human/examine.dm @@ -528,24 +528,24 @@ if(istype(passed_mob, /mob/living/carbon/human)) var/mob/living/carbon/human/passed_human = passed_mob if (issynth(passed_human)) - return 1 + return TRUE switch(hudtype) if("security") if(skillcheck(passed_human, SKILL_POLICE, SKILL_POLICE_SKILLED)) var/datum/mob_hud/sec_hud = GLOB.huds[MOB_HUD_SECURITY_ADVANCED] - if(locate(passed_mob) in sec_hud.hudusers) + if(sec_hud.hudusers[passed_human]) return TRUE if("medical") if(skillcheck(passed_human, SKILL_MEDICAL, SKILL_MEDICAL_MEDIC)) var/datum/mob_hud/med_hud = GLOB.huds[MOB_HUD_MEDICAL_ADVANCED] - if(locate(passed_mob) in med_hud.hudusers) + if(med_hud.hudusers[passed_human]) return TRUE if("squadleader") var/datum/mob_hud/faction_hud = GLOB.huds[MOB_HUD_FACTION_USCM] - if(passed_human.mind && passed_human.assigned_squad && passed_human.assigned_squad.squad_leader == passed_human && locate(passed_mob) in faction_hud.hudusers) + if(passed_human.mind && passed_human.assigned_squad && passed_human.assigned_squad.squad_leader == passed_human && faction_hud.hudusers[passed_mob]) return TRUE else - return 0 + return FALSE else if(isrobot(passed_mob)) var/mob/living/silicon/robot/R = passed_mob switch(hudtype) @@ -554,6 +554,6 @@ if("medical") return istype(R.module_state_1, /obj/item/robot/sight/hud/med) || istype(R.module_state_2, /obj/item/robot/sight/hud/med) || istype(R.module_state_3, /obj/item/robot/sight/hud/med) else - return 0 + return FALSE else - return 0 + return FALSE diff --git a/code/modules/mob/living/carbon/human/species/zombie.dm b/code/modules/mob/living/carbon/human/species/zombie.dm index 76b1c3928659..f5db0c1b8728 100644 --- a/code/modules/mob/living/carbon/human/species/zombie.dm +++ b/code/modules/mob/living/carbon/human/species/zombie.dm @@ -59,10 +59,10 @@ zombie.equip_to_slot_or_del(new /obj/item/weapon/zombie_claws(zombie), WEAR_L_HAND, TRUE) zombie.equip_to_slot_or_del(new /obj/item/clothing/glasses/zombie_eyes(zombie), WEAR_EYES, TRUE) - var/datum/disease/black_goo/D = locate() in zombie.viruses - if(!D) - D = zombie.AddDisease(new /datum/disease/black_goo()) - D.stage = 5 + var/datum/disease/black_goo/zombie_infection = locate() in zombie.viruses + if(!zombie_infection) + zombie_infection = zombie.AddDisease(new /datum/disease/black_goo()) + zombie_infection.stage = 3 var/datum/mob_hud/Hu = GLOB.huds[MOB_HUD_MEDICAL_OBSERVER] Hu.add_hud_to(zombie, zombie) @@ -70,6 +70,7 @@ return ..() + /datum/species/zombie/post_species_loss(mob/living/carbon/human/zombie) ..() remove_from_revive(zombie)