Jump to content

Detection Script Released


MBot

Recommended Posts

Hi TOViper

 

That little script of yours looks almost like something I have been looking for for a LONG time. Would it be possible to modify it so that if a Red EWR detects a blue unit of a specific name inside a specific zone a flag is set to a certain value? Like "If RedEWR dectects BluePlayer inside RedZone -> Flag 99 is 1. Skickat från min D5503 via Tapatalk

I use the "red" version in a multiplayer mission (I am currently creating) as well. You may use it for whatever you like as long as you quote the source with this very important info:

https://www.youtube.com/watch?v=QuoKNZjr8_U:megalol:

 

Bear in mind that if you use the getDetectedTargets() function, the list of units on the AWACS's screen doesn't contain information about WHO (which unit name) the target is.

I haven't played around with determining WHO the intrudor into the zone is, I only care about that THERE IS a intruding unit. The rest of the "responsibility" goes to the AWACS, that orders a CAP (or not).

In fact if the scripts detects an intrudor, I put the ROE of the CAPs (in this case the red CAPs) to "WEAPONS FREE" (before I set them to "RETURN FIRE"). The rest of the story (interception) is done by the units themselves.

Further note that the "red" script here takes care of two trigger zones (the "blue" version only takes care about a single one). Intruding into one of the two red zones - no matter which one - returns "TRUE".

BTW: The counter "InterestingTargets" is just for my own purpose, you don't really need it ;-)

 

 

 

[size=2]AWACS_RUS_Unit = Unit.getByName('Pilot_1_RUS_50_AI')
if AWACS_RUS_Unit ~= nil then
   AWACS_RUS_Ctrl = AWACS_RUS_Unit:getGroup():getController()
   local Targets = AWACS_RUS_Ctrl:getDetectedTargets(VISUAL, RADAR, RWR)
   if #Targets > 0 then
       local InterestingTargets = 0
       for n = 1, #Targets do
           if Targets[n].object:isExist() == true and Targets[n].object:inAir() == true and Targets[n].object:getCoalition() == 2 then
               InterestingTargets = InterestingTargets + 1
               local TargetPosition = Targets[n].object:getPosition()
               local RedZone1Info = trigger.misc.getZone('Red_Land1')
               local RedZone2Info = trigger.misc.getZone('Red_Land2')
               local DistanceToRedZone1 = math.sqrt(math.pow(TargetPosition.p.x - RedZone1Info.point.x, 2) + math.pow(TargetPosition.p.y - RedZone1Info.point.y, 2))
               local DistanceToRedZone2 = math.sqrt(math.pow(TargetPosition.p.x - RedZone2Info.point.x, 2) + math.pow(TargetPosition.p.y - RedZone2Info.point.y, 2))
               if DistanceToRedZone1 <= RedZone1Info.radius or DistanceToRedZone2 <= RedZone2Info.radius then
                   return true
               end
           end
       end
   end
end[/size]

Happy to help, and I really hope you find your way ...:joystick:


Edited by TOViper

Visit https://www.viggen.training
...Viggen... what more can you ask for?

my computer:
AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1

 

Link to comment
Share on other sites

I tried it TOViper, indeed it is alive! It works! Now I can scramble GCIs from the ground when a intruder is detected. I edited it so I switched the Red AWACS for a Red EWR on the ground. The only reson for having it tied to a specific unit was to have it tied to the player in single player just in case some friendly AI wingman or something started doing something wierd instead of flying low im cover. But they are working on the AI as I hear so it this is good enough :)

 

Skickat från min D5503 via Tapatalk

Link to comment
Share on other sites

  • 2 weeks later...
:happy:
Hey TOViper, since you are much better than me on this lua scripting I hope you dont mind me asking if you know if your little version of this script can be tweaked so that it returns true if no blue target is detected in the zone. I have tried myself but I cant figure it out.

 

I have sam-radars that randomly goes online for a short time and then shuts down again with the exeption of a blue target is detected, then the shutdown should not happen. So the shutdown trigger should only execute if it is true that there are no blue targets in the zone.

 

Skickat från min D5503 via Tapatalk

Link to comment
Share on other sites

Hey TOViper, since you are much better than me on this lua scripting I hope you dont mind me asking if you know if your little version of this script can be tweaked so that it returns true if no blue target is detected in the zone. I have tried myself but I cant figure it out.

 

I have sam-radars that randomly goes online for a short time and then shuts down again with the exeption of a blue target is detected, then the shutdown should not happen. So the shutdown trigger should only execute if it is true that there are no blue targets in the zone.

 

