本文整理汇总了C++中CBasePlayerWeapon类的典型用法代码示例。如果您正苦于以下问题:C++ CBasePlayerWeapon类的具体用法?C++ CBasePlayerWeapon怎么用?C++ CBasePlayerWeapon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBasePlayerWeapon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateClientData
/*
=================
UpdateClientData
Data sent to current client only
engine sets cd to 0 before calling.
=================
*/
void UpdateClientData ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd )
{
cd->flags = ent->v.flags;
cd->health = ent->v.health;
cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) );
cd->waterlevel = ent->v.waterlevel;
cd->watertype = ent->v.watertype;
cd->weapons = ent->v.weapons;
// Vectors
cd->origin = ent->v.origin;
cd->velocity = ent->v.velocity;
cd->view_ofs = ent->v.view_ofs;
cd->punchangle = ent->v.punchangle;
cd->bInDuck = ent->v.bInDuck;
cd->flTimeStepSound = ent->v.flTimeStepSound;
cd->flDuckTime = ent->v.flDuckTime;
cd->flSwimTime = ent->v.flSwimTime;
cd->waterjumptime = ent->v.teleport_time;
strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) );
cd->maxspeed = ent->v.maxspeed;
cd->fov = ent->v.fov;
cd->weaponanim = ent->v.weaponanim;
cd->pushmsec = ent->v.pushmsec;
// Spectator
cd->iuser1 = ent->v.iuser1;
cd->iuser2 = ent->v.iuser2;
if ( sendweapons )
{
entvars_t *pev = (entvars_t *)&ent->v;
CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev );
if ( pl )
{
cd->m_flNextAttack = pl->m_flNextAttack;
if ( pl->m_pActiveItem )
{
CBasePlayerWeapon *gun;
gun = (CBasePlayerWeapon *)pl->m_pActiveItem->GetWeaponPtr();
if ( gun && gun->UseDecrement() )
{
ItemInfo II;
memset( &II, 0, sizeof( II ) );
gun->GetItemInfo( &II );
cd->m_iId = II.iId;
}
}
}
}
}
示例2: GetWeaponData
int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
{
#if defined( CLIENT_WEAPONS )
int i;
weapon_data_t *item;
entvars_t *pev = &player->v;
CBasePlayer *pl = ( CBasePlayer *) CBasePlayer::Instance( pev );
CBasePlayerWeapon *gun;
ItemInfo II;
memset( info, 0, 32 * sizeof( weapon_data_t ) );
if ( !pl )
return 1;
// go through all of the weapons and make a list of the ones to pack
for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ )
{
if ( pl->m_rgpPlayerItems[ i ] )
{
// there's a weapon here. Should I pack it?
CBasePlayerItem *pPlayerItem = pl->m_rgpPlayerItems[ i ];
while ( pPlayerItem )
{
gun = (CBasePlayerWeapon *)pPlayerItem->GetWeaponPtr();
if ( gun && gun->UseDecrement() )
{
// Get The ID.
memset( &II, 0, sizeof( II ) );
gun->GetItemInfo( &II );
if ( II.iId >= 0 && II.iId < 32 )
{
item = &info[ II.iId ];
item->m_iId = II.iId;
item->m_iClip = gun->m_iClip;
item->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle, -0.001 );
item->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack, -0.001 );
item->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack, -0.001 );
item->m_fInReload = gun->m_fInReload;
}
}
pPlayerItem = pPlayerItem->m_pNext;
}
}
}
#else
memset( info, 0, 32 * sizeof( weapon_data_t ) );
#endif
return 1;
}
示例3: UpdateWeaponHUD
//
// Think:
// Used for selection of weapon menu item.
//
void CHudAmmo::Think()
{
if( m_bNeedsLocalUpdate )
{
m_bNeedsLocalUpdate = false;
if( m_pWeapon )
UpdateWeaponHUD( m_pWeapon, m_bOnTarget );
}
if ( gHUD.m_bPlayerDead )
return;
CBasePlayer* pPlayer = g_Prediction.GetLocalPlayer();
if ( gHUD.m_iWeaponBits != pPlayer->pev->weapons )
{
pPlayer->pev->weapons = gHUD.m_iWeaponBits;
for (int i = MAX_WEAPONS-1; i > 0; i-- )
{
CBasePlayerWeapon *p = g_Prediction.GetWeapon(i);
if ( p && p->GetWeaponInfo() )
{
if ( gHUD.m_iWeaponBits & ( 1 << p->GetWeaponInfo()->GetID() ) )
pPlayer->AddPlayerItem( p );
else
pPlayer->RemovePlayerItem( p );
}
}
}
if( !m_pActiveSel )
return;
// has the player selected one?
if (gHUD.m_iKeyBits & IN_ATTACK)
{
if ( m_pActiveSel != (CBasePlayerWeapon *)1)
{
ServerCmd( m_pActiveSel->GetWeaponInfo()->GetWeaponName());
g_weaponselect = m_pActiveSel->GetWeaponInfo()->GetID();
}
m_pLastSel = m_pActiveSel;
m_pActiveSel = nullptr;
gHUD.m_iKeyBits &= ~IN_ATTACK;
PlaySound("common/wpn_select.wav", 1);
}
}
示例4: MaxAmmoCarry
void CWeaponBox::Touch( CBaseEntity *pOther )
{
if ( !(pev->flags & FL_ONGROUND ) ) return;
if ( !pOther->IsPlayer() ) return;
if ( !pOther->IsAlive() ) return;
CBasePlayer *pPlayer = (CBasePlayer *)pOther;
int i;
// dole out ammo
for ( i = 0 ; i < MAX_AMMO_SLOTS ; i++ )
{
if ( !FStringNull( m_rgiszAmmo[ i ] ) )
{
// there's some ammo of this type.
pPlayer->GiveAmmo( m_rgAmmo[ i ], (char *)STRING( m_rgiszAmmo[ i ] ), MaxAmmoCarry( m_rgiszAmmo[ i ] ) );
// now empty the ammo from the weaponbox since we just gave it to the player
m_rgiszAmmo[ i ] = iStringNull;
m_rgAmmo[ i ] = 0;
}
}
// go through my weapons and try to give the usable ones to the player.
// it's important the the player be given ammo first, so the weapons code doesn't refuse
// to deploy a better weapon that the player may pick up because he has no ammo for it.
for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ )
{
if ( m_rgpPlayerItems[ i ] )
{
CBasePlayerWeapon *pItem;
// have at least one weapon in this slot
while ( m_rgpPlayerItems[i] )
{
pItem = m_rgpPlayerItems[i];
m_rgpPlayerItems[i] = m_rgpPlayerItems[i]->m_pNext; // unlink this weapon from the box
if( pPlayer->AddPlayerItem( pItem ))
pItem->AttachToPlayer( pPlayer );
}
}
}
EMIT_SOUND( pOther->edict(), CHAN_BODY, "items/gunpickup2.wav", 1, ATTN_NORM );
SetTouch( NULL );
UTIL_Remove( this );
}
示例5: HUD_GetWeaponEnabled
bool HUD_GetWeaponEnabled(int inID)
{
ASSERT(inID >= 0);
ASSERT(inID < 32);
// puzl: 497 - use the enabled state in the associated WEAPON instead of the CBasePlayerWeapon's iuser3
bool theWeaponEnabled = false;
CBasePlayerWeapon* theWeapon = g_pWpns[inID];
if(theWeapon)
{
ItemInfo theItemInfo;
theWeapon->GetItemInfo(&theItemInfo);
WEAPON *pWeapon = gWR.GetWeapon( theItemInfo.iId );
if ( pWeapon != 0 ) {
theWeaponEnabled = (pWeapon->iEnabled == 1);
}
}
return theWeaponEnabled;
}
示例6: Kill
void CWeaponBox::Kill( void )
{
CBasePlayerWeapon *pWeapon;
int i;
// destroy the weapons
for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ )
{
pWeapon = m_rgpPlayerItems[ i ];
while ( pWeapon )
{
pWeapon->SetThink( Remove );
pWeapon->SetNextThink( 0.1 );
pWeapon = pWeapon->m_pNext;
}
}
// remove the box
UTIL_Remove( this );
}
示例7: HUD_WeaponsPostThink
/*
=====================
HUD_WeaponsPostThink
Run Weapon firing code on client
=====================
*/
void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cmd, double time, unsigned int random_seed )
{
int i;
int buttonsChanged;
CBasePlayerWeapon *pWeapon = NULL;
CBasePlayerWeapon *pCurrent;
weapon_data_t nulldata, *pfrom, *pto;
static int lasthealth;
memset( &nulldata, 0, sizeof( nulldata ) );
HUD_InitClientWeapons();
// Get current clock
gpGlobals->time = time;
// Fill in data based on selected weapon
// FIXME, make this a method in each weapon? where you pass in an entity_state_t *?
switch ( from->client.m_iId )
{
case WEAPON_DISC:
pWeapon = &g_Disc;
break;
}
// We are not predicting the current weapon, just bow out here.
if ( !pWeapon )
return;
for ( i = 0; i < 32; i++ )
{
pCurrent = g_pWpns[ i ];
if ( !pCurrent )
{
continue;
}
pfrom = &from->weapondata[ i ];
pCurrent->m_fInReload = pfrom->m_fInReload;
pCurrent->m_iClip = pfrom->m_iClip;
pCurrent->m_flNextPrimaryAttack = pfrom->m_flNextPrimaryAttack;
pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack;
pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle;
// Ricochet uses m_iClip to transmit current/primary ammo to client
if ( pWeapon == pCurrent )
{
player.m_rgAmmo[pCurrent->m_iPrimaryAmmoType] = pfrom->m_iClip;
}
}
// For random weapon events, use this seed to seed random # generator
player.random_seed = random_seed;
// Get old buttons from previous state.
player.m_afButtonLast = from->playerstate.oldbuttons;
// Which buttsons chave changed
buttonsChanged = (player.m_afButtonLast ^ cmd->buttons); // These buttons have changed this frame
// Debounced button codes for pressed/released
// The changed ones still down are "pressed"
player.m_afButtonPressed = buttonsChanged & cmd->buttons;
// The ones not down are "released"
player.m_afButtonReleased = buttonsChanged & (~cmd->buttons);
// Set player variables that weapons code might check/alter
player.pev->button = cmd->buttons;
player.pev->velocity = from->client.velocity;
player.pev->flags = from->client.flags;
player.pev->deadflag = from->client.deadflag;
player.pev->waterlevel = from->client.waterlevel;
player.pev->maxspeed = from->client.maxspeed;
player.pev->fov = from->client.fov;
player.pev->weaponanim = from->client.weaponanim;
player.pev->viewmodel = from->client.viewmodel;
player.m_flNextAttack = from->client.m_flNextAttack;
player.m_flBackupTime = from->client.fuser1;
player.m_Activity = (Activity)(int)from->client.fuser2;
player.m_flThrowTime = from->client.fuser3;
player.m_vecOldVelocity = from->client.vuser1;
player.pev->sequence = from->playerstate.sequence;
player.pev->gaitsequence = from->playerstate.gaitsequence;
player.pev->angles = from->playerstate.angles;
// Point to current weapon object
if ( from->client.m_iId )
{
//.........这里部分代码省略.........
示例8: ScaleColors
//
// Draw Weapon Menu
//
int CHudAmmo::DrawWList(float flTime)
{
int r,g,b,x,y,a,i;
if ( !m_pActiveSel )
return 0;
int iActiveSlot;
if ( m_pActiveSel == ( CBasePlayerWeapon *)1 )
iActiveSlot = -1; // current slot has no weapons
else
iActiveSlot = m_pActiveSel->GetWeaponInfo()->GetBucket();
x = 10; //!!!
y = 10; //!!!
CBasePlayer* pPlayer = g_Prediction.GetLocalPlayer();
// Ensure that there are available choices in the active slot
if ( iActiveSlot > 0 )
{
if ( !pPlayer->GetFirstPos( iActiveSlot ) )
{
m_pActiveSel = ( CBasePlayerWeapon *)1;
iActiveSlot = -1;
}
}
// Shepard : determine how many buckets we should draw
int iBucketsToDraw = 0;
for ( i = 0; i < MAX_WEAPON_SLOTS; i++ )
{
for ( int j = 0; j < MAX_WEAPONS; j++ )
{
CBasePlayerWeapon *pWeapon = pPlayer->GetWeapon( i, j );
if ( pWeapon && pWeapon->GetWeaponInfo() && pWeapon->GetWeaponInfo()->GetBucket() > iBucketsToDraw )
iBucketsToDraw = pWeapon->GetWeaponInfo()->GetBucket();
}
}
iBucketsToDraw++;
// Draw top line
for ( i = 0; i < iBucketsToDraw; i++ )
{
int iWidth;
gHUD.GetPrimaryColor().UnpackRGB(r,g,b);
if ( iActiveSlot == i )
a = 255;
else
a = 192;
ScaleColors(r, g, b, 255);
SPR_Set(gHUD.GetSprite(m_HUD_bucket0 + i), r, g, b );
// make active slot wide enough to accomodate gun pictures
if ( i == iActiveSlot )
{
CBasePlayerWeapon *p = pPlayer->GetFirstPos(iActiveSlot);
if ( p )
iWidth = p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.right - p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.left;
else
iWidth = m_iBucketWidth;
}
else
iWidth = m_iBucketWidth;
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_bucket0 + i));
x += iWidth + 5;
}
a = 128; //!!!
x = 10;
// Draw all of the buckets
for (i = 0; i < iBucketsToDraw; i++)
{
y = m_iBucketHeight + 10;
// If this is the active slot, draw the bigger pictures,
// otherwise just draw boxes
if ( i == iActiveSlot )
{
CBasePlayerWeapon *p = pPlayer->GetFirstPos( i );
int iWidth = m_iBucketWidth;
if ( p )
iWidth = p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.right - p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.left;
for ( int iPos = 0; iPos < MAX_WEAPONS; iPos++ )
{
p = pPlayer->GetWeapon( i, iPos );
if ( !p || !p->GetWeaponInfo() )
//.........这里部分代码省略.........
示例9: DrawWList
bool CHudAmmo::Draw(float flTime)
{
int a, x, y, r, g, b;
int AmmoWidth;
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
return true;
if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
return true;
// Draw Weapon Menu
DrawWList(flTime);
// Draw ammo pickup history
gHR.DrawAmmoHistory( flTime );
if (!(m_iFlags & HUD_ACTIVE))
return false;
if (!m_pWeapon)
return false;
if( m_pCrosshair->value != 0 && m_hCrosshair != INVALID_HSPRITE )
{
float flScale;
switch( static_cast<int>( m_pCrosshairMode->value ) )
{
default:
case CROSS_NATIVESCALE:
flScale = 1;
break;
case CROSS_RESSCALE:
flScale = max( ( ScreenWidth / 640.0 ) * 0.75, 1.0 );
break;
case CROSS_USERSCALE:
flScale = abs( m_pCrosshairScale->value );
break;
}
class CCrosshairTriCallback : public ITriCoordFallback
{
public:
void Calculate( HSPRITE hSprite, const int frame, const wrect_t& rect, const float flScale, int& x, int& y ) override
{
x = ( ScreenWidth - ( ( rect.right - rect.left ) ) ) / 2;
y = ( ScreenHeight - ( ( rect.bottom - rect.top ) ) ) / 2;
}
};
CCrosshairTriCallback callback;
Tri_DrawScaledSprite( m_hCrosshair, 0, m_iR, m_iG, m_iB, 255, kRenderTransTexture, flScale, callback, &m_CrosshairRC );
}
CBasePlayerWeapon *pw = m_pWeapon; // shorthand
// SPR_Draw Ammo
if( !pw->GetWeaponInfo()->GetPrimaryAmmo() && !pw->GetWeaponInfo()->GetSecondaryAmmo() )
return false;
int iFlags = DHN_DRAWZERO; // draw 0 values
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
a = (int) max( static_cast<float>( MIN_ALPHA ), m_fFade );
if (m_fFade > 0)
m_fFade -= (gHUD.m_flTimeDelta * 20);
gHUD.GetPrimaryColor().UnpackRGB(r,g,b);
ScaleColors(r, g, b, a );
// Does this weapon have a clip?
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight/2;
CBasePlayer* pPlayer = g_Prediction.GetLocalPlayer();
// Does weapon have any ammo at all?
if ( auto pAmmo = pw->GetWeaponInfo()->GetPrimaryAmmo() )
{
const auto& ammo = m_pWeapon->GetWeaponInfo()->GetHUDInfo()->GetPrimaryAmmo();
int iIconWidth = ammo.rect.right - ammo.rect.left;
if (pw->m_iClientClip >= 0)
{
// room for the number and the '|' and the current ammo
x = ScreenWidth - (8 * AmmoWidth) - iIconWidth;
x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pw->m_iClientClip, r, g, b);
wrect_t rc;
rc.top = 0;
rc.left = 0;
rc.right = AmmoWidth;
//.........这里部分代码省略.........
示例10: CVAR_GET_FLOAT
void CHudAmmo::SelectSlot( int iSlot, const bool fAdvance, int iDirection )
{
if ( gHUD.m_Menu.m_fMenuDisplayed && !fAdvance && (iDirection == 1) )
{ // menu is overriding slot use commands
gHUD.m_Menu.SelectMenuItem( iSlot + 1 ); // slots are one off the key numbers
return;
}
if ( iSlot > MAX_WEAPON_SLOTS )
return;
if ( gHUD.m_bPlayerDead || gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) )
return;
if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
return;
if ( ! ( gHUD.m_iWeaponBits & ~(1<<(WEAPON_SUIT)) ))
return;
CBasePlayerWeapon *p = NULL;
bool fastSwitch = CVAR_GET_FLOAT( "hud_fastswitch" ) != 0;
CBasePlayer* pPlayer = g_Prediction.GetLocalPlayer();
if ( ( m_pActiveSel == NULL) || ( m_pActiveSel == ( CBasePlayerWeapon *)1) || (iSlot != m_pActiveSel->GetWeaponInfo()->GetBucket()) )
{
PlaySound( "common/wpn_hudon.wav", 1 );
p = pPlayer->GetFirstPos( iSlot );
if ( p && fastSwitch ) // check for fast weapon switch mode
{
// if fast weapon switch is on, then weapons can be selected in a single keypress
// but only if there is only one item in the bucket
CBasePlayerWeapon *p2 = pPlayer->GetNextActivePos( p->GetWeaponInfo()->GetBucket(), p->GetWeaponInfo()->GetPosition() );
if ( !p2 )
{ // only one active item in bucket, so change directly to weapon
ServerCmd( p->GetWeaponInfo()->GetWeaponName() );
g_weaponselect = p->GetWeaponInfo()->GetID();
return;
}
}
}
else
{
PlaySound("common/wpn_moveselect.wav", 1);
if ( m_pActiveSel )
p = pPlayer->GetNextActivePos( m_pActiveSel->GetWeaponInfo()->GetBucket(), m_pActiveSel->GetWeaponInfo()->GetPosition() );
if ( !p )
p = pPlayer->GetFirstPos( iSlot );
}
if ( !p ) // no selection found
{
// just display the weapon list, unless fastswitch is on just ignore it
if ( !fastSwitch )
m_pActiveSel = ( CBasePlayerWeapon *)1;
else
m_pActiveSel = nullptr;
}
else
m_pActiveSel = p;
}
示例11: HUD_WeaponsPostThink
/*
=====================
HUD_WeaponsPostThink
Run Weapon firing code on client
=====================
*/
void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cmd, double time, unsigned int random_seed )
{
int i;
int buttonsChanged;
CBasePlayerWeapon* pCurrent = NULL;
weapon_data_t nulldata, *pfrom, *pto;
static int lasthealth;
memset( &nulldata, 0, sizeof( nulldata ) );
HUD_InitClientWeapons();
// Get current clock
gpGlobals->time = time;
// Fill in data based on selected weapon
// FIXME, make this a method in each weapon? where you pass in an entity_state_t *?
// Store pointer to our destination entity_state_t so we can get our origin, etc. from it
CBasePlayerWeapon* pWeapon = HUD_GetWeaponForID(from->client.m_iId);
// for setting up events on the client
g_finalstate = to;
// If we are running events/etc. go ahead and see if we
// managed to die between last frame and this one
// If so, run the appropriate player killed or spawn function
if ( g_runfuncs )
{
if ( to->client.health <= 0 && lasthealth > 0 )
{
player.Killed( NULL, 0 );
}
else if ( to->client.health > 0 && lasthealth <= 0 )
{
player.Spawn();
}
lasthealth = to->client.health;
}
// We are not predicting the current weapon, just bow out here.
if ( !pWeapon )
return;
for ( i = 0; i < 32; i++ )
{
pCurrent = g_pWpns[ i ];
if ( !pCurrent )
{
continue;
}
pfrom = &from->weapondata[ i ];
pCurrent->m_fInReload = pfrom->m_fInReload;
pCurrent->m_fInSpecialReload = pfrom->m_fInSpecialReload;
// pCurrent->m_flPumpTime = pfrom->m_flPumpTime;
pCurrent->m_iClip = pfrom->m_iClip;
pCurrent->m_flNextPrimaryAttack = pfrom->m_flNextPrimaryAttack;
pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack;
pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle;
if(pWeapon && (pWeapon->m_iId == pfrom->m_iId))
{
// Predict clip
gHUD.m_Ammo.SetCurrentClip(pfrom->m_iClip);
AvHBasePlayerWeapon* theWeapon = dynamic_cast<AvHBasePlayerWeapon*>(pWeapon);
if(theWeapon)
{
gHUD.SetCurrentWeaponData(pWeapon->m_iId, theWeapon->GetEnabledState());
}
//gHUD.SetClientDebugCSP(pfrom, from->client.m_flNextAttack);
}
// Tell HUD what energy level is needed to use weapon, so alien HUD can indicate this
float theEnergyLevel = 0.0f;
AvHMUGetEnergyCost((AvHWeaponID)(pWeapon->m_iId), theEnergyLevel);
gHUD.SetCurrentUseableEnergyLevel(theEnergyLevel);
// New SDK stuff...needed?
// pCurrent->pev->fuser1 = pfrom->fuser1;
pCurrent->m_flStartThrow = pfrom->fuser2;
pCurrent->m_flReleaseThrow = pfrom->fuser3;
// pCurrent->m_chargeReady = pfrom->iuser1;
// pCurrent->m_fInAttack = pfrom->iuser2;
pCurrent->pev->iuser3 = pfrom->iuser3;
// pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[2];
pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[0];
// player.m_rgAmmo[ pCurrent->m_iPrimaryAmmoType ] = (int)from->client.vuser4[1];
// player.m_rgAmmo[ pCurrent->m_iSecondaryAmmoType ] = (int)from->client.vuser4[2];
//.........这里部分代码省略.........
示例12: HUD_WeaponsPostThink
/*
=====================
HUD_WeaponsPostThink
Run Weapon firing code on client
=====================
*/
void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cmd, double time, unsigned int random_seed )
{
int i;
int buttonsChanged;
CBasePlayerWeapon *pWeapon = NULL;
CBasePlayerWeapon *pCurrent;
weapon_data_t nulldata, *pfrom, *pto;
static int lasthealth;
memset( &nulldata, 0, sizeof( nulldata ) );
HUD_InitClientWeapons();
// Get current clock
gpGlobals->time = time;
// Fill in data based on selected weapon
// FIXME, make this a method in each weapon? where you pass in an entity_state_t *?
switch ( from->client.m_iId )
{
case WEAPON_GLOCK:
pWeapon = &g_QuakeGun;
break;
}
// Store pointer to our destination entity_state_t so we can get our origin, etc. from it
// for setting up events on the client
g_finalstate = to;
// If we are running events/etc. go ahead and see if we
// managed to die between last frame and this one
// If so, run the appropriate player killed or spawn function
if ( g_runfuncs )
{
if ( to->client.health <= 0 && lasthealth > 0 )
{
player.Killed( NULL, 0 );
}
else if ( to->client.health > 0 && lasthealth <= 0 )
{
player.Spawn();
}
lasthealth = to->client.health;
}
// We are not predicting the current weapon, just bow out here.
if ( !pWeapon )
return;
gpGlobals->deathmatch = from->client.iuser4;
for ( i = 0; i < 32; i++ )
{
pCurrent = g_pWpns[ i ];
if ( !pCurrent )
{
continue;
}
pfrom = &from->weapondata[ i ];
pCurrent->m_fInReload = pfrom->m_fInReload;
pCurrent->m_iClip = pfrom->m_iClip;
pCurrent->m_flNextPrimaryAttack = pfrom->m_flNextPrimaryAttack;
pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack;
pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle;
}
// For random weapon events, use this seed to seed random # generator
player.random_seed = random_seed;
// Get old buttons from previous state.
player.m_afButtonLast = from->playerstate.oldbuttons;
// Which buttsons chave changed
buttonsChanged = (player.m_afButtonLast ^ cmd->buttons); // These buttons have changed this frame
// Debounced button codes for pressed/released
// The changed ones still down are "pressed"
player.m_afButtonPressed = buttonsChanged & cmd->buttons;
// The ones not down are "released"
player.m_afButtonReleased = buttonsChanged & (~cmd->buttons);
// Set player variables that weapons code might check/alter
player.pev->button = cmd->buttons;
player.pev->velocity = from->client.velocity;
player.pev->flags = from->client.flags;
player.pev->deadflag = from->client.deadflag;
g_iWaterLevel = player.pev->waterlevel = from->client.waterlevel;
player.pev->maxspeed = from->client.maxspeed;
//.........这里部分代码省略.........
示例13: HUD_WeaponsPostThink
/*
=====================
HUD_WeaponsPostThink
Run Weapon firing code on client
=====================
*/
void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cmd, double time, unsigned int random_seed )
{
int i;
int buttonsChanged;
CBasePlayerWeapon *pWeapon = NULL;
static int lasthealth;
int flags;
HUD_InitClientWeapons();
// Get current clock
gpGlobals->time = time;
// Fill in data based on selected weapon
switch ( from->client.m_iId )
{
case WEAPON_P228:
pWeapon = &g_P228;
break;
case WEAPON_SCOUT:
pWeapon = &g_SCOUT;
break;
case WEAPON_HEGRENADE:
pWeapon = &g_HEGrenade;
break;
case WEAPON_XM1014:
pWeapon = &g_XM1014;
break;
case WEAPON_C4:
pWeapon = &g_C4;
break;
case WEAPON_MAC10:
pWeapon = &g_MAC10;
break;
case WEAPON_AUG:
pWeapon = &g_AUG;
break;
case WEAPON_SMOKEGRENADE:
pWeapon = &g_SmokeGrenade;
break;
case WEAPON_ELITE:
pWeapon = &g_ELITE;
break;
case WEAPON_FIVESEVEN:
pWeapon = &g_FiveSeven;
break;
case WEAPON_UMP45:
pWeapon = &g_UMP45;
break;
case WEAPON_SG550:
pWeapon = &g_SG550;
break;
case WEAPON_GALIL:
pWeapon = &g_Galil;
break;
case WEAPON_FAMAS:
pWeapon = &g_Famas;
break;
case WEAPON_USP:
pWeapon = &g_USP;
break;
case WEAPON_GLOCK18:
pWeapon = &g_GLOCK18;
break;
case WEAPON_AWP:
pWeapon = &g_AWP;
break;
case WEAPON_MP5N:
pWeapon = &g_MP5N;
break;
case WEAPON_M249:
pWeapon = &g_M249;
break;
case WEAPON_M3:
//.........这里部分代码省略.........
示例14: HUD_WeaponsPostThink
/*
=====================
HUD_WeaponsPostThink
Run Weapon firing code on client
=====================
*/
void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cmd, double time, unsigned int random_seed )
{
int i;
int buttonsChanged;
CBasePlayerWeapon *pWeapon = NULL;
CBasePlayerWeapon *pCurrent;
weapon_data_t nulldata, *pfrom, *pto;
static int lasthealth;
memset( &nulldata, 0, sizeof( nulldata ) );
HUD_InitClientWeapons();
// Get current clock
gpGlobals->time = time;
// Fill in data based on selected weapon
// FIXME, make this a method in each weapon? where you pass in an entity_state_t *?
switch ( from->client.m_iId )
{
case WEAPON_CROWBAR:
pWeapon = &g_Crowbar;
break;
case WEAPON_GLOCK:
pWeapon = &g_Glock;
break;
case WEAPON_PYTHON:
pWeapon = &g_Python;
break;
case WEAPON_MP5:
pWeapon = &g_Mp5;
break;
case WEAPON_CROSSBOW:
pWeapon = &g_Crossbow;
break;
case WEAPON_SHOTGUN:
pWeapon = &g_Shotgun;
break;
case WEAPON_RPG:
pWeapon = &g_Rpg;
break;
case WEAPON_GAUSS:
pWeapon = &g_Gauss;
break;
case WEAPON_EGON:
pWeapon = &g_Egon;
break;
case WEAPON_HORNETGUN:
pWeapon = &g_HGun;
break;
case WEAPON_HANDGRENADE:
pWeapon = &g_HandGren;
break;
case WEAPON_SATCHEL:
pWeapon = &g_Satchel;
break;
case WEAPON_TRIPMINE:
pWeapon = &g_Tripmine;
break;
case WEAPON_SNARK:
pWeapon = &g_Snark;
break;
}
// Store pointer to our destination entity_state_t so we can get our origin, etc. from it
// for setting up events on the client
g_finalstate = to;
// If we are running events/etc. go ahead and see if we
// managed to die between last frame and this one
// If so, run the appropriate player killed or spawn function
if ( g_runfuncs )
{
if ( to->client.health <= 0 && lasthealth > 0 )
{
player.Killed( NULL, 0 );
}
else if ( to->client.health > 0 && lasthealth <= 0 )
{
//.........这里部分代码省略.........
示例15: SERVER_COMMAND
/* <18b4aa> ../cstrike/dlls/training_gamerules.cpp:52 */
void CHalfLifeTraining::__MAKE_VHOOK(PlayerThink)(CBasePlayer *pPlayer)
{
if (pPlayer->pev->radsuit_finished && gpGlobals->time > pPlayer->pev->radsuit_finished)
{
SERVER_COMMAND("reload\n");
}
if (!pPlayer->m_iAccount)
{
if (pPlayer->pev->scale)
{
pPlayer->m_iAccount = (int)pPlayer->pev->scale;
}
}
if (pPlayer->m_iTeam == UNASSIGNED)
{
pPlayer->SetProgressBarTime(0);
pPlayer->m_bHasDefuser = pPlayer->pev->ideal_yaw != 0;
}
m_iHostagesRescued = 0;
m_iRoundTimeSecs = (int)(gpGlobals->time + 1.0f);
m_bFreezePeriod = FALSE;
g_fGameOver = FALSE;
pPlayer->m_iTeam = CT;
pPlayer->m_bCanShoot = true;
pPlayer->m_fLastMovement = gpGlobals->time;
if (pPlayer->m_pActiveItem)
pPlayer->m_iHideHUD &= ~HIDEHUD_WEAPONS;
else
pPlayer->m_iHideHUD |= HIDEHUD_WEAPONS;
if (pPlayer->HasNamedPlayerItem("weapon_c4"))
{
if (pPlayer->m_rgAmmo[ pPlayer->GetAmmoIndex("C4") ] <= 0)
{
pPlayer->m_bHasC4 = false;
CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)pPlayer->m_pActiveItem;
if (FClassnameIs(pWeapon->pev, "weapon_c4"))
{
pPlayer->pev->weapons &= ~(1 << pWeapon->m_iId);
pPlayer->RemovePlayerItem(pWeapon);
pWeapon->Drop();
}
}
else
pPlayer->m_bHasC4 = true;
}
if (!pPlayer->m_bVGUIMenus)
{
if (fVGUIMenus)
{
pPlayer->m_bVGUIMenus = fVGUIMenus;
}
}
CGrenade *pBomb = NULL;
while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade")) != NULL)
{
if (pBomb->m_pentCurBombTarget != NULL)
pBomb->m_bStartDefuse = true;
}
if (pPlayer->m_signals.GetState() & SIGNAL_BUY)
{
if (!fInBuyArea)
{
FillAccountTime = 1;
if (!fVisitedBuyArea)
{
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, NULL, pPlayer->pev);
WRITE_BYTE(STATUSICON_FLASH);
WRITE_STRING("buyzone");
WRITE_BYTE(0);
WRITE_BYTE(160);
WRITE_BYTE(0);
MESSAGE_END();
}
}
fInBuyArea = TRUE;
if (pPlayer->m_iAccount < 16000 && FillAccountTime == 0.0f)
FillAccountTime = gpGlobals->time + 5;
if (FillAccountTime != 0.0f && gpGlobals->time > FillAccountTime)
{
if (!fVisitedBuyArea)
{
MESSAGE_BEGIN(MSG_ONE, gmsgBlinkAcct, NULL, pPlayer->pev);
WRITE_BYTE(3);
MESSAGE_END();
//.........这里部分代码省略.........