Skip to content

Commit

Permalink
Compiling, no SD stuff yet, needs tweaking, EvacAuthority is dead
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowwolf committed Sep 11, 2023
1 parent 7f92d31 commit e38901b
Show file tree
Hide file tree
Showing 24 changed files with 263 additions and 144 deletions.
1 change: 0 additions & 1 deletion code/__DEFINES/subsystems.dm
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@
#define SS_INIT_INFLUXSTATS 11
#define SS_INIT_LIGHTING 10
#define SS_INIT_DEFCON 9
#define SS_INIT_HIJACK 7
#define SS_INIT_LAW 6
#define SS_INIT_FZ_TRANSITIONS 5
#define SS_INIT_PROJECTILES 4.1
Expand Down
180 changes: 144 additions & 36 deletions code/controllers/subsystem/hijack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
#define EVACUATION_TYPE_ADDITIVE 1
#define EVACUATION_TYPE_MULTIPLICATIVE 2

#define HIJACK_ANNOUNCE "ARES Emergency Procedures"
#define XENO_HIJACK_ANNOUNCE "You sense something unusual..."

#define EVACUATION_STATUS_NOT_INITIATED 0
#define EVACUATION_STATUS_INITIATED 1

#define HIJACK_OBJECTIVES_NOT_STARTED 0
#define HIJACK_OBJECTIVES_STARTED 1
#define HIJACK_OBJECTIVES_COMPLETE 2

SUBSYSTEM_DEF(hijack)
name = "Hijack"
wait = 2 SECONDS
flags = SS_KEEP_TIMING
init_order = SS_INIT_HIJACK
flags = SS_NO_INIT | SS_KEEP_TIMING
priority = SS_PRIORITY_HIJACK

///Required progress to evacuate safely via lifeboats
Expand Down Expand Up @@ -37,20 +46,40 @@ SUBSYSTEM_DEF(hijack)
///Holds the next % point it should be announced to xenos, increments on itself
var/xeno_announce_checkpoint = 25

///What stage of evacuation we are currently on
var/evac_status = EVACUATION_STATUS_NOT_INITIATED

///What stage of hijack are we currently on
var/hijack_status = HIJACK_OBJECTIVES_NOT_STARTED

///Whether or not evacuation has been disabled by admins
var/evac_admin_denied = FALSE

///Whether or not self destruct has been disabled by admins
//var/evac_self_destruct_denied = FALSE // Re-enable for SD stuff - Morrow

/datum/controller/subsystem/hijack/stat_entry(msg)
..()
if(!SSticker.mode.is_in_endgame)
msg += " Not Hijack"
return
if(!SSticker?.mode?.is_in_endgame)
msg = " Not Hijack"
return ..()

//Add current progress and change last fire() - Morrow
if(current_progress >= required_progress)
msg = " Complete"
return ..()

msg = " Progress: [current_progress] | Last run: [last_run_progress_change]"
return ..()

/datum/controller/subsystem/hijack/fire(resumed = FALSE)
if(!SSticker.mode.is_in_endgame)
if(!SSticker?.mode?.is_in_endgame)
return

if(hijack_status < HIJACK_OBJECTIVES_STARTED)
hijack_status = HIJACK_OBJECTIVES_STARTED

if(current_progress >= required_progress)
if(hijack_status < HIJACK_OBJECTIVES_COMPLETE)
hijack_status = HIJACK_OBJECTIVES_COMPLETE
return

if(!resumed)
Expand Down Expand Up @@ -88,50 +117,129 @@ SUBSYSTEM_DEF(hijack)
current_run_progress_additive = 0
current_run_progress_multiplicative = 1

///Called when the xeno dropship crashes into the Almayer and announces the current status of various objectives to all sides
///Called when the xeno dropship crashes into the Almayer and announces the current status of various objectives to marines
/datum/controller/subsystem/hijack/proc/announce_status_on_crash()
//todo - Morrow

/*
[b]ARES Emergency Procedures[/b]
var/message = ""

[cycled_area_name] - [status ? "Online" : "Offline"]
for(var/area/cycled_area in progress_areas)
message += "[cycled_area] - [cycled_area.power_equip ? "Online" : "Offline"]\n"

Maintain functionality for safe lifeboat evacuation.
*/
message += "\nMaintain fueling functionality for optimal lifeboat usage."

