Not a member yet? Why not Sign up today
Create an account  

  • 4 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 
Smart Lua Missile Guidance System v2.1.2

#1
Smart Lua Missile Guidance System

Feature Overview:
-Easily configurable, just edit the varaibles at the top of the code, should work on any vessel.
-Full guidance system for all lua enabled missiles, including missile interceptors.
-Highly accurate prediction system. (Uses second order mathematics and time-stepped modelling)
-Designates missiles to each enemy target based on thier score (score from mainframe).
-Different guidance styles:
  • Attack from above(Javelin style)
  • Attack from below
  • Direct engagement
  • Sea skimming
  • Anything else you can think of using the config variables
-Terrain aviodance system.
-Allied vessel avoidance system. (Accounts for velocity and bounding box with a time-stepped model)
-Safe detonation of missiles if there are no valid target.
-Can control some or all lua enabled missiles on a vehicle meaning different lua blocks with different settings can control different missiles.
-Missiles can be detonated when they are within a certain range of thier target.(By default turned off, by negative config value)
-Sea diving. If the target is in the water, dive into the water just before impact for explosives buff.
-Missile thrust control
  • Provides more thrust for faster targets
  • Provides boost thrust upon final closing for extra kinetic damage from Thumpers
or a different system that attempts to automatically find the best thrust values based off:
  • Predicted time till interception
  • Missile fuel left
  • Time till missile despawns (60 + (number of regulators * 180))


Links to 2.1.2 code:
.txt   FTD_Smart_Missile_Guidance_System_V2.txt (Size: 39.74 KB / Downloads: 1,336)
https://pastebin.com/yccQy1mG

Links to 1.4.0 code:
.txt   FTD_Smart_Lua_Missile_System.txt (Size: 20.73 KB / Downloads: 727)
http://pastebin.com/P2N9KyQb

   


*change notes*
17/10/2017 2.1.2
-Can now use weapon slots instead of weapons controller ID

09/09/2017 2.1.1
-Multitargetting can be turned off, if done everything targets the highest scoring enemy
-Minor fixes

30/08/2017 2.1.0
-Thrust levels can now be calculated using the fuel time left and the time till despawn of the missile. (Yes it accounts for any regulators you have)
-Calculates if the mssile can turn in time to hit the target, if not goes 'off course' till it can
-Missile can be detonated if it runs out of fuel

16/08/2017 2.0.1
-Fixed bug which was incorrectly deallocating usable lua transcievers

15/08/2017 2.0.0
-Huge rewrite of code
-Reworked and fixed the predictive algorithm
-Fixed the acceleration calculations
-Code can now control missile interceptors
-Missile thrust now also uses the angle to target in its calculations
-Missiles can now dive into the water just before impacting with a naval target for an explosives buff
-Choosing to a direct engagement guidance (putting the max crusing range higher than the max allowed range) will no longer disable ground aviodance

29/07/2017 1.4.0
-Missile thrust control (thanks to Aleksander Wit for pointing out this was possible, despite the lack of documentation on it)
-Provides more thrust for faster targets
-Provides boost thrust upon final closing for extra kinetic damage from Thumpers
-Rewritten en route cruising code

26/07/2017 1.3.1:
-Bug fixes thanks to evilebob.

20/03/17 1.3:
-Direct engagement range can now change dependant on target speed. (Useful for shooting down really fast targets)

08/03/17 1.2:
-Fixed lots of bugs.
-Code cleanup.
-Improved the prediction system. (Now accounts for the missile acceleration)
-Missiles can be detonated when they are within a certain range of thier target. (By default turned off, by negative config value)

06/03/17 1.1:
-Fixed bugs causing the guidance system to crash...usually causing the missile to do the same.
-Added user variables which enable use of torpedos
-Added function so each lua control block only controls lua transceivers near (user configured range) the associated missile control block.

05/03/17 1.0:
-Release
*end change notes*

