Browse Source

Make reload for weapon_pepsigun,fixes for zombozo and rock.

clcampaign
RAINBOW2000 8 years ago
parent
commit
c085df6ffd
  1. 2
      dlls/cross.cpp
  2. 2
      dlls/crowbar.cpp
  3. 2
      dlls/katana.cpp
  4. 6
      dlls/needle.cpp
  5. 278
      dlls/pepsigun.cpp
  6. 200
      dlls/rock.cpp
  7. 271
      dlls/shotgun(1).cpp
  8. 386
      dlls/shotgun(2).cpp
  9. 1
      dlls/weapons.cpp
  10. 1
      dlls/weapons.h
  11. 54
      dlls/zombozo.cpp

2
dlls/cross.cpp

@ -286,7 +286,7 @@ void CCrowbar2::Precache( void ) @@ -286,7 +286,7 @@ void CCrowbar2::Precache( void )
PRECACHE_SOUND( "g_bounce2.wav" );
UTIL_PrecacheOther( "crossbow2_bolt" );
UTIL_PrecacheOther( "crowbar2_bolt" );
m_usCrossbow12 = PRECACHE_EVENT( 1, "events/crowbar.sc" );
m_usCrossbow22 = PRECACHE_EVENT( 1, "events/crowbar.sc" );

2
dlls/crowbar.cpp

@ -168,7 +168,7 @@ void CCrowbar::SecondaryAttack( void ) @@ -168,7 +168,7 @@ void CCrowbar::SecondaryAttack( void )
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "taunts/taunt4.wav", 1, ATTN_NORM );
break;
};
pev->nextthink = gpGlobals->time + 2;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1;
}
void CCrowbar::Smack()

2
dlls/katana.cpp

@ -86,6 +86,7 @@ void CKatana::Precache( void ) @@ -86,6 +86,7 @@ void CKatana::Precache( void )
PRECACHE_SOUND( "weapons/katana_hitbod2.wav" );
PRECACHE_SOUND( "weapons/katana_hitbod3.wav" );
PRECACHE_SOUND( "weapons/katana_miss1.wav" );
PRECACHE_SOUND( "weapons/katana_draw.wav" );
m_usKatana = PRECACHE_EVENT( 1, "events/crowbar.sc" );
@ -109,6 +110,7 @@ int CKatana::GetItemInfo( ItemInfo *p ) @@ -109,6 +110,7 @@ int CKatana::GetItemInfo( ItemInfo *p )
BOOL CKatana::Deploy()
{
return DefaultDeploy( "models/v_katana.mdl", "models/p_katana.mdl", CROWBAR_DRAW, "katana" );
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/katana_draw.wav", 1, ATTN_NORM );
}
void CKatana::Holster( int skiplocal /* = 0 */ )

6
dlls/needle.cpp

@ -110,12 +110,8 @@ void CNeedle::Holster( int skiplocal /* = 0 */ ) @@ -110,12 +110,8 @@ void CNeedle::Holster( int skiplocal /* = 0 */ )
void CNeedle::PrimaryAttack()
{
SendWeaponAnim( NEEDLE_GIVESHOT );
switch( RANDOM_LONG( 0, 0 ) )
{
case 0:
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5;
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/needleshot.wav", 1, ATTN_NORM );
break;
}
}

278
dlls/pepsigun.cpp