marine_announcement(message, HIJACK_ANNOUNCE)

///Called when an area power status is changed to announce that it has been changed
/datum/controller/subsystem/hijack/proc/announce_area_power_change(area/changed_area)
//todo - Morrow
var/message = "[changed_area] - [changed_area.power_equip ? "Online" : "Offline"]"

marine_announcement(message, HIJACK_ANNOUNCE)

var/status = changed_area.power_equip
///Called to announce to xenos the state of evacuation progression
/datum/controller/subsystem/hijack/proc/announce_to_xenos()
var/xeno_percent_announce = xeno_announce_checkpoint / initial(xeno_announce_checkpoint)

var/warning_areas = ""

for(var/area/cycled_area in progress_areas)
if(cycled_area.power_equip)
warning_areas += "[cycled_area], "

if(warning_areas)
warning_areas = copytext(warning_areas, 1, -2)

var/datum/hive_status/hive
for(var/hivenumber in GLOB.hive_datum)
hive = GLOB.hive_datum[hivenumber]
if(!length(hive.totalXenos))
continue

switch(xeno_percent_announce)
if(1)
xeno_announcement(SPAN_XENOANNOUNCE("The talls are a quarter of the way towards their goals. Disable the following areas: [warning_areas]"), hive.hivenumber, XENO_HIJACK_ANNOUNCE)
if(2)
xeno_announcement(SPAN_XENOANNOUNCE("The talls are half way towards their goals. Disable the following areas: [warning_areas]"), hive.hivenumber, XENO_HIJACK_ANNOUNCE)
if(3)
xeno_announcement(SPAN_XENOANNOUNCE("The talls are three quarters of the way towards their goals. Disable the following areas: [warning_areas]"), hive.hivenumber, XENO_HIJACK_ANNOUNCE)
if(4)
xeno_announcement(SPAN_XENOANNOUNCE("The talls have completed their goals!"), hive.hivenumber, XENO_HIJACK_ANNOUNCE)

/// Passes the ETA for status panels
/datum/controller/subsystem/hijack/proc/get_status_panel_eta()
switch(hijack_status)
if(HIJACK_OBJECTIVES_STARTED)
if(estimated_time_left == INFINITY)
return "Never"
return "[estimated_time_left]"

if(HIJACK_OBJECTIVES_COMPLETE)
return "Complete"



//~~~~~~~~~~~~~~~~~~~~~~~~ EVAC STUFF ~~~~~~~~~~~~~~~~~~~~~~~~//

/// Initiates evacuation by announcing and then prepping all lifepods/lifeboats
/datum/controller/subsystem/hijack/proc/initiate_evacuation()
if(evac_status == EVACUATION_STATUS_NOT_INITIATED && !(evac_admin_denied & FLAGS_EVACUATION_DENY))
evac_status = EVACUATION_STATUS_INITIATED
ai_announcement("Attention. Emergency. All personnel must evacuate immediately.", 'sound/AI/evacuate.ogg')

for(var/obj/structure/machinery/status_display/cycled_status_display in machines)
if(is_mainship_level(cycled_status_display.z))
cycled_status_display.set_picture("evac")
for(var/obj/docking_port/mobile/crashable/escape_shuttle/shuttle in SSshuttle.mobile)
shuttle.prepare_evac()
activate_lifeboats()
return TRUE

/// Cancels evacuation, tells lifepods/lifeboats and status_displays
/datum/controller/subsystem/hijack/proc/cancel_evacuation()
if(evac_status == EVACUATION_STATUS_INITIATED)
evac_status = EVACUATION_STATUS_NOT_INITIATED
deactivate_lifeboats()
ai_announcement("Evacuation has been cancelled.", 'sound/AI/evacuate_cancelled.ogg')

for(var/obj/structure/machinery/status_display/cycled_status_display in machines)
if(is_mainship_level(cycled_status_display.z))
cycled_status_display.set_sec_level_picture()

for(var/obj/docking_port/mobile/crashable/escape_shuttle/shuttle in SSshuttle.mobile)
shuttle.cancel_evac()
return TRUE

/// Opens the lifeboat doors and gets them ready to launch
/datum/controller/subsystem/hijack/proc/activate_lifeboats()
for(var/obj/docking_port/stationary/lifeboat_dock/lifeboat_dock in GLOB.lifeboat_almayer_docks)
var/obj/docking_port/mobile/crashable/lifeboat/lifeboat = lifeboat_dock.get_docked()
if(lifeboat && lifeboat.available)
lifeboat.status = LIFEBOAT_ACTIVE
lifeboat_dock.open_dock()

