Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds various ventcrawl QoL changes #14432

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
54c6d1f
Fixes done
warior4356 Sep 25, 2020
ee3792a
Fixes linter issue
warior4356 Sep 25, 2020
cc70211
Removed delay on exiting vents
warior4356 Sep 25, 2020
24d3d30
Emagged drones can now bypass welded vents
warior4356 Sep 25, 2020
0255b2a
Fixed 1 vs true
warior4356 Sep 25, 2020
a3f0b1a
Misc coding standards
warior4356 Sep 25, 2020
b770285
Span tags
warior4356 Sep 25, 2020
12707f3
reducee drone welding bypass to 10 seconds
warior4356 Sep 25, 2020
d4dc55a
Merge branch 'master' into crawl-tweaks
warior4356 Sep 25, 2020
5f7a725
Readded bug fix post merge conflict
warior4356 Sep 25, 2020
f56168a
Merge branch 'master' into crawl-tweaks
warior4356 Jan 22, 2021
41fcf25
Adding Farie's tweaks
warior4356 Jan 22, 2021
073e751
Makes drone stuff OOP. Lowers overhead on pipe creation and destruction.
warior4356 Jan 22, 2021
af08c70
Adds inline conditionals AA requested
warior4356 Jan 22, 2021
678b62c
Cleans up duplicated code
warior4356 Jan 22, 2021
1e84fbf
Merge branch 'crawl-tweaks' of https://github.com/warior4356/Paradise…
warior4356 Jan 22, 2021
8bbfc52
Removes unneeded check
warior4356 Jan 22, 2021
1eb613d
Makes leaving a pipe put you on the turf rather than loc
warior4356 Jan 22, 2021
9b42afb
removes typing
warior4356 Jan 23, 2021
6ab13ed
Merge branch 'master' into crawl-tweaks
warior4356 Jan 26, 2021
a847bc4
Merge branch 'master' into crawl-tweaks
warior4356 Feb 18, 2021
7bf7db4
Merge branch 'master' into crawl-tweaks
warior4356 Mar 4, 2021
17d5f89
Apply suggestions from code review
warior4356 Mar 9, 2021
7b25c58
Fixes possible null value issue and formatting
warior4356 Mar 9, 2021
5d66d53
Formatting tweak
warior4356 Mar 9, 2021
085095a
Merge branch 'master' into crawl-tweaks
warior4356 Mar 13, 2021
37b1af3
Removes unneeded var
warior4356 Mar 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 38 additions & 13 deletions code/ATMOSPHERICS/atmospherics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Pipelines + Other Objects -> Pipe network
if(!pipe_color_check(pipe_color))
pipe_color = null

update_all_pipe_vision()

/obj/machinery/atmospherics/Initialize()
. = ..()
SSair.atmos_machinery += src
Expand All @@ -61,6 +63,7 @@ Pipelines + Other Objects -> Pipe network
L.remove_ventcrawl()
L.forceMove(get_turf(src))
QDEL_NULL(pipe_image) //we have to qdel it, or it might keep a ref somewhere else
update_all_pipe_vision() // Remove it from the vision of ventcrawlers
return ..()

/obj/machinery/atmospherics/set_frequency(new_frequency)
Expand Down Expand Up @@ -277,35 +280,57 @@ Pipelines + Other Objects -> Pipe network

var/obj/machinery/atmospherics/target_move = findConnecting(direction)
if(target_move)
if(is_type_in_list(target_move, GLOB.ventcrawl_machinery) && target_move.can_crawl_through())
user.remove_ventcrawl()
user.forceMove(target_move.loc) //handles entering and so on
user.visible_message("You hear something squeezing through the ducts.", "You climb out the ventilation system.")
if(is_type_in_list(target_move, GLOB.ventcrawl_machinery))
if(target_move.can_crawl_through())
user.remove_ventcrawl()
user.forceMove(target_move.loc) //handles entering and so on
user.visible_message("<span class='notice'>You hear something squeezing through the ducts.</span>", \
"<span class='notice'>You climb out the ventilation system.</span>")
else if(istype(user, /mob/living/silicon/robot/drone))
to_chat(user, "<span class='notice'>Using specialized micro tools you begin disconnecting the [target_move] from its frame....</span>")
if(do_after(user, 100, target = target_move))
user.remove_ventcrawl()
user.forceMove(target_move.loc) //handles entering and so on
user.visible_message("<span class='boldnotice'>You hear something squeezing through the ducts. With a resounding snap the [target_move] is fastened back in place.</span>", \
"<span class='notice'>You climb out the ventilation system. With a resounding snap the [target_move] is fastened back in place.</span>")
else if(target_move.can_crawl_through())
if(returnPipenet() != target_move.returnPipenet())
user.update_pipe_vision(target_move)
user.loc = target_move
user.client.eye = target_move //if we don't do this, Byond only updates the eye every tick - required for smooth movement
if(returnPipenet() != target_move.returnPipenet())
user.update_pipe_vision()
if(world.time - user.last_played_vent > VENT_SOUND_DELAY)
user.last_played_vent = world.time
playsound(src, 'sound/machines/ventcrawl.ogg', 50, 1, -3)
else
if((direction & initialize_directions) || is_type_in_list(src, GLOB.ventcrawl_machinery)) //if we move in a way the pipe can connect, but doesn't - or we're in a vent
user.remove_ventcrawl()
user.forceMove(src.loc)
user.visible_message("You hear something squeezing through the pipes.", "You climb out the ventilation system.")
user.canmove = 0
if(do_after(user, 30, target = src))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sources tell me target=src may be a problem and may not work well with people in vents

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Target is just for the location of the progress bar and is only visible to the user. It worked fine in testing. Is there any interaction you are concerned about?

