Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weapon_ashlands_carbine #218

Draft
wants to merge 2 commits into
base: ez2/mapbase
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sp/src/game/client/hl2/c_weapon__stubs_hl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ STUB_WEAPON_CLASS( weapon_arbeit_clipboard, WeaponArbeitClipboard, C_WeaponCitiz

STUB_WEAPON_CLASS( weapon_flechette_shotgun, WeaponFlechetteShotgun, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_stasis_grenade, WeaponStasisGrenade, C_BaseHLCombatWeapon );
STUB_WEAPON_CLASS( weapon_ashlands_carbine, WeaponAshlandsCarbine, C_BaseHLCombatWeapon)
#endif


153 changes: 153 additions & 0 deletions sp/src/game/server/hl2/weapon_pistol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ void CWeaponPistol::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCh
{
switch( pEvent->event )
{
#ifdef EZ2
// In case derivatives of weapon_pistol use other firing events
case EVENT_WEAPON_SMG1:
case EVENT_WEAPON_SMG2:
case EVENT_WEAPON_AR1:
case EVENT_WEAPON_AR2:
#endif
case EVENT_WEAPON_PISTOL_FIRE:
{
#ifdef EZ2
Expand Down Expand Up @@ -406,6 +413,11 @@ void CWeaponPistol::Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCh
//-----------------------------------------------------------------------------
void CWeaponPistol::FireNPCPrimaryAttack( CBaseCombatCharacter *pOperator, Vector &vecShootOrigin, Vector &vecShootDir )
{
#ifdef EZ2
if (IsSilenced())
CSoundEnt::InsertSound(SOUND_COMBAT | SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL / 3.0f, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy());
else
#endif
CSoundEnt::InsertSound( SOUND_COMBAT|SOUND_CONTEXT_GUNFIRE, pOperator->GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL, 0.2, pOperator, SOUNDENT_CHANNEL_WEAPON, pOperator->GetEnemy() );

WeaponSound( SINGLE_NPC );
Expand Down Expand Up @@ -468,6 +480,12 @@ void CWeaponPistol::PrimaryAttack( void )

m_flLastAttackTime = gpGlobals->curtime;
m_flSoonestPrimaryAttack = gpGlobals->curtime + PISTOL_FASTEST_REFIRE_TIME;

#ifdef EZ2
if (IsSilenced())
CSoundEnt::InsertSound(SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL / 3.0f, 0.2, GetOwner());
else
#endif
CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_PISTOL, 0.2, GetOwner() );

CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
Expand Down Expand Up @@ -1476,4 +1494,139 @@ BEGIN_DATADESC( CWeaponPulsePistol )
DEFINE_FIELD( m_flLastChargeSoundTime, FIELD_TIME ),
DEFINE_FIELD( m_hChargeSprite, FIELD_EHANDLE )
END_DATADESC()



//-----------------------------------------------------------------------------
// CWeaponAshlandsCarbine, a silenced semi-automatic rifle from the Wasteland
//-----------------------------------------------------------------------------
class CWeaponAshlandsCarbine : public CWeaponPistol
{
public:
DECLARE_CLASS(CWeaponAshlandsCarbine, CWeaponPistol);
DECLARE_SERVERCLASS();

void AddViewKick(void);

bool IsSilenced() const { return true; }

DECLARE_ACTTABLE();

virtual float GetFireRate(void)
{
return 0.083f;;
}
};

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponAshlandsCarbine::AddViewKick(void)
{
#define EASY_DAMPEN 2.5f
#define MAX_VERTICAL_KICK 11.0f
#define SLIDE_LIMIT 2.0f

//Get the view kick
CBasePlayer* pPlayer = ToBasePlayer(GetOwner());

if (pPlayer == NULL)
return;

DoMachineGunKick(pPlayer, EASY_DAMPEN, MAX_VERTICAL_KICK, m_fFireDuration, SLIDE_LIMIT);
}

acttable_t CWeaponAshlandsCarbine::m_acttable[] =
{
{ ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_SMG1, true },
{ ACT_RELOAD, ACT_RELOAD_SMG1, true },
{ ACT_IDLE, ACT_IDLE_SMG1, true },
{ ACT_IDLE_ANGRY, ACT_IDLE_ANGRY_SMG1, true },

{ ACT_WALK, ACT_WALK_RIFLE, true },
{ ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true },

// Readiness activities (not aiming)
{ ACT_IDLE_RELAXED, ACT_IDLE_SMG1_RELAXED, false },//never aims
{ ACT_IDLE_STIMULATED, ACT_IDLE_SMG1_STIMULATED, false },
{ ACT_IDLE_AGITATED, ACT_IDLE_ANGRY_SMG1, false },//always aims

{ ACT_WALK_RELAXED, ACT_WALK_RIFLE_RELAXED, false },//never aims
{ ACT_WALK_STIMULATED, ACT_WALK_RIFLE_STIMULATED, false },
{ ACT_WALK_AGITATED, ACT_WALK_AIM_RIFLE, false },//always aims

{ ACT_RUN_RELAXED, ACT_RUN_RIFLE_RELAXED, false },//never aims
{ ACT_RUN_STIMULATED, ACT_RUN_RIFLE_STIMULATED, false },
{ ACT_RUN_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims

// Readiness activities (aiming)
{ ACT_IDLE_AIM_RELAXED, ACT_IDLE_SMG1_RELAXED, false },//never aims
{ ACT_IDLE_AIM_STIMULATED, ACT_IDLE_AIM_RIFLE_STIMULATED, false },
{ ACT_IDLE_AIM_AGITATED, ACT_IDLE_ANGRY_SMG1, false },//always aims

{ ACT_WALK_AIM_RELAXED, ACT_WALK_RIFLE_RELAXED, false },//never aims
{ ACT_WALK_AIM_STIMULATED, ACT_WALK_AIM_RIFLE_STIMULATED, false },
{ ACT_WALK_AIM_AGITATED, ACT_WALK_AIM_RIFLE, false },//always aims

{ ACT_RUN_AIM_RELAXED, ACT_RUN_RIFLE_RELAXED, false },//never aims
{ ACT_RUN_AIM_STIMULATED, ACT_RUN_AIM_RIFLE_STIMULATED, false },
{ ACT_RUN_AIM_AGITATED, ACT_RUN_AIM_RIFLE, false },//always aims
//End readiness activities

{ ACT_WALK_AIM, ACT_WALK_AIM_RIFLE, true },
{ ACT_WALK_CROUCH, ACT_WALK_CROUCH_RIFLE, true },
{ ACT_WALK_CROUCH_AIM, ACT_WALK_CROUCH_AIM_RIFLE, true },
{ ACT_RUN, ACT_RUN_RIFLE, true },
{ ACT_RUN_AIM, ACT_RUN_AIM_RIFLE, true },
{ ACT_RUN_CROUCH, ACT_RUN_CROUCH_RIFLE, true },
{ ACT_RUN_CROUCH_AIM, ACT_RUN_CROUCH_AIM_RIFLE, true },
{ ACT_GESTURE_RANGE_ATTACK1, ACT_GESTURE_RANGE_ATTACK_SMG1, true },
{ ACT_RANGE_ATTACK1_LOW, ACT_RANGE_ATTACK_SMG1_LOW, true },
{ ACT_COVER_LOW, ACT_COVER_SMG1_LOW, false },
{ ACT_RANGE_AIM_LOW, ACT_RANGE_AIM_SMG1_LOW, false },
{ ACT_RELOAD_LOW, ACT_RELOAD_SMG1_LOW, false },
{ ACT_GESTURE_RELOAD, ACT_GESTURE_RELOAD_SMG1, true },

#if EXPANDED_HL2_WEAPON_ACTIVITIES
{ ACT_ARM, ACT_ARM_RIFLE, false },
{ ACT_DISARM, ACT_DISARM_RIFLE, false },
#endif

#if EXPANDED_HL2_COVER_ACTIVITIES
{ ACT_RANGE_AIM_MED, ACT_RANGE_AIM_SMG1_MED, false },
{ ACT_RANGE_ATTACK1_MED, ACT_RANGE_ATTACK_SMG1_MED, false },

{ ACT_COVER_WALL_R, ACT_COVER_WALL_R_RIFLE, false },
{ ACT_COVER_WALL_L, ACT_COVER_WALL_L_RIFLE, false },
{ ACT_COVER_WALL_LOW_R, ACT_COVER_WALL_LOW_R_RIFLE, false },
{ ACT_COVER_WALL_LOW_L, ACT_COVER_WALL_LOW_L_RIFLE, false },
#endif

#ifdef MAPBASE
// HL2:DM activities (for third-person animations in SP)
{ ACT_HL2MP_IDLE, ACT_HL2MP_IDLE_SMG1, false },
{ ACT_HL2MP_RUN, ACT_HL2MP_RUN_SMG1, false },
{ ACT_HL2MP_IDLE_CROUCH, ACT_HL2MP_IDLE_CROUCH_SMG1, false },
{ ACT_HL2MP_WALK_CROUCH, ACT_HL2MP_WALK_CROUCH_SMG1, false },
{ ACT_HL2MP_GESTURE_RANGE_ATTACK, ACT_HL2MP_GESTURE_RANGE_ATTACK_SMG1, false },
{ ACT_HL2MP_GESTURE_RELOAD, ACT_HL2MP_GESTURE_RELOAD_SMG1, false },
{ ACT_HL2MP_JUMP, ACT_HL2MP_JUMP_SMG1, false },
#if EXPANDED_HL2DM_ACTIVITIES
{ ACT_HL2MP_WALK, ACT_HL2MP_WALK_SMG1, false },
{ ACT_HL2MP_GESTURE_RANGE_ATTACK2, ACT_HL2MP_GESTURE_RANGE_ATTACK2_SMG1, false },
#endif
#endif
};

IMPLEMENT_ACTTABLE(CWeaponAshlandsCarbine);

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

IMPLEMENT_SERVERCLASS_ST(CWeaponAshlandsCarbine, DT_WeaponAshlandsCarbine)
END_SEND_TABLE()

LINK_ENTITY_TO_CLASS(weapon_ashlands_carbine, CWeaponAshlandsCarbine);
PRECACHE_WEAPON_REGISTER(weapon_ashlands_carbine);

#endif