Jump to content
Sign in to follow this  
Docattak

Can I addAction to command my group to go to a marker?

Recommended Posts

I am the player leader a group (grp1). I have a base with a marker (ResHQ).

I want to add an action (with text "Return to base") that will appear in my action list - when selected it will make all of my group return to the marker.

my player init code:

grp1 = group this; this addAction["Return to base","backtobase.sqf"];

backtobase.sqf code:

grp1 doMove (getMarkerPos "ResHQ");
hint "Return to base!";//used as check that code has got to here

also tried backtobase.sqf code:

_mywp = grp1 addWaypoint [getMarkerPos "ResHQ", 10];
_mywp setCurrentWaypoint [_mywp, 1];
_mywp setWaypointType "MOVE";
hint "Return to base!";//used as check that code has got to here

I get my "Return to base message" but the guys look at me as though I'm barmy and stand still!

Any suggestions gratefully received, whether t works just for the whole group or for the guys I select.

Share this post


Link to post
Share on other sites

{_x domove getmarkerpos "ResHQ"} foreach units grp1;

Share this post


Link to post
Share on other sites

Many thanks F2k Sel - works perfectly:)

Is there any way I can select some of my men in the usual way when commanding them and then give the order from the order menu and only the selected ones return to base?

It would seem that an 'if' statement inside the {} of the solution F2k Sel provided should do the trick but I don't know what the condition is for finding those members of the group which have been selected :)

Just tried this, but obviously if I select a member of the group I can't get the action to show without the selection of the member being cancelled. I need my added action to be showing in one of the normal menus and don't know how to do that! Currently my added action just shows on its own!

_selectedUnits = groupSelectedUnits player;
{_x domove getmarkerpos "ResHQ"} foreach units _selectedUnits; 
hint "Return to base!";

Edited by Docattak

Share this post


Link to post
Share on other sites

One easy way would just be delay the move for a few seconds to give you time to make a selection.

save as backtobase.sqf

hint "select units quickly"
sleep 4;
_selectedUnits = groupSelectedUnits player;
{_x domove getmarkerpos "ResHQ"} foreach _selectedUnits; 
hint "Returning to base!";

Or instead of an action use a radio call to run the script and you wouldn't need the addaction and delay.

The best way would be to use the custom menu system, it's been a while since I messed with that and as it no longer works in A3 I can't test until I fire up A2.

Share this post


Link to post
Share on other sites

if you do that, won't the units simply regroup when they have reached base?

Share this post


Link to post
Share on other sites

Thanks again F2k Sel - I've sorted out the custom menu techniques, adding to the normal menu system and standalone - unfortunately

_selectedUnits = groupSelectedUnits player;
{_x domove getmarkerpos "ResHQ"} foreach _selectedUnits; 

does not seem to work. I tested it in the original scenario (no custom menus etc.) . I then put it into a custom menu, the original code works but this doesn't. I've checked the syntax and all seems ok.

k0rd : that's the idea :) I want to be able to sent guys back to base with captured vehicles for example. Also to get them all at the base where they can change things (for the random developing story line) - but I want them to travel there from various places, sometimes leaving some guys behind etc.

Edited by Docattak

Share this post


Link to post
Share on other sites

I just modded up an old script and it works fine here, it was what I used to change units rank so references may look odd.

call using null=[] execvm "menu.sqf"

You may need function module and in game press 0,8,1 to get order list.

If no units selected they should be grey.

save menu.sqf

sleep 1;
[] call BIS_fnc_commsMenuCreate;

CUSTOM_menu = [
["New Orders",false],
["Orders",[2],"#USER:Rank_menu",-5,[["expression",""]],"1","1"]
];

_rank=[];
//Remove Promotions above the players rank.
// set up number of Orders 0-xx
for "_i" from  0 to 1 do {
// if (_rank_pl >= _i)  then {_rank = _rank+["1"]} else {_rank = _rank+["0"]} ;
_rank = _rank+["1"];

}; 

// "NotEmpty" = greyed out if no unit selected.

Rank_menu = [
["Orders",false],
["1 Move "+"resHQ",[],"",-5,[["expression","nul=[player,groupSelectedUnits player] execVM 'move.sqf'"]],_rank select 0,"NotEmpty"],
["2 Speed"+"Limited",[],"",-5,[["expression","nul=[player,groupSelectedUnits player] execVM 'speed.sqf'"]],_rank select 0,"NotEmpty"]
];


BIS_MENU_GroupCommunication = [
[localize "", false],["New Orders",[2],"#USER:Rank_menu",-5,[["expression",""]],"1","1"]
];

if (true) exitWith {hint "I'm out of here"};// remove hint (testing only).

save as move.sqf

_units = _this select 1;
{_x domove getmarkerpos "ResHQ"} foreach _Units; 
hint "Returning to base!";

save as speed.sqf

_units = _this select 1;
{_x setspeedMode "limited";} foreach _Units; 
hint "Roger That"; 

Edited by F2k Sel

Share this post


Link to post
Share on other sites

Thanks, that works perfectly. I was almost there except that I got the selectedgroup inside the move.sqf file (where you have _units = ...) - it didn't seem to get what it needed from that - this way the selectedgroup is passed as a parameter into move.sqf and all is well.

One more thing if you have the time F2k Sel :

My original aim was:

do a domove to "carparkHQ"

disembark (if in a vehicle, probably doesn't matter if it isn't)

do a domove to "ResHQ"

EDIT: Just got this sorted I think - but need to go out - will post solution later tonight!!!

Is this possible?

Thanks for your time, mate, very much appreciated.

Edited by Docattak

Share this post


Link to post
Share on other sites

Should be easy enough, I can't try it till later as a load of work has just turned up.

Share this post


Link to post
Share on other sites

This works fine except that if I am close they come and look for me lol - not time to sort that out until tomorrow. Good to watch them drive along in various vehicles, stop, get out, wait for each other and then run off to the Resistance HQ lol - all from one call!

hint "Returning to base!"; 
_units = _this select 1;
{_x domove getmarkerpos "SHA_Park"} foreach _units; 

_all_ready = false;

while {!_all_ready} do {
   _all_ready = true;
    {if ((alive _x)&&(!unitready _x)) then {_all_ready = false;};
   } foreach _units;
    sleep 1;    
};


hint "All Units Ready";

{commandGetOut _x} foreach _units;

sleep 3;

{_x domove getmarkerpos "ResHQ"} foreach _units; //needs a second alive check

Many thanks for all your help F2k Sel - as you may have guessed I'm a programmer who has just found Arma 2 (still using windows XP SP3 so can't use Arma 3 - also my love is WWII) - I'm from UK as well :)

Share this post


Link to post
Share on other sites

Cool glad you got it sorted. I still prefer A2/OA and XP myself.

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  

×