@ -1,7 +1,3 @@ @@ -1,7 +1,3 @@
/*
Здесь был rainbow
*/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
@ -9,44 +5,45 @@ @@ -9,44 +5,45 @@
#include "weapons.h"
#include "nodes.h"
#include "player.h"
#include "gamerules.h"
#define HANDGRENADE_PRIMARY_VOLUME 450
#define WEAPON_PEPSIGUN 22
enum handgrenade_e
{
HANDGRENADE_IDLE = 0,
HANDGRENADE_FIRE,
HANDGRENADE_OPEN,
HANDGRENADE_INSERT,
HANDGRENADE_CLOSE,
HANDGRENADE_DRAW
};
class CPepsigun : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 4; }
int iItemSlot( ) { return 3; }
int GetItemInfo(ItemInfo *p);
int AddToPlayer( CBasePlayer *pPlayer );
void PrimaryAttack( void );
BOOL Deploy( );
void Reload( void );
BOOL Deploy( void );
BOOL CanHolster( void );
void Holster( int skiplocal = 0 );
void WeaponIdle( void );
int m_fInReload;
float m_flNextReload;
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
private:
};
enum shotgun_e
{
SHOTGUN_IDLE = 0,
SHOTGUN_FIRE,
SHOTGUN_OPEN,
SHOTGUN_INSERT,
SHOTGUN_CLOSE,
SHOTGUN_DRAW
};
LINK_ENTITY_TO_CLASS( weapon_pepsigun, CPepsigun )
@ -57,20 +54,42 @@ void CPepsigun::Spawn() @@ -57,20 +54,42 @@ void CPepsigun::Spawn()
m_iId = WEAPON_PEPSIGUN;
SET_MODEL( ENT( pev ), "models/w_pepsigun.mdl" );
#ifndef CLIENT_DLL
pev->dmg = 80;
#endif
m_iDefaultAmmo = HANDGRENADE_DEFAULT_GIVE;
FallInit();// get ready to fall down.
FallInit();// get ready to fall
}
void CPepsigun::Precache( void )
{
PRECACHE_MODEL( "models/w_pepsigun.mdl" );
PRECACHE_MODEL( "models/v_pepsigun.mdl" );
PRECACHE_MODEL( "models/w_pepsigun.mdl" );
PRECACHE_MODEL( "models/p_pepsigun.mdl" );
PRECACHE_SOUND( "weapons/pepsigun_shoot.wav");
PRECACHE_SOUND( "items/9mmclip1.wav" );
PRECACHE_SOUND( "weapons/dbarrel1.wav" );//shotgun
PRECACHE_SOUND( "weapons/pepsigun_shoot.wav" );//shotgun
PRECACHE_SOUND( "weapons/reload1.wav" ); // shotgun reload
PRECACHE_SOUND( "weapons/reload3.wav" ); // shotgun reload
//PRECACHE_SOUND( "weapons/sshell1.wav" ); // shotgun reload - played on client
//PRECACHE_SOUND( "weapons/sshell3.wav" ); // shotgun reload - played on client
PRECACHE_SOUND( "weapons/357_cock1.wav" ); // gun empty sound
PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun
}
int CPepsigun::AddToPlayer( CBasePlayer *pPlayer )
{
if( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
{
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
WRITE_BYTE( m_iId );
MESSAGE_END();
return TRUE;
}
return FALSE;
}
int CPepsigun::GetItemInfo( ItemInfo *p )
@ -83,84 +102,70 @@ int CPepsigun::GetItemInfo( ItemInfo *p ) @@ -83,84 +102,70 @@ int CPepsigun::GetItemInfo( ItemInfo *p )
p->iMaxClip = 8;
p->iSlot = 2;
p->iPosition = 4;
p->iFlags = 0;
p->iId = m_iId = WEAPON_PEPSIGUN;
p->iWeight = 10;
p->iFlags = ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE;
p->iWeight = SHOTGUN_WEIGHT;
return 1;
}
BOOL CPepsigun::Deploy()
{
m_flReleaseThrow = -1;
return DefaultDeploy( "models/v_pepsigun.mdl", "models/p_pepsigun.mdl", HANDGRENADE_DRAW, "crowbar" );
return DefaultDeploy( "models/v_pepsigun.mdl", "models/p_pepsigun.mdl", SHOTGUN_DRAW, "shotgun" );
}
BOOL CPepsigun::CanHolster( void )
void CPepsigun::PrimaryAttack()
{
// can only holster hand grenades when not primed!
return ( m_flStartThrow == 0 );
}
m_iClip--;
Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
void CPepsigun::Holster( int skiplocal /* = 0 */ )
{
m_pPlayer->m_flNextAttack = gpGlobals->time + 0.5;
if( angThrow.x < 0 )
angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 );
else
angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 );
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
float flVel = ( 90 - angThrow.x ) * 4;
if( flVel > 500 )
flVel = 500;
}
else
{
// no more grenades!
m_pPlayer->pev->weapons &= ~( 1 << WEAPON_PEPSIGUN );
SetThink( &CBasePlayerItem::DestroyItem );
pev->nextthink = gpGlobals->time + 0.1;
}
UTIL_MakeVectors( angThrow );
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM );
}
Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16;
void CPepsigun::PrimaryAttack()
{
m_flStartThrow = gpGlobals->time;
m_flReleaseThrow = 0;
m_flTimeWeaponIdle = gpGlobals->time + 0.25;
if(m_iClip > 0)
{
m_flStartThrow = gpGlobals->time;
m_flReleaseThrow = 0;
m_flTimeWeaponIdle = gpGlobals->time + 0.25;
}
else
{
Reload();
}
Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity;
CGrenade::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow*2, 3 );
SendWeaponAnim( SHOTGUN_FIRE );
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
m_fInSpecialReload = 0;
}
void CPepsigun::Reload( void )
{
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP )
return;
// don't reload until recoil is done
if( m_flNextPrimaryAttack > gpGlobals->time)
if( m_flNextPrimaryAttack > UTIL_WeaponTimeBase() )
return;
// check to see if we're ready to reload
if( m_fInSpecialReload == 0 )
{
SendWeaponAnim( HANDGRENADE_OPEN );
SendWeaponAnim( SHOTGUN_OPEN );
m_fInSpecialReload = 1;
m_pPlayer->m_flNextAttack = gpGlobals->time+ 0.6;
m_flTimeWeaponIdle = gpGlobals->time + 0.6;
m_flNextPrimaryAttack = gpGlobals->time + 1.0;
m_flNextSecondaryAttack = gpGlobals->time + 1.0;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
return;
}
else if( m_fInSpecialReload == 1 )
{
if( m_flTimeWeaponIdle > gpGlobals->time )
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return;
// was waiting for gun to move to side
m_fInSpecialReload = 2;
@ -170,10 +175,10 @@ void CPepsigun::Reload( void ) @@ -170,10 +175,10 @@ void CPepsigun::Reload( void )
else
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
SendWeaponAnim( HANDGRENADE_INSERT );
SendWeaponAnim( SHOTGUN_INSERT );
m_flNextReload = gpGlobals->time + 0.5;
m_flTimeWeaponIdle = gpGlobals->time + 0.5;
m_flNextReload = UTIL_WeaponTimeBase() + 0.5;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
}
else
{
@ -186,6 +191,19 @@ void CPepsigun::Reload( void ) @@ -186,6 +191,19 @@ void CPepsigun::Reload( void )
void CPepsigun::WeaponIdle( void )
{
ResetEmptySound();
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
if( m_flPumpTime && m_flPumpTime < gpGlobals->time )
{
// play pumping sound
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) );
m_flPumpTime = 0;
}
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{
if( m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
Reload();
@ -199,112 +217,32 @@ void CPepsigun::WeaponIdle( void ) @@ -199,112 +217,32 @@ void CPepsigun::WeaponIdle( void )
else
{
// reload debounce has timed out
SendWeaponAnim( HANDGRENADE_CLOSE );
SendWeaponAnim( SHOTGUN_CLOSE );
m_fInSpecialReload = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5;
}
}
if( m_flReleaseThrow == 0 && m_flStartThrow )
m_flReleaseThrow = gpGlobals->time;
if( m_flTimeWeaponIdle > gpGlobals->time )
return;
if( m_flStartThrow )
{
Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
if( angThrow.x < 0 )
angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 );
else
angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 );
float flVel = ( 90 - angThrow.x ) * 4;
if( flVel > 500 )
flVel = 1400;
UTIL_MakeVectors( angThrow );
Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16;
Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity;
// alway explode 3 seconds after the pin was pulled
float time = m_flStartThrow - gpGlobals->time + 3.0;
if( time < 0 )
time = 0;
CGrenade::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow, time );
m_iClip--;
if( flVel < 500 )
{
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM );
SendWeaponAnim( HANDGRENADE_FIRE );
}
else if( flVel < 1000 )
{
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM );
SendWeaponAnim( HANDGRENADE_FIRE );
}
else
{
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pepsigun_shoot.wav", 1, ATTN_NORM );
SendWeaponAnim( HANDGRENADE_FIRE );
}
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_flReleaseThrow = 0;
m_flStartThrow = 0;
m_flNextPrimaryAttack = gpGlobals->time + 0.5;
m_flTimeWeaponIdle = gpGlobals->time + 0.5;
if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
if( flRand <= 0.8 )
{
// just threw last grenade
// set attack times in the future, and weapon idle in the future so we can see the whole throw
// animation, weapon idle will automatically retire the weapon for us.
m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = gpGlobals->time + 0.5;// ensure that the animation can finish playing
}
return;
iAnim = SHOTGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0 / 12.0 );// * RANDOM_LONG( 2, 5 );
}
else if( m_flReleaseThrow > 0 )
else if( flRand <= 0.95 )
{
// we've finished the throw, restart.
m_flStartThrow = 0;
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
SendWeaponAnim( HANDGRENADE_DRAW );
iAnim = SHOTGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
}
else
{
RetireWeapon();
return;
iAnim = SHOTGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
}
m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
m_flReleaseThrow = -1;
return;
}
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
if( flRand <= 0.75 )
{
iAnim = HANDGRENADE_IDLE;
m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again.
SendWeaponAnim( iAnim );
}
else
{
m_flTimeWeaponIdle = gpGlobals->time + 75.0 / 30.0;
}
if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
}
}

