Jump to content
Sign in to follow this  
1para{god-father}

BIS_fnc_spawnGroup issue

Recommended Posts

I am using the following to spawn some armour in , but when i do they all spawn on the same spot so they end up bouncing on each other and flying in the air and turing over, should they not spawn next to eachother ?

_grp3 = [getMarkerPos "taskarmour3", east,["BMP3","T90","T90","BMP3","BMP3"]] call BIS_fnc_spawnGroup;

Share this post


Link to post
Share on other sites

try using the extended syntax to include a list of relative positions. I believe this is an array of positions (so an array within an array) of positions, and just add/subtract difference to where the spawn location reference is.

Unless im mistaken, it could also be a list of special types for the units, such as "NONE", "IN FORMATION", "CAN_COLLIDE"

so as an example of relative positions, assuming 4 tanks are spawned;

_grp3 = [getMarkerPos "taskarmour3", east,["BMP3","T90","T90","BMP3","BMP3"], [
[(getMarkerPos "taskarmour3" select 0) + 20, (getMarkerPos "taskarmour3" select 1) + 20, getMarkerPos "taskarmour3" select 2], [(getMarkerPos "taskarmour3" select 0) + 40, (getMarkerPos "taskarmour3" select 1) + 40, getMarkerPos "taskarmour3" select 2],
[(getMarkerPos "taskarmour3" select 0) + 60, (getMarkerPos "taskarmour3" select 1) + 0, getMarkerPos "taskarmour3" select 2],
[(getMarkerPos "taskarmour3" select 0) , (getMarkerPos "taskarmour3" select 1), getMarkerPos "taskarmour3" select 2]
]
] call BIS_fnc_spawnGroup; 

and see if that works, you might need to play around with the addition numbers to get them to spawn uniformly around each other.

Share this post


Link to post
Share on other sites

How do you make them go to a certain marker (invisible H for example)?

Share this post


Link to post
Share on other sites

try this instead:

_grp = [];
_spawn = getMarkerPos "taskarmour3";
_offset = 0;
{
_veh = [[(_spawn select 0) +_offset,_spawn select 1,0], 0, _x, east] call bis_fnc_spawnvehicle;
_grp1 = _veh select 2;
_offset = _offset + 10;
if ((count _grp) == 0) then {
	_grp = [_grp1];
} else {
	{[_x] joinSilent (_grp select 0)} foreach units _grp1;
};
} foreach ["BMP3","T90","T90","BMP3","BMP3"];
_mainGroup = _grp select 0;

Edited by Demonized
fixed error with "none"

Share this post


Link to post
Share on other sites

bis_fnc_spawnGroup does indeed have an optional parameter that tells it what the relative positions should be. It is the 4th parameter in the array, so:

_grp3 = [getMarkerPos "taskarmour3", east,["BMP3","T90","T90","BMP3","BMP3"], [[-3,-3], [3,3], [0,0], [3,-3], [-3,3]]] call BIS_fnc_spawnGroup;

Will spawn them in an "X"-like formation. You can change the relative position array for whatever you want of course. Keep in mind they will want to move into formation which can cause a mess with AI driving (well, AI driving is always a mess in a group with multiple vehicles so not a whole lot you can do about that I suppose).

Overall having each vehicle in its own group will reduce issues related to crappy AI driving.

Edited by galzohar

Share this post


Link to post
Share on other sites

you are correct Galzohar, but the vehicles are spawned at center on top of eachother and pushed violently to the position, often resulting in a tipped over vehicle or something, even on the flat tarmac of the airport.

btw you were missing a ] in your code:

_grp3 = [ getMarkerPos "taskarmour3", east,["BMP3","T90","T90","BMP3","BMP3"], [[-3,-3], [3,3], [0,0], [3,-3], [-3,3]] [b][i]][/i][/b] call BIS_fnc_spawnGroup;

Share this post


Link to post
Share on other sites

Interesting. The relative positions fixed it for me for groups that include only 1 armored vehicle and several infantrymen (solved by spawning the vehicle a bit away from the infantry), but it might have worked only because infantry don't "collide" with vehicles (they just get run over, and I suppose they don't have enough time to get run over before the script sets the vehicle in position).

If bis_fnc_spawngroup fails I guess you'll just have to do the spawnvehicle solution.

In any case I strongly recommend against grouping AI vehicles together in any way.

Share this post


Link to post
Share on other sites
In any case I strongly recommend against grouping AI vehicles together in any way.
this will give many headaches, but there are some good workarounds like norrins convoy script and others, but yeah,
AI vehicle groups == early balding;

its somewhat better in the air, but thats just because there are no roads up there x)

Share this post


Link to post
Share on other sites

Hi demonized,

