Raised This Month: $51 Target: $400
 12% 

Warp bot and avoid stuck in walls?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 09-18-2021 , 04:58   Warp bot and avoid stuck in walls?
Reply With Quote #1

I wrote a warp bot plugin to move bots around and it works great except for the feature that lets me warp a single bot where I am pointing. It works but it allows placing the bot in the walls where they are stuck. I would like to not allow the warp in this case.

It must have something to do with the traceline but I don't have the expirence to know how to change it.

PHP Code:
//-----------------------------------------------------------------------------
public Action Command_warpFarBot(int clientint args)
{
    
float clientPos[3];
    
GetEntPropVector(clientProp_Data"m_vecOrigin"clientPos);
    
int farthestBotIndex getFarthestBot(client);
    if (
farthestBotIndex 1)
    {
        
ReplyToCommand(client"Could not find a bot to teleport.");
        return 
Plugin_Handled;
    }

    new 
Float:g_Origin[3];
    new 
Float:g_Angle[3];

    
GetClientEyePosition(clientg_Origin);
    
GetClientEyeAngles(clientg_Angle);
    
TR_TraceRayFilter(g_Origing_AngleMASK_OPAQUERayType_InfiniteTraceRayDontHitSelfclient);
    if(
TR_DidHit(INVALID_HANDLE))
        
TR_GetEndPosition(g_Origin);
    else
        
PrintToChat(client"Vector out of world geometry. Spawning on current position instead");
    
TeleportEntity(farthestBotIndexg_Origing_AngleNULL_VECTOR);

    
ReplyToCommand(client"[SM] Teleported %N to you."farthestBotIndex);
    return 
Plugin_Handled;
}

//-----------------------------------------------------------------------------
int getFarthestBot(client)
{
    
int farthestBotIndex = -1;
    
float maxDist 1.0;
    
float otherPos[3], clientPos[3];
    
GetEntPropVector(clientProp_Data"m_vecOrigin"clientPos);
    for (
int i 1<= MaxClientsi++)
    {
        if (!
IsClientInGame(i))    continue;
        if (!
IsPlayerAlive(i))    continue;
        if (!
IsFakeClient(i))        continue;
        if (
GetClientTeam(i) !=  GetClientTeam(client)) continue;

        
GetEntPropVector(iProp_Data"m_vecOrigin"otherPos);
        if (
GetVectorDistance(clientPosotherPosfalse) > maxDist)
        {
            
maxDist GetVectorDistance(clientPosotherPosfalse);
            
farthestBotIndex i;
        }
    }
    return 
farthestBotIndex;
}

//-----------------------------------------------------------------------------
public bool:TraceRayDontHitSelf(entitymaskany:data)
{
    if(
entity == data)    // TraceRay hit the itself?
        
return false;            // Don't let the entity be hit
    
return true;

Austin is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:48.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode