Skip to content

Commit

Permalink
Adds possibility to customize req crates
Browse files Browse the repository at this point in the history
  • Loading branch information
fira committed Nov 7, 2023
1 parent 329074c commit 97a2c28
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 24 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals/atom/signals_obj.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@

/// from /obj/proc/afterbuckle()
#define COSMIG_OBJ_AFTER_BUCKLE "signal_obj_after_buckle"

#define COMSIG_STRUCTURE_CRATE_SQUAD_LAUNCHED "structure_crate_squad_launched"
35 changes: 35 additions & 0 deletions code/datums/components/crate_tag.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/datum/component/crate_tag
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
/// The crate tag used for notifications and as label
var/name

/datum/component/crate_tag/Initialize(name, obj/structure/closet/crate/masquarade_type)
var/obj/structure/closet/crate/crate = parent
if(!istype(crate))
return COMPONENT_INCOMPATIBLE
setup(name, masquarade_type)
RegisterSignal(parent, COMSIG_STRUCTURE_CRATE_SQUAD_LAUNCHED, PROC_REF(notify_squad))

/datum/component/crate_tag/InheritComponent(datum/component/C, i_am_original, name, obj/structure/closet/crate/masquarade_type)
. = ..()
setup(name, masquarade_type)

/datum/component/crate_tag/proc/setup(name, obj/structure/closet/crate/masquarade_type)
var/obj/structure/closet/crate/crate = parent
if(masquarade_type)
crate.name = initial(masquarade_type.name)
crate.desc = initial(masquarade_type.desc)
crate.icon_opened = initial(masquarade_type.icon_opened)
crate.icon_closed = initial(masquarade_type.icon_closed)
if(crate.opened)
crate.icon_state = crate.icon_opened
else
crate.icon_state = crate.icon_closed
if(name)
parent.AddComponent(/datum/component/label, name)
src.name = name // Keep it around additionally for notifications

/datum/component/crate_tag/proc/notify_squad(datum/source, datum/squad/squad)
SIGNAL_HANDLER
squad.send_message("'[name]' supply drop incoming. Heads up!")
squad.send_maptext(name, "Incoming Supply Drop:")
14 changes: 14 additions & 0 deletions code/game/objects/structures/crates_lockers/crates.dm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
throwpass = 1 //prevents moving crates by hurling things at them
store_mobs = FALSE
var/rigged = 0
/// Types this crate can be made into
var/list/crate_customizing_types = list(
"Plain" = /obj/structure/closet/crate,
"Weapons" = /obj/structure/closet/crate/weapon,
"Supply" = /obj/structure/closet/crate/supply,
"Ammo" = /obj/structure/closet/crate/ammo,
"Construction" = /obj/structure/closet/crate/construction,
"Explosives" = /obj/structure/closet/crate/explosives,
"Alpha" = /obj/structure/closet/crate/alpha,
"Bravo" = /obj/structure/closet/crate/bravo,
"Charlie" = /obj/structure/closet/crate/charlie,
"Delta" = /obj/structure/closet/crate/delta,
)

/obj/structure/closet/crate/initialize_pass_flags(datum/pass_flags_container/PF)
..()
Expand Down Expand Up @@ -207,6 +220,7 @@
icon_state = "closed_freezer"
icon_opened = "open_freezer"
icon_closed = "closed_freezer"
crate_customizing_types = null
var/target_temp = T0C - 40
var/cooling_power = 40

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
icon_state = "secure_locked_basic"
icon_opened = "secure_open_basic"
icon_closed = "secure_locked_basic"
crate_customizing_types = null
var/icon_locked = "secure_locked_basic"
var/icon_unlocked = "secure_unlocked_basic"
var/sparks = "securecratesparks"
Expand Down
10 changes: 3 additions & 7 deletions code/modules/cm_marines/overwatch.dm
Original file line number Diff line number Diff line change
Expand Up @@ -841,18 +841,14 @@

busy = TRUE
C.visible_message(SPAN_WARNING("\The [C] loads into a launch tube. Stand clear!"))
C.anchored = TRUE //To avoid accidental pushes
current_squad.send_message("'[C.name]' supply drop incoming. Heads up!")
current_squad.send_maptext(C.name, "Incoming Supply Drop:")
var/datum/squad/S = current_squad //in case the operator changes the overwatched squad mid-drop
COOLDOWN_START(S, next_supplydrop, 500 SECONDS)
SEND_SIGNAL(C, COMSIG_STRUCTURE_CRATE_SQUAD_LAUNCHED, current_squad)
COOLDOWN_START(current_squad, next_supplydrop, 500 SECONDS)
if(ismob(usr))
var/mob/M = usr
M.count_niche_stat(STATISTICS_NICHE_CRATES)

playsound(C.loc,'sound/effects/bamf.ogg', 50, 1) //Ehh
var/obj/structure/droppod/supply/pod = new()
C.forceMove(pod)
var/obj/structure/droppod/supply/pod = new(null, C)
pod.launch(T)
visible_message("[icon2html(src, viewers(src))] [SPAN_BOLDNOTICE("'[C.name]' supply drop launched! Another launch will be available in five minutes.")]")
busy = FALSE
Expand Down
25 changes: 20 additions & 5 deletions code/modules/cm_tech/droppod/supply.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
/obj/structure/droppod/supply
name = "\improper USCM requisitions droppod"
name = "\improper USCM requisitions package"
drop_time = 10 SECONDS
dropping_time = 2 SECONDS
open_time = 2 SECONDS
var/obj/structure/package

