diff --git a/code/__DEFINES/shuttles.dm b/code/__DEFINES/shuttles.dm index 7277bb6fbdc..76be2fecaa2 100644 --- a/code/__DEFINES/shuttles.dm +++ b/code/__DEFINES/shuttles.dm @@ -31,6 +31,11 @@ #define EARLY_LAUNCHED 2 #define ENDGAME_TRANSIT 3 +//positive value = cannot puchase +#define SHUTTLEPURCHASE_PURCHASABLE 0 //station can buy a shuttle +#define SHUTTLEPURCHASE_PURCHASED 1 //station has already bought a shuttle, so cannot +#define SHUTTLEPURCHASE_FORCED 2 //station was given a new shuttle through events or other shenanigans + // Ripples, effects that signal a shuttle's arrival #define SHUTTLE_RIPPLE_TIME 100 diff --git a/code/controllers/subsystem/shuttle.dm b/code/controllers/subsystem/shuttle.dm index ed0b177a4ef..f989e5ff359 100644 --- a/code/controllers/subsystem/shuttle.dm +++ b/code/controllers/subsystem/shuttle.dm @@ -47,7 +47,7 @@ SUBSYSTEM_DEF(shuttle) var/datum/round_event/shuttle_loan/shuttle_loan - var/shuttle_purchased = FALSE //If the station has purchased a replacement escape shuttle this round + var/shuttle_purchased = SHUTTLEPURCHASE_PURCHASABLE //If the station has purchased a replacement escape shuttle this round var/list/shuttle_purchase_requirements_met = list() //For keeping track of ingame events that would unlock new shuttles, such as defeating a boss or discovering a secret item var/lockdown = FALSE //disallow transit after nuke goes off diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm index e9d7d75a4e9..a9b4e335aa8 100755 --- a/code/game/machinery/computer/communications.dm +++ b/code/game/machinery/computer/communications.dm @@ -159,8 +159,10 @@ if(SSshuttle.emergency.mode != SHUTTLE_RECALL && SSshuttle.emergency.mode != SHUTTLE_IDLE) to_chat(usr, "It's a bit late to buy a new shuttle, don't you think?") return - if(SSshuttle.shuttle_purchased) + if(SSshuttle.shuttle_purchased == SHUTTLEPURCHASE_PURCHASED) to_chat(usr, "A replacement shuttle has already been purchased.") + else if(SSshuttle.shuttle_purchased == SHUTTLEPURCHASE_FORCED) + to_chat(usr, "Due to unforseen circumstances, shuttle purchasing is no longer available.") else if(!S.prerequisites_met()) to_chat(usr, "You have not met the requirements for purchasing this shuttle.") else @@ -169,7 +171,7 @@ if(D) points_to_check = D.account_balance if(points_to_check >= S.credit_cost) - SSshuttle.shuttle_purchased = TRUE + SSshuttle.shuttle_purchased = SHUTTLEPURCHASE_PURCHASED SSshuttle.unload_preview() SSshuttle.load_template(S) SSshuttle.existing_shuttle = SSshuttle.emergency diff --git a/code/modules/events/shuttle_catastrophe.dm b/code/modules/events/shuttle_catastrophe.dm new file mode 100644 index 00000000000..d948b39d3bf --- /dev/null +++ b/code/modules/events/shuttle_catastrophe.dm @@ -0,0 +1,37 @@ +/datum/round_event_control/shuttle_catastrophe + name = "Shuttle Catastrophe" + typepath = /datum/round_event/shuttle_catastrophe + weight = 10 + max_occurrences = 1 + +/datum/round_event_control/shuttle_catastrophe/canSpawnEvent(players, gamemode) + if(SSshuttle.emergency.name == "Build your own shuttle kit") + return FALSE //don't undo manual player engineering, it also would unload people and ghost them, there's just a lot of problems + return ..() + + +/datum/round_event/shuttle_catastrophe + var/datum/map_template/shuttle/new_shuttle + +/datum/round_event/shuttle_catastrophe/announce(fake) + var/cause = pick("was attacked by [syndicate_name()] Operatives", "mysteriously teleported away", "had its refuelling crew mutiny", + "was found with its engines stolen", "\[REDACTED\]", "flew into the sunset, and melted", "learned something from a very wise cow, and left on its own", + "had cloning devices on it", "had its shuttle inspector put the shuttle in reverse instead of park, causing the shuttle to crash into the hangar") + + priority_announce("Your emergency shuttle [cause]. Your replacement shuttle will be the [new_shuttle.name] until further notice.", "CentCom Spacecraft Engineering") + +/datum/round_event/shuttle_catastrophe/setup() + var/list/valid_shuttle_templates = list() + for(var/shuttle_id in SSmapping.shuttle_templates) + var/datum/map_template/shuttle/template = SSmapping.shuttle_templates[shuttle_id] + if(template.can_be_bought && template.credit_cost < INFINITY) //if we could get it from the communications console, it's cool for us to get it here + valid_shuttle_templates += template + new_shuttle = pick(valid_shuttle_templates) + +/datum/round_event/shuttle_catastrophe/start() + SSshuttle.shuttle_purchased = SHUTTLEPURCHASE_FORCED + SSshuttle.unload_preview() + SSshuttle.load_template(new_shuttle) + SSshuttle.existing_shuttle = SSshuttle.emergency + SSshuttle.action_load(new_shuttle) + log_shuttle("Shuttle Catastrophe set a new shuttle, [new_shuttle.name].") diff --git a/tgstation.dme b/tgstation.dme index 7cb4d4af10d..4f32762bae8 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1874,6 +1874,7 @@ #include "code\modules\events\processor_overload.dm" #include "code\modules\events\radiation_storm.dm" #include "code\modules\events\sentience.dm" +#include "code\modules\events\shuttle_catastrophe.dm" #include "code\modules\events\shuttle_loan.dm" #include "code\modules\events\space_dragon.dm" #include "code\modules\events\spacevine.dm"