Jump to content
Sign in to follow this  
rekrul

How to merge groups?

Recommended Posts

I have 4 squads (+ some reinforcements) that have been through the wringer so after this I want to merge all 4 squads into one group but I have no idea how I should do this. I'm guessing I should use forEach at some point but I'm pretty clueless here so can anyone help me out?

Share this post


Link to post
Share on other sites

Thanks, but when I enter that into a radio Alpha trigger I just get a blank error message?

Share this post


Link to post
Share on other sites

Umm.. might be some kind of encoding thing, since that's copied directly from a trigger. :) Maybe hand type it out, and make sure you have your groups named grp1 through grp4 via:

grp1 = group this;

in your group leader's init fields.

Share this post


Link to post
Share on other sites

No sorry, my bad! I called the group 2ndPlatoon and it didn't like the 2.

Share this post


Link to post
Share on other sites

I'm having some problems with this is in my UPSMON mission, meaning it works in the start but not after a while. I'm suspecting that it might be because it's trying to merge dead units so it just exists. How would I do this merger with only alive units?

Share this post


Link to post
Share on other sites
{if (alive _x) then { [_x] joinSilent grp1}} forEach units grp2 + units grp3 + units grp4;

Share this post


Link to post
Share on other sites

Thanks again. I still see the same behavior though. If I run that in the start of the mission (after UPSMON initialization) it works, but if I run it in the middle of the mission, it doesn't and I can't for the life of me understand why.

Share this post


Link to post
Share on other sites

It's probably UPSMon which is messing default things up. I have no idea how it handles groups. :) Why not just delete the groups and make a brand new group?

Share this post


Link to post
Share on other sites

Hmm, but if I delete them, how to I make them join my new group?

Share this post


Link to post
Share on other sites

o.O ? You're trying to use UPSMon controlled units as player controlled units? Not sure it's designed for that really.

If that's the case I'd probably just have all the units leave their current group, (releaseing them from UPS hopefully) then join you.

Something like:

myNewUnits = units grp1 + units grp2 + units grp3 + units grp4;
{if (alive _x) then {[_x] joinSilent player}} forEach myNewUnits;

Share this post


Link to post
Share on other sites

Yes and no. I have some EAST units fortified with UPSMON and then I have 4 squads where leader isn't playable also ran by UPSMON. And then some other minor units.

I've made some debugging text and sometimes the script reports 0 in all squads. Why's that happening? I guess I could name all of them and then merge them that way.

_cnt=0;
{_cnt=_cnt+1} forEach units Squad1;
player sidechat format["Units in 1st Squad: %1",_cnt]; 

_cnt=0;
{_cnt=_cnt+1} forEach units Squad2;
player sidechat format["Units in 2nd Squad: %1",_cnt]; 

_cnt=0;
{_cnt=_cnt+1} forEach units Squad3;
player sidechat format["Units in 3rd Squad: %1",_cnt]; 

_cnt=0;
{_cnt=_cnt+1} forEach units Squad4;
player sidechat format["Units in 4th Squad: %1",_cnt]; 


Platoon = createGroup WEST;
sleep 2;
{if (alive _x) then { [_x] joinSilent Platoon}} forEach units Squad1; 
{if (alive _x) then { [_x] joinSilent Platoon}} forEach units Squad2; 
{if (alive _x) then { [_x] joinSilent Platoon}} forEach units Squad3; 
{if (alive _x) then { [_x] joinSilent Platoon}} forEach units Squad4; 
sleep 2;
Platoon setGroupID ["2nd Platoon"]; 
_leader = leader Platoon;

_cnt=0;
{_cnt=_cnt+1} forEach units Platoon;
player sidechat format["Units in platoon: %1",_cnt]; 

Btw, in your examples you're always writing + units grp3 etc. Does that actually work? I can't get it working.

Share this post


Link to post
Share on other sites

Can you post the mission you're having trouble with?

The code I posted just above works fine. I copied it right out of a test mission. Place down four sniper groups, use grp1 = group this; and so on to name each group. Put that code in a trigger and tada, everyone's in my group.

I'm totally confused about the approach you're taking with these groups combining into one brand new one. I'm unclear why you'd want to do that and why you can't just make them all join the leader of one of their groups. Also why you're using a forEach to increment count them when you can just count them. :)

I think seeing the mission might help figure out your goal here. :)

Share this post


Link to post
Share on other sites

Ah well, the reason for this is that I'm very inexperienced in scripting so I have to use the commands I know and learn. That's why my scripts are atrocious to read and I'm pretty sure there are 50 ways to make my scripts better. :)

I will post the mission when I'm home later. However there are some issues I've noticed. For instance, all the units that doesn't start in the Stryker are called "Squad 1 6", "Squad 1 9" and so on. Those who are in the Stryker are called Squadb1 and similar. I don't know if that matters. Also, when I move the units into "Platoon", I use setGroupID on platoon but they're still called "Squad 3 5" etc. I think this might have confused my sense of how successful the merger was.

