Skip to content
Merged
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ out
/game/neo/particles
/game/neo/shaders
/game/neo/models
/game/neo/modelsrc
/game/neo/materials/temp
/game/neo/resource/*.sfd
/game/neo/resource/*.ttf
Expand Down
59 changes: 55 additions & 4 deletions src/game/shared/neo/weapons/weapon_neobasecombatweapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,23 @@ void CNEOBaseCombatWeapon::Equip(CBaseCombatCharacter* pOwner)

bool CNEOBaseCombatWeapon::Reload( void )
{
if (!BaseClass::Reload())
const bool bEmptyReload = UsesClipsForAmmo1() && m_iClip1 <= 0 &&
SelectWeightedSequence(ACT_VM_RELOAD_EMPTY) != ACTIVITY_NOT_AVAILABLE;

const bool bReloaded = bEmptyReload
? DefaultReload(GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD_EMPTY)
: BaseClass::Reload();
if (!bReloaded)
{
return false;
}

if (bEmptyReload)
{
// others see the reload, as for a reload with rounds left
ToHL2MPPlayer(GetOwner())->DoAnimationEvent(PLAYERANIMEVENT_RELOAD);
}

// The magazine loads at the gun's last reload click, which the script gives as a time before the reload animation ends;
// the animation and the wait to fire still run to the end
m_flReloadReadyTime = Max(gpGlobals->curtime, m_flNextPrimaryAttack - GetNEOWpnData().m_flReloadReadyBeforeEnd);
Expand Down Expand Up @@ -518,6 +530,16 @@ bool CNEOBaseCombatWeapon::Deploy(void)
AddEffects(EF_BONEMERGE);
m_bTriggerReset = true;

// An empty weapon draws with its slide held back where the model has that draw,
// which carries no activity, so it is picked by name
static constexpr const char *VM_SEQ_DRAW_EMPTY = "drawempty";
const int iDrawEmpty = (UsesClipsForAmmo1() && m_iClip1 <= 0) ? LookupSequence(VM_SEQ_DRAW_EMPTY) : ACTIVITY_NOT_AVAILABLE;
if (iDrawEmpty != ACTIVITY_NOT_AVAILABLE)
{
SetSequence(iDrawEmpty);
SendViewModelAnim(iDrawEmpty);
}

#ifdef DEBUG
CNEO_Player* pOwner = NULL;
if (GetOwner())
Expand Down Expand Up @@ -967,6 +989,22 @@ void CNEOBaseCombatWeapon::DryFire()
m_flNextPrimaryAttack = gpGlobals->curtime + GetFastestDryRefireTime(); // SequenceDuration();
}

// An empty weapon idles on its empty sequence where the model has one, such as a pistol with its slide held back
bool CNEOBaseCombatWeapon::SendWeaponAnim(int iActivity)
{
if (iActivity == ACT_VM_IDLE && UsesClipsForAmmo1() && m_iClip1 <= 0 && HasEmptyIdle())
{
iActivity = ACT_VM_IDLE_EMPTY;
}

return BaseClass::SendWeaponAnim(iActivity);
}

bool CNEOBaseCombatWeapon::HasEmptyIdle()
{
return SelectWeightedSequence(ACT_VM_IDLE_EMPTY) != ACTIVITY_NOT_AVAILABLE;
}

void CNEOBaseCombatWeapon::PrimaryAttack(void)
{
if (ShootingIsPrevented())
Expand Down Expand Up @@ -1045,8 +1083,6 @@ void CNEOBaseCombatWeapon::PrimaryAttack(void)
#endif // GAME_DLL
}

SendWeaponAnim(GetPrimaryAttackActivity());
SetWeaponIdleTime(gpGlobals->curtime + 2.0);
if (IsSemiAuto())
{
m_bTriggerReset = false;
Expand Down Expand Up @@ -1090,6 +1126,22 @@ void CNEOBaseCombatWeapon::PrimaryAttack(void)
m_iPrimaryAmmoCount -= info.m_iShots;
}

// the last round's shot locks a pistol's slide back:
// the pistols' dry fire sequence is a shot's kick with the slide held back,
static constexpr NEO_WEP_BITS_UNDERLYING_TYPE NEO_WEP_SLIDE_LOCK = NEO_WEP_MILSO | NEO_WEP_TACHI;
if (UsesClipsForAmmo1() && m_iClip1 <= 0 && (GetNeoWepBits() & NEO_WEP_SLIDE_LOCK))
{
SendWeaponAnim(ACT_VM_DRYFIRE);
}
else
{
SendWeaponAnim(GetPrimaryAttackActivity());
}

// and goes straight on to the empty idle when it ends
const bool bEmptyIdleNext = UsesClipsForAmmo1() && m_iClip1 <= 0 && HasEmptyIdle();
SetWeaponIdleTime(gpGlobals->curtime + (bEmptyIdleNext ? SequenceDuration() : 2.0));

info.m_flDistance = MAX_TRACE_LENGTH;
info.m_iAmmoType = m_iPrimaryAmmoType;
info.m_iTracerFreq = UsesTracers() ? 1 : 0;
Expand Down Expand Up @@ -1469,4 +1521,3 @@ const char *CNEOBaseCombatWeapon::GetDeathIcon(const CNEOBaseCombatWeapon *pNeoW
}
return "";
}

2 changes: 2 additions & 0 deletions src/game/shared/neo/weapons/weapon_neobasecombatweapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon
#endif

virtual void DryFire(void);
virtual bool SendWeaponAnim(int iActivity) override;

virtual Activity GetPrimaryAttackActivity(void) override;
#ifdef CLIENT_DLL
Expand Down Expand Up @@ -295,6 +296,7 @@ class CNEOBaseCombatWeapon : public CBaseHL2MPCombatWeapon

private:
CNEOBaseCombatWeapon(const CNEOBaseCombatWeapon &other);
bool HasEmptyIdle();

};

Expand Down
Loading