Jump to content
Sign in to follow this  
avibird 1

Can you set the direction when using the [position player, #]; command

Recommended Posts

When using the command [position player, 1000]; were the 1000 is the meters away from the players location can you set the direction of the 1000 meters. Lets say north. As it is the direction can be any direction it is random west,east,south or north.

I have a script that the SL can call in Tank support but when the tank platoon gets to the SL position sometimes the tanks move away from the AO): going the wrong direction.

wp = GroupTankA addwaypoint [position player, 1000];

wp setwaypointtype "MOVE";

wp setWaypointSpeed "FULL";

---------- Post added at 05:47 ---------- Previous post was at 05:37 ----------

I have no clue if this can be used or have any clue how to use this command _degrees = getDir player. Any input would be great Thanks AVIBIRD

Share this post


Link to post
Share on other sites

No it's random - if you want a position 1000m north you have to generate it first:

_dir = 360;
_dist = 1000;
_ref = getPosATL player;
_pos = [(_ref select 0) + (_dist * sin(_dir)), (_ref select 1) + (_dist * cos(_dir)), 0];

 _wp2 = _group addWaypoint [_pos, 0, 2];
   [_group, 2] setWaypointType "MOVE";

_ref can be any marker,object or position eg, getMarkerPos "mkr"; getPosATL _vehicle; [0,0,0];

waypoint index is 2 in the above - adjust to whatever.

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

Hey that is awesome that it can be done if I post my script can you show me how to insert the code into my SQF to call the script. I need to go to work now but I will post it later if you can take a look thanks AVIBIRD

---------- Post added at 14:22 ---------- Previous post was at 14:13 ----------

Are you saying north is _dir=360 and south would be _dir=180 and west would be _dir=240 and east would be _dir=90

Share this post


Link to post
Share on other sites

Hey any help on getting this to work right in my script would be great. Here is the SQF

if (!((player getVariable "TsupportAvailable") == "TSupportAvailable")) exitWith {hint "Tank Platoon not available for Support"};
player setVariable ["TsupportAvailable", "TsupportUNAvailable"]; 

armor3 = false;
publicVariable "armor3";
[] exec "AISUPPORT\menu\close_menu.sqf";

player sideChat "HQ Requesting Tank Support, Over";

sleep 2;


GroupTank = CreateGroup West;

TK1 = createVehicle ["M1A2_US_TUSK_MG_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 550, "FORM"];
TKc1 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
TKc1 moveInDriver TK1;
TKc2 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,2], [], 0, "CAN_COLLIDE"];
TKc2 moveInGunner TK1;
TKc3 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,3], [], 0, "CAN_COLLIDE"];
TKc3 moveInCommander TK1;

TK2 = createVehicle ["M1A2_US_TUSK_MG_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 550, "FORM"];
TK2c1 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
TK2c1 moveInDriver TK2;
TK2c2 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,2], [], 0, "CAN_COLLIDE"];
TK2c2 moveInGunner TK2;
TK2c3 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,3], [], 0, "CAN_COLLIDE"];
TK2c3 moveInCommander TK2;

TK3 = createVehicle ["M1A2_US_TUSK_MG_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 550, "FORM"];
TK3c1 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
TK3c1 moveInDriver TK3;
TK3c2 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,2], [], 0, "CAN_COLLIDE"];
TK3c2 moveInGunner TK3;
TK3c3 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,3], [], 0, "CAN_COLLIDE"];
TK3c3 moveInCommander TK3;

TK4 = createVehicle ["M1A2_US_TUSK_MG_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 550, "FORM"];
TK4c1 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
TK4c1 moveInDriver TK4;
TK4c2 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,2], [], 0, "CAN_COLLIDE"];
TK4c2 moveInGunner TK4;
TK4c3 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,3], [], 0, "CAN_COLLIDE"];
TK4c3 moveInCommander TK4;

