Space Engineers

Space Engineers

37 ratings
Remote Targeting Script Mk4 (Decommissioned)
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
3.856 KB
21 Oct, 2015 @ 5:09am
1 Jul, 2016 @ 11:01am
17 Change Notes ( view )

Subscribe to download
Remote Targeting Script Mk4 (Decommissioned)

Description
GetFreeDestination is removed, therefore this script is decommissioned.

Lock-on script to be used on Semi-Active Radar Homing Missile Systems (SARH). This script is revamped again for optimized and accurate lock-on plus more simple setup.

This is a Vanilla Script. No Mods are required.


Features

- Long range locking up to draw distance (20km by default).
- Multiple target locking (Provided your CPU can support).
- Outputs coordinates to Text Panel, for use by other scripts such as Cruise Missile Script.
- Allows multiple Remote Controls hand off, to re-accquire targets if the lock is broken by line of sight from first Remote Control.


Limitations

- Must have line of sight from the Remote Control block to the target, excluding your own ship.
- Must be aimed directly at target for initial locking, as beam is very narrow.
- Beam is calculated from ship's Remote Control block to target instead of missile to target.


Required Setup

- A Remote Control block called RE_REMOTE. The facing direction of this block will be used for initial locking (Facing same direction as your aiming camera).
- A set of Text Panels called CMD_TARGET_*, where * is a running number starting from 1. If you set 3 targets, you must have CMD_TARGET_1, CMD_TARGET_2 and CMD_TARGET_3.
- (Optional) A set of lighting blocks (Interior Light or Spotlight) called RE_INDICATOR_*, where * is a running number starting from 1. This will be used to indicate the locking status.
- (Optional) A Text Panel called TARGET_INFO_PANEL. This is for displaying targeting information.
- (Optional) A group named RE_REMOTE_GROUP containing a set of Remote Control blocks. Place the Remote Control blocks as far apart as possible for best efficiency.


Changable Parameters

outputGPSFormat - Set true to output target information in standard GPS coordinates format, else output in [T:<X>:<Y>:<Z>].
showRadius - Set true to also output Radius information to Target Info Panel.

numTargets - Maximum number of targets to track.
prefixIndexOffset - The running number offset. Example, if 5 is entered, CMD_TARGET_* and RE_INDICATOR_* starts from 6 onwards (CMD_TARGET_6, RE_INDICATOR_6 etc).

GFD_MIN_LOCK_DISTANCE - Mimimum distance to lock target (Prevent locking on nearby friendly ships or yourself).
GFD_MAX_LOCK_DISTANCE - Maximum distance to lock target.
GFD_BEAM_WIDTH - Width of the locking beam (See codes for more explanation).
GFD_INTERRUPT_THRESHOLD - Amount of distance change in one tick to declare GFD lock interrupted and handoff to be initiated.


How To Use

1) Load the script into Programmable Block.
2) Setup a Timer Block to loop the Programmable Block script (Triggers "Run" Action of Programmable Block and "Trigger Now" Action of the Timer itself).
2) Create a toolbar item calling this script's Programmable Block (Action: Run), with the Argument as LOCK:<number> (e.g. LOCK:1, LOCK:2, up to the max number of targets to track).
3) Trigger this toolbar item. It will toggle between lock and unlock. When script is first started, indicator light is Blue (Idle mode). When LOCK:1 is called, the target #1 indicator light turns Green (Seeking mode).
4) Point your ship nose at the target (based on where RE_REMOTE is facing). When target is locked, indicator light turns Red (Locked mode).
5) Once lock is established, target information is written to the Public Title of the Text Panels CMD_TARGET_<target #> (e.g. CMD_TARGET_1 for locked target #1, CMD_TARGET_2 for locked target #2).
6) Press the toolbar item to toggle between Lock and Unlock. If target is locked, pressing it will reset the lock and go back to Idle mode.
7) If lock is broken, it will go back to Seeking mode.

Added: You can target a pre-determined location for lock-on, without aiming your ship at it. To do so, trigger Programmable Block (Action: Run), with the Argument as:

LOCK:<number>:<GPS Coordinates>

Example:

LOCK:1:GPS:Outpost:100:200:300:

Note: The Lock and RESET commands are also subjected to "prefixIndexOffset" if you set a non zero number. Example, if you set prefixIndexOffset to 7, first target is CMD_TARGET_8, and to lock you need to enter command LOCK:8.


How It Works

Rough explanation of how this lock-on works.




