
Posts
602
Respect
52Add +1
Forum Rank
Zombie Enslaver
Primary Group
Box Mappers Elite
Login Issues
Forgot password?Activate Issues
Account activation email not received? Wrong account activation email used?Other Problems?
Contact Support - Help Center Get help on the UGX Discord. Join it now!get_array_of_closest( org, array, excluders, max, maxdist )
{
// pass an array of entities to this function and it will return them in the order of closest
// to the origin you pass, you can also set max to limit how many ents get returned
if( !IsDefined( max ) )
max = array.size;
if( !isdefined( excluders ) )
excluders = [];
maxdists2rd = undefined;
if( isdefined( maxdist ) )
maxdists2rd = maxdist * maxdist;
// return the array, reordered from closest to farthest
dist = [];
index = [];
for( i = 0;i < array.size;i ++ )
{
excluded = false;
for( p = 0;p < excluders.size;p ++ )
{
if( array[ i ] != excluders[ p ] )
continue;
excluded = true;
break;
}
if( excluded )
continue;
length = distancesquared( org, array[ i ].origin );
if( isdefined( maxdists2rd ) && maxdists2rd < length )
continue;
dist[ dist.size ] = length;
index[ index.size ] = i;
}
for( ;; )
{
change = false;
for( i = 0;i < dist.size - 1;i ++ )
{
if( dist[ i ] <= dist[ i + 1 ] )
continue;
change = true;
temp = dist[ i ];
dist[ i ] = dist[ i + 1 ];
dist[ i + 1 ] = temp;
temp = index[ i ];
index[ i ] = index[ i + 1 ];
index[ i + 1 ] = temp;
}
if( !change )
break;
}
newArray = [];
if( max > dist.size )
max = dist.size;
for( i = 0;i < max;i ++ )
newArray[ i ] = array[ index[ i ] ];
return newArray;
}
check_zombie()
{
view_pos = self gettagorigin("tag_flash");
zombies = get_array_of_closest( view_pos, GetAiSpeciesArray( "axis", "all" ), undefined, undefined, 60 ); // 60 is the distance to see how far the zombie can be
if ( !isDefined( zombies ) )
{
return;
}
}![]() | |
![]() | Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum. |
![]() | Has shown excellence and experience in the area of custom scripting in the UGX-Mods community. |
![]() BO3 Modtools Alpha | This user has access to the Black Ops 3 Modtools Alpha |
zombies = get_array_of_closest( self GetTagOrigin( "j_head" ), GetAiSpeciesArray( "axis", "all" ), undefined, undefined, GetDvarInt("player_meleeRange") );