TK5 = createVehicle ["M1A2_US_TUSK_MG_EP1", [(getpos player) select 0,(getpos player) select 1,0], [], 750, "FORM"];
TK5c1 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,1], [], 0, "CAN_COLLIDE"];
TK5c1 moveInDriver TK5;
TK5c2 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,2], [], 0, "CAN_COLLIDE"];
TK5c2 moveInGunner TK5;
TK5c3 = GroupTank createUnit ["US_Soldier_Crew_EP1", [0,0,3], [], 0, "CAN_COLLIDE"];
TK5c3 moveInCommander TK5;

TK5c1 sideChat "Platoon Ostrich: Roger that Tank Support on route to your AO over";

sleep 1;

wp1 = GroupTank addwaypoint [position player, 0];
wp1 setwaypointtype "MOVE";
wp1 setWaypointSpeed "FULL";
wp1 setWaypointCompletionRadius 10;

wp2 = GroupTank addwaypoint [position player, 1000];
wp2 setwaypointtype "SAD";
wp2 setWaypointSpeed "FULL";
wp2 setWaypointCompletionRadius 500;

wp3 = GroupTank addwaypoint [position player, 0];
wp3 setwaypointtype "MOVE";
wp3 setWaypointSpeed "FULL";
wp3 setWaypointCompletionRadius 10;

wp4 = GroupTank addwaypoint [position player, 1000];
wp4 setwaypointtype "SAD";
wp4 setWaypointSpeed "FULL";
wp4 setWaypointCompletionRadius 500;

wp5 = GroupTank addwaypoint [position player, 0];
wp5 setwaypointtype "MOVE";
wp5 setWaypointSpeed "FULL";
wp5 setWaypointCompletionRadius 10;

wp5 = GroupTank addwaypoint [position player, 1000];
wp5 setwaypointtype "SAD";
wp5 setWaypointSpeed "FULL";
wp5 setWaypointCompletionRadius 500;

wp6 = GroupTank addwaypoint [position player, 0];
wp6 setwaypointtype "MOVE";
wp6 setWaypointSpeed "FULL";
wp6 setWaypointCompletionRadius 10;

wp7 = GroupTank addwaypoint [position player, 1000];
wp7 setwaypointtype "SAD";
wp7 setWaypointSpeed "FULL";
wp7 setWaypointCompletionRadius 5000;

wp8 = GroupTank addwaypoint [position player, 0];
wp8 setwaypointtype "MOVE";
wp8 setWaypointSpeed "FULL";
wp8 setWaypointCompletionRadius 10;

TankT1 = createTrigger ["EmptyDetector",getPos player]; 
TankT1 setTriggerArea [1000, 1000, 1000, false];
TankT1 setTriggerActivation ["EAST", "NOT PRESENT", false];
TankT1 setTriggerTimeout [900, 900, 900, false ];
TankT1 setTriggerStatements ["this", "TKc1 sideChat ""Tank Platoon Ostrich: Returning back to base to rearm, OVER""; GroupTank exec ""AISUPPORT\support-req\donearmor3.sqf""" , ""];

TankT2 = createTrigger ["EmptyDetector", getPos player]; 
TankT2 setTriggerArea [0, 0, 0, false];
TankT2 setTriggerActivation ["NONE", "NOT PRESENT", false];
TankT2 setTriggerStatements ["!(alive TKc1) && !(alive TKc2) && !(alive TKc3) && !(alive TK2c1) && !(alive TK2c2) && !(alive TK2c3) && !(alive TK3c1) && !(alive TK3c2) && !(alive TK3c3) && !(alive TK4c1) && !(alive TK4c2) && !(alive TK4c3) && !(alive TK5c1) && !(alive TK5c2) && !(alive TK5c3)","player sideChat ""HQ INTELL REPORTS: Tank Platoon has been destroyed""; GroupTank exec ""AISUPPORT\support-req\donearmor3.sqf""" , ""];
sleep 1800; 
player setVariable ["TsupportAvailable", "TsupportAvailable"];
hint "Tank Platoon rearmed and ready for support if needed!";

