Files
Paradise/code/game/objects/structures/extinguisher_cabinet.dm
T
warriorstar-orionandGitHub 525c68d617 Attack chain, initial setup. (pull *immediately* for *any* TM issues) (#26834)
* refactor: Attack chain, initial setup.

* migrate curtain to make dreamchecker happy

* update thurible

* don't call attacked_by separately for legacy attack chain

* remove duplicate proc

* condense similar code, put allowances for legacy code in new procs

* update docs, include diagram source

* add comment on how to update diagram

* fix admonition

* mindflayer updates

* remove commented out code

* clarify all steps

* after_attack should be overridable

* whoops

* retrofit recent changes

* duh, can't restrict this yet because of tool_acts

* i hate ore bags with the fire of a thousand suns

* return correct value for object attack logic

* Various cleanups.

We don't want to attempt to pull stuff out of `/obj/item/attackby`,
because those pieces are part of the related objects' migrations, not
`/obj/item` itself. Attempting to do this causes knockon effects where
things expected to call e.g. `/obj/item/storage/attackby` in the call
chain were not ferried over to the new item interaction code, because
the related objects hadn't actually been migrated over yet.

I've used refactoring /obj/vehicle as the example for migrating
`attackby` methods instead.

* simplify some argument names

* fuck it

* make it do the thing

* Rename CI module call

* Prove that CI works

* improve test output

* aaand fix it again

* fix curtain tool interactions

* fix compile error

* fix compile error

* Better docs, introduce migration plan tool.
2024-12-02 23:36:36 +00:00

176 lines
5.3 KiB
Plaintext

#define NO_EXTINGUISHER 0
#define NORMAL_EXTINGUISHER 1
#define MINI_EXTINGUISHER 2
/obj/structure/extinguisher_cabinet
name = "extinguisher cabinet"
desc = "A small wall mounted cabinet designed to hold a fire extinguisher. \"Don't break the glass\" is written next to the handle."
icon = 'icons/obj/closet.dmi'
icon_state = "extinguisher"
anchored = TRUE
density = FALSE
max_integrity = 200
integrity_failure = 50
var/obj/item/extinguisher/has_extinguisher = null
var/extinguishertype
var/opened = FALSE
var/material_drop = /obj/item/stack/sheet/metal
/obj/structure/extinguisher_cabinet/Initialize(mapload, direction = null)
. = ..()
name = "extinguisher cabinet"
if(direction)
setDir(direction)
set_pixel_offsets_from_dir(28, -28, 30, -30)
switch(extinguishertype)
if(NO_EXTINGUISHER)
return
if(MINI_EXTINGUISHER)
has_extinguisher = new /obj/item/extinguisher/mini(src)
else
has_extinguisher = new /obj/item/extinguisher(src)
update_icon(UPDATE_ICON_STATE)
/obj/structure/extinguisher_cabinet/examine(mob/user)
. = ..()
. += "<span class='notice'>Alt-click to [opened ? "close":"open"] it.</span>"
/obj/structure/extinguisher_cabinet/AltClick(mob/living/user)
if(!istype(user) || user.incapacitated())
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return
if(!in_range(src, user))
return
if(!iscarbon(usr) && !isrobot(usr))
return
playsound(loc, 'sound/machines/click.ogg', 15, TRUE, -3)
opened = !opened
update_icon(UPDATE_ICON_STATE)
/obj/structure/extinguisher_cabinet/Destroy()
QDEL_NULL(has_extinguisher)
return ..()
/obj/structure/extinguisher_cabinet/ex_act(severity)
if(has_extinguisher)
has_extinguisher.ex_act(severity)
..()
/obj/structure/extinguisher_cabinet/handle_atom_del(atom/A)
if(A == has_extinguisher)
has_extinguisher = null
update_icon(UPDATE_ICON_STATE)
/obj/structure/extinguisher_cabinet/attackby__legacy__attackchain(obj/item/O, mob/user, params)
if(isrobot(user) || isalien(user))
return
if(istype(O, /obj/item/extinguisher))
if(!has_extinguisher && opened)
if(!user.drop_item())
return
user.drop_item(O)
contents += O
has_extinguisher = O
update_icon(UPDATE_ICON_STATE)
to_chat(user, "<span class='notice'>You place [O] in [src].</span>")
return TRUE
else
playsound(loc, 'sound/machines/click.ogg', 15, TRUE, -3)
opened = !opened
update_icon(UPDATE_ICON_STATE)
else if(user.a_intent != INTENT_HARM)
playsound(loc, 'sound/machines/click.ogg', 15, TRUE, -3)
opened = !opened
update_icon(UPDATE_ICON_STATE)
else
return ..()
/obj/structure/extinguisher_cabinet/welder_act(mob/user, obj/item/I)
if(has_extinguisher)
to_chat(user, "<span class='warning'>You need to remove the extinguisher before deconstructing [src]!</span>")
return
if(!opened)
to_chat(user, "<span class='warning'>Open the cabinet before cutting it apart!</span>")
return
. = TRUE
if(!I.tool_use_check(user, 0))
return
WELDER_ATTEMPT_SLICING_MESSAGE
if(I.use_tool(src, user, 40, volume = I.tool_volume))
WELDER_SLICING_SUCCESS_MESSAGE
deconstruct(TRUE)
/obj/structure/extinguisher_cabinet/attack_hand(mob/user)
if(isrobot(user) || isalien(user))
to_chat(user, "<span class='notice'>You don't have the dexterity to do this!</span>")
return
if(ishuman(user))
var/mob/living/carbon/human/H = user
var/obj/item/organ/external/temp = H.bodyparts_by_name["r_hand"]
if(user.hand)
temp = H.bodyparts_by_name["l_hand"]
if(temp && !temp.is_usable())
to_chat(user, "<span class='notice'>You try to move your [temp.name], but cannot!")
return
if(has_extinguisher)
if(icon_state == "extinguisher_closed")
playsound(loc, 'sound/machines/click.ogg', 15, TRUE, -3)
user.put_in_hands(has_extinguisher)
to_chat(user, "<span class='notice'>You take [has_extinguisher] from [src].</span>")
has_extinguisher = null
opened = TRUE
else
playsound(loc, 'sound/machines/click.ogg', 15, TRUE, -3)
opened = !opened
update_icon(UPDATE_ICON_STATE)
/obj/structure/extinguisher_cabinet/attack_tk(mob/user)
if(has_extinguisher)
if(icon_state == "extinguisher_closed")
playsound(loc, 'sound/machines/click.ogg', 15, TRUE, -3)
has_extinguisher.loc = loc
to_chat(user, "<span class='notice'>You telekinetically remove [has_extinguisher] from [src].</span>")
has_extinguisher = null
opened = TRUE
else
playsound(loc, 'sound/machines/click.ogg', 15, TRUE, -3)
opened = !opened
update_icon(UPDATE_ICON_STATE)
/obj/structure/extinguisher_cabinet/obj_break(damage_flag)
if(!broken && !(flags & NODECONSTRUCT))
broken = TRUE
opened = TRUE
if(has_extinguisher)
has_extinguisher.forceMove(loc)
has_extinguisher = null
update_icon(UPDATE_ICON_STATE)
/obj/structure/extinguisher_cabinet/deconstruct(disassembled = TRUE)
if(!(flags & NODECONSTRUCT))
new /obj/item/stack/sheet/metal(loc)
if(has_extinguisher)
has_extinguisher.forceMove(loc)
has_extinguisher = null
qdel(src)
/obj/structure/extinguisher_cabinet/update_icon_state()
icon_state = "extinguisher" // Needs to reset the state with every update
if(has_extinguisher)
if(istype(has_extinguisher, /obj/item/extinguisher/mini))
icon_state += "_mini"
else
icon_state += "_full"
if(!opened)
icon_state += "_closed"
/obj/structure/extinguisher_cabinet/empty
extinguishertype = NO_EXTINGUISHER
#undef NO_EXTINGUISHER
#undef NORMAL_EXTINGUISHER
#undef MINI_EXTINGUISHER