Home   Help Search Login Register  

Author Topic: Which Game Logic is the closest to my loon???  (Read 618 times)

0 Members and 1 Guest are viewing this topic.

gundernak

  • Guest
Which Game Logic is the closest to my loon???
« on: 07 Jan 2004, 20:10:43 »
Hi all,

I have 3 Game Logics to set up 3 different position to where I can send my loon.

How can I check which Game Logic is the closest to my loon???

I need this check in a script I can not use triggers.

Thanks in advance

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Which Game Logic is the closest to my loon???
« Reply #1 on: 08 Jan 2004, 03:39:34 »
Well, the command distance could come in handy here ...
Plenty of reviewed ArmA missions for you to play

gundernak

  • Guest
Re:Which Game Logic is the closest to my loon???
« Reply #2 on: 08 Jan 2004, 13:27:30 »
Ok...

If I could have only 3 points to define wich is the closest to me, I could use:

as a draft...

if A<B and A<B then A is the closest
if B<A and B<C then B is the closest
if C<A and C<B then C is the closest.......

but what if I have to check let's say 10 or more distance?
Is there a more simple way to check it in OFP?

Offline .pablo.

  • Former Staff
  • ****
  • When in doubt, empty the magazine.
Re:Which Game Logic is the closest to my loon???
« Reply #3 on: 09 Jan 2004, 00:32:31 »
i made a function to do just that

put this in a file named closesttarget.sqf:

Quote
//closesttarget.sqf by pablo for Skye Virus
//pablo_m123@yahoo.com
//returns the closest target within an array
//put this in init.sqs: closesttarget = preprocessFile "closesttarget.sqf"
//ex of how to use: target = [potentialtargets, man] call closesttarget


private ["_potentialtargets", "_man", "_closesttarget", "_distance"];

_potentialtargets = _this select 0;
_man = _this select 1;

_closestdistance = 999999;


"If ((_man distance _x) < _closestdistance) Then
{
    _closestdistance = (_man distance _x);
    _closesttarget = _x;
};" ForEach _potentialtargets;

_closesttarget

gundernak

  • Guest
Re:Which Game Logic is the closest to my loon???
« Reply #4 on: 09 Jan 2004, 11:58:52 »
thanks for the sqf

It seemes a little bit advanced to me, but I am definitely trying....