Skickat från min D5503 via Tapatalk

 

 

just replace this line:

if DistanceToRedZone1 <= RedZone1Info.radius or DistanceToRedZone2 <= RedZone2Info.radius then

 

with this one:

if DistanceToRedZone1 >= RedZone1Info.radius AND DistanceToRedZone2 >= RedZone2Info.radius then

I dont have the chance to test it since I am not at home, but it is worth a try ;)

Visit https://www.viggen.training
...Viggen... what more can you ask for?

my computer:
AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1

 

Link to comment
Share on other sites

I will try it! Thank you!

 

But when thinking about it, I dont think it will work fully since I guess that means that it will become true if a blue target is detected outside of the zone but not if no blue target is detected at all. I dont know if its possible but if it dont work I will try to replace the line you are saying to:

if DistanceToRedZone1 >= RedZone1Info.radius AND DistanceToRedZone2 >= RedZone2Info.radius or InterestingTargets = 0 then


Edited by Fisherman82
Link to comment
Share on other sites

I am sorry for not getting what you initially hunted for ...

 

 

Ok, in your case you have to modifiy this:

if #Targets > 0 then

...

..

.

to this:

if #Targets = 0 then

return true

 

 

 

 

 

 

EDIT: be aware, the list of targets of the AWACS is kept for a very long time within the aircraft, thus it might be the case that 20 minutes after a target is physically not visible to any sensor of the AWACS, the list still contains the aircraft.

 


Edited by TOViper

Visit https://www.viggen.training
...Viggen... what more can you ask for?

my computer:
AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1

 

Link to comment
Share on other sites

Ok

 

But everytime the condition (the LUA predicate) is evaluated is not the list updated?

 

 

I hope I get your question right, ...

 

 

 

The "internal list" of the AWACS is evaluated (=asked) every time the script runs. If a CONTINUOUS TRIGGER is used this happens every single second.

Visit https://www.viggen.training
...Viggen... what more can you ask for?

my computer:
AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1

 

Link to comment
Share on other sites

Yes I think you understand almost what I mean, I might not know what Im asking exactly though :)

 

Im thinking if what you said about targets staying in the list for 20 min or more will be a problem for me. Say like this:

 

If the scritpt is run once it creates this internal list with targets and then the trigger might become true because of this. If the script is then run again 20 minutes later, targets that are detected then will be added to the list, but will the old targets from 20 minutes earlier remain on it also? So that basicly, if a target was detected the first time, the script will always come up with true because it still detects this target 20 minutes later when it is run again. Or does the list reset every time the script is run? I get it that targets stay on it until it is run again but that wont be a problem for me.

Link to comment
Share on other sites

Yes I think you understand almost what I mean, I might not know what Im asking exactly though :)

 

Im thinking if what you said about targets staying in the list for 20 min or more will be a problem for me. Say like this:

 

If the scritpt is run once it creates this internal list with targets and then the trigger might become true because of this. If the script is then run again 20 minutes later, targets that are detected then will be added to the list, but will the old targets from 20 minutes earlier remain on it also? So that basicly, if a target was detected the first time, the script will always come up with true because it still detects this target 20 minutes later when it is run again. Or does the list reset every time the script is run? I get it that targets stay on it until it is run again but that wont be a problem for me.

 

 

The information of existing "targets" is existent in the AWACS (the DCS object), no matter if you request the list from the AWACS or not.

 

 

I have tried to determine how long a "target" is kept in the AWACS after it disappears from line of sight,and I think it was something of 20 minutes or so. This makes sense to me, since it might be interesting for the AWACS to know what happend 20 minutes ago ... like: "yes guys ... there were targets , .... last known position was ... here and there ... go and search this area to terminate them .... :P)

 

 

 

If I am not wrong (and I really hope it is 100% true what I am writing here), the script always starts from scratch when it runs (meaning all variables are emtpy when it starts running), since the definition of the variables are kept "local". Thus the list I build up with the script is created from scratch every single time it runs.

Visit https://www.viggen.training
...Viggen... what more can you ask for?

my computer:
AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1

 

Link to comment
Share on other sites

I belive you are right, it has got to be that way that the list is reset everytime it runs.

 

I really appreciate your help by the way

 

I applied the first version that becomes true if it detects to a number of ground radars and also four fighter caps, it worked for all of them except for two of the caps.

For them I get a script error when the mission starts, something like "CAP3_RED_Unit does not exist"

