Jump to content

Recommended Posts

     {deleteVehicle _x} forEach (units _Ga3);    // WORKS but only for alive units  :(

Share this post


Link to post
Share on other sites
_RBapc = ["B_APC_wheeled_01_cannon_F","B_engineer_F", "B_medic_F", "B_soldier_AT_F","B_soldier_M_F","B_ghillie_sard_F","B_soldier_AA_F","B_soldier_AR_F","B_soldier_GL_F"];
_RBtank = ["B_MBT_01_TUSK_F","B_engineer_F", "B_medic_F", "B_soldier_AT_F","B_soldier_M_F","B_soldier_AA_F","B_soldier_GL_F" ];  
_RBaaa = ["B_APC_tracked_01_AA_F"];   
_RBcar = ["B_MRAP_01_hmg_F","B_MRAP_01_gmg_F"];  
 
_RBconvoy = selectRandom [_RBapc, _RBtank, _RBaaa, _RBcar] append selectRandom [_RBapc, _RBtank, _RBaaa, _RBcar];

_pos = (getPos Bres1) set [2, 0];

// get unique reative positions in a circle of 20 m around Bres1 (no more random explosions)
_angle_diff = 360 / count _RBconvoy;
_cur_angle = random 360;

_relativePositions = [];
{
 _relativePositions pushBack (_pos getPos[20, _cur_angle]);
 _cur_angle = _cur_angle + _angle_diff;
 true
} count _RBconvoy;

// spawn convoy
_Ga3 = [_pos,WEST,_RBconvoy ,_relativePositions] call BIS_fnc_spawnGroup;

//get all unit and vecs of convoy
_all_men = [];
_all_vec = [];

{
 _all_men pushBackUnique _x;
 
 _vec = objectParent _x;
 if(!isNull _vec) then
 {
  _all_vec pushBackUnique _vec;
  {
   _all_men pushBackUnique _x;
   true
  } count crew vec;
 };
 true
}count units _Ga3;

//get all empty cargo seats of convoy
_all_empty_seats = _all_vec apply 
{
 fullCrew [_x, "cargo", true] params ["_unit", "_role", "_cindex"];
 [_x, _unit, _cindex]
}) select {isNull (_x select 1)};

//move all men in all empty cargo seats
_num_men = count _all_men;

{
 if (_forEachIndex isEqualTo _num_men) exitWith {}; // end loop if all men borded already

 (_all_men select _forEachIndex) moveInCargo [_x select 0, _x select 2];

} forEach _all_empty_seats;



/// DO WHAT EVER U WANT HERE



//Delete all vecs and men of convoy
 {deleteVehicle _x;} count _all_men;
 {deleteVehicle _x;} count _all_vec;

 

Edited by sarogahtyp
corrected something

Share this post


Link to post
Share on other sites

ok this seems to work:

 

  Reveal hidden contents


EDIT:
Sarogahtyp..you beated me again on time ! thanks man for your help ! i really appreciate !

Share this post


Link to post
Share on other sites

i did not beat u. I scripted a complete other (I bet faster) way to do all those things...

I also bet that u get some random explosions sometimes with ur current script. also it uses too long arrays. As I can't test here so I'm just guessing but I think what I posted in my last post should have faster methods and no explosions because of 2 positions are too close together sometimes (thats what can happen with ur current script).

 

but in it's current state my script could have errors and bugs because it's untested.

Edited by sarogahtyp

Share this post


Link to post
Share on other sites

ahh ! good info !! thanks man, i'm going to test it intensively !!
thanks for your tips !
 

Share this post


Link to post
Share on other sites

ok guys....back to the original script (LOL) !
(the one about create a vehicle, that if destroyed get re-created ecc..)

 

  Reveal hidden contents

