|
303 | 303 | /datum/wires/ui_act(action, params) |
304 | 304 | if(..() || !interactable(usr)) |
305 | 305 | return |
| 306 | + if(!holder) // wires with no holder makes no sense to exist and probably breaks things, so catch any instances of that |
| 307 | + CRASH("[type] has no holder!") |
306 | 308 | var/target_wire = params["wire"] |
307 | | - var/mob/living/L = usr |
308 | | - var/obj/item/I |
| 309 | + var/mob/living/user = usr |
| 310 | + var/obj/item/tool |
| 311 | + var/tool_delay = max((0.5**user.get_skill(SKILL_TECHNICAL)) SECONDS, 0) |
| 312 | + if(tool_delay < 0.2 SECONDS) // effectively already instant |
| 313 | + tool_delay = 0 |
309 | 314 | switch(action) |
310 | 315 | if("cut") |
311 | | - I = (L.is_holding_tool_quality(TOOL_WIRECUTTER) || (L.is_holding_tool_quality(TOOL_WIRING) && is_cut(target_wire))) |
312 | | - if(I || IsAdminGhost(usr)) |
313 | | - if(I && holder) |
314 | | - I.play_tool_sound(holder, 20) |
| 316 | + tool = user.is_holding_tool_quality(TOOL_WIRECUTTER) |
| 317 | + if(tool?.use_tool(holder, user, tool_delay) || IsAdminGhost(usr)) |
| 318 | + tool.play_tool_sound(holder, 20) |
315 | 319 | cut_color(target_wire) |
316 | 320 | . = TRUE |
317 | | - else |
318 | | - to_chat(L, span_warning("You need wirecutters!")) |
| 321 | + else if(!tool) |
| 322 | + to_chat(user, span_warning("You need wirecutters!")) |
319 | 323 | if("pulse") |
320 | | - I = L.is_holding_tool_quality(TOOL_MULTITOOL) |
321 | | - if(I || IsAdminGhost(usr)) |
322 | | - if(I && holder) |
323 | | - I.play_tool_sound(holder, 20) |
324 | | - pulse_color(target_wire, L) |
| 324 | + tool = user.is_holding_tool_quality(TOOL_MULTITOOL) |
| 325 | + if(tool?.use_tool(holder, user, tool_delay) || IsAdminGhost(usr)) |
| 326 | + tool.play_tool_sound(holder, 20) |
| 327 | + pulse_color(target_wire, user) |
325 | 328 | . = TRUE |
326 | | - else |
327 | | - to_chat(L, span_warning("You need a multitool!")) |
| 329 | + else if(!tool) |
| 330 | + to_chat(user, span_warning("You need a multitool!")) |
328 | 331 | if("attach") |
329 | 332 | if(is_attached(target_wire)) |
330 | | - I = detach_assembly(target_wire) |
331 | | - if(I) |
332 | | - L.put_in_hands(I) |
333 | | - . = TRUE |
| 333 | + if(!do_after(user, tool_delay, holder)) |
| 334 | + return |
| 335 | + user.put_in_hands(detach_assembly(target_wire)) |
| 336 | + . = TRUE |
334 | 337 | else |
335 | | - I = L.get_active_held_item() |
336 | | - if(istype(I, /obj/item/assembly)) |
337 | | - var/obj/item/assembly/A = I |
| 338 | + tool = user.get_active_held_item() |
| 339 | + if(istype(tool, /obj/item/assembly) && tool?.use_tool(holder, user, tool_delay)) |
| 340 | + var/obj/item/assembly/A = tool |
338 | 341 | if(A.attachable) |
339 | | - if(!L.temporarilyRemoveItemFromInventory(A)) |
| 342 | + if(!user.temporarilyRemoveItemFromInventory(A)) |
340 | 343 | return |
341 | 344 | if(!attach_assembly(target_wire, A)) |
342 | | - A.forceMove(L.drop_location()) |
| 345 | + A.forceMove(user.drop_location()) |
343 | 346 | . = TRUE |
344 | 347 | else |
345 | | - to_chat(L, span_warning("You need an attachable assembly!")) |
| 348 | + to_chat(user, span_warning("You need an attachable assembly!")) |
346 | 349 |
|
347 | 350 | #undef MAXIMUM_EMP_WIRES |
0 commit comments