Jump to content
Sign in to follow this  
bigshotking

Help with vehicle spawn with crew

Recommended Posts

Hello everyone,

I made this script that spawns civilian vehicles and gives them a way point to drive to. The problem I'm having is that the vehicle spawns with people in them but they don't move anywhere!

well here is the script:

// Random Vehicle Spawner //
// Made by: 42nd|Bigshot //
// Spawns vehicles with civilians and gives them a waypoint to drive too. //

if (!isServer) exitWith{};

while {true} do {

private ["_vehicles", "_spawn", "_wp"];

// Array of Vehicles //
_vehicles = ["Ikarus_TK_CIV_EP1", "Lada1_TK_CIV_EP1", "Lada2_TK_CIV_EP1","LandRover_TK_CIV_EP1", "VolhaLimo_TK_CIV_EP1", "hilux1_civil_3_open_EP1", "S1203_TK_CIV_EP1", "SUV_TK_CIV_EP1", "Ural_TK_CIV_EP1", "V3S_Open_TK_CIV_EP1", "Volha_1_TK_CIV_EP1", "Volha_2_TK_CIV_EP1"] call BIS_fnc_selectRandom;

// Spawns Vehicles //
_spawn = [getMarkerPos "spawn", 315, _vehicles , Civilian] call bis_fnc_spawnvehicle;

// Spawn Waypoint //
_wp = _spawn addWaypoint [(getmarkerpos "waypoint"), 0];
_spawn setWaypointType "MOVE";
_spawn setWaypointCompletionRadius 30;
_spawn setwaypointCombatMode "BLUE";
_spawn setWaypointBehaviour "SAFE";

sleep 180;
};

Any help on this issue is greatly appreciated!

-Bigshot

Edited by bigshotking

Share this post


Link to post
Share on other sites

I would think, if you state:

_wp = _spawn addWaypoint [(getmarkerpos "waypoint"), 0];
_spawn setWaypointType "MOVE";
_spawn setWaypointCompletionRadius 30;
_spawn setwaypointCombatMode "BLUE";
_spawn setWaypointBehaviour "SAFE";

you would need to change to:

_wp = _spawn addWaypoint [(getmarkerpos "waypoint"), 0];
_wp setWaypointType "MOVE";
_wp setWaypointCompletionRadius 30;
_wp setwaypointCombatMode "BLUE";
_wp setWaypointBehaviour "SAFE";

make sure your marker position, named "waypoint" is placed on the map.

Edited by panther42

Share this post


Link to post
Share on other sites
I would think, if you state:

_wp = _spawn addWaypoint [(getmarkerpos "waypoint"), 0];
_spawn setWaypointType "MOVE";
_spawn setWaypointCompletionRadius 30;
_spawn setwaypointCombatMode "BLUE";
_spawn setWaypointBehaviour "SAFE";

you would need to change to:

_wp = _spawn addWaypoint [(getmarkerpos "waypoint"), 0];
_wp setWaypointType "MOVE";
_wp setWaypointCompletionRadius 30;
_wp setwaypointCombatMode "BLUE";
_wp setWaypointBehaviour "SAFE";

make sure your marker position, named "waypoint" is placed on the map.

I made the change, but nothing happened. I killed the driver and the vehicle is full of fuel and at full health. Any other ideas?

Share this post


Link to post
Share on other sites

yes, I think the waypoints will only move if you assign a group name, and have the group move.

something like:

_cargrp = _spawn select 2;

and then

_wp = _cargrp addWaypoint [(getmarkerpos "waypoint"), 0];
_wp setWaypointType "MOVE";
_wp setWaypointCompletionRadius 30;
_wp setwaypointCombatMode "BLUE";
_wp setWaypointBehaviour "SAFE";  

---------- Post added at 12:42 AM ---------- Previous post was at 12:39 AM ----------

or you can use this script by Demonized, and change to your needs:

// ------------ markers

mySpawnPos = getMarkerPos "carspawn";
wppos_1 = getMarkerPos "wpq";
wppos_2 = getMarkerPos "wpz";

// ------------ group spawn

