Jump to content
Sign in to follow this  
avibird 1

Using the waypointAttachVehicle command can you make the units stay 25 meters away!

Recommended Posts

I am using the waypointAttachVehicle command for a combat support script that I am working on. Is there a way you make the units stay 25 meters away from the player.

This is how I am using it

//staging sector

wp1 = GroupMechanized addwaypoint [position Player, 25]; this waypoint is needed to work but the units will move right next to the player at 0 meters away

wp1 waypointAttachVehicle vehicle player; I have attempted multiple changes of this code line to get it to work and stay 25 meters away from the player

wp1 setwaypointtype "MOVE";

wp1 setWaypointCombatMode "RED";

wp1 setWaypointFormation "WEDGE";

wp1 setWaypointSpeed "FULL";

wp1 setWaypointBehaviour "AWARE";

wp1 setWaypointStatements ["true", "hint 'Cardinal1';"];

wp1 setWaypointTimeout [60,60,60];

wp2 ect

the last waypoint uses the cycle so the units will follow the player around the whole mission if still alive.

Share this post


Link to post
Share on other sites

Try using this in a looping trigger...

GroupMechanizedLDR = leader GroupMechanized; GroupMechanizedLDR move (player modelToWorld [0,-25,0]); GroupMechanized setFormation "WEDGE"; GroupMechanized setCombatMode "RED"; GroupMechanized setSpeedMode "FULL"; GroupMechanized setBehaviour "AWARE"

ProfTournesol helpfully explains how to get a trigger to loop here...

http://forums.bistudio.com/showthread.php?94768-Time-lapse-script-trigger(need-looping-trigger)

Try not to go too fast when you are leading a group like this, full speed movement will cause them to lag behind a little.

Share this post


Link to post
Share on other sites

or..., maybe you want to try this,

no waypoint needed, you can set many group following your group (Leader),

just remember to set the distance differently for each group.

put something like this on init.sqf or on trigger act or on any external script, (Not in unit init field),

and should use 'groupname', Not 'group unitname':

null = [FrontGroupName, FollowerGroupName1, 25] execVM "flower.sqf";

null = [FrontGroupName, FollowerGroupName2, 50] execVM "flower.sqf";

null = [FrontGroupName, FollowerGroupName3, 75] execVM "flower.sqf";

etc...

my example script:

flower.sqf

//null = [FrontGroupName, FollowerGroupName, 25] execVM "flower.sqf";
_grp1 = _this select 0;
_grp2 = _this select 1;
_dist = _this select 2;

while {({alive _x} count units _grp2) != 0} do
{
while {_dist < leader _grp1 distance leader _grp2 and "MOVE" != currentCommand leader _grp2} do {
if (10 > getpos leader _grp1 select 2) then {_grp2 move getposatl leader _grp1};
//hint "follow";
};
while {_dist > leader _grp1 distance leader _grp2 and "MOVE" == currentCommand leader _grp2} do {
_grp2 move getposatl leader _grp2;
//hint "hold";
sleep (_dist *0.1);
waituntil {0 != speed vehicle (leader _grp1)};
};
};

This is a simple demo mission using flower.sqf.

Edited by Morieza

Share this post


Link to post
Share on other sites

@ james Mckenzie-smith

In my combat support script I am already using the player modelToWorld command

hint "US Army Platoon Stork will Establish a Service Point Sector at your Current Location Sir";

//staging sector

wp1 = GroupSupport addwaypoint [position Player, 0];

wp1 waypointAttachVehicle vehicle player;

wp1 setwaypointtype "MOVE";

wp1 setWaypointCombatMode "RED";

wp1 setWaypointFormation "WEDGE";

wp1 setWaypointSpeed "FULL";

wp1 setWaypointBehaviour "AWARE";

wp1 setWaypointCompletionRadius 10;

wp1 setWaypointStatements ["true", "hint 'US Army Logistic Platoon Stork to Relocating Service Point Sector within the AO, Over';"];

wp1 setWaypointTimeout [600,600,600];

//Alpha waypoint going west

wp2 = GroupSupport addwaypoint [(player ModelToWorld [0,+600,0]), 0];

//wp2 waypointAttachVehicle vehicle player;

wp2 setwaypointtype "MOVE";

wp2 setWaypointCombatMode "RED";

wp2 setWaypointFormation "WEDGE";

wp2 setWaypointSpeed "FULL";

wp2 setWaypointBehaviour "AWARE";

wp2 setWaypointCompletionRadius 10;

wp2 setWaypointStatements ["true", "hint 'US Army Logistic Platoon Stork moving Service Point Sector within the AO, Over';"];

wp2 setWaypointTimeout [600,600,600];

how it works is that the new units that spawn will move to the players current location and wait for 10 minutes then using the player modelToWorld command the group will move 600 meters towards the north of the first location the player called the group not the current location of the player. To get the group to follow the player all over the mission you need to use the waypointAttachVehicle command. It works for infantry but for armor units it can get a little messed up when the armor units run over your AT and medic units lol. I was hoping for a away to use the waypointAttachVehicle to keep the units somewhat away!

