FreeSpace Releases > Scripting Releases

Subsystem Hotkey Script

(1/2) > >>

MadProf:
The zip file contains a script (and example usage) that can be used to give subsystems & turrets a hot key. Requires 3.1.13 revision 6967 or higher to work, due to a issue with earlier revisions.

Use the script from FRED requires two string variables to be set
SubDShip  - the ship name e.g. GTD Killer
SubDSubsys - the subsystem e.g. turret01
then a script-eval of subsystemdirec('key')


--- Code: ---$Formula: ( when
   ( has-time-elapsed 0 )
   ( modify-variable
      "@SubDShip[ ]"
      "Fenris"
   )
   ( modify-variable
      "@SubDSubsys[ ]"
      "turret09a-01-main"
   )
   ( script-eval "subsystemdirec('F9')" )
   ( modify-variable
      "@SubDSubsys[ ]"
      "navigation"
   )
   ( script-eval "subsystemdirec('F10')" )
   ( modify-variable
      "@SubDSubsys[ ]"
      "engine"
   )
   ( script-eval "subsystemdirec('F10')" )
   ( modify-variable
      "@SubDShip[ ]"
      "Leviathan"
   )
   ( modify-variable
      "@SubDSubsys[ ]"
      "turret09a-01-main"
   )
--- End code ---

NB multiple class to the subsystemdirec with the same key appends the ship/subsystem to the list it doesn't replace it.
Pressing the hotkey in game then cycles the targeting through the list, as long as the ship exists and the subsystem isn't at 0 health.

The other way to init is to create a script tbm like

--- Code: ---$Mission: SubSysDirec-script.fs2
$On Mission Start:
[
  subsysdirecs['f9'] =  { 0, {'Fenris', 'turret09a-01-main'}, {'Leviathan', 'turret09a-01-main'} }
  subsysdirecs['f10'] = { 0, {'Fenris', 'navigation'}, {'Fenris', 'engine'} }
  subsysdirecs['f11'] = { 0, {'Leviathan', 'navigation'}, {'Leviathan', 'engine'} }
]
--- End code ---
notice the keys have to in lower case

Hope somebody finds the useful.

files in the zip
------------------
SubsysHotKeysMain-sct.tbm  - the scripting it self
SubSysDirec-fred.fs2   -  a basic mission showing how to configure the keys from within FRED
SubSysDirec-script.fs2 - the same basic mission but uses the file SubHotKeys-scriptset-sct.tbm to set the keys

edit
updated zip file - fixed retargeting issue

edit 2
update zip again - now draws a small white box around the subsystems that aren't targeted

edit 3
zip update yet again - fixed a silly little bug the crept in with the first edit

[attachment deleted by ninja]

General Battuta:
God this is AMAZING

Zacam:

MadProf get's Mad Props for Awesome Work.

MadProf:
Glad people like it, having enjoyed the work of others thought it was about time to give something back.

The scripts not perfect in that
1) it doesn't draw the boxes around the subsystems
2) with a single subsystem in the list pressing the hotkey causes target lock to start again

Zacam:

--- Quote from: MadProf on January 24, 2011, 02:38:52 pm ---1) it doesn't draw the boxes around the subsystems

--- End quote ---

That can be fixed later. The HUD Escort script I _think_ is updated in the Wiki to show how to possibly approach doing something like that.


--- Quote from: MadProf on January 24, 2011, 02:38:52 pm ---2) with a single subsystem in the list pressing the hotkey causes target lock to start again

--- End quote ---

This is a basic function of the Targeting system in general and does not in any way specifically apply to this script, except maybe if it's possible to get it to not fire off re-targeting by doing a check if already targeted first in order to maintain target lock, but only when the index is at 1. But even still, if you had a single subsystem ship in regular and already locked, I think if you hit subsystems targetting (not the on/off toggle, but the prev/next one) that it would cause a re-lock on. Could be wrong though.

Navigation

[0] Message Index

[#] Next page

Go to full version