Jump to content

Determining Pre-Active Status?


Rex
Go to solution Solved by Kanelbolle,

Recommended Posts

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 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

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

  • Solution
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.

  • Thanks 1
Link to comment
Share on other sites

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

  • 6 months later...

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

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 by Kanelbolle
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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