.:: 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
Getting the enemy's weapon-help plz
Old
  (#1)
noGrip
Member
 
Status: Offline
Posts: 2
Join Date: Jun 2006
Default Getting the enemy's weapon-help plz - 10-06-2006

Hi all,

I'm trying to build a bot for counter-strike 1.6. I want to know what weapon the bot's sighted enemy is using. For that I'm using the entvars_s structure. I do something like this (short version):

Code:
//What enemies do i see?
edict_t** visibleEnemies = vision->seeEnemies();
edict_t* targetEnemy = visibleEnemies[0];
if(targetEnemy->v.weaponmodel == ???)
{
     //do something about it
}
The ??? is what I want to know... I know it is an integer, but I have spent the last hours trying to find the match between that integer and the weapon. Does anyone know where it is? Or if it is another way of detecting the enemy's weapon?

Thanks,

Paulo
  
Reply With Quote
Re: Getting the enemy's weapon-help plz
Old
  (#2)
jeefo
путинхуйлоебаное
 
jeefo's Avatar
 
Status: Offline
Posts: 452
Join Date: Nov 2005
Location: Saint-Petersburg
Default Re: Getting the enemy's weapon-help plz - 10-06-2006

weaponmodel field is a string, so you need to use a strcmp() stuff, so i advice you to use bits

if ((targetEnemy->v.weapons & (1 << CS_WEAPON_AWP)))
m_botHasAWP = true;

in this way
  
Reply With Quote
Re: Getting the enemy's weapon-help plz
Old
  (#3)
noGrip
Member
 
Status: Offline
Posts: 2
Join Date: Jun 2006
Default Re: Getting the enemy's weapon-help plz - 10-06-2006

Thanks for the help!
Where do you find the weapons name like CS_WEAPON_AWP? I'm looking specifically for the gun and shield. ( I want to throw them grenades )
  
Reply With Quote
Re: Getting the enemy's weapon-help plz
Old
  (#4)
jeefo
путинхуйлоебаное
 
jeefo's Avatar
 
Status: Offline
Posts: 452
Join Date: Nov 2005
Location: Saint-Petersburg
Default Re: Getting the enemy's weapon-help plz - 10-06-2006

np

Weapons:
PHP Code:
enum eWeapon
{
   
WEAPON_P228         1,
   
WEAPON_SHIELDGUN    2,
   
WEAPON_SCOUT        3,
   
WEAPON_HEGRENADE    4,
   
WEAPON_XM1014       5,
   
WEAPON_C4           6,
   
WEAPON_MAC10        7,
   
WEAPON_AUG          8,
   
WEAPON_SMOKEGRENADE 9,
   
WEAPON_ELITE        10,
   
WEAPON_FIVESEVEN    11,
   
WEAPON_UMP45        12,
   
WEAPON_SG550        13,
   
WEAPON_GALIL        14,
   
WEAPON_FAMAS        15,
   
WEAPON_USP          16,
   
WEAPON_GLOCK18      17,
   
WEAPON_AWP          18,
   
WEAPON_MP5NAVY      19,
   
WEAPON_M249         20,
   
WEAPON_M3           21,
   
WEAPON_M4A1         22,
   
WEAPON_TMP          23,
   
WEAPON_G3SG1        24,
   
WEAPON_FLASHBANG    25,
   
WEAPON_DEAGLE       26,
   
WEAPON_SG552        27,
   
WEAPON_AK47         28,
   
WEAPON_KNIFE        29,
   
WEAPON_P90          30,
   
WEAPON_ARMOR        31,
   
WEAPON_ARMORHELM    32,
   
WEAPON_DEFUSER      33
}; 
WEAPON_SHIELDGUN - is not a weapon, it's just added as helper.
To check if bot has shield use:
PHP Code:
bool CBot::HasShield (void)
{
   
// this function returns true, if bot has a tactical shield
   
   
return (strncmp (STRING (pev->viewmodel), "models/shield/v_shield_"23) == 0);
}

bool CBot::IsShieldDrawn (void)
{
   
// this function returns true, is the tactical shield is drawn
   
   
if (!HasShield ())
      return 
false;

   return ((
pev->weaponanim == 6) || (pev->weaponanim == 7));

pev = entvars_t structure.
  
Reply With Quote
Re: Getting the enemy's weapon-help plz
Old
  (#5)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: Getting the enemy's weapon-help plz - 11-06-2006

well he wanted to get the current weapon which the enemy is using, which cannot be done using entvars_t::weapons ...

check for STRING(targetEnemy->v.viewmodel) may be a good idea for this. The values are usually "models/v_[weaponname].mdl" so just use strcmp to check it.
  
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