2016-06-04 15:24:23 +02:00
|
|
|
/***
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
****/
|
2021-06-07 16:17:22 +02:00
|
|
|
#if !OEM_BUILD && !HLDEMO_BUILD
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
#include "extdll.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "cbase.h"
|
|
|
|
#include "monsters.h"
|
|
|
|
#include "weapons.h"
|
|
|
|
#include "nodes.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "gamerules.h"
|
|
|
|
|
2017-07-23 18:41:05 +02:00
|
|
|
enum satchel_state
|
|
|
|
{
|
|
|
|
SATCHEL_IDLE = 0,
|
|
|
|
SATCHEL_READY,
|
|
|
|
SATCHEL_RELOAD
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
enum satchel_e
|
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
SATCHEL_IDLE1 = 0,
|
|
|
|
SATCHEL_FIDGET1,
|
|
|
|
SATCHEL_DRAW,
|
|
|
|
SATCHEL_DROP
|
|
|
|
};
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
enum satchel_radio_e
|
|
|
|
{
|
2016-06-04 15:24:23 +02:00
|
|
|
SATCHEL_RADIO_IDLE1 = 0,
|
|
|
|
SATCHEL_RADIO_FIDGET1,
|
|
|
|
SATCHEL_RADIO_DRAW,
|
|
|
|
SATCHEL_RADIO_FIRE,
|
|
|
|
SATCHEL_RADIO_HOLSTER
|
|
|
|
};
|
|
|
|
|
|
|
|
class CSatchelCharge : public CGrenade
|
|
|
|
{
|
2017-07-17 07:11:39 +02:00
|
|
|
Vector m_lastBounceOrigin; // Used to fix a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set
|
2016-06-04 15:24:23 +02:00
|
|
|
void Spawn( void );
|
|
|
|
void Precache( void );
|
|
|
|
void BounceSound( void );
|
|
|
|
|
|
|
|
void EXPORT SatchelSlide( CBaseEntity *pOther );
|
|
|
|
void EXPORT SatchelThink( void );
|
|
|
|
|
|
|
|
public:
|
|
|
|
void Deactivate( void );
|
|
|
|
};
|
2016-06-25 18:33:39 +02:00
|
|
|
|
|
|
|
LINK_ENTITY_TO_CLASS( monster_satchel, CSatchelCharge )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// Deactivate - do whatever it is we do to an orphaned
|
|
|
|
// satchel when we don't want it in the world anymore.
|
|
|
|
//=========================================================
|
|
|
|
void CSatchelCharge::Deactivate( void )
|
|
|
|
{
|
|
|
|
pev->solid = SOLID_NOT;
|
|
|
|
UTIL_Remove( this );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CSatchelCharge::Spawn( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
Precache();
|
2016-06-04 15:24:23 +02:00
|
|
|
// motor
|
|
|
|
pev->movetype = MOVETYPE_BOUNCE;
|
|
|
|
pev->solid = SOLID_BBOX;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
SET_MODEL( ENT( pev ), "models/w_satchel.mdl" );
|
|
|
|
//UTIL_SetSize( pev, Vector( -16, -16, -4 ), Vector( 16, 16, 32 ) ); // Old box -- size of headcrab monsters/players get blocked by this
|
|
|
|
UTIL_SetSize( pev, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) ); // Uses point-sized, and can be stepped over
|
2016-06-04 15:24:23 +02:00
|
|
|
UTIL_SetOrigin( pev, pev->origin );
|
|
|
|
|
|
|
|
SetTouch( &CSatchelCharge::SatchelSlide );
|
|
|
|
SetUse( &CGrenade::DetonateUse );
|
|
|
|
SetThink( &CSatchelCharge::SatchelThink );
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->gravity = 0.5f;
|
|
|
|
pev->friction = 0.8f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
pev->dmg = gSkillData.plrDmgSatchel;
|
2016-07-31 15:48:50 +02:00
|
|
|
// ResetSequenceInfo();
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->sequence = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSatchelCharge::SatchelSlide( CBaseEntity *pOther )
|
|
|
|
{
|
2017-06-29 15:56:03 +02:00
|
|
|
//entvars_t *pevOther = pOther->pev;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
// don't hit the guy that launched this grenade
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pOther->edict() == pev->owner )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
// pev->avelocity = Vector( 300, 300, 300 );
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->gravity = 1;// normal gravity now
|
|
|
|
|
|
|
|
// HACKHACK - On ground isn't always set, so look for ground underneath
|
|
|
|
TraceResult tr;
|
2016-07-31 15:48:50 +02:00
|
|
|
UTIL_TraceLine( pev->origin, pev->origin - Vector( 0, 0, 10 ), ignore_monsters, edict(), &tr );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
if( tr.flFraction < 1.0f )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// add a bit of static friction
|
|
|
|
pev->velocity = pev->velocity * 0.95;
|
|
|
|
pev->avelocity = pev->avelocity * 0.9;
|
|
|
|
// play sliding sound, volume based on velocity
|
|
|
|
}
|
2019-10-13 13:49:25 +02:00
|
|
|
if( !( pev->flags & FL_ONGROUND ) && pev->velocity.Length2D() > 10.0f )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-17 07:11:39 +02:00
|
|
|
// Fix for a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set
|
|
|
|
if( pev->origin != m_lastBounceOrigin )
|
2017-07-18 23:51:17 +02:00
|
|
|
BounceSound();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2017-07-17 07:11:39 +02:00
|
|
|
m_lastBounceOrigin = pev->origin;
|
2017-07-18 23:51:17 +02:00
|
|
|
// There is no model animation so commented this out to prevent net traffic
|
|
|
|
// StudioFrameAdvance();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CSatchelCharge::SatchelThink( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-18 23:51:17 +02:00
|
|
|
// There is no model animation so commented this out to prevent net traffic
|
|
|
|
// StudioFrameAdvance();
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->nextthink = gpGlobals->time + 0.1f;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !IsInWorld() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
UTIL_Remove( this );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pev->waterlevel == 3 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->movetype = MOVETYPE_FLY;
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->velocity = pev->velocity * 0.8f;
|
|
|
|
pev->avelocity = pev->avelocity * 0.9f;
|
2016-06-04 15:24:23 +02:00
|
|
|
pev->velocity.z += 8;
|
|
|
|
}
|
2016-07-31 15:48:50 +02:00
|
|
|
else if( pev->waterlevel == 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pev->movetype = MOVETYPE_BOUNCE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
pev->velocity.z -= 8.0f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CSatchelCharge::Precache( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-17 07:11:39 +02:00
|
|
|
PRECACHE_MODEL( "models/w_satchel.mdl" );
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_SOUND( "weapons/g_bounce1.wav" );
|
|
|
|
PRECACHE_SOUND( "weapons/g_bounce2.wav" );
|
|
|
|
PRECACHE_SOUND( "weapons/g_bounce3.wav" );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CSatchelCharge::BounceSound( void )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( RANDOM_LONG( 0, 2 ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
case 0:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce1.wav", 1, ATTN_NORM );
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce2.wav", 1, ATTN_NORM );
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce3.wav", 1, ATTN_NORM );
|
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-25 18:33:39 +02:00
|
|
|
LINK_ENTITY_TO_CLASS( weapon_satchel, CSatchel )
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal
|
|
|
|
//=========================================================
|
|
|
|
int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal )
|
|
|
|
{
|
|
|
|
CSatchel *pSatchel;
|
|
|
|
|
2021-06-07 02:05:58 +02:00
|
|
|
#if CLIENT_DLL
|
2016-07-31 15:48:50 +02:00
|
|
|
if( bIsMultiplayer() )
|
2016-06-04 15:24:23 +02:00
|
|
|
#else
|
2016-07-31 15:48:50 +02:00
|
|
|
if( g_pGameRules->IsMultiplayer() )
|
2016-06-04 15:24:23 +02:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
pSatchel = (CSatchel *)pOriginal;
|
|
|
|
|
2017-07-23 18:41:05 +02:00
|
|
|
if( pSatchel->m_chargeReady != SATCHEL_IDLE )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// player has some satchels deployed. Refuse to add more.
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
return CBasePlayerWeapon::AddDuplicate( pOriginal );
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
|
|
|
int CSatchel::AddToPlayer( CBasePlayer *pPlayer )
|
|
|
|
{
|
|
|
|
int bResult = CBasePlayerItem::AddToPlayer( pPlayer );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
pPlayer->pev->weapons |= ( 1 << m_iId );
|
2017-07-23 18:41:05 +02:00
|
|
|
m_chargeReady = SATCHEL_IDLE;// this satchel charge weapon now forgets that any satchels are deployed by it.
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( bResult )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
return AddWeapon();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
void CSatchel::Spawn()
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
Precache();
|
2016-06-04 15:24:23 +02:00
|
|
|
m_iId = WEAPON_SATCHEL;
|
2016-07-31 15:48:50 +02:00
|
|
|
SET_MODEL( ENT( pev ), "models/w_satchel.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
m_iDefaultAmmo = SATCHEL_DEFAULT_GIVE;
|
|
|
|
|
|
|
|
FallInit();// get ready to fall down.
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSatchel::Precache( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
PRECACHE_MODEL( "models/v_satchel.mdl" );
|
|
|
|
PRECACHE_MODEL( "models/v_satchel_radio.mdl" );
|
|
|
|
PRECACHE_MODEL( "models/w_satchel.mdl" );
|
|
|
|
PRECACHE_MODEL( "models/p_satchel.mdl" );
|
|
|
|
PRECACHE_MODEL( "models/p_satchel_radio.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
|
|
|
UTIL_PrecacheOther( "monster_satchel" );
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
int CSatchel::GetItemInfo( ItemInfo *p )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
p->pszName = STRING( pev->classname );
|
2016-06-04 15:24:23 +02:00
|
|
|
p->pszAmmo1 = "Satchel Charge";
|
|
|
|
p->iMaxAmmo1 = SATCHEL_MAX_CARRY;
|
|
|
|
p->pszAmmo2 = NULL;
|
|
|
|
p->iMaxAmmo2 = -1;
|
|
|
|
p->iMaxClip = WEAPON_NOCLIP;
|
|
|
|
p->iSlot = 4;
|
|
|
|
p->iPosition = 1;
|
|
|
|
p->iFlags = ITEM_FLAG_SELECTONEMPTY | ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE;
|
|
|
|
p->iId = m_iId = WEAPON_SATCHEL;
|
|
|
|
p->iWeight = SATCHEL_WEIGHT;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
//=========================================================
|
|
|
|
BOOL CSatchel::IsUseable( void )
|
|
|
|
{
|
2017-07-23 18:41:05 +02:00
|
|
|
return CanDeploy();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL CSatchel::CanDeploy( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// player is carrying some satchels
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-07-23 18:41:05 +02:00
|
|
|
if( m_chargeReady )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
// player isn't carrying any satchels, but has some out
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
BOOL CSatchel::Deploy()
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0f;
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10.0f, 15.0f );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_chargeReady )
|
2016-06-04 15:24:23 +02:00
|
|
|
return DefaultDeploy( "models/v_satchel_radio.mdl", "models/p_satchel_radio.mdl", SATCHEL_RADIO_DRAW, "hive" );
|
|
|
|
else
|
|
|
|
return DefaultDeploy( "models/v_satchel.mdl", "models/p_satchel.mdl", SATCHEL_DRAW, "trip" );
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSatchel::Holster( int skiplocal /* = 0 */ )
|
|
|
|
{
|
2019-10-13 13:49:25 +02:00
|
|
|
m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5f;
|
2016-07-31 15:48:50 +02:00
|
|
|
|
|
|
|
if( m_chargeReady )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
SendWeaponAnim( SATCHEL_RADIO_HOLSTER );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SendWeaponAnim( SATCHEL_DROP );
|
|
|
|
}
|
2019-10-13 13:49:25 +02:00
|
|
|
EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0f, ATTN_NORM );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-07-23 18:41:05 +02:00
|
|
|
if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && m_chargeReady != SATCHEL_READY )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SATCHEL );
|
2017-07-23 18:41:05 +02:00
|
|
|
DestroyItem();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSatchel::PrimaryAttack()
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
switch( m_chargeReady )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-23 18:41:05 +02:00
|
|
|
case SATCHEL_IDLE:
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-23 18:41:05 +02:00
|
|
|
Throw();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
break;
|
2017-07-23 18:41:05 +02:00
|
|
|
case SATCHEL_READY:
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-23 18:41:05 +02:00
|
|
|
SendWeaponAnim( SATCHEL_RADIO_FIRE );
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-07-23 18:41:05 +02:00
|
|
|
edict_t *pPlayer = m_pPlayer->edict();
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-07-23 18:41:05 +02:00
|
|
|
CBaseEntity *pSatchel = NULL;
|
2016-06-04 15:24:23 +02:00
|
|
|
|
2017-07-23 18:41:05 +02:00
|
|
|
while( ( pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 ) ) != NULL )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-23 18:41:05 +02:00
|
|
|
if( FClassnameIs( pSatchel->pev, "monster_satchel" ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2017-07-23 18:41:05 +02:00
|
|
|
if( pSatchel->pev->owner == pPlayer )
|
|
|
|
{
|
|
|
|
pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 );
|
|
|
|
}
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-23 18:41:05 +02:00
|
|
|
m_chargeReady = SATCHEL_RELOAD;
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flNextPrimaryAttack = GetNextAttackDelay( 0.5f );
|
|
|
|
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f;
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f;
|
2017-07-23 18:41:05 +02:00
|
|
|
break;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
2017-07-23 18:41:05 +02:00
|
|
|
case SATCHEL_RELOAD:
|
2016-06-04 15:24:23 +02:00
|
|
|
// we're reloading, don't allow fire
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSatchel::SecondaryAttack( void )
|
|
|
|
{
|
2017-07-23 18:41:05 +02:00
|
|
|
if( m_chargeReady != SATCHEL_RELOAD )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
Throw();
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSatchel::Throw( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2021-06-07 02:05:58 +02:00
|
|
|
#if !CLIENT_DLL
|
2016-06-04 15:24:23 +02:00
|
|
|
Vector vecSrc = m_pPlayer->pev->origin;
|
|
|
|
|
|
|
|
Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
CBaseEntity *pSatchel = Create( "monster_satchel", vecSrc, Vector( 0, 0, 0 ), m_pPlayer->edict() );
|
2016-06-04 15:24:23 +02:00
|
|
|
pSatchel->pev->velocity = vecThrow;
|
|
|
|
pSatchel->pev->avelocity.y = 400;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_satchel_radio.mdl" );
|
|
|
|
m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_satchel_radio.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
#else
|
2016-07-31 15:48:50 +02:00
|
|
|
LoadVModel( "models/v_satchel_radio.mdl", m_pPlayer );
|
2016-06-04 15:24:23 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
SendWeaponAnim( SATCHEL_RADIO_DRAW );
|
|
|
|
|
|
|
|
// player "shoot" animation
|
|
|
|
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
|
|
|
|
2017-07-23 18:41:05 +02:00
|
|
|
m_chargeReady = SATCHEL_READY;
|
|
|
|
|
2016-06-04 15:24:23 +02:00
|
|
|
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flNextPrimaryAttack = GetNextAttackDelay( 1.0f );
|
|
|
|
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f;
|
2016-06-04 15:24:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSatchel::WeaponIdle( void )
|
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
|
2016-06-04 15:24:23 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch( m_chargeReady )
|
|
|
|
{
|
2017-07-23 18:41:05 +02:00
|
|
|
case SATCHEL_IDLE:
|
2016-06-04 15:24:23 +02:00
|
|
|
SendWeaponAnim( SATCHEL_FIDGET1 );
|
|
|
|
// use tripmine animations
|
|
|
|
strcpy( m_pPlayer->m_szAnimExtention, "trip" );
|
|
|
|
break;
|
2017-07-23 18:41:05 +02:00
|
|
|
case SATCHEL_READY:
|
2016-06-04 15:24:23 +02:00
|
|
|
SendWeaponAnim( SATCHEL_RADIO_FIDGET1 );
|
|
|
|
// use hivehand animations
|
|
|
|
strcpy( m_pPlayer->m_szAnimExtention, "hive" );
|
|
|
|
break;
|
2017-07-23 18:41:05 +02:00
|
|
|
case SATCHEL_RELOAD:
|
2016-07-31 15:48:50 +02:00
|
|
|
if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
m_chargeReady = 0;
|
|
|
|
RetireWeapon();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-07 02:05:58 +02:00
|
|
|
#if !CLIENT_DLL
|
2016-07-31 15:48:50 +02:00
|
|
|
m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_satchel.mdl" );
|
|
|
|
m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_satchel.mdl" );
|
2016-06-04 15:24:23 +02:00
|
|
|
#else
|
2016-07-31 15:48:50 +02:00
|
|
|
LoadVModel( "models/v_satchel.mdl", m_pPlayer );
|
2016-06-04 15:24:23 +02:00
|
|
|
#endif
|
|
|
|
SendWeaponAnim( SATCHEL_DRAW );
|
|
|
|
|
|
|
|
// use tripmine animations
|
|
|
|
strcpy( m_pPlayer->m_szAnimExtention, "trip" );
|
|
|
|
|
2019-10-13 13:49:25 +02:00
|
|
|
m_flNextPrimaryAttack = GetNextAttackDelay( 0.5f );
|
|
|
|
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5f;
|
2017-07-23 18:41:05 +02:00
|
|
|
m_chargeReady = SATCHEL_IDLE;
|
2016-06-04 15:24:23 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again.
|
|
|
|
}
|
|
|
|
|
|
|
|
//=========================================================
|
|
|
|
// DeactivateSatchels - removes all satchels owned by
|
|
|
|
// the provided player. Should only be used upon death.
|
|
|
|
//
|
|
|
|
// Made this global on purpose.
|
|
|
|
//=========================================================
|
|
|
|
void DeactivateSatchels( CBasePlayer *pOwner )
|
|
|
|
{
|
|
|
|
edict_t *pFind;
|
|
|
|
|
|
|
|
pFind = FIND_ENTITY_BY_CLASSNAME( NULL, "monster_satchel" );
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
while( !FNullEnt( pFind ) )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
CBaseEntity *pEnt = CBaseEntity::Instance( pFind );
|
|
|
|
CSatchelCharge *pSatchel = (CSatchelCharge *)pEnt;
|
|
|
|
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pSatchel )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
2016-07-31 15:48:50 +02:00
|
|
|
if( pSatchel->pev->owner == pOwner->edict() )
|
2016-06-04 15:24:23 +02:00
|
|
|
{
|
|
|
|
pSatchel->Deactivate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pFind = FIND_ENTITY_BY_CLASSNAME( pFind, "monster_satchel" );
|
|
|
|
}
|
|
|
|
}
|
2016-04-17 22:30:05 +02:00
|
|
|
#endif
|