I get an error when i try your code this is in the rpt:-

Error in expression <t 2;
_offset = _offset + 10;  
if (_grp == "none") then {
_grp = _grp1;
} else {>
 Error position: <== "none") then {
_grp = _grp1;
} else {>
 Error Generic error in expression

Share this post


Link to post
Share on other sites

How can I make this start out flying?

planeGrp1 = [ getMarkerPos "planeGrp1Start", east,["Su25_TK_EP1","Su25_TK_EP1"] ] call BIS_fnc_spawnGroup;

I'd also like it to respawn a set amount of times if it is destroyed, but I'm not sure exactly how to do that. If it is possible to make it respawn, would any ejected crew need to be dead before the plane can respawn? Because I'd rather the plane respawn again even if the crew ejected and is still alive.

---------- Post added at 11:54 AM ---------- Previous post was at 11:44 AM ----------

Maybe I should have first explained what I am trying to do.

I am making a mission where 4 BLUFOR start out near the runway, run and hop in some F-16's, take off, shoot down some planes, which is all working, but once we shoot them all down it would be nice if more enemy planes showed up, lol. Then we shoot all of those down and then more enemy planes show up.

OR

As each enemy plane gets shot down, a new plane respawns far away taking its place and heads towards a "DESTROY" waypoint/marker in the center of the map.

I don't normally make missions like this, but Mykes F-16 addon is becoming quite addictive. In the end I want to replace the Su25_TK_EP1 with a more challenging fighter. Suggestions on a better enemy fighter would be appreciated.

---------- Post added at 12:40 PM ---------- Previous post was at 11:54 AM ----------

su34 works better

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

i think for spawnGroup wich is meant for groundplaced inf/vehicle groups, you cannot get them into the air (exept using setPos and setVelocity for planes), but this is a workaround:

waituntil {!isnil "bis_fnc_init"};
_type = "Su25_TK_EP1";  // here is the type spawned, replace with your choosen type.
_side = EAST;  // side of units, note these must be same as vehicle, meaning US a-10 cannot be east etc...
_pos = getMarkerPos "planeGrp1Start";  // this is where they will spawn.
_dir = 180;  // this is the direction they will spawn heading towards, 180 is South, 0 is North etc..

_patrol = getMarkerPos "planeGrp1Patrol";  // center pos the group will patrol.
_range = 1000; // how big radius on the patrol area.

_mainGrp = createGroup _side;  // creating a group for all the units.
while {true} do {
_amount = 2;  // amount of planes in a wave.
while {_amount != 0} do {
	_amount = _amount - 1;
	_leader = [_pos, _dir, _type, _side] call bis_fnc_spawnvehicle;
	_veh = _leader select 0;
	_grp = _leader select 2;
	(units _grp) joinSilent _mainGrp;  // join the mainGrp for all units of this group.
	sleep 3; // allow the first plane to move out of the spawning position.
	deleteGroup _grp;  // cleanup empty group.
};
_patrol = [_mainGrp, _patrol, _range] call bis_fnc_taskPatrol;
waitUntil {({alive _x} count units _mainGrp) == 0};  // wait until noone is alive in the wave group.
sleep 10;  // the delay after all is dead before a new group is added.
};

Edited by Demonized
fixed typos

Share this post


Link to post
Share on other sites

I really appreciate all the help your giving me with this. For some reason nothing seems to be spawning. I used the exact script from above and pasted it into a file called "spawnPlanes.sqf", then I tried testing it out by placing a trigger right in front of the player with - this exec "spawnPlanes.sqf" in the activation along with a hint message to make sure it was activating when triggered, then I placed a marker called "planeGrp1Start" right near the player, another marker named "planeGrp1Patrol" in the center of the map, then I placed a functions module in the mission figuring it might need it, then I tested it and walked over and stepped into the trigger radius and nothing happened, but the hint worked. No errors either. Then I tried using - nul = [] execVM "spawnPlanes.sqf" and that gave me errors so I went back to using - this exec "spawnPlanes.sqf". I also tried adding an east unit with 0% probability of presence. Is there something else I need to do, or I'm I going about this wrong?

Edited by A-SUICIDAL

Share this post


Link to post
Share on other sites

hey, i had a missing { in the waituntil and mistakingly used _this instead of _leader in the grp part.

fixed previous post.

it was just typed out after memory, maybe im getting alzheimers :)

Share this post


Link to post
Share on other sites
i think for spawnGroup wich is meant for groundplaced inf/vehicle groups, you cannot get them into the air (exept using setPos and setVelocity for planes), but this is a workaround:

It's quite easy to get them to spawn in the air and flying.

I'm just using a markerpos as a spawn point and direction.

They fly ok but I did add velocity as I don't know how else to change their starting direction without them flying backwards.

The other thing is although in the full script I have waypoints set I can't get them to engage the enemy. spawned ground units will engage the aircraft.

// To use place in trigger
//null=["markerpos",east,"east","BIS_TK","Air","TK_Su25Flight"] execvm "Spawn_Group.sqf";



_pos  = _this select 0;      // spawn position
_side = _this select 1;      
_sides = _this select 2; 
_grpfact = _this select 3;   
_grptype = _this select 4;
_grpname = _this select 5;
_where = _this select 6;    // where to move to
_dir = markerdir _pos;

_grpempty = createCenter _side;
_grp = createGroup _side;

_grp=[GetMarkerPos _pos, _side, (configFile >> "CfgGroups" >> _sides >> _grpfact >> _grptype  >> _grpname)] call BIS_fnc_spawnGroup;

{
 _vehicle = vehicle _x;
_vel = velocity _vehicle;
_speed = speed _vehicle;
_vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];
_vehicle setdir _dir;
} foreach units _grp;