Example missile cruiser, using two different types of missile in addition to torpedos all using this script with different user config files:
   
Download blueprint:
.blueprint   Hurricane.blueprint (Size: 643.11 KB / Downloads: 187)
(Note: Uses v1.3.0 which is bugged)

Updated version of the Hurricane which uses v2.0.0 code:
.blueprint   Maelstrom.blueprint (Size: 484.3 KB / Downloads: 131)



Example config setups for v2.1.2, just copy these over the existing config:

Long range attack from above cruise missile with sea diving(default):
Quote:--User Config Variables

--Launcher vehicle variables
MainFrameID = 0; --Which MainFrame to connect to
UseWeaponsSlots = false;
--If 'true' will use all weapons control blocks using the weapons slot of the variable 'WeaponID'
--If 'false' will use the weapons control block with the ID of the variable 'WeaponID'
WeaponID = 0;
MaxDistanceBetweenLuaTranscieverAndMissileControl = 10; --The maximum distnace between a lua transciever and its corrisponding missile control block.

--Missile variables
MissileInterceptor = false; --Set true if using being used for missile interception
TargetDetonationRange = -10; --If the distance between target and missile is below this value, blow up.

--Target acquisition variables
MultiTarget = true;
MaxRange = 4000; --Targets above this range from the missile launcher will be ignored.
MaxTargetHeight = 10000; --Targets above this height will be ignored.
MinTargetHeight = -20; --Targets below this range will be ignored.

--Safe detonation variables
SafeDetonteAltitude = 500; --If there are no target, goto and detonte at this altitude.
DetonateMissileUponEmptyFuel = true; --If the missile has run out of fuel, detonate?

--Missile boost variables
UseFuelDefinedThrustControl = true;
--If true: Uses the predicted time to intercept and the amount of remaining fuel to calculate thrust value. More adaptable to different ranges.
--If false: Uses the 'BaseMissileThrust' added to the target speed multiplied by 'MissileThrustTargetSpeedMultiplier' to calculate thrust.
--In both: If target is below 'BoostInterceptionTime' then thrust is multiplied by 'BoostThrustMultiplier'
BaseMissileThrust = 300; --Base thrust for missile.
MissileThrustTargetSpeedMultiplier = 10.0; --Value is multiplied by target's speed then added to base thrust of missile, useful for fast targets. Not used is UseFuelDefinedThrustControl = true.
BoostInterceptionTime = 6.0; --When the intercept time falls below this value,'BoostThrust' is added to missile thrust, useful for Thumpers.
BoostThrustMultiplier = 1.2; --Value multiplied to missile thrust once within boost range.

--Check angle to intercept variables
InterceptionTurnAngleTollerance = 5; --Added tollerance when calculating whether to steer away from target as interception is deemed currently impossible due to too steep an angle.

--Cruising variables
BaseDirectEngagementGroundRange = 240; --Below this ground range to target, head directly to target.
DirectEngagementGroundRangeSpeedMultipler = 0.6; --Added onto the engagement range after it has been multiplied by the target speed, used for fast targets.
CruisingAltitude = 250; --While en route travel at this altitude.
CruisingAltitudeAboveTerrain = 30; --If terrain nears cruising altitude, travel this heigh above the terrain.
MaxAllowedCruisingAltitude = 10000; --Missile will try and aviod going above this altitude
MinAllowedCruisingAltitude = 10; --Missile will try and aviod going below this altitude

--SeaDive variables
GroundRangeToTargetToSeaDive = 200;--Below this ground range to target, start diving underwater for explosives buff.
MaxTargetHeightForSeaDive = 5; --Max height of enemy aimpoint above the water to use seadiving on.
AdditionalSeaDiveDepth = 5; --Additional depth added to enemy aimpoint when seadriving.

