Browse Source

Merge assault shotgun source code into shotgun.

coldice
Night Owl 8 years ago
parent
commit
904d742f54
  1. 2
      cl_dll/CMakeLists.txt
  2. 22
      cl_dll/ev_hldm.cpp
  3. 10
      cl_dll/hl/hl_weapons.cpp
  4. 4
      dlls/CMakeLists.txt
  5. 108
      dlls/shotgun.cpp
  6. 4
      dlls/weapons.cpp
  7. 4
      dlls/weapons.h

2
cl_dll/CMakeLists.txt

@ -39,7 +39,7 @@ set (CLDLL_SOURCES @@ -39,7 +39,7 @@ set (CLDLL_SOURCES
# ../dlls/python.cpp
../dlls/rpg.cpp
../dlls/satchel.cpp
# ../dlls/shotgun.cpp
../dlls/shotgun.cpp
# ../dlls/squeakgrenade.cpp
../dlls/tripmine.cpp
# ../dlls/glock.cpp

22
cl_dll/ev_hldm.cpp

@ -594,19 +594,12 @@ void EV_FireShotGunDouble( event_args_t *args ) @@ -594,19 +594,12 @@ void EV_FireShotGunDouble( event_args_t *args )
EV_EjectBrass( ShellOrigin, ShellVelocity, angles[ YAW ], shell, TE_BOUNCE_SHOTSHELL );
}
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/dbarrel1.wav", gEngfuncs.pfnRandomFloat( 0.98, 1.0 ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) );
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/ashotgun1.wav", gEngfuncs.pfnRandomFloat( 0.98, 1.0 ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
if( gEngfuncs.GetMaxClients() > 1 )
{
EV_HLDM_FireBullets( idx, forward, right, up, 8, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.17365, 0.04362 );
}
else
{
EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 );
}
EV_HLDM_FireBullets( idx, forward, right, up, 16, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 );
}
void EV_FireShotGunSingle( event_args_t *args )
@ -646,19 +639,12 @@ void EV_FireShotGunSingle( event_args_t *args ) @@ -646,19 +639,12 @@ void EV_FireShotGunSingle( event_args_t *args )
EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHOTSHELL );
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/sbarrel1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0x1f ) );
gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/ashotgun1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0x1f ) );
EV_GetGunPosition( args, vecSrc, origin );
VectorCopy( forward, vecAiming );
if( gEngfuncs.GetMaxClients() > 1 )
{
EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.04362 );
}
else
{
EV_HLDM_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 );
}
EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 );
}
//======================
// SHOTGUN END

10
cl_dll/hl/hl_weapons.cpp

