Refactored the attack proc (#19908)

Refactored the attack proc signature.
Added signals and components for the attack proc.
Added signals and components for the attackby proc.
Adjusted some leftover attackby procs signatures.
Added grep test to ensure people don't keep adding attack/attackby procs
with the wrong signature.
This commit is contained in:
Fluffy
2024-10-06 21:30:00 +00:00
committed by GitHub
parent b79b7c5177
commit 9636363e60
121 changed files with 878 additions and 663 deletions
+8 -9
View File
@@ -25,19 +25,19 @@
if(user.isSynthetic())
to_chat(user, SPAN_NOTICE("\The [src] does not seem to be doing anything, but you can feel it. A signal, beyond anything you can consciously understand, weaving and scratching a shield around the back of your mind."))
/obj/structure/ecd/attackby(obj/item/W, mob/user)
if(W.iswrench())
/obj/structure/ecd/attackby(obj/item/attacking_item, mob/user, params)
if(attacking_item.iswrench())
switch(state)
if(ECD_LOOSE)
state = ECD_BOLTED
W.play_tool_sound(get_turf(src), 75)
attacking_item.play_tool_sound(get_turf(src), 75)
user.visible_message(SPAN_NOTICE("\The [user] secures \the [src] to the floor."), \
SPAN_NOTICE("You secure \the [src]'s external reinforcing bolts to the floor."), \
SPAN_WARNING("You hear a ratcheting noise."))
anchored = TRUE
if(ECD_BOLTED)
state = ECD_LOOSE
W.play_tool_sound(get_turf(src), 75)
attacking_item.play_tool_sound(get_turf(src), 75)
user.visible_message(SPAN_NOTICE("\The [user] unsecures \the [src]'s reinforcing bolts from the floor."), \
SPAN_NOTICE("You undo \the [src]'s external reinforcing bolts."), \
SPAN_WARNING("You hear a ratcheting noise."))
@@ -46,8 +46,8 @@
to_chat(user, SPAN_WARNING("\The [src] needs to be unwelded from the floor."))
return
if(W.iswelder())
var/obj/item/weldingtool/WT = W
if(attacking_item.iswelder())
var/obj/item/weldingtool/WT = attacking_item
switch(state)
if(ECD_LOOSE)
to_chat(user, SPAN_WARNING("\The [src] needs to be wrenched to the floor."))
@@ -57,7 +57,7 @@
user.visible_message(SPAN_NOTICE("\The [user] starts to weld \the [src] to the floor."), \
SPAN_NOTICE("You start to weld \the [src] to the floor."), \
SPAN_WARNING("You hear the sound of metal being welded."))
if(W.use_tool(src, user, 20, volume = 50))
if(attacking_item.use_tool(src, user, 20, volume = 50))
if(!src || !WT.isOn())
return
state = ECD_WELDED
@@ -70,14 +70,13 @@
user.visible_message(SPAN_NOTICE("\The [user] starts to cut \the [src] free from the floor."), \
SPAN_NOTICE("You start to cut \the [src] free from the floor."), \
SPAN_WARNING("You hear the sound of metal being welded."))
if(W.use_tool(src, user, 20, volume = 50))
if(attacking_item.use_tool(src, user, 20, volume = 50))
if(!src || !WT.isOn())
return
state = ECD_BOLTED
to_chat(user, SPAN_NOTICE("You cut \the [src] free from the floor."))
else
to_chat(user, SPAN_WARNING("You need more welding fuel to complete this task."))
return
#undef ECD_LOOSE
#undef ECD_BOLTED
+4 -4
View File
@@ -33,21 +33,21 @@
if(start_deployed)
deploy()
/obj/structure/survey_probe/attackby(obj/item/item, mob/living/user)
if(!timer_id && item.iswrench())
/obj/structure/survey_probe/attackby(obj/item/attacking_item, mob/user, params)
if(!timer_id && attacking_item.iswrench())
if(!anchored)
user.visible_message(
SPAN_NOTICE("\The [user] unfastens the locking bolts on \the [src], deploying it."),
SPAN_NOTICE("You unfasten the locking bolts on \the [src], and it deploys, lowering its devices and drill bits to the ground. It is ready to survey."),
)
item.play_tool_sound(user, 30)
attacking_item.play_tool_sound(user, 30)
deploy()
else
user.visible_message(
SPAN_NOTICE("\The [user] fastens the locking bolts on \the [src], stowing it."),
SPAN_NOTICE("You fasten the locking bolts \the [src], stowing it. It retracts its devices and drill bits."),
)
item.play_tool_sound(user, 30)
attacking_item.play_tool_sound(user, 30)
undeploy()
/obj/structure/survey_probe/attack_hand(mob/user as mob)