From b208a51975ba759679cbe5cf8c049d1f5ce596c8 Mon Sep 17 00:00:00 2001 From: Jordan Brown Date: Wed, 23 Aug 2017 19:39:35 -0400 Subject: [PATCH] Fixes supermatter sliver objective being given if there is no supermatter engine (#30032) * Adds /engine variants of supermatter_shard * Makes maps use /engine supermatter_shard variants * Adds a framework for ensuring an objective_item exists before giving it as a target * Fixes supermatter sliver objective being given with no supermatter engine on the map * Works around BYOND stupidity --- _maps/map_files/BoxStation/BoxStation.dmm | 2 +- _maps/map_files/Cerestation/cerestation.dmm | 2 +- .../map_files/Deltastation/DeltaStation2.dmm | 2 +- _maps/map_files/MetaStation/MetaStation.dmm | 2 +- _maps/map_files/OmegaStation/OmegaStation.dmm | 2 +- code/game/gamemodes/objective.dm | 7 ++-- code/game/gamemodes/objective_items.dm | 39 +++++++++++++++++++ code/modules/power/supermatter/supermatter.dm | 14 ++++++- 8 files changed, 61 insertions(+), 9 deletions(-) diff --git a/_maps/map_files/BoxStation/BoxStation.dmm b/_maps/map_files/BoxStation/BoxStation.dmm index ce100c807a5..e1a6d179b64 100644 --- a/_maps/map_files/BoxStation/BoxStation.dmm +++ b/_maps/map_files/BoxStation/BoxStation.dmm @@ -57251,7 +57251,7 @@ /turf/open/floor/engine, /area/engine/engineering) "cAm" = ( -/obj/machinery/power/supermatter_shard/crystal, +/obj/machinery/power/supermatter_shard/crystal/engine, /turf/open/floor/engine, /area/engine/supermatter) "cAn" = ( diff --git a/_maps/map_files/Cerestation/cerestation.dmm b/_maps/map_files/Cerestation/cerestation.dmm index 811996dbdae..f9f808e392a 100644 --- a/_maps/map_files/Cerestation/cerestation.dmm +++ b/_maps/map_files/Cerestation/cerestation.dmm @@ -28475,7 +28475,7 @@ /turf/open/floor/plating, /area/engine/supermatter) "buX" = ( -/obj/machinery/power/supermatter_shard/crystal, +/obj/machinery/power/supermatter_shard/crystal/engine, /turf/open/floor/engine{ name = "reinforced floor" }, diff --git a/_maps/map_files/Deltastation/DeltaStation2.dmm b/_maps/map_files/Deltastation/DeltaStation2.dmm index da4fe635d8e..5e0ded4416d 100644 --- a/_maps/map_files/Deltastation/DeltaStation2.dmm +++ b/_maps/map_files/Deltastation/DeltaStation2.dmm @@ -10203,7 +10203,7 @@ /turf/open/floor/plating, /area/engine/supermatter) "avQ" = ( -/obj/machinery/power/supermatter_shard/crystal, +/obj/machinery/power/supermatter_shard/crystal/engine, /turf/open/floor/engine, /area/engine/supermatter) "avR" = ( diff --git a/_maps/map_files/MetaStation/MetaStation.dmm b/_maps/map_files/MetaStation/MetaStation.dmm index 4511bfe5820..595e4922dbd 100644 --- a/_maps/map_files/MetaStation/MetaStation.dmm +++ b/_maps/map_files/MetaStation/MetaStation.dmm @@ -84203,7 +84203,7 @@ /turf/open/floor/plating, /area/engine/engineering) "dfa" = ( -/obj/machinery/power/supermatter_shard/crystal, +/obj/machinery/power/supermatter_shard/crystal/engine, /turf/open/floor/engine, /area/engine/supermatter) "dfb" = ( diff --git a/_maps/map_files/OmegaStation/OmegaStation.dmm b/_maps/map_files/OmegaStation/OmegaStation.dmm index 028c958e3e4..9a3b2b94543 100644 --- a/_maps/map_files/OmegaStation/OmegaStation.dmm +++ b/_maps/map_files/OmegaStation/OmegaStation.dmm @@ -23982,7 +23982,7 @@ /turf/open/floor/plasteel, /area/engine/engineering) "aOa" = ( -/obj/machinery/power/supermatter_shard{ +/obj/machinery/power/supermatter_shard/engine{ anchored = 1; base_icon_state = "darkmatter"; explosion_power = 20; diff --git a/code/game/gamemodes/objective.dm b/code/game/gamemodes/objective.dm index cc13d80e825..b33500db226 100644 --- a/code/game/gamemodes/objective.dm +++ b/code/game/gamemodes/objective.dm @@ -442,7 +442,8 @@ GLOBAL_LIST_EMPTY(possible_items) /datum/objective/steal/New() ..() if(!GLOB.possible_items.len)//Only need to fill the list when it's needed. - init_subtypes(/datum/objective_item/steal,GLOB.possible_items) + for(var/I in subtypesof(/datum/objective_item/steal)) + new I /datum/objective/steal/find_target() var/approved_targets = list() @@ -507,8 +508,8 @@ GLOBAL_LIST_EMPTY(possible_items_special) /datum/objective/steal/special/New() ..() if(!GLOB.possible_items_special.len) - init_subtypes(/datum/objective_item/special,GLOB.possible_items_special) - init_subtypes(/datum/objective_item/stack,GLOB.possible_items_special) + for(var/I in subtypesof(/datum/objective_item/special) + subtypesof(/datum/objective_item/stack)) + new I /datum/objective/steal/special/find_target() return set_target(pick(GLOB.possible_items_special)) diff --git a/code/game/gamemodes/objective_items.dm b/code/game/gamemodes/objective_items.dm index aa964111313..3cfede5f937 100644 --- a/code/game/gamemodes/objective_items.dm +++ b/code/game/gamemodes/objective_items.dm @@ -11,6 +11,20 @@ /datum/objective_item/proc/check_special_completion() //for objectives with special checks (is that slime extract unused? does that intellicard have an ai in it? etcetc) return 1 +/datum/objective_item/proc/TargetExists() + return TRUE + +/datum/objective_item/steal/New() + ..() + if(TargetExists()) + GLOB.possible_items += src + else + qdel(src) + +/datum/objective_item/steal/Destroy() + GLOB.possible_items -= src + return ..() + /datum/objective_item/steal/caplaser name = "the captain's antique laser gun." targetitem = /obj/item/gun/energy/laser/captain @@ -94,6 +108,9 @@ special_equipment += /obj/item/storage/box/syndie_kit/supermatter ..() +/datum/objective_item/steal/supermatter/TargetExists() + return GLOB.main_supermatter_engine != null + //Items with special checks! /datum/objective_item/steal/plasma name = "28 moles of plasma (full tank)." @@ -157,6 +174,17 @@ targetitem = /obj/item/documents/syndicate/blue difficulty = 10 +/datum/objective_item/special/New() + ..() + if(TargetExists()) + GLOB.possible_items_special += src + else + qdel(src) + +/datum/objective_item/special/Destroy() + GLOB.possible_items_special -= src + return ..() + //Old ninja objectives. /datum/objective_item/special/pinpointer name = "the captain's pinpointer." @@ -193,6 +221,17 @@ targetitem = /obj/item/reagent_containers/food/snacks/meat/slab/corgi difficulty = 5 +/datum/objective_item/stack/New() + ..() + if(TargetExists()) + GLOB.possible_items_special += src + else + qdel(src) + +/datum/objective_item/stack/Destroy() + GLOB.possible_items_special -= src + return ..() + //Stack objectives get their own subtype /datum/objective_item/stack name = "5 cardboard." diff --git a/code/modules/power/supermatter/supermatter.dm b/code/modules/power/supermatter/supermatter.dm index 5d8261be452..07cb98ea6d4 100644 --- a/code/modules/power/supermatter/supermatter.dm +++ b/code/modules/power/supermatter/supermatter.dm @@ -55,6 +55,8 @@ #define SUPERMATTER_DANGER_PERCENT 50 #define SUPERMATTER_WARNING_PERCENT 100 +GLOBAL_DATUM(main_supermatter_engine, /obj/machinery/power/supermatter_shard) + /obj/machinery/power/supermatter_shard name = "supermatter shard" desc = "A strangely translucent and iridescent crystal that looks like it used to be part of a larger structure." @@ -131,6 +133,7 @@ var/produces_gas = TRUE var/obj/effect/countdown/supermatter/countdown + var/is_main_engine = FALSE /obj/machinery/power/supermatter_shard/Initialize() . = ..() @@ -143,7 +146,8 @@ radio.listening = 0 radio.recalculateChannels() investigate_log("has been created.", INVESTIGATE_SUPERMATTER) - + if(is_main_engine) + GLOB.main_supermatter_engine = src /obj/machinery/power/supermatter_shard/Destroy() investigate_log("has been destroyed.", INVESTIGATE_SUPERMATTER) @@ -151,6 +155,8 @@ QDEL_NULL(radio) GLOB.poi_list -= src QDEL_NULL(countdown) + if(is_main_engine && GLOB.main_supermatter_engine == src) + GLOB.main_supermatter_engine = null . = ..() /obj/machinery/power/supermatter_shard/examine(mob/user) @@ -584,6 +590,9 @@ else L.show_message("You hear an unearthly ringing and notice your skin is covered in fresh radiation burns.", 2) +/obj/machinery/power/supermatter_shard/engine + is_main_engine = TRUE + // When you wanna make a supermatter shard for the dramatic effect, but // don't want it exploding suddenly /obj/machinery/power/supermatter_shard/hugbox @@ -599,6 +608,9 @@ gasefficency = 0.15 explosion_power = 35 +/obj/machinery/power/supermatter_shard/crystal/engine + is_main_engine = TRUE + /obj/machinery/power/supermatter_shard/proc/supermatter_pull(turf/center, pull_range = 10) playsound(src.loc, 'sound/weapons/marauder.ogg', 100, 1, extrarange = 7) for(var/atom/P in orange(pull_range,center))