Skip to content

Commit

Permalink
Merge pull request #48 from Starfly-13/code/game/machinery/suit_stora…
Browse files Browse the repository at this point in the history
…ge_unit

Constructable Suit Storage Units part 1
  • Loading branch information
lectronyx authored Jun 12, 2024
2 parents e2e37e2 + 0cdbccd commit c7796a5
Showing 1 changed file with 65 additions and 32 deletions.
97 changes: 65 additions & 32 deletions code/game/machinery/suit_storage_unit.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define BASE_UV_CYCLES 7

// SUIT STORAGE UNIT /////////////////
/obj/machinery/suit_storage_unit
name = "suit storage unit"
Expand All @@ -7,6 +9,7 @@
base_icon_state = "ssu_classic"
density = TRUE
max_integrity = 250
circuit = /obj/item/circuitboard/machine/suit_storage_unit

var/obj/item/clothing/suit/space/suit = null
var/obj/item/clothing/head/helmet/space/helmet = null
Expand Down Expand Up @@ -40,7 +43,9 @@
*/
var/uv_super = FALSE
/// How many cycles remain for the decontamination sequence.
var/uv_cycles = 6
var/uv_cycles = 7
/// Time reduction from stock parts
var/lasers_bonus = 0
/// Cooldown for occupant breakout messages via relaymove()
var/message_cooldown
/// How long it takes to break out of the SSU.
Expand Down Expand Up @@ -191,6 +196,19 @@
storage = new storage_type(src)
update_appearance()

/obj/machinery/suit_storage_unit/examine(mob/user)
. = ..()
. += span_notice("Number of UV cycles reduced by <b>[lasers_bonus]<b>.")
if(locked)
. += span_notice("The locking bolts on \the [src] are engaged, preventing it from being pried open.")

/obj/machinery/suit_storage_unit/RefreshParts()
lasers_bonus = 0
for(var/obj/item/stock_parts/micro_laser/lasers in component_parts)
lasers_bonus += ((lasers.rating) * 0.25)

uv_cycles = BASE_UV_CYCLES - lasers_bonus

/obj/machinery/suit_storage_unit/Destroy()
QDEL_NULL(suit)
QDEL_NULL(helmet)
Expand Down Expand Up @@ -250,7 +268,15 @@
if(!(flags_1 & NODECONSTRUCT_1))
open_machine()
dump_contents()
new /obj/item/stack/sheet/metal (loc, 2)
on_deconstruction()
if(circuit)
circuit.forceMove(loc)
circuit = null
if(length(component_parts))
spawn_frame(disassembled)
for(var/obj/item/I in component_parts)
I.forceMove(loc)
component_parts.Cut()
qdel(src)

/obj/machinery/suit_storage_unit/interact(mob/living/user)
Expand Down Expand Up @@ -318,7 +344,7 @@
else
if (occupant)
var/mob/living/mob_occupant = occupant
to_chat(mob_occupant, "<span class='userdanger'>[src]'s confines grow warm, then hot, then scorching. You're being burned [!mob_occupant.stat ? "alive" : "away"]!</span>")
to_chat(mob_occupant, span_userdanger("[src]'s confines grow warm, then hot, then scorching. You're being burned [!mob_occupant.stat ? "alive" : "away"]!"))
cook()
if ("lock", "unlock")
if (!state_open)
Expand Down Expand Up @@ -364,27 +390,27 @@
return
var/mob/living/target = A
if(!state_open)
to_chat(user, "<span class='warning'>The unit's doors are shut!</span>")
to_chat(user, span_warning("The unit's doors are shut!"))
return
if(!is_operational)
to_chat(user, "<span class='warning'>The unit is not operational!</span>")
to_chat(user, span_warning("The unit is not operational!"))
return
if(occupant || helmet || suit || storage)
to_chat(user, "<span class='warning'>It's too cluttered inside to fit in!</span>")
to_chat(user, span_warning("It's too cluttered inside to fit in!"))
return

