zulu1 145 Posted June 1, 2014 (edited) This seems like it should rather simple, but I'm stumped. I'm sure it's a little syntax problem. I have two units a3 & a4 who need to place two mines each on markers mine1, 2, 3 and 4. This worked fine when I just had a delay between each line. I wanted some more precise so I introduced a distance condition of the unit to each marker where the mines are to be placed. Can anyone see where I went wrong? I've tried dozens of variations, most give errors, this does not. The units go to the last marker without placing any mines. a3 domove (getMarkerpos "mine1") ?(a3 distance mine1) < 0.01 : goto lay1 ~5 a4 domove (getMarkerpos "mine3") ?(a4 distance mine3) < 0.01 : goto lay2 ~5 #mine3 a3 domove (getMarkerpos "mine2") ?(a3 distance mine2) < 0.01 : goto lay3 ~5 #mine4 a4 domove (getMarkerpos "mine4") ?(a4 distance mine4) < 0.01 : goto lay4 #lay1 a3 fire ["put","mine"] : goto mine3 #lay2 a4 fire ["put","mine"] : goto mine4 #lay3 a3 fire ["put","mine"] #lay4 a4 fire ["put","mine"] Edited June 1, 2014 by Zulu1 Share this post Link to post Share on other sites
-rageQuit- 10 Posted June 1, 2014 (edited) Don't you mean to use @ (wait until condition is true) instead of ? (if) - which won't become true since you don't give them time to move to the position and lay mines. And now you've edited what you had, so I'll have to think again. Added, making it up as I go along ---> [ <unitname>, <first mine pos.>, <second mine pos.> ] exec "place_two_mines.sqs" _unit = _this select 0_1stmine = _this select 1 _2ndmine = _this select 2 _unit doMove getMarkerPos "_1stmine" @_unit distance getMarkerPos "_1stmine" < 0.2 _unit fire ["Put", "Mine"] ~6 _unit doMove getMarkerPos "_2ndmine" @_unit distance getMarkerPos "_2ndmine" < 0.2 _unit fire ["Put", "Mine"] Edited June 1, 2014 by -rageQuit- Share this post Link to post Share on other sites
zulu1 145 Posted June 1, 2014 (edited) @rage, I appreciate the effort, but did you try this? I get distance error type object expected array (or something like that) and the units complain "Can't get there" I ran it from a radio alpha trigger with this initl line: [a3, mine1, mine3] exec "placemines.sqs"; [a4, mine2, mine4] exec "placemines.sqs" I got this to work somewhat but I think the conditions are ignored. a3 domove (getMarkerpos "mine1") ~5 ?(a3 distance mine1) < 0.01 ~2 a3 fire ["put","mine"] a4 domove (getMarkerpos "mine3") ~5 ?(a4 distance mine3) < 0.01 ~2 a4 fire ["put","mine"] a3 domove (getMarkerpos "mine2") ~5 ?(a3 distance mine2) < 0.01 ~2 a3 fire ["put","mine"] a4 domove (getMarkerpos "mine4") ~5 ?(a4 distance mine4) < 0.01 ~2 a4 fire ["put","mine"] edit: Just a thought...Can you do distance from a marker, or does it have to be an object? Edited June 1, 2014 by Zulu1 Share this post Link to post Share on other sites
-rageQuit- 10 Posted June 1, 2014 Tested the following just now (apparently distance doesn't like arrays or markers) [ <unitname>, "<first mine pos.>", "<second mine pos.>" ] exec "place_two_mines.sqs" (NB. Quotation marks around mine positions are important as they make it into strings). _unit = _this select 0 _1stmine = _this select 1 _2ndmine = _this select 2 _unit doMove getMarkerPos _1stmine @ (((getPos _unit select 0) - (getMarkerPos _1stmine select 0)) ^ 2) + (((getPos _unit select 1) - (getMarkerPos _1stmine select 1)) ^ 2) < 0.5 _unit fire ["Put", "Mine"] ~4 _unit doMove getMarkerPos _2ndmine @ (((getPos _unit select 0) - (getMarkerPos _2ndmine select 0)) ^ 2) + (((getPos _unit select 1) - (getMarkerPos _2ndmine select 1)) ^ 2) < 0.5 _unit fire ["Put", "Mine"] exit Share this post Link to post Share on other sites
kenoxite 156 Posted June 1, 2014 @zulu1 Just a quick reply. Your latest concern was valid. Distance can only be used between objects. Only in later Armas does it work with arrays. Replace the markers with logics and group them (so you can have up to 12 mines/logics while not bloating OFP's inner group count) and name them "mine#". That should do the trick. Alternatively, search for distancepos.sqf function by snypir in OFPEC once it's up again and use that to look for distances between positions. WTH, here it is. Formatted to be used inside addons, but it's basically the same: comment{ /*--------------------------------------------------------------- distancePos function -=- by snYpir Returns the distance between two x,y positions Called with: [[<x pos 1>,<y pos 1>],[<x pos 2>,<y pos 2>]] call distancePos ---------------------------------------------------------------*/ }; comment{ declare private variables}; private ["_x1","_y1","_x2","_y2"]; comment{ get positions}; _x1 = (_this select 0) select 0; _y1 = (_this select 0) select 1; _x2 = (_this select 1) select 0; _y2 = (_this select 1) select 1; comment{ return the distance}; sqrt( (_x1-_x2)^2 + (_y1-_y2)^2 ) Share this post Link to post Share on other sites
zulu1 145 Posted June 1, 2014 (edited) Thanks for the reply guys. I'll try your script when I have more time and I'm sure Kenosite's option will work also...I remember using Logics insted of markers in other missions. I did figure out something that meets my needs, maybe not the most elegant way but it works in this case. I kept the markers as waypoints and placed them close to road object ID's and used this script...and viola it worked. a3 domove (getMarkerpos "mine1") ~1 @ (a3 distance (object 62697) < 1) ~1 a3 fire ["put","mine"] ~1 a4 domove (getMarkerpos "mine3") ~1 @ (a4 distance (object 62497) < 1) ~1 a4 fire ["put","mine"] ~1 a3 domove (getMarkerpos "mine2") ~1 @ (a3 distance (object 62495) < 1) ~1 a3 fire ["put","mine"] ~1 a4 domove (getMarkerpos "mine4") ~1 @ (a4 distance (object 62351) < 1) ~1 a4 fire ["put","mine"] Thanks again Edited June 2, 2014 by Zulu1 Share this post Link to post Share on other sites