Moves most screwdriver checks to screwdriver_act (#19024)

* screwdriver_act my beloved

* convert to returns instead of . / lewcc review

* it will be done

* i'm a little bit stupid, but now time to test

* sometimes I get excited and press the commit

* The great test has been completed

* oh wow oh wow, lewc review

* found one last one

* Steel review

* Lewc review

* quick sirryan review

* removes stupid comments (old coders I blame)

* sirryan review two

* whoops...

* hal review

* the fix to the fix to the fix

* Revert "the fix to the fix to the fix"

FUCK I pushed to the wrong branch
This reverts commit a96fe98781.
This commit is contained in:
Contrabang
2022-10-06 09:30:33 +01:00
committed by GitHub
parent 6933ed99fd
commit 8418997ed8
39 changed files with 572 additions and 468 deletions
@@ -307,13 +307,7 @@
show_controls(user)
/mob/living/simple_animal/bot/attackby(obj/item/W, mob/user, params)
if(istype(W, /obj/item/screwdriver))
if(!locked)
open = !open
to_chat(user, "<span class='notice'>The maintenance panel is now [open ? "opened" : "closed"].</span>")
else
to_chat(user, "<span class='warning'>The maintenance panel is locked.</span>")
else if(istype(W, /obj/item/card/id) || istype(W, /obj/item/pda))
if(istype(W, /obj/item/card/id) || istype(W, /obj/item/pda))
if(allowed(user) && !open && !emagged)
locked = !locked
to_chat(user, "Controls are now [locked ? "locked." : "unlocked."]")
@@ -363,6 +357,19 @@
else
return ..()
/mob/living/simple_animal/bot/screwdriver_act(mob/living/user, obj/item/I)
if(user.a_intent == INTENT_HARM)
return ..()
if(locked)
to_chat(user, "<span class='warning'>The maintenance panel is locked.</span>")
return TRUE // must be true or we attempt to stab the bot
open = !open
I.play_tool_sound(src)
to_chat(user, "<span class='notice'>The maintenance panel is now [open ? "opened" : "closed"].</span>")
return TRUE
/mob/living/simple_animal/bot/welder_act(mob/user, obj/item/I)
if(user.a_intent != INTENT_HELP)
return
@@ -157,13 +157,8 @@
qdel(W)
if(8)
if(istype(W, /obj/item/screwdriver))
playsound(loc, W.usesound, 100, 1)
to_chat(user, "<span class='notice'>You start attaching the gun to the frame...</span>")
if(do_after(user, 40 * W.toolspeed, target = src))
build_step++
update_appearance(UPDATE_NAME)
to_chat(user, "<span class='notice'>Taser gun attached.</span>")
return
// Handled by screwdriver act, return here to prevent errors being thrown for no switch(build_step) = 8 (might not be needed?)
if(9)
if(istype(W, /obj/item/stock_parts/cell))
@@ -177,6 +172,17 @@
user.unEquip(src, 1)
qdel(src)
/obj/item/ed209_assembly/screwdriver_act(mob/living/user, obj/item/I)
if(build_step != 8)
return
I.play_tool_sound(src)
to_chat(user, "<span class='notice'>You start attaching the gun to the frame...</span>")
if(do_after(user, 40 * I.toolspeed, target = src))
build_step++
update_appearance(UPDATE_NAME)
to_chat(user, "<span class='notice'>You attach the gun to the frame.</span>")
return TRUE
/obj/item/ed209_assembly/update_name()
. = ..()
switch(build_step)
@@ -439,15 +445,16 @@
..()
return
if(!S.secured)
qdel(S)
var/obj/item/secbot_assembly/A = new /obj/item/secbot_assembly
user.put_in_hands(A)
to_chat(user, "<span class='notice'>You add the signaler to the helmet.</span>")
user.unEquip(src, 1)
qdel(src)
else
if(S.secured)
to_chat(user, "<span class='notice'>[S] is secured.</span>")
return
qdel(S)
var/obj/item/secbot_assembly/A = new /obj/item/secbot_assembly
user.put_in_hands(A)
to_chat(user, "<span class='notice'>You add the signaler to the helmet.</span>")
user.unEquip(src, 1)
qdel(src)
/obj/item/secbot_assembly/attackby(obj/item/I, mob/user, params)
..()
@@ -491,34 +498,40 @@
created_name = t
log_game("[key_name(user)] has renamed a robot to [t]")
else if(istype(I, /obj/item/screwdriver))
if(!build_step)
new /obj/item/assembly/signaler(get_turf(src))
new /obj/item/clothing/head/helmet(get_turf(src))
to_chat(user, "<span class='notice'>You disconnect the signaler from the helmet.</span>")
qdel(src)
else if(build_step == 2)
new /obj/item/assembly/prox_sensor(get_turf(src))
to_chat(user, "<span class='notice'>You detach the proximity sensor from [src].</span>")
build_step--
else if(build_step == 3)
new /obj/item/robot_parts/l_arm(get_turf(src))
to_chat(user, "<span class='notice'>You remove the robot arm from [src].</span>")
build_step--
//General Griefsky
else if((istype(I, /obj/item/wrench)) && (build_step == 3))
else if(istype(I, /obj/item/wrench) && build_step == 3)
var/obj/item/griefsky_assembly/A = new /obj/item/griefsky_assembly(get_turf(src))
user.put_in_hands(A)
to_chat(user, "<span class='notice'>You adjust the arm slots for extra weapons!.</span>")
to_chat(user, "<span class='notice'>You adjust the arm slots for extra weapons!</span>")
user.unEquip(src, 1)
qdel(src)
update_appearance(UPDATE_NAME|UPDATE_OVERLAYS)
/obj/item/secbot_assembly/screwdriver_act(mob/living/user, obj/item/I)
if(build_step != 0 && build_step != 2 && build_step != 3)
return
switch(build_step)
if(0)
new /obj/item/assembly/signaler(get_turf(src))
new /obj/item/clothing/head/helmet(get_turf(src))
to_chat(user, "<span class='notice'>You disconnect the signaler from the helmet.</span>")
qdel(src)
if(2)
new /obj/item/assembly/prox_sensor(get_turf(src))
to_chat(user, "<span class='notice'>You detach the proximity sensor from [src].</span>")
build_step--
if(3)
new /obj/item/robot_parts/l_arm(get_turf(src))
to_chat(user, "<span class='notice'>You remove the robot arm from [src].</span>")
build_step--
I.play_tool_sound(src)
update_appearance(UPDATE_NAME|UPDATE_OVERLAYS)
return TRUE
/obj/item/secbot_assembly/update_name()
. = ..()
switch(build_step)
@@ -578,15 +591,20 @@
qdel(I)
qdel(src)
else if(istype(I, /obj/item/screwdriver))
if((build_step == 1) || (build_step == 2) || (build_step == 3) || (build_step == 4))
new /obj/item/melee/energy/sword(get_turf(src))
to_chat(user, "<span class='notice'>You detach the energy sword from [src].</span>")
build_step--
else if((toy_step == 1) || (toy_step == 2) || (toy_step == 3) || (toy_step == 4))
new /obj/item/toy/sword(get_turf(src))
to_chat(user, "<span class='notice'>You detach the toy sword from [src].</span>")
toy_step--
/obj/item/griefsky_assembly/screwdriver_act(mob/living/user, obj/item/I)
if(!build_step && !toy_step)
return
if(build_step)
new /obj/item/melee/energy/sword(get_turf(src))
to_chat(user, "<span class='notice'>You detach the energy sword from [src].</span>")
build_step--
else if(toy_step)
new /obj/item/toy/sword(get_turf(src))
to_chat(user, "<span class='notice'>You detach the toy sword from [src].</span>")
toy_step--
I.play_tool_sound(src)
return TRUE
//Honkbot Assembly
/obj/item/storage/box/clown/attackby(obj/item/W, mob/user, params)
@@ -193,7 +193,7 @@
..()
if(istype(W, /obj/item/weldingtool) && user.a_intent != INTENT_HARM) // Any intent but harm will heal, so we shouldn't get angry.
return
if(!istype(W, /obj/item/screwdriver) && (!target)) // Added check for welding tool to fix #2432. Welding tool behavior is handled in superclass.
if(!isscrewdriver(W) && !locked && (!target)) //If the target is locked, they are recieving damage from the screwdriver
if(W.force && W.damtype != STAMINA)//If force is non-zero and damage type isn't stamina.
retaliate(user)
if(lasercolor)//To make up for the fact that lasertag bots don't hunt
@@ -102,7 +102,7 @@
..()
if(istype(W, /obj/item/weldingtool) && user.a_intent != INTENT_HARM) // Any intent but harm will heal, so we shouldn't get angry.
return
if(!istype(W, /obj/item/screwdriver) && (W.force) && (!target) && (W.damtype != STAMINA) ) // Added check for welding tool to fix #2432. Welding tool behavior is handled in superclass.
if(!isscrewdriver(W) && !locked && (W.force) && (!target) && (W.damtype != STAMINA))//If the target is locked, they are recieving damage from the screwdriver
retaliate(user)
addtimer(CALLBACK(src, .proc/react_buzz), 5)
@@ -95,12 +95,7 @@
reached_target = 0
/mob/living/simple_animal/bot/mulebot/attackby(obj/item/I, mob/user, params)
if(istype(I, /obj/item/screwdriver))
..()
if(open)
on = FALSE
update_controls()
else if(istype(I,/obj/item/stock_parts/cell) && open && !cell)
if(istype(I,/obj/item/stock_parts/cell) && open && !cell)
if(!user.drop_item())
return
var/obj/item/stock_parts/cell/C = I
@@ -141,6 +136,13 @@
update_icon()
return
/mob/living/simple_animal/bot/mulebot/screwdriver_act(mob/living/user, obj/item/I)
if(open)
on = FALSE
update_controls()
update_icon()
return TRUE
/mob/living/simple_animal/bot/mulebot/emag_act(mob/user)
if(emagged < 1)
emagged = 1
@@ -197,7 +197,7 @@
..()
if(istype(W, /obj/item/weldingtool) && user.a_intent != INTENT_HARM) // Any intent but harm will heal, so we shouldn't get angry.
return
if(!istype(W, /obj/item/screwdriver) && (W.force) && (!target) && (W.damtype != STAMINA) ) // Added check for welding tool to fix #2432. Welding tool behavior is handled in superclass.
if(!isscrewdriver(W) && !locked && (W.force) && (!target) && (W.damtype != STAMINA))//If the target is locked, they are recieving damage from the screwdriver
retaliate(user)
/mob/living/simple_animal/bot/secbot/emag_act(mob/user)