* Cleaned the disposals code a bit (making it uses the defines !)

* Disposals constructs are now stored inside disposals instead of having them deleted and a copy created
* Bins, chutes and outlets will now properly clean any connected trunk on qdel()
* You can no longer change the RPD setting by keeping its window opened
* You can no longer use the RPD as a non-dextrous mob
* Reinforced floors will now be broken by ejected items/mobs, instead of stucking them in the void indefinitely
This commit is contained in:
Menshin
2015-01-19 01:30:58 +01:00
parent 2f66068231
commit b8230e024b
7 changed files with 166 additions and 136 deletions

View File

@@ -26,12 +26,14 @@ Buildable meters
#define DISP_PIPE_STRAIGHT 0
#define DISP_PIPE_BENT 1
#define DISP_JUNCTION 2
#define DISP_YJUNCTION 3
#define DISP_END_TRUNK 4
#define DISP_END_BIN 5
#define DISP_END_OUTLET 6
#define DISP_END_CHUTE 7
#define DISP_SORTJUNCTION 8
#define DISP_JUNCTION_FLIP 3
#define DISP_YJUNCTION 4
#define DISP_END_TRUNK 5
#define DISP_END_BIN 6
#define DISP_END_OUTLET 7
#define DISP_END_CHUTE 8
#define DISP_SORTJUNCTION 9
#define DISP_SORTJUNCTION_FLIP 10
/obj/item/pipe
name = "pipe"

View File