...ok ..well...right now its works, but i wish to update a bit the "rescue" part.
wish to make crew automatically join same side player that goes to less than 10 meters from crew.
...and make it automatically joins as captive (weapons removed) if a player ofenemy faction approach him from less than 10 meters!
is a plausible thing to do, and more important will be performance friendly ?
thanks for any help ! (i'm still burning my head to find a solution!)

Share this post


Link to post
Share on other sites

i've menaged to put togheter this:
 

{
  if ((side _x) == independent) then
  {
      if (_x distance2D crew1 < 10) then
      {
         [crew1] join _x;
      };
  };
} forEach allUnits;

seems to do its work...now i must elaborate a logic and a script to support the whole idea!

Share this post


Link to post
Share on other sites

"big" progress (well.... for me....)

 

  Reveal hidden contents

this makes so that when a player gets near to crew1 (will be replaced once merged into original script) it will discriminate the situation by side A and side B.
i dont know how terminate this anyway after 10 minutes!

Share this post


Link to post
Share on other sites
  On 7/21/2017 at 1:02 PM, sarogahtyp said:

i did not beat u. I scripted a complete other (I bet faster) way to do all those things...

I also bet that u get some random explosions sometimes with ur current script. also it uses too long arrays. As I can't test here so I'm just guessing but I think what I posted in my last post should have faster methods and no explosions because of 2 positions are too close together sometimes (thats what can happen with ur current script).

 

but in it's current state my script could have errors and bugs because it's untested.

 

No that doesn't happen. I tested spawning 3 ,even 4 patrols at the same point, using a repeatable radio A.   The reason is in my use of BIS_fnc_spawnGroup. (Last script, see all params).

You did a good job with your version. Not tested but a different approach is always interesting.
Good luck for endless inputs, making all scripts as mash!

Share this post


Link to post
Share on other sites

GOOD NEWS! i think i made it!!
 


_timeOver = diag_tickTime +5;
waitUntil {sleep 10;{_x distance crew1 < 10} count allPlayers > 0 || diag_tickTime >= _timeOver};
{
  if ((side _x) == independent) then
  {
      if (_x distance2D crew1 < 10) then {[crew1] join _x};
  };
} forEach allplayers;

{
  if ((side _x) == west) then
  {
      if (_x distance2D crew1 < 10) then {[crew1] join _x};
  };
} forEach allplayers;
if (diag_tickTime >= _timeOver) then {hint "time over"};

yeeeah!

Share this post


Link to post
Share on other sites

.....i seriously melted my brain.....
.....anyway i made it! here is the code, for the people of tomorrow:
 

  Reveal hidden contents

YEAH!

EDITED

Share this post


Link to post
Share on other sites

haha i was too optimist....seems that if the starting crew its less than 4 people, it throws an error...
need some way to adapt it to 1 to 4 crew, or (evil way) kill crew in excess, so there is always only 1 to save.
really need help on this...i already did all that came to my mind!

EDIT:
i'm in the situation where i need two different  _x in same sentence....  kind of :
 { if (_x distance2D _x < 10) then [MYCODE]} forEach _crewDveh;
(where first _x its about allplayers and second _x its about _crewDveh

Share this post


Link to post
Share on other sites

...its a ridicolous brutal approach....i really need help optimizing this....

 

  Reveal hidden contents

thanks !

EDITED: fixed a typo error

Share this post


Link to post
Share on other sites

i've a problem with a simple condition (right now it activates also if crew to rescue is dead, and i dont want to):

 

 waitUntil {sleep 10;({alive _x} count _crewDveh) > 0;{_x distance _DCrew < 9} count allPlayers > 0 || diag_tickTime >= _timeOver};

i wish condition be like this:
WAITUNTIL (check condition every 10 seconds; there is at least 1 alive crew; the distance between crew and a player is <9);   OR     timer is over;

Share this post


Link to post
Share on other sites

......menaged to get it work with:

waitUntil {sleep 10;(({alive _x} count _crewDveh) > 0 && ({_x distance _DCrew < 9} count allPlayers) > 0) || diag_tickTime >= _timeOver};


BUT.....i need to use others conditions, like this:
 

waitUntil {sleep 10;(({alive _x} count _crewDveh > 0) && (({_x distance _DCrew < 9} count allPlayers) > 0 &&  ({_x distance _DCrew2 < 9} count allPlayers) > 0))) || diag_tickTime >= _timeOver};

pleasee....help me !

Share this post


Link to post
Share on other sites

// SSSSSSPPLAAAATTT !!! (_brain exploded);

 

  Reveal hidden contents

i cant belive this...but seems to work!

Share this post


Link to post
Share on other sites

...added variables to be able to clone the script for more vehicles!

 

  Reveal hidden contents

 

Share this post


Link to post
Share on other sites

hello guys!

was streamlining a bit this really ugly script....i've encountered the major problem here:
 

if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {...my code bla bla bla...

the problem is that there can be 1 to 4 crew members (_Dcrew, _Dcrew2 _Dcrew3, _Dcrew4), and i wish that any player (_x) who get at a distance of 10 meters from any crew member can capture the whole crew group.
i somehow need to use the _x variable two times for different subjects (dont seem to exist an _y variable, right ?) or ....really dunno how do this whitout repeat code, but i'm sure there is a way!
just point me in the right direction please!
thanks!

Share this post


Link to post
Share on other sites
  On 7/29/2017 at 7:40 AM, dlegion said:

hello guys!

was streamlining a bit this really ugly script....i've encountered the major problem here:
 

if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {...my code bla bla bla...

the problem is that there can be 1 to 4 crew members (_Dcrew, _Dcrew2 _Dcrew3, _Dcrew4), and i wish that any player (_x) who get at a distance of 10 meters from any crew member can capture the whole crew group.
i somehow need to use the _x variable two times for different subjects (dont seem to exist an _y variable, right ?) or ....really dunno how do this whitout repeat code, but i'm sure there is a way!
just point me in the right direction please!
thanks!

 

_unit = player or whatever;
if ({_unit distance2D _x < 10} count [_DCrew1,_DCrew2,DCrew3] >= 1) then {hint "success!"};

Cheers

Share this post


Link to post
Share on other sites

...i feel that stupid when solution was so simple!
really thanks man !!

Share this post


Link to post
Share on other sites

i'm melting by tring to make this work. re-readed BIKI on all commands being used, but there is something escaping from my sight.
now error is "4 elements provided, 3 expected", but i suppose thats not the point...
 

_crewDveh = crew _Dveh;          // i already defined an array with crew members 

 waitUntil {sleep 10;(({alive _x} count _crewDveh) > 0 && ({_crewDveh distance2D _x < 10} count allPlayers) >= 1) || diag_tickTime >= _timeOver};

the goal is to waitUntil  ANY alive player gets near (less than 10 meters) to ANY of the still alive crew members.
i'm really sorry but i cant get out of this one :(
thanks!

Share this post


Link to post
Share on other sites

crewDveh is an array of objects...

can distance2D be used with such an array?

Share this post


Link to post
Share on other sites

...distance (and distance2d) accept arrays, or i misunderstood it ?

 

waituntil {allplayers distance _crewDveh};

i'm trying this right now....

Share this post


Link to post
Share on other sites

sorry but i've no idea what that mean man!
 

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

×