-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathventcrawling.dm
160 lines (127 loc) · 5.39 KB
/
ventcrawling.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
GLOBAL_LIST_INIT(ventcrawl_machinery, typecacheof(list(
/obj/machinery/atmospherics/components/unary/vent_pump,
/obj/machinery/atmospherics/components/unary/vent_scrubber)))
//VENTCRAWLING
/mob/living/proc/handle_ventcrawl(atom/A)
if(!ventcrawler || !Adjacent(A))
return
if(stat)
to_chat(src, "You must be conscious to do this!")
return
if(IsStun() || IsParalyzed())
to_chat(src, "You can't vent crawl while you're stunned!")
return
if(restrained())
to_chat(src, "You can't vent crawl while you're restrained!")
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 can't vent crawl while buckled!")
return
var/obj/machinery/atmospherics/components/unary/vent_found
if(A)
vent_found = A
if(!istype(vent_found) || !vent_found.can_crawl_through())
vent_found = null
if(!vent_found)
for(var/obj/machinery/atmospherics/machine in range(1,src))
if(is_type_in_typecache(machine, GLOB.ventcrawl_machinery))
vent_found = machine
if(!vent_found.can_crawl_through())
vent_found = null
if(vent_found)
break
if(vent_found)
var/datum/pipeline/vent_found_parent = vent_found.parents[1]
if(vent_found_parent && (vent_found_parent.members.len || vent_found_parent.other_atmos_machines))
visible_message(span_notice("[src] begins climbing into the ventilation system...") ,span_notice("You begin climbing into the ventilation system..."))
if(!do_after(src, 2.5 SECONDS, vent_found))
return
if(!client)
return
if(iscarbon(src) && ventcrawler < 2)//It must have atleast been 1 to get this far
var/failed = 0
var/list/items_list = get_equipped_items(include_pockets = TRUE)
if(items_list.len)
failed = 1
for(var/obj/item/I in held_items)
failed = 1
break
if(failed)
to_chat(src, span_warning("You can't crawl around in the ventilation ducts with items!"))
return
visible_message(span_notice("[src] scrambles into the ventilation ducts!"),span_notice("You climb into the ventilation ducts."))
move_into_vent(vent_found)
else
to_chat(src, span_warning("This ventilation duct is not connected to anything!"))
/mob/living/simple_animal/slime/handle_ventcrawl(atom/A)
if(buckled)
to_chat(src, "<i>I can't vent crawl while feeding...</i>")
return
..()
/**
* Moves living mob directly into the vent as a ventcrawler
*
* Arguments:
* * ventcrawl_target - The vent into which we are moving the mob
*/
/mob/living/proc/move_into_vent(obj/machinery/atmospherics/components/ventcrawl_target)
forceMove(ventcrawl_target)
ADD_TRAIT(src, TRAIT_MOVE_VENTCRAWLING, VENTCRAWLING_TRAIT)
update_pipe_vision()
/mob/living/proc/add_ventcrawl(obj/machinery/atmospherics/starting_machine)
if(!istype(starting_machine) || !starting_machine.can_see_pipes() || isnull(client))
return
var/list/totalMembers = list()
for(var/datum/pipeline/P in starting_machine.return_pipenets())
totalMembers += P.members
totalMembers += P.other_atmos_machines
if(!totalMembers.len)
return
set_sight(SEE_TURFS|BLIND)
// We're gonna color the lighting plane to make it darker while ventcrawling, so things look nicer
// This is a bit hacky but it makes the background darker, which has a nice effect
for(var/atom/movable/screen/plane_master/lighting as anything in hud_used.get_true_plane_masters(LIGHTING_PLANE))
lighting.add_atom_colour("#4d4d4d", TEMPORARY_COLOUR_PRIORITY)
for(var/atom/movable/screen/plane_master/pipecrawl as anything in hud_used.get_true_plane_masters(PIPECRAWL_IMAGES_PLANE))
pipecrawl.unhide_plane(src)
var/obj/machinery/atmospherics/current_location = loc
var/list/our_pipenets = current_location.return_pipenets()
for(var/obj/machinery/atmospherics/pipenet_part as anything in totalMembers)
// If the machinery is not in view or is not meant to be seen, continue
// If the machinery is not part of our net or is not meant to be seen, continue
var/list/thier_pipenets = pipenet_part.return_pipenets()
if(!length(thier_pipenets & our_pipenets))
continue
if(!in_view_range(client.mob, pipenet_part))
continue
if(!pipenet_part.pipe_vision_img)
var/turf/their_turf = get_turf(pipenet_part)
pipenet_part.pipe_vision_img = image(pipenet_part, pipenet_part.loc, dir = pipenet_part.dir)
SET_PLANE(pipenet_part.pipe_vision_img, PIPECRAWL_IMAGES_PLANE, their_turf)
client.images += pipenet_part.pipe_vision_img
pipes_shown += pipenet_part.pipe_vision_img
setMovetype(movement_type | VENTCRAWLING)
/mob/living/proc/remove_ventcrawl()
// Take away all the pipe images if we're not doing anything with em
if(isnull(client) || !HAS_TRAIT(src, TRAIT_MOVE_VENTCRAWLING) || !istype(loc, /obj/machinery/atmospherics) || !(movement_type & VENTCRAWLING))
for(var/image/current_image in pipes_shown)
client.images -= current_image
pipes_shown.len = 0
for(var/atom/movable/screen/plane_master/lighting as anything in hud_used.get_true_plane_masters(LIGHTING_PLANE))
lighting.remove_atom_colour(TEMPORARY_COLOUR_PRIORITY, "#4d4d4d")
for(var/atom/movable/screen/plane_master/pipecrawl as anything in hud_used.get_true_plane_masters(PIPECRAWL_IMAGES_PLANE))
pipecrawl.hide_plane(src)
setMovetype(movement_type & ~VENTCRAWLING)
update_sight()
//OOP
/atom/proc/update_pipe_vision(atom/new_loc = null)
return
/mob/living/update_pipe_vision(atom/new_loc = null)
. = loc
if(new_loc)
. = new_loc
remove_ventcrawl()
add_ventcrawl(.)