200
dlls/rock.cpp

@ -1,6 +1,17 @@ @@ -1,6 +1,17 @@
/*
Здесь был rainbow
*/
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#include "extdll.h"
#include "util.h"
@ -9,40 +20,43 @@ @@ -9,40 +20,43 @@
#include "weapons.h"
#include "nodes.h"
#include "player.h"
#include "gamerules.h"
#define HANDGRENADE_PRIMARY_VOLUME 450
// special deathmatch shotgun spreads
#define VECTOR_CONE_DM_SHOTGUN Vector( 0.08716, 0.04362, 0.00 )// 10 degrees by 5 degrees
#define VECTOR_CONE_DM_DOUBLESHOTGUN Vector( 0.17365, 0.04362, 0.00 ) // 20 degrees by 5 degrees
#define WEAPON_ROCK 21
enum handgrenade_e
enum shotgun_e
{
HANDGRENADE_IDLE = 0,
HANDGRENADE_THROW2,
HANDGRENADE_DRAW,
HANDGRENADE_FIDGET
PEPSIGUN_IDLE = 0,
PEPSIGUN_THROW,
PEPSIGUN_DRAW,
PEPSIGUN_FIDGET
};
class CRock : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 5; }
int iItemSlot( void ) { return 4; }
int GetItemInfo(ItemInfo *p);
void PrimaryAttack( void );
BOOL Deploy( void );
BOOL CanHolster( void );
void Holster( int skiplocal = 0 );
void WeaponIdle( void );
virtual BOOL UseDecrement( void )
{
#if defined( CLIENT_WEAPONS )
return TRUE;
#else
return FALSE;
#endif
}
};
LINK_ENTITY_TO_CLASS( weapon_rock, CRock )
void CRock::Spawn()
@ -51,89 +65,43 @@ void CRock::Spawn() @@ -51,89 +65,43 @@ void CRock::Spawn()
m_iId = WEAPON_ROCK;
SET_MODEL( ENT( pev ), "models/w_rock.mdl" );
#ifndef CLIENT_DLL
pev->dmg = 40;
#endif
m_iDefaultAmmo = 10000000;
m_iDefaultAmmo = PEPSIGUN_DEFAULT_GIVE;
FallInit();// get ready to fall down.
FallInit();// get ready to fall
}
void CRock::Precache( void )
{
PRECACHE_MODEL( "models/w_rock.mdl" );
PRECACHE_MODEL( "models/v_rock.mdl" );
PRECACHE_MODEL( "models/w_rock.mdl" );
PRECACHE_MODEL( "models/p_rock.mdl" );
}
int CRock::GetItemInfo( ItemInfo *p )
{
p->pszName = STRING( pev->classname );
p->pszAmmo1 = "Hand Grenade";
p->iMaxAmmo1 = 10000000000000;
p->pszAmmo1 = NULL;
p->iMaxAmmo1 = HANDGRENADE_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = WEAPON_NOCLIP;
p->iSlot = 4;
p->iMaxClip = 8;
p->iSlot = 2;
p->iPosition = 4;
p->iFlags = 0;
p->iId = m_iId = WEAPON_ROCK;
p->iWeight = HANDGRENADE_WEIGHT;
p->iFlags = ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE;
p->iWeight = 16;
return 1;
}
BOOL CRock::Deploy()
{
m_flReleaseThrow = -1;
return DefaultDeploy( "models/v_rock.mdl", "models/p_rock.mdl", HANDGRENADE_DRAW, "crowbar" );
}
BOOL CRock::CanHolster( void )
{
// can only holster hand grenades when not primed!
return ( m_flStartThrow == 0 );
}
void CRock::Holster( int skiplocal /* = 0 */ )
{
m_pPlayer->m_flNextAttack = gpGlobals->time + 0.5;
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
}
else
{
// no more grenades!
m_pPlayer->pev->weapons &= ~( 1 << WEAPON_HANDGRENADE );
SetThink( &CBasePlayerItem::DestroyItem );
pev->nextthink = gpGlobals->time + 0.1;
}
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM );
return DefaultDeploy( "models/v_rock.mdl", "models/p_rock.mdl", PEPSIGUN_DRAW, "PEPSIGUN" );
}
void CRock::PrimaryAttack()
{
if( !m_flStartThrow && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0 )
{
m_flStartThrow = gpGlobals->time;
m_flReleaseThrow = 0;
m_flTimeWeaponIdle = gpGlobals->time + 0.5;
}
}
void CRock::WeaponIdle( void )
{
if( m_flReleaseThrow == 0 && m_flStartThrow )
m_flReleaseThrow = gpGlobals->time;
if( m_flTimeWeaponIdle > gpGlobals->time )
return;
if( m_flStartThrow )
{
Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
if( angThrow.x < 0 )
@ -150,83 +118,55 @@ void CRock::WeaponIdle( void ) @@ -150,83 +118,55 @@ void CRock::WeaponIdle( void )
Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16;
Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity;
CGrenadeRock::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow, 300000000000 );
SendWeaponAnim( PEPSIGUN_THROW );
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
// alway explode 3 seconds after the pin was pulled
float time = m_flStartThrow - gpGlobals->time + 3000000000;
if( time < 0 )
time = 0;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
m_fInSpecialReload = 0;
}
CGrenadeRock::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow, time );
void CRock::WeaponIdle( void )
{
ResetEmptySound();
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
if( flVel < 500 )
if( m_flPumpTime && m_flPumpTime < gpGlobals->time )
{
SendWeaponAnim( HANDGRENADE_THROW2 );
m_flPumpTime = 0;
}
else if( flVel < 1000 )
{
SendWeaponAnim( HANDGRENADE_THROW2 );
}
else
{
SendWeaponAnim( HANDGRENADE_THROW2 );
}
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
m_flReleaseThrow = 0;
m_flStartThrow = 0;
m_flNextPrimaryAttack = gpGlobals->time + 0.5;
m_flTimeWeaponIdle = gpGlobals->time + 0.5;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{
// just threw last grenade
// set attack times in the future, and weapon idle in the future so we can see the whole throw
// animation, weapon idle will automatically retire the weapon for us.
m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = gpGlobals->time + 0.5;// ensure that the animation can finish playing
}
return;
if( m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
Reload();
}
else if( m_flReleaseThrow > 0 )
else if( m_fInSpecialReload != 0 )
{
// we've finished the throw, restart.
m_flStartThrow = 0;
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
SendWeaponAnim( HANDGRENADE_DRAW );
Reload();
}
else
{
RetireWeapon();
return;
m_fInSpecialReload = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5;
}
m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
m_flReleaseThrow = -1;
return;
}
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 20 );
if( flRand <= 0.75 )
{
iAnim = HANDGRENADE_IDLE;
m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again.
}
else
{
iAnim = HANDGRENADE_FIDGET;
m_flTimeWeaponIdle = gpGlobals->time + 75.0 / 30.0;
}
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
iAnim = PEPSIGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
SendWeaponAnim( iAnim );
}
}
}

