Ported ventcrawling from vg.

This commit is contained in:
Zuhayr
2016-08-27 21:46:50 +09:30
committed by Yoshax
parent 34cc19cf1e
commit 18c2f33eab
18 changed files with 344 additions and 160 deletions

View File

@@ -0,0 +1,211 @@
var/list/ventcrawl_machinery = list(
/obj/machinery/atmospherics/unary/vent_pump,
/obj/machinery/atmospherics/unary/vent_scrubber
)
// Vent crawling whitelisted items, whoo
/mob/living/var/list/can_enter_vent_with = list(
/obj/item/weapon/implant,
/obj/item/device/radio/borg,
/obj/item/weapon/holder,
/obj/machinery/camera,
/mob/living/simple_animal/borer,
)
/mob/living/var/list/icon/pipes_shown = list()
/mob/living/var/last_played_vent
/mob/living/var/is_ventcrawling = 0
/mob/var/next_play_vent = 0
/mob/living/proc/can_ventcrawl()
return 0
/mob/living/Login()
. = ..()
//login during ventcrawl
if(is_ventcrawling && istype(loc, /obj/machinery/atmospherics)) //attach us back into the pipes
remove_ventcrawl()
add_ventcrawl(loc)
/mob/living/carbon/slime/can_ventcrawl()
if(Victim)
src << "<span class='warning'>You cannot ventcrawl while feeding.</span>"
return 0
return 1
/mob/living/proc/is_allowed_vent_crawl_item(var/obj/item/carried_item)
if(carried_item == ability_master)
return 1
for(var/type in can_enter_vent_with)
if(istype(carried_item, can_enter_vent_with))
return get_inventory_slot(carried_item) == 0
return 0
/mob/living/carbon/is_allowed_vent_crawl_item(var/obj/item/carried_item)
if(carried_item in internal_organs)
return 1
return ..()
/mob/living/carbon/human/is_allowed_vent_crawl_item(var/obj/item/carried_item)
if(carried_item in organs)
return 1
return ..()
/mob/living/simple_animal/spiderbot/is_allowed_vent_crawl_item(var/obj/item/carried_item)
if(carried_item == held_item)
return 1
return ..()
/mob/living/proc/ventcrawl_carry()
for(var/atom/A in src.contents)
if(!is_allowed_vent_crawl_item(A))
src << "<span class='warning'>You can't be carrying that when vent crawling! - [A.name]</span>"
return 0
return 1
/mob/living/AltClickOn(var/atom/A)
if(is_type_in_list(A,ventcrawl_machinery) && src.can_ventcrawl())
src.handle_ventcrawl(A)
return 1
return ..()
/mob/living/carbon/human/can_ventcrawl()
return issmall(src)
/mob/proc/start_ventcrawl()
var/atom/pipe
var/list/pipes = list()
for(var/obj/machinery/atmospherics/unary/U in range(1))
if(is_type_in_list(U,ventcrawl_machinery) && Adjacent(U))
pipes |= U
if(!pipes || !pipes.len)
to_chat(src, "There are no pipes that you can ventcrawl into within range!")
return
if(pipes.len == 1)
pipe = pipes[1]
else
pipe = input("Crawl Through Vent", "Pick a pipe") as null|anything in pipes
if(canmove && pipe)
return pipe
/mob/living/carbon/slime/can_ventcrawl()
return 1
/mob/living/simple_animal/borer/can_ventcrawl()
return 1
/mob/living/simple_animal/borer/ventcrawl_carry()
return 1
/mob/living/simple_animal/mouse/can_ventcrawl()
return 1
/mob/living/simple_animal/spiderbot/can_ventcrawl()
return 1
/mob/living/carbon/alien/can_ventcrawl()
return 1
/mob/living/carbon/alien/ventcrawl_carry()
return 1
/mob/living/var/ventcrawl_layer = 3
/mob/living/proc/handle_ventcrawl(var/atom/clicked_on)
if(!stat)
if(!lying)
var/obj/machinery/atmospherics/unary/vent_found
if(clicked_on && Adjacent(clicked_on))
vent_found = clicked_on
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_list(machine, ventcrawl_machinery))
vent_found = machine
if(!vent_found || !vent_found.can_crawl_through())
vent_found = null
if(vent_found)
break
if(vent_found)
if(vent_found.network && (vent_found.network.normal_members.len || vent_found.network.line_members.len))
to_chat(src, "You begin climbing into the ventilation system...")
if(vent_found.air_contents && !issilicon(src))
switch(vent_found.air_contents.temperature)
if(0 to BODYTEMP_COLD_DAMAGE_LIMIT)
to_chat(src, "<span class='danger'>You feel a painful freeze coming from the vent!</span>")
if(BODYTEMP_COLD_DAMAGE_LIMIT to T0C)
to_chat(src, "<span class='warning'>You feel an icy chill coming from the vent.</span>")
if(T0C + 40 to BODYTEMP_HEAT_DAMAGE_LIMIT)
to_chat(src, "<span class='warning'>You feel a hot wash coming from the vent.</span>")
if(BODYTEMP_HEAT_DAMAGE_LIMIT to INFINITY)
to_chat(src, "<span class='danger'>You feel a searing heat coming from the vent!</span>")
switch(vent_found.air_contents.return_pressure())
if(0 to HAZARD_LOW_PRESSURE)
to_chat(src, "<span class='danger'>You feel a rushing draw pulling you into the vent!</span>")
if(HAZARD_LOW_PRESSURE to WARNING_LOW_PRESSURE)
to_chat(src, "<span class='warning'>You feel a strong drag pulling you into the vent.</span>")
if(WARNING_HIGH_PRESSURE to HAZARD_HIGH_PRESSURE)
to_chat(src, "<span class='warning'>You feel a strong current pushing you away from the vent.</span>")
if(HAZARD_HIGH_PRESSURE to INFINITY)
to_chat(src, "<span class='danger'>You feel a roaring wind pushing you away from the vent!</span>")
if(!do_after(src, 45, vent_found, 1, 1))
return
if(!client)
return
if(!ventcrawl_carry())
return
visible_message("<B>[src] scrambles into the ventilation ducts!</B>", "You climb into the ventilation system.")
forceMove(vent_found)
add_ventcrawl(vent_found)
else
to_chat(src, "This vent is not connected to anything.")
else
to_chat(src, "You must be standing on or beside an air vent to enter it.")
else
to_chat(src, "You can't vent crawl while you're stunned!")
else
to_chat(src, "You must be conscious to do this!")
return
/mob/living/proc/add_ventcrawl(obj/machinery/atmospherics/starting_machine)
is_ventcrawling = 1
//candrop = 0
var/datum/pipe_network/network = starting_machine.return_network(starting_machine)
if(!network)
return
for(var/datum/pipeline/pipeline in network.line_members)
for(var/obj/machinery/atmospherics/A in (pipeline.members || pipeline.edges))
if(!A.pipe_image)
A.pipe_image = image(A, A.loc, layer = 20, dir = A.dir)
pipes_shown += A.pipe_image
client.images += A.pipe_image
/mob/living/proc/remove_ventcrawl()
is_ventcrawling = 0
//candrop = 1
if(client)
for(var/image/current_image in pipes_shown)
client.images -= current_image
client.eye = src
pipes_shown.len = 0

