Jump to content

Is it possible to despawn a full coalition or country all at once?


Recommended Posts

Posted (edited)

Is there an easy way to despawn every unit of a specific country/coalition?

I am asking because I am spawning several missions (through the F10 menus) and seems the be the cleanest/easiest way to wipe/reset them all up (assuming there is a function).

 

From what I found so far, the destroy() function will not do it and will not allow respawns afterward.

Edited by strikers_blade

My systems:

 

Windows 10 64 bits

I7-8700k

32.0 GB RAM

500Gb SSD

Asus ROG 2080ti

HP Reverb

 

Windows 10 64 bits

I7-6820HQ CPU @ 2.70Ghz

32.0 GB RAM

500Gb SSD

Nvidia Quadro M4000M

TrackIR 5

  • strikers_blade changed the title to Is it possible to despawn a full coalition or country all at once?
Posted
45 minutes ago, strikers_blade said:

Is there an easy way to despawn every unit of a specific country/coalition?

...

 

 

Yes, this script example that you can directly use in a "do script" box in mission editor will destroy (or deactivate) all red coalition's groups (whatever the type) :

 

for i, gp in pairs(coalition.getGroups(1)) do
targetGroup = Group.getByName(Group.getName(gp))
if targetGroup and targetGroup:isExist() == true then
targetGroup:destroy()
end    
end

 

You can change the number inside parenthesis in first line according to the available function's parameters here (for changing coalition or groups types) :
https://wiki.hoggitworld.com/view/DCS_func_getGroups
You can also use trigger.action.deactivateGroup(targetGroup) instead of targetGroup:destroy() on 4th line to deactivate instead of destroy.

Posted

just a few points for better scripting

13 hours ago, toutenglisse said:

Group.getByName(Group.getName(gp))

this is completely redundant. you already have the group object, its "gp".

 

13 hours ago, toutenglisse said:

if targetGroup and targetGroup:isExist() == true

this is completely redundant for multiple reasons:

1) "x == true" is the same as "x"
2) you just got the group object from DCS. that means "targetGroup" will certainly not be nil and isExist() will certainly be true. if either of those expressions werent as i say, the script would have already crashed at the getName().

 

 

14 hours ago, strikers_blade said:

From what I found so far, the destroy() function will not do it and will not allow respawns afterward.

correct.

the only way to respawn a group is via addGroup(). you can also multiplicate groups that way:

 

basically you want to destroy() the original and create a duplicate with addGroup().

CPU: AMD Ryzen 5 1600X

GPU: AMD RX 580

  • Recently Browsing   0 members

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