mattxr 9 Posted January 2, 2007 I used to know of one at OPEC but they have harldy any scripts there anymore so you know, turn to the guys who have everything I tried Unit1 DoFollow Unit2 but that just doesnt work Share this post Link to post Share on other sites
BadAss -Mapfact.net- 0 Posted January 2, 2007 What about doMove getPos? A very basic script could just look like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {(alive Unit1)&&(alive Unit2)}do { unit1 doMove getPos unit2; sleep 5; }; Share this post Link to post Share on other sites
mattxr 9 Posted January 4, 2007 @ Jan. 02 2007,15:06)]What about doMove getPos? A very basic script could just look like this:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {(alive Unit1)&&(alive Unit2)}do { unit1 doMove getPos unit2; sleep 5; }; hmm i get an error expect line 1 or something. Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted January 5, 2007 @ Jan. 02 2007,15:06)]What about doMove getPos? A very basic script could just look like this:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">while {(alive Unit1)&&(alive Unit2)}do { unit1 doMove getPos unit2; sleep 5; }; hmm i get an error expect line 1 or something. Are you using it in an sqf file via execVM? Also, given that in arma, while loops quit after 10,000 loops, that while loop needs to be nested or just done differently. Like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> while {(alive Unit1)&&(alive Unit2)}do { while {(alive Unit1)&&(alive Unit2)}do { unit1 doMove getPos unit2; sleep 5; }; }; Share this post Link to post Share on other sites
Cloughy 0 Posted January 15, 2007 Also, given that in arma, while loops quit after 10,000 loops, that while loop needs to be nested or just done differently. If it sleeps for 5 sec for every loop, wouldnt this be 5*10000 = 50000 secs which is over 13 hours??? Cheers GC Share this post Link to post Share on other sites
johnnyboy 3744 Posted January 15, 2007 The following is an OFP script authored by Toadlife. It may need some tweaks before it works in ARMA (I haven't tried it yet): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> requiredversion "1.85" ; This script will cause unit or group of units to follow another unit or group of units without joining ; any group ; Initialize this script with the string below: ; [[leaders],[followers],distance,degree,leeway,checkinterval,behaviour,position] exec "follow_toadlife.sqs" ; ; ** [leaders] = an array of units which will be followed, can be only one unit. Must be in array format! ; ** Example: [soldier1,soldier2,soldier3] ; ** [followers] = an array of units that will follow the leaders, can be only one unit. Must be in array format! ; ** Example: [man1,man2,man3] ; ** distance = Distance followers must stay from leaders ; ** degree = position relative to leaders followers will stay relative to the direction the leader is facing ; ** Example: 0 = directly in front of leader / 90 to the right of leader ; ** leeway = distance followers can be from their currently assigned position before they must move again ; ** checkinterval = how often the followers check their position releative to the leaders position ; ** behaviour = the behaviour of the followers ("careless", "safe", "aware", "combat", "stealth") ; ** position = position the followers will assume ("auto", "up", "down") ; _leaders = _this select 0 _followers = _this select 1 _dis = _this select 2 _degree = _this select 3 _leeway = _this select 4 _checkinterval = _this select 5 _behaviour = _this select 6 _position = _this select 7 "_x setbehaviour ""_behaviour""" foreach _followers "_x setunitpos ""_position""" foreach _followers goto "move" ~1 #check {if (!alive _x) then {_followers = _followers - [_x]}} foreach _followers {if (!alive _x) then {_leaders = _leaders - [_x]}} foreach _leaders ?count _followers == 0:exit ?count _leaders == 0:exit ?((_leaders select 0) distance (_followers select 0) > (_dis + _leeway)): goto "move" ?((_leaders select 0) distance (_followers select 0) < ((_dis + _leeway) * 0.5)): goto "move" ~_checkinterval goto "check" #move _lpos = getpos (_leaders select 0) _ldir = getdir (_leaders select 0) _lposx = _lpos select 0 _lposy = _lpos select 1 _moveto = [_lposx + ((sin (_ldir + (_this select 3))) * _dis), _lposy + ((cos (_ldir + (_this select 3))) * _dis), 0] "_x Move _moveto" foreach _followers ~4 goto "check" Good luck. If you have to tweak it to get it work, please post your solution for the rest of us! Share this post Link to post Share on other sites
hoz 0 Posted January 15, 2007 I wrote an ArmA one, the unit never gets closer then a few meters other wise you get this merging effect with units if the leader stops for a min. dofollowunit.sqf <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> // Do Follow other Unit example - Hoz 01/02/07 // Usage: dummy = [Follower,Leader] execVM DoFollowUnit.sqf _Follower = _this select 0; _Leader = _this select 1; while {(alive _Follower)&&(alive _Leader)}do { if ((_Follower distance _Leader) < 5) then { sleep 5; } else { _Follower domove [(getpos _Leader select 0) + (5*sin(getdir _Leader - 180)), (getpos _Leader select 1) + (5*cos(getdir _Leader - 180))]; sleep 2.5; } }; hope it helps. Hoz Share this post Link to post Share on other sites
snkman 351 Posted January 15, 2007 @hoz i can't get your script to work... I always get the message missing "[" P.s. i think its: Leader not Leaver <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// Usage: dummy = [Follower,Leaver] execVM and name of the skript should be DoFollowUnit.sqf not dofollowunit.sqf But anyway it dosn't work... Share this post Link to post Share on other sites
hoz 0 Posted January 15, 2007 This should work, only way I can see how you would get that error is if you mistyped the dummy = [Follower,Leader] execVM "dofollowunit.sqf" When do you get the error? Where are you placing this line? As a test I would just put it in a radio trigger and execute it manually Leader, Leaver same thing, I updated the typo in my script. thanks Share this post Link to post Share on other sites
snkman 351 Posted January 15, 2007 Well i can't go to the Game after i wrote this: dummy = [Follower,Leader] execVM "dofollowunit.sqf" in the init the error appers in the Editor. Okay now i tryed to put it in a Trigger init as Radio Alpha: Init of the Trigger: dummy = [Follower,Leader] execVM "dofollowunit.sqf" Now the error again: Missing [ The error message tells me it should look like this: [Follower,Leader[] but thats defenetly wrong... Well i have no clue im not good in Scripting... Share this post Link to post Share on other sites
hoz 0 Posted January 16, 2007 This would go in the onactivation part of the trigger. I'm going to test it in a sec, but I'm almost positive it works. Share this post Link to post Share on other sites
rithrin 10 Posted September 8, 2009 i have been tring to use this script by puting ( [this] exec "movep1.sqs"; ) in the ai's init line then in the sqs its self ive got ( while {alive _this} do { _this doMove getPos p1; sleep 2; }; but for some reson the ai only go'se to where i was standing then dosent move anymore can someone help me Share this post Link to post Share on other sites