View File

@@ -0,0 +1,86 @@
/obj/machinery/atmospherics/var/image/pipe_image
/obj/machinery/atmospherics/Destroy()
for(var/mob/living/M in src) //ventcrawling is serious business
M.remove_ventcrawl()
M.forceMove(get_turf(src))
if(pipe_image)
for(var/mob/living/M in player_list)
if(M.client)
M.client.images -= pipe_image
M.pipes_shown -= pipe_image
pipe_image = null
. = ..()
/obj/machinery/atmospherics/ex_act(severity)
for(var/atom/movable/A in src) //ventcrawling is serious business
A.ex_act(severity)
. = ..()
/obj/machinery/atmospherics/Entered(atom/movable/Obj)
if(istype(Obj, /mob/living))
var/mob/living/L = Obj
L.ventcrawl_layer = layer
. = ..()
/obj/machinery/atmospherics/relaymove(mob/living/user, direction)
if(!(direction & initialize_directions)) //can't go in a way we aren't connecting to
return
ventcrawl_to(user,findConnecting(direction, user.ventcrawl_layer),direction)
/obj/machinery/atmospherics/proc/ventcrawl_to(var/mob/living/user, var/obj/machinery/atmospherics/target_move, var/direction)
if(target_move)
if(is_type_in_list(target_move, 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.")
else if(target_move.can_crawl_through())
if(target_move.return_network(target_move) != return_network(src))
user.remove_ventcrawl()
user.add_ventcrawl(target_move)
user.forceMove(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(world.time > user.next_play_vent)
user.next_play_vent = world.time+30
playsound(src, 'sound/machines/ventcrawl.ogg', 50, 1, -3)
else
if((direction & initialize_directions) || is_type_in_list(src, ventcrawl_machinery) && src.can_crawl_through()) //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
spawn(1)
user.canmove = 1
/obj/machinery/atmospherics/proc/can_crawl_through()
return 1
/obj/machinery/atmospherics/proc/findConnecting(var/direction)
for(var/obj/machinery/atmospherics/target in get_step(src,direction))
if(target.initialize_directions & get_dir(target,src))
if(isConnectable(target) && target.isConnectable(src))
return target
/obj/machinery/atmospherics/proc/isConnectable(var/obj/machinery/atmospherics/target)
return (target == node1 || target == node2)
/obj/machinery/atmospherics/pipe/manifold/isConnectable(var/obj/machinery/atmospherics/target)
return (target == node3 || ..())
obj/machinery/atmospherics/trinary/isConnectable(var/obj/machinery/atmospherics/target)
return (target == node3 || ..())
/obj/machinery/atmospherics/pipe/manifold4w/isConnectable(var/obj/machinery/atmospherics/target)
return (target == node3 || target == node4 || ..())
/obj/machinery/atmospherics/tvalve/isConnectable(var/obj/machinery/atmospherics/target)
return (target == node3 || ..())
/obj/machinery/atmospherics/pipe/cap/isConnectable(var/obj/machinery/atmospherics/target)
return (target == node || ..())
/obj/machinery/atmospherics/portables_connector/isConnectable(var/obj/machinery/atmospherics/target)
return (target == node || ..())
/obj/machinery/atmospherics/unary/isConnectable(var/obj/machinery/atmospherics/target)
return (target == node || ..())

View File

@@ -0,0 +1,24 @@
/obj/machinery/atmospherics/pipe/zpipe/up/verb/ventcrawl_move_up()
set name = "Ventcrawl Upwards"
set desc = "Climb up through a pipe."
set category = "Abilities"
set src = usr.loc
var/obj/machinery/atmospherics/target = check_ventcrawl(GetAbove(loc))
if(target) ventcrawl_to(usr, target, UP)
/obj/machinery/atmospherics/pipe/zpipe/down/verb/ventcrawl_move_down()
set name = "Ventcrawl Downwards"
set desc = "Climb down through a pipe."
set category = "Abilities"
set src = usr.loc
var/obj/machinery/atmospherics/target = check_ventcrawl(GetBelow(loc))
if(target) ventcrawl_to(usr, target, DOWN)
/obj/machinery/atmospherics/pipe/zpipe/proc/check_ventcrawl(var/turf/target)
if(!istype(target))
return
if(node1 in target)
return node1
if(node2 in target)
return node2
return

View File

@@ -0,0 +1,9 @@
/mob/living/proc/ventcrawl()
set name = "Crawl through Vent"
set desc = "Enter an air vent and crawl through the pipe system."
set category = "Abilities"
if(incapacitated() || restrained())
return
var/pipe = start_ventcrawl()
if(pipe)
handle_ventcrawl()