.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   Half-Life 2 SDK (http://forums.bots-united.com/forumdisplay.php?f=62)
-   -   Yay - Bots move to given vector location... (http://forums.bots-united.com/showthread.php?t=3326)

Cheeseh 11-01-2005 00:34

Re: Yay - Bots move to given vector location...
 
ahh god I'm so ignorant :(

The movement is the SAME !!

It's just that EyeAngles returns a angle from 0 to 360 instead of -180 to 180 I think.

So my old code works fine now (changed in post)... it works perfectly too, the last one was a bit dodgy

stefanhendriks 11-01-2005 10:42

Re: Yay - Bots move to given vector location...
 
this is what i use:

Code:

Vector vMoveDir;
        Vector vLookDir;
       
        pBot->vLookAtVector = pBot->vMoveToVector; // ITS THE SAME
        vLookDir = pBot->vLookAtVector;        // look at this
        AngleVectors(AngleWeMoveTo, &vMoveDir); // get movement direction
       
        // move in vMoveDir
        // dot product vMoveDir onto vLookDir to get forward movement
       
        float fForwardDot=DotProduct(vMoveDir, vLookDir); // get the proportion of forwards
       
        Vector vRightLook, vUpLook;
        VectorVectors(vLookDir, vRightLook, vUpLook); // get the vector perpendicular to the forward vector
       
        float fSideDot=DotProduct(vMoveDir, vRightLook); // get the proportion of side
       
       
        cmd.forwardmove=fForwardDot*200.0f;
        cmd.sidemove=fSideDot*200.0f;


SteveC 11-01-2005 18:56

Re: Yay - Bots move to given vector location...
 
Works a treat doesn't it Stefan ;).

Oh and by the way people I think I've worked out how to get the bots to shoot at enemies, (human or bot). But I need to do some testing first, should have a result by the weekend.

stefanhendriks 11-01-2005 21:25

Re: Yay - Bots move to given vector location...
 
got that working already :P

Cheeseh 11-01-2005 22:14

Re: Yay - Bots move to given vector location...
 
Quote:

Originally Posted by SteveC
Works a treat doesn't it Stefan ;).

Oh and by the way people I think I've worked out how to get the bots to shoot at enemies, (human or bot). But I need to do some testing first, should have a result by the weekend.

don't you just get the team Index from playerinfo and see if its different? Cos if they are it's an enemy.

SteveC 11-01-2005 23:24

Re: Yay - Bots move to given vector location...
 
Yeah, but to get the entity list there may be more than one technique, I'm using the edict list.

I guess we'll have a bot build off for a couple of weeks, then work together to produce a kick ass bot, once we know how everything works. Up for it?

stefanhendriks 12-01-2005 00:13

Re: Yay - Bots move to given vector location...
 
hey stevec, thats what Bots-United is for... to work together on kick-ass bots. Or alteast, at a kick-ass-framework

my snippet:

Code:

void BotFindEnemy(bot_t *pBot)
{
        // FIXME: Make this use UTIL_TRACELINE some day?
        Vector vFrom, vTo;       
        Ray_t mRay;                // the ray itself
 CTraceFilterHitAll mTraceFilter;       
        CGameTrace tRay;        // the results
        CBaseEntity *pEnemyBaseEntity=NULL;
        if (pBot->pEnemy)
        {
                BotAttackEnemy(pBot);
                return;
        }
        float fDistance=9999;
        // scan for enemy activities
 for ( int i = 1; i <= 32; i++ )  // EVIL: shouldn't just assume maxplayers is 32!!!
 {
  edict_t *pPlayerEdict = INDEXENT( i );
 
                if (pPlayerEdict)  // valid edict               
                {                         
                        if (pPlayerEdict == pBot->edict)
                                continue; // do not check self
                        pEnemyBaseEntity = CBaseEntity::Instance(pPlayerEdict);// get the player entity
                        if (pEnemyBaseEntity == NULL)
                                continue; // failed
                        // Check if its a player. (thx botman for pointing me out on this <shame>)
                        if (!pEnemyBaseEntity->IsPlayer())
                                continue;
                        if ( !pPlayerEdict->IsFree() ) // valid client
                        {                 
                                // HACK HACK
                         
                                // ok, this COULD be our enemy, so check this team status                               
                                IPlayerInfo* pInfo = NULL;
                               
                                if (playerinfomanager)
                                        pInfo = playerinfomanager->GetPlayerInfo(pPlayerEdict);
               
                                if (pInfo == NULL || !pInfo)
                                        return; // get out, this wont work :S                                        */
                               
                                // Set team (in case the game dll changed it for us)
                                int iTeam = pInfo->GetTeamIndex();
                         
                                if (iTeam != pBot->iTeam)
                                {                                       
                                        // potential enemy
                                        vFrom = pBot->vMyOrigin;
                                        gameclients->ClientEarPosition( pPlayerEdict, &vTo );  // to = his origin
                                        // TODO: How to make sure it is in our viewangles?
                                        QAngle viewangles;
                                        UTIL_VectorAngles( pBot->vLookAtVector, viewangles );
                                        if (FInViewCone(vFrom, vTo, viewangles) == false)
                                                continue;
                                        //bool FInViewCone (Vector vStart, Vector vLookDir, QAngle viewangles)
                                        // CHECK if enemy is behind wall or not
                                       
                                        if (UTIL_DistanceBetween(vFrom, vTo) > fDistance)
                                                continue; // too far
                                        mRay.Init(vFrom,vTo); // init
                                       
                                        enginetrace->TraceRay(mRay, MASK_PLAYERSOLID, &mTraceFilter, &tRay);

                                        //if (pEnemyBaseEntity == NU
                                        // success
                                        if (tRay.fraction == 1.0 || tRay.m_pEnt == pEnemyBaseEntity)
                                                {
                                                // could be our enemy
                                                fDistance = UTIL_DistanceBetween(vFrom, vTo);
                                                // Set as our enemy for now
                                                pBot->pEnemy = pPlayerEdict;
                                        }
                                }
                        }               
                }
 }
}

Note:
my "FInViewCone" function... is a bit of a fuzz. I do not know if it works 100%, here it is. Btw, i did not notice odd behaviour just yet...

Code:

bool FInViewCone (Vector vStart, Vector vLookDir, QAngle viewangles)

  float flDot;
  Vector vMoveDir;
  // We move to this
  AngleVectors(viewangles, &vMoveDir);
 
  Vector vRightLook, vUpLook;       
  VectorVectors(vLookDir, vRightLook, vUpLook); // get the vector perpendicular to the forward vector
 
  Vector vDest = vLookDir-vStart;
  // vLookDir
  flDot = DotProduct(vDest, vLookDir);       
  //Msg("FlDOT=%f ", flDot); 
         
  if (fabs(flDot) > 0.50)  // 60 degree field of view
        {
          return TRUE;
        }
  else
        {
          return FALSE;
        }
}


SteveC 12-01-2005 00:36

Re: Yay - Bots move to given vector location...
 
OK, I'll help where I can then.

If you want to fix the //EVIL on the maxplayers you can get the max players when the ServerActivate function is called in the plugin part of the code.

And I think there is a get FOV function in the CBasePlayer class we can use, but I'll need to check. It will help with FOV when using snipers etc.

stefanhendriks 12-01-2005 08:50

Re: Yay - Bots move to given vector location...
 
About maxplayers, yes i know, i am just really lazy to fix that ;)

for FOV, i did a quick search in the base class and the player class but did not find anything yet. I did not use "FOV" as keysearch though. :S Perhaps its there, but i think my function works? :)

Pierre-Marie Baty 12-01-2005 10:45

Re: Yay - Bots move to given vector location...
 
I think I found out how to make bots switch weapons. You must pass in the wpnselect field of the usercmd struct the entity index of the weapon to select. It's not a bitfield like I initially thought. However since I have little clue so far on how to peek around entities, I have not been able to test.


All times are GMT +2. The time now is 04:53.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.