Space Engineers

Space Engineers

54 ratings
[Obsolete] Active Radar Homing Script
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
8.625 KB
5 Dec, 2015 @ 2:16pm
4 Jan, 2016 @ 6:00am
11 Change Notes ( view )

Subscribe to download
[Obsolete] Active Radar Homing Script

Description
This is an Obsolete script, superseded by the Easy Radar Homing Script (Much easier to setup)
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=688803417

This script operates the same way as the real life Active Radar Homing Missile Guidance. It is used to setup a true Fire and Forget homing missile. All the required target locking and missile homing are packaged into this script, therefore the launching ship only needs to trigger the timer loop to run this script.

This is a vanilla script. No mods are required.

This script is designed to intercept fast moving targets, with a lockable closing speed limit of up to ~1600m/s. No point using on slow moving targets as the locking methods are very CPU intensive.


Features

1) Active Radar Homing - The missile maintains the lock by using GetFreeDestination() of Remote Control block to trace a locking beam to the target.
2) Orientation Auto Detection - All gyroscopes and thrusters can be mounted in any orientation. The script will auto detect the appropriate orientation and configure it accordingly.
3) Lead Target Function - By default the missile will try to lead the target, to correct the tail chasing problem.
4) Drift Function - This setting is used when your missile has no side thrusters. The drift function will perform over-steering to compensate for the drift. Can be activated by setting "boolDrift" to true.
5) Natural Gravity Dampener - Automatically spins the missile to face the thrusters against natural gravity. In this way, you can have thrusters on only one side, saving cost. To activate this, set "boolNaturalDampener" to true.


Required Setup

For Missile

- A Programmable block with this script.
- A Timer block loop to run this script. (Timer block calls "TriggerNow" of itself for looping and calls Programmable block "Run" to run this script)
- A reference block named V_MID in the middle.
- A reference block named V_FRONT directly in front of V_MID.
- A set of gyroscopes saved under group named GYROS.
- A set of backward facing thrusters saved under group named THRUSTERS.
- A Remote Control block named LREMOTE.
- A Merge Block -OR- Rotor block, either named as DISPATCH or saved under group named DISPATCH. Script will detach missile for launch via this block (The one closest to script block if many is detected).

- (Only if boolNaturalDampener is true) A reference block named V_DAMPENER positioned such that the direction from V_MID to V_DAMPENER is the same direction the side thrusters is going to face towards natural gravity. Set to true to use this feature.
- (Optional) A Sensor block named LSENSOR to be used for sensor lock on mode. *Sensor API changed, no longer working*

For Launching Ship

- A Remote Control block named REF_REMOTE.
- A reference block named REF_FRONT directly in front of REF_REMOTE.


How To Use

Aim ship nose at target and trigger the timer block looping this script.
(The aiming is done using REF_REMOTE and REF_FRONT. Therefore position them in-line with the cockpit for easier and more intuitive aiming.)


How It Works

1) Upon triggering this script loop, the missile will detach itself from ship via the closest Merge Block or Rotor block in the DISPATCH group.
2) The missile will initially use the launching ship's Remote Control block and pilot aiming (REF_REMOTE and REF_FRONT) to lock on to the target.
3) Once initial lock is achieved, missile will also use its own on-board Remote Control block to lock on to the same target.
4) Once on-board lock is stable, it will permanently switch to this on-board lock. (Fully Fire and Forget mode at this point)

Coordinate Based Initial Locking

You can also use a coordinate based method for the initial locking, instead of REF_REMOTE and REF_FRONT.
(E.g. Initial locking is done via Remote Targeting Script with target coordinates instead)

In this case, change strInitialCommandPanel string value to the name of the Text Panel to get the coordinates (e.g. CMD_TARGET_1).
Have another script update the coordinates to the Public Title of this specified Text Panel, in the format:

[T:<X>:<Y>:<Z>]

Where X, Y, Z is the coordinates (e.g. [T:12:34:56]).
Once the missile achieved a stable locking using its own on-board Remote Control block, it will ignore this coordinate and home on its own.


Notes