Let me walk you through the mission. There are 2 Strykers and 2 M1A2 S of Bastam and 2 Strykers and 2 M1A2 E of Bastam. Strykers link up with M1A2 just outside Bastam (but doesn't join groups or anything) and the strykers are supposed to meet by the mosque in Bastam. (The tanks were supposed to escort the strykers but that's impossible due to tanks driving like drunken sailors.) However, Bastam is filled with enemies so they're ambushed and a firefight ensues. If two strykers are lost, air support comes in. After they've re-captured Bastam, they're supposed to merge into one unit.

The reason for this merger is that basically 80% are lost in the firefight. I might have an entire squad wiped out, 2 survivors in another, 5 in a third one etc. Since they're going to attack the airfield, I see no benefits in having 2 guys wander off so I want all the survivors in one group so they can attack as one group.

Once Bastam is seized, I spawn two Guerrilla groups on the airport and fortify them. Then I want this new group (Platoon) to attack the airport and seize that as well.

I do get some partial success now with this merger. I set reinforce to false before merger and that seem to help for whatever reason. Is there a way I can log all sideChat and sideRadio to a file, e.g. the .rpt file?

Share this post


Link to post
Share on other sites

AAAAAAARGH! !#%&$@! I just realised that I'm calling the Strykers Squad1, Squad2, etc!

Share this post


Link to post
Share on other sites

hehe, been there done that. :) Was working on a script the other night with three techs: techniacian1, technician2 and technician3. Never could understand why 2 and 3 would never join 1, till after an hour I finally noticed I'd typo'd the name of 1 and had an extra 'a' in it! :)

Share this post


Link to post
Share on other sites

Typos and copy and paste errors are probably the worst. I've just spent the most part of the last 24 hours trying to figure out a bug. A bug I completely suspected to be due to something entirely different, as I've had other problems with the script in the past ending with the same symptoms. The bug? A missing "!"..... I'm beginning to think the Arma1 SP mission "Blood, sweat, and tears" was dedicated to us mission makers... :D

Share this post


Link to post
Share on other sites

hehe

I have a routine for joining 2 groups. I had the best results if first 'unjoining' the groups to be joined. In this, _grpJoin is an array of groups to be joined together.

	{
	[_x] join grpNull;
	sleep .2;
	//hint format ["null group %1", group _x];
	//sleep 1;
	[_x] joinSilent player;
	//hint format ["unit combine %1", _x];
	sleep 1;
	_dispTxt = "Units combined";
	} forEach _grpJoin;

I know, I know, having _x join grpNull in the same forEach look doesn't seem like it would work. But it did. :) At least, in A1 it did. Haven't tried it in A2.

Oh, and I'll raise a beer to toast all the typos and missing semi-colons that cause bugs that are hard to trace! :) May their lives be short and the debugging thorough!

Share this post


Link to post
Share on other sites

Well the merger works fine now, the problem is that I don't know how to delete the UPSMON line the units had previously so now they have two UPSMON identities and they use forever to get to the airfield. I delete the groups after they've joined the new one but it doesn't help. I have to find a way to delete the previous UPSMON "identity".

Share this post


Link to post
Share on other sites

The joining grpNull doesn't do that? It should remove the units from the group, maybe add in a deleteGroup command too?

Share this post


Link to post
Share on other sites

Well for every squadleader I have:

SquadL1 = group this; 
this setGroupid ["1st Squad"];
nul=[this,"BastamCity","move"] execVM "scripts\upsmon.sqf"; 
this addEventHandler ["handleHeal",{_this select 1 addScore 1}];

Obviously calling them SquadL1, 2, 3, and 4. The last line is just to give +1 to score for healing.

Then my script said:

Platoon = createGroup WEST;
{[_x] joinSilent Platoon} forEach units SquadL1 + units SquadL2 + units SquadL3 + units SquadL4; 
deleteGroup SquadL1;
deleteGroup SquadL2;
deleteGroup SquadL3;
deleteGroup SquadL4;

Platoon setGroupID ["2nd Platoon"]; 

I tried changing it to:

Platoon = createGroup WEST; 
{
 [_x] join grpNull;
 sleep .2;
 [_x] joinSilent Platoon;
 sleep 1;
} forEach units SquadL1 + units SquadL2 + units SquadL3 + units SquadL4; 
deleteGroup SquadL1;
deleteGroup SquadL2;
deleteGroup SquadL3;
deleteGroup SquadL4;
Platoon setGroupID ["2nd Platoon"]; 

but it doesn't really help. The only thing is that it's using longer time (due to sleeps). The UPSMON IDs are still there. Does anyone know how UPSMON deletes the group ID?

Share this post


Link to post
Share on other sites

If anyone can figure out how to make a unit first attack one area and then a second one - please, please let me know how.

I've tried moving the marker, I've tried changing groups, I've tried giving them the "[unit,"marker2","Move"] execVM "scripts\upsmon.sqf";"-line, etc. Basically I've exhausted all my options.

From what I can tell, when it starts, it stores all the group members and the groupID and since members are only removed when dead or surrendered, it's kind of hard to delete the groupID. Then again I'm pretty clueless to this so I might be wrong. I was thinking of moving them to a civilian group, but I'm worried that either a) the group is counted as west since they're west and not civilians and b) turning them to civilians will replicate a surrender (e.g. drop their weapons).

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
Sign in to follow this  

×