Skip to content

Commit 1bff8f5

Browse files
authored
RPD attack chain migration (#30574)
1 parent bb369af commit 1bff8f5

File tree

1 file changed

+53
-36
lines changed

1 file changed

+53
-36
lines changed

code/game/objects/items/rpd.dm

Lines changed: 53 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,26 @@
2222
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, RAD = 0, FIRE = 100, ACID = 50)
2323
resistance_flags = FIRE_PROOF
2424
origin_tech = "engineering=4;materials=2"
25+
new_attack_chain = TRUE
2526
var/datum/effect_system/spark_spread/spark_system
2627
var/lastused
27-
var/iconrotation = 0 //Used to orient icons and pipes
28-
var/mode = RPD_ATMOS_MODE //Disposals, atmospherics, etc.
29-
var/pipe_category = RPD_ATMOS_PIPING //For TGUI menus, this is a subtype of pipes e.g. scrubbers pipes, devices
30-
var/whatpipe = PIPE_SIMPLE_STRAIGHT //What kind of atmos pipe is it?
31-
var/whatdpipe = PIPE_DISPOSALS_STRAIGHT //What kind of disposals pipe is it?
28+
/// Used to orient icons and pipes.
29+
var/iconrotation = 0
30+
/// Disposals, atmospherics, etc.
31+
var/mode = RPD_ATMOS_MODE
32+
/// For TGUI menus, this is a subtype of pipes e.g. scrubbers pipes, devices.
33+
var/pipe_category = RPD_ATMOS_PIPING
34+
/// What kind of atmos pipe are we trying to lay?
35+
var/whatpipe = PIPE_SIMPLE_STRAIGHT
36+
/// What kind of disposals pipe are we trying to lay?
37+
var/whatdpipe = PIPE_DISPOSALS_STRAIGHT
38+
/// What kind of transit tube are we trying to lay?
3239
var/whatttube = PIPE_TRANSIT_TUBE
40+
/// Cooldown on RPD use.
3341
var/spawndelay = RPD_COOLDOWN_TIME
42+
/// Time taken to drill a borehole before the pipe can be laid.
3443
var/walldelay = RPD_WALLBUILD_TIME
44+
/// Can this RPD lay pipe on non-adjacent turfs?
3545
var/ranged = FALSE
3646
var/primary_sound = 'sound/machines/click.ogg'
3747
var/alt_sound = null
@@ -209,7 +219,9 @@
209219
return
210220
// TGUI stuff
211221

212-
/obj/item/rpd/attack_self__legacy__attackchain(mob/user)
222+
/obj/item/rpd/activate_self(mob/user)
223+
if(..())
224+
return
213225
ui_interact(user)
214226

215227
/obj/item/rpd/ui_state(mob/user)
@@ -303,24 +315,39 @@
303315
else
304316
return //Either nothing was selected, or an invalid mode was selected
305317
to_chat(user, "<span class='notice'>You set [src]'s mode.</span>")
318+
319+
/obj/item/rpd/ranged_interact_with_atom(atom/target, mob/living/user, list/modifiers)
320+
if(!ranged)
321+
return NONE
322+
323+
if(handle_atom_interaction(target, user, ranged))
324+
return ITEM_INTERACT_COMPLETE
325+
326+
return NONE
327+
328+
/obj/item/rpd/interact_with_atom(atom/target, mob/living/user, list/modifiers)
329+
if(handle_atom_interaction(target, user, ranged))
330+
return ITEM_INTERACT_COMPLETE
306331

307-
/obj/item/rpd/afterattack__legacy__attackchain(atom/target, mob/user, proximity)
308-
..()
332+
return NONE
333+
334+
/obj/item/rpd/proc/handle_atom_interaction(atom/target, mob/living/user, ranged)
309335
if(isstorage(target))
310336
var/obj/item/storage/S = target
311337
if(!S.can_be_inserted(src, stop_messages = TRUE))
312-
return
313-
if(loc != user)
314-
return
315-
if(!proximity && !ranged)
316-
return
338+
return ITEM_INTERACT_COMPLETE
339+
return NONE
340+
317341
if(world.time < lastused + spawndelay)
318-
return
342+
return ITEM_INTERACT_COMPLETE
319343

