Jump to content
Sign in to follow this  
Scouter

Opfor attack each other on spawn

Recommended Posts

I have made a small script that spawns OPFOR technicals at a marker using the "addAction" command. This works fine and dandy, but when I spawn more than one at a time, they just attack each other, killing gunners and drivers before they even get to their destination. I think that when I spawn them in quick succession, they damage each other, causing them to attack each other. I want my end result to have the entire OPFOR side friendly to each other, even if they accidentally damage each other.

Here is the code for where I think the problem is:

(I know these are not a lot of lines in each file, but I just getting into C)

closeman3.sqf

_grp = createGroup east;
_dir = random 359;
_pos5 = [(getMarkerPos "closeV" select 0)-10*sin(_dir),(getMarkerPos "closeV" select 1)-10*cos(_dir)];
_posHome = getMarkerPos "my_airport";

_veh = [_pos5, 270, "Pickup_PK_GUE", _grp] call BIS_fnc_spawnVehicle;
_veh doMove _posHome;

closeman3.sqf is initiated by this line of a different file:

dangerclose addAction ["Spawn - Marauding Technical","badguys\closemen3.sqf"];

Note that I have about 10 .sqfs that look very similar to this.

Share this post


Link to post
Share on other sites

Looks like usual issue, when you try to spawn soldiers of one side into group of another side using this command:

createUnit array

And BIS_fnc_spawnVehicle uses exactly that command to spawn default crew for the vehicle of its default side into yours group, that is of another side, hence the problem. To avoid that do not mix sides of group and the unit's (vehicle's), or write own spawn vehicle function based on another version of createVehicle command:

createUnit

(with this version I can spawn eg. western units for eastern group without such problems - side mixing allowed).

Or just spawn "manually" an empty vehicle and then spawn chosen crew units of the same side, as group's.

Edited by Rydygier

Share this post


Link to post
Share on other sites

Ok, so I remake the sqf, it is now:

_grp = createGroup east;
_dir = random 359;
_pos5 = [(getMarkerPos "closeV" select 0)-10*sin(_dir),(getMarkerPos "closeV" select 1)-10*cos(_dir)];
_pos4 = getMarkerPos "close";
_posHome = getMarkerPos "my_airport";

_veh = createVehicle ["Pickup_PK_GUE", _pos5, [], 0, "NONE"];
sleep 0.5;
"RUS_Soldier_GL" createUnit [_pos4, _grp,"newUnit = this; this moveInDriver _veh", 0.5, "corporal"];
"RUS_Soldier_GL" createUnit [_pos4, _grp,"newUnit = this; this moveInGunner _veh", 0.5, "corporal"];
_veh doMove _posHome;

I spawn a technical then the men. They go the driver and gunner position. This solved the problem. They now come straight at me single file with no violence between 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
Sign in to follow this  

×