Share this post


Link to post
Share on other sites

oops, edit, didnt see that last post.

---------- Post added at 08:56 PM ---------- Previous post was at 08:09 PM ----------

With Demonized script, they were still spawning on the ground and the "_dir = 180" didn't seem to be working. I tried fixing the height a few different ways, but I'm not having any luck with that yet.

With F2k Sel script, I couldn't figure out the "_where" part, meaning where the planes were heading. Center of the map? Also I tried changing the planes to:

null=["planeGrp1Start",east,"east","RU","Air","RU_Su34FighterSquadron"] execVM "spawn_group.sqf";

but then I had comment out:

// _vehicle setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+ (cos _dir*_speed),(_vel select 2)];

to keep them from slamming into a mountain at mach 90, lol.

If I downloaded an enemy fighter addon to use in the mission, how would I get it to spawn? Like, how would I find out its Faction and group name?

And I'm still trying to figure out the best way to make them respawn. Maybe a timer that just keeps spawning them every few minutes? I'd prefer that after the plane is destroyed that another one respawns with a new crew, even if the old crew is still alive in parachutes, but I haven't ever seen this before, and I imagine it isn't possible. Maybe with vehicle damage detection script, where under a certain vehicle damage level that would cause them to bail, it would then activate a new plane group to spawn. Hmm.

Share this post


Link to post
Share on other sites

Sorry the _where was for something else which I abandoned. To change the direction they are flying just change the direction the marker is pointing, just turn it..

This is a BIS_function so it won't work with addons, it's the way the group spawn works in the editor so only those options are available.

Share this post


Link to post
Share on other sites

@A-SUICIDAL

you need to learn to use proper debugging techniques when using or creating scripts.

1: to see what direction planes spawn flying in, place yourself as a foot unit where they spawn and WATCH what direction they really do spawn in.

2: add in tracking markers or similar to see in realtime on map where they fly.

3: add in sidechat or hints to give you updates on when what happens.

4: also ofc, know where you do spawn a flying plane, doing it down inside a tight canyon, or infront of and heading towards a high mountain is bad... right?

5: since this is a repeating script after they have been shot down, create some means to "kill" off the planes so you can easily and fast see the respawning, in my tests i placed 10 us AA avenger jeeps in the patrol area with this in their init line, so they are invincible and never run out of ammo.

this allowDammage false; _null = (vehicle this) spawn {while {true} do {_this setVehicleAmmo 1; sleep 1;};};

From my script you will see they spawn in correct direction, but they spawn at 0 height and climb to their default flying height, this is now fixed to the _height option.

also they will move/evade on their own no matter what based on the AI game engine, you have no control over that, even with disableAI.

this is a feature or bug from long ago, its the danger-fsm that kicks in for the AI.

ive added in a flying height option and use that also as a spawning height, no need to push or anything they spawn at speed the correct way.

i also chnaged the alive count to rather check if planes can still move, otherwise if pilot was shot down and not dead, the script would wait for him to die.

place 2 markers on map (objective) and name them p1 and p2.

notice ive added a option:

_height = 500;

this is the height in meters they spawn flying in and the height they will keep flying in during their patrol.

ive higlighted the debugging parts as markers and sidechat, wich you can delete for your playing mission, and save it as ascript, the spawn line is also just for usage in on act of triggers, and they cannot take comment fields, so they have been removed also, only practical change from last script i posted is the added _height option.

place this in a radio trigger on act field:

blue parts is for use in on act of triggers.

red parts is debugging such as marker tracking and sidechat.

Purple is the new option with spawn/flying height.

