Skip to content

Commit

Permalink
Ship FSD script updated to provide information about arrival system…
Browse files Browse the repository at this point in the history
… nearby hazards and lack of charted scoopable stars.

Similar info removed from the `FSD engaged` script. Warnings about scoopable stars occur only if the ship has a fuel scoop.
Resolves #2494.
  • Loading branch information
Tkael committed Jan 22, 2023
1 parent 602c08b commit c4fc835
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 26 deletions.
14 changes: 9 additions & 5 deletions DataDefinitions/Status.cs
Expand Up @@ -69,7 +69,8 @@ public enum Flags2 : uint
OnFootExterior = 0x00008000, // On Foot Exterior (Not sure when this would actually be set. Space walks maybe?)
BreathableAtmosphere = 0x00010000, // Breathable Atmosphere
TelepresenceMulticrew = 0x00020000, // Telepresence Multicrew
PhysicalMulticrew = 0x00040000 // Physical Multicrew
PhysicalMulticrew = 0x00040000, // Physical Multicrew
FsdHyperDriveCharging = 0x00080000 // Fsd hyperdrive charging
}

// Variables set from status flags (when not signed in, this is set to '0')
Expand Down Expand Up @@ -100,10 +101,13 @@ public enum Flags2 : uint

[PublicAPI]
public string fsd_status =>
((flags & Flags.FsdCooldown) != 0) ? "cooldown"
: ((flags & Flags.FsdCharging) != 0) ? "charging"
: ((flags & Flags.FsdMassLocked) != 0) ? "masslock"
: "ready";
((flags & Flags.FsdCooldown) != 0) ? "cooldown" :
((flags & Flags.FsdCharging) != 0) ? "charging" :
((flags & Flags.FsdMassLocked) != 0) ? "masslock" :
"ready";

[PublicAPI]
public bool fsd_hyperdrive_charging => (flags2 & Flags2.FsdHyperDriveCharging) != 0;