if(target == user)
user.visible_message("<span class='warning'>[user] starts squeezing into [src]!</span>", "<span class='notice'>You start working your way into [src]...</span>")
user.visible_message(span_warning("[user] starts squeezing into [src]!"), span_notice("You start working your way into [src]..."))
else
target.visible_message("<span class='warning'>[user] starts shoving [target] into [src]!</span>", "<span class='userdanger'>[user] starts shoving you into [src]!</span>")
target.visible_message(span_warning("[user] starts shoving [target] into [src]!"), span_userdanger("[user] starts shoving you into [src]!"))

if(do_mob(user, target, 30))
if(occupant || helmet || suit || storage)
return
if(target == user)
user.visible_message("<span class='warning'>[user] slips into [src] and closes the door behind [user.p_them()]!</span>", "<span class=notice'>You slip into [src]'s cramped space and shut its door.</span>")
user.visible_message(span_warning("[user] slips into [src] and closes the door behind [user.p_them()]!"), span_notice("You slip into [src]'s cramped space and shut its door."))
else
target.visible_message("<span class='warning'>[user] pushes [target] into [src] and shuts its door!</span>", "<span class='userdanger'>[user] shoves you into [src] and shuts the door!</span>")
target.visible_message(span_warning("[user] pushes [target] into [src] and shuts its door!"), span_userdanger("[user] shoves you into [src] and shuts the door!"))
close_machine(target)
add_fingerprint(user)

Expand All @@ -398,7 +424,7 @@
*/
/obj/machinery/suit_storage_unit/proc/cook()
var/mob/living/mob_occupant = occupant
if(uv_cycles)
if(uv_cycles > 0)
uv_cycles--
uv = TRUE
locked = TRUE
Expand All @@ -411,11 +437,11 @@
mob_occupant.emote("scream")
addtimer(CALLBACK(src, PROC_REF(cook)), 50)
else
uv_cycles = initial(uv_cycles)
uv_cycles = (BASE_UV_CYCLES - lasers_bonus)
uv = FALSE
locked = FALSE
if(uv_super)
visible_message("<span class='warning'>[src]'s door creaks open with a loud whining noise. A cloud of foul black smoke escapes from its chamber.</span>")
visible_message(span_warning("[src]'s door creaks open with a loud whining noise. A cloud of foul black smoke escapes from its chamber."))
playsound(src, 'sound/machines/creaking.ogg', 50, TRUE)
helmet = null
qdel(helmet)
Expand All @@ -429,9 +455,9 @@
wires.cut_all()
else
if(!occupant)
visible_message("<span class='notice'>[src]'s door slides open. The glowing yellow lights dim to a gentle green.</span>")
visible_message(span_notice("[src]'s door slides open. The glowing yellow lights dim to a gentle green."))
else
visible_message("<span class='warning'>[src]'s door slides open, barraging you with the nauseating smell of charred flesh.</span>")
visible_message(span_warning("[src]'s door slides open, barraging you with the nauseating smell of charred flesh."))
mob_occupant.radiation = 0
playsound(src, 'sound/machines/airlocks/standard/close.ogg', 25, TRUE)
var/list/things_to_clear = list() //Done this way since using GetAllContents on the SSU itself would include circuitry and such.
Expand Down Expand Up @@ -469,7 +495,7 @@
if(locked)
if(message_cooldown <= world.time)
message_cooldown = world.time + 50
to_chat(user, "<span class='warning'>[src]'s door won't budge!</span>")
to_chat(user, span_warning("[src]'s door won't budge!"))
return
open_machine()
dump_contents()
Expand All @@ -481,64 +507,64 @@
return
user.changeNext_move(CLICK_CD_BREAKOUT)
user.last_special = world.time + CLICK_CD_BREAKOUT
user.visible_message("<span class='notice'>You see [user] kicking against the doors of [src]!</span>", \
"<span class='notice'>You start kicking against the doors... (this will take about [DisplayTimeText(breakout_time)].)</span>", \
"<span class='hear'>You hear a thump from [src].</span>")
user.visible_message(span_notice("You see [user] kicking against the doors of [src]!"), \
span_notice("You start kicking against the doors... (this will take about [DisplayTimeText(breakout_time)].)"), \
span_hear("You hear a thump from [src]."))
if(do_after(user,(breakout_time), target = src))
if(!user || user.stat != CONSCIOUS || user.loc != src)
return
user.visible_message("<span class='warning'>[user] successfully broke out of [src]!</span>", \
"<span class='notice'>You successfully break out of [src]!</span>")
user.visible_message(span_warning("[user] successfully broke out of [src]!"), \
span_notice("You successfully break out of [src]!"))
open_machine()
dump_contents()

