Jump to content
Sign in to follow this  
avibird 1

How an you set a move waypoint to be behind the players locatuion by 500 meters!

Recommended Posts

another stumbling block ): I would like to keep a medical support squad ~ 500 meter from the front lines.

I am using this to spawn the group into the game -

_pos = [(getPosATL Player select 0) + (1500 * sin(180)), (getPosATL Player select 1) + (1500 * cos(180)), 0];

GroupMedical = CreateGroup West; this works great the group is south of the players location and 1500 meters away.

for the waypoint I am using this wp1 = GroupMedical addwaypoint [position Player, 500]; You would think the group would only go 500 meters towards the player but in fact the group rolls right next to the players location less then 50 meters away.

So I tryed this wp1 = GroupMedical addwaypoint [(getPosATL Player select 0) + (500 * sin(180)), (getPosATL Player select 1) + (500 * cos(180)), 0]; The group does spawn into the game but will not advance to the first WP set.

Any input on how I can keep a group in the rear based on the PLAYERS current location. AVIBIRD

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

If you need a waypoint 500m behind where the player is currently facing it's:

_wpx = _groupName addWaypoint [(player ModelToWorld [0,-500,0]), 0]; 
_wpx setWaypointType "MOVE";

wp1 = GroupMedical addwaypoint [(getPosATL Player select 0) + (500 * sin(180)), (getPosATL Player select 1) + (500 * cos(180)), 0];
wp1 setWaypointType "MOVE";

There is an error in the above, positions need to be in an array [x,y,z]:

wp1 = grp4 addwaypoint [[color="#FF0000"][[/color](getPosATL Player select 0) + (500 * sin(180)), (getPosATL Player select 1) + (500 * cos(180))[color="#FF0000"]][/color], 0];

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

Posted on November 26, 2009

tijmenjoppe

If you add a waypoint to your group and then want them to start moving to that waypoint, make sure to call setWaypointType "MOVE" on your waypoint.

Remember you don't actually need to keep creating waypoints everytime you need a group to move somewhere:

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

{
_x doMove [(getPosATL Player select 0) + (500 * sin(180)), (getPosATL Player select 1) + (500 * cos(180)), 0]; 
_x setSpeedMode "FULL";
} forEach units _groupName;

If you keep running that in a loop, they will follow a position 500m south of the player.

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

Hey Mattar I did have a waypoint type within the code!

Your codeline of wpx = _groupName addWaypoint [(player ModelToWorld [0,-500,0]), 0];

_wpx setWaypointType "MOVE"; did not work!

Hey is how I am using it

hint "Squad Leader advance to the sector Position that you want Medical Support Squad Dove to setup a Mash location, deployment time ETA 2 minutes from staging sector"; 

//staging sector
wp1 = GroupMedical addwaypoint [position Player, 0]; 
wp1 waypointAttachVehicle vehicle player; 
wp1 setwaypointtype "MOVE"; 
wp1 setWaypointCombatMode "YELLOW"; 
wp1 setWaypointFormation "STAG COLUMN";
wp1 setWaypointSpeed "FULL"; 
wp1 setWaypointBehaviour "AWARE"; 
wp1 setWaypointCompletionRadius 10; 
wp1 setWaypointStatements ["true", "hint 'Medical personal Squad Dove Attempting to move to Position Alpha';"];
wp1 setWaypointTimeout [60,60,60];   


//Alpha waypoint
wp2 = GroupMedical addwaypoint [position Player, 0];   
wp2 waypointAttachVehicle vehicle player;  
wp2 setwaypointtype "MOVE"; 
wp2 setWaypointCombatMode "Yellow"; 
wp2 setWaypointFormation "STAG COLUMN"; 
wp2 setWaypointSpeed "FULL"; 
wp2 setWaypointBehaviour "AWARE"; 
wp2 setWaypointCompletionRadius 10;
wp2 setWaypointStatements ["true", "hint 'Medical personal Squad Dove Attempting to move to Position Bravo';"];
wp2 setWaypointTimeout [60,60,60]; 


