Jump to content
BlacKnightBK

accessing all units in an array

Recommended Posts

you can also add more cases obviously.  Like if you want a heavy weapons team or something.  If you want a bunch of rifleman, but one of each of the specialists, then riflemen can use case default and default will execute for all cases that aren't being handled manually.  Like the code I sent you way above with the default case.  Should you have had a squad leader, grenadier, medic, marksman, and AT soldier, the default case could have been a standard rifleman, and however many extra men in the squad you had would have been riflemen, assuming you didn't handle case # for the position of the current index.

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, stuguy said:

you can also add more cases obviously.  Like if you want a heavy weapons team or something.  If you want a bunch of rifleman, but one of each of the specialists, then riflemen can use case default and default will execute for all cases that aren't being handled manually.  Like the code I sent you way above with the default case.  Should you have had a squad leader, grenadier, medic, marksman, and AT soldier, the default case could have been a standard rifleman, and however many extra men in the squad you had would have been riflemen, assuming you didn't handle case # for the position of the current index.

Thanks @stuguy, you can't believe how much easier you just made my life.

 

Can't thank you enough.

I definitely have to put your name in the credit's section. Would you like it same as here or something different :D

Share this post


Link to post
Share on other sites
Just now, BlacKnightBK said:

I definitely have to put your name in the credit's section. Would you like it same as here or something different :D

stuguy is fine.  Glad I could help.  Enjoy :)

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, stuguy said:

stuguy is fine.  Glad I could help.  Enjoy :)

i definitely am. Man this is so much better and fun than those c++ assignments i had that my professor wouldn't even bother looking at because he knows i did it right.

Used to bug me so much. At least now i am doing something people will be using and giving me feedback so i can keep on making it better

Share this post


Link to post
Share on other sites
58 minutes ago, stuguy said:

{
	_grp = _x
	_grp = createGroup east;
	{
		switch(_forEachIndex) do {
			case 0 : {};
			case 1 : {};
			case 2 : {};
			case 3 : {};
			case 4 : {};
			case 5 : {};
			default : {};
		};
	}|#|forEach _x;
	_x set [_forEachIndex, _grp];
}forEach _groupArray;

 

Hey stuguy, i have teeny problem with the code, hope you can help

 

http://steamcommunity.com/sharedfiles/filedetails/?id=857900413

Share this post


Link to post
Share on other sites

@stuguy Hey buddy as much as I would still love to know why this error exists, while trying to fix it i remembered something.

 

I will be using these loadouts in multiple missions and not just one, so I have decided to create every squad in a separate file and use the ExecVM to create them in the mission. This way I do not have to create the AIs in every mission file.

 

I am guessing the way to do this is save the mission location in a global variable and that will be used to spawn the units every time the file is executed. 

I haven't done this yet, just starting on it however I hope i am right :P

Share this post


Link to post
Share on other sites
Fn_Gear_Clear = {
	private _obj = _this;

	if (_obj isKindOf "Man")
		then {
			removeGoggles _obj;
			removeHeadgear _obj;
			removeAllWeapons _obj;	
			removeAllContainers _obj;
			removeAllAssignedItems _obj}
		else {
			clearBackpackCargo _obj;
			clearMagazineCargo _obj;
			clearWeaponCargo _obj;
			clearItemCargo _obj}
};

//Usage:
_unitOrVehicleOrAmmoBox call Fn_Gear_Clear;

 

Share this post


Link to post
Share on other sites
54 minutes ago, serena said:

Fn_Gear_Clear = {
	private _obj = _this;

	if (_obj isKindOf "Man")
		then {
			removeGoggles _obj;
			removeHeadgear _obj;
			removeAllWeapons _obj;	
			removeAllContainers _obj;
			removeAllAssignedItems _obj}
		else {
			clearBackpackCargo _obj;
			clearMagazineCargo _obj;
			clearWeaponCargo _obj;
			clearItemCargo _obj}
};

//Usage:
_unitOrVehicleOrAmmoBox call Fn_Gear_Clear;

 

Thanks @serena

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

×