@@ -145,22 +145,20 @@ Nah
return 1
var/dat = {"<b>Disposal Pipes</b><br><br>
<A href='?src=\ref[src];dmake=0'>Pipe</A><BR>
<A href='?src=\ref[src];dmake=1'>Bent Pipe</A><BR>
<A href='?src=\ref[src];dmake=2'>Junction</A><BR>
<A href='?src=\ref[src];dmake=3'>Y-Junction</A><BR>
<A href='?src=\ref[src];dmake=4'>Trunk</A><BR>
<A href='?src=\ref[src];dmake=5'>Bin</A><BR>
<A href='?src=\ref[src];dmake=6'>Outlet</A><BR>
<A href='?src=\ref[src];dmake=7'>Chute</A><BR>
<A href='?src=\ref[src];dmake=8'>Sort Junction</A><BR>
<A href='?src=\ref[src];dmake=[DISP_PIPE_STRAIGHT]'>Pipe</A><BR>
<A href='?src=\ref[src];dmake=[DISP_PIPE_BENT]'>Bent Pipe</A><BR>
<A href='?src=\ref[src];dmake=[DISP_JUNCTION]'>Junction</A><BR>
<A href='?src=\ref[src];dmake=[DISP_YJUNCTION]'>Y-Junction</A><BR>
<A href='?src=\ref[src];dmake=[DISP_END_TRUNK]'>Trunk</A><BR>
<A href='?src=\ref[src];dmake=[DISP_END_BIN]'>Bin</A><BR>
<A href='?src=\ref[src];dmake=[DISP_END_OUTLET]'>Outlet</A><BR>
<A href='?src=\ref[src];dmake=[DISP_END_CHUTE]'>Chute</A><BR>
<A href='?src=\ref[src];dmake=[DISP_SORTJUNCTION]'>Sort Junction</A><BR>
"}
user << browse("<HEAD><TITLE>[src]</TITLE></HEAD><TT>[dat]</TT>", "window=pipedispenser")
return
// 0=straight, 1=bent, 2=junction-j1, 3=junction-j2, 4=junction-y, 5=trunk
/obj/machinery/pipedispenser/disposal/Topic(href, href_list)
if(..())
@@ -170,7 +168,7 @@ Nah
if(href_list["dmake"])
if(!wait)
var/p_type = text2num(href_list["dmake"])
var/obj/structure/disposalconstruct/C = new (src.loc,p_type+1)
var/obj/structure/disposalconstruct/C = new (src.loc,p_type)
if(!C.can_place())
usr << "<span class='warning'>There's not enough room to build that here!</span>"

View File

@@ -48,12 +48,14 @@ var/global/list/disposalpipeID2State=list(
"pipe-s",
"pipe-c",
"pipe-j1",
"pipe-j2",
"pipe-y",
"pipe-t",
"disposal",
"outlet",
"intake",
"pipe-j1s"
"pipe-j1s",
"pipe-j2s"
)
/datum/pipe_info/disposal
@@ -65,7 +67,7 @@ var/global/list/disposalpipeID2State=list(
src.icon_state=disposalpipeID2State[pid+1]
src.dir=2
src.dirtype=dt
if(pid<5 || pid>7)
if(pid<DISP_END_BIN || pid>DISP_END_CHUTE)
icon_state = "con[icon_state]"
/datum/pipe_info/disposal/Render(var/dispenser,var/label)
@@ -400,7 +402,7 @@ var/global/list/RPD_recipes=list(
return
/obj/item/weapon/pipe_dispenser/Topic(href, href_list)
if(usr.stat || usr.restrained())
if(!usr.canUseTopic(src))
usr << browse(null, "window=pipedispenser")
return
usr.set_machine(src)
@@ -459,10 +461,13 @@ var/global/list/RPD_recipes=list(
/obj/item/weapon/pipe_dispenser/afterattack(atom/A, mob/user)
if(!in_range(A,user))
return
if(loc != user)
return
if(!in_range(A,user) || loc != user)
return 0
if(!user.IsAdvancedToolUser())
user << "<span class='notice'>You don't have the dexterity to do this!</span>"
return 0
if(istype(A,/area/shuttle)||istype(A,/turf/space/transit))
return 0
@@ -528,7 +533,7 @@ var/global/list/RPD_recipes=list(
user << "<span class='notice'>Building Pipes...</span>"
playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1)
if(do_after(user, 20))
var/obj/structure/disposalconstruct/C = new (A,p_type+1)
var/obj/structure/disposalconstruct/C = new (A,p_type,p_dir)
if(!C.can_place())
user << "<span class='warning'>There's not enough room to build that here!</span>"
@@ -536,9 +541,6 @@ var/global/list/RPD_recipes=list(
return 0
activate()
// This may still produce runtimes, but I checked and /obj/structure/disposalconstruct
// DOES have a dir property, inherited from /obj/structure. - N3X
C.dir=p_dir
C.add_fingerprint(usr)
C.update()

View File

@@ -86,6 +86,7 @@
icon_state = "engine"
thermal_conductivity = 0.025
heat_capacity = 325000
floor_tile = /obj/item/stack/rods
/turf/simulated/floor/engine/break_tile()
return //unbreakable
@@ -93,7 +94,9 @@
/turf/simulated/floor/engine/burn_tile()
return //unburnable
/turf/simulated/floor/engine/make_plating()
/turf/simulated/floor/engine/make_plating(var/force = 0)
if(force)
..()
return //unplateable
/turf/simulated/floor/engine/attackby(obj/item/weapon/C as obj, mob/user as mob)

View File

@@ -12,17 +12,17 @@
pressure_resistance = 5*ONE_ATMOSPHERE
level = 2
var/ptype = 0
// 0=straight, 1=bent, 2=junction-j1, 3=junction-j2, 4=junction-y, 5=trunk, 6=disposal bin, 7=outlet, 8=inlet
var/dpdir = 0 // directions as disposalpipe
var/base_state = "pipe-s"
/obj/structure/disposalconstruct/New(var/loc, var/pipe_type)
/obj/structure/disposalconstruct/New(var/loc, var/pipe_type, var/direction = 1)
..(loc)
if(pipe_type)
ptype = pipe_type
if(!is_pipe()) // bins/chutes/outlets are dense
density = 1
dir = direction
// update iconstate and dpdir due to dir and type
/obj/structure/disposalconstruct/proc/update()
@@ -31,44 +31,44 @@
var/right = turn(dir, -90)
switch(ptype)
if(0)
if(DISP_PIPE_STRAIGHT)
base_state = "pipe-s"
dpdir = dir | flip
if(1)
if(DISP_PIPE_BENT)
base_state = "pipe-c"
dpdir = dir | right
if(2)
if(DISP_JUNCTION)
base_state = "pipe-j1"
dpdir = dir | right | flip
if(3)
if(DISP_JUNCTION_FLIP)
base_state = "pipe-j2"
dpdir = dir | left | flip
if(4)
if(DISP_YJUNCTION)
base_state = "pipe-y"
dpdir = dir | left | right
if(5)
if(DISP_END_TRUNK)
base_state = "pipe-t"
dpdir = dir
// disposal bin has only one dir, thus we don't need to care about setting it
if(6)
if(DISP_END_BIN)
if(anchored)
base_state = "disposal"
else
base_state = "condisposal"
if(7)
if(DISP_END_OUTLET)
base_state = "outlet"
dpdir = dir
if(8)
if(DISP_END_CHUTE)
base_state = "intake"
dpdir = dir
if(9)
if(DISP_SORTJUNCTION)
base_state = "pipe-j1s"
dpdir = dir | right | flip
if(10)
if(DISP_SORTJUNCTION_FLIP)
base_state = "pipe-j2s"
dpdir = dir | left | flip
@@ -117,33 +117,33 @@
dir = turn(dir, 180)
switch(ptype)
if(2)
ptype = 3
if(3)
ptype = 2
if(9)
ptype = 10
if(10)
ptype = 9
if(DISP_JUNCTION)
ptype = DISP_JUNCTION_FLIP
if(DISP_JUNCTION_FLIP)
ptype = DISP_JUNCTION
if(DISP_SORTJUNCTION)
ptype = DISP_SORTJUNCTION_FLIP
if(DISP_SORTJUNCTION_FLIP)
ptype = DISP_SORTJUNCTION
update()
// returns the type path of disposalpipe corresponding to this item dtype
/obj/structure/disposalconstruct/proc/dpipetype()
switch(ptype)
if(0,1)
if(DISP_PIPE_STRAIGHT,DISP_PIPE_BENT)
return /obj/structure/disposalpipe/segment
if(2,3,4)
if(DISP_JUNCTION, DISP_JUNCTION_FLIP, DISP_YJUNCTION)
return /obj/structure/disposalpipe/junction
if(5)
if(DISP_END_TRUNK)
return /obj/structure/disposalpipe/trunk
if(6)
if(DISP_END_BIN)
return /obj/machinery/disposal
if(7)
if(DISP_END_OUTLET)
return /obj/structure/disposaloutlet
if(8)
if(DISP_END_CHUTE)
return /obj/machinery/disposal/deliveryChute
if(9,10)
if(DISP_SORTJUNCTION, DISP_SORTJUNCTION_FLIP)
return /obj/structure/disposalpipe/sortjunction
return
@@ -156,20 +156,20 @@
/obj/structure/disposalconstruct/attackby(var/obj/item/I, var/mob/user)
var/nicetype = "pipe"
var/ispipe = is_pipe() // Indicates if we should change the level of this pipe
src.add_fingerprint(user)
add_fingerprint(user)
switch(ptype)
if(6)
if(DISP_END_BIN)
nicetype = "disposal bin"
if(7)
if(DISP_END_OUTLET)
nicetype = "disposal outlet"
if(8)
if(DISP_END_CHUTE)
nicetype = "delivery chute"
if(9, 10)
if(DISP_SORTJUNCTION, DISP_SORTJUNCTION_FLIP)
nicetype = "sorting pipe"
else
nicetype = "pipe"
var/turf/T = src.loc
var/turf/T = loc
if(T.intact)
user << "You can only attach the [nicetype] if the floor plating is removed."
return
@@ -210,62 +210,51 @@
else
density = 1 // We don't want disposal bins or outlets to go density 0
user << "You attach the [nicetype] to the underfloor."
playsound(src.loc, 'sound/items/Ratchet.ogg', 100, 1)
playsound(loc, 'sound/items/Ratchet.ogg', 100, 1)
update()
else if(istype(I, /obj/item/weapon/weldingtool))
if(anchored)
var/obj/item/weapon/weldingtool/W = I
if(W.remove_fuel(0,user))
playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1)
playsound(loc, 'sound/items/Welder2.ogg', 100, 1)
user << "Welding the [nicetype] in place."
if(do_after(user, 20))
if(!src.loc || !W.isOn())
if(!loc || !W.isOn())
return
user << "The [nicetype] has been welded in place!"
update() // TODO: Make this neat
if(ispipe) // Pipe
if(ispipe)
var/pipetype = dpipetype()
var/obj/structure/disposalpipe/P = new pipetype(src.loc)
src.transfer_fingerprints_to(P)
P.base_icon_state = base_state
P.dir = dir
P.dpdir = dpdir
var/obj/structure/disposalpipe/P = new pipetype(loc, src)
P.updateicon()
transfer_fingerprints_to(P)
//Needs some special treatment ;)
if(ptype==9 || ptype==10)
if(ptype == DISP_SORTJUNCTION || ptype == DISP_SORTJUNCTION_FLIP)
var/obj/structure/disposalpipe/sortjunction/SortP = P
SortP.updatedir()
else if(ptype==6) // Disposal bin
var/obj/machinery/disposal/P = new /obj/machinery/disposal(src.loc)
src.transfer_fingerprints_to(P)
else if(ptype == DISP_END_BIN)
var/obj/machinery/disposal/P = new /obj/machinery/disposal(loc,src)
P.mode = 0 // start with pump off
transfer_fingerprints_to(P)
else if(ptype==7) // Disposal outlet
else if(ptype == DISP_END_OUTLET)
var/obj/structure/disposaloutlet/P = new /obj/structure/disposaloutlet(loc,src)
transfer_fingerprints_to(P)
var/obj/structure/disposaloutlet/P = new /obj/structure/disposaloutlet(src.loc)
src.transfer_fingerprints_to(P)
P.dir = dir
var/obj/structure/disposalpipe/trunk/Trunk = CP
Trunk.linked = P
else if(ptype == DISP_END_CHUTE)
var/obj/machinery/disposal/deliveryChute/P = new /obj/machinery/disposal/deliveryChute(loc,src)
transfer_fingerprints_to(P)
else if(ptype==8) // Disposal chute
var/obj/machinery/disposal/deliveryChute/P = new /obj/machinery/disposal/deliveryChute(src.loc)
src.transfer_fingerprints_to(P)
P.dir = dir
qdel(src)
return
else
user << "You need to attach it to the plating first!"
return
/obj/structure/disposalconstruct/proc/is_pipe()
return !(ptype >=6 && ptype <= 8)
return !(ptype >=DISP_END_BIN && ptype <= DISP_END_CHUTE)
//helper proc that makes sure you can place the construct (i.e no dense objects stacking)
/obj/structure/disposalconstruct/proc/can_place()

View File

@@ -25,9 +25,16 @@
var/obj/structure/disposalconstruct/stored
// create a new disposal
// find the attached trunk (if present) and init gas resvr.
/obj/machinery/disposal/New()
/obj/machinery/disposal/New(loc, var/obj/structure/disposalconstruct/make_from)
..()
stored = new /obj/structure/disposalconstruct(0,6) // 6 = disposal unit
if(make_from)
dir = make_from.dir
make_from.loc = 0
stored = make_from
else
stored = new /obj/structure/disposalconstruct(0,DISP_END_BIN,dir)
trunk_check()
air_contents = new/datum/gas_mixture()
@@ -46,6 +53,8 @@
/obj/machinery/disposal/Destroy()
eject()
if(trunk)
trunk.linked = null
..()
/obj/machinery/disposal/singularity_pull(S, current_size)
@@ -348,8 +357,7 @@
src.updateDialog()
if(flush && air_contents.return_pressure() >= SEND_PRESSURE ) // flush can happen even without power
spawn(0)
flush()
flush()
if(stat & NOPOWER) // won't charge if no power
return
@@ -619,27 +627,35 @@
var/obj/structure/disposalconstruct/stored
// new pipe, set the icon_state as on map
/obj/structure/disposalpipe/New()
/obj/structure/disposalpipe/New(loc,var/obj/structure/disposalconstruct/make_from)
..()
base_icon_state = icon_state
stored = new /obj/structure/disposalconstruct(src)
switch(base_icon_state)
if("pipe-s")
stored.ptype = 0
if("pipe-c")
stored.ptype = 1
if("pipe-j1")
stored.ptype = 2
if("pipe-j2")
stored.ptype = 3
if("pipe-y")
stored.ptype = 4
if("pipe-t")
stored.ptype = 5
if("pipe-j1s")
stored.ptype = 9
if("pipe-j2s")
stored.ptype = 10
if(make_from && !make_from.gc_destroyed)
base_icon_state = make_from.base_state
dir = make_from.dir
dpdir = make_from.dpdir
make_from.loc = src
stored = make_from
else
base_icon_state = icon_state
stored = new /obj/structure/disposalconstruct(src,direction=dir)
switch(base_icon_state)
if("pipe-s")
stored.ptype = DISP_PIPE_STRAIGHT
if("pipe-c")
stored.ptype = DISP_PIPE_BENT
if("pipe-j1")
stored.ptype = DISP_JUNCTION
if("pipe-j2")
stored.ptype = DISP_JUNCTION_FLIP
if("pipe-y")
stored.ptype = DISP_YJUNCTION
if("pipe-t")
stored.ptype = DISP_END_TRUNK
if("pipe-j1s")
stored.ptype = DISP_SORTJUNCTION
if("pipe-j2s")
stored.ptype = DISP_SORTJUNCTION_FLIP
return
@@ -728,7 +744,8 @@
if(istype(T, /turf/simulated/floor) && !istype(T, /turf/simulated/floor/plating)) //intact floor, pop the tile
var/turf/simulated/floor/myturf = T
new myturf.floor_tile(T)
if(myturf.floor_tile)
new myturf.floor_tile(T)
myturf.make_plating()
if(direction) // direction is specified
@@ -876,7 +893,7 @@
/obj/structure/disposalpipe/segment/New()
..()
if(icon_state == "pipe-s")
if(stored.ptype == DISP_PIPE_STRAIGHT)
dpdir = dir | turn(dir, 180)
else
dpdir = dir | turn(dir, -90)
@@ -893,12 +910,13 @@
/obj/structure/disposalpipe/junction/New()
..()
if(icon_state == "pipe-j1")
dpdir = dir | turn(dir, -90) | turn(dir,180)
else if(icon_state == "pipe-j2")
dpdir = dir | turn(dir, 90) | turn(dir,180)
else // pipe-y
dpdir = dir | turn(dir,90) | turn(dir, -90)
switch(stored.ptype)
if(DISP_JUNCTION)
dpdir = dir | turn(dir, -90) | turn(dir,180)
if(DISP_JUNCTION_FLIP)
dpdir = dir | turn(dir, 90) | turn(dir,180)
if(DISP_YJUNCTION)
dpdir = dir | turn(dir,90) | turn(dir, -90)
update()
return
@@ -950,7 +968,7 @@
posdir = dir
negdir = turn(posdir, 180)
if(icon_state == "pipe-j1s")
if(stored.ptype == DISP_SORTJUNCTION)
sortdir = turn(posdir, -90)
else
icon_state = "pipe-j2s"
@@ -1029,7 +1047,7 @@
/obj/structure/disposalpipe/wrapsortjunction/New()
..()
posdir = dir
if(icon_state == "pipe-j1s")
if(stored.ptype == DISP_SORTJUNCTION)
sortdir = turn(posdir, -90)
negdir = turn(posdir, 180)
else
@@ -1211,21 +1229,34 @@
anchored = 1
var/active = 0
var/turf/target // this will be where the output objects are 'thrown' to.
var/obj/structure/disposalpipe/trunk/trunk = null // the attached pipe trunk
var/obj/structure/disposalconstruct/stored
var/mode = 0
var/start_eject = 0
var/eject_range = 2
/obj/structure/disposaloutlet/New()
/obj/structure/disposaloutlet/New(loc, var/obj/structure/disposalconstruct/make_from)
..()
if(make_from)
dir = make_from.dir
make_from.loc = src
stored = make_from
else
stored = new (src, DISP_END_OUTLET,dir)
spawn(1)
target = get_ranged_target_turf(src, dir, 10)
var/obj/structure/disposalpipe/trunk/trunk = locate() in src.loc
trunk = locate() in src.loc
if(trunk)
trunk.linked = src // link the pipe trunk to self
/obj/structure/disposaloutlet/Destroy()
if(trunk)
trunk.linked = null
..()
// expel the contents of the holder object, then delete it
// called when the holder exits the outlet
/obj/structure/disposaloutlet/proc/expel(var/obj/structure/disposalholder/H)
@@ -1272,11 +1303,11 @@
if(do_after(user,20))
if(!src || !W.isOn()) return
user << "<span class='notice'>You've sliced the floorweld off \the [src].</span>"
var/obj/structure/disposalconstruct/C = new (src.loc, 7) // 7 = outlet
src.transfer_fingerprints_to(C)
C.update()
C.anchored = 1
C.density = 1
stored.loc = loc
src.transfer_fingerprints_to(stored)
stored.update()
stored.anchored = 0
stored.density = 1
qdel(src)
return
else

View File

@@ -237,14 +237,19 @@
var/start_flush = 0
var/c_mode = 0
/obj/machinery/disposal/deliveryChute/New()
/obj/machinery/disposal/deliveryChute/New(loc,var/obj/structure/disposalconstruct/make_from)
..()
stored.ptype = 8 // 8 = Delivery chute
stored.ptype = DISP_END_CHUTE
spawn(5)
trunk = locate() in loc
if(trunk)
trunk.linked = src // link the pipe trunk to self
/obj/machinery/disposal/deliveryChute/Destroy()
if(trunk)
trunk.linked = null
..()
/obj/machinery/disposal/deliveryChute/interact()
return