.:: 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
an idea of selecting weapons to buy
Old
  (#1)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default an idea of selecting weapons to buy - 26-12-2004

PHP Code:

// choose a weapon to buy and returns the weapon ID
// emotion: 0 (defensive) - 100 (aggressive)
// type: 0 - primary, 1 - secondary
int CCSBuyManager::ChooseWeapon(int iEmotionint iMoneyint iTeamint iType)
{
   
int iPersonality 1// personality: 0 - defensive, 1 - normal, 2 - aggressive

   
int iRandom RandomLong(0100); // choose a random value
   
int delta iRandom iEmotion;
   if (
abs(delta) > 33) {
      if (
delta 0) {
         
iPersonality 0// defensive
      
} else {
         
iPersonality 2// aggressive
      
}
   }

   
std::vector<int> *p;
   if (
iTeam == CS_TEAM_TERRORIST) {
      if (
iPersonality == 0)
         
= &defensive_t;
      else if (
iPersonality == 1)
         
= &normal_t;
      else
         
= &aggressive_t;
   } else {
      if (
iPersonality == 0)
         
= &defensive_ct;
      else if (
iPersonality == 1)
         
= &normal_ct;
      else
         
= &aggressive_ct;
   }

   
int iSize p->size();
   
std::vector<intchosen// weapons which has been chosen

   
for (int i 0iSizei++) {
      
int iId = (*p)[i];

      
// see if this weapon can be bought

      // if we're NOT using CS 1.6 and this weapon is only for CS 1.6
      
if (((CServerCS *)g_pServer)->GetCSVersion() == CS_VERSION_WON &&
         (
iId == CS_WEAPON_GALIL || iId == CS_WEAPON_FAMAS || iId == CS_WEAPON_SHIELDGUN))
         continue; 
// skip this weapon

      // are we on an assasssination map?
      
if (((CServerCS *)g_pServer)->GetMapType() & MAP_AS) {
         
// skip certain weapons which is not available on as_* maps
         
if (iTeam == CS_TEAM_TERRORIST) {
            if (
iId == CS_WEAPON_M3 || iId == CS_WEAPON_XM1014 ||
               
iId == CS_WEAPON_MP5NAVY || iId == CS_WEAPON_P90 ||
               
iId == CS_WEAPON_M249)
               continue; 
// skip this weapon
         
} else {
            if (
iId == CS_WEAPON_AWP)
               continue; 
// skip this weapon
         
}
      }

      
cs_weapontable_s *pWeapon get_weapon(iId);
      if (!
pWeapon// check if this weapon is in our list
         
continue; // skip this weapon if not

      // check if we have enough money
      
if (iMoney pWeapon->iPrice RandomLong(100200))
         continue; 
// skip this weapon if not

      
if ((iType == && (UtilCS::WeaponIsPrimary(iId) || iId == CS_WEAPON_SHIELDGUN)) ||
         (
iType == && UtilCS::WeaponIsPistol(iId)))
         continue; 
// skip this weapon

      // this is a good weapon, add it to our chosen list
      
chosen.push_back(iId);
   }

   if (
chosen.empty())
      return 
0// no weapon is chosen, can't buy weapon

   // select the weapon to buy in the table
   
float flFactor = (iMoney 3000.0) / (16000 3000) * 3;
   if (
flFactor 1)
      
flFactor 1;

   
float f log10(RandomFloat(1pow(10flFactor)));
   return 
chosen[(int)((float)(chosen.size() - 1) * flFactor 0.5)];

  
Reply With Quote
Re: an idea of selecting weapons to buy
Old
  (#2)
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: an idea of selecting weapons to buy - 26-12-2004

This is great. You are include personality.
I like that but I don't see any menuselect code .
Can you explain.
  
Reply With Quote
Re: an idea of selecting weapons to buy
Old
  (#3)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: an idea of selecting weapons to buy - 26-12-2004

well, it just returns the index of the weapon you wanna buy ... actual buying has to be done elsewhere and since it's everywhere in CS the same, no need to post this here

nice idea to put the weapons prizes on a logarithmic scale and then select them via random function on this scale ... does that give good results ?

and why do you use this RANDOM_LONG with the prize ? I think one should avoid this here for the sake of clear code, since you already have a random function later on, so why here ?

the data structures to which the p points are updated when the actual weapon is bought ?


  
Reply With Quote
Re: an idea of selecting weapons to buy
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: an idea of selecting weapons to buy - 26-12-2004

I make all my weapon pickups/dropping/buying/handling decisions through a BotRateWeapon() function...
Code:
int BotRateWeapon (player_t *pPlayer, weaponspec_t *weapon_spec)
{
   // this function returns an integer value describing how much a particular weapon (passed by
   // the "weapon" pointer) is interesting for the bot whose player structure is pointed to by
   // pPlayer. The more interesting the weapon, the higher the number this function returns.
   // FIXME: quick and dirty, empirical. Redo this right.
   int score;
   // does the bot already have this weapon ?
   if (pPlayer->weapons[weapon_spec->index].is_present)
	  return (0); // then this weapon is of no interest for the bot
   // first reset the weapon score
   score = 0;
   // rate the interest regarding the weapon class
   // is weapon primary AND has bot no primary weapon yet ?
   if ((weapon_spec->weapon_class == WEAPON_CLASS_PRIMARY)
	   && !PlayerHasWeaponOfClass (pPlayer, WEAPON_CLASS_PRIMARY))
	  score += 500; // then weapon is highly interesting, add 500 in a row
   // else is weapon secondary AND has bot no secondary weapon yet ?
   else if ((weapon_spec->weapon_class == WEAPON_CLASS_SECONDARY)
			&& !PlayerHasWeaponOfClass (pPlayer, WEAPON_CLASS_SECONDARY))
	  score += 500; // then weapon is highly interesting, add 500 in a row
   // else is weapon grenade AND has bot no grenade yet ?
   else if ((weapon_spec->weapon_class == WEAPON_CLASS_GRENADE)
			&& !PlayerHasWeaponOfClass (pPlayer, WEAPON_CLASS_GRENADE))
	  score += 500; // then weapon is highly interesting, add 500 in a row
   // rate the interest regarding the bot's personal weapon preference
   // is this weapon the bot's preferred weapon AND the bot doesn't own that weapon yet ?
   if ((strcmp (weapon_spec->classname, pPlayer->Bot.pProfile->preferred_weapon) == 0)
	   && !PlayerHasWeapon (pPlayer, weapon_spec))
	   score += 500; // then weapon is highly interesting, add 500 in a row
   // now rate the interest regarding the weapon range
   // does this weapon work best in melee AND has bot no melee weapon yet ?
   if ((((weapon_spec->primary.range > 0) && (weapon_spec->primary.range == WEAPONRAIL_RANGE_MELEE))
		|| ((weapon_spec->secondary.range > 0) && (weapon_spec->secondary.range == WEAPONRAIL_RANGE_MELEE)))
	   && !PlayerHasWeaponOfRange (pPlayer, WEAPONRAIL_RANGE_MELEE))
	  score += 10; // interesting, add 10
   // else does this weapon work best at close range AND has bot no close range weapon yet ?
   else if ((((weapon_spec->primary.range > 0) && (weapon_spec->primary.range == WEAPONRAIL_RANGE_CLOSE))
			 || ((weapon_spec->secondary.range > 0) && (weapon_spec->secondary.range == WEAPONRAIL_RANGE_CLOSE)))
			&& !PlayerHasWeaponOfRange (pPlayer, WEAPONRAIL_RANGE_CLOSE))
	  score += 10; // interesting, add 10
   // else does this weapon work best at medium range AND has bot no medium range weapon yet ?
   else if ((((weapon_spec->primary.range > 0) && (weapon_spec->primary.range == WEAPONRAIL_RANGE_MEDIUM))
			 || ((weapon_spec->secondary.range > 0) && (weapon_spec->secondary.range == WEAPONRAIL_RANGE_MEDIUM)))
			&& !PlayerHasWeaponOfRange (pPlayer, WEAPONRAIL_RANGE_MEDIUM))
	  score += 10; // interesting, add 10
   // else does this weapon work best at long range AND has bot no long range weapon yet ?
   else if ((((weapon_spec->primary.range > 0) && (weapon_spec->primary.range == WEAPONRAIL_RANGE_FAR))
			 || ((weapon_spec->secondary.range > 0) && (weapon_spec->secondary.range == WEAPONRAIL_RANGE_FAR)))
			&& !PlayerHasWeaponOfRange (pPlayer, WEAPONRAIL_RANGE_FAR))
	  score += 10; // interesting, add 10
   // now parse each parameter individually
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_DISABLER)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_DISABLER))
		 score -= 2;
	  else
		 score += 11;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_WATERPROOF)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_MISSILE))
		 score += 1;
	  else
		 score += 12;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_LIGHTDAMAGE)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_LIGHTDAMAGE))
		 score -= 49;
	  else
		 score -= 16;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_MEDIUMDAMAGE)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_MEDIUMDAMAGE))
		 score -= 6;
	  else
		 score += 7;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_HEAVYDAMAGE)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_HEAVYDAMAGE))
		 score += 5;
	  else
		 score += 31;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_RADIUSEFFECT)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_RADIUSEFFECT))
		 score -= 5;
	  else
		 score += 15;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_AUTOMATIC)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_AUTOMATIC))
		 score += 17;
	  else
		 score += 33;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_BUCKSHOT)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_BUCKSHOT))
		 score -= 9;
	  else
		 score += 16;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_SCOPED)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_SCOPED))
		 score += 5;
	  else
		 score += 17;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_SNIPER)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_LIGHTDAMAGE))
		 score -= 22;
	  else
		 score += 14;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_SILENCED)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_SILENCED))
		 score += 10;
	  else
		 score += 28;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_MISSILE)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_MISSILE))
		 score -= 2;
	  else
		 score += 10;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_HOMING)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_HOMING))
		 score += 5;
	  else
		 score += 20;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_TOSS)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_TOSS))
		 score += 2;
	  else
		 score += 10;
   }
   if (weapon_spec->primary.properties & WEAPONRAIL_PROPERTY_PLACE)
   {
	  if (PlayerHasWeaponOfType (pPlayer, WEAPONRAIL_PROPERTY_PLACE))
		 score -= 5;
	  else
		 score += 5;
   }
   return (score); // return the overall score for this weapon
}



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: an idea of selecting weapons to buy
Old
  (#5)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: an idea of selecting weapons to buy - 29-12-2004

using the log10() to select the weapon can ensure that there are higher possibility to select "better" weapon and lower possibility to select "worse" weapon
the possibility is also depending on money

also the "p" points to a std::vector<int> which is a table similar to POD-Bot. it just chooses one of them depending on current bot's aggression value.
  
Reply With Quote
Re: an idea of selecting weapons to buy
Old
  (#6)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: an idea of selecting weapons to buy - 29-12-2004

RB is open source, but since we like to paste code here is mine:

Code:
void BotBuyStuff (cBot * pBot)
{
 int money = pBot->bot_money; // Money
 int team = pBot->iTeam; // Team
 int buy_weapon = -1;
 
 // What to buy?
 if (pBot->buy_primary == true)
 {
  // Buy primary
  bool bBuyOther = true;
  // Personality related:
  // Check if we can buy our favorite weapon
  if (pBot->ipFavoPriWeapon > -1)
  {
   if (FUNC_BotHasWeapon (pBot, pBot->ipFavoPriWeapon) == false)
   {
	if (GoodWeaponForTeam (pBot->ipFavoPriWeapon, pBot->iTeam))
	 if (PriceWeapon (pBot->ipFavoPriWeapon) <= money)
	 {
	  // Buy favorite weapon
	  buy_weapon = pBot->ipFavoPriWeapon;
	  bBuyOther=false;
	 }	  
	 else
	 {
	  // We do here something to 'save' for our favorite weapon
	  if (RANDOM_LONG (0, 100) < pBot->ipSaveForWeapon)
	  {  // 31.08.04 Frashman forgotten brace
	   pBot->buy_primary = false;
	   bBuyOther = false;
	   pBot->buy_secondary = false; // don't buy a secondary
	   return; // get out of function, don't buy anything
	  }
	 }
   }
   else
   {
	pBot->buy_primary=false; // already have our favorite weapon
	bBuyOther=false;
	return; // get out of function, go buy a secondary weapon or something?
   }
  }
  // Normal buy code
  if (bBuyOther)
  {
   // Find weapon we can buy in the list of weapons
   for (int i = 0; i < MAX_WEAPONS; i++)
   {
	// 31.08.04 Frashman Filter Out all except PRIMARY and SHIELD 
	// SHIELD is used as primary weapon
	if ((UTIL_GiveWeaponType (weapons_table[i].iId) != PRIMARY) 
	 && (UTIL_GiveWeaponType (weapons_table[i].iId) !=SHIELD))	 
	 continue;
	if (GoodWeaponForTeam (weapons_table[i].iId, team) == false)
	 continue;
	if (weapons_table[i].price <= money)
	{
	 if (pBot->iPrimaryWeapon > -1)  // has a primary weapon
	  if (weapons_table[ListIdWeapon(pBot->iPrimaryWeapon)].priority >= 
	   weapons_table[i].priority)
	   continue;
	 if (buy_weapon == -1)
	  buy_weapon = weapons_table[i].iId;
	 else
	 {
	  if (RANDOM_LONG (0, 100) < weapons_table[i].priority)
	   buy_weapon = weapons_table[i].iId; // randomly buy a different weapon
	 }
	 // 30.8.04 Frashman fixed from 150 to 100
	 if (RANDOM_LONG (0, 100) < weapons_table[i].priority)
	  break;
	}
   }
  } // Buy a primary weapon

  if (buy_weapon != -1)
  {
   pBot->buy_primary = false;
   // depending on amount of money we have left buy a secondary weapon
   int iMoneyLeft = money - PriceWeapon (buy_weapon);
   // TODO: this should be dependant on something else... not only money
   // 01.09.04 Frashman if buyed a Shield, try to buy a good Pistol
   if (iMoneyLeft >= 600)
	if ((RANDOM_LONG (0, 100) < 15) || (pBot->iPrimaryWeapon == CS_WEAPON_SHIELD))
	 pBot->buy_secondary = true;
  }
 }
 else if (pBot->buy_secondary == true)
 {
  // Buy secondary
  bool bBuyOther = true;
  // Personality related:
  // Check if we can buy our favorite weapon
  if (pBot->ipFavoSecWeapon > -1)
  {
   if (FUNC_BotHasWeapon (pBot, pBot->ipFavoSecWeapon) == false)
   {
	if (GoodWeaponForTeam (pBot->ipFavoSecWeapon, pBot->iTeam))
	 if (PriceWeapon (pBot->ipFavoSecWeapon) < money)
	 {
	  // Buy favorite weapon
	  buy_weapon = pBot->ipFavoPriWeapon;
	  bBuyOther=false;
	 }	  
	 else
	 {
	  // We do here something to 'save' for our favorite weapon
	  if (RANDOM_LONG (0, 100) < pBot->ipSaveForWeapon)
	  {  // 31.08.04 Frashman forgotten brace
	   bBuyOther = false;
	   pBot->buy_secondary = false; // don't buy a secondary
	   return; // get out of function, don't buy anything
	  }
	 }
   }
   else
   {
	bBuyOther=false;
	return; // get out of function, go buy a secondary weapon or something?
   }
  }
	// Normal buy code
	if (bBuyOther)
	{	
	 // Buy secondary
	 // Find weapon we can buy in the list of weapons
	 for (int i = 0; i < MAX_WEAPONS; i++)
	 {
	  // When enough money and the priority is high enough..
	  // Filter out Secondary and Grenades
	  if (UTIL_GiveWeaponType (weapons_table[i].iId) != SECONDARY)
	   continue;
	  if (GoodWeaponForTeam (weapons_table[i].iId, team) == false)
	   continue;
	  if (weapons_table[i].price <= money)
	  {
	   if (pBot->iSecondaryWeapon > -1) {
		int index = weapons_table[pBot->iSecondaryWeapon].iIdIndex;
		// 31.08.04 Frashman > corrected to >= ,
		// else the bot will buy another weapon with the same priority
		if (weapons_table[index].priority >= weapons_table[i].priority)
		 continue;
	   }
	   if (buy_weapon == -1)
		buy_weapon = weapons_table[i].iId;
	   else
	   {
		if (RANDOM_LONG (0, 100) < weapons_table[i].priority)
		 buy_weapon = weapons_table[i].iId;
	   }
	   if (RANDOM_LONG (0, 100) < weapons_table[i].priority)
		break;
	  }
	 }
	}
	if (buy_weapon != -1)
	 pBot->buy_secondary = false;
 }
 else if (pBot->buy_ammo_primary == true)
 {
  // Buy primary ammo
  BuyWeapon (pBot, "6", NULL);
  pBot->buy_ammo_primary = false;
  return;
 }
 else if (pBot->buy_ammo_secondary == true)
 {
  // Buy secondary ammo
  BuyWeapon (pBot, "7", NULL);
  pBot->buy_ammo_secondary = false;
  return;
 }
 else if (pBot->buy_defusekit)
 {
  if (money >= 200)
  {
   buy_weapon = CS_DEFUSEKIT;
   pBot->buy_defusekit = false;
  }
 }
 else if (pBot->buy_armor)
 {
  if (money < 1000 && money >= 650)
  {
   // Buy light armor
   buy_weapon = CS_WEAPON_ARMOR_LIGHT;
  }
  else if (money >= 1000)
  {
   // Buy heavy armor
   buy_weapon = CS_WEAPON_ARMOR_HEAVY;
  }
  pBot->buy_armor = false;
 }
 else if (pBot->buy_grenade)
 {
  // Buy grenade
  if (money >= weapons_table[ListIdWeapon (CS_WEAPON_HEGRENADE)].price)   
   buy_weapon = CS_WEAPON_HEGRENADE;
  pBot->buy_grenade = false;
 }
 else if (pBot->buy_flashbang > 0)
 {
  // Buy flashbang
  if (money >= weapons_table[ListIdWeapon (CS_WEAPON_FLASHBANG)].price) 
  {
   buy_weapon = CS_WEAPON_FLASHBANG;
   pBot->buy_flashbang--;
  }
  else
   pBot->buy_flashbang = 0; // do not buy				 
 }
 else if (pBot->buy_smokegrenade)  //31.08.04 Frashman added Smoke Grenade support
 {
  // Buy SmokeGrenade
  if (money >= weapons_table[ListIdWeapon (CS_WEAPON_SMOKEGRENADE)].price)   
   buy_weapon = CS_WEAPON_SMOKEGRENADE;
  pBot->buy_smokegrenade = false;
 }
 if (buy_weapon != -1)
 {
  // Buy...	   
  // TODO
  // FRASHMAN 30.08.04 haven't changed the cs 1.5 buycode, maybe there are also errors
  // CS 1.5 only
  if (counterstrike == 0)
  {
   switch (buy_weapon)
   {
   case CS_WEAPON_AK47:	BuyWeapon (pBot, "4", "1"); break;
   case CS_WEAPON_DEAGLE:  BuyWeapon (pBot, "1", "3"); break;
   case CS_WEAPON_P228:	BuyWeapon (pBot, "1", "4"); break;
   case CS_WEAPON_SG552:   BuyWeapon (pBot, "4", "2"); break;
   case CS_WEAPON_SG550:   BuyWeapon (pBot, "4", "8"); break;
   case CS_WEAPON_SCOUT:   BuyWeapon (pBot, "4", "5"); break;
   case CS_WEAPON_AWP:	 BuyWeapon (pBot, "4", "6"); break;
   case CS_WEAPON_MP5NAVY: BuyWeapon (pBot, "3", "1"); break;
   case CS_WEAPON_UMP45:   BuyWeapon (pBot, "3", "5"); break;
   case CS_WEAPON_ELITE: BuyWeapon (pBot, "1", "5"); break; // T only
   case CS_WEAPON_MAC10: BuyWeapon (pBot, "3", "4"); break; // T only
   case CS_WEAPON_AUG: BuyWeapon (pBot, "4", "4"); break; // CT Only
   case CS_WEAPON_FIVESEVEN: BuyWeapon(pBot, "1", "6"); break; // CT only
   case CS_WEAPON_M4A1: BuyWeapon(pBot, "4", "3"); break; // CT Only
   case CS_WEAPON_TMP: BuyWeapon(pBot, "3", "2"); break; // CT only
   case CS_WEAPON_HEGRENADE: BuyWeapon(pBot, "8", "4"); break;
   case CS_WEAPON_XM1014: BuyWeapon(pBot, "2", "2"); break;
   case CS_WEAPON_SMOKEGRENADE: BuyWeapon(pBot, "8", "5"); break;
   case CS_WEAPON_USP: BuyWeapon(pBot, "1", "1"); break;
   case CS_WEAPON_GLOCK18: BuyWeapon(pBot, "1", "2"); break;
   case CS_WEAPON_M249: BuyWeapon(pBot, "5", "1"); break;
   case CS_WEAPON_M3: BuyWeapon(pBot, "2", "1"); break;
   case CS_WEAPON_G3SG1: BuyWeapon (pBot, "4", "7"); break;
   case CS_WEAPON_FLASHBANG: BuyWeapon (pBot, "8", "3"); break;
   case CS_WEAPON_P90: BuyWeapon (pBot, "3", "3"); break;
	// Armor
   case CS_WEAPON_ARMOR_LIGHT: BuyWeapon (pBot, "8", "1"); break;
   case CS_WEAPON_ARMOR_HEAVY: BuyWeapon (pBot, "8", "2"); break;
	// Defuse kit
   case CS_DEFUSEKIT: BuyWeapon (pBot, "8", "6"); break;
   }
  }

  // CS 1.6 only
  if (counterstrike == 1)
  {  // FRASHMAN 30/08/04: redone switch block, it was full of errors
   switch (buy_weapon)
   {
	//Pistols
   case CS_WEAPON_GLOCK18: BuyWeapon (pBot, "1", "1"); break;
   case CS_WEAPON_USP:	 BuyWeapon (pBot, "1", "2"); break;
   case CS_WEAPON_P228:	BuyWeapon (pBot, "1", "3"); break;
   case CS_WEAPON_DEAGLE:  BuyWeapon (pBot, "1", "4"); break;
   case CS_WEAPON_ELITE:   BuyWeapon (pBot, "1", "5"); break;
	//ShotGUNS
   case CS_WEAPON_M3:   BuyWeapon (pBot, "2", "1"); break;
   case CS_WEAPON_XM1014:  BuyWeapon (pBot, "2", "2"); break;
	//SMG
   case CS_WEAPON_MAC10:   BuyWeapon (pBot, "3", "1"); break;
   case CS_WEAPON_TMP:   BuyWeapon (pBot, "3", "1"); break;
   case CS_WEAPON_MP5NAVY: BuyWeapon (pBot, "3", "2"); break;
   case CS_WEAPON_UMP45:   BuyWeapon (pBot, "3", "3"); break;
   case CS_WEAPON_P90:   BuyWeapon (pBot, "3", "4"); break;
	//rifles
   case CS_WEAPON_GALIL:   BuyWeapon (pBot, "4", "1"); break;
   case CS_WEAPON_FAMAS:   BuyWeapon (pBot, "4", "1"); break;
   case CS_WEAPON_AK47:	BuyWeapon (pBot, "4", "2"); break;
   case CS_WEAPON_M4A1:	BuyWeapon (pBot, "4", "3"); break;
   case CS_WEAPON_SG552:   BuyWeapon (pBot, "4", "4"); break;
   case CS_WEAPON_AUG:   BuyWeapon (pBot, "4", "4"); break;
   case CS_WEAPON_SG550:   BuyWeapon (pBot, "4", "5"); break;
   case CS_WEAPON_G3SG1:   BuyWeapon (pBot, "4", "6"); break;
	//machinegun
   case CS_WEAPON_M249:   BuyWeapon (pBot, "5", "1"); break;
	// equipment
   case CS_WEAPON_ARMOR_LIGHT:   BuyWeapon (pBot, "8", "1"); break;
   case CS_WEAPON_ARMOR_HEAVY:   BuyWeapon (pBot, "8", "2"); break;
   case CS_WEAPON_FLASHBANG:	BuyWeapon (pBot, "8", "3"); break;
   case CS_WEAPON_HEGRENADE:	BuyWeapon (pBot, "8", "4"); break;
   case CS_WEAPON_SMOKEGRENADE:   BuyWeapon (pBot, "8", "5"); break;
   case CS_WEAPON_SHIELD:	BuyWeapon (pBot, "8", "8"); break;
   
   case CS_DEFUSEKIT:   BuyWeapon (pBot, "8", "6"); break;
   }
   // This differs per team
   // FRASHMAN 30/08/04: all into one ifthen block
   if (pBot->iTeam == 2) // counter
   {
	switch(buy_weapon)
	{
	case CS_WEAPON_SCOUT: BuyWeapon(pBot,"4","2"); break;
	case CS_WEAPON_AWP: BuyWeapon(pBot,"4","6"); break;
	 //whats about nightvision? BuyWeapon (pBot, "8", "7") 
	}	 
   }
   else  // terror
   {
	switch(buy_weapon)
	{
	case CS_WEAPON_SCOUT: BuyWeapon(pBot,"4","3"); break;
	case CS_WEAPON_AWP: BuyWeapon(pBot,"4","5"); break;
	 //whats about nightvision? BuyWeapon (pBot, "8", "6") 
	}	 
   }
  }  // end of cs 1.6 part
 }	// We actually gonna buy this weapon
}
its personality related (favorite weapon, etc)
its cs 1.5/1.6 compatible
its not _as and _es compatible (maps)
it has some sort of scoring system
its output relies on the ini parsed information from buytable.ini

piece of buytable.ini

Quote:
#======
#CS 1.6
#======
; Counter-Terrorist weapon; not as good as Galil
[FAMAS]
Price=2250
Priority=15
; Terrorist Weapon; pretty accurate
[GALIL]
Price=2000
Priority=30


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: an idea of selecting weapons to buy
Old
  (#7)
@$3.1415rin
Council Member, Author of JoeBOT
 
@$3.1415rin's Avatar
 
Status: Offline
Posts: 1,381
Join Date: Nov 2003
Location: Germany
Default Re: an idea of selecting weapons to buy - 29-12-2004

[ hey stefan, we had already a general "let's post my über leet buyfunction thread" ]


  
Reply With Quote
Re: an idea of selecting weapons to buy
Old
  (#8)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: an idea of selecting weapons to buy - 30-12-2004

rofl really? let me double post on there!


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: an idea of selecting weapons to buy
Old
  (#9)
botmeister
Ex-Council Member
 
botmeister's Avatar
 
Status: Offline
Posts: 1,090
Join Date: Nov 2003
Location: Canada
Default Re: an idea of selecting weapons to buy - 02-01-2005

An effective but low tech way of having bots select good weapons for a given map, is to have a map "scenario" file which can specify which weapons are most effective for the type of map in use. A scenario file can specify much more, such as which personalities are best, weapon type distribution (eg 2 snipers, 3 shotgun, etc), and so on.


Maker of the (mEAn) Bot.Admin Manager

"In theory, there is no difference between theory and practice. But, in practice, there is." - Jan L.A. van de Snepscheut
  
Reply With Quote
Re: an idea of selecting weapons to buy
Old
  (#10)
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: an idea of selecting weapons to buy - 02-01-2005

good point, but this can be done automatically if the bots keep track themselves of which weapons are useful for which map. Let's let them discover it by themselves, it's always funnier



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