refactors pods, new helper for spawning items from pods through code (#58222)

This commit is contained in:
tralezab
2021-04-13 00:37:48 -07:00
committed by GitHub
parent 9845c6be8d
commit d0eb1ce36c
10 changed files with 102 additions and 43 deletions

View File

@@ -1474,3 +1474,49 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
return "[number]-tuple" return "[number]-tuple"
#define TURF_FROM_COORDS_LIST(List) (locate(List[1], List[2], List[3])) #define TURF_FROM_COORDS_LIST(List) (locate(List[1], List[2], List[3]))
/**
* One proc for easy spawning of pods in the code to drop off items before whizzling (please don't proc call this in game, it will destroy you)
*
* Arguments:
* * specifications: special mods to the pod, see non var edit specifications for details on what you should fill this with
* Non var edit specifications:
* * target = where you want the pod to drop
* * path = a special specific pod path if you want, this can save you a lot of var edits
* * style = style of the pod, defaults to the normal pod
* * spawn = spawned path or a list of the paths spawned, what you're sending basically
* Returns the pod spawned, in case you want to spawn items yourself and modify them before putting them in.
*/
/proc/podspawn(specifications)
//get non var edit specifications
var/turf/landing_location = specifications["target"]
var/spawn_type = specifications["path"]
var/style = specifications["style"]
var/list/paths_to_spawn = specifications["spawn"]
//setup pod, add contents
if(!isturf(landing_location))
landing_location = get_turf(landing_location)
if(!spawn_type)
spawn_type = /obj/structure/closet/supplypod/podspawn
var/obj/structure/closet/supplypod/podspawn/pod = new spawn_type(null, style)
if(!islist(paths_to_spawn))
paths_to_spawn = list(paths_to_spawn)
for(var/atom/path as anything in paths_to_spawn)
path = new path(pod)
//remove non var edits from specifications
specifications -= landing_location
specifications -= style
specifications -= spawn_type
specifications -= paths_to_spawn
//rest of specificiations are edits on the pod
for(var/variable_name in specifications)
var/variable_value = specifications[variable_name]
if(!pod.vv_edit_var(variable_name, variable_value))
stack_trace("WARNING! podspawn vareditting \"[variable_name]\" to \"[variable_value]\" was rejected by the pod!")
new /obj/effect/pod_landingzone(landing_location, pod)
return pod

View File

@@ -72,10 +72,12 @@ GLOBAL_LIST_INIT(skill_types, subtypesof(/datum/skill))
if (LAZYFIND(mind.skills_rewarded, src.type)) if (LAZYFIND(mind.skills_rewarded, src.type))
to_chat(mind.current, "<span class='nicegreen'>It seems the Professional [title] Association won't send me another status symbol.</span>") to_chat(mind.current, "<span class='nicegreen'>It seems the Professional [title] Association won't send me another status symbol.</span>")
return return
var/obj/structure/closet/supplypod/bluespacepod/pod = new() podspawn(list(
pod.delays[POD_TRANSIT] = 150 "target" = get_turf(mind.current),
pod.explosionSize = list(0,0,0,0) "path" = /obj/structure/closet/supplypod/mechpod,
"style" = STYLE_BLUESPACE,
"spawn" = skill_cape_path,
"delays" = list(POD_TRANSIT = 150, POD_FALLING = 4, POD_OPENING = 30, POD_LEAVING = 30)
))
to_chat(mind.current, "<span class='nicegreen'>My legendary skill has attracted the attention of the Professional [title] Association. It seems they are sending me a status symbol to commemorate my abilities.</span>") to_chat(mind.current, "<span class='nicegreen'>My legendary skill has attracted the attention of the Professional [title] Association. It seems they are sending me a status symbol to commemorate my abilities.</span>")
var/turf/T = get_turf(mind.current)
new /obj/effect/pod_landingzone(T, pod , new skill_cape_path(T))
LAZYADD(mind.skills_rewarded, src.type) LAZYADD(mind.skills_rewarded, src.type)

View File

@@ -111,13 +111,15 @@
return return
say("Thank you for your purchase! Please note: The charge of this purchase and machine cooldown has been doubled!") say("Thank you for your purchase! Please note: The charge of this purchase and machine cooldown has been doubled!")
COOLDOWN_START(src, order_cooldown, 120 SECONDS) COOLDOWN_START(src, order_cooldown, 120 SECONDS)
var/obj/structure/closet/supplypod/bluespacepod/pod = new() var/list/ordered_paths = list()
pod.explosionSize = list(0,0,0,0)
for(var/datum/orderable_item/item as anything in grocery_list)//every order for(var/datum/orderable_item/item as anything in grocery_list)//every order
for(var/amt in 1 to grocery_list[item])//every order amount for(var/amt in 1 to grocery_list[item])//every order amount
new item.item_instance.type(pod) ordered_paths += item.item_instance.type
var/turf/landing_location = get_turf(chef) podspawn(list(
new /obj/effect/pod_landingzone(landing_location, pod) "target" = get_turf(chef),
"style" = STYLE_BLUESPACE,
"spawn" = ordered_paths
))
grocery_list.Cut() grocery_list.Cut()
update_static_data(chef) update_static_data(chef)
. = TRUE . = TRUE

View File

@@ -53,10 +53,13 @@
* * where - where the supply pod will land after grabbing the mech * * where - where the supply pod will land after grabbing the mech
*/ */
/obj/machinery/mechpad/proc/launch(obj/machinery/mechpad/where) /obj/machinery/mechpad/proc/launch(obj/machinery/mechpad/where)
var/obj/structure/closet/supplypod/mechpod/pod = new() var/turf/reverse_turf = get_turf(where)
var/turf/target_turf = get_turf(where) podspawn(list(
pod.reverse_dropoff_coords = list(target_turf.x, target_turf.y, target_turf.z) "target" = get_turf(src),
new /obj/effect/pod_landingzone(get_turf(src), pod) "path" = /obj/structure/closet/supplypod/mechpod,
"style" = STYLE_SEETHROUGH,
"reverse_dropoff_coords" = list(reverse_turf.x, reverse_turf.y, reverse_turf.z)
))
/obj/structure/closet/supplypod/mechpod /obj/structure/closet/supplypod/mechpod
style = STYLE_SEETHROUGH style = STYLE_SEETHROUGH

View File

@@ -51,9 +51,11 @@
to_chat(M, "<span class='notice'>[uses] use[uses > 1 ? "s" : ""] remaining on the [src].</span>") to_chat(M, "<span class='notice'>[uses] use[uses > 1 ? "s" : ""] remaining on the [src].</span>")
/obj/item/choice_beacon/proc/spawn_option(obj/choice,mob/living/M) /obj/item/choice_beacon/proc/spawn_option(obj/choice,mob/living/M)
var/obj/structure/closet/supplypod/bluespacepod/pod = new() podspawn(list(
new choice(pod) "target" = get_turf(src),
pod.explosionSize = list(0,0,0,0) "style" = STYLE_BLUESPACE,
"spawn" = choice,
))
var/msg = "<span class=danger>After making your selection, you notice a strange target on the ground. It might be best to step back!</span>" var/msg = "<span class=danger>After making your selection, you notice a strange target on the ground. It might be best to step back!</span>"
if(ishuman(M)) if(ishuman(M))
var/mob/living/carbon/human/H = M var/mob/living/carbon/human/H = M
@@ -61,8 +63,6 @@
msg = "You hear something crackle in your ears for a moment before a voice speaks. \"Please stand by for a message from Central Command. Message as follows: <span class='bold'>Item request received. Your package is inbound, please stand back from the landing site.</span> Message ends.\"" msg = "You hear something crackle in your ears for a moment before a voice speaks. \"Please stand by for a message from Central Command. Message as follows: <span class='bold'>Item request received. Your package is inbound, please stand back from the landing site.</span> Message ends.\""
to_chat(M, msg) to_chat(M, msg)
new /obj/effect/pod_landingzone(get_turf(src), pod)
/obj/item/choice_beacon/ingredient /obj/item/choice_beacon/ingredient
name = "ingredient delivery beacon" name = "ingredient delivery beacon"
desc = "Summon a box of ingredients to help you get started cooking." desc = "Summon a box of ingredients to help you get started cooking."

View File

@@ -713,15 +713,18 @@
var/chosen = pick_closest_path(object) var/chosen = pick_closest_path(object)
if(!chosen) if(!chosen)
return return
var/turf/T = get_turf(usr) var/turf/target_turf = get_turf(usr)
if(ispath(chosen, /turf)) if(ispath(chosen, /turf))
T.ChangeTurf(chosen) target_turf.ChangeTurf(chosen)
else else
var/obj/structure/closet/supplypod/centcompod/pod = new() var/obj/structure/closet/supplypod/pod = podspawn(list(
"target" = target_turf,
"path" = /obj/structure/closet/supplypod/centcompod,
))
//we need to set the admin spawn flag for the spawned items so we do it outside of the podspawn proc
var/atom/A = new chosen(pod) var/atom/A = new chosen(pod)
A.flags_1 |= ADMIN_SPAWNED_1 A.flags_1 |= ADMIN_SPAWNED_1
new /obj/effect/pod_landingzone(T, pod)
log_admin("[key_name(usr)] pod-spawned [chosen] at [AREACOORD(usr)]") log_admin("[key_name(usr)] pod-spawned [chosen] at [AREACOORD(usr)]")
SSblackbox.record_feedback("tally", "admin_verb", 1, "Podspawn Atom") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! SSblackbox.record_feedback("tally", "admin_verb", 1, "Podspawn Atom") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!

View File

@@ -34,16 +34,15 @@
/datum/smite/supply_pod_quick/effect(client/user, mob/living/target) /datum/smite/supply_pod_quick/effect(client/user, mob/living/target)
. = ..() . = ..()
podspawn(list(
var/obj/structure/closet/supplypod/centcompod/pod = new "target" = get_turf(target),
pod.damage = SUPPLY_POD_QUICK_DAMAGE "path" = /obj/structure/closet/supplypod/centcompod,
pod.explosionSize = list(0, 0, 0, SUPPLY_POD_QUICK_FIRE_RANGE) "style" = STYLE_CENTCOM,
pod.effectStun = TRUE "spawn" = target_path,
"damage" = SUPPLY_POD_QUICK_DAMAGE,
if (!isnull(target_path)) "explosionSize" = list(0, 0, 0, SUPPLY_POD_QUICK_FIRE_RANGE),
new target_path(pod) "effectStun" = TRUE
))
new /obj/effect/pod_landingzone(get_turf(target), pod)
#undef SUPPLY_POD_QUICK_DAMAGE #undef SUPPLY_POD_QUICK_DAMAGE
#undef SUPPLY_POD_QUICK_FIRE_RANGE #undef SUPPLY_POD_QUICK_FIRE_RANGE

View File

@@ -389,11 +389,11 @@
LAZYADD(rev_mind.special_statuses, "<span class='bad'>Former head revolutionary</span>") LAZYADD(rev_mind.special_statuses, "<span class='bad'>Former head revolutionary</span>")
if(!charter_given && rev_mind.current && rev_mind.current.stat == CONSCIOUS) if(!charter_given && rev_mind.current && rev_mind.current.stat == CONSCIOUS)
charter_given = TRUE charter_given = TRUE
var/obj/structure/closet/supplypod/bluespacepod/syndicate/pod = new() podspawn(list(
pod.explosionSize = list(0,0,0,0) "target" = get_turf(rev_mind.current),
new /obj/item/station_charter/revolution(pod) "style" = STYLE_SYNDICATE,
var/turf/landing_location = get_turf(rev_mind.current) "spawn" = /obj/item/station_charter/revolution
new /obj/effect/pod_landingzone(landing_location, pod) ))
to_chat(rev_mind.current, "<span class='hear'>You hear something crackle in your ears for a moment before a voice speaks. \ to_chat(rev_mind.current, "<span class='hear'>You hear something crackle in your ears for a moment before a voice speaks. \
\"Please stand by for a message from your benefactor. Message as follows, provocateur. \ \"Please stand by for a message from your benefactor. Message as follows, provocateur. \
<b>You have been chosen out of your fellow provocateurs to rename the station. Choose wisely.</b> Message ends.\"</span>") <b>You have been chosen out of your fellow provocateurs to rename the station. Choose wisely.</b> Message ends.\"</span>")

