mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-28 23:58:07 +01:00
[MIRROR] Tool act superpack 2 [MDB IGNORE] (#11947)
* Tool act superpack 2 (#64428) About The Pull Request Continuation of #64375, extracting tool behavior from attackby() and moving it into discrete _act procs. This is about as many files as I had in the last version, as I still want this to be reviewable. As before, I've tested everything in game and it works as it previously did. Why It's Good For The Game The more code moved out of attackby, the more modular things become. Changelog cl refactor: Moves more tool behavior out of attackby(). /cl * Tool act superpack 2 Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
This commit is contained in:
@@ -180,50 +180,67 @@
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/structure/window/tool_act(mob/living/user, obj/item/tool, tool_type, is_right_clicking)
|
||||
if(!can_be_reached(user))
|
||||
return TRUE //skip the afterattack
|
||||
add_fingerprint(user)
|
||||
return ..()
|
||||
|
||||
/obj/structure/window/welder_act(mob/living/user, obj/item/tool)
|
||||
if(atom_integrity >= max_integrity)
|
||||
to_chat(user, span_warning("[src] is already in good condition!"))
|
||||
return TOOL_ACT_TOOLTYPE_SUCCESS
|
||||
if(!tool.tool_start_check(user, amount = 0))
|
||||
return FALSE
|
||||
to_chat(user, span_notice("You begin repairing [src]..."))
|
||||
if(tool.use_tool(src, user, 4 SECONDS, volume = 50))
|
||||
atom_integrity = max_integrity
|
||||
update_nearby_icons()
|
||||
to_chat(user, span_notice("You repair [src]."))
|
||||
return TOOL_ACT_TOOLTYPE_SUCCESS
|
||||
|
||||
/obj/structure/window/screwdriver_act(mob/living/user, obj/item/tool)
|
||||
if((flags_1 & NODECONSTRUCT_1) || (reinf && state >= RWINDOW_FRAME_BOLTED))
|
||||
return
|
||||
to_chat(user, span_notice("You begin to [anchored ? "unscrew the window from":"screw the window to"] the floor..."))
|
||||
if(tool.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_anchored, anchored)))
|
||||
set_anchored(!anchored)
|
||||
to_chat(user, span_notice("You [anchored ? "fasten the window to":"unfasten the window from"] the floor."))
|
||||
return TOOL_ACT_TOOLTYPE_SUCCESS
|
||||
|
||||
/obj/structure/window/wrench_act(mob/living/user, obj/item/tool)
|
||||
if(anchored)
|
||||
return FALSE
|
||||
if((flags_1 & NODECONSTRUCT_1) || (reinf && state >= RWINDOW_FRAME_BOLTED))
|
||||
return FALSE
|
||||
|
||||
to_chat(user, span_notice("You begin to disassemble [src]..."))
|
||||
if(!tool.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored)))
|
||||
return TOOL_ACT_TOOLTYPE_SUCCESS
|
||||
var/obj/item/stack/sheet/G = new glass_type(user.loc, glass_amount)
|
||||
if (!QDELETED(G))
|
||||
G.add_fingerprint(user)
|
||||
playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE)
|
||||
to_chat(user, span_notice("You successfully disassemble [src]."))
|
||||
qdel(src)
|
||||
return TOOL_ACT_TOOLTYPE_SUCCESS
|
||||
|
||||
/obj/structure/window/crowbar_act(mob/living/user, obj/item/tool)
|
||||
if(!anchored || !reinf)
|
||||
return FALSE
|
||||
if((flags_1 & NODECONSTRUCT_1) || (state != WINDOW_OUT_OF_FRAME))
|
||||
return FALSE
|
||||
to_chat(user, span_notice("You begin to lever the window into the frame..."))
|
||||
if(tool.use_tool(src, user, 10 SECONDS, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored)))
|
||||
state = RWINDOW_SECURE
|
||||
to_chat(user, span_notice("You pry the window into the frame."))
|
||||
return TOOL_ACT_TOOLTYPE_SUCCESS
|
||||
|
||||
/obj/structure/window/attackby(obj/item/I, mob/living/user, params)
|
||||
if(!can_be_reached(user))
|
||||
return TRUE //skip the afterattack
|
||||
|
||||
add_fingerprint(user)
|
||||
|
||||
if(I.tool_behaviour == TOOL_WELDER)
|
||||
if(atom_integrity < max_integrity)
|
||||
if(!I.tool_start_check(user, amount = 0))
|
||||
return
|
||||
|
||||
to_chat(user, span_notice("You begin repairing [src]..."))
|
||||
if(I.use_tool(src, user, 40, volume = 50))
|
||||
atom_integrity = max_integrity
|
||||
update_nearby_icons()
|
||||
to_chat(user, span_notice("You repair [src]."))
|
||||
else
|
||||
to_chat(user, span_warning("[src] is already in good condition!"))
|
||||
return
|
||||
|
||||
if(!(flags_1&NODECONSTRUCT_1) && !(reinf && state >= RWINDOW_FRAME_BOLTED))
|
||||
if(I.tool_behaviour == TOOL_SCREWDRIVER)
|
||||
to_chat(user, span_notice("You begin to [anchored ? "unscrew the window from":"screw the window to"] the floor..."))
|
||||
if(I.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_anchored, anchored)))
|
||||
set_anchored(!anchored)
|
||||
to_chat(user, span_notice("You [anchored ? "fasten the window to":"unfasten the window from"] the floor."))
|
||||
return
|
||||
else if(I.tool_behaviour == TOOL_WRENCH && !anchored)
|
||||
to_chat(user, span_notice("You begin to disassemble [src]..."))
|
||||
if(I.use_tool(src, user, decon_speed, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored)))
|
||||
var/obj/item/stack/sheet/G = new glass_type(user.loc, glass_amount)
|
||||
if (!QDELETED(G))
|
||||
G.add_fingerprint(user)
|
||||
playsound(src, 'sound/items/deconstruct.ogg', 50, TRUE)
|
||||
to_chat(user, span_notice("You successfully disassemble [src]."))
|
||||
qdel(src)
|
||||
return
|
||||
else if(I.tool_behaviour == TOOL_CROWBAR && reinf && (state == WINDOW_OUT_OF_FRAME) && anchored)
|
||||
to_chat(user, span_notice("You begin to lever the window into the frame..."))
|
||||
if(I.use_tool(src, user, 100, volume = 75, extra_checks = CALLBACK(src, .proc/check_state_and_anchored, state, anchored)))
|
||||
state = RWINDOW_SECURE
|
||||
to_chat(user, span_notice("You pry the window into the frame."))
|
||||
return
|
||||
|
||||
return ..()
|
||||
|
||||
/obj/structure/window/AltClick(mob/user)
|
||||
@@ -396,6 +413,7 @@
|
||||
//this is shitcode but all of construction is shitcode and needs a refactor, it works for now
|
||||
//If you find this like 4 years later and construction still hasn't been refactored, I'm so sorry for this //Adding a timestamp, I found this in 2020, I hope it's from this year -Lemon
|
||||
//2021 AND STILLLL GOING STRONG
|
||||
//2022 BABYYYYY ~lewc
|
||||
/obj/structure/window/reinforced/attackby_secondary(obj/item/tool, mob/user, params)
|
||||
switch(state)
|
||||
if(RWINDOW_SECURE)
|
||||
|
||||
Reference in New Issue
Block a user