limmy3 0 Posted December 5, 2006 Hello I'm back  , Well, let's start. The player is the commander of a fireteam. (West) The enemy has six groups of about 8 units. One unit of fireteam west should move to the gunner position of a MG position. I know that I could to that with the trigger and east present command. But I want to use the "distance" command. Which means that if any unit of an east group comes closer than 25m the unit west will move to the MG. I tried it with: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(W_2 distance E_G_1) or (W_2 distance E_G_2) or (W_2 distance E_G_3) < 25But there is an ERROR message. E_G_1 = East Group 1 W_2 = West Unit 2 I would be very thankfull if someone could help me!  All   is  . Regards limmy3 Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted December 5, 2006 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(W_2 distance E_G_1) or (W_2 distance E_G_2) or (W_2 distance E_G_3) < 25 Well, for starters, you can't just compare multiple things to one other thing like that. You have to do it like this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">(W_2 distance E_G_1 < 25) or (W_2 distance E_G_2 < 25) or (W_2 distance E_G_3 < 25) Also, you can't distance check against a group, it has to be an object. like (w_2 distance e_2 < 25), using your variable names as an example. The simplest way is to dump all the east guys you want into an array, then check each soldier againts the array. It'll have to look something like this, although this code isn't going to be syntaxtually accurate (it should be close though): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _manMachineGunFlag = false #loop ~1 _enemyArray = [] {_enemyArray = _enemyArray + [_x]} forEach units E_G_1 {_enemyArray = _enemyArray + [_x]} forEach units E_G_2 {_enemyArray = _enemyArray + [_x]} forEach units E_G_3 _friendlyArray = [] {_friendlyArray = _friendlyArray + [_x]} forEach units W_G_1 _enemyCount = count _enemyArray _friendlyCount = count _friendlyArray _i = 0 #for1 _j = 0 #for2 ? (((_enemyArray select _i) distance (_friendlyArray select _j)) < 25) : _manMachineGunFlag = true ? _manMachineGunFlag : goto "exitLoop" _j = _j + 1 ? _j < _friendlyCount goto "for2" _i = _i + 1 ? _i < _enemyCount : goto "for1" goto "loop" #exitLoop edit: dang, I really need to start proofreading *before* I hit the submit button... Share this post Link to post Share on other sites
mandoble 1 Posted December 5, 2006 Just curious, why to calculate distances when you can use a simple trigger? Share this post Link to post Share on other sites
limmy3 0 Posted December 6, 2006 Just curious, why to calculate distances when you can use a simple trigger? Because a trigger is immotile. It will get activated when the enemy is e.g. 30m off the fortress where the unit shall retreat to. Which means that the enemy may be closer than 5m to the unit which should retreat. With a "distance" command the distance will effect on the unit itself thus the unit will retreat when the enemy is closer than 30m and has enough time to retreat to the fortress. Regards limmy3 Share this post Link to post Share on other sites
SevenBEF 0 Posted December 6, 2006 Because a trigger is immotile. Supposing you ment immobile. Make ur trigger, east present axis 30;30 and name it mytrigger have whatever you need in the activation part; in the initline of that westunit put: [this] exec "triggerfollow.sqs" or whatever you want to name it triggerfollow.sqs <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _unit = _this select 0 #loop mytrigger setpos getpos _unit ~1 goto "loop" Share this post Link to post Share on other sites
limmy3 0 Posted December 7, 2006 Hello SevenBef, Yes, you're wright immobile of course. Well, as I don't know how to write scripts I didn't know this way. Thank you. In german you would say "There are many ways to go to Rom." Altough I found another way:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">E_G_1 or E_G_2 or E_G_3 distance W_1 < 100 But I have to ckeck if this will work:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">W_1 distance E_G_1 or E_G_2 or E_G_3 < 100 Regards limmy3 Share this post Link to post Share on other sites
Metal Heart 0 Posted December 7, 2006 Quote[/b] ]Altough I found another way: No, you didn't. OR only works with booleans (true or false). and distance doesn't work with groups. What you have: group OR group OR condition_that_doesn't_work What you should have: boolean As in: condition OR condition OR condition Which will return: boolean Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted December 7, 2006 Quote[/b] ]In german you would say "There are many ways to go to Rom." In english, that goes: "All roads lead to Rome." Although it's not quite true these days, with multiple continents on the map and such... Metal Heart is absolutly right and is saying the same thing I said above. Share this post Link to post Share on other sites
limmy3 0 Posted December 8, 2006 Hi, yes, I tried it once more and I got ERROR messages. I have a try on SevenBEF triggers. A pity I can't write scripts so ColonelSandersLite script may be to difficult for me. I thank you all for your great help. Â Regards limmy3 Share this post Link to post Share on other sites
ColonelSandersLite 0 Posted December 8, 2006 A pity I can't write scripts The only way to learn is to jump in and go for it. There's a few basic scripting tutorials floating around. Once you get the very basics from one of these, use this forum and ofpec to help you. Hell, I wouldn't be supprised if you even found one or two in german. (I think you said that's your native language) Share this post Link to post Share on other sites