Jump to content
Sign in to follow this  
total

Help needed - Spawning units with waypoints, with Trigger

Recommended Posts

Need help! :p I can't find an example with position numbers, only objects, units or markers.

1) setWaypointPosition or addwaypoint? I get Error Type Number

2) How do I replace AA_Squad_spawn1-marker with position?

if (!isServer) exitwith {};
_side = createCenter EAST;
_AASquad1 = [getMarkerPos "AA_Squad_spawn1", _side, ["O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;

_wp1 = _AASquad1 addWaypoint [14230.033,14.379024]];    
_wp1 setWaypointType "MOVE";
_wp1 setWaypointStatements ["true", ""];  
_wp1 setWaypointCombatMode "RED";
_wp1 setWaypointSpeed "NORMAL";

_wp2 = _AASquad1 addWaypoint [14414.781,17.423283]];    
_wp2 setWaypointType "MOVE";
_wp2 setWaypointStatements ["true", ""];  
_wp2 setWaypointCombatMode "RED";
_wp2 setWaypointSpeed "NORMAL";

_wp3 = _AASquad1 addWaypoint [14415.356,17.463614]];    
_wp3 setWaypointType "MOVE";
_wp3 setWaypointStatements ["true", ""];  
_wp3 setWaypointCombatMode "RED";
_wp3 setWaypointSpeed "NORMAL";

_wp4 = _AASquad1 addWaypoint [14079.998,14.377373]];    
_wp4 setWaypointType "CYCLE";
_wp4 setWaypointStatements ["true", ""]; 

or this? I have no idea.

