Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emergency Jumps #2722

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion code/__DEFINES/nsv13.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ GLOBAL_DATUM_INIT(conquest_role_handler, /datum/conquest_role_handler, new)

#define COMSIG_SHIP_BOARDED "ship_boarded"
#define COMSIG_GLOB_CHECK_INTERDICT "check_interdict" //from interdiction component
#define BEING_INTERDICTED (1<<0) //returned on successful interdict
#define WEAK_INTERDICT (1<<0) //! Not a "true" interdiction in that it disrupts the drive field, relies on scrambling calculations and rendering a jump too dangerous to execute.
#define STRONG_INTERDICT (1<<1) //! The "true" interdiction, disrupts drive fields to the point any shift is impossible.

//Gaming
#define shares_overmap(A, B) (A.get_overmap() == B.get_overmap())
Expand Down
35 changes: 35 additions & 0 deletions code/modules/security_levels/keycard_authentication.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ GLOBAL_DATUM_INIT(keycard_events, /datum/events, new)
#define KEYCARD_RED_ALERT "Red Alert"
#define KEYCARD_EMERGENCY_MAINTENANCE_ACCESS "Emergency Maintenance Access"
#define KEYCARD_BSA_UNLOCK "Bluespace Artillery Unlock"
//NSV13
#define KEYCARD_FTL_SAFETY_OVERRIDE "FTL Safety Override"
//NSV13 end.

/obj/machinery/keycard_auth
name = "Keycard Authentication Device"
Expand Down Expand Up @@ -52,6 +55,13 @@ GLOBAL_DATUM_INIT(keycard_events, /datum/events, new)
data["red_alert"] = (seclevel2num(get_security_level()) >= SEC_LEVEL_RED) ? 1 : 0
data["emergency_maint"] = GLOB.emergency_access
data["bsa_unlock"] = GLOB.bsa_unlock
//NSV13 - emergency FTL
var/ftl_state = -1 // -1 = not overmap; 0 = Safe; 1 = Unsafe.
var/obj/structure/overmap/current_overmap = get_overmap()
if(current_overmap)
ftl_state = current_overmap.ftl_safety_override
data["ftl_safety_override"] = ftl_state
//NSV13 end
return data

/obj/machinery/keycard_auth/ui_status(mob/user)
Expand All @@ -76,13 +86,24 @@ GLOBAL_DATUM_INIT(keycard_events, /datum/events, new)
. = TRUE
if("auth_swipe")
if(event_source)
//NSV13 - cross overmap safety even if the other things don't have it (we can have a subtype for syndi vessels that doesn't have the other options?).
var/overmap1 = event_source.get_overmap()
var/overmap2 = get_overmap()
if(overmap1 != overmap2)
return TRUE
//NSV13 end.
event_source.trigger_event(usr)
event_source = null
. = TRUE
if("bsa_unlock")
if(!event_source)
sendEvent(KEYCARD_BSA_UNLOCK)
. = TRUE
if("ftl_safety_override")
if(!event_source)
sendEvent(KEYCARD_FTL_SAFETY_OVERRIDE)
. = TRUE


/obj/machinery/keycard_auth/proc/sendEvent(event_type)
triggerer = usr
Expand Down Expand Up @@ -121,6 +142,8 @@ GLOBAL_DATUM_INIT(keycard_events, /datum/events, new)
make_maint_all_access()
if(KEYCARD_BSA_UNLOCK)
toggle_bluespace_artillery()
if(KEYCARD_FTL_SAFETY_OVERRIDE)
toggle_ftl_drive_safety(get_overmap())

GLOBAL_VAR_INIT(emergency_access, FALSE)
/proc/make_maint_all_access()
Expand Down Expand Up @@ -148,6 +171,18 @@ GLOBAL_VAR_INIT(emergency_access, FALSE)
minor_announce("Bluespace Artillery firing protocols have been [GLOB.bsa_unlock? "unlocked" : "locked"]", "Weapons Systems Update:")
SSblackbox.record_feedback("nested tally", "keycard_auths", 1, list("bluespace artillery", GLOB.bsa_unlock? "unlocked" : "locked"))

///NSV13 - toggles FTL safety mode of a passed vessel.
/proc/toggle_ftl_drive_safety(obj/structure/overmap/target)
if(QDELETED(target))
return
target.ftl_safety_override = !target.ftl_safety_override
if(target.ftl_safety_override) //Safety disengaged.
target.relay('nsv13/sound/misc/triple_boop_alert.ogg',"<h1 class='alert'>FTL Drive System Notice</h1><span class='alert'>FTL Drive Safeties disengaged. Drive reverting to manual control.</span><br>")
else //Safety reengaged.
target.relay('sound/misc/notice2.ogg', "<h1 class='alert'>FTL Drive System Notice</h1><span class='alert'>FTL Drive Safeties restored.</span><br>")
//NSV13 end.

