You need to login in order to create posts and topics. » Login
I can not find the code for changing the animation of HL-weapons in Pr ...

I study the principle of the operation of weapons. I cannot understand where the changing animation of the weapon is being caused during the shot.

//----------------------------------------------//

// Code MP5
void CMP5::Precache( void )
{
PRECACHE_MODEL("models/v_9mmAR.mdl");
PRECACHE_MODEL("models/w_9mmAR.mdl");
PRECACHE_MODEL("models/p_9mmAR.mdl");

m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shellTE_MODEL

PRECACHE_MODEL("models/grenade.mdl"); // grenade

PRECACHE_MODEL("models/w_9mmARclip.mdl");
PRECACHE_SOUND("items/9mmclip1.wav");

PRECACHE_SOUND("items/clipinsert1.wav");
PRECACHE_SOUND("items/cliprelease1.wav");

//Sounds of shots
PRECACHE_SOUND ("weapons/hks1.wav");
PRECACHE_SOUND ("weapons/hks2.wav");
PRECACHE_SOUND ("weapons/hks3.wav");

PRECACHE_SOUND( "weapons/glauncher.wav" );
PRECACHE_SOUND( "weapons/glauncher2.wav" );

PRECACHE_SOUND ("weapons/357_cock1.wav");

m_usMP5 = PRECACHE_EVENT( 1, "events/mp5.sc" );
m_usMP52 = PRECACHE_EVENT( 1, "events/mp52.sc" );
}

void CMP5::PrimaryAttack()
{
// don't fire underwater
if (m_pPlayer->pev->waterlevel == 3)
{
PlayEmptySound( );
m_flNextPrimaryAttack = 0.15;
return;
}

if (m_iClip <= 0)
{
PlayEmptySound();
m_flNextPrimaryAttack = 0.15;
return;
}

m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;

m_iClip--;

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
{
// optimized multiplayer. Widened to make it easier to hit a moving player
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_6DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}
else
{
// single player spread
vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed );
}

int flags;
#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST;
#else
flags = 0;
#endif

PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 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);

m_flNextPrimaryAttack = GetNextAttackDelay(0.1);

if ( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() )
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1;

m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}

BOOL CMP5:Deploy( )
{
return DefaultDeploy( "models/v_9mmAR.mdl", "models/p_9mmAR.mdl", MP5_DEPLOY, "mp5" );
}

void CMP5::Reload( void )
{
if ( m_pPlayer->ammo_9mm <= 0 )
return;

DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5 );
}

//----------------------------------------------//

Procedure SendWeaponAnim is changing property pev->weaponanim. Procedure is called in DefaultDeploy and Reload. I think, engine is checking each animation of the weapon model (In our case - v_9mmar.mdl) contains the path to the sound file. Animation for fire of these model hasn't path to the sound file. If delete (/*commented*/) body PrimaryAttack then be playing sound fire and draw decal.

How? How does he know the path to the sound files and the number of weapons animations (This is in all the weapons of the project hldll). I can add code in PrimaryAttack procedure SendWeaponAnim and EMIT_SOUND_DYN for sound, but i'm interested in how to do better.

P.S. I'm used translate.google.com.

I found out the answers to my questions. Maybe someone will come in handy.

Check the project hl_cdll.

Source Files->_hl->cl_dll->hl->ev_hldm.cpp.

Here are called sounds fire and more...

Glad you found it. Also Thanks for posting back with a solution 🙂

Stay in Touch

Discover the Community

Copyright © 2018 www.sourcemodding.com
Sourcemodding is made in Ireland and brought to you by this Eejit.
All trademarks are property of their respective owners in the US and other countries.
Disclaimer

Disclaimer!

Sourcemodding is in no way affiliated with the Valve Corporation. This a non-profit community driven website using content from myself, Valve and the Community. All files are provided as is and are simply mirrors of files that can easily be found through a smart Google/Bing/Yahoo/DuckDuckGo search. If you dispute anything on the website or want something removed please get in touch.