Getting fighters to descend when targeted/defensive

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
User avatar
Struan76
Posts: 38
Joined: Tue Sep 03, 2019 7:38 am

Getting fighters to descend when targeted/defensive

Post by Struan76 »

This might have already been addressed - how to do I get fighters to descend 5kft and hold manual altitude when targeted (eg engaged defensive).

Currently if I use this basic script the fighter will climb back up to some pre-set altitude (eg station alt).

Code: Select all

local function dragdefend()
     local unit = SE_GetUnit({name='J-11D Flanker B [Su-27SK Copy]', guid='JUKBGX-0HMCITSF58TL8'})
     local block = 5000/3.208
         if unit.firedOn then
         local newalt = unit.altitude-block
         SE_SetUnit({unitname=unit.name, manualaltitude=newalt})
         print (newalt..'m')
         end
 end

The idea is for fighters to gain energy when in a defensive turn - dropping a block. I have a much longer code sample that sets all the behaviours based on crank logic (eg start high finish low) but that is based on first shot opportunity. I want to make it so a fighter that is shot conducts the standard AI defensive routine but also descends 5,000ft. Possible? The aforementioned code I turn off the Automatic Evasion function. But I quite like everything the AI does, apart from the altitude, so I'd prefer just to have the code force the altitude change.
User avatar
Struan76
Posts: 38
Joined: Tue Sep 03, 2019 7:38 am

RE: Getting fighters to descend when targeted/defensive

Post by Struan76 »

Would also like to ensure this only iterates once per shot, can't figure out how to make that work in Event Editor (current event trigger using 'Unit Remains in Area', which means the targeted fighter keeps trying to descend as long as there are missiles in flight).

KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Getting fighters to descend when targeted/defensive

Post by KnightHawk75 »

Possible?
---
Should be.
The aforementioned code I turn off the Automatic Evasion function. But I quite like everything the AI does, apart from the altitude, so I'd prefer just to have the code force the altitude change.
---
That may be where the boggle is, kinda can't let the ai take control _and_ still override alt (least most the time as I recall), you either let it engage and do it's thing, or do everything yourself has been my experience - ie with engaged offensive or defensive they take on a mind of their own most of the time based on the profiles involved.
Post Reply

Return to “Lua Legion”