--Anti ally collsion variables
AntiAlliedCollisionPredictionTimeLimit = 8; --Used to prevent missile-allied vessel collisions, number is seconds into the future predicted.
AntiAlliedCollisionPredictionTimeStep = 1; --The time step in seconds used to prevent missile-allied vessel collisions.
AntiAlliedCollisionAdditionalSafetyRange = 5; --Additional range to border of allies to avoid.

--End of User Config Variables


Long range attack from below torpedo:
Quote:--User Config Variables

--Launcher vehicle variables
MainFrameID = 0; --Which MainFrame to connect to
UseWeaponsSlots = false;
--If 'true' will use all weapons control blocks using the weapons slot of the variable 'WeaponID'
--If 'false' will use the weapons control block with the ID of the variable 'WeaponID'
WeaponID = 0;
MaxDistanceBetweenLuaTranscieverAndMissileControl = 10; --The maximum distnace between a lua transciever and its corrisponding missile control block.

--Missile variables
MissileInterceptor = false; --Set true if using being used for missile interception
TargetDetonationRange = -10; --If the distance between target and missile is below this value, blow up.

--Target acquisition variables
MultiTarget = true;
MaxRange = 4000; --Targets above this range from the missile launcher will be ignored.
MaxTargetHeight = 30; --Targets above this height will be ignored.
MinTargetHeight = -5000; --Targets below this range will be ignored.

--Safe detonation variables
SafeDetonteAltitude = -500; --If there are no target, goto and detonte at this altitude.
DetonateMissileUponEmptyFuel = true; --If the missile has run out of fuel, detonate?

--Missile boost variables
UseFuelDefinedThrustControl = false;
--If true: Uses the predicted time to intercept and the amount of remaining fuel to calculate thrust value. More adaptable to different ranges.
--If false: Uses the 'BaseMissileThrust' added to the target speed multiplied by 'MissileThrustTargetSpeedMultiplier' to calculate thrust.
--In both: If target is below 'BoostInterceptionTime' then thrust is multiplied by 'BoostThrustMultiplier'
BaseMissileThrust = 500; --Base thrust for missile.
MissileThrustTargetSpeedMultiplier = 10.0; --Value is multiplied by target's speed then added to base thrust of missile, useful for fast targets.
BoostInterceptionTime = 6.0; --When the intercept time falls below this value,'BoostThrust' is added to missile thrust, useful for Thumpers.
BoostThrustMultiplier = 15; --Value multiplied to missile thrust once within boost range.

--Check angle to intercept variables
InterceptionTurnAngleTollerance = 5; --Added tollerance when calculating whether to steer away from target as interception is deemed currently impossible due to too steep an angle.

--Cruising variables
BaseDirectEngagementGroundRange = 240; --Below this ground range to target, head directly to target.
DirectEngagementGroundRangeSpeedMultipler = 0.8; --Added onto the engagement range after it has been multiplied by the target speed, used for fast targets.
CruisingAltitude = -180; --While en route travel at this altitude.
CruisingAltitudeAboveTerrain = 30; --If terrain nears cruising altitude, travel this heigh above the terrain.
MaxAllowedCruisingAltitude = -5; --Missile will try and aviod going above this altitude
MinAllowedCruisingAltitude = -5000; --Missile will try and aviod going below this altitude

--SeaDive variables
GroundRangeToTargetToSeaDive = -10;--Below this ground range to target, start diving underwater for explosives buff.
MaxTargetHeightForSeaDive = 0; --Max height of enemy aimpoint above the water to use seadiving on.
AdditionalSeaDiveDepth = 0; --Additional depth added to enemy aimpoint when seadriving.

--Anti ally collsion variables
AntiAlliedCollisionPredictionTimeLimit = 8; --Used to prevent missile-allied vessel collisions, number is seconds into the future predicted.
AntiAlliedCollisionPredictionTimeStep = 1; --The time step in seconds used to prevent missile-allied vessel collisions.
AntiAlliedCollisionAdditionalSafetyRange = 5; --Additional range to border of allies to avoid.

--End of User Config Variables

Short range direct engagement frag missile
Quote:--User Config Variables

