Jump to content
Sign in to follow this  
CaptainBravo

HELP: Spawn Vehicles /Planes

Recommended Posts

Hi everyone,

I am searching for a script to spawn vehicles/planes and halos (both west and east)

After they are destoyed they spawn 3 times at base and move to certain point (marker)

I know there is a spawn function but not sure how to use it to achive above.

Any noobs guide showing how would be highly appreciated.

Share this post


Link to post
Share on other sites

Thanks CryHavok. I have used that script to spawn infantry and it works great! However, it does not work for vehicles/planes ...

Any other ideas?

Thanks.

Share this post


Link to post
Share on other sites

The fourth script down on this page creates respawning AI vehicles, which then use Kronzky's urban patrol script to patrol an area:

http://www.ofpec.com/forum/index.php?topic=33732.0

If you want a slightly simpler script so that the respawned vehicles just move to some waypoints, ie. not use Kronzky's UPS, let me know and I'll adapt the script for you.

Share this post


Link to post
Share on other sites

That would be great norrin !

But i have a problem:

I want to spawn a unit during the mission with a trigger. and then they should move to waypoints.

Edited by Wiggum

Share this post


Link to post
Share on other sites

AI vehicle respawn that moves to waypoint script

© JULY 2009 - norrin

Download

http://norrin.org/downloads/ArmA2/AI_respawn/AIvclRespawn_WP.utes.rar

To implement

1. Copy AIvcl_respawn_WP folder to your mission directory

2. Create a manned AI vehicle that will respawn in the editor

3. in the init line of the vehicle put:

nul = [this, 3, 10, "WS1","WP_scripts\WP1.sqf"] execVM "AIvcl_respawn_WP\AIvcl_respawn_WP_init.sqf";

where:

3 - is the number of times you want the AI unit to respawn;

10 - is the delay in seconds after the unit dies that you want it to respawn in

"WS1" - is the marker postion where you want the AI units to respawn

"WP_scripts\WP1.sqf" - is the name of path and the script that will add the waypoints.

In the test mission I have put the waypoint script in the directory called WP_scripts and the script that adds the waypoints is called "WP1.sqf". It commands the units to move to WPs created at markers. In the test mission the WP markers for AI units are called:"WP1" and "WP2" and the code looks like this:

_unit = _this select 0;
_group = group _unit;

_waypoint0 = _group addwaypoint[getmarkerpos"WP1",0];
_waypoint0 setwaypointtype"Move"; 

_waypoint1 = _group addwaypoint[getmarkerpos"WP2",0];
_waypoint1 setwaypointtype"Move"; 

Adapt this script to your own purposes. For instance you can add additional WP markers or you could have several of these scripts in the mission so different units moveTo different positions.

Note

* Each respawning AI vehicle needs to have the above code put in its init line.

* The respawning AI vehicles are created as the same type and their skill is set to the same level as set in the editor

Also in the test mission the player is setCaptive true so the enemy units will not shoot him.

@Wiggum - what you are asking is different to this, what you need to do is when the trigger is activated run a script, which

1. Creates an empty vehicle

2. Creates some crew for the vehicle

3. Moves the crew into the vehicle using the moveInDriver, moveINGunner etc

4. adds the waypoints for the group

EDIT

Wiggum, here's a test mission where I've spawned a vehicle after a trigger is activated, which you can use as a guide:

http://norrin.org/downloads/ArmA2/AI_respawn/spawn_vcl_trigger.utes.rar

Just run straight forward when the mission starts and a HMMWV will spawn and move off to two WPs. Open the mission up in the editor to see how its done! If you run into probs let me know and I'll post some explanatory notes.

Edited by norrin

Share this post


Link to post
Share on other sites

Thanks norrin! I appreciate it. I use your other scripts and they are great (specially UPS)! All I needed was vehicle spawn and I will try yours when I get home.

Would it also work for planes/halos? if yes, can they spawn flying mid air?

Thanks for the great scripts!

Share this post


Link to post
Share on other sites

The UPS and WP vehicle respawn scripts work for both planes and helos and there's examples of both in the test missions. At the moment I just spawn them on the ground but they will fly to waypoints, for planes and the UPS script just make sure that the patrol marker is nice and big.

PS: Kronzky wrote the amazing UPS, I'm just responsible for the AI respawn part.

Edited by norrin

Share this post


