.:: Bots United ::.  
filebase forums discord server github wiki web
cubebot epodbot fritzbot gravebot grogbot hpbbot ivpbot jkbotti joebot
meanmod podbotmm racc rcbot realbot sandbot shrikebot soulfathermaps yapb

Go Back   .:: Bots United ::. > Developer's Farm > SDK Programming discussions > Half-Life 2 SDK
Half-Life 2 SDK For developments focused around the Half-Life 2 engine Half-Life 2

Reply
 
Thread Tools
Re: Yay - Bots move to given vector location...
Old
  (#21)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Yay - Bots move to given vector location... - 11-01-2005

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

Last edited by Cheeseh; 11-01-2005 at 00:39..
  
Reply With Quote
Re: Yay - Bots move to given vector location...
Old
  (#22)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Yay - Bots move to given vector location... - 11-01-2005

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;


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Yay - Bots move to given vector location...
Old
  (#23)
SteveC
Member
 
Status: Offline
Posts: 37
Join Date: Jan 2005
Location: UK
Default Re: Yay - Bots move to given vector location... - 11-01-2005

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.
  
Reply With Quote
Re: Yay - Bots move to given vector location...
Old
  (#24)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Yay - Bots move to given vector location... - 11-01-2005

got that working already


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Yay - Bots move to given vector location...
Old
  (#25)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: Yay - Bots move to given vector location... - 11-01-2005

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.
  
Reply With Quote
Re: Yay - Bots move to given vector location...
Old
  (#26)
SteveC
Member
 
Status: Offline
Posts: 37
Join Date: Jan 2005
Location: UK
Default Re: Yay - Bots move to given vector location... - 11-01-2005

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?
  
Reply With Quote
Re: Yay - Bots move to given vector location...
Old
  (#27)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Yay - Bots move to given vector location... - 12-01-2005

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;
	}
}


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Yay - Bots move to given vector location...
Old
  (#28)
SteveC
Member
 
Status: Offline
Posts: 37
Join Date: Jan 2005
Location: UK
Default Re: Yay - Bots move to given vector location... - 12-01-2005

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.
  
Reply With Quote
Re: Yay - Bots move to given vector location...
Old
  (#29)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: Yay - Bots move to given vector location... - 12-01-2005

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?


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: Yay - Bots move to given vector location...
Old
  (#30)
Pierre-Marie Baty
Roi de France
 
Pierre-Marie Baty's Avatar
 
Status: Offline
Posts: 5,049
Join Date: Nov 2003
Location: 46°43'60N 0°43'0W 0.187A
Default Re: Yay - Bots move to given vector location... - 12-01-2005

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.



RACC home - Bots-United: beer, babies & bots (especially the latter)
"Learn to think by yourself, else others will do it for you."
  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

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



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
vBulletin Skin developed by: vBStyles.com