add_fingerprint(user)
if(locked)
visible_message("<span class='notice'>You see [user] kicking against the doors of [src]!</span>", \
"<span class='notice'>You start kicking against the doors...</span>")
visible_message(span_notice("You see [user] kicking against the doors of [src]!"), \
span_notice("You start kicking against the doors..."))
addtimer(CALLBACK(src, PROC_REF(resist_open), user), 300)
else
open_machine()
dump_contents()

/obj/machinery/suit_storage_unit/proc/resist_open(mob/user)
if(!state_open && occupant && (user in src) && user.stat == 0) // Check they're still here.
visible_message("<span class='notice'>You see [user] burst out of [src]!</span>", \
"<span class='notice'>You escape the cramped confines of [src]!</span>")
visible_message(span_notice("You see [user] burst out of [src]!"), \
span_notice("You escape the cramped confines of [src]!"))
open_machine()

/obj/machinery/suit_storage_unit/attackby(obj/item/I, mob/user, params)
if(state_open && is_operational)
if(istype(I, /obj/item/clothing/suit))
if(suit)
to_chat(user, "<span class='warning'>The unit already contains a suit!.</span>")
to_chat(user, span_warning("The unit already contains a suit!."))
return
if(!user.transferItemToLoc(I, src))
return
suit = I
else if(istype(I, /obj/item/clothing/head))
if(helmet)
to_chat(user, "<span class='warning'>The unit already contains a helmet!</span>")
to_chat(user, span_warning("The unit already contains a helmet!"))
return
if(!user.transferItemToLoc(I, src))
return
helmet = I
else if(istype(I, /obj/item/clothing/mask))
if(mask)
to_chat(user, "<span class='warning'>The unit already contains a mask!</span>")
to_chat(user, span_warning("The unit already contains a mask!"))
return
if(!user.transferItemToLoc(I, src))
return
mask = I
else
if(storage)
to_chat(user, "<span class='warning'>The auxiliary storage compartment is full!</span>")
to_chat(user, span_warning("The auxiliary storage compartment is full!"))
return
if(!user.transferItemToLoc(I, src))
return
storage = I

visible_message("<span class='notice'>[user] inserts [I] into [src]</span>", "<span class='notice'>You load [I] into [src].</span>")
visible_message(span_notice("[user] inserts [I] into [src]"), span_notice("You load [I] into [src]."))
update_appearance()
return

Expand All @@ -561,7 +587,7 @@
*/
/obj/machinery/suit_storage_unit/default_deconstruction_screwdriver(mob/user, icon_state_open, icon_state_closed, obj/item/I)
if(!(flags_1 & NODECONSTRUCT_1) && I.tool_behaviour == TOOL_SCREWDRIVER && uv)
to_chat(user, "<span class='warning'>It might not be wise to fiddle with [src] while it's running...</span>")
to_chat(user, span_warning("It might not be wise to fiddle with [src] while it's running..."))
return TRUE
return ..()

Expand All @@ -570,8 +596,12 @@
. = !(state_open || panel_open || is_operational || locked || (flags_1 & NODECONSTRUCT_1)) && I.tool_behaviour == TOOL_CROWBAR
if(.)
I.play_tool_sound(src, 50)
visible_message("<span class='notice'>[usr] pries open \the [src].</span>", "<span class='notice'>You pry open \the [src].</span>")
visible_message(span_notice("[usr] pries open \the [src]."), span_notice("You pry open \the [src]."))
open_machine()
// todo, make it not deconstruct while locked
if(!locked)
if(default_deconstruction_crowbar(I))
return TRUE

// Mapping helper unit takes whatever lies on top of it
/obj/machinery/suit_storage_unit/inherit/Initialize(mapload)
Expand All @@ -596,3 +626,6 @@
AM.forceMove(src)
storage = AM
update_appearance()


#undef BASE_UV_CYCLES

0 comments on commit c7796a5

Please sign in to comment.