v1 = [mySpawnPos, 001, "Ural_INS", east] call bis_fnc_spawnvehicle;
// Name the vehicle and group.
_car = v1 select 0;     // vehicle spawned.
_cargrp = v1 select 2;  // group of vehicle so waypoints work.

hint "assigning waypoints";
// ------------ waypoint assignment

wp1 = _cargrp addWaypoint [wppos_1, 1];
wp1 setWaypointType "MOVE";
wp1 setWaypointSpeed "FULL";
wp1 setBehaviour "Careless";

wp2 = _cargrp addWaypoint [wppos_2, 1];
wp2 setWaypointType "MOVE";
wp2 setWaypointSpeed "LIMITED";
wp2 setBehaviour "Careless";

// use domove on first wp to start moving if not moving.
(driver _car) doMove (getPos _car);  // if this line works delete below line, else delete this line and remove // in front of next line.
//(driver _car) doMove [(getPos _car select 0)+5, getPos _car select 1,0];  // use this line if above does not work.

hint "waypoints assigned exiting script";
// dont use exit in sqf because it will exit on its own once it reaches the end.  

from this post:

Vehicle spawn with waypoints by Demonized

Edited by panther42

Share this post


Link to post
Share on other sites

Works perfectly now1 Thank you so much for the help!

---------- Post added at 06:39 AM ---------- Previous post was at 06:14 AM ----------

Ok now I can't seem to get it to loop, I put an invisible helipad down and put this in its init:

null = this execVM "scripts\random_vehicles.sqf";

This is the updated script:

// Random Vehicle Spawner //
// Made by: 42nd|Bigshot //
// Spawns vehicles with civilians and gives them a waypoint to drive too. //

private ["_vehicles", "_spawn", "_car", "_cargrp", "_wp1", "_wp2"];

if (!isServer) exitWith{};

while {alive _this} do {

mySpawnPos = getMarkerPos "spawn";
wppos_1 = getMarkerPos "wp1";
wppos_2 = getMarkerPos "wp2";

// Array of Vehicles //
_vehicles = ["Ikarus_TK_CIV_EP1", "Lada1_TK_CIV_EP1", "Lada2_TK_CIV_EP1","LandRover_TK_CIV_EP1", "VolhaLimo_TK_CIV_EP1", "hilux1_civil_3_open_EP1", "S1203_TK_CIV_EP1", "SUV_TK_CIV_EP1", 
"Ural_TK_CIV_EP1", "V3S_Open_TK_CIV_EP1", "Volha_1_TK_CIV_EP1", "Volha_2_TK_CIV_EP1"] call BIS_fnc_selectRandom;


// Spawns Vehicles //
_spawn = [mySpawnPos, 300, _vehicles , Civilian] call bis_fnc_spawnvehicle;

_car = _spawn select 0;
_cargrp = _spawn select 2;

// Spawn Waypoint //
_wp1 = _cargrp addWaypoint [wppos_1, 1];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "LIMITED";
_wp1 setwaypointCombatMode "BLUE";
_wp1 setBehaviour "SAFE";

_wp2 = _cargrp addWaypoint [wppos_2, 1];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "LIMITED";
_wp2 setwaypointCombatMode "BLUE";
_wp2 setBehaviour "SAFE";

// Force Vehicle to Move //
(driver _car) doMove (getPos _car);

sleep 180;

};

Any ideas?

Share this post


Link to post
Share on other sites

Do you want this to continuously spawn civilian vehicles? Or just up to a certain count?

Share this post


Link to post
Share on other sites

A couple of things:

I would add the following to your code:

waituntil {!isnil "bis_fnc_init"};

Second, I don't know if you can check this line:

while {alive _this} do

on an invisible helipad? Maybe so if it is considered a building...

Maybe just an

while {alive player} do

You could try a count to spawn by adding the following:

for "_i" from 1 to x do {
_spawn = [mySpawnPos, 300, _vehicles , Civilian] call bis_fnc_spawnvehicle; 
};

Where x is the number of vehicles you want to have spawned

Share this post


Link to post
Share on other sites

Still no dice, the first vehicle spawns but no other vehicles spawn after that....

here is the updated script:

