.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   HPB_bot (http://forums.bots-united.com/forumdisplay.php?f=35)
-   -   op4ctf (http://forums.bots-united.com/showthread.php?t=2176)

Whistler 02-07-2004 07:59

op4ctf
 
I have just found that the op4ctf flag owner problem isn't fixed correctly. actually there're quite a lot of places checking pent->v.owner and all of them need to check pent->v.origin as well:
(actually I think this is a bug of OP4. the "owner" field is just not nulled out when someone lost the flag and we have to use a "hack" like this to "fix" it)

Code:

  else if ((mod_id == GEARBOX_DLL) && (pent_info_ctfdetect != NULL))
  {
      pent = NULL;

      while ((pent = UTIL_FindEntityByClassname( pent, "item_ctfflag" )) != NULL)
      {
        // is this bot carrying the item? (after capture bug fix by Whistler)
        if ((pent->v.owner == pEdict) && (pent->v.origin == pEdict->v.origin))
        {
            // we are carrying the flag

            bot_has_flag = TRUE;

            break;  // break out of while loop
        }
        else if (FInViewCone( &pent->v.origin, pEdict ) &&
                  FVisible( pent->v.origin, pEdict))
        {
            // the bot can see it, check what type of model it is...

            skin = pent->v.skin;

            if (skin == 0) // Opposing Force team (these are BACKASSWARDS!)
              skin = 1;
            else if (skin == 1) // Black Mesa team
              skin = 0;

            // see if the flag matches the bot's team...
            if (skin == team)
            {
              // is and enemy carrying our flag/card?
              if (pent->v.owner != NULL)
              {
+                if (pent->v.origin == pent->v.owner->v.origin)
+                {
                    // kill the man with the flag/card!
                    pBot->pBotEnemy = pent->v.owner;

                    pBot->waypoint_goal = -1;  // forget the goal (if there is one)

                    return TRUE;
+                }
              }
            }
            else  // flag/card is for another team!
            {
              // check if someone is NOT carrying the flag/card...
+              bool bIsCarrying = FALSE;
+              if (!FNullEnt(pent->v.owner))
+              {
+                if (pent->v.origin == pent->v.owner->v.origin)
+                    bIsCarrying = TRUE;
+              }

-              if (pent->v.owner == NULL)
+              if (bIsCarrying)
              {
                  // find the nearest waypoint to the flag/card...
                  index = WaypointFindNearest(pent->v.origin, pEdict, 500, team);

                  if (index == -1)
                  {
                    // no waypoint is close enough, just head straight towards the flag/card
                    Vector v_flag = pent->v.origin - pEdict->v.origin;

                    Vector bot_angles = UTIL_VecToAngles( v_flag );

                    pEdict->v.ideal_yaw = bot_angles.y;

                    BotFixIdealYaw(pEdict);

                    return TRUE;
                  }
                  else
                  {
                    waypoint_distance = (waypoints[index].origin - pent->v.origin).Length();
                    distance = (pent->v.origin - pEdict->v.origin).Length();

                    // is the bot closer to the flag/card than the waypoint is?
                    if (distance < waypoint_distance)
                    {
                        // just head towards the flag/card
                        Vector v_flag = pent->v.origin - pEdict->v.origin;

                        Vector bot_angles = UTIL_VecToAngles( v_flag );

                        pEdict->v.ideal_yaw = bot_angles.y;

                        BotFixIdealYaw(pEdict);

                        return TRUE;
                    }
                    else
                    {
                        // head towards this waypoint
                        pBot->waypoint_goal = index;

                        // remember where the flag/card is located...
                        pBot->waypoint_near_flag = TRUE;
                        pBot->waypoint_flag_origin = pent->v.origin;
                    }
                  }
              }
            }
        }
      }
  }


Pierre-Marie Baty 02-07-2004 16:35

Re: op4ctf
 
Seeing this I wonder if it would be a good idea to put the HPB_bot code on CVS as well ?

What do you guys think ?

MusicMan 02-07-2004 16:44

Re: op4ctf
 
go for it ;)

stefanhendriks 02-07-2004 16:59

Re: op4ctf
 
CVS rules the world..... :) lets put it there

Pierre-Marie Baty 02-07-2004 17:34

Re: op4ctf
 
lol, well sure as hell if the whole world was on CVS I'd do a cvsup and commit() two or three things :D

bomberman 02-07-2004 18:35

Re: op4ctf
 
hmm ... may I know what is CVS and how to use it ?

botman 02-07-2004 22:21

Re: op4ctf
 
CVS is a source control versioning system.

WinCVS is a popular Windows client to access CVS files.

botman


All times are GMT +2. The time now is 17:54.

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