/obj/structure/droppod/supply/Initialize(mapload, obj/structure/closet/crate/package)
. = ..()
if(!istype(package))
return INITIALIZE_HINT_QDEL
package.forceMove(src)
src.package = package

/obj/structure/droppod/supply/Destroy()
. = ..()
package = null

/* Pose as the crate so we see it falling from the skies */
/obj/structure/droppod/supply/update_icon()
. = ..()
icon = package.icon
icon_state = package.icon_state

/obj/structure/droppod/supply/open()
. = ..()
for(var/atom/movable/content as anything in contents)
///Crates are anchored when launched to avoid pushing them while launching and this created issues with them being anchored when they landed groundside.
///This unanchors them before moving them out to make sure that crates are able to be moved when groundside.
if(istype(content, /obj/structure/closet/crate))
content.anchored = FALSE
content.forceMove(loc)
package = null
qdel(src)

40 changes: 28 additions & 12 deletions code/modules/recycling/sortingmachinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
icon = 'icons/obj/items/items.dmi'
icon_state = "deliveryPaper"
w_class = SIZE_MEDIUM
var/amount = 25
var/amount = 50


/obj/item/packageWrap/afterattack(obj/target as obj, mob/user as mob, proximity)
Expand Down Expand Up @@ -267,18 +267,34 @@
SPAN_NOTICE("You wrap \the [target], leaving [amount] units of paper on \the [src]."),\
"You hear someone taping paper around a small object.")
else if (istype(target, /obj/structure/closet/crate))
var/obj/structure/closet/crate/O = target
if (src.amount > 3 && !O.opened)
var/obj/structure/bigDelivery/P = new /obj/structure/bigDelivery(get_turf(O.loc))
P.icon_state = "deliverycrate"
P.wrapped = O
O.forceMove(P)
var/obj/structure/closet/crate/crate = target
var/answer = tgui_alert(user, "Wrap the crate for delivery or customize it?", "Crate wrapping", list("Customize", "Wrap"))
if(!answer || !user.Adjacent(target) || !target.z)
return
if(answer == "Customize")
if(!length(crate.crate_customizing_types))
to_chat(user, SPAN_WARNING("You cannot customize this kind of crate."))
return
var/label = tgui_input_text(user, "Give the crate a new logistic tag:", "Customizing")
if(!label || !user.Adjacent(target) || !target.z)
return
var/chosen_type = tgui_input_list(user, "Select the kind of crate to make this into:", "Customizing", crate.crate_customizing_types)
if(!chosen_type || !ispath(crate.crate_customizing_types[chosen_type]) || !user.Adjacent(target) || !target.z)
return
target.AddComponent(/datum/component/crate_tag, label, crate.crate_customizing_types[chosen_type])
src.amount -= 3
user.visible_message("\The [user] wraps \a [target] with \a [src].",\
SPAN_NOTICE("You wrap \the [target], leaving [amount] units of paper on \the [src]."),\
"You hear someone taping paper around a large object.")
else if(src.amount < 3)
to_chat(user, SPAN_WARNING("You need more paper."))
else
if (src.amount > 3 && !crate.opened)
var/obj/structure/bigDelivery/P = new /obj/structure/bigDelivery(get_turf(crate.loc))
P.icon_state = "deliverycrate"
P.wrapped = crate
crate.forceMove(P)
src.amount -= 3
user.visible_message("\The [user] wraps \a [target] with \a [src].",\
SPAN_NOTICE("You wrap \the [target], leaving [amount] units of paper on \the [src]."),\
"You hear someone taping paper around a large object.")
else if(src.amount < 3)
to_chat(user, SPAN_WARNING("You need more paper."))
else if (istype (target, /obj/structure/closet))
var/obj/structure/closet/O = target
if (src.amount > 3 && !O.opened)
Expand Down
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@
#include "code\datums\components\bonus_damage_stack.dm"
#include "code\datums\components\cluster_stack.dm"
#include "code\datums\components\connect_mob_behalf.dm"
#include "code\datums\components\crate_tag.dm"
#include "code\datums\components\footstep.dm"
#include "code\datums\components\healing_reduction.dm"
#include "code\datums\components\id_lock.dm"
Expand Down
3 changes: 3 additions & 0 deletions maps/map_files/USS_Almayer/USS_Almayer.dmm
Original file line number Diff line number Diff line change
Expand Up @@ -42111,6 +42111,7 @@
amount = 50
},
/obj/structure/surface/rack,
/obj/item/packageWrap,
/turf/open/floor/almayer{
dir = 4;
icon_state = "green"
Expand Down Expand Up @@ -56264,6 +56265,7 @@
/obj/structure/surface/table/almayer,
/obj/effect/spawner/random/powercell,
/obj/effect/spawner/random/tool,
/obj/item/packageWrap,
/turf/open/floor/almayer{
dir = 8;
icon_state = "green"
Expand Down Expand Up @@ -77582,6 +77584,7 @@
"xfw" = (
/obj/structure/surface/table/almayer,
/obj/item/storage/fancy/cigarettes/lucky_strikes,
/obj/item/packageWrap,
/turf/open/floor/almayer{
dir = 9;
icon_state = "green"
Expand Down

0 comments on commit 97a2c28

Please sign in to comment.