本文整理汇总了C++中WeaponsResource::GetWeapon方法的典型用法代码示例。如果您正苦于以下问题:C++ WeaponsResource::GetWeapon方法的具体用法?C++ WeaponsResource::GetWeapon怎么用?C++ WeaponsResource::GetWeapon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WeaponsResource
的用法示例。
在下文中一共展示了WeaponsResource::GetWeapon方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MsgFunc_CurWeapon
//
// 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;
}
示例2: Think
//
// 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);
}
}
示例3: Think
//
// 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"));
}
}
示例4: MsgFunc_CurWeapon
//
// 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;
}