Jump to content
Sign in to follow this  
Tankbuster

Using an addon to swap the side/faction of a unit. Alternatives?

Recommended Posts

This might belong better in the configs section, but as it started out as an addon and my current fix involves the editor, I'll start in here.

My clan addon is used to fix a few config things. Such as the Scud launcher being East side and for some missions I need it to be independent. So I make an addon that simply changes it's side.

But I was thinking - is it possible to do this another way? How about if I create the unit in the mission editor, put it out of the way safely somewhere, then manually edit the sqm to change it's side? Then when I need the unit, I setPos it into position. Job done.

That will work if I only need the unit once, but supposing I need ten of them? As I've not found a way to duplicate a unit that's been editor placed, I assume I'd have to make ten of them in the way I describe above?

Share this post


Link to post
Share on other sites

Just tried editing the sqm. There are basically two sides. The group side and the unit side. The unit side controls such stuff as how it appears on the map in some situations (and for vehicles how early they engage??). Eg. EAST makes it red. The group side determines whose side the units are on. So if you put down a GUER unit and go in and edit the group side to be EAST then blufor will attack it and vica versa.

Also the editor changes how it displays too. If you change the GUER "unit side" to EAST then it will be red in the editor. The editor also keeps every change just remember to load. If you are in the editor alt-tabs out and edit the sqm then remember to load it again in editor before making any changes otherwise when you save it will use the old settings. That also means that if you have a "changed" unit in the editor then you can copy and the copy will keep the same attributes. Meaning if you copy the guerilla unit with group assigned to east then you will get another guerilla unit with group assigned to east.

I really hope that in Arma 3 they make sides and factions independent or at least configurable without using an addon (this is basically a hack/workaround).

But I was thinking - is it possible to do this another way? How about if I create the unit in the mission editor, put it out of the way safely somewhere, then manually edit the sqm to change it's side? Then when I need the unit, I setPos it into position. Job done.

What was your approach before? I'm guessing in that case you don't have them "ready" on the map but spawn them instead. AFAIK (untested) if you just create the group under the right side when you make them that should work. Remember vehicles don't have side, well they do, but is the side of the crew that matters really, actually the group side of the crew. So when you create the SCUD you could do something like this:

//Create guer group
_group = createGroup resistance;
//Create the vehicle
//.....
//Create the men under _group
//...
//???
//Profit

Share this post


Link to post
Share on other sites

Are you trying to change the sides in-game. Example if the units starts OPFOR but then goes Independent? That I dont know but I quite often have missions where an American unit starts out OPFOR. There is very easy way to do this actually without all these codes and .sqf files and configs. Doing that is doing nothing other than making your life difficult.

Let's say you want a SCUD to start Independent in game. You can make an Independent unit with the rank of colonel with a 0 percent chance of appearing and group it to a lower rank SCUD. Alternatively you can also make an empty SCUD and use the commands

this moveinGunner this moveindriver ...etc

for whatever unit you want to occupy that place of gunner and driver in the SCUD. So you could man a SCUD with American soldiers if you wanted to using these commands.

For example, make an American rifleman and under initialization put this moveingunner [name of SCUD] and make another another American unit and under initialization type this moveindriver [name of SCUD]

Edited by TexKaz

Share this post


Link to post
Share on other sites

What was your approach before? I'm guessing in that case you don't have them "ready" on the map but spawn them instead. AFAIK (untested) if you just create the group under the right side when you make them that should work. Remember vehicles don't have side,

In the case of the scud launcher, it was spawned by script. It is an east vehicle and the independent around it kill it instantly, regardless of if it has crew or not. So that leads me to ask - is putting an AI of the side you want in a vehicle really a bullet proof method of changing the vehicle side? I think things could get funky if the crew member got killed but the vehicle survived.

---------- Post added at 22:55 ---------- Previous post was at 22:52 ----------

Are you trying to change the sides in-game.

I'm not, although for another project I am looking into this. :) No... I want to spawn the vehicle by script with a side of my choice..

Sometimes for mission reasons, it MUST be empty. What happens when you take the 'foreign' crewman out? Does the vehicle revert back to it's default side?

Share this post


Link to post
Share on other sites

Hmm. I just set up empty SCUD, independent and BLUFOR groups - there wasn't any shooting at SCUD. Empty vehicles was/are of civilian side, as dead bodies, and are marked on map with civilian colour.

Do not know, if this will help, but when working on CEMS I noted one thing, when implemented "summoned" creatures. For example I'm using there spawned empty APC, that is next filled with spawned crew. So, until I use this syntax for crew spawn:

createUnit_array