--Launcher vehicle variables
MainFrameID = 0; --Which MainFrame to connect to
UseWeaponsSlots = false;
--If 'true' will use all weapons control blocks using the weapons slot of the variable 'WeaponID'
--If 'false' will use the weapons control block with the ID of the variable 'WeaponID'
WeaponID = 0;
MaxDistanceBetweenLuaTranscieverAndMissileControl = 10; --The maximum distnace between a lua transciever and its corrisponding missile control block.

--Missile variables
MissileInterceptor = false; --Set true if using being used for missile interception
TargetDetonationRange = 10; --If the distance between target and missile is below this value, blow up.

--Target acquisition variables
MultiTarget = true;
MaxRange = 2000; --Targets above this range from the missile launcher will be ignored.
MaxTargetHeight = 10000; --Targets above this height will be ignored.
MinTargetHeight = -20; --Targets below this range will be ignored.

--Safe detonation variables
SafeDetonteAltitude = 400; --If there are no target, goto and detonte at this altitude.
DetonateMissileUponEmptyFuel = true; --If the missile has run out of fuel, detonate?

--Missile boost variables
UseFuelDefinedThrustControl = false;
--If true: Uses the predicted time to intercept and the amount of remaining fuel to calculate thrust value. More adaptable to different ranges.
--If false: Uses the 'BaseMissileThrust' added to the target speed multiplied by 'MissileThrustTargetSpeedMultiplier' to calculate thrust.
--In both: If target is below 'BoostInterceptionTime' then thrust is multiplied by 'BoostThrustMultiplier'
BaseMissileThrust = 750; --Base thrust for missile.
MissileThrustTargetSpeedMultiplier = 10.0; --Value is multiplied by target's speed then added to base thrust of missile, useful for fast targets.
BoostInterceptionTime = 5.0; --When the intercept time falls below this value,'BoostThrust' is added to missile thrust, useful for Thumpers.
BoostThrustMultiplier = 15; --Value multiplied to missile thrust once within boost range.

--Check angle to intercept variables
InterceptionTurnAngleTollerance = 5; --Added tollerance when calculating whether to steer away from target as interception is deemed currently impossible due to too steep an angle.

--Cruising variables
BaseDirectEngagementGroundRange = 2000; --Below this ground range to target, head directly to target.
DirectEngagementGroundRangeSpeedMultipler = 0.6; --Added onto the engagement range after it has been multiplied by the target speed, used for fast targets.
CruisingAltitude = 250; --While en route travel at this altitude.
CruisingAltitudeAboveTerrain = 30; --If terrain nears cruising altitude, travel this heigh above the terrain.
MaxAllowedCruisingAltitude = 10000; --Missile will try and aviod going above this altitude
MinAllowedCruisingAltitude = 10; --Missile will try and aviod going below this altitude

--SeaDive variables
GroundRangeToTargetToSeaDive = -10;--Below this ground range to target, start diving underwater for explosives buff.
MaxTargetHeightForSeaDive = 5; --Max height of enemy aimpoint above the water to use seadiving on.
AdditionalSeaDiveDepth = 5; --Additional depth added to enemy aimpoint when seadriving.

--Anti ally collsion variables
AntiAlliedCollisionPredictionTimeLimit = 8; --Used to prevent missile-allied vessel collisions, number is seconds into the future predicted.
AntiAlliedCollisionPredictionTimeStep = 1; --The time step in seconds used to prevent missile-allied vessel collisions.
AntiAlliedCollisionAdditionalSafetyRange = 5; --Additional range to border of allies to avoid.

--End of User Config Variables

Long range sea skimming/diving missile :
Quote:--User Config Variables

--Launcher vehicle variables
MainFrameID = 0; --Which MainFrame to connect to
UseWeaponsSlots = false;
--If 'true' will use all weapons control blocks using the weapons slot of the variable 'WeaponID'
--If 'false' will use the weapons control block with the ID of the variable 'WeaponID'
WeaponID = 0;
MaxDistanceBetweenLuaTranscieverAndMissileControl = 10; --The maximum distnace between a lua transciever and its corrisponding missile control block.

