Adds a cargo crate spawning tool for admins (#20220)

* Allows admins to create cargo crates

* AA and Miravel review

* remove debug text

* AA review

* Oops

* sirryan review

* sirryan review 2

* atom to turf
This commit is contained in:
Contrabang
2023-02-13 23:21:58 -06:00
committed by GitHub
parent f5db427bc8
commit 93f26cf5aa
4 changed files with 82 additions and 23 deletions
+2 -1
View File
@@ -116,7 +116,8 @@ GLOBAL_LIST_INIT(admin_verbs_event, list(
GLOBAL_LIST_INIT(admin_verbs_spawn, list(
/datum/admins/proc/spawn_atom, /*allows us to spawn instances*/
/client/proc/respawn_character,
/client/proc/admin_deserialize
/client/proc/admin_deserialize,
/client/proc/create_crate
))
GLOBAL_LIST_INIT(admin_verbs_server, list(
/client/proc/reload_admins,
+47
View File
@@ -1190,3 +1190,50 @@ Traitors and the like can also be revived with the previous role mostly intact.
if(!source)
return
REMOVE_TRAIT(D, chosen_trait, source)
/client/proc/create_crate(object as text)
set name = "Create Crate"
set desc = "Spawn a crate from a supplypack datum. Append a period to the text in order to exclude subtypes of paths matching the input."
set category = "Event"
if(!check_rights(R_SPAWN))
return
var/list/types = SSeconomy.supply_packs
var/list/matches = list()
var/include_subtypes = TRUE
if(copytext(object, -1) == ".")
include_subtypes = FALSE
object = copytext(object, 1, -1)
if(include_subtypes)
for(var/path in types)
if(findtext("[path]", object))
matches += path
else
var/needle_length = length(object)
for(var/path in types)
if(copytext("[path]", -needle_length) == object)
matches += path
if(!length(matches))
return
var/chosen = input("Select a supply crate type", "Create Crate", matches[1]) as null|anything in matches
if(!chosen)
return
var/datum/supply_packs/the_pack = new chosen()
var/spawn_location = get_turf(usr)
if(!spawn_location)
return
var/obj/structure/closet/crate/crate = the_pack.create_package(spawn_location)
crate.admin_spawned = TRUE
for(var/atom/A in crate.contents)
A.admin_spawned = TRUE
qdel(the_pack)
log_admin("[key_name(usr)] created a '[chosen]' crate at ([usr.x],[usr.y],[usr.z])")
SSblackbox.record_feedback("tally", "admin_verb", 1, "Create Crate") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
+6 -22
View File
@@ -27,10 +27,10 @@
return
//create the crate
var/obj/structure/closet/crate/crate = new object.containertype(_loc)
crate.name = "[object.containername] [comment ? "([comment])":"" ]"
if(object.access)
crate.req_access = list(text2num(object.access))
var/obj/structure/closet/crate/crate = object.create_package(_loc)
if(comment)
crate.name = "[crate.name] ([comment])"
//create the manifest slip
var/obj/item/paper/manifest/slip = new
@@ -52,24 +52,8 @@
slip.info += "[packagesAmt] PACKAGES IN THIS SHIPMENT<br>"
slip.info += "CONTENTS:<br><ul>"
//we now create the actual contents
var/list/contains = list()
if(istype(object, /datum/supply_packs/misc/randomised))
var/datum/supply_packs/misc/randomised/SO = object
contains = list()
if(length(object.contains))
for(var/j in 1 to SO.num_contained)
contains += pick(object.contains)
else
contains = object.contains
for(var/typepath in contains)
if(!typepath)
continue
var/atom/A = new typepath(crate)
if(object.amount && A.vars.Find("amount") && A:amount)
A:amount = object.amount
slip.info += "<li>[A.name]</li>" //add the item to the manifest (even if it was misplaced)
for(var/atom/A in crate.contents)
slip.info += "<li>[A.name]</li>"
if(istype(crate, /obj/structure/closet/critter)) // critter crates do not actually spawn mobs yet and have no contains var, but the manifest still needs to list them
var/obj/structure/closet/critter/CritCrate = crate
+27
View File
@@ -32,3 +32,30 @@
//Add the name to the UI manifest
ui_manifest += "[initial(AM.name)]"
manifest += "</ul>"
/datum/supply_packs/proc/create_package(turf/spawn_location)
var/obj/structure/closet/crate/crate = new containertype(spawn_location)
crate.name = containername
if(access)
crate.req_access = list(text2num(access))
//we now create the actual contents
for(var/typepath in generate_items())
if(!typepath)
continue
var/atom/A = new typepath(crate)
if(isstack(A))
var/obj/item/stack/mats = A
mats.amount = amount
return crate
/datum/supply_packs/proc/generate_items()
return contains
/datum/supply_packs/misc/randomised/generate_items()
. = list()
if(length(contains))
for(var/j in 1 to num_contained)
. += pick(contains)