Jump to content
stuguy

high command scripting, reverse lookup in allMissionObjects

Recommended Posts

Long time no talk.  I am currently working with the high command module with some old scripts I dusted off.  I was able to get some easy scripts to create the HC and add all the units on a particular side to the player:


 

if (count (allMissionObjects "HighCommand") == 0) then {

    _Group = createGroup (sideLogic);

    _Group_HC_C = _Group createUnit ["HighCommand", [0, 0, 0], [], 0, "NONE"];

    _Group_HC_S = _Group createUnit ["HighCommandSubordinate", [0, 0, 0], [], 0, "NONE"];


    player synchronizeObjectsAdd [_Group_HC_C];


    _Group_HC_C synchronizeObjectsAdd [_Group_HC_S];

    {

        if (side _x == resistance) then {

            leader _x synchronizeObjectsAdd [_Group_HC_S];

        };

    }forEach allGroups;

} else ....

The else condition is what I am having problems with:


 

else {

    _Groups_HC = hcAllGroups player;

    _Group_HC_C = synchronizedObjects player select (side player == sideLogic);

    _Group_HC_S = synchronizedObjects _Group_HC_C select 0; // or 1?  Neither works


    {

        if (side _x == resistance && !(_x in _Groups_HC)) then {

            leader _x synchronizeObjectsAdd [_Group_HC_S];

        };

    }forEach allGroups;

};

I've tried all sorts of ways of tracking down the objects in the allMissionObjects:


 

_Groups = allMissionObjects "HighCommand";

_Group = allMissionObjects "HighCommand" select (side player == sideLogic); //This looks like a subordinate

_Group = synchronizedObjects player select 0; //it's definitely a group in this case

//and

_Group_HC_C = synchronizedObjects player select 0; //primary group

_Group_HC_S = synchronizedObjects _Group_HC_C select 0; //p1

//and

_Group_HC_C = synchronizedObjects player select 0; //primary group

_Group_HC_S = synchronizedObjects _Group_HC_C select 1; //looks like the sub

I'm stumped on how to pull the same data I injected so I can add more groups.  The goal is getting a basic example working and sort out a simple admin script to add basic high command group management, nothing more.  Anyone have any ideas?

 

 

edit:

wait, I think the else isn't adding leaders.  checking...  Ok, i updated the else to reflect what I needed it to do, but I am still unable to properly lookup and find the variables I created.

 

Share this post


Link to post
Share on other sites

synchronizedObjects player  will return all synchronized objects on player, so an array, not a group.

The logic of the module can be returned by:

_logic = synchronizedObjects player  select {_x isKindOf "highCommand"} select 0;

 

the logics corresponding to sub-modules can be returned by:

_subLogics = synchronizedObjects (synchronizedObjects player select {_x isKindOf "highCommand"} select 0) - [player];

 

Everything leads to mandatory syntax ... see BIKI

Not sure what you want to do with that....

 

Adding a group on player:

{player hcSetGroup [_x] } forEach (allGroups select {side _x == INDEPENDENT});

Not matter the group is already belonging to the HC groups of the player.

 

Feel free to make your own selection, but don't forget the condition code must be wrapped with curly braket {...}, not bracket (...)

 

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, pierremgi said:

synchronizedObjects player  will return all synchronized objects on player, so an array, not a group.

The logic of the module can be returned by:

_logic = synchronizedObjects player  select {_x isKindOf "highCommand"} select 0;

 

the logics corresponding to sub-modules can be returned by:

_subLogics = synchronizedObjects (synchronizedObjects player select {_x isKindOf "highCommand"} select 0) - [player];

 

Everything leads to mandatory syntax ... see BIKI

Not sure what you want to do with that....

 

Adding a group on player:

{player hcSetGroup [_x] } forEach (allGroups select {side _x == INDEPENDENT});

Not matter the group is already belonging to the HC groups of the player.

 

Feel free to make your own selection, but don't forget the condition code must be wrapped with curly braket {...}, not bracket (...)

 

 

Thanks for the response.

  • I was reading () as syntax for boolean and {} as syntax for an expression.  I saw some conditions work with select using () and some expressions work with select using {}.
  • I noticed that the primary synchronizedObjects returned array, hence I was using the forEach and select statements because it was an iterable.
hc_module = synchronizedObjects player select {_x isKindOf "highCommand"} select 0;
hc_sub_module = synchronizedObjects hc_module select {_x isKindOf "highCommandSubordinate"} select 0;

I definitely did this one.  If we are going off of my original post, I created a basic high command and subordinate logic and synchronized them.  I then attach high command to the player, and iterate through all the groups in a side and make them subordinate.  The old code I found was unable to select the old modules stored on the player object and make additions to it.  So naturally, I needed to access the synchronized object that I placed on the player, but I am unable to bind new groups to the subordinate module. 

 

Working:

_Groups_HC = hcAllGroups player;
_grp = allGroups select {
	side _x == resistance
};
_grp = _grp - _Groups_HC;
_grp = _grp - [group player];

{
	player hcSetGroup [_x];
} forEach _grp;

 

Not Working:

hc_module = synchronizedObjects player select {
	_x isKindOf "highCommand"
} select 0;
hc_sub_module = synchronizedObjects hc_module select {
	_x isKindOf "highCommandSubordinate"
} select 0;

_Groups_HC = hcAllGroups player;
_grp = allGroups select {
	side _x == resistance
};
_grp = _grp - _Groups_HC;
_grp = _grp - [group player];