--Missile variables
MissileInterceptor = false; --Set true if using being used for missile interception
TargetDetonationRange = -10; --If the distance between target and missile is below this value, blow up.

--Target acquisition variables
MultiTarget = true;
MaxRange = 4000; --Targets above this range from the missile launcher will be ignored.
MaxTargetHeight = 10000; --Targets above this height will be ignored.
MinTargetHeight = -20; --Targets below this range will be ignored.

--Safe detonation variables
SafeDetonteAltitude = 500; --If there are no target, goto and detonte at this altitude.
DetonateMissileUponEmptyFuel = true; --If the missile has run out of fuel, detonate?

--Missile boost variables
UseFuelDefinedThrustControl = false;
--If true: Uses the predicted time to intercept and the amount of remaining fuel to calculate thrust value. More adaptable to different ranges.
--If false: Uses the 'BaseMissileThrust' added to the target speed multiplied by 'MissileThrustTargetSpeedMultiplier' to calculate thrust.
--In both: If target is below 'BoostInterceptionTime' then thrust is multiplied by 'BoostThrustMultiplier'
BaseMissileThrust = 500; --Base thrust for missile.
MissileThrustTargetSpeedMultiplier = 10.0; --Value is multiplied by target's speed then added to base thrust of missile, useful for fast targets.
BoostInterceptionTime = 6.0; --When the intercept time falls below this value,'BoostThrust' is added to missile thrust, useful for Thumpers.
BoostThrustMultiplier = 15; --Value multiplied to missile thrust once within boost range.

--Check angle to intercept variables
InterceptionTurnAngleTollerance = 5; --Added tollerance when calculating whether to steer away from target as interception is deemed currently impossible due to too steep an angle.

--Cruising variables
BaseDirectEngagementGroundRange = 240; --Below this ground range to target, head directly to target.
DirectEngagementGroundRangeSpeedMultipler = 0.6; --Added onto the engagement range after it has been multiplied by the target speed, used for fast targets.
CruisingAltitude = 15; --While en route travel at this altitude.
CruisingAltitudeAboveTerrain = 30; --If terrain nears cruising altitude, travel this heigh above the terrain.
MaxAllowedCruisingAltitude = 10000; --Missile will try and aviod going above this altitude
MinAllowedCruisingAltitude = 5; --Missile will try and aviod going below this altitude

--SeaDive variables
GroundRangeToTargetToSeaDive = 200;--Below this ground range to target, start diving underwater for explosives buff.
MaxTargetHeightForSeaDive = 5; --Max height of enemy aimpoint above the water to use seadiving on.
AdditionalSeaDiveDepth = 5; --Additional depth added to enemy aimpoint when seadriving.

--Anti ally collsion variables
AntiAlliedCollisionPredictionTimeLimit = 8; --Used to prevent missile-allied vessel collisions, number is seconds into the future predicted.
AntiAlliedCollisionPredictionTimeStep = 1; --The time step in seconds used to prevent missile-allied vessel collisions.
AntiAlliedCollisionAdditionalSafetyRange = 5; --Additional range to border of allies to avoid.

--End of User Config Variables

Short range direct engagement missile interceptor
Quote:--User Config Variables

--Launcher vehicle variables
MainFrameID = 0; --Which MainFrame to connect to
UseWeaponsSlots = false;
--If 'true' will use all weapons control blocks using the weapons slot of the variable 'WeaponID'
--If 'false' will use the weapons control block with the ID of the variable 'WeaponID'
WeaponID = 0;
MaxDistanceBetweenLuaTranscieverAndMissileControl = 10; --The maximum distnace between a lua transciever and its corrisponding missile control block.

