Skip to content

Commit

Permalink
Fixes zombies being able to use huds / zombie code refactor (#5313)
Browse files Browse the repository at this point in the history
# 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 <[email protected]>
  • Loading branch information
Cthulhu80 and Drulikar committed Dec 31, 2023
1 parent 56cfec7 commit 206bc57
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 91 deletions.
172 changes: 94 additions & 78 deletions code/datums/diseases/black_goo.dm
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 0 additions & 2 deletions code/datums/mob_hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 7 additions & 7 deletions code/modules/mob/living/carbon/human/examine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
9 changes: 5 additions & 4 deletions code/modules/mob/living/carbon/human/species/zombie.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,18 @@
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)

return ..()



/datum/species/zombie/post_species_loss(mob/living/carbon/human/zombie)
..()
remove_from_revive(zombie)
Expand Down

0 comments on commit 206bc57

Please sign in to comment.