Merge pull request #844 from tigercat2000/Ventrcrawl

Ventcrawl Overhaul
This commit is contained in:
ZomgPonies
2015-04-21 17:30:15 -04:00
17 changed files with 222 additions and 226 deletions
+53 -11
View File
@@ -15,26 +15,38 @@ Pipelines + Other Objects -> Pipe network
active_power_usage = 0
power_channel = ENVIRON
var/nodealert = 0
layer = 2.4 //under wires with their 2.44
layer = 2.4 //under wires with their 2.44
var/connect_types[] = list(1) //1=regular, 2=supply, 3=scrubber
var/connected_to = 1 //same as above, currently not used for anything
var/icon_connect_type = "" //"-supply" or "-scrubbers"
var/initialize_directions = 0
var/pipe_color
var/global/datum/pipe_icon_manager/icon_manager
/obj/machinery/atmospherics/Destroy()
for(var/mob/living/M in src) //ventcrawling is serious business
M.remove_ventcrawl()
M.loc = src.loc
..()
// Find a connecting /obj/machinery/atmospherics in specified direction.
/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))
return target
/obj/machinery/atmospherics/New()
if(!icon_manager)
icon_manager = new()
if(!pipe_color)
pipe_color = color
color = null
if(!pipe_color_check(pipe_color))
pipe_color = null
..()
@@ -84,22 +96,22 @@ obj/machinery/atmospherics/proc/check_connect_types_construction(obj/machinery/a
if(list1[i] == list2[j])
var/n = list1[i]
return n
return 0
return 0
/obj/machinery/atmospherics/proc/check_icon_cache(var/safety = 0)
if(!istype(icon_manager))
if(!safety) //to prevent infinite loops
icon_manager = new()
check_icon_cache(1)
return 0
return 1
/obj/machinery/atmospherics/proc/color_cache_name(var/obj/machinery/atmospherics/node)
//Don't use this for standard pipes
if(!istype(node))
return null
return node.pipe_color
/obj/machinery/atmospherics/process()
@@ -134,4 +146,34 @@ obj/machinery/atmospherics/proc/check_connect_types_construction(obj/machinery/a
/obj/machinery/atmospherics/proc/disconnect(obj/machinery/atmospherics/reference)
/obj/machinery/atmospherics/update_icon()
return null
return null
#define VENT_SOUND_DELAY 30
/obj/machinery/atmospherics/relaymove(mob/living/user, direction)
if(!(direction & initialize_directions)) //can't go in a way we aren't connecting to
return
var/obj/machinery/atmospherics/target_move = findConnecting(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())
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(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, ventcrawl_machinery) && target_move.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
@@ -39,7 +39,7 @@
var/radio_filter_out
var/radio_filter_in
connect_types = list(1,2) //connects to regular and supply pipes
/obj/machinery/atmospherics/unary/vent_pump/on
@@ -80,7 +80,7 @@
return
overlays.Cut()
var/vent_icon = "vent"
var/turf/T = get_turf(src)
@@ -89,7 +89,7 @@
if(T.intact && node && node.level == 1 && istype(node, /obj/machinery/atmospherics/pipe))
vent_icon += "h"
if(welded)
vent_icon += "weld"
else if(!powered())
@@ -307,6 +307,9 @@
update_icon()
return
/obj/machinery/atmospherics/unary/vent_pump/can_crawl_through()
return !welded
/obj/machinery/atmospherics/unary/vent_pump/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
@@ -375,16 +378,3 @@
initial_loc.air_vent_names -= id_tag
..()
return
/*
Alt-click to ventcrawl - Monkeys, aliens, slimes and mice.
This is a little buggy but somehow that just seems to plague ventcrawl.
I am sorry, I don't know why.
*/
/obj/machinery/atmospherics/unary/vent_pump/AltClick(var/mob/living/ML)
if(istype(ML))
var/list/ventcrawl_verbs = list(/mob/living/carbon/monkey/verb/ventcrawl, /mob/living/carbon/alien/verb/alien_ventcrawl, /mob/living/carbon/slime/verb/ventcrawl,/mob/living/simple_animal/mouse/verb/ventcrawl)
if(length(ML.verbs & ventcrawl_verbs)) // alien queens have this removed, an istype would be complicated
ML.handle_ventcrawl(src)
return
..()
@@ -23,13 +23,14 @@
var/volume_rate = 120
var/panic = 0 //is this scrubber panicked?
var/welded = 0
var/area_uid
var/radio_filter_out
var/radio_filter_in
connect_types = list(1,3) //connects to regular and scrubber pipes
/obj/machinery/atmospherics/unary/vent_scrubber/New()
icon = null
@@ -50,7 +51,7 @@
return
overlays.Cut()
var/scrubber_icon = "scrubber"
var/turf/T = get_turf(src)
@@ -61,6 +62,8 @@
scrubber_icon += "off"
else
scrubber_icon += "[on ? "[scrubbing ? "on" : "in"]" : "off"]"
if(welded)
scrubber_icon = "scrubberweld"
overlays += icon_manager.get_atmos_icon("device", , , scrubber_icon)
@@ -127,6 +130,8 @@
return
if (!node)
on = 0
if(welded)
return 0
//broadcast_status()
if(!on)
return 0
@@ -151,7 +156,7 @@
removed.oxygen = 0
if(scrub_N2)
filtered_out.nitrogen = removed.nitrogen
removed.nitrogen = 0
removed.nitrogen = 0
if(scrub_Toxins)
filtered_out.toxins = removed.toxins
removed.toxins = 0
@@ -229,7 +234,7 @@
scrubbing = text2num(signal.data["scrubbing"])
if(signal.data["toggle_scrubbing"])
scrubbing = !scrubbing
if(signal.data["o2_scrub"] != null)
scrub_O2 = text2num(signal.data["o2_scrub"])
if(signal.data["toggle_o2_scrub"])
@@ -276,7 +281,30 @@
if(old_stat != stat)
update_icon()
/obj/machinery/atmospherics/unary/vent_scrubber/can_crawl_through()
return !welded
/obj/machinery/atmospherics/unary/vent_scrubber/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob, params)
if(istype(W, /obj/item/weapon/weldingtool))
var/obj/item/weapon/weldingtool/WT = W
if (WT.remove_fuel(0,user))
user << "<span class='notice'>Now welding the scrubber.</span>"
if(do_after(user, 20))
if(!src || !WT.isOn()) return
playsound(get_turf(src), 'sound/items/Welder2.ogg', 50, 1)
if(!welded)
user.visible_message("[user] welds the scrubber shut.", "You weld the vent scrubber.", "You hear welding.")
welded = 1
update_icon()
else
user.visible_message("[user] unwelds the scrubber.", "You unweld the scrubber.", "You hear welding.")
welded = 0
update_icon()
else
user << "<span class='notice'>The welding tool needs to be on to start this task.</span>"
else
user << "<span class='notice'>You need more welding fuel to complete this task.</span>"
return 1
if (!istype(W, /obj/item/weapon/wrench))
return ..()
if (!(stat & NOPOWER) && on)
+37
View File
@@ -0,0 +1,37 @@
var/list/ventcrawl_machinery = list(/obj/machinery/atmospherics/unary/vent_pump, /obj/machinery/atmospherics/unary/vent_scrubber)
/mob/living/carbon/slime/AltClickOn(var/atom/A)
if(is_type_in_list(A,ventcrawl_machinery))
src.ventcrawl(A)
return
..(A)
/mob/living/carbon/monkey/AltClickOn(var/atom/A)
if(is_type_in_list(A,ventcrawl_machinery))
src.ventcrawl(A)
return
..(A)
/mob/living/simple_animal/borer/AltClickOn(var/atom/A)
if(is_type_in_list(A,ventcrawl_machinery))
src.ventcrawl(A)
return
..(A)
/mob/living/simple_animal/mouse/AltClickOn(var/atom/A)
if(is_type_in_list(A,ventcrawl_machinery))
src.ventcrawl(A)
return
..(A)
/mob/living/simple_animal/spiderbot/AltClickOn(var/atom/A)
if(is_type_in_list(A,ventcrawl_machinery))
src.ventcrawl(A)
return
..(A)
/mob/living/carbon/alien/AltClickOn(var/atom/A)
if(is_type_in_list(A,ventcrawl_machinery))
src.ventcrawl(A)
return
..(A)
@@ -47,7 +47,7 @@
real_name = src.name
verbs.Add(/mob/living/carbon/alien/humanoid/proc/corrosive_acid,/mob/living/carbon/alien/humanoid/proc/resin)
verbs -= /mob/living/carbon/alien/verb/alien_ventcrawl
verbs -= /mob/living/carbon/alien/verb/ventcrawl
..()
/mob/living/carbon/alien/humanoid/empress
@@ -24,7 +24,7 @@
real_name = src.name
verbs.Add(/mob/living/carbon/alien/humanoid/proc/corrosive_acid,/mob/living/carbon/alien/humanoid/proc/neurotoxin,/mob/living/carbon/alien/humanoid/proc/resin)
verbs -= /mob/living/carbon/alien/verb/alien_ventcrawl
verbs -= /mob/living/carbon/alien/verb/ventcrawl
..()
@@ -1,5 +1,5 @@
/mob/living/carbon/alien/verb/alien_ventcrawl() // -- TLE
set name = "Crawl through vent (alien)"
/mob/living/carbon/alien/verb/ventcrawl(var/atom/pipe) // -- TLE
set name = "Crawl Through Vent(Alien)"
set desc = "Enter an air vent and crawl through the pipe system."
set category = "Alien"
handle_ventcrawl()
handle_ventcrawl(pipe)
+73 -91
View File
@@ -1,3 +1,6 @@
mob/living
var/canEnterVentWith = "/obj/item/weapon/implant=0&/obj/item/clothing/mask/facehugger=0&/obj/item/device/radio/borg=0&/obj/machinery/camera=0"
/mob/living/carbon/Login()
..()
update_hud()
@@ -256,104 +259,83 @@
/mob/living/carbon/can_use_vents()
return
/mob/living/proc/handle_ventcrawl(var/obj/machinery/atmospherics/unary/vent_pump/vent_found = null, var/ignore_items = 0) // -- TLE -- Merged by Carn
if(stat)
src << "You must be conscious to do this!"
return
if(lying)
src << "You can't vent crawl while you're stunned!"
return
/mob/living/proc/handle_ventcrawl(var/atom/clicked_on) // -- TLE -- Merged by Carn
diary << "[src] is ventcrawling."
if(!stat)
if(!lying)
var/special_fail_msg = can_use_vents()
if(special_fail_msg)
src << "\red [special_fail_msg]"
return
/*
if(clicked_on)
world << "We start with [clicked_on], and [clicked_on.type]"
*/
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.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))
src << "You begin climbing into the ventilation system..."
if(!do_after(src, 45))
return
if(!client)
return
if(contents.len && !isrobot(src))
for(var/obj/item/carried_item in contents)//If the ventcrawler got on objects.
if(!(isInTypes(carried_item, canEnterVentWith)))
src << "<SPAN CLASS='warning'>You can't be carrying items or have items equipped when vent crawling!</SPAN>"
return
visible_message("<B>[src] scrambles into the ventilation ducts!</B>", "You climb into the ventilation system.")
loc = vent_found
add_ventcrawl(vent_found)
else
src << "This vent is not connected to anything."
else
src << "You must be standing on or beside an air vent to enter it."
else
src << "You can't vent crawl while you're stunned!"
if(vent_found) // one was passed in, probably from vent/AltClick()
if(vent_found.welded)
src << "That vent is welded shut."
return
if(!vent_found.Adjacent(src))
return // don't even acknowledge that
else
for(var/obj/machinery/atmospherics/unary/vent_pump/v in range(1,src))
if(!v.welded)
if(v.Adjacent(src))
vent_found = v
if(!vent_found)
src << "You'll need a non-welded vent to crawl into!"
return
src << "You must be conscious to do this!"
return
if(!vent_found.network || !vent_found.network.normal_members.len)
src << "This vent is not connected to anything."
return
/mob/living/proc/add_ventcrawl(obj/machinery/atmospherics/unary/starting_machine)
for(var/datum/pipeline/pipeline in starting_machine.network.line_members)
for(var/atom/A in (pipeline.members || pipeline.edges))
var/image/new_image = image(A, A.loc, dir = A.dir)
pipes_shown += new_image
client.images += new_image
var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in vent_found.network.normal_members)
if(temp_vent.welded)
continue
if(temp_vent in loc)
continue
var/turf/T = get_turf(temp_vent)
/mob/living/proc/remove_ventcrawl()
for(var/image/current_image in pipes_shown)
client.images -= current_image
if(!T || T.z != loc.z)
continue
pipes_shown.len = 0
var/i = 1
var/index = "[T.loc.name]\[[i]\]"
while(index in vents)
i++
index = "[T.loc.name]\[[i]\]"
vents[index] = temp_vent
if(!vents.len)
src << "\red There are no available vents to travel to, they could be welded."
return
var/obj/selection = input("Select a destination.", "Duct System") as null|anything in sortAssoc(vents)
if(!selection) return
if(!vent_found.Adjacent(src))
src << "Never mind, you left."
return
if(!ignore_items)
for(var/obj/item/carried_item in contents)//If the monkey got on objects.
if( !istype(carried_item, /obj/item/weapon/implant) && !istype(carried_item, /obj/item/clothing/mask/facehugger) )//If it's not an implant or a facehugger
src << "\red You can't be carrying items or have items equipped when vent crawling!"
return
if(isslime(src))
var/mob/living/carbon/slime/S = src
if(S.Victim)
src << "\red You'll have to let [S.Victim] go or finish eating \him first."
return
var/obj/machinery/atmospherics/unary/vent_pump/target_vent = vents[selection]
if(!target_vent)
return
for(var/mob/O in viewers(src, null))
O.show_message(text("<B>[src] scrambles into the ventillation ducts!</B>"), 1)
loc = target_vent
var/travel_time = round(get_dist(loc, target_vent.loc) / 2)
spawn(travel_time)
if(!target_vent) return
for(var/mob/O in hearers(target_vent,null))
O.show_message("You hear something squeezing through the ventilation ducts.",2)
sleep(travel_time)
if(!target_vent) return
if(target_vent.welded) //the vent can be welded while alien scrolled through the list or travelled.
target_vent = vent_found //travel back. No additional time required.
src << "\red The vent you were heading to appears to be welded."
loc = target_vent.loc
var/area/new_area = get_area(loc)
if(new_area)
new_area.Entered(src)
if(client)
client.eye = src
/mob/living/carbon/clean_blood()
. = ..()
@@ -104,7 +104,7 @@
adjustBruteLoss(-10)
adjustFireLoss(-10)
adjustCloneLoss(-10)
updatehealth()
if(Victim)
Victim.updatehealth()
@@ -227,9 +227,9 @@
else
src << "<i>I am not old enough to reproduce yet...</i>"
/mob/living/carbon/slime/verb/ventcrawl()
/mob/living/carbon/slime/verb/ventcrawl(var/atom/pipe)
set name = "Crawl through Vent"
set desc = "Enter an air vent and crawl through the pipe system."
set category = "Slime"
if(Victim) return
handle_ventcrawl()
handle_ventcrawl(pipe)
@@ -1,5 +1,5 @@
/mob/living/carbon/monkey/verb/ventcrawl()
/mob/living/carbon/monkey/verb/ventcrawl(var/atom/pipe)
set name = "Crawl through Vent"
set desc = "Enter an air vent and crawl through the pipe system."
set category = "Monkey"
handle_ventcrawl()
handle_ventcrawl(pipe)
@@ -44,3 +44,6 @@
var/silent = null //Can't talk. Value goes down every life proc.
var/floating = 0
var/nightvision = 0
var/list/icon/pipes_shown = list()
var/last_played_vent
@@ -456,11 +456,11 @@ mob/living/simple_animal/borer/proc/detatch()
host_brain.real_name = M.real_name
host.status_flags |= PASSEMOTES
/mob/living/simple_animal/borer/verb/ventcrawl()
/mob/living/simple_animal/borer/verb/ventcrawl(var/atom/pipe)
set name = "Crawl through vent (borer)"
set desc = "Enter an air vent and crawl through the pipe system."
set category = "Alien"
handle_ventcrawl()
handle_ventcrawl(pipe)
/mob/living/simple_animal/borer/can_use_vents()
return
@@ -70,58 +70,11 @@
client.time_died_as_mouse = world.time
//copy paste from alien/larva, if that func is updated please update this one also
/mob/living/simple_animal/mouse/verb/ventcrawl()
/mob/living/simple_animal/mouse/verb/ventcrawl(var/atom/pipe)
set name = "Crawl through Vent"
set desc = "Enter an air vent and crawl through the pipe system."
set category = "Mouse"
// if(!istype(V,/obj/machinery/atmoalter/siphs/fullairsiphon/air_vent))
// return
if(src.stat != CONSCIOUS) return
var/obj/machinery/atmospherics/unary/vent_pump/vent_found
var/welded = 0
for(var/obj/machinery/atmospherics/unary/vent_pump/v in range(1,src))
if(!v.welded)
vent_found = v
break
else
welded = 1
if(vent_found)
if(vent_found.network&&vent_found.network.normal_members.len)
var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in vent_found.network.normal_members)
if(temp_vent.loc == loc)
continue
vents.Add(temp_vent)
var/list/choices = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/vent in vents)
if(vent.loc.z != loc.z)
continue
var/atom/a = get_turf(vent)
choices.Add(a.loc)
var/turf/startloc = loc
var/obj/selection = input("Select a destination.", "Duct System") in choices
var/selection_position = choices.Find(selection)
if(loc==startloc)
var/obj/target_vent = vents[selection_position]
if(target_vent)
/*
for(var/mob/O in oviewers(src, null))
if ((O.client && !( O.blinded )))
O.show_message(text("<B>[src] scrambles into the ventillation ducts!</B>"), 1)
*/
loc = target_vent.loc
else
src << "\blue You need to remain still while entering a vent."
else
src << "\blue This vent is not connected to anything."
else if(welded)
src << "\red That vent is welded."
else
src << "\blue You must be standing on or beside an air vent to enter it."
return
handle_ventcrawl(pipe)
//make mice fit under tables etc? this was hacky, and not working
/*
@@ -140,7 +140,7 @@
for(var/mob/M in viewers(src, null))
if ((M.client && !( M.blinded )))
M.show_message("\red [user] gently taps [src] with the [O]. ")
/mob/living/simple_animal/spiderbot/emag_act(user as mob)
if (emagged)
user << "\red [src] is already overloaded - better run."
@@ -219,51 +219,11 @@
return
//copy paste from alien/larva, if that func is updated please update this one also
/mob/living/simple_animal/spiderbot/verb/ventcrawl()
/mob/living/simple_animal/spiderbot/verb/ventcrawl(var/atom/pipe)
set name = "Crawl through Vent"
set desc = "Enter an air vent and crawl through the pipe system."
set category = "Spiderbot"
// if(!istype(V,/obj/machinery/atmoalter/siphs/fullairsiphon/air_vent))
// return
var/obj/machinery/atmospherics/unary/vent_pump/vent_found
var/welded = 0
for(var/obj/machinery/atmospherics/unary/vent_pump/v in range(1,src))
if(!v.welded)
vent_found = v
break
else
welded = 1
if(vent_found)
if(vent_found.network&&vent_found.network.normal_members.len)
var/list/vents = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/temp_vent in vent_found.network.normal_members)
if(temp_vent.loc == loc)
continue
vents.Add(temp_vent)
var/list/choices = list()
for(var/obj/machinery/atmospherics/unary/vent_pump/vent in vents)
if(vent.loc.z != loc.z)
continue
var/atom/a = get_turf(vent)
choices.Add(a.loc)
var/turf/startloc = loc
var/obj/selection = input("Select a destination.", "Duct System") in choices
var/selection_position = choices.Find(selection)
if(loc==startloc)
var/obj/target_vent = vents[selection_position]
if(target_vent)
loc = target_vent.loc
else
src << "\blue You need to remain still while entering a vent."
else
src << "\blue This vent is not connected to anything."
else if(welded)
src << "\red That vent is welded."
else
src << "\blue You must be standing on or beside an air vent to enter it."
return
handle_ventcrawl(pipe)
//Cannibalized from the parrot mob. ~Zuhayr
/mob/living/simple_animal/spiderbot/verb/drop_held_item()