// Random Vehicle Spawner //
// Made by: 42nd|Bigshot //
// Spawns vehicles with civilians and gives them a waypoint to drive too. //

waituntil {!isnil "bis_fnc_init"}; 

private ["_vehicles", "_spawn", "_car", "_cargrp", "_wp1", "_wp2"];

if (!isServer) exitWith{};

while {alive player} do {

mySpawnPos = getMarkerPos "spawn";
wppos_1 = getMarkerPos "wp1";
wppos_2 = getMarkerPos "wp2";

// Array of Vehicles //
_vehicles = ["Ikarus_TK_CIV_EP1", "Lada1_TK_CIV_EP1", "Lada2_TK_CIV_EP1","LandRover_TK_CIV_EP1", "VolhaLimo_TK_CIV_EP1", "hilux1_civil_3_open_EP1", "S1203_TK_CIV_EP1", "SUV_TK_CIV_EP1", 
"Ural_TK_CIV_EP1", "V3S_Open_TK_CIV_EP1", "Volha_1_TK_CIV_EP1", "Volha_2_TK_CIV_EP1"] call BIS_fnc_selectRandom;


// Spawns Vehicles //
_spawn = [mySpawnPos, 300, _vehicles , Civilian] call bis_fnc_spawnvehicle;

_car = _spawn select 0;
_cargrp = _spawn select 2;

// Spawn Waypoint //
_wp1 = _cargrp addWaypoint [wppos_1, 1];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "LIMITED";
_wp1 setwaypointCombatMode "BLUE";
_wp1 setBehaviour "SAFE";

_wp2 = _cargrp addWaypoint [wppos_2, 1];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "LIMITED";
_wp2 setwaypointCombatMode "BLUE";
_wp2 setBehaviour "SAFE";

// Force Vehicle to Move //
(driver _car) doMove (getPos _car);

sleep 5;
};

Share this post


Link to post
Share on other sites

I tested this by adding:

nul = execVM "scripts\random_vehicles.sqf";

to my init.sqf.

also need to fix

_wp1 setBehaviour "SAFE";

and

_wp2 setBehaviour "SAFE";

to:

_wp1 setWaypointBehaviour "SAFE";

_wp2 setWaypointBehaviour "SAFE";

The vehicles spawn, but there are no crew assigned to these vehicles to move them...Apparently these vehicles have no default crew.

---------- Post added at 07:13 PM ---------- Previous post was at 06:45 PM ----------

I didn't have any other civilians on my map. :o As soon as I added one, seems to be working fine.

I will test the multiple spawns now.

Seems to work just fine. I changed the sleep time to 15 just to speed things up. Make sure you place a takistani civilian or another taki vehicle(not empty) on the map somewhere.

This is the script I'm using:

// Random Vehicle Spawner //
// Made by: 42nd|Bigshot //
// Spawns vehicles with civilians and gives them a waypoint to drive too. //

waituntil {!isnil "bis_fnc_init"};

private ["_vehicles", "_spawn", "_car", "_cargrp", "_wp1", "_wp2"];

if (!isServer) exitWith{};

while {alive player} do {

mySpawnPos = getMarkerPos "spawn";
wppos_1 = getMarkerPos "wp1";
wppos_2 = getMarkerPos "wp2";

// Array of Vehicles //
_vehicles = ["Ikarus_TK_CIV_EP1", "Lada1_TK_CIV_EP1", "Lada2_TK_CIV_EP1","LandRover_TK_CIV_EP1", "VolhaLimo_TK_CIV_EP1", "hilux1_civil_3_open_EP1", "S1203_TK_CIV_EP1", "SUV_TK_CIV_EP1", 
"Ural_TK_CIV_EP1", "V3S_Open_TK_CIV_EP1", "Volha_1_TK_CIV_EP1", "Volha_2_TK_CIV_EP1"] call BIS_fnc_selectRandom;


// Spawns Vehicles //
_spawn = [mySpawnPos, 300, _vehicles , Civilian] call bis_fnc_spawnvehicle;

_car = _spawn select 0;
_cargrp = _spawn select 2;

// Spawn Waypoint //
_wp1 = _cargrp addWaypoint [wppos_1, 1];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "LIMITED";
_wp1 setWaypointCombatMode "BLUE";
_wp1 setWaypointBehaviour "SAFE";

_wp2 = _cargrp addWaypoint [wppos_2, 1];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "LIMITED";
_wp2 setWaypointCombatMode "BLUE";
_wp2 setWaypointBehaviour "SAFE";

// Force Vehicle to Move //
(driver _car) doMove (getPos _car);

   sleep 15;

};