WP1 is the call in at players location

WP2 I would like to set for north position with SAD

WP3 back to player

WP4 set for east position with SAD

WP5 back to player

WP6 set for west position with SAD

WP7 back to player

WP8 set to south position with SAD.

at this point the tanks should get deleted and the script could be called in again after a set time to use in the mission.

Thanks AVIBIRD I only have a few more issues to fix before real beta test of this mission.

Share this post


Link to post
Share on other sites

Any input would help! can't get mattar's codeline to work. Help please! 3 days working on this makes you go nuts):

Share this post


Link to post
Share on other sites

You can condense much of that, tested and working:

waitUntil {!isNil "bis_fnc_init"};//you need a functions module on the map
_GroupTank = CreateGroup West;
//you need marker "tankspawn" on map with a 100m clear radius for the tanks to spawn:
{[[(getMarkerPos "tankspawn" select 0) + (random 50 * sin(random 360)), (getMarkerPos "tankspawn" select 1) + (random 50 * cos(random 360)), 0], 360, "M1A2_US_TUSK_MG_EP1", _GroupTank] call bis_fnc_spawnvehicle; sleep 0.5;} forEach [1,2,3,4,5,6,7];
{_x setDamage 0} forEach units _GroupTank;

_mkrlst = ["wp1mkr","wp2mkr","wp3mkr","wp4mkr","wp5mkr","wp6mkr","wp7mkr","wp8mkr"]; //place markers with these names on the map where you want the waypoints to be

{_wpt = _GroupTank addwaypoint [getMarkerPos _x, 0];
_wpt setwaypointtype "MOVE";
_wpt setWaypointSpeed "FULL";
_wpt setWaypointCompletionRadius 10;
} forEach _mkrlst;

//this moves and changes the type for waypoint 2, 1000m north of the player
[_GroupTank, 2] setWaypointPosition [[(getPosATL player select 0) + (1000 * sin(360)), (getPosATL player select 1) + (1000 * cos(360)), 0], 0];
[_GroupTank, 2] setWaypointType "SAD";

//They will spend a long time searching - if you need them to move on change the waypoint back to "move" when the task is completed.

//debug
_wPos = waypointPosition [_GroupTank, 2];
_mkr0 = createMarker["mkrtest",_wPos];
_mkr0 setMarkerShape "ICON";
_mkr0 setMarkerType "dot";
_mkr0 setMarkerColor "colorGreen";
_mkr0 setMarkerText "New WP2 location";

//To delete all the tanks and crews at WP8:
[_GroupTank, 8] setWaypointStatements ["true", "{deleteVehicle (vehicle _x)} foreach units (group this); {deletevehicle _x} foreach units (group this);"];

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

Thank you for your hard work but the script I am working on is for a dynamic battlefield! The two SL can call for support anywhere on the map. Markers will not work for the functionally of this script/mission.

In this misison you must liberate all towns/citys on the map OVER 30 one at a time as well as 5 random enemy HQ's with random enemy ground and air patrols around the whole map. blufor has the ability to relocate the main HQ and build two FOB's anywhere on the map. Both FOB's can be relocate. The two SL can call for multiple support units ie tanks, air and ground units to there locations if needed. All support units can be recalled after a set time during the mission. This mission can be played sole, coop 12 and player vs player 12 vs 3.

Right now some of the support units are using SAD waypoints but the issue is some times they move away from the combat. If I use the guard waypoint (which is great) but sometimes they will move across the map to engage other units and not the ones kicking my ass at the time. Do you see my issue now with the waypoints. The other issue is sometimes when I call the support the units get spawned on the map at different directions from my location and will cut trapped in the enemy territory. This is making me nuts. I am almost done with this mission but need to tire up some of details.

Share this post


Link to post
Share on other sites