Link to post
Share on other sites

Thanks norrin !

But if have a littel problem again:

I changed some stuff in your script to get a Insurgent BMP2 that moves.

// spawn_vcl.sqf

// JULY 2009 - norrin

if (!isServer) exitWith {};

_type = _this select 0;

_marker_pos = _this select 1;

// Create Vehicle

_vcl_new = _type createVehicle (getMarkerPos _marker_pos);

// Create Crew

_group = createGroup EAST;

"Ins_Soldier_Crew" createUnit [(getMarkerPos _marker_pos), _group];

"Ins_Soldier_Crew" createUnit [(getMarkerPos _marker_pos), _group];

"Ins_Soldier_Crew" createUnit [(getMarkerPos _marker_pos), _group];

_unitsGroup = units _group;

// Move crew in Vehicle

for [{ _loop = 0 },{ _loop < count _unitsGroup},{ _loop = _loop + 1}] do

{

_guy = _unitsGroup select _loop;

_guy setSkill (_AI_skillArray select _loop);

if (_loop == 0) then {_guy moveInDriver _vcl_new};

if (_loop == 1) then {_guy moveInGunner _vcl_new};

if (_loop == 2) then {_guy moveInCommander _vcl_new};

sleep 0.1;

};

sleep 1;

// Add waypoints

_waypoint0 = _group addwaypoint[getmarkerpos"WP1",0];

_waypoint0 setwaypointtype"Move";

_waypoint1 = _group addwaypoint[getmarkerpos"WP2",0];

_waypoint1 setwaypointtype"Move";

But there are no Crew inside.

If i change EAST to WEST it works but the tanks dont attack me.

Edited by Wiggum

Share this post


Link to post
Share on other sites

Tested it and it workes great Norrin. Thanks!

A couple of observations:

When east east tanks spawn, they have smoke coming out before any combat ..

Is it possible to have the units patrol within say 50m or 100 m from their waypoint?

Thanks for great scripts!

Share this post


Link to post
Share on other sites

Not sure whether this is what you're after but in the

_waypoint0 = _group addwaypoint[getmarkerpos"WP1",0];

the last number ie. 0 randomly places the waypoint in a circle with a radius of this number, if that makes sense. So maybe set it to 50 or 100.

See here: http://community.bistudio.com/wiki/addWaypoint

Share this post


Link to post
Share on other sites

Thanks norrin. I have made a large mission with plans, halos, tanks and infantry, it works beautifully!

The only question how can you make different way points for respawned groups, vehicles: for example a group with : destory, cycle, hold , etc .. waypoints ?

Thanks again.

Share this post


Link to post
Share on other sites
Thanks norrin. I have made a large mission with plans, halos, tanks and infantry, it works beautifully!

The only question how can you make different way points for respawned groups, vehicles: for example a group with : destory, cycle, hold , etc .. waypoints ?

Thanks again.

All you need to do is add an extra line of code for each waypoint in your waypoint script and use the setWaypointType command, see: http://community.bistudio.com/wiki/setWaypointType

You can also add lines that set:

setWaypointBehaviour: http://community.bistudio.com/wiki/setWaypointBehaviour

setWaypointFormation: http://community.bistudio.com/wiki/setWaypointFormation

setWaypointSpeed: http://community.bistudio.com/wiki/setWaypointSpeed etc etc

See here for a full list of setwaypoint commands: http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA

Share this post


Link to post
Share on other sites

Thanks norrin for your quick response.

This is where the noob in me comes out ..

The command for the waypoint type is:

In example given

[_grp, 2] setWaypointType "GUARD"

I am not sure what is [_grp, 2]

name of group? what is the number? where would this line go?

Thanks for your help as usual.

Share this post


Link to post
Share on other sites

_grp is the group and the number is the number of the waypoint in the order it was added ie. first waypoint added is 0 (i think), second waypoint added 1 etc etc

So in our previous example

 _waypoint0 = _group addwaypoint[getmarkerpos"WP1",0];
[_group, 0] setwaypointType "MOVE"; 
[_group, 0] setWaypointBehaviour "AWARE";

_waypoint1 = _group addwaypoint[getmarkerpos"WP2",0];
[_group, 1] setWaypointType "GUARD";

Share this post


Link to post
Share on other sites
Thanks norrin, but it dont work for me...

