// // CurWeapon: Update hud state with the current weapon and clip count. Ammo // counts are updated with AmmoX. Server assures that the Weapon ammo type // numbers match a real ammo type. // int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf) { static wrect_t nullrc; int fOnTarget = FALSE; BEGIN_READ(pbuf, iSize); int iState = READ_BYTE(); int iId = READ_BYTE(); int iClip = READ_CHAR(); // detect if we're also on target if(iState > 1) { fOnTarget = TRUE; } if(iId < 1) { SetCrosshair(0, nullrc, 0, 0, 0); return 0; } // Is player dead??? if((iId == -1) && (iClip == -1)) { gHUD.m_fPlayerDead = TRUE; gpActiveSel = NULL; return 1; } gHUD.m_fPlayerDead = FALSE; WEAPON *pWeapon = gWR.GetWeapon(iId); if(!pWeapon) return 0; if(iClip < -1) pWeapon->iClip = abs(iClip); else pWeapon->iClip = iClip; if(iState == 0) // we're not the current weapon, so update no more return 1; m_pWeapon = pWeapon; m_fFade = 200.0f; //!!! m_iFlags |= HUD_ACTIVE; return 1; }
// // Think: // Used for selection of weapon menu item. // void CHudAmmo::Think(void) { if ( gHUD.m_fPlayerDead ) return; if ( gHUD.m_iWeaponBits != gWR.iOldWeaponBits ) { gWR.iOldWeaponBits = gHUD.m_iWeaponBits; for (int i = 0; i < MAX_WEAPONS-1; i++ ) { WEAPON *p = gWR.GetWeapon(i); if ( p ) { if ( gHUD.m_iWeaponBits & ( 1 << p->iId ) ) { gWR.PickupWeapon( p ); } else { gWR.DropWeapon( p ); } } } } if (!gpActiveSel) return; // has the player selected one? if (gHUD.m_iKeyBits & IN_ATTACK) { if (gpActiveSel != (WEAPON *)1) { ServerCmd(gpActiveSel->szName); g_weaponselect = gpActiveSel->iId; } gpLastSel = gpActiveSel; gpActiveSel = NULL; gHUD.m_iKeyBits &= ~IN_ATTACK; PlaySound("common/wpn_select.wav", 1); } }
// // Think: // Used for selection of weapon menu item. // void CHudAmmo::Think(void) { if ( gHUD.m_fPlayerDead ) return; if ( gHUD.m_iWeaponBits != gWR.iOldWeaponBits ) { gWR.iOldWeaponBits = gHUD.m_iWeaponBits; for (int i = MAX_WEAPONS-1; i > 0; i-- ) { WEAPON *p = gWR.GetWeapon(i); if ( p ) { if ( gHUD.m_iWeaponBits & ( 1 << p->iId ) ) gWR.PickupWeapon( p ); else gWR.DropWeapon( p ); } } } if (!gpActiveSel) return; // has the player selected one? if (gHUD.m_iKeyBits & IN_ATTACK) { if (gpActiveSel != (WEAPON *)1) { ServerCmd(gpActiveSel->szName); g_weaponselect = gpActiveSel->iId; } gpLastSel = gpActiveSel; gpActiveSel = NULL; gHUD.m_iKeyBits &= ~IN_ATTACK; // Fograin92: Replaced with new audio engine gSoundEngine.PlaySound("common/wpn_select.wav", g_vecZero, SND_2D, 0, CVAR_GET_FLOAT("sm_snd_sfx")); } }
// // CurWeapon: Update hud state with the current weapon and clip count. Ammo // counts are updated with AmmoX. Server assures that the Weapon ammo type // numbers match a real ammo type. // int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf) { static wrect_t nullrc; int fOnTarget = FALSE; BEGIN_READ(pbuf, iSize); int iState = READ_BYTE(); int iId = READ_CHAR(); int iClip = READ_CHAR(); // detect if we're also on target if(iState > 1) { fOnTarget = TRUE; } if(iId < 1) { SetCrosshair(0, nullrc, 0, 0, 0); return 0; } // Is player dead??? if((iId == -1) && (iClip == -1)) { gHUD.m_fPlayerDead = TRUE; gpActiveSel = NULL; return 1; } gHUD.m_fPlayerDead = FALSE; WEAPON *pWeapon = gWR.GetWeapon(iId); if(!pWeapon) return 0; if(iClip < -1) pWeapon->iClip = abs(iClip); else pWeapon->iClip = iClip; if(iState == 0) // we're not the current weapon, so update no more return 1; m_pWeapon = pWeapon; if(!(gHUD.m_iHideHUDDisplay & (HIDEHUD_WEAPONS | HIDEHUD_ALL))) { if(gHUD.m_iFOV >= 90) { // normal crosshairs if(fOnTarget && m_pWeapon->hAutoaim) SetCrosshair(m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255); else SetCrosshair(m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255); } else { // zoomed crosshairs if(fOnTarget && m_pWeapon->hZoomedAutoaim) SetCrosshair(m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255); else SetCrosshair(m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255); } } m_fFade = 200.0f; //!!! m_iFlags |= HUD_ACTIVE; return 1; }
// // CurWeapon: Update hud state with the current weapon and clip count. Ammo // counts are updated with AmmoX. Server assures that the Weapon ammo type // numbers match a real ammo type. // int CHudAmmo::MsgFunc_CurWeapon(const char *pszName, int iSize, void *pbuf ) { static wrect_t nullrc; BEGIN_READ( pbuf, iSize ); int iState = READ_BYTE(); int iId = READ_CHAR(); int iClip = READ_CHAR(); if ( iId < 1 ) { SetCrosshair(0, nullrc, 0, 0, 0); return 0; } if ( g_iUser1 != OBS_IN_EYE ) { // Is player dead??? if ((iId == -1) && (iClip == -1)) { gHUD.m_fPlayerDead = TRUE; gpActiveSel = NULL; return 1; } gHUD.m_fPlayerDead = FALSE; } WEAPON *pWeapon = gWR.GetWeapon( iId ); if ( !pWeapon ) return 0; if ( iClip < -1 ) pWeapon->iClip = abs(iClip); else pWeapon->iClip = iClip; if ( iState == 0 ) // we're not the current weapon, so update no more return 1; m_pWeapon = pWeapon; /*if( gHUD.m_iFOV <= 40 ) { // zoomed crosshairs if (fOnTarget && m_pWeapon->hZoomedAutoaim) SetCrosshair(m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255); else SetCrosshair(m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255); } else { SetCrosshair( 0, nullrc, 0, 0, 0); }*/ m_fFade = 200.0f; //!!! m_iFlags |= HUD_ACTIVE; return 1; }