Skip to content

Commit

Permalink
Return jump optimizations and modularity (#2520)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bokkiewokkie committed Sep 1, 2023
1 parent 1404e61 commit 348046b
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 60 deletions.
11 changes: 6 additions & 5 deletions code/controllers/subsystem/vote.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ SUBSYSTEM_DEF(vote)
factor = 1.4
choices["Initiate Crew Transfer"] += round(non_voters.len * factor)
else if(mode == "Press On Or Return Home?") //NSV13 - Round extension vote
choices["Return to Outpost 45"] += non_voters.len
if(choices["Return to Outpost 45"] >= greatest_votes)
greatest_votes = choices["Return to Outpost 45"]
var/datum/star_system/target = SSstar_system.return_system
choices["Return to [target.name]]"] += non_voters.len
if(choices["Return to [target.name]]"] >= greatest_votes)
greatest_votes = choices["Return to [target.name]"]
//get all options with that many votes and return them in a list
. = list()
if(greatest_votes)
Expand Down Expand Up @@ -182,9 +183,9 @@ SUBSYSTEM_DEF(vote)
SSovermap_mode.already_ended = FALSE
SSovermap_mode.objectives_completed = FALSE
else
priority_announce("Returning to Outpost 45") //TEMP
priority_announce("Returning to [SSstar_system.return_system.name]") //TEMP
var/obj/structure/overmap/OM = SSstar_system.find_main_overmap()
OM.force_return_jump(SSstar_system.system_by_id("Outpost 45"))
OM.force_return_jump()

if(restart)
var/active_admins = FALSE
Expand Down
3 changes: 3 additions & 0 deletions code/datums/map_config.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
var/list/omode_blacklist = list() //NSV13 - Blacklisted overmap modes - ie remove modes
var/list/omode_whitelist = list() //NSV13 - Whitelisted overmap modes - ie add modes
var/starmap_path = CONFIG_DIRECTORY + "/" + STARMAP_FILE //NSV13 - What starmap should this map load?
var/return_system = "Outpost 45" //NSV13 - Which system are we jumping back to when the round ends?
var/mine_traits = null

//NSV13 - special mapvote things
Expand Down Expand Up @@ -188,6 +189,8 @@
omode_whitelist = json["omode_whitelist"]
if("starmap_path" in json)
starmap_path = json["starmap_path"]
if("return_system" in json)
starmap_path = json["return_system"]
if("map_description" in json)
map_description = json["map_description"]
if("manufacturer" in json)
Expand Down
6 changes: 4 additions & 2 deletions code/game/machinery/computer/communications.dm
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,16 @@
log_game("[key_name(usr)] enabled emergency maintenance access.")
message_admins("[ADMIN_LOOKUPFLW(usr)] enabled emergency maintenance access.")
deadchat_broadcast("<span class='deadsay'><span class='name'>[usr.real_name]</span> enabled emergency maintenance access at <span class='name'>[get_area_name(usr, TRUE)]</span>.</span>", usr)
if("checkObjectives")
if("checkObjectives") //NSV13 overmap objectives
if (!authenticated(usr))
return
. = TRUE
state = STATE_OBJECTIVES
if(SSovermap_mode.already_ended)
return
SSovermap_mode.mode.check_completion()
if(SSovermap_mode.objectives_completed && SSovermap_mode.round_extended)
priority_announce("Auto-recall to Outpost 45 will occur once you are out of combat.", "[SSovermap_mode.mode.reminder_origin]")
state = STATE_OBJECTIVES

/obj/machinery/computer/communications/ui_data(mob/user)
var/list/data = list(
Expand Down
3 changes: 2 additions & 1 deletion nsv13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -3672,8 +3672,8 @@
#include "nsv13\code\__DEFINES\paths.dm"
#include "nsv13\code\__DEFINES\research.dm"
#include "nsv13\code\__DEFINES\robot_defines.dm"
#include "nsv13\code\__DEFINES\ships.dm"
#include "nsv13\code\__DEFINES\skynet.dm"
#include "nsv13\code\__DEFINES\starsystem.dm"
#include "nsv13\code\__DEFINES\traits.dm"
#include "nsv13\code\__DEFINES\weapons.dm"
#include "nsv13\code\__DEFINES\dcs\signals.dm"
Expand All @@ -3688,6 +3688,7 @@
#include "nsv13\code\__HELPERS\text.dm"
#include "nsv13\code\_globalvars\misc.dm"
#include "nsv13\code\_globalvars\ships.dm"
#include "nsv13\code\_globalvars\starsystem.dm"
#include "nsv13\code\_globalvars\lists\holomap.dm"
#include "nsv13\code\_globalvars\lists\names.dm"
#include "nsv13\code\_globalvars\lists\weapons.dm"
Expand Down
9 changes: 9 additions & 0 deletions nsv13/code/__DEFINES/overmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,12 @@ GLOBAL_LIST_INIT(overmap_impact_sounds, list('nsv13/sound/effects/ship/freespace
#define INTERIOR_READY 2
#define INTERIOR_DELETING 3
#define INTERIOR_DELETED 4

//Ship mass
#define MASS_TINY 1 //1 Player - Fighters
#define MASS_SMALL 2 //2-5 Players - FoB/Mining Ship
#define MASS_MEDIUM 3 //10-20 Players - Small Capital Ships
#define MASS_MEDIUM_LARGE 5 //10-20 Players - Small Capital Ships
#define MASS_LARGE 7 //20-40 Players - Medium Capital Ships
#define MASS_TITAN 150 //40+ Players - Large Capital Ships
#define MASS_IMMOBILE 200 //Things that should not be moving. See: stations
7 changes: 0 additions & 7 deletions nsv13/code/__DEFINES/ships.dm

This file was deleted.

15 changes: 15 additions & 0 deletions nsv13/code/__DEFINES/starsystem.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

//Time between each 'combat cycle' of starsystems. Every combat cycle, every system that has opposing fleets in it gets iterated through, with the fleets firing at eachother.
#define COMBAT_CYCLE_INTERVAL 180 SECONDS

//Threat level of star systems
#define THREAT_LEVEL_NONE 0
#define THREAT_LEVEL_UNSAFE 2
#define THREAT_LEVEL_DANGEROUS 4

//The different sectors, keep this updated
#define ALL_STARMAP_SECTORS 1,2,3

#define SECTOR_SOL 1
#define SECTOR_NEUTRAL 2
#define SECTOR_SYNDICATE 3
2 changes: 2 additions & 0 deletions nsv13/code/_globalvars/starsystem.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//Set when the ship successfully returns after the mission
GLOBAL_VAR_INIT(crew_transfer_risa, FALSE)
23 changes: 12 additions & 11 deletions nsv13/code/controllers/subsystem/overmap_mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,20 @@ SUBSYSTEM_DEF(overmap_mode)
objective_reminder_stacks = 0
else
var/obj/structure/overmap/OM = SSstar_system.find_main_overmap()
var/datum/star_system/S = SSstar_system.return_system
if(length(OM.current_system?.enemies_in_system))
if(objective_reminder_stacks == 3)
priority_announce("Auto-recall to Outpost 45 will occur once you are out of combat.", "[mode.reminder_origin]")
priority_announce("Auto-recall to [S.name] will occur once you are out of combat.", "[mode.reminder_origin]")
return // Don't send them home while there are enemies to kill
switch(objective_reminder_stacks) //Less Stacks Here, Prevent The Post-Round Stalling
if(1)
priority_announce("Auto-recall to Outpost 45 will occur in [(mode.objective_reminder_interval * 2) / 600] Minutes.", "[mode.reminder_origin]")
priority_announce("Auto-recall to [S.name] will occur in [(mode.objective_reminder_interval * 2) / 600] Minutes.", "[mode.reminder_origin]")

if(2)
priority_announce("Auto-recall to Outpost 45 will occur in [(mode.objective_reminder_interval * 1) / 600] Minutes.", "[mode.reminder_origin]")
priority_announce("Auto-recall to [S.name] will occur in [(mode.objective_reminder_interval * 1) / 600] Minutes.", "[mode.reminder_origin]")

else
priority_announce("Auto-recall to Outpost 45 activated, additional objective aborted.", "[mode.reminder_origin]")
priority_announce("Auto-recall to [S.name] activated, additional objective aborted.", "[mode.reminder_origin]")
mode.victory()

/datum/controller/subsystem/overmap_mode/proc/start_reminder()
Expand Down Expand Up @@ -303,7 +304,7 @@ SUBSYSTEM_DEF(overmap_mode)

/datum/controller/subsystem/overmap_mode/proc/request_additional_objectives()
for(var/datum/overmap_objective/O in mode.objectives)
O.ignore_check = TRUE //We no longer care about checking these objective against completeion
O.ignore_check = TRUE //We no longer care about checking these objective against completion

var/list/extension_pool = subtypesof(/datum/overmap_objective)
var/players = get_active_player_count(TRUE, TRUE, FALSE) //Number of living, non-AFK players including non-humanoids
Expand Down Expand Up @@ -414,6 +415,7 @@ SUBSYSTEM_DEF(overmap_mode)
return
if(SSovermap_mode.objectives_completed)
victory()
return

var/objective_length = objectives.len
var/objective_check = 0
Expand All @@ -435,9 +437,8 @@ SUBSYSTEM_DEF(overmap_mode)
SSovermap_mode.modify_threat_elevation(-TE_OBJECTIVE_THREAT_NEGATION * (successes - SSovermap_mode.highest_objective_completion))
SSovermap_mode.highest_objective_completion = successes
if(istype(SSticker.mode, /datum/game_mode/pvp)) //If the gamemode is PVP and a faction has over a 700 points, they win.
for(var/X in SSstar_system.factions)
for(var/datum/faction/F in SSstar_system.factions)
var/datum/game_mode/pvp/mode = SSticker.mode
var/datum/faction/F = X
if(F.tickets >= 700)
mode.winner = F //This should allow the mode to finish up by itself
mode.check_finished()
Expand All @@ -452,16 +453,16 @@ SUBSYSTEM_DEF(overmap_mode)
if(SSvote.mode == "Press On Or Return Home?") // We're still voting
return

var/datum/star_system/S = SSstar_system.system_by_id("Outpost 45")
var/datum/star_system/S = SSstar_system.return_system
S.hidden = FALSE
if(!SSovermap_mode.round_extended) //If we haven't yet extended the round, let us vote!
priority_announce("Mission Complete - Vote Pending") //TEMP get better words
SSvote.initiate_vote("Press On Or Return Home?", "Centcomm", forced=TRUE, popup=FALSE)
else //Begin FTL jump to Outpost 45
else //Begin FTL return jump
var/obj/structure/overmap/OM = SSstar_system.find_main_overmap()
if(!length(OM.current_system?.enemies_in_system))
priority_announce("Mission Complete - Returning to Outpost 45") //TEMP get better words
OM.force_return_jump(SSstar_system.system_by_id("Outpost 45"))
priority_announce("Mission Complete - Returning to [S.name]") //TEMP get better words
OM.force_return_jump()

/datum/overmap_gamemode/proc/defeat() //Override this if defeat is to be called based on an objective
priority_announce("Mission Critical Failure - Standby for carbon asset liquidation")
Expand Down
15 changes: 4 additions & 11 deletions nsv13/code/controllers/subsystem/starsystem.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
GLOBAL_VAR_INIT(crew_transfer_risa, FALSE)

#define COMBAT_CYCLE_INTERVAL 180 SECONDS //Time between each 'combat cycle' of starsystems. Every combat cycle, every system that has opposing fleets in it gets iterated through, with the fleets firing at eachother.

#define THREAT_LEVEL_NONE 0
#define THREAT_LEVEL_UNSAFE 2
#define THREAT_LEVEL_DANGEROUS 4

//Subsystem to control overmap events and the greater gameworld
SUBSYSTEM_DEF(star_system)
name = "star_system"
Expand All @@ -24,6 +16,7 @@ SUBSYSTEM_DEF(star_system)
var/list/neutral_zone_systems = list()
var/list/all_missions = list()
var/time_limit = FALSE //Do we want to end the round after a specific time? Mostly used for galconquest.
var/datum/star_system/return_system //Which system should we jump to at the end of the round?

var/enable_npc_combat = TRUE //If you are running an event and don't want fleets to shoot eachother, set this to false.
var/next_combat_cycle = 0
Expand Down Expand Up @@ -56,6 +49,7 @@ SUBSYSTEM_DEF(star_system)
/datum/controller/subsystem/star_system/Initialize(start_timeofday)
instantiate_systems()
. = ..()
return_system = system_by_id(SSmapping.config.return_system)
enemy_types = subtypesof(/obj/structure/overmap/syndicate/ai)
for(var/type in enemy_blacklist)
enemy_types -= type
Expand All @@ -66,7 +60,7 @@ SUBSYSTEM_DEF(star_system)
F.setup_relationships() //Set up faction relationships AFTER they're all initialised to avoid errors.

for(var/datum/star_system/S in systems) //Setup the neutral zone for easier access - Bit of overhead but better than having to search for sector 2 systems everytime we want a new neutral zone occupier)
if(S.sector != 2) //Magic numbers bad I know, but there is no sector defines.
if(S.sector != SECTOR_NEUTRAL)
continue
neutral_zone_systems += S

Expand Down Expand Up @@ -749,7 +743,7 @@ Returns a faction datum by its name (case insensitive!)
anomaly_type = /obj/effect/overmap_anomaly/singularity
parallax_property = "pitchblack"
if("blacksite") //this a special one!
adjacency_list += "Outpost 45" //you're going to risa, damnit.
adjacency_list += SSstar_system.return_system.name //you're going to risa, damnit.
SSstar_system.spawn_anomaly(/obj/effect/overmap_anomaly/wormhole, src, center=TRUE)
if(alignment == "syndicate")
spawn_enemies() //Syndicate systems are even more dangerous, and come pre-loaded with some Syndie ships.
Expand Down Expand Up @@ -1600,4 +1594,3 @@ Welcome to the endgame. This sector is the hardest you'll encounter in game and
fleet_type = /datum/fleet/border
adjacency_list = list("Rubicon", "Aeterna Victrix")

#define ALL_STARMAP_SECTORS 1,2,3 //KEEP THIS UPDATED.
2 changes: 1 addition & 1 deletion nsv13/code/game/gamemodes/overmap/armada.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
if(S.alignment == "nanotrasen")
candidate += S.name

candidate -= "Outpost 45"
candidate -= SSmapping.config.return_system
selected_system = pick(candidate)

brief = "Fleet Intelligence indicates that the Syndicate are preparing an invasion fleet to capture [selected_system], rally defences to repel the Armada by freeing up fleet assets and prepare to defend the system."
Expand Down
2 changes: 1 addition & 1 deletion nsv13/code/modules/overmap/FTL/components/drive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ Preset classes of FTL drive with pre-programmed behaviours
if(!target_system)
radio.talk_into(src, "ERROR. Specified star_system no longer exists.", radio_channel)
return
linked?.begin_jump(target_system, force)
linked.begin_jump(target_system, force)
playsound(src, 'nsv13/sound/voice/ftl_start.wav', 100, FALSE)
radio.talk_into(src, "Initiating FTL translation.", radio_channel)
playsound(src, 'nsv13/sound/effects/ship/freespace2/computer/escape.wav', 100, 1)
Expand Down
40 changes: 21 additions & 19 deletions nsv13/code/modules/overmap/FTL/ftl_jump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -146,31 +146,36 @@
desired_angle = 90 //90 degrees AKA face EAST to match the FTL parallax.
addtimer(CALLBACK(src, PROC_REF(jump_start), target_system, force), ftl_drive.ftl_startup_time)

/obj/structure/overmap/proc/force_return_jump(datum/star_system/target_system)
/obj/structure/overmap/proc/force_return_jump()
SIGNAL_HANDLER
var/datum/star_system/target_system = SSstar_system.return_system
SSovermap_mode.already_ended = TRUE
if(ftl_drive) //Do we actually have an ftl drive?
if(ftl_drive && target_system) //Do we actually have an ftl drive?
ftl_drive.lockout = TRUE //Prevent further jumps
if(ftl_drive.ftl_state == FTL_STATE_JUMPING)
addtimer(CALLBACK(src, PROC_REF(force_return_jump), target_system), 30 SECONDS)
message_admins("[src] is already jumping, delaying recall for 30 seconds")
log_runtime("DEBUG: force_return_jump: Players were already jumping, trying again in 30 seconds")
RegisterSignal(src, COMSIG_SHIP_ARRIVED, PROC_REF(force_return_jump))
message_admins("[src] is already jumping, delaying recall")
log_game("DEBUG: force_return_jump: Players were already jumping, trying again when jump is complete")
else
target_system.hidden = FALSE //Reveal where we are going

log_runtime("DEBUG: force_return_jump: Beginning jump to outpost 45")
SSstar_system.return_system.hidden = FALSE //Reveal where we are going
UnregisterSignal(src, COMSIG_SHIP_ARRIVED)
log_game("DEBUG: force_return_jump: Beginning jump to [target_system.name]")
ftl_drive.force_jump(target_system) //Jump home
addtimer(CALLBACK(src, PROC_REF(check_return_jump)), SSstar_system.ships[src]["to_time"] + 35 SECONDS)

else if(target_system)
message_admins("Failed to force return jump! [src] does not have an FTL Drive!")
log_runtime("DEBUG: force_return_jump: [src] had no FTL drive")
else
message_admins("Target does not have an FTL Drive!")
log_runtime("DEBUG: force_return_jump: Ship had no FTL drive")
message_admins("Failed to force return jump! No target system was found! (Tell a coder)")
log_runtime("DEBUG: force_return_jump: No target system")

/obj/structure/overmap/proc/check_return_jump()
log_runtime("DEBUG: check_return_jump called")
var/datum/star_system/S = SSstar_system.system_by_id("Outpost 45")
log_game("DEBUG: check_return_jump called")
var/datum/star_system/S = SSstar_system.return_system
if(current_system != S && SSstar_system.ships[src]["target_system"] != S) // Not in 45 and not on our way there
log_runtime("DEBUG: check_return_jump detected bad state, trying to force_return_jump")
force_return_jump(S)
force_return_jump()


/obj/structure/overmap/proc/force_parallax_update(ftl_start)
Expand All @@ -191,19 +196,17 @@

/obj/structure/overmap/proc/jump_start(datum/star_system/target_system, force=FALSE)
if(ftl_drive?.ftl_state != FTL_STATE_JUMPING)
if(force)
if(force && ftl_drive)
ftl_drive.ftl_state = FTL_STATE_JUMPING
else
log_runtime("DEBUG: jump_start: aborted jump to [target_system], drive state = [ftl_drive?.ftl_state]")
return
if((SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CHECK_INTERDICT, src) & BEING_INTERDICTED) && !force) // Override interdiction if the game is over
ftl_drive?.radio?.talk_into(ftl_drive, "Warning. Local energy anomaly detected - calculated jump parameters invalid. Performing emergency reboot.", ftl_drive.radio_channel)
ftl_drive.radio.talk_into(ftl_drive, "Warning. Local energy anomaly detected - calculated jump parameters invalid. Performing emergency reboot.", ftl_drive.radio_channel)
relay('sound/magic/lightning_chargeup.ogg', channel=CHANNEL_IMPORTANT_SHIP_ALERT)
ftl_drive?.depower()
log_runtime("DEBUG: jump_start: aborted jump to [target_system] due to interdiction")
ftl_drive.depower()
return

log_runtime("DEBUG: jump_start: jump to [target_system] passed initial checks")
relay_to_nearby('nsv13/sound/effects/ship/FTL.ogg', null, ignore_self=TRUE)//Ships just hear a small "crack" when another one jumps
if(reserved_z) //Actual overmap parallax behaviour
var/datum/space_level/SL = SSmapping.z_list[reserved_z]
Expand All @@ -213,7 +216,6 @@

relay(ftl_drive.ftl_loop, "<span class='warning'>You feel the ship lurch forward</span>", loop=TRUE, channel = CHANNEL_SHIP_ALERT)
var/datum/star_system/curr = SSstar_system.ships[src]["current_system"]
log_runtime("DEBUG: jump_start: starting jump to [target_system] from [curr]")
SEND_SIGNAL(src, COMSIG_SHIP_DEPARTED) // Let missions know we have left the system
curr.remove_ship(src)
var/speed = (curr.dist(target_system) / (ftl_drive.get_jump_speed() * 10)) //TODO: FTL drive speed upgrades.
Expand Down
4 changes: 2 additions & 2 deletions nsv13/code/modules/overmap/starmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@
. = TRUE
if("jump")
if(linked.ftl_drive.lockout)
visible_message("<span class='warning'>[icon2html(src, viewers(src))] Unable to comply. Invalid authkey to unlock remove override code.</span>")
to_chat(usr, "<span class='warning'>[icon2html(src, viewers(src))] Unable to comply. Invalid authkey to unlock remove override code.</span>")
return
linked.ftl_drive.jump(selected_system)
. = TRUE
if("cancel_jump")
if(linked.ftl_drive.lockout)
visible_message("<span class='warning'>[icon2html(src, viewers(src))] Unable to comply. Invalid authkey to unlock remove override code.</span>")
to_chat(usr, "<span class='warning'>[icon2html(src, viewers(src))] Unable to comply. Invalid authkey to unlock remove override code.</span>")
return
if(linked.ftl_drive.cancel_ftl())
linked.stop_relay(CHANNEL_IMPORTANT_SHIP_ALERT)
Expand Down

0 comments on commit 348046b

Please sign in to comment.