Jump to content

IA attack a group spawned by lua ?


inconnudiscret

Recommended Posts

Hello guys, 

 

I’ve been reading for hours and I can’t make it work...

 

 I have 50 CAS BLUE groups and a RED convoy , spawned dynamically somewhere on the map.
 

I need the BLUE units to engage it, problem I can’t use the attack group in the editor as it’s spawned dynamically. The convoy has group name « Convoy1 », is there a simple way to have the 50 groups detect and engage it ?


 

Also, can you simulate the detection of all the RED units in a zone and show them to all blue units on F10 map ? I want my E3 AWACS to act as a JSTAR.

 

thanks

 

Link to comment
Share on other sites

Rename your 50 groups : 'Blue CAS 1' to 'Blue CAS 50' (to match script) and use this "do script" :

 

local target = Group.getByName('Convoy1')
local groupId = Group.getID(target)
local Task = {
["id"] = "AttackGroup",
["params"] = {
["groupId"] = groupId,
},
}
for i = 1,50 do
local groupName = 'Blue CAS ' .. i
if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true and #Group.getByName(groupName):getUnits() > 0 then
Group.getByName(groupName):getController():pushTask(Task)
end
end

 

I don't know for your last question.

  • Thanks 1
Link to comment
Share on other sites

Thank you so much, do you know if it would be possible to do the same with a prefix ?  Like Cas ?

Because I named them casMig23-1...n, casMiG29-1...n and I already have so much lua with these names 


 

thanks 😊 
 

also they spawn randomly between 0s and 2h, is that an issue ? 

 


Edited by inconnudiscret
Link to comment
Share on other sites

You can make a group table including every group with 'cas' prefix and run the "pushtask" through the table in a similar way.
Spawning randomly is not an issue - just run the "attackGroup" when new cas group spawns, linked by a function-scheduller (and directly refering to the correct group name).

Link to comment
Share on other sites

Hi, I got it working, but only the first unit of each group is engaging my Convoy.

 

I use this, that I paste in each attack group 1st waypoint, under script

 

Is there a way to have a group attack ?

 

local target = Group.getByName('Convoy')
local groupId = Group.getID(target)
local Task = {
["id"] = "AttackGroup",
["params"] = {
["groupId"] = groupId,
["altitudeEnabled"] = true,
["altitude"] = 4500,
},
}

local groupName = 'Mig23-1'
if Group.getByName(groupName) and Group.getByName(groupName):isExist() == true and #Group.getByName(groupName):getUnits() > 0 then
Group.getByName(groupName):getController():pushTask(Task)
end

 

Link to comment
Share on other sites

Suppose it might be an issue with the weapons the aircraft are armed with and what they are attacking. 

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

  • Recently Browsing   0 members

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