View Single Post
zXCaptainXz
Member
Join Date: May 2017
Old 02-14-2022 , 15:39   Re: Find a random spawn location around an origin?
Reply With Quote #2

I won't pretend like I even barely understood how this function works, but maybe you could try shuffling the array randomly before scanning?

Code:
    
new randIndex, tmp;
for(new i; i < sizeof(iOrder); i++)
{
    randIndex = random(sizeof(iOrder));
    tmp = iOrder[i];
    iOrder[i] = iOrder[randIndex];
    iOrder[randIndex] = tmp;
}
EDIT: I was doing some digging and I found this function, maybe you could make some use of it instead of all this mess?

Code:
stock bool:is_monster_hull_vacant( ent, const Float:origin[ 3 ] )
{
    new iTr = 0;
    engfunc( EngFunc_TraceMonsterHull, ent, origin, origin, 0, ent, iTr );

    if( !get_tr2( iTr, TR_StartSolid ) && !get_tr2( iTr, TR_AllSolid ) && get_tr2( iTr, TR_InOpen ) )
        return true;
        
    return false;
}

Last edited by zXCaptainXz; 02-14-2022 at 15:52. Reason: Adding stuff
zXCaptainXz is offline