3 registered members (Konsti, AndrewAMD, 1 invisible),
1,376
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: EVENT_DETECT nearest target.
[Re: mEnTaL]
#405480
07/31/12 19:51
07/31/12 19:51
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
One simple way would be
var min_dist = 100;
result = c_scan
if(you)if(vec_dist(my.x, you.x) < min_dist) _found_a_near_ent;
//if(result < 100) _found_a_neaR_ent; //could work
Or u save all found ents in an array then checking all distances to get the "real" nearest ent. Edit: Manual says YOU is automatic set to nearest entity.
Last edited by rayp; 07/31/12 20:00.
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
Re: EVENT_DETECT nearest target.
[Re: mEnTaL]
#405484
07/31/12 20:22
07/31/12 20:22
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
: var i; for (i=0; i<5; i++) // repeat 5 times x *= x; // calculate the 5th power of x
edit: Adding something to an array (if i remember right) looks like this:
var my_array[100];
var my_index;
var i;
//add
c_scan
if(you)
{
my_Array[my_Index] = handle (you);
my_index += 1;
}
But this is a long time ago i used a array with 3dgs Edit2: theres an simple way to go through all ents with an "for" then using vec_dist, but i cant remember. Edit3: This is what i meant. U could modify it with vec_dist etc. to check for all ents function hide_all_ents() { // repeat for all entities for(you = ent_next(NULL); you; you = ent_next(you)) set(you,INVISIBLE); // make entity invisible } }
Last edited by rayp; 07/31/12 21:20.
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
Re: EVENT_DETECT nearest target.
[Re: mEnTaL]
#405498
08/01/12 00:02
08/01/12 00:02
|
Joined: Jul 2008
Posts: 2,107 Germany
rayp
X
|
X
Joined: Jul 2008
Posts: 2,107
Germany
|
Your welcome ! Btw: I blame the manual:
function hide_all_ents() { // repeat for all entities for(you = ent_next(NULL); you; you = ent_next(you)) set(you,INVISIBLE); // make entity invisible } }
Edit2: I now used my own function from above the first time. Worked well.
Last edited by rayp; 08/03/12 16:03.
Acknex umgibt uns...zwischen Dir, mir, dem Stein dort... "Hey Griswold ... where u gonna put a tree that big ?" 1998 i married my loved wife ... Sheeva from Mortal Kombat, not Evil-Lyn as might have been expected rayp.flags |= UNTOUCHABLE;
|
|
|
|