if (!isServer) exitwith {};
_side = createCenter EAST;
_AASquad1 = [getMarkerPos "AA_Squad_spawn1", _side, ["O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;

_marker1 = createMarker ["wp1", [14230.033,14.379024]];
_marker1 setMarkerType "mil_destroy";
_marker1 setMarkerColor "ColorRed";

_marker2 = createMarker ["wp2", [14414.781,17.423283]];
_marker2 setMarkerType "mil_destroy";
_marker2 setMarkerColor "ColorRed";

_marker3 = createMarker ["wp3", [14415.356,17.463614]];
_marker3 setMarkerType "mil_destroy";
_marker3 setMarkerColor "ColorRed";

_marker4 = createMarker ["wp4", [14079.998,14.377373]];
_marker4 setMarkerType "mil_destroy";
_marker4 setMarkerColor "ColorRed";



_wp1 = _AASquad1 addWaypoint [getMarkerPos "wp1", 0];    
_wp1 setWaypointType "MOVE";
_wp1 setWaypointStatements ["true", ""];  
_wp1 setWaypointCombatMode "RED";
_wp1 setWaypointSpeed "NORMAL";

_wp2 = _AASquad1 addWaypoint [getMarkerPos "wp2", 0];    
_wp2 setWaypointType "MOVE";
_wp2 setWaypointStatements ["true", ""];  
_wp2 setWaypointCombatMode "RED";
_wp2 setWaypointSpeed "NORMAL";

_wp3 = _AASquad1 addWaypoint [getMarkerPos "wp3", 0];    
_wp3 setWaypointType "MOVE";
_wp3 setWaypointStatements ["true", ""];  
_wp3 setWaypointCombatMode "RED";
_wp3 setWaypointSpeed "NORMAL";

_wp4 = _AASquad1 addWaypoint [getMarkerPos "wp4", 0];   
_wp4 setWaypointType "CYCLE";
_wp4 setWaypointStatements ["true", ""]; 

Edited by Total

Share this post


Link to post
Share on other sites

Looks like you have too many brackets at the end of your addWaypoint lines. Remove one of them.

Share this post


Link to post
Share on other sites

I can't get the waypoint positions to work. I tried creating markers with positions and use getMarkerpos on waypoints, but nothing works.

Edited by Total

Share this post


Link to post
Share on other sites

@Delta99: I've tried to remove it, but still it doesn't work. The unit spawns, but the waypoinst doesn't work at all.

Share this post


Link to post
Share on other sites

This way works for me.

_AISpawnLoc = "AISpawn"; 
_AttckPos = getMarkerPos "AttackArea"; 

_grp1 = createGroup east; 
_grp1 = [getMarkerPos _AISpawnLoc, east, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfTeam")] call BIS_fnc_spawnGroup; 

_wp0 = _grp1 addWaypoint [ _AttckPos,0]; 
_wp0 setWaypointType "SAD"; 
_wp0 setWaypointFormation "COLUMN"; 
_wp0 setWaypointBehaviour "COMBAT"; 
_wp0 setwaypointcombatmode "RED"; 
_wp0 setWaypointSpeed "LIMITED"; 
_wp0 setWaypointCompletionRadius 20; 

---------- Post added at 03:47 PM ---------- Previous post was at 03:32 PM ----------

It's not the index of the waypoints is it? (in red)

_wp1 = _AASquad1 addWaypoint [getMarkerPos "wp1", 0];

_wp1 setWaypointType "MOVE";

_wp1 setWaypointStatements ["true", ""];

_wp1 setWaypointCombatMode "RED";

_wp1 setWaypointSpeed "NORMAL";

_wp2 = _AASquad1 addWaypoint [getMarkerPos "wp2", 1];

_wp2 setWaypointType "MOVE";

_wp2 setWaypointStatements ["true", ""];

_wp2 setWaypointCombatMode "RED";

_wp2 setWaypointSpeed "NORMAL";

_wp3 = _AASquad1 addWaypoint [getMarkerPos "wp3", 2];

_wp3 setWaypointType "MOVE";

_wp3 setWaypointStatements ["true", ""];

_wp3 setWaypointCombatMode "RED";

_wp3 setWaypointSpeed "NORMAL";

_wp4 = _AASquad1 addWaypoint [getMarkerPos "wp4", 3];

_wp4 setWaypointType "CYCLE";

_wp4 setWaypointStatements ["true", ""];

Share this post


Link to post
Share on other sites

I want to connect this script with Urban Patrol.

What's wrong?

if (!isServer) exitwith {};
_side = createCenter EAST;

// Anti Air Squad - Gravia
_01_wp0 = getMarkerPos "01_wp0";

_01Squad = [getMarkerPos "01_spawn", _side, ["O_soldier_TL_F","O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;
_01Squad = setvariable ["nul=[this,""Sector1"",""random""] execVM ""ups.sqf""], true];

_wp0 = _01Squad addWaypoint [ _01_wp0,0];  
_wp0 setWaypointType "MOVE";
_wp0 setWaypointStatements ["true", ""];
_wp0 setWaypointCombatMode "RED";
_wp0 setWaypointSpeed "NORMAL";

Is this the right way to get all units to run UPS?

_01Squad = setvariable ["nul=[this,""Sector1"",""random""] execVM ""ups.sqf""], true];

1) AI spawns

2) Follows the waypoint into the marker "Sector1"

3) Generates new random waypoints with UPS inside the marker "Sector1".

If not, how can I get this to work?

Edited by Total

Share this post


Link to post
Share on other sites

_01Squad = setvariable [nul=[this,"sector1","NOAI"] execVM "ups.sqf"];

Error message: Missing ;

Whats wrong?

Share this post


Link to post
Share on other sites

setVariable doesn't work that way at all, you don't execute code within in you just set a value referenced to an object. I don't think you want to use setvariable there at all, just the exeVM stuff on it's own.

_01Squad = [getMarkerPos "01_spawn", _side, ["O_soldier_TL_F","O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;
[_01Squad,"Sector1","random"] execVM "ups.sqf";

Share this post


Link to post
Share on other sites

Error in expression <c) then {_exit = false;}		
} else {
if (count _obj>0) then {
{if (alive _x) then>
 Error position: <count _obj>0) then {
{if (alive _x) then>
 Error count: Type Group, expected Array,Config entry
File C:\Users\Total\Documents\Arma 3 - Other Profiles\[aCe]Total\missions\[aCe]COOP_test.Altis\ups.sqf, line 191

What's wrong?

if (!isServer) exitwith {};
_side = createCenter EAST;

// Anti Air Squad - Gravia
_01_wp0 = getMarkerPos "01_wp0";

_01Squad = [getMarkerPos "01_spawn", _side, ["O_soldier_TL_F","O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;
[_01Squad,"Alpha","random"] execVM "ups.sqf";

_wp0 = _01Squad addWaypoint [ _01_wp0,0];  
_wp0 setWaypointType "MOVE";
_wp0 setWaypointStatements ["true", ""];
_wp0 setWaypointCombatMode "RED";
_wp0 setWaypointSpeed "NORMAL";  

// unit that's moving
_obj = _this select 0;		
_npc = _obj;
// is anybody alive in the group?
_exit = true;		
if (typename _obj=="OBJECT") then {
if (alive _npc) then {_exit = false;}		
} else {
if (count _obj>0) then {
	{if (alive _x) then {_npc = _x; _exit = false;}} forEach _obj;
};
};

Edited by Total

Share this post


Link to post
Share on other sites

That error is from 191 lines down, not the first 10 lines of the script. The error references code you're not showing us.

Share this post


Link to post
Share on other sites

Ooh, ok. Looks like UPS is designed to be run from the group leader's init. So change your code to:

[leader _01Squad,"Alpha","random"] execVM "ups.sqf";

Share this post


Link to post
Share on other sites

Thanks, that fixed the problem. Now it has suddenly appeared an new error message. AI spawns, but disappear 1-2 seconds later when this error message pops up:

Error in expression <KRON_TRGFlag=KRON_Trig_EAST_Alpha>
 Error position: <KRON_Trig_EAST_Alpha>
 Error Undefined variable in expression: kron_trig_east_alpha

Share this post


Link to post
Share on other sites

But why does my array spawned units disappear as soon as they run UPS ? Is it possible to get the leader to not run UPS before last waypoint is completed?

Edited by Total

Share this post


Link to post
Share on other sites

Caching?

It seems like it's my waypoints that are the problem. How can I get UPS to run after the waypoint is completed? In the worst case, how can I put Sleep on UPS, so it doesn't run until after 2-3 minutes?

Waypoint = 0

If waypoint = 1 run UPS.sqf

if (!isServer) exitwith {};
_side = createCenter EAST;

// Anti Air Squad - Gravia
_01_wp0 = getMarkerPos "01_wp0";

_01Squad = [getMarkerPos "01_spawn", _side, ["O_soldier_TL_F","O_soldier_TL_F", "O_soldier_AA_F", "O_soldier_AA_F", "O_soldier_AA_F"], [], [], [0.3, 0.6]] call BIS_fnc_spawnGroup;
[leader _01Squad,"Alpha","random"] execVM "ups.sqf";

_wp0 = _01Squad addWaypoint [ _01_wp0,0];  
_wp0 setWaypointType "MOVE";
_wp0 setWaypointStatements ["true", ""];
_wp0 setWaypointCombatMode "RED";
_wp0 setWaypointSpeed "NORMAL";  

Edited by Total

Share this post


Link to post
Share on other sites

You don't. Either you give your guys waypoints OR you set them up to patrol a marker using UPS. Why have them walk to a waypoint anyway, just start them at the marker and have them patrol

Or run the ups from the waypoint.

_wp0 setWaypointStatements ["true", "foo = [leader this,'Alpha','random'] execVM 'ups.sqf';"];

I think that might work, but trying to combine waypoints and a script which dictates waypoints is just a recipe for a headache. :)

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  

×