[b][color="Blue"]_null = [] spawn {[/color][/b]

waituntil {!isnil "bis_fnc_init"};
_type = "Su25_TK_EP1";
_side = EAST;
_pos = getMarkerPos "planeGrp1Start";
_dir = 180;
[b][color="Purple"]_height = 500;[/color][/b]

_patrol = getMarkerPos "planeGrp1Patrol";
_range = 1000;

[b][color="Red"]_markers = ["p1","p2"];[/color][/b]
_mainGrp = createGroup _side;
while {true} do {
_vehicles = [];
[b][color="Red"]_marker = _markers;[/color][/b]
_amount = 2;
while {_amount != 0} do {
	_amount = _amount - 1;
	_leader = [[_pos select 0,_pos select 1, _height], _dir, _type, _side] call bis_fnc_spawnvehicle;
	_veh = _leader select 0;
	_grp = _leader select 2;
	(crew _veh) joinSilent _mainGrp;
	_veh flyInHeight _height;
	_vehicles = _vehicles + [_veh];

	[b][color="Red"]_null = [_veh,(_marker select 0)] spawn {
		_veh = _this select 0;
		_mar = _this select 1;
		_pos = getMarkerPos _mar;
		while {canMove _veh} do {
			_mar setMarkerPos (getPos _veh);
			sleep 0.1;
		};
		_mar setMarkerPos _pos;
	};
	_marker = _marker - [(_marker select 0)];[/color][/b]

	sleep 3;
	deleteGroup _grp;
};
_patrol = [_mainGrp, _patrol, _range] call bis_fnc_taskPatrol;
waitUntil {({canMove _x} count _vehicles) == 0};
[b][color="Red"]player sidechat "all planes going down";[/color][/b]
sleep 10;
};

[b][color="Blue"]};[/color][/b]

Now you watch them spawn, correct direction, go correct place, get shot down by the massive Avenger platoon, wait 10 seconds and it repeats itself forever.

using workarounds like F2k Sel posted is fine, but there is no need to when the game engine does it correctly for you anyway, but the functionality is pretty much the same, its just a matter of taste at this point.

and ofc for any version, you need at least a center or a unit of that side placed with probability of presence to 0, for any spawns to work regardless of script, and the function module for the functions.

Edit: and using spawnVehicle instead of groups works with any addon, but i believe you can use the vehicle classname multiple times when using spawngroup as well, he just vent with the cfgGroup option here.

more infor on that on wiki with inf units example.

Share this post


Link to post
Share on other sites

That's what I thought, that it only worked with non addon planes. I still have no idea where they are going, but I guess they will spot me and come after me anyway.

Demonized, is there a way to fix the height? Direction doesn't matter so much since they will eventually head towards their marker.

This mission could be the makings of something very awesomely fun. A dog-fighting mission, where players respawn and jump back into a jet and get their ass back in the sky pronto. Unlimited enemy, and a mission end timer. Planes shot down respawn despite the crew that ejected and still remain running around. I'm an idea guy. I get bored with the usual and want something more. The brain power in this forum to make it a reality. Everybody loves to fly. And no, this isn't a realism idea, but it's more damn fun than anything I've done with Arma 2 since I digitally downloaded and impregnated my comp with it's engine.

I'm going to make this happen, but I need help from the scripting gods. If it works, I will pay for a dog server.

Share this post


Link to post
Share on other sites

uh.. did you try script in spoiler in my last post? it has fixed height issue with an option _height and better functionality waiting for plane to go dowwn instead of pilot dying.

I support fun everywhere and hell yeah, flying is awsome in arma2. :D

i could upload a demo mission for you if you still have issues.

Share this post


Link to post
Share on other sites

Sorry Demonized, I was pretty lit last night and did not read either of your last 2 posts at all. Sometimes I forget to refresh the page before I post a reply. Last night was one of those times obviously. I'm going to test it now. Oh, and I've never used any debugging before, mainly because I never knew how to, but I definitely have a few missions that could use some debugging.

Share this post


Link to post
Share on other sites

np m8, by the looks of your now edited post, it was a good reason to be hyped. :)

the part about the techno beat and swarm of enemys got me a little hyped as well :D

i forget to refresh the page many times myself, leads me in all kinds of trouble. ;)

Share this post


Link to post
Share on other sites

Yeah, I edit removed that stuff because I was pretty bombed and later when I read it it sounded lame, so I just left a video link so people could just see that it's a lot of fun.

---------- Post added at 10:19 PM ---------- Previous post was at 09:06 PM ----------

Ok, I finally got a chance to test the script out, everything works great, except the planes keep crashing as if the pilot is missing. My brain is still on tilt from last night so trying to figure this out right now is a little difficult. After testing I removed the parts in red and right now I'm trying to keep the planes in the air.

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  

×