{
	leader _x synchronizeObjectsAdd [hc_sub_module];
} forEach _grp;
  • I want to use the synchronize objects system for multiplayer, and I need to be able to grab the items on the individual _unit
  • I want to avoid using hcSetGroup, if possible. 
  • I want to select a specific object to bind teams to and avoid conflict, more on that later.
  • I will migrate off of player once I have a working setup
  • The end goal is making a simple action menu that allows a player to manage its own teams and avoid conflict with built in HC commands or complexities with the other HC management systems.

 

And for good measure, I also tried your script which was overly complicated:

 

_subLogic = synchronizedObjects (synchronizedObjects player select {_x isKindOf "highCommand"} select 0) - [player] select 0;

It's no different from my two step process, but is way more difficult to read.

 

 

So in a nutshell, I am stumped on accessing the sublogic and using it like I did when I invoked it.  I can create and attach, but am unable to recall and modify....  Though I can collect the groups, destroy it and rebuild it, though, not ideal.

Share this post


Link to post
Share on other sites
0 spawn { 
 highCommandFunc = { 
  params ["_unit", "_grpArry"]; 
 
  not_done = true; 
  while { not_done } do { 
   _unit_hc_count = count (synchronizedObjects _unit select { 
    _x isKindOf "HighCommand" 
   }); 
   switch (_unit_hc_count) do 
   { 
    case 0: 
    { 
     _Group = createGroup (sideLogic); 
     _Group_HC_C = _Group createUnit ["HighCommand", [0, 0, 0], [], 0, "NONE"]; 
     _Group_HC_S = _Group createUnit ["HighCommandSubordinate", [0, 0, 0], [], 0, "NONE"]; 
 
     _unit synchronizeObjectsAdd [_Group_HC_C]; 
 
     _Group_HC_C synchronizeObjectsAdd [_Group_HC_S]; 
     _grpArry = _grpArry - [group _unit]; 
     { 
      _unit hcSetGroup [_x]; 
     }forEach _grpArry; 
     not_done = false; 
    }; 
    case 1: 
    { 
     _hc_grps = hcAllGroups _unit; 
     _grpArry = _grpArry - _hc_grps; 
     _grpArry = _grpArry - [group _unit]; 
     if (count (_grpArry) > 0) then { 
      { 
       _unit hcSetGroup [_x]; 
      } forEach _grpArry; 
     }; 
     not_done = false; 
    }; 
    default { 
     _hc_grps = hcAllGroups _unit; 
     _hc_grps = _hc_grps - _grpArry; 
     _grpArry = _grpArry + _hc_grps; 
     hcRemoveAllGroups _unit; 
     sleep 0.25; 
     hc_module = synchronizedObjects player select { 
      _x isKindOf "HighCommand" 
     }; 
     if (count (hc_module) > 1) then { 
      { 
       hc_sub_module = synchronizedObjects _x select { 
        _x isKindOf "HighCommandSubordinate" 
       }; 
       if (count (hc_sub_module) > 0) then { 
        { 
         deleteVehicle _x; 
        } forEach hc_sub_module; 
       }; 
       deleteVehicle _x; 
      } forEach hc_module; 
     }; 
     sleep 0.25; 
    }; 
   }; 
  }; 
 }; 
 
 _grp = allGroups select { 
  side _x == resistance 
 }; 
 
 [player, _grp] call highCommandFunc; 
};

 

edit:

yup, I have to spawn it and add sleep threads.  Definitely goes over the the 3 ms per frame scheduler execution limit.

Share this post


Link to post
Share on other sites

I more or less have a working solution now, but I'm still puzzled as to why:

 

// creating the HC module from scratch 
_Group = createGroup (sideLogic); 
_Group_HC_C = _Group createUnit ["HighCommand", [0, 0, 0], [], 0, "NONE"]; 
_Group_HC_S = _Group createUnit ["HighCommandSubordinate", [0, 0, 0], [], 0, "NONE"]; 
player synchronizeObjectsAdd [_Group_HC_C]; 
_Group_HC_C synchronizeObjectsAdd [_Group_HC_S]; 


_grp = allGroups select {side _x == independent}; // get independent groups
_grp = _grp - [group player]; // remove player group
_g1 = (_grp select 0); // group 1 active
//_g2 = (_grp select 1); // group 2 commented out
leader _g1 synchronizeObjectsAdd [_Group_HC_S];
 
// added group to HC system via leader injection
  • This can be used as a way to create High Command modules and groups for a unit, found similar on the forum.
  • Note that we bind groups to the logic via the leader, similarly to syncing the leader to the module in the editor.

BUT:

  • Can't call up the logic from synchronizedObjects and bind new groups using the same setup.
// recalling modules
_Group_HC_C = synchronizedObjects player select {
	_x isKindOf "HighCommand"
} select 0;
_Group_HC_S = synchronizedObjects _Group_HC_C select {
	_x isKindOf "HighCommandSubordinate"
} select 0;
// The subordinate is already bound, so we skip that part... Yes?
// _Group_HC_C synchronizeObjectsAdd [_Group_HC_S];
// The player is already bound to the HC module, so we skip that too...  Yes?
// player synchronizeObjectsAdd [_Group_HC_C];

_grp = allGroups select {side _x == independent}; // get independent groups
_grp = _grp - [group player]; // remove player group
//_g1 = (myside select 0); // group 1 commented out
_g2 = (_grp select 1); // group 2 active

leader _g1 synchronizeObjectsAdd [_Group_HC_S];

// called back the modules, which I checked are there... but adding groups to HC system via leader injection fails.

It's not overly important at this point.  I am just curious why I can't jam units back into these logics, or perhaps I am doing it wrong with this method?

 

NOTE:  In my specific test cases, I added a selection of one of the resistance groups minus the player.  Then later tried to add the other selection.  It won't add it.  My new work around program works, but I would like to know why I can't work with the logics directly, or how I correctly recall them?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×