[Testmerge ready] Ports tool behaviours; refactors all tools; adds functionality for self-filling reagent containers (#11700)

* Adds support for self-filling reagent containers

* Sets tool_behaviour on the default set of tools

* Fixing merge conflicts

* Refactors welder to use tool behaviour

* The refactor: part I

* The refactor: part II

* Tool Refactor Part III: Revenge of the Maint

* Tool Refactor Part IV: A New Hope

* Tool Refactor Part V: The Oldcoder Strikes Back

* Tool Refactor Part VI: Return of the Coder

* VII

* Holy shit, it compiles?!

* Nannek I completed your TODO, you owe me ice cream

* Tool helpers; telepad is compliant

* Bugtest, Round 1: Fight

Fuck refactoring disposals

* Buggfixing, Round 2: Electric Boogaloo

* Personal crafting uses tool behaviours now

* Construction datums use new tool behaviours; better way of handling fueltank refuelling; more bugfixing

* multitool_check_buffer change; removes some useless things in tool_helpers

* proc name change

* TRUE/FALSE changes

* Bugfixing, Round 3: A Good Day To Bugfix Hard

Fixes multiple issues raised by the testmerge

* Minor style changes
This commit is contained in:
Citinited
2020-02-15 13:31:08 -07:00
committed by GitHub
parent 5b1941e784
commit fddff1049b
238 changed files with 6681 additions and 5544 deletions
+27 -37
View File
@@ -286,42 +286,6 @@
to_chat(user, "<span class='warning'>The [src.name] needs to be unwelded from the floor.</span>")
return
if(istype(W, /obj/item/weldingtool))
var/obj/item/weldingtool/WT = W
if(active)
to_chat(user, "Turn off the [src] first.")
return
switch(state)
if(0)
to_chat(user, "<span class='warning'>The [src.name] needs to be wrenched to the floor.</span>")
if(1)
if(WT.remove_fuel(0,user))
playsound(src.loc, WT.usesound, 50, 1)
user.visible_message("[user.name] starts to weld the [src.name] to the floor.", \
"You start to weld the [src] to the floor.", \
"You hear welding")
if(do_after(user, 20 * WT.toolspeed, target = src))
if(!src || !WT.isOn()) return
state = 2
to_chat(user, "You weld the [src] to the floor.")
connect_to_network()
else
to_chat(user, "<span class='warning'>You need more welding fuel to complete this task.</span>")
if(2)
if(WT.remove_fuel(0,user))
playsound(src.loc, WT.usesound, 50, 1)
user.visible_message("[user.name] starts to cut the [src.name] free from the floor.", \
"You start to cut the [src] free from the floor.", \
"You hear welding")
if(do_after(user, 20 * WT.toolspeed, target = src))
if(!src || !WT.isOn()) return
state = 1
to_chat(user, "You cut the [src] free from the floor.")
disconnect_from_network()
else
to_chat(user, "<span class='warning'>You need more welding fuel to complete this task.</span>")
return
if(istype(W, /obj/item/card/id) || istype(W, /obj/item/pda))
if(emagged)
to_chat(user, "<span class='warning'>The lock seems to be broken</span>")
@@ -343,7 +307,7 @@
if(exchange_parts(user, W))
return
if(default_deconstruction_crowbar(W))
if(default_deconstruction_crowbar(user, W))
return
return ..()
@@ -354,3 +318,29 @@
emagged = 1
if(user)
user.visible_message("[user.name] emags the [src.name].","<span class='warning'>You short out the lock.</span>")
/obj/machinery/power/emitter/welder_act(mob/user, obj/item/I)
if(active)
to_chat(user, "<span class='notice'>Turn off [src] first.</span>")
return
if(state == 0)
to_chat(user, "<span class='warning'>[src] needs to be wrenched to the floor.</span>")
return
. = TRUE
if(!I.tool_use_check(user, 0))
return
if(state == 1)
WELDER_ATTEMPT_FLOOR_WELD_MESSAGE
else if(state == 2)
WELDER_ATTEMPT_FLOOR_SLICE_MESSAGE
if(!I.use_tool(src, user, 20, volume = I.tool_volume))
return
if(state == 1)
WELDER_FLOOR_WELD_SUCCESS_MESSAGE
connect_to_network()
state = 2
else if(state == 2)
WELDER_FLOOR_SLICE_SUCCESS_MESSAGE
disconnect_from_network()
state = 1
@@ -101,41 +101,29 @@ field_generator power level display
anchored = 0
if(FG_WELDED)
to_chat(user, "<span class='warning'>The [name] needs to be unwelded from the floor!</span>")
else if(istype(W, /obj/item/weldingtool))
var/obj/item/weldingtool/WT = W
switch(state)
if(FG_UNSECURED)
to_chat(user, "<span class='warning'>The [name] needs to be wrenched to the floor!</span>")
if(FG_SECURED)
if(WT.remove_fuel(0,user))
playsound(loc, WT.usesound, 50, 1)
user.visible_message("[user.name] starts to weld the [name] to the floor.", \
"<span class='notice'>You start to weld \the [src] to the floor...</span>", \
"<span class='italics'>You hear welding.</span>")
if(do_after(user, 20 * WT.toolspeed, target = src))
if(!src || !WT.isOn())
return
state = FG_WELDED
to_chat(user, "<span class='notice'>You weld the field generator to the floor.</span>")
if(FG_WELDED)
if(WT.remove_fuel(0,user))
playsound(loc, WT.usesound, 50, 1)
user.visible_message("[user.name] starts to cut the [name] free from the floor.", \
"<span class='notice'>You start to cut \the [src] free from the floor...</span>", \
"<span class='italics'>You hear welding.</span>")
if(do_after(user, 20 * WT.toolspeed, target = src))
if(!src || !WT.isOn())
return
state = FG_SECURED
to_chat(user, "<span class='notice'>You cut \the [src] free from the floor.</span>")
else
return ..()
/obj/machinery/field/generator/welder_act(mob/user, obj/item/I)
. = TRUE
if(state == FG_UNSECURED)
to_chat(user, "<span class='warning'>[src] needs to be wrenched to the floor!</span>")
return
if(!I.tool_use_check(user, 0))
return
if(state == FG_SECURED)
WELDER_ATTEMPT_FLOOR_SLICE_MESSAGE
else if(state == FG_WELDED)
WELDER_ATTEMPT_FLOOR_WELD_MESSAGE
if(I.use_tool(src, user, 20, volume = I.tool_volume))
if(state == FG_SECURED)
WELDER_FLOOR_SLICE_SUCCESS_MESSAGE
state = FG_WELDED
else if(state == FG_WELDED)
WELDER_FLOOR_WELD_SUCCESS_MESSAGE
state = FG_SECURED
/obj/machinery/field/generator/emp_act()
return 0
@@ -54,6 +54,10 @@ Strength being set by the computer and a null strength (Computer is powered off
So, hopefully this is helpful if any more icons are to be added/changed/wondering what the hell is going on here
*/
#define ACCELERATOR_UNWRENCHED 0
#define ACCELERATOR_WRENCHED 1
#define ACCELERATOR_WIRED 2
#define ACCELERATOR_READY 3
/obj/structure/particle_accelerator
name = "Particle Accelerator"
@@ -136,12 +140,6 @@ So, hopefully this is helpful if any more icons are to be added/changed/wonderin
desc = desc_holder
. = ..()
/obj/structure/particle_accelerator/attackby(obj/item/W, mob/user, params)
if(istool(W))
if(process_tool_hit(W,user))
return
return..()
/obj/structure/particle_accelerator/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
new /obj/item/stack/sheet/metal (loc, 5)
@@ -196,66 +194,58 @@ So, hopefully this is helpful if any more icons are to be added/changed/wonderin
return 1
return 0
/obj/structure/particle_accelerator/attackby(obj/item/W, mob/user, params)
if(!iscoil(W))
return ..()
if(construction_state == ACCELERATOR_WRENCHED)
var/obj/item/stack/cable_coil/C = W
if(C.use(1))
playsound(loc, C.usesound, 50, 1)
user.visible_message("[user.name] adds wires to the [name].", \
"You add some wires.")
construction_state = ACCELERATOR_WIRED
update_icon()
/obj/structure/particle_accelerator/proc/process_tool_hit(var/obj/item/O, var/mob/user)
if(!(O) || !(user))
return 0
if(!ismob(user) || !isobj(O))
return 0
var/temp_state = construction_state
/obj/structure/particle_accelerator/screwdriver_act(mob/user, obj/item/I)
if(construction_state != ACCELERATOR_WIRED && construction_state != ACCELERATOR_READY)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(construction_state == ACCELERATOR_WIRED)
SCREWDRIVER_CLOSE_PANEL_MESSAGE
construction_state = ACCELERATOR_READY
switch(construction_state)//TODO:Might be more interesting to have it need several parts rather than a single list of steps
if(0)
if(iswrench(O) && !isinspace())
playsound(loc, O.usesound, 50, 1)
anchored = 1
user.visible_message("[user.name] secures the [name] to the floor.", \
"You secure the external bolts.")
temp_state++
if(1)
if(iswrench(O))
playsound(loc, O.usesound, 50, 1)
anchored = 0
user.visible_message("[user.name] detaches the [name] from the floor.", \
"You remove the external bolts.")
temp_state--
else if(iscoil(O))
var/obj/item/stack/cable_coil/C = O
if(C.use(1))
playsound(loc, O.usesound, 50, 1)
user.visible_message("[user.name] adds wires to the [name].", \
"You add some wires.")
temp_state++
else
to_chat(user, "<span class='warning'>You need one length of cable to wire the [name]!</span>")
return
if(2)
if(iswirecutter(O))//TODO:Shock user if its on?
playsound(loc, O.usesound, 50, 1)
user.visible_message("[user.name] removes some wires from the [name].", \
"You remove some wires.")
temp_state--
else if(isscrewdriver(O))
playsound(loc, O.usesound, 50, 1)
user.visible_message("[user.name] closes the [name]'s access panel.", \
"You close the access panel.")
temp_state++
if(3)
if(isscrewdriver(O))
playsound(loc, O.usesound, 50, 1)
user.visible_message("[user.name] opens the [name]'s access panel.", \
"You open the access panel.")
temp_state--
if(temp_state == construction_state)//Nothing changed
return 0
else
construction_state = temp_state
if(construction_state < 3)//Was taken apart, update state
update_state()
update_icon()
return 1
return 0
construction_state = ACCELERATOR_WIRED
SCREWDRIVER_OPEN_PANEL_MESSAGE
update_state()
update_icon()
/obj/structure/particle_accelerator/wirecutter_act(mob/user, obj/item/I)
if(construction_state != ACCELERATOR_WIRED)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
WIRECUTTER_SNIP_MESSAGE
construction_state = ACCELERATOR_WRENCHED
/obj/structure/particle_accelerator/wrench_act(mob/user, obj/item/I)
if(construction_state != ACCELERATOR_UNWRENCHED && construction_state != ACCELERATOR_WRENCHED)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(construction_state == ACCELERATOR_UNWRENCHED)
anchored = TRUE
WRENCH_ANCHOR_MESSAGE
construction_state = ACCELERATOR_WRENCHED
else
anchored = FALSE
WRENCH_UNANCHOR_MESSAGE
construction_state = ACCELERATOR_UNWRENCHED
update_icon()
/obj/machinery/particle_accelerator
@@ -306,72 +296,65 @@ So, hopefully this is helpful if any more icons are to be added/changed/wonderin
return
/obj/machinery/particle_accelerator/attackby(obj/item/W, mob/user, params)
if(istool(W))
if(process_tool_hit(W,user))
return
return ..()
if(!iscoil(W))
return ..()
if(construction_state == ACCELERATOR_WRENCHED)
var/obj/item/stack/cable_coil/C = W
if(C.use(1))
playsound(loc, C.usesound, 50, 1)
user.visible_message("[user.name] adds wires to the [name].", \
"You add some wires.")
construction_state = ACCELERATOR_WIRED
update_icon()
/obj/machinery/particle_accelerator/screwdriver_act(mob/user, obj/item/I)
if(construction_state != ACCELERATOR_WIRED && construction_state != ACCELERATOR_READY)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(construction_state == ACCELERATOR_WIRED)
SCREWDRIVER_CLOSE_PANEL_MESSAGE
construction_state = ACCELERATOR_READY
use_power = IDLE_POWER_USE
else
construction_state = ACCELERATOR_WIRED
SCREWDRIVER_OPEN_PANEL_MESSAGE
use_power = NO_POWER_USE
update_state()
update_icon()
/obj/machinery/particle_accelerator/wirecutter_act(mob/user, obj/item/I)
if(construction_state != ACCELERATOR_WIRED)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
WIRECUTTER_SNIP_MESSAGE
construction_state = ACCELERATOR_WRENCHED
/obj/machinery/particle_accelerator/wrench_act(mob/user, obj/item/I)
if(construction_state != ACCELERATOR_UNWRENCHED && construction_state != ACCELERATOR_WRENCHED)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(construction_state == ACCELERATOR_UNWRENCHED)
anchored = TRUE
WRENCH_ANCHOR_MESSAGE
construction_state = ACCELERATOR_WRENCHED
else
anchored = FALSE
WRENCH_UNANCHOR_MESSAGE
construction_state = ACCELERATOR_UNWRENCHED
update_icon()
/obj/machinery/particle_accelerator/proc/update_state()
return 0
/obj/machinery/particle_accelerator/proc/process_tool_hit(var/obj/item/O, var/mob/user)
if(!(O) || !(user))
return 0
if(!ismob(user) || !isobj(O))
return 0
var/temp_state = construction_state
switch(construction_state)//TODO:Might be more interesting to have it need several parts rather than a single list of steps
if(0)
if(iswrench(O))
playsound(loc, O.usesound, 50, 1)
anchored = 1
user.visible_message("[user.name] secures the [name] to the floor.", \
"You secure the external bolts.")
temp_state++
power_change()
if(1)
if(iswrench(O))
playsound(loc, O.usesound, 50, 1)
anchored = 0
user.visible_message("[user.name] detaches the [name] from the floor.", \
"You remove the external bolts.")
temp_state--
power_change()
else if(iscoil(O))
if(O:use(1))
playsound(loc, O.usesound, 50, 1)
user.visible_message("[user.name] adds wires to the [name].", \
"You add some wires.")
temp_state++
if(2)
if(iswirecutter(O))//TODO:Shock user if its on?
playsound(loc, O.usesound, 50, 1)
user.visible_message("[user.name] removes some wires from the [name].", \
"You remove some wires.")
temp_state--
else if(isscrewdriver(O))
playsound(loc, O.usesound, 50, 1)
user.visible_message("[user.name] closes the [name]'s access panel.", \
"You close the access panel.")
temp_state++
if(3)
if(isscrewdriver(O))
playsound(loc, O.usesound, 50, 1)
user.visible_message("[user.name] opens the [name]'s access panel.", \
"You open the access panel.")
temp_state--
active = 0
if(temp_state == construction_state)//Nothing changed
return 0
else
if(construction_state < 3)//Was taken apart, update state
update_state()
if(use_power)
use_power = NO_POWER_USE
construction_state = temp_state
if(construction_state >= 3)
use_power = IDLE_POWER_USE
update_icon()
return 1
return 0
#undef ACCELERATOR_UNWRENCHED
#undef ACCELERATOR_WRENCHED
#undef ACCELERATOR_WIRED
#undef ACCELERATOR_READY