Well it's just an example, you can build an array of positions, objects, vehicles, markers etc and set the waypoints however you like. If you set the waypoint to "SAD" they will in fact search and destroy - why not just have a "move" waypoint synchronised to a trigger switch - activation: opfor, not present? The commands are in the wiki to script all that to make it dynamic. Creating 8 waypoints all on the player's position is a little strange?

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

There must be a way to set the direction of a waypoint from the players location not using markers. This is not a complex equation but still way over my paygrade lol

Example#1 in this codeline Tank = createVehicle ["M1A2_TUSK_MG", [(getpos player) select 0,(getpos player) select 1,0], [], 1000, "FORM"];

* The 1000 is for the meters away from the players current location that the tank will spawn in the game world. Currently It could be north, south,east or west of the players location. How hard is it to set the

direction that the tank will spawn? There must be a basic way to do this!

Example#2 in this codeline wp1 = Tank1 addwaypoint [position player, 1000];

wp1 setwaypointtype "SAD";

wp1 setWaypointCompletionRadius 100;

* The 1000 is for the meters that the tank will move from the players current location to perfrom the waypoint SAD. Right now that movement is random it called be any direction from the players position. I think and feel that this is a real simple thing that could be done. If not could someone please tell more why!

@ Mattar I did not want to use 8 waypoints LOL but it was the only way I could get the tank platoon to SAD in all directions of the current AO in my mission effectively to give my player units good support during combat.

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

How would I insert this command _degrees = getDir player into the example#2

wp1 = Tank1 addwaypoint [position player, 1000];

wp1 setwaypointtype "SAD";

Wp1 setWaypointCompletionRadius 100;

_degrees =direction 0-360 lets say 360 would be north

how can I add so the 1000 meters would be north of the player. HELP!!!!!!!!!!

wp1 = GroupTank1 addwaypoint [position player, 1000]; [360 = getDir player];

wp1 setwaypointtype "SAD";

wp1 setWaypointCompletionRadius 100;

I get an error saying I CAN'T USE USE 360 AS A TARGET FOR AN ASSIGNMENT what the hell does this mean lol.

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

It's already answered:

_pos = [(getPosATL player select 0) + (1000 * sin(360)), (getPosATL player select 1) + (1000 * cos(360)), 0]; //position 1000m north of player
wp1 = Tank1 addwaypoint [_pos, 0];//place WP at the above position
wp1 setwaypointtype "SAD";
Wp1 setWaypointCompletionRadius 100;

Share this post


Link to post
Share on other sites
It's already answered:

_pos = [(getPosATL player select 0) + (1000 * sin(360)), (getPosATL player select 1) + (1000 * cos(360)), 0]; //position 1000m north of player
wp1 = Tank1 addwaypoint [_pos, 0];//place WP at the above position
wp1 setwaypointtype "SAD";
Wp1 setWaypointCompletionRadius 100;

I put this into my script but no luck the tanks just roll up to the player location and stop and just sit there. What the hell am I doing wrong. 95% of the time it's me lol.

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

Example mission you PMed me about AVI - might give you a few ideas:

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

The tankspawner.sqf can be used every time you want an armoured attack somewhere - just put the vehicles you want in the array in the middle.

The helicopter that tracks the armoured column for most of the mission is controlled by just 1 waypoint and these lines only:

while {true} do {
_tldr = leader _grp;
_posldr = getPosATL vehicle _tldr;
if (format ["%1", _posldr] != "[0,0,0]") then {
_hgtArr = [25,50,75,100];	
  h1 flyInHeight (_hgtArr select (floor (random 4)));
    [(group h1), 1] setWaypointPosition [_posldr, floor(random 50)];
      (group h1) setCurrentWaypoint [(group h1), 1];
sleep 20;
};

It's the true power of the loop.

-Marker system plus deletion to show you whats going on.

-Spawning loop for armour that spaces them correctly.

-3 possible endings

Lots of other controls and loops in there - hope you find something useful!

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  

×