Home   Help Search Login Register  

Author Topic: Creategroup / deletegroup  (Read 2047 times)

0 Members and 1 Guest are viewing this topic.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Creategroup / deletegroup
« on: 26 Feb 2007, 17:24:25 »
I encountered a problem and i hope someone in here might help me to solve this.

Well, here it comes.

Since ArmA it is now possible to create new groups. As in OFP this wasn't possible except the group was created before mission starts. Now in ArmA with "createcenter" and "creategroup" it is possible to create groups from scratch. So far so good.

But now comes the Problem: ArmA limits the numbers of groups to 144 Groups per side, which is a lot. Anyhow, one a group was created and then dead (no units left) the used groups will not be available for creating a new group. I tried the deletegroup command but it seems that ArmA will not release the group for newly create a group.

What i'm trying to do: this is for my Dynamic group creator. It creates randomly groups into predefined area and let them patrol and the player can attack the area and clean it up. This would theoretically allow to make coop missions covering whole Sahrani. But now i reach i limit. I don't want to have more than 144 groups all at the same time, but staggered during the mission. But with this problem you reach too fast the limit of 144 groups.

Now my question: is there a way that ArmA will release a group as soon it is no longer present (all units dead) for being newly used for another group to be created? I thought the "deletegroup" would do so, but at my testing it didn't (created 150 groups, each with one single unit but as soon 144 was reached, no more units were created, even when the most first units already died).

I know there's somehow a workaround by using a second side (i.e. Resistance or/and Civilian) but i would like to know if theres a way without this workaround. As the deletegroup command does implement there should be such a way.

Offline Silola

  • Members
  • *
Re: Creategroup / deletegroup
« Reply #1 on: 26 Feb 2007, 20:32:00 »
hi myke,

You simply store the empty groups in an array for each side.

first u init these arrays:

EmptyGroupsWest = []
EmptyGroupsEast = []

Then you examine each group for the number of alive units. If all units are dead, you store the empty group in the appropriate array:

for example:

Code: [Select]
if(({alive _x} count units _group) == 0) then
{
    EmptyGroupsWest = EmptyGroupsWest + [_group];
};

If you create now a new group, you examine first the array whether there empty groups are.
If not, you must create a new group. If an empty group is however at least in the array,
you take the first empty group from this array, in order to create new units there. Example:

Code: [Select]
_newgroup = group player;
if(count EmptyGroupsWest > 0) then
{
    _newgroup = (EmptyGroupsWest select 0);
    EmptyGroupsWest = EmptyGroupsWest - [_newgroup];
}
else
{
    _newgroup = creategroup west;
};

Now u can create the first unit for the group (the leader):

Code: [Select]
_leader = _newgroup createUnit ["SquadLeaderW",position respawnLogic,[], 0, "NONE"];
[_leader] join _newgroup;

thats all :-)

I use the same method in the new DAC version, and it functions perfectly ;-)

bye
silola

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Creategroup / deletegroup
« Reply #2 on: 26 Feb 2007, 22:41:54 »
Thx Silola (hope you're getting your DAC done really soon)

but i did some more testing with my groupspawner (or should i call it DAC light? :whistle:).
and i realised that the deletegroup in fact does work. Seems i did something wrong the first time.

How i tested it:

I firstly created the first 144 groups (in fact groups with a single unit), then killed them (not nice, but necessarly). Then with a radio trigger i called the same groupspawner script a second time and i get 144 new units (groups). I could do it 2 times before i run out of ammo. Therefore it created 3 x 144 groups (432 Groups all in all) without any problem. Interesting is, that the "deletegroup" command does not delete a group as long some units are still alive. Only when the last groupmember died, the command will delete the group and ArmA will reuse this group again.

However, maybe you'll take a closer look to this command, since it would clean up your DAC from storing and reading groups in/from an array, saving some cpu ressources.

Thank you for your reply and your pretty well solution but i'm affraid as i'm no longer have a use for it.

regards

Myke