271
dlls/shotgun(1).cpp

@ -1,271 +0,0 @@ @@ -1,271 +0,0 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "player.h"
#include "gamerules.h"
// special deathmatch shotgun spreads
#define VECTOR_CONE_DM_SHOTGUN Vector( 0.08716, 0.04362, 0.00 )// 10 degrees by 5 degrees
#define VECTOR_CONE_DM_DOUBLESHOTGUN Vector( 0.17365, 0.04362, 0.00 ) // 20 degrees by 5 degrees
enum shotgun_e
{
PEPSIGUN_IDLE = 0,
PEPSIGUN_FIRE,
PEPSIGUN_OPEN,
PEPSIGUN_INSERT,
PEPSIGUN_CLOSE,
PEPSIGUN_DRAW
};
class CPepsigun : public CBasePlayerWeapon
{
public:
void Spawn( void );
void Precache( void );
int iItemSlot( void ) { return 4; }
int GetItemInfo(ItemInfo *p);
void PrimaryAttack( void );
void Reload( void );
BOOL Deploy( void );
BOOL CanHolster( void );
void Holster( int skiplocal = 0 );
void WeaponIdle( void );
int m_fInReload;
float m_flNextReload;
virtual BOOL UseDecrement( void )
{
return FALSE;
}
};
LINK_ENTITY_TO_CLASS( weapon_pepsigun, CPepsigun )
void CPepsigun::Spawn()
{
Precache();
m_iId = WEAPON_PEPSIGUN;
SET_MODEL( ENT( pev ), "models/w_pepsigun.mdl" );
m_iDefaultAmmo = PEPSIGUN_DEFAULT_GIVE;
FallInit();// get ready to fall
}
void CPepsigun::Precache( void )
{
PRECACHE_MODEL( "models/v_pepsigun.mdl" );
PRECACHE_MODEL( "models/w_pepsigun.mdl" );
PRECACHE_MODEL( "models/p_pepsigun.mdl" );
m_iShell = PRECACHE_MODEL( "models/shotgunshell.mdl" );// shotgun shell
PRECACHE_SOUND( "items/9mmclip1.wav" );
PRECACHE_SOUND( "weapons/dbarrel1.wav" );//shotgun
PRECACHE_SOUND( "weapons/sbarrel1.wav" );//shotgun
PRECACHE_SOUND( "weapons/reload1.wav" ); // shotgun reload
PRECACHE_SOUND( "weapons/reload3.wav" ); // shotgun reload
//PRECACHE_SOUND( "weapons/sshell1.wav" ); // shotgun reload - played on client
//PRECACHE_SOUND( "weapons/sshell3.wav" ); // shotgun reload - played on client
PRECACHE_SOUND( "weapons/357_cock1.wav" ); // gun empty sound
PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun
}
int CPepsigun::AddToPlayer( CBasePlayer *pPlayer )
{
if( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
{
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
WRITE_BYTE( m_iId );
MESSAGE_END();
return TRUE;
}
return FALSE;
}
int CPepsigun::GetItemInfo( ItemInfo *p )
{
p->pszName = STRING( pev->classname );
p->pszAmmo1 = "Hand Grenade";
p->iMaxAmmo1 = HANDGRENADE_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = 8;
p->iSlot = 2;
p->iPosition = 4;
p->iFlags = 0;
p->iId = m_iId = WEAPON_PEPSIGUN;
p->iWeight = 16;
return 1;
}
BOOL CPepsigun::Deploy()
{
return DefaultDeploy( "models/v_pepsigun.mdl", "models/p_pepsigun.mdl", PEPSIGUN_DRAW, "PEPSIGUN" );
}
void CPepsigun::PrimaryAttack()
{
m_iClip--;
if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
if( m_iClip != 0 )
m_flPumpTime = gpGlobals->time + 0.5;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75;
if( m_iClip != 0 )
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
else
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
m_fInSpecialReload = 0;
}
void CPepsigun::Reload( void )
{
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP )
return;
// don't reload until recoil is done
if( m_flNextPrimaryAttack > UTIL_WeaponTimeBase() )
return;
// check to see if we're ready to reload
if( m_fInSpecialReload == 0 )
{
SendWeaponAnim( PEPSIGUN_OPEN );
m_fInSpecialReload = 1;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
return;
}
else if( m_fInSpecialReload == 1 )
{
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return;
// was waiting for gun to move to side
m_fInSpecialReload = 2;
if( RANDOM_LONG( 0, 1 ) )
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload1.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
else
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
SendWeaponAnim( PEPSIGUN_INSERT );
m_flNextReload = UTIL_WeaponTimeBase() + 0.5;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
}
else
{
// Add them to the clip
m_iClip += 1;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= 1;
m_fInSpecialReload = 1;
}
}
void CPepsigun::WeaponIdle( void )
{
ResetEmptySound();
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
if( m_flPumpTime && m_flPumpTime < gpGlobals->time )
{
// play pumping sound
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) );
m_flPumpTime = 0;
}
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{
if( m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
Reload();
}
else if( m_fInSpecialReload != 0 )
{
if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
Reload();
}
else
{
// reload debounce has timed out
SendWeaponAnim( PEPSIGUN_PUMP );
// play cocking sound
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) );
m_fInSpecialReload = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5;
}
}
else
{
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
iAnim = PEPSIGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
SendWeaponAnim( iAnim );
}
}
}
class CPepsigunAmmo : public CBasePlayerAmmo
{
void Spawn( void )
{
Precache();
SET_MODEL( ENT( pev ), "models/w_shotbox.mdl" );
CBasePlayerAmmo::Spawn();
}
void Precache( void )
{
PRECACHE_MODEL( "models/w_shotbox.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
}
BOOL AddAmmo( CBaseEntity *pOther )
{
if( pOther->GiveAmmo( AMMO_BUCKSHOTBOX_GIVE, "buckshot", BUCKSHOT_MAX_CARRY ) != -1 )
{
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
return TRUE;
}
return FALSE;
}
};
LINK_ENTITY_TO_CLASS( ammo_buckshot, CPepsigunAmmo )

386
dlls/shotgun(2).cpp

@ -1,386 +0,0 @@ @@ -1,386 +0,0 @@
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "player.h"
#include "gamerules.h"
// special deathmatch shotgun spreads
#define VECTOR_CONE_DM_SHOTGUN Vector( 0.08716, 0.04362, 0.00 )// 10 degrees by 5 degrees
#define VECTOR_CONE_DM_DOUBLESHOTGUN Vector( 0.17365, 0.04362, 0.00 ) // 20 degrees by 5 degrees
enum shotgun_e
{
SHOTGUN_IDLE = 0,
SHOTGUN_FIRE,
SHOTGUN_FIRE2,
SHOTGUN_RELOAD,
SHOTGUN_PUMP,
SHOTGUN_START_RELOAD,
SHOTGUN_DRAW,
SHOTGUN_HOLSTER,
SHOTGUN_IDLE4,
SHOTGUN_IDLE_DEEP
};
LINK_ENTITY_TO_CLASS( weapon_shotgun, CShotgun )
void CShotgun::Spawn()
{
Precache();
m_iId = WEAPON_SHOTGUN;
SET_MODEL( ENT( pev ), "models/w_shotgun.mdl" );
m_iDefaultAmmo = SHOTGUN_DEFAULT_GIVE;
FallInit();// get ready to fall
}
void CShotgun::Precache( void )
{
PRECACHE_MODEL( "models/v_shotgun.mdl" );
PRECACHE_MODEL( "models/w_shotgun.mdl" );
PRECACHE_MODEL( "models/p_shotgun.mdl" );
m_iShell = PRECACHE_MODEL( "models/shotgunshell.mdl" );// shotgun shell
PRECACHE_SOUND( "items/9mmclip1.wav" );
PRECACHE_SOUND( "weapons/dbarrel1.wav" );//shotgun
PRECACHE_SOUND( "weapons/sbarrel1.wav" );//shotgun
PRECACHE_SOUND( "weapons/reload1.wav" ); // shotgun reload
PRECACHE_SOUND( "weapons/reload3.wav" ); // shotgun reload
//PRECACHE_SOUND( "weapons/sshell1.wav" ); // shotgun reload - played on client
//PRECACHE_SOUND( "weapons/sshell3.wav" ); // shotgun reload - played on client
PRECACHE_SOUND( "weapons/357_cock1.wav" ); // gun empty sound
PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun
m_usSingleFire = PRECACHE_EVENT( 1, "events/shotgun1.sc" );
m_usDoubleFire = PRECACHE_EVENT( 1, "events/shotgun2.sc" );
}
int CShotgun::AddToPlayer( CBasePlayer *pPlayer )
{
if( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
{
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
WRITE_BYTE( m_iId );
MESSAGE_END();
return TRUE;
}
return FALSE;
}
int CShotgun::GetItemInfo( ItemInfo *p )
{
p->pszName = STRING( pev->classname );
p->pszAmmo1 = "buckshot";
p->iMaxAmmo1 = BUCKSHOT_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = SHOTGUN_MAX_CLIP;
p->iSlot = 2;
p->iPosition = 1;
p->iFlags = 0;
p->iId = m_iId = WEAPON_SHOTGUN;
p->iWeight = SHOTGUN_WEIGHT;
return 1;
}
BOOL CShotgun::Deploy()
{
return DefaultDeploy( "models/v_shotgun.mdl", "models/p_shotgun.mdl", SHOTGUN_DRAW, "shotgun" );
}
void CShotgun::PrimaryAttack()
{
// don't fire underwater
if( m_pPlayer->pev->waterlevel == 3 )
{
PlayEmptySound();
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15;
return;
}
if( m_iClip <= 0 )
{
Reload();
if( m_iClip == 0 )
PlayEmptySound();
return;
}
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
m_iClip--;
int flags;
#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH;
Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
Vector vecDir;
#ifdef CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
vecDir = m_pPlayer->FireBulletsPlayer( 4, vecSrc, vecAiming, VECTOR_CONE_DM_SHOTGUN, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
else
{
// regular old, untouched spread.
vecDir = m_pPlayer->FireBulletsPlayer( 6, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSingleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 );
if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
if( m_iClip != 0 )
m_flPumpTime = gpGlobals->time + 0.5;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75;
if( m_iClip != 0 )
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0;
else
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.75;
m_fInSpecialReload = 0;
}
void CShotgun::SecondaryAttack( void )
{
// don't fire underwater
if( m_pPlayer->pev->waterlevel == 3 )
{
PlayEmptySound();
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15;
return;
}
if( m_iClip <= 1 )
{
Reload();
PlayEmptySound();
return;
}
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
m_iClip -= 2;
int flags;
#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH;
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
Vector vecDir;
#ifdef CLIENT_DLL
if( bIsMultiplayer() )
#else
if( g_pGameRules->IsMultiplayer() )
#endif
{
// tuned for deathmatch
vecDir = m_pPlayer->FireBulletsPlayer( 8, vecSrc, vecAiming, VECTOR_CONE_DM_DOUBLESHOTGUN, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
else
{
// untouched default single player
vecDir = m_pPlayer->FireBulletsPlayer( 12, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, 2048, BULLET_PLAYER_BUCKSHOT, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usDoubleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 );
if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
if( m_iClip != 0 )
m_flPumpTime = gpGlobals->time + 0.95;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5;
if( m_iClip != 0 )
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0;
else
m_flTimeWeaponIdle = 1.5;
m_fInSpecialReload = 0;
}
void CShotgun::Reload( void )
{
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP )
return;
// don't reload until recoil is done
if( m_flNextPrimaryAttack > UTIL_WeaponTimeBase() )
return;
// check to see if we're ready to reload
if( m_fInSpecialReload == 0 )
{
SendWeaponAnim( SHOTGUN_START_RELOAD );
m_fInSpecialReload = 1;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0;
return;
}
else if( m_fInSpecialReload == 1 )
{
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
return;
// was waiting for gun to move to side
m_fInSpecialReload = 2;
if( RANDOM_LONG( 0, 1 ) )
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload1.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
else
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/reload3.wav", 1, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ) );
SendWeaponAnim( SHOTGUN_RELOAD );
m_flNextReload = UTIL_WeaponTimeBase() + 0.5;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
}
else
{
// Add them to the clip
m_iClip += 1;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= 1;
m_fInSpecialReload = 1;
}
}
void CShotgun::WeaponIdle( void )
{
ResetEmptySound();
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
if( m_flPumpTime && m_flPumpTime < gpGlobals->time )
{
// play pumping sound
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) );
m_flPumpTime = 0;
}
if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() )
{
if( m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
Reload();
}
else if( m_fInSpecialReload != 0 )
{
if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
Reload();
}
else
{
// reload debounce has timed out
SendWeaponAnim( SHOTGUN_PUMP );
// play cocking sound
EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) );
m_fInSpecialReload = 0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5;
}
}
else
{
int iAnim;
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
if( flRand <= 0.8 )
{
iAnim = SHOTGUN_IDLE_DEEP;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0 / 12.0 );// * RANDOM_LONG( 2, 5 );
}
else if( flRand <= 0.95 )
{
iAnim = SHOTGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
}
else
{
iAnim = SHOTGUN_IDLE4;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
}
SendWeaponAnim( iAnim );
}
}
}
class CShotgunAmmo : public CBasePlayerAmmo
{
void Spawn( void )
{
Precache();
SET_MODEL( ENT( pev ), "models/w_shotbox.mdl" );
CBasePlayerAmmo::Spawn();
}
void Precache( void )
{
PRECACHE_MODEL( "models/w_shotbox.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
}
BOOL AddAmmo( CBaseEntity *pOther )
{
if( pOther->GiveAmmo( AMMO_BUCKSHOTBOX_GIVE, "buckshot", BUCKSHOT_MAX_CARRY ) != -1 )
{
EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM );
return TRUE;
}
return FALSE;
}
};
LINK_ENTITY_TO_CLASS( ammo_buckshot, CShotgunAmmo )

