.:: 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
Re: Need some help for shield support
Old
  (#31)
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: Need some help for shield support - 30-10-2004

OK ; assuming your buy numbers are correct I see no problem with that array.
Can you post your buy function now ?
Perhaps not the function, but the 15-20 lines that make the bot buy, at least.



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: Need some help for shield support
Old
  (#32)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,620
Join Date: Jul 2004
Location: Bulgaria
Default Re: Need some help for shield support - 30-10-2004

Quote:
Code:
void BotBuyStuff(bot_t *pBot)
{
	char szMenuSelect[40];
	edict_t *pEdict = pBot->pEdict;

#ifdef DEBUG
	report_log (LOG_BOTBASE, "BotBuyStuff","Action=%d",pBot->BuyAction);
#endif
	// Needs a Weapon ?
	if((pBot->BuyAction == MSG_CS_BUYWEAPON_SELECT) 
		&& (pBot->f_buy_time+ RANDOM_LONG(1,6)/10)<gpGlobals->time)
	{
		pBot->BuyAction = MSG_CS_IDLE;
		if(pBot->pSelected_weapon == NULL || pBot->iBuyCount>1)
		{
#ifdef _DEBUG
			fp=fopen("PODERROR.txt","a"); fprintf(fp, "ERROR no Weapon selected: MSG_CS_BUYWEAPON_GROUPSELECT: %s - iBuyCount=%d\n",pBot->name,pBot->iBuyCount); fclose(fp);
#endif
			return;
		}
//		fp=fopen("bot.txt","a"); fprintf(fp, "MSG_CS_BUYWEAPON_GROUPSELECT: %s - iBuyCount=%d\n",pBot->name,pBot->iBuyCount); fclose(fp);
		pBot->iBuyCount = 2;
		pBot->f_buy_time=gpGlobals->time;
	
		sprintf(szMenuSelect,"%d",pBot->pSelected_weapon->iBuyGroup);
		FakeClientCommand(pEdict, "menuselect",szMenuSelect, NULL);
		return;
	}

	if((pBot->BuyAction == MSG_CS_WEAPONBUY) 
		&& (pBot->f_buy_time+(20-pBot->Ph)/5 + RANDOM_LONG(1,6)/5)<gpGlobals->time)
	{
		pBot->BuyAction = MSG_CS_IDLE;
		if((pBot->pSelected_weapon == NULL) || (pBot->iBuyCount != 2))
		{
			fp=fopen("bot.txt","a"); fprintf(fp, "ERROR no Weapon selected: MSG_CS_BUYWEAPON_PSSRM: %s - iBuyCount=%d\n",pBot->name,pBot->iBuyCount); fclose(fp);
			return;
		}
//		fp=fopen("bot.txt","a"); fprintf(fp, "MSG_CS_BUYWEAPON_PSSRM: %s - iBuyCount=%d\n",pBot->name,pBot->iBuyCount); fclose(fp);
		pBot->iBuyCount=3;
		pBot->f_buy_time=gpGlobals->time;

//		sprintf(szMenuSelect,"%d",pBot->pSelected_weapon->iBuySelect);
		// Whistler: changed this for CS 1.6
		if (g_bIsVersion16)
		{
			if (UTIL_GetTeam(pBot->pEdict) == 0) // terrorist
				sprintf(szMenuSelect,"%d",pBot->pSelected_weapon->iNewBuySelectT);
			else // CT
				sprintf(szMenuSelect,"%d",pBot->pSelected_weapon->iNewBuySelectCT);
		}
		else
			sprintf(szMenuSelect,"%d",pBot->pSelected_weapon->iBuySelect);

		FakeClientCommand(pEdict, "menuselect",szMenuSelect, NULL);
		BotPushMessageQueue(pBot,MSG_CS_BUY);
		return;
	}

	// Needs Ammo ?
	if((pBot->BuyAction==MSG_CS_BUYAMMO) 
		&& (pBot->f_buy_time+(20-pBot->Ph)/8)<gpGlobals->time)
	{
		
		pBot->BuyAction=MSG_CS_IDLE;
		if(BotHasPrimaryWeapon(pBot)==FALSE) // Pistol ?
			FakeClientCommand(pEdict, "menuselect","7", NULL);
		else
			FakeClientCommand(pEdict, "menuselect","6", NULL);
//		fp=fopen("bot.txt","a"); fprintf(fp, "MSG_CS_BUYAMMO: %s - iBuyCount=%d\n",pBot->name,pBot->iBuyCount); fclose(fp);
		pBot->iBuyCount=4;
		pBot->f_buy_time=gpGlobals->time;
		BotPushMessageQueue(pBot,MSG_CS_BUY);
		return;
}
Here is the code.
  
Reply With Quote
Re: Need some help for shield support
Old
  (#33)
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: Need some help for shield support - 31-10-2004

I remember there is a problem with the "menuselect n" client commands in CS 1.6. It's not your fault; it's a CS bug. To make sure bots buy effectively what you tell them to buy you should make them buy using the new shortcuts (like "famas", "deagle", etc.) For this I advise you to change a bit your bot_weapon_select_t structure and change these

int iNewBuySelectT;
int iNewBuySelectCT;

into a char array where you will put the buy shortcut to use for each weapon. For example:

char buy_shortcut[32];

You can then replace

FakeClientCommand(pEdict, "menuselect",szMenuSelect, NULL);

with

FakeClientCommand(pEdict, pBot->pSelected_weapon->buy_shortcut, NULL, NULL);



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: Need some help for shield support
Old
  (#34)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,620
Join Date: Jul 2004
Location: Bulgaria
Default Re: Need some help for shield support - 31-10-2004

Ok, I do that think but I can't test the bots becorse the C++ compiler give me error masege :
error LNK2001: unresolved external symbol "void __cdecl FakeClientCommand(struct edict_s *,char const *,...)" (?FakeClientCommand@@YAXPAUedict_s@@PBDZZ)

How to fix this problem.

Last edited by The Storm; 31-10-2004 at 13:59..
  
Reply With Quote
Re: Need some help for shield support
Old
  (#35)
sfx1999
Member
 
sfx1999's Avatar
 
Status: Offline
Posts: 534
Join Date: Jan 2004
Location: Pittsburgh, PA, USA
Default Re: Need some help for shield support - 31-10-2004

What compiler are you using?

Also, it looks like you didn't link some object in with your code.


sfx1999.postcount++
  
Reply With Quote
Re: Need some help for shield support
Old
  (#36)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,620
Join Date: Jul 2004
Location: Bulgaria
Default Re: Need some help for shield support - 31-10-2004

So, I done what you are say PMB but now the bots don't buy anythink. :'(
  
Reply With Quote
Re: Need some help for shield support
Old
  (#37)
sPlOrYgOn
<-- He did it.
 
sPlOrYgOn's Avatar
 
Status: Offline
Posts: 1,558
Join Date: Jan 2004
Location: Los Angeles, California, USA, North America, Earth, Solar System, Milky Way.
Default Re: Need some help for shield support - 01-11-2004

look at pbmm buy code...
you can't use it since it's GPLed but you can get the concept of what it does...
  
Reply With Quote
Re: Need some help for shield support
Old
  (#38)
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: Need some help for shield support - 01-11-2004

It looks like you did things wrong. I suspect you made the modifications to the wrong place. Can you post your changes to your original buy function ?



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: Need some help for shield support
Old
  (#39)
The Storm
Council Member / E[POD]bot developer
 
The Storm's Avatar
 
Status: Offline
Posts: 1,620
Join Date: Jul 2004
Location: Bulgaria
Default Re: Need some help for shield support - 01-11-2004

OK, OK I think that I know where is the problem.
The function buy_shortcut must be declared somewere with the weapons that will be in that function, but where and how to declared the function.
P.S. PMB I change only this that you tell me and added in the weapons ID menuselect function.
So where to declare the another part of the function buy_shortcut???
I think that this function must be declared in some .cpp file not only in bot.h.
I think that this is the problem.
  
Reply With Quote
Re: Need some help for shield support
Old
  (#40)
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: Need some help for shield support - 01-11-2004

OUCH
I really think you need to take some C classes, friend

Lesson #1.

A function is something like

void DoSomething (int parameter1, float parameter2)

or

int DoSomethingElse (Vector parameter1)

in fact it can take any form you want, either it does not return a value - and then the type is "void" - or it returns a value after execution, and then the type is int, float, or any data type you want.
When a function is called in the code, the computer branches the execution right into it, executes the function, and once the function is finished returns to the point from where it was called.

Functions usually end up with the statement "return". When the function has a return type of "void", then "return" does not need to be called. The code will just exit the function as soon as the last closing brace } is reached. On functions that are required to return a value, though, the return value must be explicitly passed as a parameter of the "return" instruction. Example:

return (-1); // this function will return -1

or

return (my_variable); // this function will return the value of my_variable



A data type is an identifier that tells what type of data you are allowed to put in a variable.

Example:

int variable_1; // in this variable you can put integer numbers only (like 1 or 2)
float variable_2; // in this variable you are allowed to put floating-point numbers (like 0.5)
char variable_3; // in this one you can put a character like 'a' or 'b'

It's not that exact. In fact in "char" variables you are also allowed to put integer numbers, like in "int" variables you can put other forms of data, like pointers, etc. All comes down to the size the variable takes in memory. "int" variables eat up 4 bytes, hence 4*8=32 bit of data (32 times 0 and 1s). That's why you are also allowed to store pointers in them, since a pointer is usually 4 bytes large too. On the other hand, "char" variables eat just 1 byte, hence 8 bits. With only 8 bits to describe a number you cannot go above +/-127 (if you keep the last bit to describe the sign, thus the data will be said signed), or 255 (if you eat the whole 8 bits for your number, and then the data will be said unsigned and you will have only positive numbers in it). With so few you cannot store pointers which are big numbers, and usually go way above 255.

You can also arrange your data in arrays. Arrays are just a set of variables of the same type put next to each other in memory. Example:

char variable1[32]; // this is an array of "char" variables

In this one you can put 32 characters, or 32 integer numbers provided each of them does not exceed 127 (since "char" means signed char). You can hence put characters

char variable1[32] = "abcdef"; // like some text (you're not forced to eat up all the 32 slots)

Or integer values

char variable1[32] = {1,45,53,23,123,6,84,22}; // as long as they don't go above 127

Char, int, long, short, float, double, void, are standard C data types. But in his code, a programmer may need to use more complex forms of data. Like, for example, a vector. A vector must be described by 3 real (floating point) numbers, and that obviously cannot fit in one single variable. One could do this:

float x_component;
float y_component;
float z_component;

but that's not very practical. The C language provides much better mechanisms for describing more complex types of data.



A struct (abbreviation for "structure") is when you tell the C compiler: "hey, from now on, I will make use of a new type of data that you don't know yet. It will be named XXXX and it will be composed of : this, that and that."

Example:

typedef struct
{
char variable1; // first member of my struct will be a "char" variable
float variable2; // second member will be a floating point variable
int variable3; // and the third slot will be occupied with an integer number.
} my_struct;

Here you say to the compiler: look, I am telling you of this new data type I am going to use. It's called "my_struct". In it you will find
1st - a char variable
2nd - a float variable
3rd and last - an int variable.

And from then on, in your code, you can use this new struct, the compiler will know about it. For example, at the beginning of a function, you can declare:

my_struct blablablah;

just like you would declare

float variable1;

or any other form of data. Since your struct has been defined, the compiler will know about it. You will then be able to access your struct's members like this:

blablablah.variable1 = 'a'; // put 'a' in the 1st member of my struct
blablablah.variable2 = 0.5; // put 0.5 in the 2nd one (it's a float variable)
blablablah.variable3 = 435264; // and so on.

In the Half-Life SDK, the Vector data type can be seen as a custom struct, having members named x, y and z. You can do:

Vector some_vector; // declare a new vector

some_vector.x = 0.324; // access x component
some_vector.y = 5643.546; // access y component
some_vector.z = 32.3; // access z component

(in fact it's a bit more complex. Vector is not only a struct, it's a class. A class can be seen like a struct, in which you put not only variables, but also functions, like Length() for example.)

Now look at this:
Code:
typedef struct
{
int iId; // the weapon ID value
char weapon_name[64]; // name of the weapon when selecting it
char model_name[64]; // Model Name to separate CS Weapons
float primary_min_distance; // 0 = no minimum
float primary_max_distance; // 9999 = no maximum
float secondary_min_distance; // 0 = no minimum
float secondary_max_distance; // 9999 = no maximum
bool can_use_underwater;	 // can use this weapon underwater
bool primary_fire_hold;	 // hold down primary fire button to use?
float primary_charge_delay; // time to charge weapon
int iPrice;	 // Price when buying
int min_primary_ammo;
int iTeamStandard;	// Used by Team (Number) (standard map)
int iTeamAS;	 // Used by Team (AS map)
int iBuyGroup;	 // Group in Buy Menu (standard map)
int iBuySelect;	// Select Item in Buy Menu (standard map)
// Whistler: added for Cs 1.6
int iNewBuySelectT;
int iNewBuySelectCT;
bool bShootsThru;	// Can shoot thru Walls 
} bot_weapon_select_t;
Question 1. Is that a function or is that a structure ?
A structure, obviously. Its name is bot_weapon_select_t and it has the aforementioned members.
Question 2. What must buy_shortcut be ?
buy_shortcut must be a member of the bot_weapon_select_t structure, so that you can use it in further declarations of bot_weapon_select_t variables.
Question 3. How do you need to define buy_shortcut ?
Simply by adding it to the list with the other members of the bot_weapon_select_t structure.

If you answer these questions right, you will know enough to fix your problem. If you CANNOT answer them right, IMO it's too early for you to take on the development of a bot as complicated as podbot

The answer is provided in clear text, btw



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