View File

@@ -64,8 +64,10 @@
bluespace = TRUE bluespace = TRUE
explosionSize = list(0,0,1,2) explosionSize = list(0,0,1,2)
/obj/structure/closet/supplypod/bluespacepod/syndicate //type used for one drop spawning items. doesn't have a style as style is set by the helper that creates this
style = STYLE_SYNDICATE /obj/structure/closet/supplypod/podspawn
bluespace = TRUE
explosionSize = list(0,0,0,0)
/obj/structure/closet/supplypod/extractionpod /obj/structure/closet/supplypod/extractionpod
name = "Syndicate Extraction Pod" name = "Syndicate Extraction Pod"

View File

@@ -179,9 +179,11 @@ GLOBAL_LIST_EMPTY(exodrone_launchers)
/// Crashes the drone somewhere random if there's no launchpad to be found. /// Crashes the drone somewhere random if there's no launchpad to be found.
/obj/item/exodrone/proc/drop_somewhere_on_station() /obj/item/exodrone/proc/drop_somewhere_on_station()
var/turf/random_spot = get_safe_random_station_turf() var/turf/random_spot = get_safe_random_station_turf()
var/obj/structure/closet/supplypod/pod = new
pod.bluespace = TRUE var/obj/structure/closet/supplypod/pod = podspawn(list(
new /obj/effect/pod_landingzone(random_spot, pod, src) "target" = random_spot,
))
forceMove(pod)
return random_spot return random_spot
/// Tries to find landing pad, starting with the one we launched from. /// Tries to find landing pad, starting with the one we launched from.