Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Fire Alarm item_interaction() #28136

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions code/game/machinery/firealarm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,28 @@ FIRE ALARM

/obj/machinery/firealarm/item_interaction(mob/living/user, obj/item/used, list/modifiers)
add_fingerprint(user)
if(wiresexposed)
if(buildstage == FIRE_ALARM_UNWIRED && istype(used, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/coil = used
if(!coil.use(5))
to_chat(user, "<span class='warning'>You need a total of five cables to wire [src]!</span>")
return ITEM_INTERACT_COMPLETE

buildstage = FIRE_ALARM_READY
playsound(get_turf(src), used.usesound, 50, 1)
to_chat(user, "<span class='notice'>You wire [src]!</span>")
update_icon()
else if(buildstage == FIRE_ALARM_FRAME && istype(used, /obj/item/firealarm_electronics))
to_chat(user, "<span class='notice'>You insert the circuit!</span>")
qdel(used)
buildstage = FIRE_ALARM_UNWIRED
update_icon()
if(!wiresexposed)
return ..()

if(buildstage == FIRE_ALARM_UNWIRED && istype(used, /obj/item/stack/cable_coil))
var/obj/item/stack/cable_coil/coil = used
if(!coil.use(5))
to_chat(user, "<span class='warning'>You need a total of five cables to wire [src]!</span>")
return ITEM_INTERACT_COMPLETE

buildstage = FIRE_ALARM_READY
playsound(get_turf(src), used.usesound, 50, 1)
Fordoxia marked this conversation as resolved.
Show resolved Hide resolved
to_chat(user, "<span class='notice'>You wire [src]!</span>")
update_icon()
return ITEM_INTERACT_COMPLETE

if(buildstage == FIRE_ALARM_FRAME && istype(used, /obj/item/firealarm_electronics))
to_chat(user, "<span class='notice'>You insert the circuit!</span>")
qdel(used)
buildstage = FIRE_ALARM_UNWIRED
update_icon()
return ITEM_INTERACT_COMPLETE

return ..()
Fordoxia marked this conversation as resolved.
Show resolved Hide resolved

/obj/machinery/firealarm/crowbar_act(mob/user, obj/item/I)
Expand Down Expand Up @@ -198,6 +202,7 @@ FIRE ALARM
return
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
update_icon()
WIRECUTTER_SNIP_MESSAGE
var/obj/item/stack/cable_coil/new_coil = new /obj/item/stack/cable_coil(drop_location())
new_coil.amount = 5
Expand Down