1
dlls/weapons.cpp

@ -304,7 +304,6 @@ void W_Precache( void ) @@ -304,7 +304,6 @@ void W_Precache( void )
UTIL_PrecacheOtherWeapon( "weapon_shotgun" );
UTIL_PrecacheOtherWeapon( "weapon_hammer");
UTIL_PrecacheOtherWeapon( "weapon_pepsigun" );
UTIL_PrecacheOther( "ammo_pepsi" );
UTIL_PrecacheOther( "ammo_buckshot" );
//needle

1
dlls/weapons.h

@ -98,7 +98,6 @@ public: @@ -98,7 +98,6 @@ public:
#define WEAPON_SNIPARS 18
#define WEAPON_GLOCK2 19
#define WEAPON_KATANA 20
#define WEAPON_ROCK 21
#define WEAPON_HAMMER 23

54
dlls/zombozo.cpp

@ -164,22 +164,66 @@ void Czombozo::HandleAnimEvent( MonsterEvent_t *pEvent ) @@ -164,22 +164,66 @@ void Czombozo::HandleAnimEvent( MonsterEvent_t *pEvent )
{
case ZOMBIE_AE_ATTACK_RIGHT:
{
Vector angThrow = gpGlobals->v_forward + gpGlobals->v_up * 0.5;
if( angThrow.x < 0 )
angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 );
else
angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 );
float flVel = ( 90 - angThrow.x ) * 4;
if( flVel > 500 )
flVel = 500;
Vector vecSrc = pev->origin + pev->view_ofs + gpGlobals->v_forward * 16;
Vector vecThrow = gpGlobals->v_forward * flVel + pev->velocity;
UTIL_MakeVectors( pev->angles );
CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 17 - gpGlobals->v_right * 27 + gpGlobals->v_up * 6, g_vecZero, 3 );
//n a group, only try to throw grenade if ordered.
CGrenade::ShootTimed( pev, vecSrc, vecThrow, 3 );
}
break;
case ZOMBIE_AE_ATTACK_LEFT:
{
Vector angThrow = gpGlobals->v_forward + gpGlobals->v_up * 0.5;
if( angThrow.x < 0 )
angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 );
else
angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 );
float flVel = ( 90 - angThrow.x ) * 4;
if( flVel > 500 )
flVel = 500;
Vector vecSrc = pev->origin + pev->view_ofs + gpGlobals->v_forward * 16;
Vector vecThrow = gpGlobals->v_forward * flVel + pev->velocity;
UTIL_MakeVectors( pev->angles );
CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 17 - gpGlobals->v_right * 27 + gpGlobals->v_up * 6, g_vecZero, 3 );
CGrenade::ShootTimed( pev, vecSrc, vecThrow, 3 );
}
break;
case ZOMBIE_AE_ATTACK_BOTH:
{
//ALERT( at_console, "Slash right!\n" );
Vector angThrow = gpGlobals->v_forward + gpGlobals->v_up * 0.5;
if( angThrow.x < 0 )
angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 );
else
angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 );
float flVel = ( 90 - angThrow.x ) * 4;
if( flVel > 500 )
flVel = 500;
Vector vecSrc = pev->origin + pev->view_ofs + gpGlobals->v_forward * 16;
Vector vecThrow = gpGlobals->v_forward * flVel + pev->velocity;
UTIL_MakeVectors( pev->angles );
CGrenade::ShootTimed( pev, pev->origin + gpGlobals->v_forward * 17 - gpGlobals->v_right * 27 + gpGlobals->v_up * 6, g_vecZero, 3 );
CGrenade::ShootTimed( pev, vecSrc, vecThrow, 3 );
}
break;
default:

Loading…
Cancel
Save