user.remove_ventcrawl()
user.forceMove(src.loc)
user.visible_message("<span class='boldnotice'>You hear something squeezing through the pipes.</span>", "<span class='notice'>You climb out the ventilation system.</span>")
else
to_chat(user, "<span class='notice'>You stop climbing out of the ventilation system.</span>")
user.canmove = FALSE
spawn(1)
user.canmove = 1
user.canmove = TRUE

/obj/machinery/atmospherics/AltClick(var/mob/living/L)
if(is_type_in_list(src, GLOB.ventcrawl_machinery))
if(is_type_in_list(src, GLOB.ventcrawl_machinery) || check_open())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is meant to be ||?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because vent crawl machinery is the list of vents, scrubbers, and passive vents. Check open on the other hand is a function that checks if the chosen atmospherics machinery has a potential connection that isn't currently filled, for example, a T junction with an open side.

TLDR: This OR lets you enter open pipes.

L.handle_ventcrawl(src)
return
..()

/obj/machinery/atmospherics/proc/can_crawl_through()
return 1
return TRUE

/obj/machinery/atmospherics/proc/check_open()
for(var/direction in GLOB.cardinal)
if((direction & initialize_directions) && !findConnecting(direction)) // Checks if a pipe can connect in a direction, then returns true if there isn't a pipe connected there
return TRUE
return FALSE

/obj/machinery/atmospherics/proc/update_all_pipe_vision()
for(var/mob/living/M in GLOB.ventcrawlers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can most likely be made typeless

M.update_pipe_vision()

/obj/machinery/atmospherics/proc/change_color(var/new_color)
//only pass valid pipe colors please ~otherwise your pipe will turn invisible
Expand Down
1 change: 1 addition & 0 deletions code/ATMOSPHERICS/components/unary_devices/vent_pump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@
user.visible_message("<span class='notice'>[user] unwelds [src]!</span>",\
"<span class='notice'>You unweld [src]!</span>")
update_icon()
update_all_pipe_vision()


/obj/machinery/atmospherics/unary/vent_pump/attack_hand()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,4 @@
user.visible_message("<span class='notice'>[user] unwelds [src]!</span>",\
"<span class='notice'>You unweld [src]!</span>")
update_icon()
update_all_pipe_vision()
3 changes: 3 additions & 0 deletions code/ATMOSPHERICS/pipes/pipe.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
/obj/machinery/atmospherics/pipe/setPipenet(datum/pipeline/P)
parent = P

/obj/machinery/atmospherics/pipe/returnPipenet()
return parent

/obj/machinery/atmospherics/pipe/color_cache_name(var/obj/machinery/atmospherics/node)
if(istype(node, /obj/machinery/atmospherics/pipe/manifold) || istype(node, /obj/machinery/atmospherics/pipe/manifold4w))
if(pipe_color == node.pipe_color)
Expand Down
65 changes: 38 additions & 27 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,8 @@
dna = newDNA


GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/vent_pump, /obj/machinery/atmospherics/unary/vent_scrubber))
GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/vent_pump, /obj/machinery/atmospherics/unary/vent_scrubber, /obj/machinery/atmospherics/unary/passive_vent))
GLOBAL_LIST_EMPTY(ventcrawlers) // List of all mobs currently ventcrawling for purpose of updating their visual pipes when pipes are changed

/mob/living/handle_ventcrawl(var/atom/clicked_on) // -- TLE -- Merged by Carn
if(!Adjacent(clicked_on))
Expand Down Expand Up @@ -451,26 +452,29 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven
if(!C.check_clothing(src))//return values confuse me right now
return

var/obj/machinery/atmospherics/unary/vent_found
var/obj/machinery/atmospherics/entrance_found = clicked_on

if(clicked_on)
vent_found = clicked_on
if(!istype(vent_found) || !vent_found.can_crawl_through())
vent_found = null
if(!(is_type_in_list(entrance_found, GLOB.ventcrawl_machinery)) && !(istype(entrance_found, /obj/machinery/atmospherics) && entrance_found.check_open()))
entrance_found = null

if(!entrance_found)
to_chat(src, "<span class='warning'>This ventilation duct is not connected to anything!</span>")
return

