.:: 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 > General Bot Coding
General Bot Coding See what a pain it is to get those little mechs shooting around

Reply
 
Thread Tools
I need by some help for the team detecting.
Old
  (#1)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default I need by some help for the team detecting. - 19-11-2005

Hi all,

Some of you already know that I code a bot for the HL mod Sands of War.
So I have a little problem. The bots shoot at the theyer teammates and I can't fix that. I code directly in to the SoW source. Here what I use:

Code:
void SearchForEnemy(CBasePlayer *bot) 
{ //Function to find enemies.

	EHANDLE nearestenemy;
	nearestenemy = NULL;

	for ( int i = 1; i <= gpGlobals->maxClients; i++ )
	{
		EHANDLE pPlayer;
		pPlayer = GetClientByIndex(i);
		float Dist1;
		float closest1 = 1000;

		// skip invalid players and skip self (i.e. this bot)
		if ((pPlayer == NULL) || (pPlayer == bot))
			continue;
 
		// skip this player if not alive (i.e. dead or dying)
		if (pPlayer->pev->deadflag != DEAD_NO)
			continue;

		// skip players that are in botcam mode...
		if (pPlayer->pev->effects & EF_NODRAW)
			continue;
/*
		// skip the teammates... This is commented out because its not work.
		if (bot->pev->team == pPlayer->pev->team)
			continue;*/
/*
		// skip the teammates... This is commented out because its not work.
		if (g_pGameRules->GetTeamID(bot) == g_pGameRules->GetTeamID(pPlayer))
			continue;*/
		// This too its not work.
		if (UTIL_TeamsMatch(bot->TeamID(), pPlayer->TeamID()))
			continue;

		if (pPlayer != NULL && pPlayer->pev)
			Dist1 = (bot->pev->origin - pPlayer->pev->origin).Length();

			if ((bot->pev->origin - pPlayer->pev->origin).Length() < closest1) 
			{
		    	closest1 = (bot->pev->origin - pPlayer->pev->origin).Length();
				nearestenemy = pPlayer;
			}
	} //This will find the nearest enemy

	if (nearestenemy != NULL) 
	{
		bot->enemy = nearestenemy;
	} //If we found someone, set them as our enemy.
}
I know that SoW is closed source but if can help me I will be very happy.
  
Reply With Quote
Re: I need by some help for the team detecting.
Old
  (#2)
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: I need by some help for the team detecting. - 21-11-2005

The coders of this mod may use their own technique for storing the players' team (such as in a new variable in their private data). Just ask them to write into pev->team like well-educated persons



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
Re: I need by some help for the team detecting.
Old
  (#3)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,618
Join Date: Jul 2004
Location: Bulgaria
Default Re: I need by some help for the team detecting. - 22-11-2005

OK. So the teams are defined in this way:
pPlayer->m_iTeam. I must set this to spawn the bot correct.
So I tryed this:
Code:
if (bot->m_iTeam == pPlayer->m_iTeam)
	continue;
But still its not working. I don't have more ideas.
  
Reply With Quote
Re: I need by some help for the team detecting.
Old
  (#4)
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: I need by some help for the team detecting. - 22-11-2005

In that case, it's your bots that don't fill their team number correctly, heh !



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)
 
Thread Tools

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