View Single Post
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