[PublicAPI]
public bool srv_drive_assist => (flags & Flags.SrvDriveAssist) != 0 && (flags & Flags.InSRV) != 0;
Expand Down
5 changes: 5 additions & 0 deletions EDDI/ChangeLog.md
Expand Up @@ -5,8 +5,13 @@ Full details of the variables available for each noted event, and VoiceAttack in
## 4.0.3
* Navigation Monitor
* Fix `Shortest Missions Route` reports all distances as zero (0) light-years #2488
* The `status` object now contains a new property `fsd_hyperdrive_charging` (`{BOOL:Status fsd hyperdrive charging}` in VoiceAttack), which contains a boolean value indicating whether the FSD is currently charging for a jump to hyperspace.
* Speech Responder
* Events
* `Ship FSD` event now includes a new boolean `hyperdrive_charging`.
* Changes to existing scripts
* `Fsd engaged` (triggered after the FSD is engaged) no longer warns about hazardous or non-scoopable arrival stars.
* `Ship FSD` (triggered before the FSD is engaged) now warns about nearby hazardous stars or no charted scoopable stars in your arrival system.
* `Swapout check` updated to fix a bug that was causing false positives.
* VoiceAttack Responder
* Fixed a bug that prevented current ship variables from being updated properly on a ship change. #2482
Expand Down
8 changes: 6 additions & 2 deletions Events/ShipFsdEvent.cs
Expand Up @@ -8,14 +8,18 @@ public class ShipFsdEvent : Event
{
public const string NAME = "Ship fsd";
public const string DESCRIPTION = "Triggered when there is a change to the status of your ship's fsd";
public const string SAMPLE = null;
public static ShipFsdEvent SAMPLE = new ShipFsdEvent(DateTime.UtcNow, "charging", true);

[PublicAPI("The status of your ship's fsd ('cooldown', 'cooldown complete', 'charging', 'charging cancelled', 'charging complete', 'masslock', or 'masslock cleared')")]
public string fsd_status { get; private set; }

public ShipFsdEvent(DateTime timestamp, string fsdStatus) : base(timestamp, NAME)
[PublicAPI("True if the FSD is currently charging for a jump to hyperspace.")]
public bool hyperdrive_charging { get; private set; }

public ShipFsdEvent(DateTime timestamp, string fsdStatus, bool hyperdriveCharging = false) : base(timestamp, NAME)
{
this.fsd_status = fsdStatus;
this.hyperdrive_charging = hyperdriveCharging;
}
}
}
1 change: 1 addition & 0 deletions SpeechResponder/Variables.md
Expand Up @@ -758,6 +758,7 @@ Any values might be missing, depending on EDDI's configuration.
- *overheating* - a boolean value indicating whether the commander's vehicle is overheating
- *low_fuel* - a boolean value indicating whether the commander has less than 25% fuel remaining
- *fsd_status* - the current status of the ship's frame shift drive. Can be one of "ready", "cooldown", "charging", or "masslock"
- *fsd_hyperdrive_charging* - a boolean value indicating whether the FSD is currently charging for a jump to hyperspace.
- *srv_drive_assist* - a boolean value indicating whether SRV drive assist is active
- *srv_highbeam* - true if the lights in your SRV are set to the high beam mode.
- *srv_under_ship* - a boolean value indicating whether the SRV in within the proximity zone around the ship
Expand Down
4 changes: 2 additions & 2 deletions SpeechResponder/eddi.cs.json
Expand Up @@ -1045,7 +1045,7 @@
"enabled": true,
"priority": 3,
"responder": true,
"script": "{_ Context }\r\n{SetState('eddi_context_last_subject', 'fsd')}\r\n{SetState('eddi_context_last_action', 'engage')}\r\n{SetState('eddi_context_system_name', event.system)}\r\n{SetState('eddi_context_system_system', event.system)}\r\n{SetState('eddi_context_fsd_target', event.target)}\r\n{SetState('eddi_context_system_lastvisit', system.lastVisitSeconds)}\r\n\r\n{_ Zero the 'remaining jump' context to only use values following this event _}\r\n{SetState('eddi_context_remaining_jumps', 0)}\r\n\r\n{if event.target = 'Hyperspace':\r\n {_ Rewrite context to represent a jump }\r\n {SetState('eddi_context_last_subject', 'jump')}\r\n {SetState('eddi_context_last_action', 'start')}\r\n\r\n {set reportsystem to SystemDetails(event.system)}\r\n\r\n {_ Wait for the FSD countdown and initial jump}\r\n {Pause(5000)}\r\n\r\n {OneOf(\"Destination confirmed\",\"Jump in progress\",\"Telemetry obtained\")}.\r\n {ShipName()} is {OneOf(\"heading to\", \"on route to\", \"travelling to\", \"in transit to\")} the {P(reportsystem.name, \"starsystem\")} system.\r\n {if reportsystem.name = homesystem.name:\r\n Welcome home, {F(\"Honorific\")}\r\n |else:\r\n {set scoopables to [\"O\", \"B\", \"A\", \"F\", \"G\", \"K\", \"M\"]}\r\n {if slice(event.stellarclass, 0, 1) = \"D\":\r\n Caution: white dwarf detected.\r\n |elif event.stellarclass = \"N\":\r\n Caution: neutron star detected.\r\n |elif event.stellarclass = \"H\":\r\n Caution: black hole detected.\r\n |elif find(scoopables, event.stellarclass) = -1:\r\n {Occasionally(2, \"Information: \")}\r\n Arrival star is not scoopable.\r\n }\r\n \r\n {if lastsystem.allegiance && lastsystem.allegiance != \"None\" && lastsystem.allegiance != \"Independent\" && (!reportsystem.allegiance || reportsystem.allegiance = \"None\" || reportsystem.allegiance = \"Independent\"):\r\n You {OneOf(\"are leaving\", \"have left\", \"are no longer in\")} {lastsystem.allegiance} space.\r\n |elif lastsystem.allegiance && lastsystem.allegiance != reportsystem.allegiance && system.allegiance && system.allegiance != \"None\":\r\n You {OneOf(\"are now in\", \"have entered\", \"are entering\")} {reportsystem.allegiance} space.\r\n {if cmdr.title != \"Commander\":\r\n Welcome back {F(\"Honorific\")}.\r\n }\r\n }\r\n\r\n {if reportsystem.visits = 0:\r\n This is your first visit to this system.\r\n |elif reportsystem.visits = 1:\r\n This is your second visit to this system.\r\n |elif reportsystem.visits = 2:\r\n {Occasionally(2, \"This is your third visit to this system.\")}\r\n |elif reportsystem.visits = 3:\r\n {Occasionally(2, \"This is your fourth visit to this system.\")}\r\n |else:\r\n {Occasionally(3, \"You have visited this system {reportsystem.visits} times.\")}\r\n }\r\n\r\n {if !reportsystem.population && lastsystem.population:\r\n {OneOf(\"This system is not populated\",\"There is no human presence here\", \"Humans have yet to colonise this system\")}.\r\n |elif reportsystem.population:\r\n {if SecondsSince(reportsystem.lastVisitSeconds) > 3600:\r\n {F(\"System report\")}\r\n }\r\n }\r\n\r\n {if reportsystem.distancefromhome:\r\n {set ReportDistanceFromHome() to:\r\n \t{return cat(\r\n \t OneOf(\"You are\", \"Current location is\", \"You are now\"), \" \",\r\n\t Humanise(reportsystem.distancefromhome), \" lightyears from \",\r\n\t OneOf(\"home\", \"{P(homesystem.name, 'starsystem')}\"), \".\"\r\n\t )}\r\n } \r\n {Occasionally(7, ReportDistanceFromHome())}\r\n }\r\n\r\n {if reportsystem.comment:\r\n You made a {OneOf(\"note\", \"comment\", \"remark\")} {OneOf(\"about\", \"for\", \"on\")} this system. It {OneOf(\"is as follows\", \"says\", \"reads\", \"is\")} {reportsystem.comment}.\r\n }\r\n }\r\n}",
"script": "{_ Context }\r\n{SetState('eddi_context_last_subject', 'fsd')}\r\n{SetState('eddi_context_last_action', 'engage')}\r\n{SetState('eddi_context_system_name', event.system)}\r\n{SetState('eddi_context_system_system', event.system)}\r\n{SetState('eddi_context_fsd_target', event.target)}\r\n{SetState('eddi_context_system_lastvisit', system.lastVisitSeconds)}\r\n\r\n{_ Zero the 'remaining jump' context to only use values following this event _}\r\n{SetState('eddi_context_remaining_jumps', 0)}\r\n\r\n{if event.target = 'Hyperspace':\r\n {_ Rewrite context to represent a jump }\r\n {SetState('eddi_context_last_subject', 'jump')}\r\n {SetState('eddi_context_last_action', 'start')}\r\n\r\n {set reportsystem to SystemDetails(event.system)}\r\n\r\n {_ Wait for the FSD countdown and initial jump}\r\n {Pause(5000)}\r\n\r\n {OneOf(\"Destination confirmed\",\"Jump in progress\",\"Telemetry obtained\")}.\r\n {ShipName()} is {OneOf(\"heading to\", \"on route to\", \"travelling to\", \"in transit to\")} the {P(reportsystem.name, \"starsystem\")} system.\r\n {if reportsystem.name = homesystem.name:\r\n Welcome home, {F(\"Honorific\")}.\r\n |else:\r\n {if lastsystem.allegiance && lastsystem.allegiance != \"None\" && lastsystem.allegiance != \"Independent\" && (!reportsystem.allegiance || reportsystem.allegiance = \"None\" || reportsystem.allegiance = \"Independent\"):\r\n You {OneOf(\"are leaving\", \"have left\", \"are no longer in\")} {lastsystem.allegiance} space.\r\n |elif lastsystem.allegiance && lastsystem.allegiance != reportsystem.allegiance && system.allegiance && system.allegiance != \"None\":\r\n You {OneOf(\"are now in\", \"have entered\", \"are entering\")} {reportsystem.allegiance} space.\r\n {if cmdr.title != \"Commander\":\r\n Welcome back {F(\"Honorific\")}.\r\n }\r\n }\r\n\r\n {if reportsystem.visits = 0:\r\n This is your first visit to this system.\r\n |elif reportsystem.visits = 1:\r\n This is your second visit to this system.\r\n |elif reportsystem.visits = 2:\r\n {Occasionally(2, \"This is your third visit to this system.\")}\r\n |elif reportsystem.visits = 3:\r\n {Occasionally(2, \"This is your fourth visit to this system.\")}\r\n |else:\r\n {Occasionally(3, \"You have visited this system {reportsystem.visits} times.\")}\r\n }\r\n }\r\n}",
"default": true,
"name": "FSD engaged",
"description": "Triggered when your FSD has engaged"
Expand Down Expand Up @@ -2053,7 +2053,7 @@
"enabled": true,
"priority": 3,
"responder": true,
"script": null,
"script": "{set hazardDistance to 100} {_ Warn me when hazardous stars are within this distance (in ls) from the main star }\r\n\r\n{_ Fetch from context _}\r\n{if state.eddi_context_next_system_name:\r\n {set reportSystem to SystemDetails(state.eddi_context_selected_system_name)}\r\n|else:\r\n {set reportSystem to nextsystem}\r\n}\r\n\r\n{if event.fsd_status = 'charging' && event.hyperdrive_charging: \r\n {if len(reportSystem.systemname) > 0:\r\n \r\n {Pause(2000)}\r\n \r\n {if reportSystem.systemname != homesystem.systemname:\r\n {for compartment in ship.compartments:\r\n {if compartment.module.invariantName = 'Fuel Scoop':\r\n {set scoop_present to true}\r\n }\r\n } \r\n \r\n {set scoop_present to true}\r\n\r\n {set nearbyWhiteDwarfStars to []}\r\n {set nearbyNeutronStars to []}\r\n {set nearbyBlackHolesStars to []}\r\n {for aBody in reportSystem.bodies:\r\n {if aBody.bodyType.invariantName = 'Star':\r\n {if aBody.mainstar:\r\n {set mainstar to aBody}\r\n |elif scoop_present && aBody.scoopable && aBody.distance < secondaryScoopStar.distance:\r\n {set secondaryScoopStar to aBody)}\r\n }\r\n {if slice(aBody.stellarclass, 0, 1) = \"D\" && aBody.distance < hazardDistance:\r\n {set nearbyWhiteDwarfStars to cat(nearbyWhiteDwarfStars, [aBody])} \r\n |elif aBody.stellarclass = 'N' && aBody.distance < hazardDistance:\r\n {set nearbyNeutronStars to cat(nearbyNeutronStars, [aBody])}\r\n |elif aBody.stellarclass = 'H' && aBody.distance < hazardDistance: \r\n {set nearbyBlackHolesStars to cat(nearbyBlackHolesStars, [aBody])}\r\n }\r\n }\r\n }\r\n \r\n {set nearbyHazards to []} \r\n {if len(nearbyWhiteDwarfStars) > 0:\r\n {set hazard to: White Dwarf{if len(nearbyWhiteDwarfStars) > 1:s}}\r\n {set nearbyHazards to cat(nearbyHazards, [hazard])}\r\n }\r\n {if len(nearbyNeutronStars) > 0:\r\n {set hazard to: Neutron Star{if len(nearbyNeutronStars) > 1:s}}\r\n {set nearbyHazards to cat(nearbyHazards, [hazard])}\r\n }\r\n {if len(nearbyBlackHolesStars) > 0:\r\n {set hazard to: Black Hole{if len(nearbyBlackHolesStars) > 1:s}}\r\n {set nearbyHazards to cat(nearbyHazards, [hazard])}\r\n }\r\n \r\n {if len(nearbyHazards) > 0:\r\n Caution: {List(nearbyHazards)} detected. \r\n }\r\n\r\n {if scoop_present && mainstar && !mainstar.scoopable && !secondaryScoopStar:\r\n {if len(nearbyHazards) = 0: {Occasionally(2, \"Alert: \")}}\r\n No scoopable stars charted\r\n {Occasionally(2, \"in arrival system\")}.\r\n }\r\n }\r\n }\r\n}",
"default": true,
"name": "Ship fsd",
"description": "Triggered when there is a change to the status of your ship's fsd"
Expand Down

0 comments on commit c4fc835

Please sign in to comment.