#undef KEYCARD_RED_ALERT
#undef KEYCARD_EMERGENCY_MAINTENANCE_ACCESS
#undef KEYCARD_BSA_UNLOCK
#undef KEYCARD_FTL_SAFETY_OVERRIDE
2 changes: 2 additions & 0 deletions nsv13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -4045,6 +4045,8 @@
#include "nsv13\code\modules\overmap\FTL\ftl_legacy.dm"
#include "nsv13\code\modules\overmap\FTL\components\drive.dm"
#include "nsv13\code\modules\overmap\FTL\components\drive_pylon.dm"
#include "nsv13\code\modules\overmap\FTL\ftl_jump_mishaps\jump_mishap_helpers.dm"
#include "nsv13\code\modules\overmap\FTL\ftl_jump_mishaps\phase_ghost.dm"
#include "nsv13\code\modules\overmap\ship_areas\badmiral.dm"
#include "nsv13\code\modules\overmap\types\miningships.dm"
#include "nsv13\code\modules\overmap\types\nanotrasen.dm"
Expand Down
5 changes: 5 additions & 0 deletions nsv13/code/__DEFINES/overmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,10 @@ GLOBAL_LIST_INIT(overmap_impact_sounds, list('nsv13/sound/effects/ship/freespace
#define SHIELD_FORCE_DEFLECT 2 //!Shield absorbed hit and is redirecting projectile with slightly turned vector.
#define SHIELD_FORCE_REFLECT 3 //!Shield absorbed hit and is redirecting projectile in reverse direction.

//Emergency FTL stuff.

#define EMERGENCY_FTL_RANGE 120 //! Range of Emergency FTL jump (uncontrolled)
#define EMERGENCY_FTL_COOLDOWN 35 MINUTES //!Cooldown of FTL drives between emergency jumps.

//Interior instancing comsig, aka cursed things.
#define COMSIG_INTERIOR_DONE_LOADING "interior_done_loading"
34 changes: 32 additions & 2 deletions nsv13/code/modules/overmap/FTL/components/drive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@

var/ftl_state = FTL_STATE_IDLE

///world.time until which an user can confirm the emergency jump triggered by Nav.
var/await_emergency_ftl_confirm = 0

/obj/machinery/computer/ship/ftl_core/Initialize(mapload)
. = ..()
add_overlay("screen")
Expand Down Expand Up @@ -202,6 +205,16 @@
jump_speed_factor = 5
max_range = initial(max_range) * 3

///Requests emergency FTL, needs manual confirm at the machine itself.
/obj/machinery/computer/ship/ftl_core/proc/request_emergency_ftl_confirm()
if(await_emergency_ftl_confirm - world.time > 0)
return
if(!linked.ftl_safety_override)
return
await_emergency_ftl_confirm = world.time + 15 SECONDS
say("Emergency FTL request signal received from Navigation system. Manual confirmation required.")
radio.talk_into(src, "Emergency FTL request signal received from Navigation system. Manual confirmation required.", radio_channel)

/*
Preset classes of FTL drive with pre-programmed behaviours
*/
Expand Down Expand Up @@ -292,6 +305,22 @@ Preset classes of FTL drive with pre-programmed behaviours
return
auto_spool_enabled = !auto_spool_enabled
. = TRUE
if("emergency_jump")
. = TRUE
if(!linked.ftl_safety_override)
return
if(world.time < linked.next_emergency_jump)
say("Failsafe Capacitor still recharging. Emergency transition unavailable.")
await_emergency_ftl_confirm = 0
return
if(world.time > await_emergency_ftl_confirm)
return
if(progress / req_charge < 0.25)
say("FTL not sufficiently spooled for emergency transition. 25% of full charge required.")
await_emergency_ftl_confirm = 0
return
await_emergency_ftl_confirm = 0
linked.emergency_jump()

/obj/machinery/computer/ship/ftl_core/ui_data(mob/user)
var/list/data = list()
Expand All @@ -317,14 +346,15 @@ Preset classes of FTL drive with pre-programmed behaviours
data["pylons"] = all_pylon_info
data["can_auto_spool"] = auto_spool_capable
data["auto_spool_enabled"] = auto_spool_enabled
data["await_emergency_ftl_confirm"] = (await_emergency_ftl_confirm > world.time && linked.ftl_safety_override)
return data

/obj/machinery/computer/ship/ftl_core/proc/jump(datum/star_system/target_system, force=FALSE)
/obj/machinery/computer/ship/ftl_core/proc/jump(datum/star_system/target_system, force=FALSE, misjump = FALSE)
ftl_state = FTL_STATE_JUMPING
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, misjump)
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
33 changes: 24 additions & 9 deletions nsv13/code/modules/overmap/FTL/ftl_jump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@
system_contents -= OM


/obj/structure/overmap/proc/begin_jump(datum/star_system/target_system, force=FALSE)
/obj/structure/overmap/proc/begin_jump(datum/star_system/target_system, force=FALSE, misjump = FALSE)
relay(ftl_drive.ftl_start, channel = CHANNEL_IMPORTANT_SHIP_ALERT)
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)
addtimer(CALLBACK(src, PROC_REF(jump_start), target_system, force, misjump), ftl_drive.ftl_startup_time)