/// Turns off ability to manually take off lifeboats
/datum/controller/subsystem/hijack/proc/deactivate_lifeboats()
for(var/obj/docking_port/stationary/lifeboat_dock/lifeboat_dock in GLOB.lifeboat_almayer_docks)
var/obj/docking_port/mobile/crashable/lifeboat/lifeboat = lifeboat_dock.get_docked()
if(lifeboat && lifeboat.available)
lifeboat.status = LIFEBOAT_INACTIVE

/*

[b]ARES Emergency Procedures[/b]

[changed_area] - [status ? "Online" : "Offline"]

*/
/* - Morrow
/datum/controller/subsystem/hijack/proc/announce_to_xenos()
switch(xeno_announce_checkpoint / initial(xeno_announce_checkpoint))
if(1)
//Announce 25%
if(2)
//Announce 50%
if(3)
//Announce 75%
if(4)
//Announce complete
To do:
Calibrate numbers to make sure objectives don't finish too early or late
/* - Morrow
Self destruct code
Thinking something like finish main objectives and then can blow fuel resevoir as a "self destruct" via engineering and a hold
During hijack give a readout in stat for estimated time remaining until evac is fully ready as well as progress
Testing:
New nuclear bomb explosion
status display change from cancel_evacuation()
Round actually ending with get_affected_zlevel() move
Verify crash chances are working correctly for crashable shuttles
Check that emergency cryo kits work
Remove old timer for evac preparations
*/
2 changes: 2 additions & 0 deletions code/game/gamemodes/cm_self_destruct.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Regardless of where it's detonated, or how, a successful detonation will end the
All of the necessary difines are stored under mode.dm in defines.
*/

/*
var/global/datum/authority/branch/evacuation/EvacuationAuthority //This is initited elsewhere so that the world has a chance to load in.
/datum/authority/branch/evacuation
Expand Down Expand Up @@ -474,3 +475,4 @@ var/global/datum/authority/branch/evacuation/EvacuationAuthority //This is initi
icon_state = "rod_3"
active_state = SELF_DESTRUCT_MACHINE_ACTIVE
else to_chat(user, SPAN_WARNING("The control rod is not ready."))
*/
34 changes: 15 additions & 19 deletions code/game/gamemodes/colonialmarines/colonialmarines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -297,29 +297,25 @@
if(SSticker.current_state != GAME_STATE_PLAYING)
return

var/living_player_list[] = count_humans_and_xenos(EvacuationAuthority.get_affected_zlevels())
var/living_player_list[] = count_humans_and_xenos(get_affected_zlevels())
var/num_humans = living_player_list[1]
var/num_xenos = living_player_list[2]

if(force_end_at && world.time > force_end_at)
round_finished = MODE_INFESTATION_X_MINOR
if(EvacuationAuthority.dest_status == NUKE_EXPLOSION_FINISHED)
round_finished = MODE_GENERIC_DRAW_NUKE //Nuke went off, ending the round.
if(EvacuationAuthority.dest_status == NUKE_EXPLOSION_GROUND_FINISHED)
round_finished = MODE_INFESTATION_M_MINOR //Nuke went off, ending the round.
if(EvacuationAuthority.dest_status < NUKE_EXPLOSION_IN_PROGRESS) //If the nuke ISN'T in progress. We do not want to end the round before it detonates.
if(!num_humans && num_xenos) //No humans remain alive.
round_finished = MODE_INFESTATION_X_MAJOR //Evacuation did not take place. Everyone died.
else if(num_humans && !num_xenos)
if(SSticker.mode && SSticker.mode.is_in_endgame)
round_finished = MODE_INFESTATION_X_MINOR //Evacuation successfully took place.
else
SSticker.roundend_check_paused = TRUE
round_finished = MODE_INFESTATION_M_MAJOR //Humans destroyed the xenomorphs.
ares_conclude()
addtimer(VARSET_CALLBACK(SSticker, roundend_check_paused, FALSE), MARINE_MAJOR_ROUND_END_DELAY)
else if(!num_humans && !num_xenos)
round_finished = MODE_INFESTATION_DRAW_DEATH //Both were somehow destroyed.

