Home   Help Search Login Register  

Author Topic: Formation Test  (Read 1144 times)

0 Members and 1 Guest are viewing this topic.

Offline Vorster

  • Members
  • *
Formation Test
« on: 13 Jan 2008, 09:36:58 »
Gentleman,

I need your help. I am not realy a noob to programming doing alot in C++ and VBA but the boolean structure used in the sqs baffles me. At present I am trying to do a script to call up a firebelt from a troop (platoon for the for the rest of the world) of tanks on a map position. For the tactic to work all tanks need to assume a line position. This were I have my problem the script has to wait until all unit are in line formation. My text is as follows

Quote

unit setformation "line";
unit setformdir _tar;

WaitUntil {(unit Formation "line")};


But "line" isn't a boolean function. How does the the function know if the line must be true or false and how do you code a function to accept only a true condition without using ==. Any suggestions.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Formation Test
« Reply #1 on: 13 Jan 2008, 10:35:12 »
try waiting until all the tanks are ready.
Code: [Select]
unit setformation "line";
unit setformdir _tar;
Sleep 2;
WaitUntil { ({unitReady _x} count _list_of_tanks) == (count _list_of_tanks)};

Offline Vorster

  • Members
  • *
Re: Formation Test
« Reply #2 on: 20 Jan 2008, 10:29:42 »
Thanks will try it

I have a second question. I want to do a test to see that each vehicle in the group does have ammo to enable it to fire. The code I have come up with

Quote

?((({_x ammo "20Rnd_120mmHE_M1A2"} foreach units unit)!=0)&&(({_x ammo "20Rnd_120mmSABOT_M1A2"} foreach units unit)!=0)&&(({_x ammo "1200Rnd_762x51_M240"} foreach units unit)!=0))): _b = 0;



doesn't work to well. Any ideas? All I want it to do is just stop the script if the one or more of the tanks are out of ammo in the group. Tanks are assigned to the group by

Quote

Groupname = _this group


in the editor and then to unit in the script.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Formation Test
« Reply #3 on: 20 Jan 2008, 10:40:04 »
ammo command uses weaponname, not magazine name.

ammo weaponmame returns the number of rounds left in the current magazine loaded in weaponname.

If you want to check how many magazines are left, then use magazines command.

Offline Loyalguard

  • Former Staff
  • ****
Re: Formation Test
« Reply #4 on: 20 Jan 2008, 14:54:14 »
In addition to mandoble's suggestion, also try changing your grouping syntax to:

Code: [Select]
Groupname = group this;
I also think you only need to do this for the leader, not all the units.

Offline Vorster

  • Members
  • *
Re: Formation Test
« Reply #5 on: 21 Jan 2008, 04:56:50 »
Sweet thanks. The whole group thing is causing more hassles than any thing else. The functions are either for arrays or an object which makes programming for a group difficult. I might have to redo the script for a bunch of objects.