@ -60,7 +60,7 @@ CPython g_Python; @@ -60,7 +60,7 @@ CPython g_Python;
CMP5 g_Mp5*/;
CCrossbow g_Crossbow;
//CShotgun g_Shotgun;
CShotgun g_Shotgun;
CRpg g_Rpg;
//CGauss g_Gauss;
CEgon g_Egon;
@ -630,7 +630,7 @@ void HUD_InitClientWeapons( void ) @@ -630,7 +630,7 @@ void HUD_InitClientWeapons( void )
/*HUD_PrepEntity( &g_Python, &player );
HUD_PrepEntity( &g_Mp5, &player );*/
HUD_PrepEntity( &g_Crossbow, &player );
//HUD_PrepEntity( &g_Shotgun, &player );
HUD_PrepEntity( &g_Shotgun, &player );
HUD_PrepEntity( &g_Rpg, &player );
//HUD_PrepEntity( &g_Gauss, &player );
HUD_PrepEntity( &g_Egon, &player );
@ -716,10 +716,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm @@ -716,10 +716,10 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
break;*/
case WEAPON_BOLTGUN:
pWeapon = &g_Crossbow;
break;/*
case WEAPON_SHOTGUN:
break;
case WEAPON_ASHOTGUN:
pWeapon = &g_Shotgun;
break;*/
break;
case WEAPON_ROCKETL:
pWeapon = &g_Rpg;
break;/*

4
dlls/CMakeLists.txt

@ -105,7 +105,7 @@ set (SVDLL_SOURCES @@ -105,7 +105,7 @@ set (SVDLL_SOURCES
schedule.cpp
scientist.cpp
scripted.cpp
# shotgun.cpp
shotgun.cpp
singleplay_gamerules.cpp
skill.cpp
sound.cpp
@ -134,7 +134,7 @@ set (SVDLL_SOURCES @@ -134,7 +134,7 @@ set (SVDLL_SOURCES
coldice/m16.cpp
coldice/railgun_arena.cpp
coldice/sshotgun.cpp
coldice/ashotgun.cpp
# coldice/ashotgun.cpp
coldice/cluster_grenade.cpp
coldice/mac_10.cpp
# coldice/railgun.cpp

108
dlls/shotgun.cpp

@ -28,51 +28,48 @@ @@ -28,51 +28,48 @@
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
ASHOTGUN_IDLE = 0,
ASHOTGUN_FIRE,
ASHOTGUN_FIRE2,
ASHOTGUN_RELOAD,
ASHOTGUN_PUMP,
ASHOTGUN_START_RELOAD,
ASHOTGUN_DRAW,
ASHOTGUN_HOLSTER,
ASHOTGUN_IDLE4,
ASHOTGUN_IDLE_DEEP
};
LINK_ENTITY_TO_CLASS( weapon_ashotgun, CShotgun )
LINK_ENTITY_TO_CLASS( weapon_shotgun, CShotgun )
void CShotgun::Spawn()
{
pev->classname = MAKE_STRING("weapon_ashotgun");
Precache();
m_iId = WEAPON_SHOTGUN;
SET_MODEL( ENT( pev ), "models/w_shotgun.mdl" );
m_iId = WEAPON_ASHOTGUN;
SET_MODEL( ENT( pev ), "models/wmodels/w_ashotgun.mdl" );
m_iDefaultAmmo = SHOTGUN_DEFAULT_GIVE;
m_iDefaultAmmo = ASHOTGUN_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" );
PRECACHE_MODEL( "models/vmodels/v_ashotgun.mdl" );
PRECACHE_MODEL( "models/wmodels/w_ashotgun.mdl" );
PRECACHE_MODEL( "models/pmodels/p_ashotgun.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/ashotgun1.wav" );
PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun
m_usSingleFire = PRECACHE_EVENT( 1, "events/shotgun1.sc" );
@ -98,19 +95,19 @@ int CShotgun::GetItemInfo( ItemInfo *p ) @@ -98,19 +95,19 @@ int CShotgun::GetItemInfo( ItemInfo *p )
p->iMaxAmmo1 = BUCKSHOT_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = SHOTGUN_MAX_CLIP;
p->iMaxClip = ASHOTGUN_MAX_CLIP;
p->iSlot = 2;
p->iPosition = 1;
p->iFlags = 0;
p->iId = m_iId = WEAPON_SHOTGUN;
p->iWeight = SHOTGUN_WEIGHT;
p->iId = m_iId = WEAPON_ASHOTGUN;
p->iWeight = ASHOTGUN_WEIGHT;
return 1;
}
BOOL CShotgun::Deploy()
{
return DefaultDeploy( "models/v_shotgun.mdl", "models/p_shotgun.mdl", SHOTGUN_DRAW, "shotgun" );
return DefaultDeploy( "models/vmodels/v_ashotgun.mdl", "models/pmodels/p_ashotgun.mdl", ASHOTGUN_DRAW, "shotgun" );
}
void CShotgun::PrimaryAttack()
@ -149,26 +146,10 @@ void CShotgun::PrimaryAttack() @@ -149,26 +146,10 @@ void CShotgun::PrimaryAttack()
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 );
}
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_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;
@ -219,27 +200,10 @@ void CShotgun::SecondaryAttack( void ) @@ -219,27 +200,10 @@ void CShotgun::SecondaryAttack( void )
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 );
}
vecDir = m_pPlayer->FireBulletsPlayer( 16, 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;
@ -255,7 +219,7 @@ void CShotgun::SecondaryAttack( void ) @@ -255,7 +219,7 @@ void CShotgun::SecondaryAttack( void )
void CShotgun::Reload( void )
{
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == SHOTGUN_MAX_CLIP )
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == ASHOTGUN_MAX_CLIP )
return;
// don't reload until recoil is done
@ -265,7 +229,7 @@ void CShotgun::Reload( void ) @@ -265,7 +229,7 @@ void CShotgun::Reload( void )
// check to see if we're ready to reload
if( m_fInSpecialReload == 0 )
{
SendWeaponAnim( SHOTGUN_START_RELOAD );
SendWeaponAnim( ASHOTGUN_START_RELOAD );
m_fInSpecialReload = 1;
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6;
@ -285,7 +249,7 @@ void CShotgun::Reload( void ) @@ -285,7 +249,7 @@ void CShotgun::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( SHOTGUN_RELOAD );
SendWeaponAnim( ASHOTGUN_RELOAD );
m_flNextReload = UTIL_WeaponTimeBase() + 0.5;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5;
@ -320,14 +284,14 @@ void CShotgun::WeaponIdle( void ) @@ -320,14 +284,14 @@ void CShotgun::WeaponIdle( void )
}
else if( m_fInSpecialReload != 0 )
{
if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
if( m_iClip != 16 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
{
Reload();
}
else
{
// reload debounce has timed out
SendWeaponAnim( SHOTGUN_PUMP );
SendWeaponAnim( ASHOTGUN_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 ) );
@ -341,17 +305,17 @@ void CShotgun::WeaponIdle( void ) @@ -341,17 +305,17 @@ void CShotgun::WeaponIdle( void )
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
if( flRand <= 0.8 )
{
iAnim = SHOTGUN_IDLE_DEEP;
iAnim = ASHOTGUN_IDLE_DEEP;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 60.0 / 12.0 );// * RANDOM_LONG( 2, 5 );
}
else if( flRand <= 0.95 )
{
iAnim = SHOTGUN_IDLE;
iAnim = ASHOTGUN_IDLE;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
}
else
{
iAnim = SHOTGUN_IDLE4;
iAnim = ASHOTGUN_IDLE4;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + ( 20.0 / 9.0 );
}
SendWeaponAnim( iAnim );
@ -364,12 +328,12 @@ class CShotgunAmmo : public CBasePlayerAmmo @@ -364,12 +328,12 @@ class CShotgunAmmo : public CBasePlayerAmmo
void Spawn( void )
{
Precache();
SET_MODEL( ENT( pev ), "models/w_shotbox.mdl" );
SET_MODEL( ENT( pev ), "models/ammo/w_buckshot.mdl" );
CBasePlayerAmmo::Spawn();
}
void Precache( void )
{
PRECACHE_MODEL( "models/w_shotbox.mdl" );
PRECACHE_MODEL( "models/ammo/w_buckshot.mdl" );
PRECACHE_SOUND( "items/9mmclip1.wav" );
}
BOOL AddAmmo( CBaseEntity *pOther )
@ -383,4 +347,4 @@ class CShotgunAmmo : public CBasePlayerAmmo @@ -383,4 +347,4 @@ class CShotgunAmmo : public CBasePlayerAmmo
}
};
LINK_ENTITY_TO_CLASS( ammo_buckshot, CShotgunAmmo )
LINK_ENTITY_TO_CLASS( ammo_buckshotbox, CShotgunAmmo )

4
dlls/weapons.cpp

@ -1643,7 +1643,7 @@ TYPEDESCRIPTION CRpgRocket::m_SaveData[] = @@ -1643,7 +1643,7 @@ TYPEDESCRIPTION CRpgRocket::m_SaveData[] =
};
IMPLEMENT_SAVERESTORE( CRpgRocket, CGrenade )
/*
TYPEDESCRIPTION CShotgun::m_SaveData[] =
{
DEFINE_FIELD( CShotgun, m_flNextReload, FIELD_TIME ),
@ -1654,7 +1654,7 @@ TYPEDESCRIPTION CShotgun::m_SaveData[] = @@ -1654,7 +1654,7 @@ TYPEDESCRIPTION CShotgun::m_SaveData[] =
};
IMPLEMENT_SAVERESTORE( CShotgun, CBasePlayerWeapon )
/*
TYPEDESCRIPTION CGauss::m_SaveData[] =
{
DEFINE_FIELD( CGauss, m_fInAttack, FIELD_INTEGER ),

4
dlls/weapons.h

@ -663,7 +663,7 @@ private: @@ -663,7 +663,7 @@ private:
unsigned short m_usCrossbow;
unsigned short m_usCrossbow2;
};
/*
class CShotgun : public CBasePlayerWeapon
{
public:
@ -700,7 +700,7 @@ private: @@ -700,7 +700,7 @@ private:
unsigned short m_usDoubleFire;
unsigned short m_usSingleFire;
};
*/
class CLaserSpot : public CBaseEntity
{
void Spawn( void );

Loading…
Cancel
Save