Author Topic: Subsystem Hotkey Script  (Read 1406 times)

0 Members and 1 Guest are viewing this topic.

Offline MadProf

  • 24
Subsystem Hotkey Script
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: [Select]
$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"
   )

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: [Select]
$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'} }
]
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]
« Last Edit: January 28, 2011, 12:27:46 pm by MadProf »

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: Subsystem Hotkey Script
God this is AMAZING

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Minecraft
    • Steam
    • Twitter
    • ModDB Feature
Re: Subsystem Hotkey Script

MadProf get's Mad Props for Awesome Work.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the FSU on #SCP-FSU Talk with the SCP on #SCP
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline MadProf

  • 24
Re: Subsystem Hotkey Script
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

 

Offline Zacam

  • Magnificent Bastard
  • Administrator
  • 211
  • I go Sledge-O-Matic on Spammers
    • Minecraft
    • Steam
    • Twitter
    • ModDB Feature
Re: Subsystem Hotkey Script
1) it doesn't draw the boxes around the subsystems

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.

2) with a single subsystem in the list pressing the hotkey causes target lock to start again

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.
Report MediaVP issues, now on the MediaVP Mantis! Read all about it Here!
Talk with the FSU on #SCP-FSU Talk with the SCP on #SCP
"If you can keep a level head in all this confusion, you just don't understand the situation"

¤[D+¬>

[08/01 16:53:11] <sigtau> EveningTea: I have decided that I am a 32-bit registerkin.  Pronouns are eax, ebx, ecx, edx.
[08/01 16:53:31] <EveningTea> dhauidahh
[08/01 16:53:32] <EveningTea> sak
[08/01 16:53:40] * EveningTea froths at the mouth
[08/01 16:53:40] <sigtau> i broke him, boys

 

Offline MadProf

  • 24
Re: Subsystem Hotkey Script
Well the zip file in the first post now has the retargeting issue fixed.

Now have two problems trying to get boxes drawn around the subsystems
1) This is the big one - I can't seem to figure out the correct world coordinates of the subsystem, have tried adding subsystem:Position and subsystem:GunPosition to the ship:Position without luck.  Maybe somebody else can point me in the correct direction for this
2) drawTargetingBrackets doesn't like subsystems - can be emulated to a point with the other drawing functions so only a minor one.

 

Offline T-Man

  • 210
  • I came... I saw... I had a cuppa!
Re: Subsystem Hotkey Script
Mr MadProf i officially want your babies. :lol: Thanks a lot for putting this together; it's a feature i've been hoping for for ages.
CAUTION: Rabid Imagination!

self-confessed UEF fanboy.

 

Offline m!m

  • 211
Re: Subsystem Hotkey Script
@MadProf
You need to adjust the position according to the ships orientation. This can be done using something like this:
Code: [Select]
ship.Position + ship.Orientation:unrotateVector(subsystem.Position)This will result in the world position of the subsystem.

 

Offline MadProf

  • 24
Re: Subsystem Hotkey Script
Thanks m!m, that was the step I was missing. :yes:

The zip file in the first post now also draws a small white box around the subsystems in the list that aren't the players current target, and aren't at 0%.
The size of the box is controlled via the halfsubsystemdirecboxsize variable near the top of SubsysHotKeysMain-sct.tbm file, alter the value to make it larger or smaller as you wish.

 

Offline MadProf

  • 24
Re: Subsystem Hotkey Script
Arrgh! Updated the script as I found a silly bug in it. If a ship had multiple subsystems which display the same name in the HUD, it thought they where the same subsystem...

The zip in the first post contains the latest version.