/obj/structure/overmap/proc/force_return_jump()
SIGNAL_HANDLER
Expand Down Expand Up @@ -214,14 +214,16 @@
if(M && M.client && M.hud_used && length(M.client.parallax_layers))
M.hud_used.update_parallax(force=TRUE)

/obj/structure/overmap/proc/jump_start(datum/star_system/target_system, force=FALSE)
/obj/structure/overmap/proc/jump_start(datum/star_system/target_system, force=FALSE, misjump = FALSE)
if(ftl_drive?.ftl_state != FTL_STATE_JUMPING)
if(force && ftl_drive)
if((force || misjump) && 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

var/interdict_return = SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CHECK_INTERDICT, src)
if(!force && ((interdict_return & STRONG_INTERDICT) || ((interdict_return & WEAK_INTERDICT) && !misjump))) // Override interdiction if the game is over, flying unsafe also bypasses non-fielddisruptive interdiction.
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()
Expand All @@ -242,6 +244,8 @@
if(drive_speed <= 0) //Assumption: If we got into this proc with speed 0, we want it to jump anyways, as it should be caught before otherwise. Using very slow speed in this case.
drive_speed = 1 //Div-by-0s are not fun.
var/speed = (curr.dist(target_system) / (drive_speed * 10)) //TODO: FTL drive speed upgrades.
if(misjump)
speed = max(speed, 3)
SSstar_system.ships[src]["to_time"] = world.time + speed MINUTES
SEND_SIGNAL(src, COMSIG_FTL_STATE_CHANGE)
if(role == MAIN_OVERMAP) //Scuffed please fix
Expand All @@ -255,9 +259,11 @@
SSstar_system.ships[src]["target_system"] = target_system
SSstar_system.ships[src]["from_time"] = world.time
SSstar_system.ships[src]["current_system"] = null
addtimer(CALLBACK(src, PROC_REF(jump_end), target_system), speed MINUTES)
addtimer(CALLBACK(src, PROC_REF(jump_end), target_system, misjump), speed MINUTES)
ftl_drive.depower(ftl_drive.auto_spool_enabled)
jump_handle_shake()
if(misjump)
on_misjump_start(target_system, (speed MINUTES))
force_parallax_update(TRUE)

/obj/structure/overmap/proc/jump_handle_shake(ftl_start)
Expand Down Expand Up @@ -286,7 +292,7 @@
shake_with_inertia(M, 4, 1, list(distance=nearestDistance, machine=nearestMachine))


/obj/structure/overmap/proc/jump_end(datum/star_system/target_system)
/obj/structure/overmap/proc/jump_end(datum/star_system/target_system, misjump = FALSE)
if(reserved_z) //Actual overmap parallax behaviour
var/datum/space_level/SL = SSmapping.z_list[reserved_z]
SL.set_parallax( (current_system != null) ? current_system.parallax_property : target_system.parallax_property, null)
Expand All @@ -300,7 +306,15 @@
SSstar_system.ships[src]["from_time"] = 0
SSstar_system.ships[src]["to_time"] = 0
SEND_SIGNAL(src, COMSIG_FTL_STATE_CHANGE)
relay(ftl_drive.ftl_exit, "<span class='warning'>You feel the ship lurch to a halt</span>", loop=FALSE, channel = CHANNEL_SHIP_ALERT)
if(!misjump)
relay(ftl_drive.ftl_exit, "<span class='warning'>You feel the ship lurch to a halt</span>", loop=FALSE, channel = CHANNEL_SHIP_ALERT)
else
var/exit_sound = pick(list('nsv13/sound/effects/ship/misjump/misjump_exit_01.ogg', 'nsv13/sound/effects/ship/misjump/misjump_exit_02.ogg'))
relay(message = "<span class='warning'>You feel the ship violently leave drive space!</span>")
for(var/mob/mob in mobs_in_ship)
if(!mob.client)
continue
mob.playsound_local(soundin = exit_sound, vol = 100, vary = FALSE) //Going for direct sound over relay because people should hear this, while system related sounds sometimes override relay.

var/list/pulled = list()
for(var/obj/structure/overmap/SOM as() in GLOB.overmap_objects) //Needs to go through global objects due to being in jumpspace not a system.
Expand All @@ -317,9 +331,10 @@

SEND_SIGNAL(src, COMSIG_SHIP_ARRIVED) // Let missions know we have arrived in the system
jump_handle_shake()
if(misjump)
on_misjump_end(target_system)
force_parallax_update(FALSE)


/obj/item/ftl_slipstream_chip
name = "Quantum slipstream field generation matrix (tier II)"
desc = "An upgrade to the ship's FTL computer, allowing it to benefit from cutting edge calculation technologies to result in faster jump times by changing the way in which it allows the ship to incurse into bluespace."
Expand Down
Loading
Loading