I use the exact same script for the two first caps that work exept I call it "CAP1_RED" and "CAP2_RED" in the script not to cause a conflict of some kind. The differce is that the two that works spawn in the air at mission start and the two that dont work start at the ramp at Shiraz as uncontrolled and is then started at a later time with a task push trigger. The wierd thing is that if I set them to spawn in the air like the two that works and remove the rask push trigger it does not help, i still get the script error but they should be set up exactly as the two that works

 

Skickat från min D5503 via Tapatalk

Link to comment
Share on other sites

I belive you are right, it has got to be that way that the list is reset everytime it runs.

 

I really appreciate your help by the way

 

I applied the first version that becomes true if it detects to a number of ground radars and also four fighter caps, it worked for all of them except for two of the caps.

For them I get a script error when the mission starts, something like "CAP3_RED_Unit does not exist"

I use the exact same script for the two first caps that work exept I call it "CAP1_RED" and "CAP2_RED" in the script not to cause a conflict of some kind. The differce is that the two that works spawn in the air at mission start and the two that dont work start at the ramp at Shiraz as uncontrolled and is then started at a later time with a task push trigger. The wierd thing is that if I set them to spawn in the air like the two that works and remove the rask push trigger it does not help, i still get the script error but they should be set up exactly as the two that works

 

Skickat från min D5503 via Tapatalk

 

 

 

 

I place all three CAPs on the map right from the beginning of the mission.

But I activate the check mark for "UNCONTROLLED". This means the pilots are not in the aircraft (which is on ground), and thus the engines are not running until the moment I send them the START command with the "AI TASK PUSH".

 

But before sending this AI TASK PUSH (respectively set in in the mission editor), you have to add the START commando to the "TRIGGERED ACTIONS" of the CAP (the symbol looks like a hashtag with loops). Once this triggered action is entered there, you might then use the AI TASK PUSH in your trigger.

 

 

See more details here if you have problems adding the "TRIGGERED ACTIONS" (don't mix these up with the TRIGGERS).

Starting from my post on 01-14-2019, 08:46 AM.

https://forums.eagle.ru/showthread.php?p=3765365#post3765365

 

 

 

 

BTW: if an object doesn't exist at a certain mission time (no matter if it exists in the ME), you can't use scripts to do something with it. Of course ... ;-)

 

 

EDIT: IIRC the trigger which contains the lua predicate also checks if the object exists. if it doesn't exist, the trigger doesn't run.


Edited by TOViper

Visit https://www.viggen.training
...Viggen... what more can you ask for?

my computer:
AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1

 

Link to comment
Share on other sites

The task push and start is exactly how I do it, Im pretty good at that :)

There is some other problem, and it only happens to two of my four flights.

I tried to rename them and let them start in the air like the others but it did not help, its wierd, this is the error Im getting

DSC_0888.thumb.jpg.3bf384868e7f8c3bf78a89fe1d5e7b0a.jpg

Link to comment
Share on other sites

The task push and start is exactly how I do it, Im pretty good at that :)

There is some other problem, and it only happens to two of my four flights.

I tried to rename them and let them start in the air like the others but it did not help, its wierd, this is the error Im getting

 

 

ok, you seem to be faster than me ... sorry :)

 

 

Ok, got it.

Obviously the object doesnt' exist on the map when mission starts. The triggers seem to be "quicker".

I think making the trigger run when 2 seconds of mission time are gone would help.

I am currently using the TIME MORE 2 seconds as TRIGGER condition.

Visit https://www.viggen.training
...Viggen... what more can you ask for?

my computer:
AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1

 

Link to comment
Share on other sites

  • 4 weeks later...

I found a possible bug/unfinished function today.

 

The following code lines produce the same list of "radartargets" of the E-3, but I think ED had other ideas when creating these options ...

 

1st version: local BlueTargets = AWACS_USA_Ctrl:getDetectedTargets(VISUAL, RADAR, RWR)
2nd version: local BlueTargets = AWACS_USA_Ctrl:getDetectedTargets(RWR)

 

E-3's radar was obviously ON, but they detected me even when only RWR was coded.

I didn't point my radar onto them, because from the beginning on I was flying in the other direction.

I tried out with VISUAL, and they got me even if I was behind them and 30 km away.

Visit https://www.viggen.training
...Viggen... what more can you ask for?

my computer:
AMD Ryzen 5600G | NVIDIA GTX 1080 Ti OC 11GB | 32 GB 3200 MHz DDR4 DUAL | SSD 980 256 GB SYS + SSD 2TB DCS | TM Warthog Stick + Throttle + TPR | Rift CV1

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...