diff --git a/code/__DEFINES/construction.dm b/code/__DEFINES/construction.dm
index 9d8ca0b3013..8e967777225 100644
--- a/code/__DEFINES/construction.dm
+++ b/code/__DEFINES/construction.dm
@@ -52,3 +52,11 @@
#define MAX_STACK_SIZE 50
//maximum amount of cable in a coil
#define MAXCOIL 30
+
+//rpd stuff
+
+#define RPD_ATMOS_MODE 1
+#define RPD_DISPOSALS_MODE 2
+#define RPD_ROTATE_MODE 3
+#define RPD_FLIP_MODE 4
+#define RPD_DELETE_MODE 5
diff --git a/code/__DEFINES/flags.dm b/code/__DEFINES/flags.dm
index 0ec1567f86d..cd6688d095f 100644
--- a/code/__DEFINES/flags.dm
+++ b/code/__DEFINES/flags.dm
@@ -101,7 +101,6 @@
//turf-only flags
#define NOJAUNT 1
-#define RPD_ALLOWED_HERE 2//By default, RPD is disabled on turfs.
//ITEM INVENTORY SLOT BITMASKS
#define SLOT_OCLOTHING 1
diff --git a/code/game/atoms.dm b/code/game/atoms.dm
index 19af319aa20..e8ceb49dc35 100644
--- a/code/game/atoms.dm
+++ b/code/game/atoms.dm
@@ -296,6 +296,9 @@
/atom/proc/emag_act()
return
+/atom/proc/rpd_act()
+ return
+
/atom/proc/hitby(atom/movable/AM, skipcatch, hitpush, blocked)
if(density && !has_gravity(AM)) //thrown stuff bounces off dense stuff in no grav, unless the thrown stuff ends up inside what it hit(embedding, bola, etc...).
addtimer(CALLBACK(src, .proc/hitby_react, AM), 2)
diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm
index 2d5a885aba1..7b67aed66be 100644
--- a/code/game/machinery/pipe/construction.dm
+++ b/code/game/machinery/pipe/construction.dm
@@ -180,6 +180,16 @@
//update the name and icon of the pipe item depending on the type
+/obj/item/pipe/rpd_act(mob/user, obj/item/rpd/our_rpd)
+ if(our_rpd.mode == RPD_ROTATE_MODE)
+ rotate()
+ else if(our_rpd.mode == RPD_FLIP_MODE)
+ flip()
+ else if(our_rpd.mode == RPD_DELETE_MODE)
+ our_rpd.delete_single_pipe(user, src)
+ else
+ ..()
+
/obj/item/pipe/proc/update(var/obj/machinery/atmospherics/make_from)
var/list/nlist = list( \
"pipe", \
@@ -650,6 +660,12 @@
to_chat(user, "You have fastened the meter to the pipe.")
qdel(src)
+/obj/item/pipe_meter/rpd_act(mob/user, obj/item/rpd/our_rpd)
+ if(our_rpd.mode == RPD_DELETE_MODE)
+ our_rpd.delete_single_pipe(user, src)
+ else
+ ..()
+
/obj/item/pipe_gsensor
name = "gas sensor"
desc = "A sensor that can be hooked to a computer"
@@ -667,6 +683,12 @@
to_chat(user, "You have fastened the gas sensor.")
qdel(src)
+/obj/item/pipe_gsensor/rpd_act(mob/user, obj/item/rpd/our_rpd)
+ if(our_rpd.mode == RPD_DELETE_MODE)
+ our_rpd.delete_single_pipe(user, src)
+ else
+ ..()
+
#undef PIPE_SIMPLE_STRAIGHT
#undef PIPE_SIMPLE_BENT
#undef PIPE_HE_STRAIGHT
diff --git a/code/game/objects/items/weapons/rpd.dm b/code/game/objects/items/weapons/rpd.dm
index aaaf034b933..b43d7d0a44f 100644
--- a/code/game/objects/items/weapons/rpd.dm
+++ b/code/game/objects/items/weapons/rpd.dm
@@ -14,16 +14,13 @@
#define GAS_SENSOR 98
#define METER 99
#define DISPOSALS_JUNCTION 2
-#define ATMOS_MODE 1
-#define DISPOSALS_MODE 2
-#define ROTATION_MODE 3
-#define FLIP_MODE 4
-#define DELETE_MODE 5
#define ATMOS_PIPING 1
#define SUPPLY_PIPING 2
#define SCRUBBERS_PIPING 3
#define DEVICES 4
#define HEAT_PIPING 5
+#define RPD_COOLDOWN_TIME 4 //How long should we have to wait between dispensing pipes?
+#define RPD_WALLBUILD_TIME 40 //How long should drilling into a wall take?
/obj/item/rpd
name = "rapid pipe dispenser"
@@ -44,12 +41,12 @@
var/datum/effect_system/spark_spread/spark_system
var/lastused
var/iconrotation = 0 //used to orient icons and pipes
- var/mode = 1 //Disposals, atmospherics, etc.
+ var/mode = RPD_ATMOS_MODE //Disposals, atmospherics, etc.
var/pipetype = 1//For nanoUI menus
var/whatpipe = 0 //What kind of pipe is it? See code/game/machinery/pipe/construction.dm for a list of defines
- var/whatdpipe = 0 //What kind of disposals pipe is it? See code/game/machinery/pipe/dispenser.dm for a list of defines
- var/spawndelay = 4 //How long should we have to wait between dispensing pipes?
- var/walldelay = 40 //How long should drilling into a wall take?
+ var/whatdpipe = 0 //What kind of disposals pipe is it?
+ var/spawndelay = RPD_COOLDOWN_TIME
+ var/walldelay = RPD_WALLBUILD_TIME
/obj/item/rpd/New()
..()
@@ -59,18 +56,81 @@
//Procs
-/obj/item/rpd/proc/Activaterpd(delay)
+/obj/item/rpd/proc/Activaterpd(delay) //Maybe makes sparks and activates cooldown if there is a delay.
playsound(loc, "sound/machines/click.ogg", 50, 1)
if(prob(15))
spark_system.start()
if(delay)
lastused = world.time
-/obj/item/rpd/proc/Manipulatepipes(subject, atmosverb, disposalsverb)
- if(istype(subject, /obj/item/pipe))
- call(subject, atmosverb)()
- else if(istype(subject, /obj/structure/disposalconstruct/))
- call(subject, disposalsverb)()
+/obj/item/rpd/proc/create_atmos_pipe(mob/user, turf/T) //Make an atmos pipe, meter, or gas sensor
+ var/obj/item/pipe/P
+ if(whatpipe == GAS_SENSOR)
+ P = new /obj/item/pipe_gsensor(T)
+ else if(whatpipe == METER)
+ P = new /obj/item/pipe_meter(T)
+ else
+ P = new(T, pipe_type = whatpipe, dir = user.dir)
+ if(iconrotation == 0 && P.is_bent_pipe()) //Automatic rotation of dispensed pipes
+ P.dir = turn(user.dir, 135)
+ else if(iconrotation == 0 && P.pipe_type in list(CONNECTOR, UNARY_VENT, GAS_SCRUBBER, HE_EXCHANGER, SIMPLE_CAP, SUPPLY_CAP, SCRUBBERS_CAP, INJECTOR, PASSIVE_VENT)) //Some pipes dispense oppositely to what you'd expect, but we don't want to do anything if they selected a direction
+ P.flip()
+ else if(iconrotation != 0 && P.is_bent_pipe()) //If they selected a rotation and the pipe is bent
+ P.dir = turn(iconrotation, -45)
+ else if(iconrotation != 0)
+ P.dir = iconrotation
+ to_chat(user, "[src] rapidly dispenses [P]!")
+ Activaterpd(1)
+
+/obj/item/rpd/proc/create_disposals_pipe(mob/user, turf/T) //Make a disposals pipe / construct
+ var/obj/structure/disposalconstruct/P = new(T) //Now we make the pipe
+ P.dir = iconrotation
+ P.ptype = whatdpipe
+ if(iconrotation == 0) //Automatic rotation
+ P.dir = user.dir
+ if(iconrotation == 0 && whatdpipe != DISPOSALS_JUNCTION) //Disposals pipes are in the opposite direction to atmos pipes, so we need to flip them. Junctions don't have this quirk though
+ P.flip()
+ P.update()
+ to_chat(user, "[src] rapidly dispenses [P]!")
+ Activaterpd(1)
+
+/obj/item/rpd/proc/rotate_all_pipes(mob/user, turf/T) //Rotate all pipes on a turf
+ for(var/obj/item/pipe/P in T)
+ P.rotate()
+ for(var/obj/structure/disposalconstruct/D in T)
+ D.rotate()
+
+/obj/item/rpd/proc/flip_all_pipes(mob/user, turf/T) //Flip all pipes on a turf
+ for(var/obj/item/pipe/P in T)
+ P.flip()
+ for(var/obj/structure/disposalconstruct/D in T)
+ D.flip()
+
+/obj/item/rpd/proc/delete_all_pipes(mob/user, turf/T) //Delete all pipes on a turf
+ var/eaten
+ for(var/obj/item/pipe/P in T)
+ QDEL_NULL(P)
+ eaten = TRUE
+ for(var/obj/item/pipe_gsensor/G in T)
+ QDEL_NULL(G)
+ eaten = TRUE
+ for(var/obj/item/pipe_meter/M in T)
+ QDEL_NULL(M)
+ eaten = TRUE
+ for(var/obj/structure/disposalconstruct/D in T)
+ if(!D.anchored)
+ QDEL_NULL(D)
+ eaten = TRUE
+ if(eaten)
+ to_chat(user, "[src] sucks up the loose pipes on [T].")
+ Activaterpd()
+ else
+ to_chat(user, "There were no loose pipes on [T].")
+
+/obj/item/rpd/proc/delete_single_pipe(mob/user, obj/P) //Delete a single pipe
+ to_chat(user, "[src] sucks up [P].")
+ QDEL_NULL(P)
+ Activaterpd()
//Lists of things
@@ -175,71 +235,11 @@ var/list/pipemenu = list(
return
SSnanoui.update_uis(src)
-//What the RPD actually does
-
/obj/item/rpd/afterattack(atom/target, mob/user, proximity)
..()
- var/turf/T = get_turf(target)
- if(loc != user || ismob(target) || istype(target, /obj/structure/window) || !proximity || world.time < lastused + spawndelay)
+ if(loc != user || !proximity || world.time < lastused + spawndelay)
return
- if(!(T.flags & RPD_ALLOWED_HERE))
- to_chat(user, "[src] beeps, \"Unable to interface with [T]. Please try again later.\"")
- return
- if(mode == ATMOS_MODE)
- if(istype(T, /turf/simulated/wall)) //Drilling into walls takes time
- playsound(loc, "sound/weapons/circsawhit.ogg", 50, 1)
- user.visible_message("[user] starts drilling a hole in [T]...", "You start drilling a hole in [T]...", "You hear a drill.")
- if(!do_after(user, walldelay, target = T))
- return
- user.visible_message("[user] finishes drilling a hole in [T]!", "You finish drilling a hole in [T]!", "You hear clanking.")
- var/obj/item/pipe/P
- if(whatpipe == GAS_SENSOR)
- P = new /obj/item/pipe_gsensor(T)
- else if(whatpipe == METER)
- P = new /obj/item/pipe_meter(T)
- else
- P = new(T, pipe_type = whatpipe, dir = user.dir)
- if(iconrotation == 0 && P.is_bent_pipe()) //Automatic rotation of dispensed pipes
- P.dir = turn(user.dir, 135)
- else if(iconrotation == 0 && P.pipe_type in list(CONNECTOR, UNARY_VENT, GAS_SCRUBBER, HE_EXCHANGER, SIMPLE_CAP, SUPPLY_CAP, SCRUBBERS_CAP, INJECTOR, PASSIVE_VENT)) //Some pipes dispense oppositely to what you'd expect, but we don't want to do anything if they selected a direction
- P.flip()
- else if(iconrotation != 0 && P.is_bent_pipe()) //If they selected a rotation and the pipe is bent
- P.dir = turn(iconrotation, -45)
- else if(iconrotation != 0)
- P.dir = iconrotation
- to_chat(user, "[src] rapidly dispenses [P]!")
- Activaterpd(1)
- else if(mode == DISPOSALS_MODE && !istype(T, /turf/simulated/shuttle))
- if(istype(T, /turf/simulated/wall)) //No disposals pipes on walls
- to_chat(user, "That type of pipe won't fit on [T]!")
- return
- var/obj/structure/disposalconstruct/P = new(T) //Now we make the pipe
- P.dir = iconrotation
- P.ptype = whatdpipe
- if(iconrotation == 0) //Automatic rotation
- P.dir = user.dir
- if(iconrotation == 0 && whatdpipe != DISPOSALS_JUNCTION) //Disposals pipes are in the opposite direction to atmos pipes, so we need to flip them. Junctions don't have this quirk though
- P.flip()
- P.update()
- to_chat(user, "[src] rapidly dispenses [P]!")
- Activaterpd(1)
- else if(mode == ROTATION_MODE)
- for(var/obj/W in T)
- Manipulatepipes(W, /obj/item/pipe/verb/rotate, /obj/structure/disposalconstruct/verb/rotate)
- else if(mode == FLIP_MODE)
- for(var/obj/W in T)
- Manipulatepipes(W, /obj/item/pipe/verb/flip, /obj/structure/disposalconstruct/verb/flip)
- else if(mode == DELETE_MODE)
- var/eaten
- for(var/obj/W in T)
- if(istype(W, /obj/item/pipe) || istype(W, /obj/item/pipe_meter) || istype(W, /obj/item/pipe_gsensor) || istype(W, /obj/structure/disposalconstruct) && !W.anchored)
- QDEL_NULL(W)
- eaten = TRUE
- if(eaten)
- to_chat(user, "[src] sucks up the loose pipes on [T].")
- Activaterpd()
- else
- to_chat(user, "There were no loose pipes on [T].")
+ target.rpd_act(user, src)
#undef SIMPLE_CAP
#undef SUPPLY_CAP
@@ -253,13 +253,10 @@ var/list/pipemenu = list(
#undef GAS_SENSOR
#undef METER
#undef DISPOSALS_JUNCTION
-#undef ATMOS_MODE
-#undef DISPOSALS_MODE
-#undef ROTATION_MODE
-#undef FLIP_MODE
-#undef DELETE_MODE
#undef ATMOS_PIPING
#undef SUPPLY_PIPING
#undef SCRUBBERS_PIPING
#undef DEVICES
#undef HEAT_PIPING
+#undef RPD_COOLDOWN_TIME
+#undef RPD_WALLBUILD_TIME
diff --git a/code/game/objects/objs.dm b/code/game/objects/objs.dm
index fe9e8444378..352868056f5 100644
--- a/code/game/objects/objs.dm
+++ b/code/game/objects/objs.dm
@@ -68,6 +68,10 @@
SSnanoui.close_uis(src)
return ..()
+/obj/rpd_act(mob/user, obj/item/rpd/our_rpd)
+ var/turf/T = get_turf(src) //This preserves RPD behaviour on specific turfs
+ T.rpd_act(user, our_rpd)
+
/obj/proc/process()
set waitfor = 0
processing_objects.Remove(src)
diff --git a/code/game/objects/structures/window.dm b/code/game/objects/structures/window.dm
index aebd111ad26..8b42d1f350e 100644
--- a/code/game/objects/structures/window.dm
+++ b/code/game/objects/structures/window.dm
@@ -79,6 +79,9 @@ var/global/wcCommon = pick(list("#379963", "#0d8395", "#58b5c3", "#49e46e", "#8f
/obj/structure/window/narsie_act()
color = "#7D1919"
+/obj/structure/window/rpd_act()
+ return
+
/obj/structure/window/singularity_pull(S, current_size)
if(current_size >= STAGE_FIVE)
destroy()
diff --git a/code/game/turfs/simulated.dm b/code/game/turfs/simulated.dm
index 89c40be8641..61f622c071f 100644
--- a/code/game/turfs/simulated.dm
+++ b/code/game/turfs/simulated.dm
@@ -4,7 +4,6 @@
var/image/wet_overlay = null
var/thermite = 0
- flags = RPD_ALLOWED_HERE
oxygen = MOLES_O2STANDARD
nitrogen = MOLES_N2STANDARD
var/to_be_destroyed = 0 //Used for fire, if a melting temperature was reached, it will be destroyed
diff --git a/code/game/turfs/simulated/shuttle.dm b/code/game/turfs/simulated/shuttle.dm
index 0c5e6c08f6b..7a781679173 100644
--- a/code/game/turfs/simulated/shuttle.dm
+++ b/code/game/turfs/simulated/shuttle.dm
@@ -1,7 +1,6 @@
/turf/simulated/shuttle
name = "shuttle"
icon = 'icons/turf/shuttle.dmi'
- flags = null
thermal_conductivity = 0.05
heat_capacity = 0
layer = 2
@@ -13,6 +12,9 @@
density = 1
blocks_air = 1
+/turf/simulated/shuttle/rpd_act(mob/user, obj/item/rpd/our_rpd)
+ if(our_rpd.mode == RPD_DELETE_MODE)//No pipes on shuttles
+ our_rpd.delete_all_pipes(user, src)
/turf/simulated/shuttle/narsie_act()
if(prob(20))
diff --git a/code/game/turfs/simulated/walls.dm b/code/game/turfs/simulated/walls.dm
index b1cbf84493f..545cf857d6d 100644
--- a/code/game/turfs/simulated/walls.dm
+++ b/code/game/turfs/simulated/walls.dm
@@ -168,6 +168,18 @@
if(prob(50))
dismantle_wall()
+/turf/simulated/wall/rpd_act(mob/user, obj/item/rpd/our_rpd)
+ if(our_rpd.mode == RPD_ATMOS_MODE)
+ playsound(src, "sound/weapons/circsawhit.ogg", 50, 1)
+ user.visible_message("[user] starts drilling a hole in [src]...", "You start drilling a hole in [src]...", "You hear drilling.")
+ if(!do_after(user, our_rpd.walldelay, target = src)) //Drilling into walls takes time
+ return
+ our_rpd.create_atmos_pipe(user, src)
+ else if(our_rpd.mode == RPD_DISPOSALS_MODE)
+ return
+ else
+ ..()
+
/turf/simulated/wall/mech_melee_attack(obj/mecha/M)
if(M.damtype == "brute")
playsound(src, 'sound/weapons/punch4.ogg', 50, 1)
diff --git a/code/game/turfs/space/space.dm b/code/game/turfs/space/space.dm
index 60c63d0f221..58911d952b4 100644
--- a/code/game/turfs/space/space.dm
+++ b/code/game/turfs/space/space.dm
@@ -3,7 +3,6 @@
name = "\proper space"
icon_state = "0"
dynamic_lighting = 0
- flags = RPD_ALLOWED_HERE
luminosity = 1
temperature = TCMB
diff --git a/code/game/turfs/space/transit.dm b/code/game/turfs/space/transit.dm
index 611ff1656f3..a1749cf15c9 100644
--- a/code/game/turfs/space/transit.dm
+++ b/code/game/turfs/space/transit.dm
@@ -1,5 +1,4 @@
/turf/space/transit
- flags = null
var/pushdirection // push things that get caught in the transit tile this direction
//Overwrite because we dont want people building rods in space.
@@ -119,7 +118,8 @@
AM.newtonian_move(dir)
-
+/turf/space/transit/rpd_act()
+ return
//Overwrite because we dont want people building rods in space.
/turf/space/transit/attackby()
diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm
index f70aee9740f..dda914482b1 100644
--- a/code/game/turfs/turf.dm
+++ b/code/game/turfs/turf.dm
@@ -71,6 +71,17 @@
/turf/ex_act(severity)
return 0
+/turf/rpd_act(mob/user, obj/item/rpd/our_rpd)
+ if(our_rpd.mode == RPD_ATMOS_MODE)
+ our_rpd.create_atmos_pipe(user, src)
+ else if(our_rpd.mode == RPD_DISPOSALS_MODE)
+ our_rpd.create_disposals_pipe(user, src)
+ else if(our_rpd.mode == RPD_ROTATE_MODE)
+ our_rpd.rotate_all_pipes(user, src)
+ else if(our_rpd.mode == RPD_FLIP_MODE)
+ our_rpd.flip_all_pipes(user, src)
+ else if(our_rpd.mode == RPD_DELETE_MODE)
+ our_rpd.delete_all_pipes(user, src)
/turf/bullet_act(var/obj/item/projectile/Proj)
if(istype(Proj ,/obj/item/projectile/beam/pulse))
diff --git a/code/game/turfs/unsimulated.dm b/code/game/turfs/unsimulated.dm
index 5c9509a3d68..35b6c2056e3 100644
--- a/code/game/turfs/unsimulated.dm
+++ b/code/game/turfs/unsimulated.dm
@@ -7,6 +7,9 @@
/turf/unsimulated/can_lay_cable()
return 0
+/turf/unsimulated/rpd_act()
+ return
+
/turf/unsimulated/floor/plating/vox
icon_state = "plating"
name = "plating"
diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm
index 3658846a696..137962d040c 100644
--- a/code/modules/recycling/disposal-construction.dm
+++ b/code/modules/recycling/disposal-construction.dm
@@ -265,3 +265,16 @@
else
to_chat(user, "You need to attach it to the plating first!")
return
+
+/obj/structure/disposalconstruct/rpd_act(mob/user, obj/item/rpd/our_rpd)
+ if(anchored)
+ to_chat(user, "[src] is bolted down!")
+ return
+ else if(our_rpd.mode == RPD_ROTATE_MODE)
+ rotate()
+ else if(our_rpd.mode == RPD_FLIP_MODE)
+ flip()
+ else if(our_rpd.mode == RPD_DELETE_MODE)
+ our_rpd.delete_single_pipe(user, src)
+ else
+ ..()