FYI the waypointAttachVehicle; vehicle player will not work without the GroupSupport addwaypoint [position Player, 0];

PS. You were working on a HC script mission a while back did you ever get it to work right and do you have a update script for it.

---------- Post added at 23:56 ---------- Previous post was at 23:40 ----------

@ morieza

What happens to the group when the Human player dies and gets respawned back into the game? does the script stop or does the group just starts following the player again.

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites
@ morieza

What happens to the group when the Human player dies and gets respawned back into the game? does the script stop or does the group just starts following the player again.

Script updated, see post #3,

now, they start following the player again after respawn (player must moving a bit for triggering their distance check),

script will stop only if the current follower group have no 'alive' unit.

Edited by Morieza

Share this post


Link to post
Share on other sites
or..., maybe you want to try this,

no waypoint needed, you can set many group following your group (Leader),

just remember to set the distance differently for each group.

put something like this on init.sqf or on trigger act or on any external script, (Not in unit init field),

and should use 'groupname', Not 'group unitname':

null = [FrontGroupName, FollowerGroupName1, 25] execVM "flower.sqf";

null = [FrontGroupName, FollowerGroupName2, 50] execVM "flower.sqf";

null = [FrontGroupName, FollowerGroupName3, 75] execVM "flower.sqf";

etc...

my example script:

flower.sqf

//null = [FrontGroupName, FollowerGroupName, 25] execVM "flower.sqf";
_grp1 = _this select 0;
_grp2 = _this select 1;
_dist = _this select 2;

while {({alive _x} count units _grp2) != 0} do
{
while {_dist < leader _grp1 distance leader _grp2 and "MOVE" != currentCommand leader _grp2} do {
if (10 > getpos leader _grp1 select 2) then {_grp2 move getposatl leader _grp1};
//hint "follow";
};
while {_dist > leader _grp1 distance leader _grp2 and "MOVE" == currentCommand leader _grp2} do {
_grp2 move getposatl leader _grp2;
//hint "hold";
sleep (_dist *0.1);
waituntil {0 != speed vehicle (leader _grp1)};
};
};

Hey morieza I am a little lost! The playable units that can call my combat support script are editor placed units with no group name only a unit name. I don't understand what you mean by FrontGroupName. The groups that are spawn in by SQF have group names that I put into the FollowerGroupName1.

I have attempted multiple times but no luck. If you have a very simple example mission that you can post I would greatly appreciated. My way works perfect for infantry units but you way sounds really good for my armor support units.

Share this post


Link to post
Share on other sites

did you create a group name to that playable unit (editor placed units) ?..., if yes, did you use that 'group name' ?

I mean, did you create this ?,

in unit (leader) init field:

groupname = group this;

A simple demo mission has been added in post #3.

Edited by Morieza

Share this post


Link to post
Share on other sites

first thank you for the demo simple.

No I need to change the two field commanders groupname = group this;

The units I want to call in are not from the editor they come from a menu that only the two commanders can use.

I am having some issues calling in the groups from my SQF's maybe I added your code wrong into my multiple SQF (support groups).

The way I have it now is that the two commanders can pick any of the 40 different support groups from multiple menus however I think with your code only one playable unit from the editor can have the groups follow them. I Think with you code I would need to pick which groups can follow the US commander and which ones can follow the BAF commanders. Tell me if I am wrong on this

I would love to use your code for my armor groups because with my way when you have a few groups next to your location and a armor group moves up you can get a some friendly units killed lol.

Share this post


Link to post
Share on other sites
I am having some issues calling in the groups from my SQF's maybe I added your code wrong into my multiple SQF (support groups).

Can you post your current SQF's ?,

maybe someone could give more help,

or maybe someone could tweak/optimize/expand that flower.sqf,

(TBH this is my second time ever creating a script in SQF format, I'm new in scripting, so SQS is my preference XD.)

...umm, about create a group name,

if it's not possible to create a group name in unit init field (groupname = group this),

you can also create/define a group name on somewhere else,

(sorry if you already know...)

example, creating a group name in init.sqf or on trigger act or on another script:

groupname = group UnitLeaderName;

or

groupname = group player;

btw, the script can also be use for AI group follow AI group.

example:

null = [westgroup1, AIinfantry1, 20] execvm "flower.sqf";

null = [westgroup1, AIinfantry2, 20] execvm "flower.sqf";

null = [AIinfantry1, AIinfantry2, 20] execvm "flower.sqf";

null = [AIinfantry1, AIinfantry3, 20] execvm "flower.sqf";

null = [AIinfantry2, AIinfantry4, 20] execvm "flower.sqf";

null = [AIinfantry2, AIinfantry5, 20] execvm "flower.sqf";

or

null = [westgroup1, AIgroupAAinfantry, 20] execvm "flower.sqf";

null = [AIgroupAAinfantry, AIgroupTANK, 50] execvm "flower.sqf";

etc.

Edited by Morieza

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  

×