--Missile variables
MissileInterceptor = true; --Set true if using being used for missile interception
TargetDetonationRange = 4; --If the distance between target and missile is below this value, blow up.

--Target acquisition variables
MultiTarget = true;
MaxRange = 2000; --Targets above this range from the missile launcher will be ignored.
MaxTargetHeight = 10000; --Targets above this height will be ignored.
MinTargetHeight = -20; --Targets below this range will be ignored.

--Safe detonation variables
SafeDetonteAltitude = 1000; --If there are no target, goto and detonte at this altitude.
DetonateMissileUponEmptyFuel = true; --If the missile has run out of fuel, detonate?

--Missile boost variables
UseFuelDefinedThrustControl = false;
--If true: Uses the predicted time to intercept and the amount of remaining fuel to calculate thrust value. More adaptable to different ranges.
--If false: Uses the 'BaseMissileThrust' added to the target speed multiplied by 'MissileThrustTargetSpeedMultiplier' to calculate thrust.
--In both: If target is below 'BoostInterceptionTime' then thrust is multiplied by 'BoostThrustMultiplier'
BaseMissileThrust = 600; --Base thrust for missile.
MissileThrustTargetSpeedMultiplier = 10.0; --Value is multiplied by target's speed then added to base thrust of missile, useful for fast targets.
BoostInterceptionTime = 8.0; --When the intercept time falls below this value,'BoostThrust' is added to missile thrust, useful for Thumpers.
BoostThrustMultiplier = 1; --Value multiplied to missile thrust once within boost range.

--Check angle to intercept variables
InterceptionTurnAngleTollerance = 5; --Added tollerance when calculating whether to steer away from target as interception is deemed currently impossible due to too steep an angle.

--Cruising variables
BaseDirectEngagementGroundRange = 2000; --Below this ground range to target, head directly to target.
DirectEngagementGroundRangeSpeedMultipler = 0.6; --Added onto the engagement range after it has been multiplied by the target speed, used for fast targets.
CruisingAltitude = 250; --While en route travel at this altitude.
CruisingAltitudeAboveTerrain = 30; --If terrain nears cruising altitude, travel this heigh above the terrain.
MaxAllowedCruisingAltitude = 10000; --Missile will try and aviod going above this altitude
MinAllowedCruisingAltitude = 10; --Missile will try and aviod going below this altitude

--SeaDive variables
GroundRangeToTargetToSeaDive = -10;--Below this ground range to target, start diving underwater for explosives buff.
MaxTargetHeightForSeaDive = 5; --Max height of enemy aimpoint above the water to use seadiving on.
AdditionalSeaDiveDepth = 5; --Additional depth added to enemy aimpoint when seadriving.

--Anti ally collsion variables
AntiAlliedCollisionPredictionTimeLimit = 8; --Used to prevent missile-allied vessel collisions, number is seconds into the future predicted.
AntiAlliedCollisionPredictionTimeStep = 1; --The time step in seconds used to prevent missile-allied vessel collisions.
AntiAlliedCollisionAdditionalSafetyRange = 5; --Additional range to border of allies to avoid.

--End of User Config Variables

Please report any bugs or problems and feel free to give suggestions for further features.
I consider my ambassadors to be the best in the world, they always seem to come to a successful resolution, I just wish they could learn to use a few less missiles on passing seagulls.
Reply



Messages In This Thread
Smart Lua Missile Guidance System v2.1.2 - by 6dwavenminer - 2017-03-07, 12:15 AM
RE: Smart Lua Missile Guidance System - by Wraith - 2017-03-26, 02:28 PM
RE: Smart Lua Missile Guidance System - by Softie - 2019-05-29, 01:28 AM
RE: Smart Lua Missile Guidance System - by Amadan - 2017-08-15, 02:46 PM
RE: Smart Lua Missile Guidance System - by Amadan - 2017-08-15, 09:59 PM
RE: Smart Lua Missile Guidance System - by Amadan - 2017-08-16, 12:21 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)