if(!num_humans && num_xenos) //No humans remain alive.
round_finished = MODE_INFESTATION_X_MAJOR //Evacuation did not take place. Everyone died.
else if(num_humans && !num_xenos)
if(SSticker.mode && SSticker.mode.is_in_endgame)
round_finished = MODE_INFESTATION_X_MINOR //Evacuation successfully took place.
else
SSticker.roundend_check_paused = TRUE
round_finished = MODE_INFESTATION_M_MAJOR //Humans destroyed the xenomorphs.
ares_conclude()
addtimer(VARSET_CALLBACK(SSticker, roundend_check_paused, FALSE), MARINE_MAJOR_ROUND_END_DELAY)
else if(!num_humans && !num_xenos)
round_finished = MODE_INFESTATION_DRAW_DEATH //Both were somehow destroyed.

/datum/game_mode/colonialmarines/check_queen_status(hivenumber)
set waitfor = 0
Expand Down Expand Up @@ -367,7 +363,7 @@
round_statistics.current_map.total_marine_victories++
round_statistics.current_map.total_marine_majors++
if(MODE_INFESTATION_X_MINOR)
var/list/living_player_list = count_humans_and_xenos(EvacuationAuthority.get_affected_zlevels())
var/list/living_player_list = count_humans_and_xenos(get_affected_zlevels())
if(living_player_list[1] && !living_player_list[2]) // If Xeno Minor but Xenos are dead and Humans are alive, see which faction is the last standing
var/headcount = count_per_faction()
var/living = headcount["total_headcount"]
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/extended/infection.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
possible_survivors -= new_survivor //either we drafted a survivor, or we're skipping over someone, either or - remove them

/datum/game_mode/infection/check_win()
var/living_player_list[] = count_humans_and_xenos(EvacuationAuthority.get_affected_zlevels())
var/living_player_list[] = count_humans_and_xenos(get_affected_zlevels())
var/num_humans = living_player_list[1]
var/zed = living_player_list[2]

Expand Down
7 changes: 5 additions & 2 deletions code/game/gamemodes/game_mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ var/global/cas_tracking_id_increment = 0 //this var used to assign unique tracki
log_game("Server IP: [world.internet_address]:[world.port]")
return TRUE

/datum/game_mode/proc/get_affected_zlevels()
if(is_in_endgame)
. = SSmapping.levels_by_any_trait(list(ZTRAIT_MARINE_MAIN_SHIP))
return

///process()
///Called by the gameticker
Expand All @@ -118,8 +122,7 @@ var/global/cas_tracking_id_increment = 0 //this var used to assign unique tracki


/datum/game_mode/proc/check_finished() //to be called by ticker
if(EvacuationAuthority.dest_status == NUKE_EXPLOSION_FINISHED || EvacuationAuthority.dest_status == NUKE_EXPLOSION_GROUND_FINISHED )
return TRUE
return

/datum/game_mode/proc/cleanup() //This is called when the round has ended but not the game, if any cleanup would be necessary in that case.
return
Expand Down
6 changes: 3 additions & 3 deletions code/game/machinery/ARES/ARES_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ GLOBAL_LIST_INIT(maintenance_categories, list(
data["access_level"] = authentication

data["alert_level"] = security_level
data["evac_status"] = EvacuationAuthority.evac_status
data["evac_status"] = SShijack.evac_status
data["worldtime"] = world.time

data["access_log"] = list()
Expand Down Expand Up @@ -527,12 +527,12 @@ GLOBAL_LIST_INIT(maintenance_categories, list(
playsound(src, 'sound/machines/buzz-two.ogg', 15, 1)
return FALSE

if(EvacuationAuthority.flags_scuttle & FLAGS_EVACUATION_DENY)
if(SShijack.evac_admin_denied)
to_chat(usr, SPAN_WARNING("The USCM has placed a lock on deploying the evacuation pods."))
playsound(src, 'sound/machines/buzz-two.ogg', 15, 1)
return FALSE

if(!EvacuationAuthority.initiate_evacuation())
if(!SShijack.initiate_evacuation())
to_chat(usr, SPAN_WARNING("You are unable to initiate an evacuation procedure right now!"))
playsound(src, 'sound/machines/buzz-two.ogg', 15, 1)
return FALSE
Expand Down
Loading

0 comments on commit e38901b

Please sign in to comment.