320-
var/turf/T = get_turf(target)
344+
// Use as melee weapon
345+
if(user.a_intent == INTENT_HARM)
346+
return NONE
321347

348+
var/turf/T = get_turf(target)
322349
if(!T)
323-
return
350+
return ITEM_INTERACT_COMPLETE
324351

325352
if(target != T)
326353
// We only check the rpd_act of the target if it isn't the turf, because otherwise
@@ -329,42 +356,32 @@
329356
// If the object we are clicking on has a valid RPD interaction for just that specific object, do that and nothing else.
330357
// Example: clicking on a pipe with a RPD in rotate mode should rotate that pipe and ignore everything else on the tile.
331358
if(ranged)
332-
user.Beam(T, icon_state="rped_upgrade", icon='icons/effects/effects.dmi', time=5)
333-
return
359+
user.Beam(T, icon_state = "rped_upgrade", icon = 'icons/effects/effects.dmi', time = 0.5 SECONDS)
360+
return ITEM_INTERACT_COMPLETE
334361

335362
// If we get this far, we have to check every object in the tile, to make sure that none of them block RPD usage on this tile.
336363
// This is done by calling rpd_blocksusage on every /obj in the tile. If any block usage, fail at this point.
337-
338364
for(var/obj/O in T)
339365
if(O.rpd_blocksusage())
340366
to_chat(user, "<span class='warning'>[O] blocks [src]!</span>")
341-
return
367+
return ITEM_INTERACT_COMPLETE
342368

343369
// If we get here, then we're effectively acting on the turf, probably placing a pipe.
344-
if(ranged) //woosh beam if bluespaced at a distance
370+
if(ranged) //woosh beam!
345371
if(get_dist(src, T) >= (user.client.maxview() / 2))
346-
message_admins("\[EXPLOIT] [key_name_admin(user)] attempted to place pipes with a BRPD via a camera console. (Attempted range exploit)")
372+
message_admins("\[EXPLOIT] [key_name_admin(user)] attempted to place pipes with a BRPD via a camera console (attempted range exploit).")
347373
playsound(src, 'sound/machines/synth_no.ogg', 15, TRUE)
348-
to_chat(user, "<span class='notice'>ERROR: \The [T] is out of [src]'s range!</span>")
349-
return
374+
to_chat(user, "<span class='warning'>ERROR: \The [T] is out of [src]'s range!</span>")
375+
return ITEM_INTERACT_COMPLETE
350376

351377
if(!(user in hearers(12, T))) // Checks if user can hear the target turf, cause viewers doesnt work for it.
352378
to_chat(user, "<span class='warning'>[src] needs full visibility to determine the dispensing location.</span>")
353379
playsound(src, 'sound/machines/synth_no.ogg', 50, TRUE)
354-
return
380+
return ITEM_INTERACT_COMPLETE
381+
355382
user.Beam(T, icon_state = "rped_upgrade", icon = 'icons/effects/effects.dmi', time = 0.5 SECONDS)
356383
T.rpd_act(user, src)
357-
358-
/obj/item/rpd/attack_obj__legacy__attackchain(obj/O, mob/living/user)
359-
if(user.a_intent != INTENT_HARM)
360-
if(istype(O, /obj/machinery/atmospherics/pipe))
361-
return
362-
else if(istype(O, /obj/structure/disposalconstruct))
363-
return
364-
else if(istype(O, /obj/structure/transit_tube_construction))
365-
return
366-
367-
return ..()
384+
return ITEM_INTERACT_COMPLETE
368385

369386
#undef RPD_COOLDOWN_TIME
370387
#undef RPD_WALLBUILD_TIME

0 commit comments

Comments
 (0)