Only problem with this, is you can end up with a butt load of vehicles. Maybe the For _i loop with a limit on the count would work better.

However you want to do it...

Edited by panther42

Share this post


Link to post
Share on other sites

I get an error when I run that script....

Try this for adding your waypoints....

_wp1 = _cargrp addWaypoint [wppos_1, 1];
[_cargrp , 1] setWaypointType "MOVE";
[_cargrp , 1] setWaypointSpeed "LIMITED";
[_cargrp , 1] setwaypointCombatMode "BLUE";
[_cargrp , 1] setWaypointBehaviour "SAFE";

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

ALSO... seems like if you had this added to your shortcut you would see the errors too... -showscripterrors

Edited by twirly

Share this post


Link to post
Share on other sites

Twirly, yeah I caught that. I run the showscript errors.

You must have posted at the same time I was editing my post before yours...:)

Share this post


Link to post
Share on other sites

Works beautifully! Thank you for your help!

I was wondering if may spice this up a little by adding enemies into the possible spawning array.

This is what I attempted but, nothing happens, the script fails to run.

// Random Vehicle Spawner //
// Made by: 42nd|Bigshot //
// Spawns vehicles with civilians and gives them a waypoint to drive too. //

waituntil {!isnil "bis_fnc_init"}; 

private ["_vehicles", "_spawn", "_car", "_cargrp", "_wp1", "_wp2"];

if (!isServer) exitWith{};

while {alive player} do {

mySpawnPos = getMarkerPos "spawn";
wppos_1 = getMarkerPos "wp1";
wppos_2 = getMarkerPos "wp2";

// Array of Vehicles //
_vehicles = ["Ikarus_TK_CIV_EP1", "Lada1_TK_CIV_EP1", "Lada2_TK_CIV_EP1","LandRover_TK_CIV_EP1", "VolhaLimo_TK_CIV_EP1", "hilux1_civil_3_open_EP1", "S1203_TK_CIV_EP1", "SUV_TK_CIV_EP1", 
"Ural_TK_CIV_EP1", "V3S_Open_TK_CIV_EP1", "Volha_1_TK_CIV_EP1", "Volha_2_TK_CIV_EP1", "LandRover_MG_TK_INS_EP1", "LandRover_SPG9_TK_INS_EP1"] call BIS_fnc_selectRandom;

// Spawns Vehicles //
if (_vehicles = "LandRover_MG_TK_INS_EP1" OR "LandRover_SPG9_TK_INS_EP1") then {
_spawn = [mySpawnPos, 300, _vehicles , East] call bis_fnc_spawnvehicle;
} else {
_spawn = [mySpawnPos, 300, _vehicles , Civilian] call bis_fnc_spawnvehicle;
};

_car = _spawn select 0;
_cargrp = _spawn select 2;

// Spawn Waypoint //
_wp1 = _cargrp addWaypoint [wppos_1, 1];
[_cargrp , 1] setWaypointType "MOVE";
[_cargrp , 1] setWaypointSpeed "LIMITED";
[_cargrp , 1] setwaypointCombatMode "BLUE";
[_cargrp , 1] setWaypointBehaviour "SAFE";

_wp2 = _cargrp addWaypoint [wppos_2, 1];
[_cargrp , 1] setWaypointType "MOVE";
[_cargrp , 1] setWaypointSpeed "LIMITED";
[_cargrp , 1] setwaypointCombatMode "BLUE";
[_cargrp , 1] setWaypointBehaviour "SAFE";  

// Force Vehicle to Move //
(driver _car) doMove (getPos _car);

sleep 5; // Testing Purposes //
};