The BMP Spawns empty but do nothing. He dont attacks me and dont drives to the waypoints. And i think thats because he is empty.

If i change EAST to WEST it works perfect. If i chose OPFOR then the AI will attack me too.

I have the German Retail edition of the game and newest patch installed, no addons.

EDIT:

If i place another east unit somewhere on the map it works...but the BMP still does not attack me.

Forget the above... :D

Now it works. I placed another enemy unit on the map and deleted the 2 waypoints and added 2 new...and it works !

But i have another question:

How do you set the skill of the BMP ?

Edited by Wiggum

Share this post


Link to post
Share on other sites

@Wiggum

I think what you want to do is to set the skill of the units that crew the vehicle so in the line:

_guy setSkill (_AI_skillArray select _loop);

(which I accidentally included from some other code I had written) change it to read:

_guy setSkill 0.8;

where 0.8 is the level of skill you want to give to the units that are driving the vehicle.

Share this post


Link to post
Share on other sites

Ok, thanks norrin !

Mhhh,

maybe just luck that it worked yesterday...today they still dont attack me.

Edited by Wiggum

Share this post


Link to post
Share on other sites

Ahhh, i go crazy right now... ;)

Sometimes it works just fine and the AI will attack me and sometimes they dont.

But, if it dont works with "BMP2_INS" i just have to chose "BRDM2_INS" and...it works. Insane...

Is this a Bug in the game or is my installation broken ?

EDIT: Sorry...forget to edit my last post.

Share this post


Link to post
Share on other sites

@norrin

Would ot be impossible to spawn a helicopter flying? maybe with a group inside?

this would be great for my counter attack part of a MP mission

Share this post


Link to post
Share on other sites

Hey, now i use this script to spawn a BRDM2 and it works.

// spawn_vcl.sqf

// JULY 2009 - norrin

if (!isServer) exitWith {};

_type = _this select 0;

_marker_pos = _this select 1;

// Create Vehicle

_vcl_new = _type createVehicle (getMarkerPos _marker_pos);

// Create Crew

_group = createGroup EAST;

"Ins_soldier_crew" createUnit [(getMarkerPos _marker_pos), _group];

"Ins_soldier_crew" createUnit [(getMarkerPos _marker_pos), _group];

"Ins_soldier_crew" createUnit [(getMarkerPos _marker_pos), _group];

_unitsGroup = units _group;

// Move crew in Vehicle

for [{ _loop = 0 },{ _loop < count _unitsGroup},{ _loop = _loop + 1}] do

{

_guy = _unitsGroup select _loop;

_guy setSkill 0.8;

if (_loop == 0) then {_guy moveInDriver _vcl_new};

if (_loop == 1) then {_guy moveInGunner _vcl_new};

if (_loop == 2) then {_guy moveInCargo _vcl_new};

sleep 0.1;

};

sleep 1;

// Add waypoints

_waypoint0 = _group addwaypoint[getmarkerpos"WP1",0];

_waypoint0 setwaypointtype"Move";

_waypoint1 = _group addwaypoint[getmarkerpos"WP2",0];

_waypoint1 setwaypointtype"Move";

But in MP there spawn 2 BRDM2's.... one is not moving to the WP. Do i have something more to do to make it fine for MP ?

I thougt that "if (!isServer) exitWith {};" will do that.

Share this post


Link to post
Share on other sites
@norrin

Would ot be impossible to spawn a helicopter flying? maybe with a group inside?

this would be great for my counter attack part of a MP mission

Check this out mate: http://norrin.org/downloads/ArmA2/AI_respawn/chopperSpawn_trigger.utes.rar

It spawns a Mi-24, pilot and gunner as well as a separate group of Russian units that are loaded into the cargo area of the chopper when the player moves into the trigger area that surrounds the flag in front of him. The foot soldiers spawn as a separate group so that you can add waypoints to them once they have disembarked.

The problem with spawning helicopters in the air is that they are spawned empty and with the engine off so you have to some how trick them into staying in the air until the crew is added and the engine powers up to the point that they won't crash straight into the ground.

The second waypoint given to the chopper in the test mission is a search and destroy waypoint so watch out especially if you start firing at the chopper.

Also check out the test mission to see how it works.

Good luck,

norrin

@ Wiggum, I'd have to see your mission to work out what's going wrong mate so if you can't sort it yourself send it here

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  

×