Bravo waypoint
wp3 = GroupMedical addwaypoint [(player ModelToWorld [0,-500,0]), 0];  
//wp3 waypointAttachVehicle vehicle player;  
wp3 setwaypointtype "MOVE"; 
wp3 setWaypointCombatMode "YELLOW"; 
wp3 setWaypointFormation "VEE"; 
wp3 setWaypointSpeed "FULL"; 
wp3 setWaypointBehaviour "AWARE"; 
wp3 setWaypointCompletionRadius 10;
wp3 setWaypointStatements ["true", "hint 'Medical personal Squad Dove has setup MASH location at your rear';"];

If you can take a look to see if I F up something with the code. AVIBIRD

Share this post


Link to post
Share on other sites

I see you are missing // in front of Bravo waypoint

Share this post


Link to post
Share on other sites
Hey Mattar I did have a waypoint type within the code!

Your codeline of wpx = _groupName addWaypoint [(player ModelToWorld [0,-500,0]), 0];

_wpx setWaypointType "MOVE"; did not work!

You can't be using it right then? It creates a WP -180 degs from the direction where player is currently facing as shown in this example mission!:

https://dl.dropbox.com/u/37698503/MTWwaypointTest.Shapur_BAF.zip

With modelToWorld the coordinates are [x,y,z] so

[0,+500,0] 500m front

[-500,0,0] 500m left

[0,0,+500] 500m above

[-500,+500,0] 500m front & 500m left

Do you have a script checker? eg Squint:

http://www.armaholic.com/page.php?id=11817

---------- Post added at 03:41 ---------- Previous post was at 02:47 ----------

Found another error:

wp1 = GroupMedical addwaypoint [(getPosATL Player select 0) + (500 * sin(180)), (getPosATL Player select 1) + (500 * cos(180)), 0];

Your position array isn't in an array - its missing the [], should be:

wp1 = GroupMedical addwaypoint [[color="#FF0000"][[/color](getPosATL Player select 0) + (500 * sin(180)), (getPosATL Player select 1) + (500 * cos(180))[color="#FF0000"]][/color], 0];

3D position format is [x,y,z] - you had x,y,z

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

Hey Mattar thanks for the help and yes I do have squint2 and spent hrs on the scripting command wiki page lol.

I can get the code to work only with one wayoint using [(player ModelToWorld [0,+500,0]), 0]; That you helped me with. I did see the COMMAND on the wiki but had no clue how to use it or to insert it into a script/codeline.

I am trying to use your codeline in multiple waypoints within my script like this-

if (!((player getVariable "MedicalsupportAvailable") == "MedicalSupportAvailable")) exitWith {hint "Medical Support not available at this time"};
player setVariable ["MedicalsupportAvailable", "MedicalsupportUNAvailable"]; 

armor4 = false;
publicVariable "armor4";
[] execVM "AISUPPORT\menu\close_menu.sqf";

player sideChat "Requesting Medical Support to our AO, Over";

sleep 2;

_pos = [[(getPosATL Player select 0) + (200 * sin(180)), (getPosATL Player select 1) + (200 * cos(180))], 0];
GroupMedical = CreateGroup West;