Regardless of group's side, units will retain its default side, what made this syntax useless in that case, as spawned such way manned vehicle should be always of side of its "summoner" (initially empty vehicle will become side of its current crew, and probably will stay with this side after crew removal, so maybe this is BTW a way to switch vehicle's side also in-game, unless will back to civilian, initial side, not sure, no time for tests).

To achieve this is needed this syntax:

createUnit

In this method group's side will overwrite default unit's side, so this way seems to be possible to have any spawned unit or manned vehicle of any side. A practical example (CEMS' function):

RYD_SummonV = 	
{
private ["_types","_side","_place","_nbr","_state","_lock","_HQ","_SummonedGrp","_veh","_ifOA160","_frPos","_crew0","_crew1","_crew2"];

_types = _this select 0;
_side = _this select 1;
_place = _this select 2;
_nbr = _this select 3;
_state = _this select 4;
_lock = _this select 5;

_HQ = createCenter _side;
_SummonedGrp = createGroup _side;
while {(_nbr > 0)} do
	{
	_veh = createVehicle [(_types select (floor (random (count _types)))), _place, [], 0, _state];
	_ifOA160 = Alldead;
	if not (isNil ("_ifOA160")) then {_veh allowCrewInImmobile true};

	_frPos = _veh emptyPositions "commander";
	if (_frPos > 0) then 
		{
		"GUE_Soldier_Crew" createUnit [_place,_SummonedGrp];
		_crew0 = (units _SummonedGrp) select ((count (units _SummonedGrp)) - 1);
		_crew0 assignAsCommander _veh;
		_crew0 moveInCommander _veh;
		};

	_frPos = _veh emptyPositions "driver";
	if (_frPos > 0) then 
		{
		"GUE_Soldier_Crew" createUnit [_place,_SummonedGrp];
		_crew1 = (units _SummonedGrp) select ((count (units _SummonedGrp)) - 1);
		_crew1 assignAsDriver _veh;
		_crew1 moveInDriver _veh;
		};

	_frPos = _veh emptyPositions "gunner";
	if (_frPos > 0) then 
		{
		"GUE_Soldier_Crew" createUnit [_place,_SummonedGrp];
		_crew2 = (units _SummonedGrp) select ((count (units _SummonedGrp)) - 1);
		_crew2 assignAsGunner _veh;
		_crew2 moveInGunner _veh;
		};

	_nbr = _nbr - 1;

	sleep 0.01;

	if (_lock) then {_veh lock true};
	};

_SummonedGrp
};

Edited by Rydygier

Share this post


Link to post
Share on other sites

That's interesting. If I'm honest, I first encountered the problems with the scud some 2 years ago and fixed it with an addon then, it's possible the problem has been fixed in the meantime. I will test it again.

What exactly do you mean by "summoner", Rydygier? Is it possible something is getting lost in translation here?

I have used createunit array because it was the more recent command, but yes, I see that the older OpF command allows you to specify the side. But, it can only be used to make a unit that's joining an existing. That's an inconvenience.

Share this post


Link to post
Share on other sites
That's interesting. If I'm honest, I first encountered the problems with the scud some 2 years ago and fixed it with an addon then, it's possible the problem has been fixed in the meantime. I will test it again.

What exactly do you mean by "summoner", Rydygier? Is it possible something is getting lost in translation here?

I have used createunit array because it was the more recent command, but yes, I see that the older OpF command allows you to specify the side. But, it can only be used to make a unit that's joining an existing. That's an inconvenience.

Inconvenience compared to what alternative?

Createunit (regardless of the used syntax) does not work in any other way than adding that created unit to an existing group, even if the given group is empty.

You must specify a group and that group necessarily belongs to a center (side).

You problem is easily solved as suggested by assigning a crew to it that belongs to the desired side.

Share this post


Link to post
Share on other sites
Inconvenience compared to what alternative?

Createunit (regardless of the used syntax) does not work in any other way than adding that created unit to an existing group, even if the given group is empty.

You must specify a group and that group necessarily belongs to a center (side).

You problem is easily solved as suggested by assigning a crew to it that belongs to the desired side.

You can create a group that's empty? I assumed otherwise. :) That was my perceived inconvenience.

Share this post


Link to post
Share on other sites
What exactly do you mean by "summoner", Rydygier? Is it possible something is getting lost in translation here?

No, not a translation problem. This is CEMS stuff - summoner is a battlemage. CEMS means Combat Effective Magick System (aka Rincewinder). This brings "magic" into battlefield, and part of spells are summoning-something spells. :) Particullary quoted function is used for summon an "earth elemental".

Share this post


Link to post
Share on other sites

Erm. Magic? In the worlds most complete light infantry game? Most odd. Still, it clearly floats your boat. That's cool. :)

Nevertheless, I do understand what you mean now and I'm grateful for your help. Thank you.

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  

×