- If Drift Function is used and your vectorPointMid is far off from center of mass, use midToCenterOfMassDist to compensate. See video or screenshot for more information.


Demo Worlds And Other Links

A demo world is setup to showcase this script:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=569582290

A script to conveniently launch missiles:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=564182124


Special Settings

midToCenterOfMassDist - How much distance in metres the center of mass is in front of the vectorMid used by the missile. (def: 0)
driftVectorReduction - For Drift mode only. Larger value results in smaller drift, smaller value results in more aggressive drifting. Do not reduce to less than 1. (def: 1.2)
boolNaturalDampener - Can be set to true to use Natural Gravity Dampener feature. (def: false)
boolDrift - Can be set to true to force over-steering. This is used to compensate for the lack of side thrusters, if your missile design is as such. (def: false)
boolLeadTarget - Can be set to true for script to lead the target. The script will calculate the interception point and aim there instead of the current target position. (def: true)
defaultLaunchSeconds - The default launch time in seconds. Missile will not steer during this period after launch to clear launch pad. (def: 1)


Sensitive Parameters

spinAmount - Amount of RPM to spin. Not compatible with boolNaturalDampener. (def: 0)
remoteTargetMinDist - Minimum distance allowed for Remote Control to lock on target. (def: 10)
remoteTargetMaxDist - Maximum distance allowed for Remote Control to lock on target. (def: 20000)
remoteInitialMinDist - Minimum distance allowed for the initial lock on. This is to prevent initially locking on to the missile itself. (def: 50)
remoteStabilizationTicks - Number of ticks of locking same target before switching from ship to missile Remote Control. (def: 30)
remoteStabilizationDist - Threshold distance between estimated path from ship to target and missile to target to declare lock stable. (def: 50)
48 Comments
Reclaimer 117 18 May, 2016 @ 8:46pm 
Oh, it also adds another merge block called "Torpedo CC Interface". This is the one that is part of the missile, the hardpoint one is the one thats part of the ship. I have no experience coding, so I have no idea if one or both of these could be the culprit/s.
Reclaimer 117 18 May, 2016 @ 6:13pm 
The large torpedo parts mod adds a "Torpedo Hardpoint", which I believe adds it as a new merge block. Maybe its because this "Torpedo Hardpoint" isnt in the script? If so, would it be possible to have it added? It would be awesome to finally be able to use these torpedo's to their full potential. No other script seems to work for them, and I suspect the "Torpedo Hardpoint" may be the culprit.
Reclaimer 117 18 May, 2016 @ 5:10pm 
Hi man, awesome mod. Im having some trouble setting it up however. I followed the video step by step, double checked and dont seem to have missed anything. But Im trying to use this script with the large torpedo parts mod, do you know if that might cause the script not to work?
BaronBoogeyman 29 Apr, 2016 @ 7:25pm 
@Puff The Magic Dragon (Rassy): So far in my testing it seems to work just fine if the missiles are at literally any orientation at all, however I would recommend they be as close to 0deg off as possible due to chance of accidentally locking a wrong target (given my understanding of how the system works)
Frog Oil Saleswoman 18 Apr, 2016 @ 5:13pm 
Question. Will any of these, specifically the Coordinate Lock method, work if the missile is mounted 90deg from the target vector (eg a Vertical Launch System)?
scavenjer 17 Apr, 2016 @ 5:43am 
It seems to be working with your set up, i'll try to make one from scratch now, so far so good ;)
scavenjer 13 Apr, 2016 @ 6:57am 
Thank you Alysius i will test this as soon as i can and i'll comment if it works for me. :)
Alysius  [author] 13 Apr, 2016 @ 5:40am 
An SE bug prevented gyro from ahving full power while turning. It is suddenly fixed after an SE update.
Skitto493 26 Mar, 2016 @ 4:22pm 
well, the script isn't working for me in general.

The missile launches, but does not track the target I fire at.

Here's a test blueprint of my creation: please see what is wrong?
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=653557661
Skitto493 26 Mar, 2016 @ 4:03pm 
Is it mandatory to claim ownership of the missile and ship? Will it work if everything is owned by nobody?