Med1 = createVehicle ["HMMWV_Avenger_DES_EP1", _pos, [], 0, "FORM"];
Med1c1 = GroupMedical createUnit ["US_Soldier_SL_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
Med1c1 moveInDriver Med1;
Med1c2 = GroupMedical createUnit ["US_Soldier_LAT_EP1", [0,0,2], [], 0, "CAN_COLLIDE"];
Med1c2 moveInGunner Med1;

//Med2 = createVehicle ["HMMWV_M998_crows_M2_DES_EP1", _pos, [], 0, "FORM"];
//Med2c1 = GroupMedical createUnit ["US_Soldier_Marksman_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
//Med2c1 moveInDriver Med2;
//Med2c2 = GroupMedical createUnit ["US_Soldier_MG_EP1", [0,0,2], [], 0, "CAN_COLLIDE"]; 
//Med2c2 moveInGunner Med2;
//Med2c3 = GroupMedical createUnit ["US_Soldier_LAT_EP1", [0,0,3], [], 0, "CAN_COLLIDE"];
//Med2c3 moveInCargo Med2;

//Med3 = createVehicle ["M1133_MEV_EP1", _pos, [], 0, "FORM"];
//Med3c1 = GroupMedical createUnit ["US_Soldier_Medic_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
//Med3c1 moveInDriver Med3;
//Med3c2 = GroupMedical createUnit ["US_Delta_Force_Medic_EP1", [0,0,2], [], 0, "CAN_COLLIDE"];
//Med3c2 moveInCargo Med3;
//Med3c3 = GroupMedical createUnit ["US_Soldier_Medic_EP1", [0,0,3], [], 0, "CAN_COLLIDE"];
//Med3c3 moveInCargo  Med3;
//Med3c4 = GroupMedical createUnit ["US_Delta_Force_Medic_EP1", [0,0,4], [], 0, "CAN_COLLIDE"];
//Med3c4 moveInCargo Med3;

//Med4 = createVehicle ["HMMWV_M998_crows_MK19_DES_EP1", _pos, [], 0, "FORM"];
//Med4c1 = GroupMedical createUnit ["US_Soldier_AA_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
//Med4c1 moveInDriver Med4;
//Med4c2 = GroupMedical createUnit ["US_Soldier_GL_EP1", [0,0,2], [], 0, "CAN_COLLIDE"];
//Med4c2 moveInGunner Med4;
//Med4c3 = GroupMedical createUnit ["US_Soldier_LAT_EP1", [0,0,3], [], 0, "CAN_COLLIDE"];
//Med4c3 moveInCargo Med4;

player sideChat "Medical Squad Dove: Roger that Medical personal are in route to the AO, Over";

sleep 1;

sleep 15;
hint "Medical Support Squad Dove will Establish a Mobile Mash Sector at this location"; 

//staging sector
wp1 = GroupMedical addwaypoint [position Player, 0]; 
wp1 waypointAttachVehicle vehicle player; 
wp1 setwaypointtype "MOVE"; 
wp1 setWaypointCombatMode "YELLOW"; 
wp1 setWaypointFormation "STAG COLUMN";
wp1 setWaypointSpeed "FULL"; 
wp1 setWaypointBehaviour "AWARE"; 
wp1 setWaypointCompletionRadius 10; 
wp1 setWaypointStatements ["true", "hint 'Medical Support Squad Dove will move up to Evac wounded units, OVER';"];
wp1 setWaypointTimeout [300,300,300];   


//Alpha waypoint
wp2 = GroupMedical addwaypoint [(player ModelToWorld [0,+500,0]), 0]; 
//wp2 waypointAttachVehicle vehicle player;  
wp2 setwaypointtype "MOVE"; 
wp2 setWaypointCombatMode "Yellow"; 
wp2 setWaypointFormation "STAG COLUMN"; 
wp2 setWaypointSpeed "FULL"; 
wp2 setWaypointBehaviour "AWARE"; 
wp2 setWaypointCompletionRadius 10;
wp2 setWaypointStatements ["true", "hint 'Medical Support Squad Dove Attempting to move towards front line to Evac wounded units';"];
wp2 setWaypointTimeout [300,300,300]; 


//Bravo waypoint
wp3 = GroupMedical addwaypoint [(player ModelToWorld [0,+1000,0]), 0]; 
//wp3 waypointAttachVehicle vehicle player; 
wp3 setwaypointtype "MOVE"; 
wp3 setWaypointCombatMode "YELLOW"; 
wp3 setWaypointFormation "VEE"; 
wp3 setWaypointSpeed "FULL"; 
wp3 setWaypointBehaviour "AWARE"; 
wp3 setWaypointCompletionRadius 10;
wp3 setWaypointStatements ["true", "hint 'New Mobile Mash Sector now Established';"];
wp3 setWaypointTimeout [300,300,300]; 


Charlie waypoint
wp4 = GroupMedical addwaypoint [position Player, 0];
//wp4 waypointAttachVehicle vehicle player; 
wp4 setwaypointtype "CYCLE"; 
wp4 setWaypointCombatMode "YELLOW"; 
wp4 setWaypointFormation "WEDGE"; 
wp4 setWaypointSpeed "FULL"; 
wp4 setWaypointBehaviour "AWARE"; 
wp4 setWaypointCompletionRadius 10;
wp4 setWaypointStatements ["true", "hint 'relocating mobile mash sector';"]; 
wp4 setWaypointTimeout [300,300,300]; 

armormed1 = createTrigger ["EmptyDetector",getPos player]; 
armormed1 setTriggerArea [500, 500, 0, false];
armormed1 setTriggerActivation ["EAST", "NOT PRESENT", false];
armormed1 setTriggerTimeout [900, 900, 900, false ];
armormed1 setTriggerStatements ["this", "Med4c1 sideChat ""Medical Platoon Dove: Returning to base to Evac wounded units, OVER""; GroupMedical execVM ""AISUPPORT\support-req\donearmor4.sqf""" , ""];

armormed2 = createTrigger ["EmptyDetector", getPos player]; 
armormed2 setTriggerArea [0, 0, 0, false];
armormed2 setTriggerActivation ["NONE", "NOT PRESENT", false];
armormed2 setTriggerStatements ["!(alive Med1c1) && !(alive Med1c2) && !(alive Med2c1) && !(alive Med2c2) && !(alive Med2c3) && !(alive Med3c1) && !(alive Med3c2) && !(alive Med3c3) && !(alive Med3c4) && !(alive Med4c1) && !(alive Med4c2) && !(alive Med4c3)","player sideChat ""INTELL REPORTS: Medical Support has been destroyed""; GroupMedical execVM ""AISUPPORT\support-req\donearmor4.sqf""" , ""];
sleep 1500; 
player setVariable ["MedicalsupportAvailable", "MedicalsupportAvailable"];
hint "Medical Support Units are resupplied and ready if needed!";

I know I have the // infornt of the other units to speed up the testing lol.

I don't know if you can use the [(player ModelToWorld [0,+500,0]), 0]; more the once I don't see why and I think it is based on the first location at the start of the script.

like always thanks for any input AVIBIRD.

---------- Post added at 18:37 ---------- Previous post was at 18:16 ----------

Hey Mattar FYI adding the extra [] inside the code makes the whole script not work!

---------- Post added at 18:55 ---------- Previous post was at 18:37 ----------

wp1,wp2 and wp3 all working like it should. If any one is looking for a good mobile MASH setup this littel script kicks ass The group will move up only 500 meters at a time and hold position until the next waypoint and then another 500 meters toward the frontlines. You could set the time and distance to what you want to meet your mission needs.

The one thing is I can't get the CYCLE waypoint to work while using the [(player ModelToWorld [0,+500,0]), 0]; code in the script! The script still works and is very fucntional but why can't the cycle waypoint work. I will never be happy with things lol.

Share this post


Link to post
Share on other sites

Ur missing // infront of Charlie Waypoint - wp4

FYI - _pos = [[(getPosATL Player select 0) + (200 * sin(180)), (getPosATL Player select 1) + (200 * cos(180))], 0];

will not work because you kept the positioning array from addWaypoint in there - should be:

_pos = [(getPosATL Player select 0) + (200 * sin(180)), (getPosATL Player select 1) + (200 * cos(180)),0];

I said you should add the sq bracks to the addwaypoint command. 3D position format: [x,y,z] correct above

in the addwaypoint correct formatis: [[x,y,z],radius]

You used BIS_fnc_spawnVehicle yet? Spawns a vehicle with crew - saves many lines of coding?

[position,direction,type,side or group] call BIS_fnc_spawnVehicle;

[_pos, 180, "HMMWV_Avenger_DES_EP1", WEST] call bis_fnc_spawnvehicle;
//or
[_pos, 90, "M1133_MEV_EP1", GroupMedical] call bis_fnc_spawnvehicle;

http://community.bistudio.com/wiki/Category:ArmA_2:_Functions

You need functions module on the map.

Arma2: Startup Parameters -showScriptErrors Introduced to show errors in scripts on-screen.

http://community.bistudio.com/wiki/Arma2:_Startup_Parameters#Developer_Options

Edited by Mattar_Tharkari

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  

×