Edited by bigshotking

Share this post


Link to post
Share on other sites

Well at first glance....this is what this should be...

if (_vehicles == "LandRover_MG_TK_INS_EP1" or _vehicles == "LandRover_SPG9_TK_INS_EP1") then {

Oh... and put an EAST soldier somewhere on the map... you can put this in his INIT.... deleteVehicle this; ... and he will never show up.

Edited by twirly

Share this post


Link to post
Share on other sites

I guess the waypoints work both ways, as mine are working as:

// Spawn Waypoint //
_wp1 = _cargrp addWaypoint [wppos_1, 1];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "LIMITED";
_wp1 setWaypointCombatMode "BLUE";
_wp1 setWaypointBehaviour "SAFE";

_wp2 = _cargrp addWaypoint [wppos_2, 1];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "LIMITED";
_wp2 setWaypointCombatMode "BLUE";
_wp2 setWaypointBehaviour "SAFE";

Share this post


Link to post
Share on other sites
I guess the waypoints work both ways, as mine are working as:

// Spawn Waypoint //
_wp1 = _cargrp addWaypoint [wppos_1, 1];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "LIMITED";
_wp1 setWaypointCombatMode "BLUE";
_wp1 setWaypointBehaviour "SAFE";

_wp2 = _cargrp addWaypoint [wppos_2, 1];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "LIMITED";
_wp2 setWaypointCombatMode "BLUE";
_wp2 setWaypointBehaviour "SAFE";

Yeah then.... I suppose they do. The Wiki describes two different ways without being very clear about the first!

---------- Post added at 02:00 PM ---------- Previous post was at 01:58 PM ----------

@bigshotking...

The code works fine.... but you have to declare/initialise _vehicles before the while {alive player} do { loop.

_vehicles =[]; will work fine.

Share this post


Link to post
Share on other sites

you might want to change the waypoints with regards to the vehicle spawned then...

I added this:

// Spawns Vehicles //
if (_vehicles == "LandRover_MG_TK_INS_EP1" or _vehicles == "LandRover_SPG9_TK_INS_EP1") then
		{
           _spawn = [mySpawnPos, 300, _vehicles , East] call bis_fnc_spawnvehicle;
		_car = _spawn select 0;
		_cargrp = _spawn select 2;
		// Spawn Waypoint //
		_wp1 = _cargrp addWaypoint [wppos_1, 1];
		_wp1 setWaypointType "MOVE";
		_wp1 setWaypointSpeed "LIMITED";
		_wp1 setWaypointCombatMode "RED";
		_wp1 setWaypointBehaviour "AWARE";

		_wp2 = _cargrp addWaypoint [wppos_2, 1];
		_wp2 setWaypointType "MOVE";
		_wp2 setWaypointSpeed "LIMITED";
		_wp2 setWaypointCombatMode "RED";
		_wp2 setWaypointBehaviour "AWARE";
		}
		else
           {
           _spawn = [mySpawnPos, 300, _vehicles , Civilian] call bis_fnc_spawnvehicle;
		_car = _spawn select 0;
		_cargrp = _spawn select 2;
		// Spawn Waypoint //
		_wp1 = _cargrp addWaypoint [wppos_1, 1];
		_wp1 setWaypointType "MOVE";
		_wp1 setWaypointSpeed "LIMITED";
		_wp1 setWaypointCombatMode "BLUE";
		_wp1 setWaypointBehaviour "SAFE";

		_wp2 = _cargrp addWaypoint [wppos_2, 1];
		_wp2 setWaypointType "MOVE";
		_wp2 setWaypointSpeed "LIMITED";
		_wp2 setWaypointCombatMode "BLUE";
		_wp2 setWaypointBehaviour "SAFE";
           };

Which makes the East spawned groups attack me as a Bluefor player.

Otherwise, the waypoints were set as CombatMode "Blue". Maybe Twirly has a better idea, or this is not what you were after...

Share this post


Link to post
Share on other sites

That did the trick guys thankyou! The enemy vehicles seem confused at first but after 10 seconds or so they get moving or get back-on the road.

Thanks again guys!

-Bigshot

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  

×