if(!vent_found)
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("<span class='notice'>[src] begins climbing into the ventilation system...</span>", \
"<span class='notice'>You begin climbing into the ventilation system...</span>")

if(!do_after(src, 45, target = src))
if(entrance_found)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed since it's checked prior

var/datum/pipeline/P = entrance_found.returnPipenet()
if(P && (length(P.members) || P.other_atmosmch))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt this make it so you cant climb into single device pipenets? If so you need to document this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went back and checked, you are still able to climb into single device pipe nets.

if(entrance_found.can_crawl_through())
visible_message("<span class='notice'>[src] begins climbing into the ventilation system...</span>", \
"<span class='notice'>You begin climbing into the ventilation system...</span>")
if(!do_after(src, 45, target = src))
return
else if(istype(src, /mob/living/silicon/robot/drone))
visible_message("<span class='notice'>Using specialized micro tools [src] begins disconnecting the [entrance_found] from its frame...</span>", \
"<span class='notice'>Using specialized micro tools you begin disconnecting the [entrance_found] from its frame....</span>")
if(!do_after(src, 150, target = src))
return
else
return

if(has_buckled_mobs())
Expand Down Expand Up @@ -500,17 +504,19 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven
to_chat(src, "<span class='warning'>You can't crawl around in the ventilation ducts with items!</span>")
return

visible_message("<b>[src] scrambles into the ventilation ducts!</b>", "You climb into the ventilation system.")
src.loc = vent_found
add_ventcrawl(vent_found)

else
to_chat(src, "<span class='warning'>This ventilation duct is not connected to anything!</span>")
if(istype(src, /mob/living/silicon/robot/drone) && !entrance_found.can_crawl_through())
visible_message("<span class='boldnotice'>[src] scrambles into the ventilation ducts! With a resounding snap the [entrance_found] is fastened back in place.</span>", \
"<span class='notice'>You climb into the ventilation system. With a resounding snap the [entrance_found] is fastened back in place.</span>")
else
visible_message("<span class='boldnotice'>[src] scrambles into the ventilation ducts!</span>", "<span class='notice'>You climb into the ventilation system.</span>")
loc = entrance_found
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
loc = entrance_found
forceMove(entrance_found)

Will make sure other logic won't break

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this. It completely breaks ventcrawling, by making all nonpipes solid black sprites.

add_ventcrawl(entrance_found)


/mob/living/proc/add_ventcrawl(obj/machinery/atmospherics/starting_machine)
if(!istype(starting_machine) || !starting_machine.returnPipenet() || !starting_machine.can_see_pipes())
return
GLOB.ventcrawlers.Add(src)
var/datum/pipeline/pipeline = starting_machine.returnPipenet()
var/list/totalMembers = list()
totalMembers |= pipeline.members
Expand All @@ -519,9 +525,11 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven
if(!A.pipe_image)
A.update_pipe_image()
pipes_shown += A.pipe_image
client.images += A.pipe_image
if(client)
client.images += A.pipe_image

/mob/living/proc/remove_ventcrawl()
GLOB.ventcrawlers.Remove(src)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does remove_ventcrawl get called when the mob is destroyed? If not, there might be a null value in the ventcrawlers list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically yes. Update ventcrawl gets called every time a pipenet is updated, which will remove them. I added it to destroy to be sure.

if(client)
for(var/image/current_image in pipes_shown)
client.images -= current_image
Expand All @@ -535,11 +543,14 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven

/mob/living/update_pipe_vision()
if(pipes_shown.len)
if(!is_ventcrawling(src))
remove_ventcrawl()
remove_ventcrawl()
if(is_ventcrawling(src))
add_ventcrawl(loc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this add duplicates to the ventcrawler global since this is also called when a pipe gets destroyed/created?

Copy link
Contributor Author

@warior4356 warior4356 Jan 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't as this check will do the following.
First, check if the mob currently has a pipe overlay, if they do. Delete it. Then if they are still currently in a pipe, regenerate it.
Then if they don't have an overlay, check if they are in a pipe, if they are, give them an overlay. Then just to be sure, if they are not in a pipe at this point, delete an overlay if they have one (This is just a sanity check to cover all four cases and probably unneeded)

The four cases are as follows for a nested if

They have an overlay and are in a pipe. Remove and readd.
They have an overlay and are not in a pipe. Just remove.
They don't have an overlay and are in a pipe. Give them an overlay.
They don't have an overlay and are not in a pipe. Try to remove it just to be sure.

Though, I could force a remove before the add in the case of no overlay and in a pipe, if you want to be sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be slightly more expensive, but would always work. Thoughts on this as a replacement?

/mob/living/update_pipe_vision()
remove_ventcrawl()
if(is_ventcrawling(src))
add_ventcrawl(loc)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All gut here. Overlooked some code it seems back when I commented on it.

else
if(is_ventcrawling(src))
add_ventcrawl(loc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

else
remove_ventcrawl()


//Throwing stuff
Expand Down