|
|
|
/***
|
|
|
|
*
|
|
|
|
* Copyright (c) 1999, 2000 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.
|
|
|
|
*
|
|
|
|
****/
|
|
|
|
#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD )
|
|
|
|
|
|
|
|
#include "extdll.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "cbase.h"
|
|
|
|
#include "weapons.h"
|
|
|
|
#include "monsters.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "gamerules.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum python_e {
|
|
|
|
/* PYTHON_IDLE1 = 0, //modif de Julien
|
|
|
|
PYTHON_FIDGET,
|
|
|
|
PYTHON_FIRE1,
|
|
|
|
PYTHON_RELOAD,
|
|
|
|
PYTHON_HOLSTER,
|
|
|
|
PYTHON_DRAW,
|
|
|
|
PYTHON_IDLE2,
|
|
|
|
PYTHON_IDLE3
|
|
|
|
*/
|
|
|
|
PYTHON_DRAW = 0,
|
|
|
|
PYTHON_IDLE1,
|
|
|
|
PYTHON_IDLE2,
|
|
|
|
PYTHON_IDLE3,
|
|
|
|
PYTHON_FIRE1,
|
|
|
|
PYTHON_FIRE_EMPTY,
|
|
|
|
PYTHON_RELOAD_EMPTY,
|
|
|
|
PYTHON_RELOAD
|
|
|
|
};
|
|
|
|
|
|
|
|
LINK_ENTITY_TO_CLASS( weapon_python, CPython );
|
|
|
|
LINK_ENTITY_TO_CLASS( weapon_357, CPython );
|
|
|
|
|
|
|
|
int CPython::GetItemInfo(ItemInfo *p)
|
|
|
|
{
|
|
|
|
p->pszName = STRING(pev->classname);
|
|
|
|
p->pszAmmo1 = "357";
|
|
|
|
p->iMaxAmmo1 = _357_MAX_CARRY;
|
|
|
|
p->pszAmmo2 = NULL;
|
|
|
|
p->iMaxAmmo2 = -1;
|
|
|
|
p->iMaxClip = PYTHON_MAX_CLIP;
|
|
|
|
p->iFlags = 0;
|
|
|
|
p->iSlot = 1;
|
|
|
|
p->iPosition = 1;
|
|
|
|
p->iId = m_iId = WEAPON_PYTHON;
|
|
|
|
p->iWeight = PYTHON_WEIGHT;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CPython::AddToPlayer( CBasePlayer *pPlayer )
|
|
|
|
{
|
|
|
|
if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) )
|
|
|
|
{
|
|
|
|
MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev );
|
|
|
|
WRITE_BYTE( m_iId );
|
|
|
|
MESSAGE_END();
|
|
|
|
|
|
|
|
m_pPlayer->TextAmmo( TA_BERETTA );
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPython::Spawn( )
|
|
|
|
{
|
|
|
|
pev->classname = MAKE_STRING("weapon_357"); // hack to allow for old names
|
|
|
|
Precache( );
|
|
|
|
m_iId = WEAPON_PYTHON;
|
|
|
|
SET_MODEL(ENT(pev), "models/w_beretta.mdl");
|
|
|
|
|
|
|
|
m_iDefaultAmmo = PYTHON_DEFAULT_GIVE;
|
|
|
|
|
|
|
|
FallInit();// get ready to fall down.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPython::Precache( void )
|
|
|
|
{
|
|
|
|
PRECACHE_MODEL("models/v_beretta.mdl");
|
|
|
|
PRECACHE_MODEL("models/w_beretta.mdl");
|
|
|
|
PRECACHE_MODEL("models/p_357.mdl");
|
|
|
|
|
|
|
|
PRECACHE_MODEL("models/w_berettaclip.mdl");
|
|
|
|
PRECACHE_SOUND("items/9mmclip1.wav");
|
|
|
|
|
|
|
|
PRECACHE_SOUND ("weapons/357_reload1.wav");
|
|
|
|
PRECACHE_SOUND ("weapons/357_cock1.wav");
|
|
|
|
PRECACHE_SOUND ("weapons/357_shot1.wav");
|
|
|
|
PRECACHE_SOUND ("weapons/357_shot2.wav");
|
|
|
|
|
|
|
|
m_usFirePython = PRECACHE_EVENT( 1, "events/python.sc" );
|
|
|
|
|
|
|
|
m_iShell = PRECACHE_MODEL ("models/beretta_shell.mdl");// brass shell
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CPython::Deploy( )
|
|
|
|
{
|
|
|
|
/* if ( g_pGameRules->IsMultiplayer() )
|
|
|
|
{
|
|
|
|
// enable laser sight geometry.
|
|
|
|
pev->body = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pev->body = 0;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
return DefaultDeploy( "models/v_beretta.mdl", "models/p_357.mdl", PYTHON_DRAW, "python" );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPython::Holster( int skiplocal /* = 0 */ )
|
|
|
|
{
|
|
|
|
m_fInReload = FALSE;// cancel any reload in progress.
|
|
|
|
|
|
|
|
/* if ( m_fInZoom )
|
|
|
|
{
|
|
|
|
SecondaryAttack();
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
|
|
|
|
m_flTimeWeaponIdle = gpGlobals->time + 10 + RANDOM_FLOAT ( 0, 5 );
|
|
|
|
// SendWeaponAnim( PYTHON_HOLSTER );
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPython::PrimaryAttack()
|
|
|
|
{
|
|
|
|
// don't fire underwater
|
|
|
|
if (m_pPlayer->pev->waterlevel == 3)
|
|
|
|
{
|
|
|
|
PlayEmptySound( );
|
|
|
|
m_flNextPrimaryAttack = gpGlobals->time + 0.15;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_iClip <= 0)
|
|
|
|
{
|
|
|
|
if (!m_fFireOnEmpty)
|
|
|
|
Reload( );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM);
|
|
|
|
m_flNextPrimaryAttack = gpGlobals->time + 0.15;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_iClip--;
|
|
|
|
|
|
|
|
// PLAYBACK_EVENT( 0, m_pPlayer->edict(), m_usFirePython ); // le full permet de pr
|
|
|
|
PLAYBACK_EVENT_FULL( 0, m_pPlayer->edict(), m_usFirePython, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 );
|
|
|
|
|
|
|
|
m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME;
|
|
|
|
m_pPlayer->Gunflash ();
|
|
|
|
|
|
|
|
// player "shoot" animation
|
|
|
|
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
|
|
|
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
|
|
|
|
|
|
|
|
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
|
|
|
|
|
|
|
|
Vector vecSrc = m_pPlayer->GetGunPosition( );
|
|
|
|
Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
|
|
|
m_pPlayer->FireBullets( 1, vecSrc, vecAiming, VECTOR_CONE_1DEGREES, 8192, BULLET_PLAYER_357, 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);
|
|
|
|
|
|
|
|
m_flNextPrimaryAttack = gpGlobals->time + 0.5;
|
|
|
|
m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT ( 10, 15 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPython::Reload( void )
|
|
|
|
{
|
|
|
|
int iResult;
|
|
|
|
|
|
|
|
if (m_iClip == 0)
|
|
|
|
iResult = DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD_EMPTY, 2.1 );
|
|
|
|
else
|
|
|
|
iResult = DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.1 );
|
|
|
|
|
|
|
|
if ( iResult )
|
|
|
|
{
|
|
|
|
m_flSoundDelay = gpGlobals->time + 1.5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPython::WeaponIdle( void )
|
|
|
|
{
|
|
|
|
ResetEmptySound( );
|
|
|
|
|
|
|
|
m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
|
|
|
|
|
|
|
|
// ALERT( at_console, "%.2f\n", gpGlobals->time - m_flSoundDelay );
|
|
|
|
if (m_flSoundDelay != 0 && m_flSoundDelay <= gpGlobals->time)
|
|
|
|
{
|
|
|
|
// EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_reload1.wav", RANDOM_FLOAT(0.8, 0.9), ATTN_NORM);
|
|
|
|
m_flSoundDelay = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_flTimeWeaponIdle > gpGlobals->time)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int iAnim;
|
|
|
|
float flRand = RANDOM_FLOAT(0, 1);
|
|
|
|
if (flRand <= 0.5)
|
|
|
|
{
|
|
|
|
iAnim = PYTHON_IDLE1;
|
|
|
|
}
|
|
|
|
else if (flRand <= 0.7)
|
|
|
|
{
|
|
|
|
iAnim = PYTHON_IDLE2;
|
|
|
|
}
|
|
|
|
else if (flRand <= 1)
|
|
|
|
{
|
|
|
|
iAnim = PYTHON_IDLE3;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + RANDOM_FLOAT( 5, 12 );
|
|
|
|
|
|
|
|
|
|
|
|
SendWeaponAnim( iAnim );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CPythonAmmo : public CBasePlayerAmmo
|
|
|
|
{
|
|
|
|
void Spawn( void )
|
|
|
|
{
|
|
|
|
Precache( );
|
|
|
|
SET_MODEL(ENT(pev), "models/w_berettaclip.mdl");
|
|
|
|
CBasePlayerAmmo::Spawn( );
|
|
|
|
}
|
|
|
|
void Precache( void )
|
|
|
|
{
|
|
|
|
PRECACHE_MODEL ("models/w_berettaclip.mdl");
|
|
|
|
PRECACHE_SOUND("items/9mmclip1.wav");
|
|
|
|
}
|
|
|
|
BOOL AddAmmo( CBaseEntity *pOther )
|
|
|
|
{
|
|
|
|
if (pOther->GiveAmmo( AMMO_357BOX_GIVE, "357", _357_MAX_CARRY ) != -1)
|
|
|
|
{
|
|
|
|
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
LINK_ENTITY_TO_CLASS( ammo_357, CPythonAmmo );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
void CPython::SecondaryAttack( void )
|
|
|
|
{
|
|
|
|
if ( !g_pGameRules->IsMultiplayer() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( m_fInZoom )
|
|
|
|
{
|
|
|
|
m_fInZoom = FALSE;
|
|
|
|
m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_fInZoom = TRUE;
|
|
|
|
m_pPlayer->m_iFOV = 40;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_flNextSecondaryAttack = gpGlobals->time + 0.5;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|