Jump to content

Photo
- - - - -

HELP: Spawn Vehicles /Planes


  • Please log in to reply
40 replies to this topic

#1 CaptainBravo

CaptainBravo

    Master Sergeant

  • Members
  • 730 posts

Posted 12 July 2009 - 22:09

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.

#2 -D:W- CryHavok

-D:W- CryHavok

    Private First Class

  • Members
  • 19 posts

Posted 12 July 2009 - 23:10

try this script http://www.armaholic...age.php?id=6199

#3 CaptainBravo

CaptainBravo

    Master Sergeant

  • Members
  • 730 posts

Posted 13 July 2009 - 08:40

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.

#4 CaptainBravo

CaptainBravo

    Master Sergeant

  • Members
  • 730 posts

Posted 14 July 2009 - 09:52

Anyone?

#5 norrin

norrin

    Master Gunnery Sergeant

  • Members
  • 1129 posts

Posted 14 July 2009 - 09:58

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...p?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.
Posted Image
**[XDF]*****************************[AAW]**

#6 Wiggum

Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 14 July 2009 - 11:01

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, 14 July 2009 - 11:34.


#7 norrin

norrin

    Master Gunnery Sergeant

  • Members
  • 1129 posts

Posted 14 July 2009 - 11:45

AI vehicle respawn that moves to waypoint script

© JULY 2009 - norrin

Download
http://norrin.org/do...awn_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/do...rigger.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, 14 July 2009 - 12:05.

Posted Image
**[XDF]*****************************[AAW]**

#8 CaptainBravo

CaptainBravo

    Master Sergeant

  • Members
  • 730 posts

Posted 14 July 2009 - 12:10

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!

#9 norrin

norrin

    Master Gunnery Sergeant

  • Members
  • 1129 posts

Posted 14 July 2009 - 12:14

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, 14 July 2009 - 12:17.

Posted Image
**[XDF]*****************************[AAW]**

#10 Wiggum

Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 14 July 2009 - 13:39

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, 14 July 2009 - 13:46.


#11 norrin

norrin

    Master Gunnery Sergeant

  • Members
  • 1129 posts

Posted 15 July 2009 - 00:46

Seems to be working OK here. Try this: http://www.norrin.or...r_east.utes.rar

Spawns a BMP2_INS and crew when the US player enters the trigger area. Units board the BMP and the BMP attacks the player and then moves off on waypoints. Please let me know if you're still having problems.
Posted Image
**[XDF]*****************************[AAW]**

#12 CaptainBravo

CaptainBravo

    Master Sergeant

  • Members
  • 730 posts

Posted 15 July 2009 - 12:29

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!

#13 norrin

norrin

    Master Gunnery Sergeant

  • Members
  • 1129 posts

Posted 15 July 2009 - 12:46

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.bis...iki/addWaypoint
Posted Image
**[XDF]*****************************[AAW]**

#14 CaptainBravo

CaptainBravo

    Master Sergeant

  • Members
  • 730 posts

Posted 16 July 2009 - 09:34

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.

#15 norrin

norrin

    Master Gunnery Sergeant

  • Members
  • 1129 posts

Posted 16 July 2009 - 09:55

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.bis...setWaypointType

You can also add lines that set:
setWaypointBehaviour: http://community.bis...ypointBehaviour
setWaypointFormation: http://community.bis...ypointFormation
setWaypointSpeed: http://community.bis...etWaypointSpeed etc etc

See here for a full list of setwaypoint commands: http://community.bis...g_Commands_ArmA
Posted Image
**[XDF]*****************************[AAW]**

#16 CaptainBravo

CaptainBravo

    Master Sergeant

  • Members
  • 730 posts

Posted 16 July 2009 - 13:17

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.

#17 norrin

norrin

    Master Gunnery Sergeant

  • Members
  • 1129 posts

Posted 16 July 2009 - 13:56

_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";

Posted Image
**[XDF]*****************************[AAW]**

#18 Wiggum

Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 16 July 2009 - 14:40

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, 16 July 2009 - 15:53.


#19 norrin

norrin

    Master Gunnery Sergeant

  • Members
  • 1129 posts

Posted 16 July 2009 - 21:16

@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.
Posted Image
**[XDF]*****************************[AAW]**

#20 Wiggum

Wiggum

    Master Gunnery Sergeant

  • Members
  • 1379 posts

Posted 17 July 2009 - 14:24

Ok, thanks norrin !

Mhhh,

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

Edited by Wiggum, 17 July 2009 - 15:03.