1) Check initial vector "RO1" and find first free point "F1".
2) Set length of "RO1" = Length of "RF1".
3) Find normal vector of "RO1" and "O1F1" using cross product. This is the normal vector of first plane "P1" (O1 mentioned here is an estimate. We do not know O1 at all. Nonetheless, P1 is still accurate as all points are on the same plane anyway).
4) Find 1m long vector "O2" = (F1-O1).Normalize(). So, now we can add both this vector and the P1 normal vector to O1 to get points 1m closer to first free point F1 and 1m above O1F1 (Diagonal line).
5) Check 1 more additional point "O1 + O2 + normal of P1" to get "F2".
6) Set length of "RO2" = Length of "RF2".
7) Find normal vector of "RO2" and "O2F2" using cross product. This is the normal vector of first plane "P2" (Same as point 3, O2 is an estimate).
8) Find line of intersection using cross product of normal of "P1" and "P2". Lets call this line's vector K. The line of intersection will be "R + zK" (R is the remote control's position, which lies on this line). Now we solve for z.
9) The radius "TO" of target's bounding sphere has always the same length. "OF" has always the same length too, it's either 1/2 radius or 20m (if target's radius is smaller then 40m). Angle "TOF" is always 90 grad, so we can conclude, that lengths of "TF1" and "TF2" are equal.
10) T is actually "R + zK". Since |TF1| = |TF2|, then Length of "R + zK - F1" = Length of "R + zK - F2".
11) Once z is solved, put it back to the "R + zK" equation to get T.


Commands

Commands are given via Run Arguments when you trigger the script using toolbar (Action: Run). No square brackets should be used. The list of possible commands are:

1) LOCK (e.g. LOCK:1)
> Integer = The target number to lock. If LOCK:2 command is given, it will toggle the locking state of Target #2.

2) LOCK (e.g. LOCK:1:GPS:Outpost:100:200:300:)
> Integer = The target number to lock. If LOCK:2 command is given, it will toggle the locking state of Target #2.
> GPS String = The GPS coordinates to target to initiate lock-on.

3) RESET (e.g. RESET:1)
> Integer = The target number to reset. If RESET:2 command is given, it will unlock and clear the Text Panel of Target #2.
54 Comments
Nob-Stop 2 Nov, 2019 @ 5:18pm 
can i use this to aim missils with an antana or becon of enemy base
DudemanGT 22 Sep, 2016 @ 2:54am 
understood. welp, then i'll hold off any larger plans until we get the script sorted out. but id really like to PM with you so i can bounce a few ideas off of you. Cheers, buddy
Alysius  [author] 22 Sep, 2016 @ 2:35am 
@Dude Must be same grid, as different grid can interfere with the lock on. Havent test this script for a long time, also no intention to do so since Keen is going to remove the GetFreeDestination function soon. Therefore a new script needs to be created.
DudemanGT 21 Sep, 2016 @ 6:34pm 
Alright, two questions @Alysius, first, does this script still work? Also, does the locking remote control block have to be attached to the same grid as the firing platform? I'd like to use an orbital platform for targeting to fire missles from a silo on the planet.
Blockdude 20 Aug, 2016 @ 2:37pm 
@Alysius I am trying to use this old script as an early warning radar by putting the remote on the end of a scanning stick (Rotors Spinning at a slow rate) and I cannot get it to indentify a test target 248m away, the script is running properly and is scanning for targets as indicated by green light, but refues to lock. Any ideas?
Alysius  [author] 24 May, 2016 @ 5:56pm 
@Kri This script is only to get the coordinates, the feature will be on the missile script itself.
Kri 24 May, 2016 @ 3:52pm 
Have you considered adding feature of intercepting the target from an angle and dodging defensive fire? Like in the example seen here: http://gtm.steamproxy.vip/sharedfiles/filedetails/?id=543982976 (since Pennywise is co-author of this it shouldn't be a problem, right? :) )
Alysius  [author] 21 May, 2016 @ 12:45am 
@Assy Can be used but the lock-on is quite CPU intensive to have many locking at one goal.
Assy Flargison 25 Apr, 2016 @ 5:48am 
so i've got this idea for a mass relay highway between planets and other key locations for smaller ships that either don't have jumpdrives or otherwise would not make the trip, but the issue i run into is that i have no way of acurately aiming one of these relays from one grid to another over a large area of space, this script sounds like it's the closest to what i am actually looking for, think it will work?
Alysius  [author] 13 Apr, 2016 @ 5:42am 
Suddenly its fixed again after an SE update, probably some game bug previously.