Rex Posted July 7, 2023 Share Posted July 7, 2023 (edited) When it comes to AI aircraft for missions, I either set them as "Uncontrolled" (starting from ramp) or "Late Activation" (starting from runway or airborne) depending on how fast I need them to respond. Sometimes I change them around, though, so instead of remembering to change the activation function, I endeavored to write a function that would activate a group, regardless of which status it is in, and always use that function to launch a group, regardless of where it's starting from. While I know how to start the groups in either situation, I've been looking, but so far haven't found how to DETECT the statuses. So far I've only found how to detect whether they are alive or dead. Reading through the group attributes, I don't see any obvious one: https://wiki.hoggitworld.com/view/DCS_Scripting_orig_Part_2#Group Can someone point me in the right direction on this one? Thanks, Rex P.S. I marked the two lines in question below with 'Psuedocode' function groupStart(groupname) --- Start an "Uncontrolled" group --- group = Group.getByName(groupname) local Start = { id = 'Start', params = {} } controller = group:getController() controller:setCommand(Start) end function groupActivate(groupname) --- Start a "Late Activation" group --- group = Group.getByName(groupname) trigger.action.activateGroup(group) end function deploy(groupname) --- Auto-detect group status, either Uncontrolled or Late Activation, and activate that group group = Group.getByName(groupname) if group.isUncontrolled then <---------- PsuedoCode groupStart(groupname) elseif group.isLateActivation then <---------- PsuedoCode groupActivate(groupname) end end Edited July 7, 2023 by Rex Rex's Rig Intel i9-14900K | Nvidia RTX 4090 | 64GB DDR5 | 3x4TB 990 Pro M2 SSDs | HP Reverb 2 | 49" Samsung 5120x1440 @ 120Mhz TM Warthog Stick + Throttle | TM Pendulum Pedals | MS Sidewinder 2 FFB | Track IR | Cougar MFD x 2 Link to comment Share on other sites More sharing options...
Kanelbolle Posted July 7, 2023 Share Posted July 7, 2023 You can check a unit if it is active: if (Group.getByName(_GpName):getUnit(1):isActive() == false) then -- do stuff end WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/ Link to comment Share on other sites More sharing options...
Rex Posted July 7, 2023 Author Share Posted July 7, 2023 Right, the problem is, it doesn’t tell me if it’s in Uncontrolled or Late Activation.. Come to think of it, I think I can just call both functions against the group. I think it will just NOOP the one that doesn’t apply. Rex's Rig Intel i9-14900K | Nvidia RTX 4090 | 64GB DDR5 | 3x4TB 990 Pro M2 SSDs | HP Reverb 2 | 49" Samsung 5120x1440 @ 120Mhz TM Warthog Stick + Throttle | TM Pendulum Pedals | MS Sidewinder 2 FFB | Track IR | Cougar MFD x 2 Link to comment Share on other sites More sharing options...
Solution Kanelbolle Posted July 7, 2023 Solution Share Posted July 7, 2023 19 minutes ago, Rex said: Right, the problem is, it doesn’t tell me if it’s in Uncontrolled or Late Activation.. Come to think of it, I think I can just call both functions against the group. I think it will just NOOP the one that doesn’t apply. You can do that to. But yea, the command is for Late Activation: https://wiki.hoggitworld.com/view/DCS_func_isActive Mission Scripting Function: isActive Added with: 1.2.0 Member Of: Unit Syntax: boolean Unit.isActive(Class Self ) Description: Returns a boolean value if the unit is activated. Units set to late activation would return false if checked by this function. 1 WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/ Link to comment Share on other sites More sharing options...
Rex Posted July 8, 2023 Author Share Posted July 8, 2023 Aaah, I got it now, thanks! Rex's Rig Intel i9-14900K | Nvidia RTX 4090 | 64GB DDR5 | 3x4TB 990 Pro M2 SSDs | HP Reverb 2 | 49" Samsung 5120x1440 @ 120Mhz TM Warthog Stick + Throttle | TM Pendulum Pedals | MS Sidewinder 2 FFB | Track IR | Cougar MFD x 2 Link to comment Share on other sites More sharing options...
609_Relentov Posted February 1 Share Posted February 1 What about checking if a group set to late activation has actually been activated? From testing, when using isActive, if it's used on a group that is set to late activation, it returns false both before and after it's activated. I also tried isExist, but that will return true both on groups that are not set to late activation, as well as those that are (before or after activation). That's what I'm trying to figure out now (i.e. how to check if a group set to late activation has been activated or not). Thanks for any further suggestions... Link to comment Share on other sites More sharing options...
Kanelbolle Posted February 1 Share Posted February 1 (edited) 15 hours ago, 609_Relentov said: What about checking if a group set to late activation has actually been activated? From testing, when using isActive, if it's used on a group that is set to late activation, it returns false both before and after it's activated. I also tried isExist, but that will return true both on groups that are not set to late activation, as well as those that are (before or after activation). That's what I'm trying to figure out now (i.e. how to check if a group set to late activation has been activated or not). Thanks for any further suggestions... Not sure what you mean. Works just fine for me. See example mission and code -- Activation happens in the mission editor, but you could add it to the code. _GpName = "Ground-1" if (Group.getByName(_GpName):getUnit(1):isActive() == false) then trigger.action.outText("Group was not active, activating group :" .. _GpName , 10) elseif (Group.getByName(_GpName):getUnit(1):isActive() == true) then trigger.action.outText("Group is allready active :" .. _GpName , 10) end test-checkactivegroup.miz Edited February 1 by Kanelbolle WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/ Link to comment Share on other sites More sharing options...
609_Relentov Posted February 1 Share Posted February 1 Thanks, Kanelbolle, interesting that it works for you. I was utilizing isActive slightly differently, which was not working after the target groups/units were activated. for i, grp in pairs(coalition.getGroups(coalition.side.RED, Group.Category.GROUND)) do for idx, theUnit in pairs(Group.getUnits(grp)) do if (Unit.isActive(theUnit) == true) then -- late activation unit is active ... <do stuff> end end I can try it more how you are using the method/function and see how it goes. Link to comment Share on other sites More sharing options...
609_Relentov Posted February 2 Share Posted February 2 Interestingly now it's working - I had another condition in that expression with the isActive, so that may have been the culprit. In any case thanks for putting up your code example to help re-affirm that it's working. Link to comment Share on other sites More sharing options...
Recommended Posts