From c41a803b9c70bcbf8d96c50f06f334c00ea2b0df Mon Sep 17 00:00:00 2001
From: DGamerL <108773801+DGamerL@users.noreply.github.com>
Date: Sat, 24 Feb 2024 19:20:55 +0100
Subject: [PATCH] Refactors one ventcrawl proc and fixes a bug (#24215)
* Refactoring and fixing a bug
* GDN review
* Contra review
---
.../atmospherics/machinery/atmospherics.dm | 2 +-
code/modules/mob/living/carbon/carbon.dm | 93 ++++++++++---------
2 files changed, 48 insertions(+), 47 deletions(-)
diff --git a/code/modules/atmospherics/machinery/atmospherics.dm b/code/modules/atmospherics/machinery/atmospherics.dm
index 2ab54354bd1..578ae0eae3c 100644
--- a/code/modules/atmospherics/machinery/atmospherics.dm
+++ b/code/modules/atmospherics/machinery/atmospherics.dm
@@ -342,7 +342,7 @@ Pipelines + Other Objects -> Pipe network
..()
/obj/machinery/atmospherics/proc/can_crawl_through()
- return 1
+ return TRUE
/obj/machinery/atmospherics/proc/change_color(new_color)
//only pass valid pipe colors please ~otherwise your pipe will turn invisible
diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm
index 0bd858d98c5..2acca034a2a 100644
--- a/code/modules/mob/living/carbon/carbon.dm
+++ b/code/modules/mob/living/carbon/carbon.dm
@@ -443,15 +443,15 @@
GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/vent_pump, /obj/machinery/atmospherics/unary/vent_scrubber))
-/mob/living/handle_ventcrawl(atom/clicked_on) // -- TLE -- Merged by Carn
+/mob/living/handle_ventcrawl(atom/clicked_on) // Why is this proc even in carbon.dm ...
if(!Adjacent(clicked_on))
return
- var/ventcrawlerlocal = 0
+ var/ventcrawlerlocal = VENTCRAWLER_NONE
if(ventcrawler)
ventcrawlerlocal = ventcrawler
- if(!ventcrawlerlocal)
+ if(ventcrawlerlocal == VENTCRAWLER_NONE) // You can't ventcrawl.
return
if(stat)
@@ -465,9 +465,11 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven
if(has_buckled_mobs())
to_chat(src, "You can't vent crawl with other creatures on you!")
return
+
if(buckled)
to_chat(src, "You can't vent crawl while buckled!")
return
+
if(ishuman(src))
var/mob/living/carbon/human/H = src
if(H.w_uniform && istype(H.w_uniform, /obj/item/clothing/under/rank/engineering/atmospheric_technician/contortionist))//IMMA SPCHUL SNOWFLAKE
@@ -484,55 +486,54 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven
if(!vent_found)
- for(var/obj/machinery/atmospherics/machine in range(1,src))
+ for(var/obj/machinery/atmospherics/machine in range(1, src))
if(is_type_in_list(machine, GLOB.ventcrawl_machinery) && machine.can_crawl_through())
vent_found = machine
break
- if(vent_found)
- if(vent_found.parent && (vent_found.parent.members.len || vent_found.parent.other_atmosmch))
- visible_message("[src] begins climbing into the ventilation system...", \
- "You begin climbing into the ventilation system...")
-
- if(!do_after(src, 45, target = src))
- return
-
- if(has_buckled_mobs())
- to_chat(src, "You can't vent crawl with other creatures on you!")
- return
-
- if(buckled)
- to_chat(src, "You cannot crawl into a vent while buckled to something!")
- return
-
- if(!client)
- return
-
- if(iscarbon(src) && contents.len && ventcrawlerlocal < 2)//It must have atleast been 1 to get this far
- for(var/obj/item/I in contents)
- var/failed = 0
- if(istype(I, /obj/item/bio_chip))
- continue
- if(istype(I, /obj/item/reagent_containers/patch))
- continue
- if(I.flags & ABSTRACT)
- continue
- else
- failed++
-
- if(failed)
- to_chat(src, "You can't crawl around in the ventilation ducts with items!")
- return
-
- visible_message("[src] scrambles into the ventilation ducts!", "You climb into the ventilation system.")
- var/old_loc = loc
- loc = vent_found
- Moved(old_loc, get_dir(old_loc, loc), FALSE)
- add_ventcrawl(vent_found)
-
- else
+ if(!vent_found)
to_chat(src, "This ventilation duct is not connected to anything!")
+ return
+ if(!vent_found.parent || !(length(vent_found.parent.members) || vent_found.parent.other_atmosmch))
+ return
+
+ visible_message("[src] begins climbing into the ventilation system...", \
+ "You begin climbing into the ventilation system...")
+
+ if(!do_after(src, 4.5 SECONDS, target = src))
+ return
+
+ if(!client)
+ return
+
+ if(!vent_found.can_crawl_through())
+ to_chat(src, "You can't vent crawl through that!")
+ return
+
+ if(has_buckled_mobs())
+ to_chat(src, "You can't vent crawl with other creatures on you!")
+ return
+
+ if(buckled)
+ to_chat(src, "You cannot crawl into a vent while buckled to something!")
+ return
+
+ if(iscarbon(src) && length(contents) && ventcrawlerlocal < VENTCRAWLER_ALWAYS) // If we're here you can only ventcrawl while completely nude
+ for(var/obj/item/I in contents)
+ if(istype(I, /obj/item/bio_chip))
+ continue
+ if(istype(I, /obj/item/reagent_containers/patch))
+ continue
+ if(I.flags & ABSTRACT)
+ continue
+
+ to_chat(src, "You can't crawl around in the ventilation ducts with items!")
+ return
+
+ visible_message("[src] scrambles into the ventilation ducts!", "You climb into the ventilation system.")
+ forceMove(vent_found)
+ add_ventcrawl(vent_found)
/mob/living/proc/add_ventcrawl(obj/machinery/atmospherics/starting_machine, obj/machinery/atmospherics/target_move)
if(!istype(starting_machine) || !starting_machine.returnPipenet(target_move) || !starting_machine.can_see_pipes())