.:: 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
how to see if the player is "actually" shooting/reloading
Old
  (#1)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default how to see if the player is "actually" shooting/reloading - 29-06-2004

use if (pPlayer->v.oldbuttons & IN_ATTACK) (or IN_RELOAD) sometimes doesn't work correctly (eg, when the player has no ammo in clip but still pressing the mouse)

anyone has a better idea ? thanks.
  
Reply With Quote
Re: how to see if the player is "actually" shooting/reloading
Old
  (#2)
botman
Super Moderator
 
Status: Offline
Posts: 280
Join Date: Jan 2004
Location: Plano, TX
Default Re: how to see if the player is "actually" shooting/reloading - 29-06-2004

Checking which animation they are playing?

botman
  
Reply With Quote
Re: how to see if the player is "actually" shooting/reloading
Old
  (#3)
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: how to see if the player is "actually" shooting/reloading - 29-06-2004

yes, that would work. FoxBot does this (it's a TFC bot). The source code is available so you might want to give it a look



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: how to see if the player is "actually" shooting/reloading
Old
  (#4)
Cheeseh
[rcbot]
 
Cheeseh's Avatar
 
Status: Offline
Posts: 361
Join Date: Dec 2003
Location: China
Default Re: how to see if the player is "actually" shooting/reloading - 29-06-2004

I've tried this myself but it doesn't always work. With my bots in SvenCoop I tried checking if the bots animation was the ACT_RELOAD animation, but no animations had that set as the animation activity... guess it depends on what MOD you use.
  
Reply With Quote
Re: how to see if the player is "actually" shooting/reloading
Old
  (#5)
stefanhendriks
RealBot Author
 
stefanhendriks's Avatar
 
Status: Offline
Posts: 3,088
Join Date: Nov 2003
Location: Netherlands
Default Re: how to see if the player is "actually" shooting/reloading - 29-06-2004

for reloading, i guess you can simply check if a reload button is pressed, and then set a timer so you know the 'animation' is being played. it probably depends per mod, but hence i bet the avarage time taken to reload is 1 to 5 seconds (depending on the gun).


Author of RealBot, "Arrakis" and "Dune 2 - The Maker" | co-Founder of Bots-United | Fundynamic | Blog | E-Mail me
  
Reply With Quote
Re: how to see if the player is "actually" shooting/reloading
Old
  (#6)
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: how to see if the player is "actually" shooting/reloading - 29-06-2004

@Cheeseh:
that's not what FoxBot does. FoxBot hooks the pfnPlaybackEvent() to check for player animations. To my knowledge this function is 100% reliable.



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: how to see if the player is "actually" shooting/reloading
Old
  (#7)
Whistler
Summoner
 
Whistler's Avatar
 
Status: Offline
Posts: 1,499
Join Date: Feb 2004
Location: Mist Village
Default Re: how to see if the player is "actually" shooting/reloading - 01-07-2004

I beg your pardon ?
...from foxbot:
Code:
void pfnPlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay,
   float *origin, float *angles, float fparam1,float fparam2, int iparam1, int iparam2, int bparam1, int bparam2)
{
   if (debug_engine) 
   {
	   fp=fopen("bot.txt","a");
	   fprintf(fp,"pfnPlaybackEvent: %d %x %d %f (%f %f %f) (%f %f %f) %f %f %d %d %d %d\n",
		   flags, 
		   pInvoker,
		   eventindex,
		   delay,
		   (*(Vector *)origin).x,
		   (*(Vector *)origin).y,
		   (*(Vector *)origin).z,
		   (*(Vector *)angles).x,
		   (*(Vector *)angles).y,
		   (*(Vector *)angles).z,
		   fparam1,
		   fparam2,
		   iparam1,
		   iparam2,
		   bparam1,
		   bparam2
		   ); 
	   fclose(fp); 
	   //delay=delay+2;
   }
   if(mr_meta) RETURN_META(MRES_HANDLED);
   (*g_engfuncs.pfnPlaybackEvent)(flags, pInvoker, eventindex, delay, origin, angles, fparam1, fparam2, iparam1, iparam2, bparam1, bparam2);
}
but I don't know whether this is good:

here I'm catching CurWeapon message sent to ALL clients (not just bots), and when ammo decreased means a bullet has fired:
Code:
bool CClient::MessageWrite(void *p) {
   static int iState, iId;

   int iMsgType = g_pServer->GetCurMsgType();
   int iMsgState = g_pServer->GetCurMsgState();

   if (iMsgType == g_General.GetUserMsgId("CurWeapon")) {
      if (iMsgState == 0)
         iState = *(int *)p; // get the state of the current weapon
      else if (iMsgState == 1)
         iId = *(int *)p; // get the weapon ID of current weapon
      else if (iMsgState == 2) {
         int iClip = *(int *)p; // get the ammo currently in the clip for this weapon
         if (iId >= 0 && iId < MAX_WEAPONS) {
            // Ammo amount decreased? Must have fired a bullet...
            if (iId == m_iCurrentWeaponId && iClip < m_rgAmmoInClip[iId])
               m_flLastShootTime = gpGlobals->time; // remember the last bullet time
            m_rgAmmoInClip[iId] = iClip;
            if (iState != 0)
               m_iCurrentWeaponId = iId;
         }
      }
and I use this to see if this client is shooting:
Code:
class CClient
{
public:
   .........
   inline bool   IsShooting(void)          { return m_flLastShootTime + 0.5 > gpGlobals->time; }
  
Reply With Quote
Re: how to see if the player is "actually" shooting/reloading
Old
  (#8)
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: how to see if the player is "actually" shooting/reloading - 01-07-2004

eh? well, that changed, then.

I am positive they DID use pfnPlaybackEvent() and I recall Tom (RedFox) explaining me over there at botman's why it was just what I wanted and how to use this function to hook for various player animations.



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