Jump to content

Sign in to follow this  
hogmason

array for spawn pos using call BIS_fnc_spawnVehicle;

Recommended Posts

ok so i am working on a little script to spawn enemy patrols around a map but i have hit a rock.

i am creating an array of spawn positions whitch are empty helipads, but when i use select _i later in the code it fails now i know its becouse i need a object not a array or whatever but how do i work around it

this is what i have ill highlight the bit in red.

waituntil {!isnil "bis_fnc_init"};
if (isServer) then 
{	

_gamelogic = center;

MARKER_array = [];
[color="#FF0000"]spawn_array = [];[/color]
 for "_i" from 0 to 100 do
   {
	  _towns = nearestLocations [getPosATL _gamelogic, ["NameVillage","NameCity","NameCityCapital"], 25000];
	   _RandomPosition = position (_towns select (floor (random (count _towns))));
	    _marker = createmarkerLocal ["WPT %1",_RandomPosition];
            MARKER_array set[(count MARKER_array), _marker];
	};

[color="#FF0000"]_selectmkr = (MARKER_array select _i);


 		for "_i" from 0 to 50 do
    {
	_spawn_position = "HeliHEmpty" createVehicle (getMarkerPos _selectmkr);
	spawn_array set[(count spawn_array), _spawn_position];
	};[/color]			

//Create Group
///////////////////////
_side = east;
_convoycenter = createCenter _side;
_convoygrp = createGroup _side;

for "_i" from 0 to 35 do
{
// Create Waypoints
///////////////////////	
_selectwp = (MARKER_array select _i);
		_wp = _convoygrp addWaypoint [(getmarkerpos _selectwp), 0];
		[_convoygrp,_i] setWaypointType "MOVE";
		[_convoygrp,_i] setWaypointCompletionRadius 30;
		[_convoygrp,_i] setwaypointCombatMode "BLUE";
		[_convoygrp,_i] setWaypointFormation "FILE";
		[_convoygrp,_i] setWaypointBehaviour "SAFE";


// Create Vehicle
///////////////////////
   //_selectPOS = (spawn_array select _i);
  [color="#FF0000"] _position = (spawn_array select _i);[/color]
_vehicle = ["T72_TK_EP1","T55_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_TK_EP1","BRDM2_ATGM_TK_EP1","M113_TK_EP1","UAZ_AGS30_TK_EP1","LandRover_MG_TK_EP1","UAZ_AGS30_TK_EP1","BRDM2_ATGM_TK_EP1","LandRover_SPG9_TK_EP1"] call BIS_fnc_selectRandom;
  [color="#FF0000"] _patrol = [(getpos _position), [/color](getdir _position), (_vehicle), _convoygrp] call BIS_fnc_spawnVehicle;
_spawnpatrol = (_patrol select 0);
 //_patrol setVehicleInit "[""killed"",{null = this execVM 'common\enemy_patrol_respawn.sqf';}]";
 //processInitCommands;

// Fill Vehicle Cargo
//////////////////////
_cargoNum = _spawnpatrol emptyPositions "cargo";
if (_cargoNum > 0) then 
{
  _fillSlots = round (random _cargoNum);
   _pos = getpos _position;
    _locGr =  _pos findEmptyPosition [10, 100];
	 sleep .2;

	if (_locGr select 0 > 0)then 
	{
	   _cargo = [_locGr, _convoygrp , _cargoNum,[],[],[],[],[_fillSlots,.5]] call BIS_fnc_spawnGroup;
	    sleep .2;
		 {_x moveInCargo _spawnpatrol;} forEach units _cargo;
	};
};	

	                      if (HOG_debug) then 
                       {                 
	                    [sgt,nil,rgroupChat,"Spawning Enemy vehicle."] call RE; 
                            sleep 0.2;				
                             [_spawnpatrol,"ptl","ColorGreen","mil_dot"] spawn TOD_debug_mkrs_fnc;
                          };

    sleep 1;
   };

};


cheers

Share this post


Link to post
Share on other sites

This line:

_selectmkr = (MARKER_array select _i);

is probably not in the right place.

Being out of any for loop, the _i references to either nothing or the previous one, wich is 100 (I don't remember if the for variable is local to the block or not).

So your second loop would spawn 50 HeliEmpty at the same place, the last in your MARKER_array.

Move that line into the second for loop and see what happens.

Share this post


Link to post
Share on other sites

i ended up changing it to

for "_i" from 0 to 35 do
{
// Create Waypoints
///////////////////////	
[color="#FF0000"]_selectwp = (MARKER_array select _i);[/color]
		_wp = _convoygrp addWaypoint [(getmarkerpos _selectwp), 0];
		[_convoygrp,_i] setWaypointType "MOVE";
		[_convoygrp,_i] setWaypointCompletionRadius 30;
		[_convoygrp,_i] setwaypointCombatMode "BLUE";
		[_convoygrp,_i] setWaypointFormation "FILE";
		[_convoygrp,_i] setWaypointBehaviour "SAFE";

// Create Vehicle
///////////////////////
   [color="#FF0000"]_position = "HeliHEmpty" createVehicle (getMarkerPos _selectwp);[/color]
_vehicle = ["T72_TK_EP1","T55_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_TK_EP1","BRDM2_ATGM_TK_EP1","M113_TK_EP1","UAZ_AGS30_TK_EP1","LandRover_MG_TK_EP1","UAZ_AGS30_TK_EP1","BRDM2_ATGM_TK_EP1","LandRover_SPG9_TK_EP1"] call BIS_fnc_selectRandom;
   _patrol = [(getpos _position), (getdir _position), (_vehicle), _convoygrp] call BIS_fnc_spawnVehicle;



now this works fine everything spawns and no errors BUT

the first 1 to spawn spawns in a good spot the rest of them all spawn in the bottom left corner then move to there waypoints.

Share this post


Link to post
Share on other sites

Might have to do with that one:

_marker = createmarkerLocal ["WPT %1",_RandomPosition];

They all get the same name: WPT %1.

The %1 is usually used in the format command. I'd guess that's waht you wanted to do, but forgot about it?

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  

×