Jump to content
Sign in to follow this  
igneous01

waypoint error when using getvariable

Recommended Posts

so i started working on a random enemy spawn script that would spawn them randomly over any number of gamelogics, but the problem seems to be when i converted my spawn types into functions (inf, armor, light armor and vehicles, and air)

I keep getting this error in my rpt/

_wp = _spawned addWaypoint [getpos (_unit getVariable ">
 Error position: <addWaypoint [getpos (_unit getVariable ">
 Error 0 elements provided, 3 expected
File C:\Documents and Settings\david\My Documents\ArmA 2 Other Profiles\Pvt%20Zalewski\missions\test.utes\RUIS.sqf, line 64
Error in expression <ll BIS_fnc_spawnGroup;

but I declared the "attack" variable space a value of the gamelogic named attack. so im not sure why it tells me im missing the array index.

heres the full script, the errors are all from each functions addwaypoint (im assuming you cant add a waypoint like this?)

// RUIS script (Random Unit Invasion Script)

// example: nul = ["RU", [spawn1, spawn2, spawn3], attackwp, spawntimer, Scripttime] execVM "RUIS.sqf"
// "RU" - faction name
// [spawn1, ...] - gamelogics for units to spawn on
// attackwp - spawned units will move to this waypoint 
// spawntimer - amount of time to wait until the spawning of a new unit 
// scripttime - amount of time the script will run until it terminates

private ["_spawntime", "_logicS", "_logicE", "_temptime", "_scripttime", "_unit"];
_unit = _this select 0;
_logicS = _this select 1;
_logicE = _this select 2;
_unit setVariable ["spawn", _logicS, true];
_unit setVariable ["attack", _logicE, true];
_spawntime = _this select 3;
_scripttime = _this select 4;

// check what side was chosen, and assimilate proper values

// Russian faction
if (true) then {
   _unit setVariable ["infantry", ["RU_InfSquad", "RU_InfSection_MG", "RU_InfSection_AT", "RU_SniperTeam", "RU_InfSection_AA", "RU_InfSection"], true];
   _unit setVariable ["lightarmor", ["RU_MotInfSection_Recon", "RU_MotInfSection_Patrol", "RU_MechInfSquad_1", "RU_MechInfSquad_2"], true];
   _unit setVariable ["armor",  ["RU_TankPlatoon"], true];
   _unit setVariable ["air", ["RU_Mi24VSquadron", "RU_Mi24PSquadron"], true];
};

// Functions for spawn

if (isnil "DZ_Spawn_INF") then {
DZ_Spawn_INF = {
       private ["_unit", "_loc", "_wp", "_spawned"];
// spawn infantry a random of 3 times
   for "_i" from 1 to (ceil(random 3)) do 
       {
           _unit = (_unit getVariable "infantry") select floor(random(count (_unit getVariable "infantry")));
           _loc = (_unit getVariable "spawn") select floor(random(count (_unit getVariable "spawn")));
           // spawn random units
           _spawned = [getPos _loc, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Infantry" >> _unit),[],[],[],[],[],180] call BIS_fnc_spawnGroup;

           // move units to waypoint
           _wp = _spawned addWaypoint [position (_unit getVariable "attack"), 0];
           _wp setWaypointType "SAD"; 
           _wp setWaypointSpeed "NORMAL";
           [_spawned, 0] setWaypointBehaviour "AWARE";
           sleep (random 20);
       };
   };	
};

if (isnil "DZ_Spawn_LA") then {
   DZ_Spawn_LA = {
       private ["_unit", "_loc", "_wp", "_spawned"];
       // spawn vehicle a random of 3 times
   for "_i" from 1 to (ceil(random 3)) do 
       {
           _unit = (_unit getVariable "lightarmor") select floor(random(count (_unit getVariable "lightarmor")));
           _loc = (_unit getVariable "spawn") select floor(random(count (_unit getVariable "spawn")));
           // spawn random units
           _spawned = [getPos _loc, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Motorized" >> _unit),[],[],[],[],[],180] call BIS_fnc_spawnGroup;

           // move units to waypoint
           _wp = _spawned addWaypoint [getpos (_unit getVariable "attack"), 0];
           _wp setWaypointType "SAD"; 
           _wp setWaypointSpeed "NORMAL";
           [_spawned, 0] setWaypointBehaviour "AWARE";
           sleep (random 50);
       };
   };	
};

if (isnil "DZ_Spawn_ARM") then {
   DZ_Spawn_ARM = {
       private ["_unit", "_loc", "_wp", "_spawned"];
       // spawn vehicle a random of 3 times
       _unit = (_unit getVariable "armor") select floor(random(count (_unit getVariable "armor")));
       _loc = (_unit getVariable "spawn") select floor(random(count (_unit getVariable "spawn")));
       // spawn random units
       _spawned = [getPos _loc, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Armored" >> _unit),[],[],[],[],[],180] call BIS_fnc_spawnGroup;

       // move units to waypoint
       _wp = _spawned addWaypoint [getpos (_unit getVariable "attack"), 0];
       _wp setWaypointType "SAD"; 
       _wp setWaypointSpeed "NORMAL";
       [_spawned, 0] setWaypointBehaviour "AWARE";
   };	
};

if (isnil "DZ_Spawn_AIR") then {
   DZ_Spawn_AIR = {
       private ["_unit", "_loc", "_wp", "_spawned"];
       // spawn vehicle a random of 3 times
       _unit = (_unit getVariable "air") select floor(random(count (_unit getVariable "air")));
       _loc = (_unit getVariable "spawn") select floor(random(count (_unit getVariable "spawn")));
       // spawn random units
       _spawned = [getPos _loc, EAST, (configFile >> "CfgGroups" >> "East" >> "RU" >> "Air" >> _unit),[],[],[],[],[],180] call BIS_fnc_spawnGroup;

       // move units to waypoint
       _wp = _spawned addWaypoint [getpos (_unit getVariable "attack"), 0];
       _wp setWaypointType "SAD"; 
       _wp setWaypointSpeed "NORMAL";
       [_spawned, 0] setWaypointBehaviour "AWARE";
   };	
};

while {_scripttime > 0} do {

   _scripttime = _scripttime - 1;
   _temptime = _spawntime;

   [] spawn DZ_Spawn_INF;
   [] spawn DZ_Spawn_LA;
   [] spawn DZ_Spawn_ARM;
   [] spawn DZ_Spawn_AIR;

   waitUntil {sleep 1; _temptime = _temptime - 1; _temptime < 1};
};

if anyone has any idea of a workaround to get my waypoints to work (or where i messed up) id really appreciate it

Share this post


Link to post
Share on other sites

Try replacing / commenting the addWaypoint code with some debugging, make sure everything's getting passed along properly:

hint format ["getPos: %1\ngroup: %2", getPos (_unit getVariable "attack"), _spawned];

Sorry, I'd test this out myself but my comp died, running with notepad only here...

Edited by bhaz

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  

×