Skip to content

Commit

Permalink
Merge pull request #156 from BSVino/melee-balance
Browse files Browse the repository at this point in the history
Rebalance melee
  • Loading branch information
TomyLobo authored Dec 24, 2020
2 parents e64b07a + 8585057 commit ebc32e4
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 9 deletions.
4 changes: 2 additions & 2 deletions mp/game/dab/scripts/weapon_brawl.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
WeaponData
{
// Weapon characteristics:
"Damage" "45" // Punch
"SecondaryDamage" "85" // Kick
"Damage" "25" // Punch
"SecondaryDamage" "45" // Kick
"Bullets" "1" // bullets per shoot
"CycleTime" "0.35" // time between shoots
"SecondaryCycleTime" "0.6"
Expand Down
2 changes: 2 additions & 0 deletions mp/src/game/client/sdk/c_sdk_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ END_RECV_TABLE()

BEGIN_RECV_TABLE_NOBASE( C_SDKPlayer, DT_SDKLocalPlayerExclusive )
RecvPropInt( RECVINFO( m_iShotsFired ) ),
RecvPropInt( RECVINFO( m_iPunchesThrown ) ),
RecvPropVector( RECVINFO_NAME( m_vecNetworkOrigin, m_vecOrigin ) ),

RecvPropFloat( RECVINFO_NAME( m_angEyeAngles.x, m_angEyeAngles[0] ) ),
Expand Down Expand Up @@ -338,6 +339,7 @@ BEGIN_PREDICTION_DATA( C_SDKPlayer )
DEFINE_PRED_FIELD( m_flDisarmRedraw, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flCycle, FIELD_FLOAT, FTYPEDESC_OVERRIDE | FTYPEDESC_PRIVATE | FTYPEDESC_NOERRORCHECK ),
DEFINE_PRED_FIELD( m_iShotsFired, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_iPunchesThrown, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flStylePoints, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flStyleSkillCharge, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flStyleSkillActivationTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
Expand Down
6 changes: 6 additions & 0 deletions mp/src/game/client/sdk/c_sdk_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ class C_SDKPlayer : public C_BasePlayer
void ClearShotsFired() { m_iShotsFired = 0; }
int GetShotsFired() { return m_iShotsFired; }

void IncreasePunchesThrown() { m_iPunchesThrown++; if (m_iPunchesThrown > 16) m_iPunchesThrown = 16; }
void DecreasePunchesThrown() { m_iPunchesThrown--; if (m_iPunchesThrown < 0) m_iPunchesThrown = 0; }
void ClearPunchesThrown() { m_iPunchesThrown = 0; }
int GetPunchesThrown() { return m_iPunchesThrown; }

virtual void DoMuzzleFlash(int iAkimbo = 0);
virtual void MakeTracer( const Vector &vecTracerSrc, const trace_t &tr, int iTracerType, bool bUseTracerAttachment );

Expand Down Expand Up @@ -306,6 +311,7 @@ class C_SDKPlayer : public C_BasePlayer
CInterpolatedVar< QAngle > m_iv_angEyeAngles;

CNetworkVar( int, m_iShotsFired ); // number of shots fired recently
CNetworkVar( int, m_iPunchesThrown ); // number of punches thrown recently

CNetworkVar( float, m_flFreezeUntil );
CNetworkVar( float, m_flFreezeAmount );
Expand Down
1 change: 1 addition & 0 deletions mp/src/game/server/sdk/sdk_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ END_SEND_TABLE()

BEGIN_SEND_TABLE_NOBASE( CSDKPlayer, DT_SDKLocalPlayerExclusive )
SendPropInt( SENDINFO( m_iShotsFired ), 8, SPROP_UNSIGNED ),
SendPropInt( SENDINFO( m_iPunchesThrown ), 8, SPROP_UNSIGNED ),
// send a hi-res origin to the local player for use in prediction
SendPropVector (SENDINFO(m_vecOrigin), -1, SPROP_NOSCALE|SPROP_CHANGES_OFTEN, 0.0f, HIGH_DEFAULT, SendProxy_Origin ),

Expand Down
6 changes: 6 additions & 0 deletions mp/src/game/server/sdk/sdk_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class CSDKPlayer : public CBaseMultiplayerPlayer

CNetworkQAngle( m_angEyeAngles ); // Copied from EyeAngles() so we can send it to the client.
CNetworkVar( int, m_iShotsFired ); // number of shots fired recently
CNetworkVar( int, m_iPunchesThrown ); // number of punches thrown recently

// Tracks our ragdoll entity.
CNetworkHandle( CBaseEntity, m_hRagdoll ); // networked entity handle
Expand Down Expand Up @@ -277,6 +278,11 @@ class CSDKPlayer : public CBaseMultiplayerPlayer
void ClearShotsFired() { m_iShotsFired = 0; }
int GetShotsFired() { return m_iShotsFired; }

void IncreasePunchesThrown() { m_iPunchesThrown++; if (m_iPunchesThrown > 16) m_iPunchesThrown = 16; }
void DecreasePunchesThrown() { m_iPunchesThrown--; if (m_iPunchesThrown < 0) m_iPunchesThrown = 0; }
void ClearPunchesThrown() { m_iPunchesThrown = 0; }
int GetPunchesThrown() { return m_iPunchesThrown; }

virtual void FreezePlayer(float flAmount = 0, float flTime = -1);
virtual bool PlayerFrozen();

Expand Down
5 changes: 5 additions & 0 deletions mp/src/game/shared/sdk/sdk_weapon_melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ void CWeaponSDKMelee::ItemPostFrame( void )
{
WeaponIdle();
}

if ( !( pPlayer->m_nButtons & (IN_ATTACK|IN_ATTACK2) ) && pPlayer->GetPunchesThrown() )
{
pPlayer->ClearPunchesThrown();
}
}

void CWeaponSDKMelee::PrimaryAttack()
Expand Down
29 changes: 22 additions & 7 deletions mp/src/game/shared/sdk/weapon_sdkbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ void CWeaponSDKBase::StartSwing(bool bIsSecondary, bool bIsStockAttack)
if ( !pOwner )
return;

if (pOwner->GetPunchesThrown() > 5)
return;

if (!bIsStockAttack && bIsSecondary && pOwner->m_Shared.IsDiving())
return;

Expand Down Expand Up @@ -581,10 +584,7 @@ void CWeaponSDKBase::Swing()
}
}

if (m_bSwingSecondary)
pOwner->UseStyleCharge(SKILL_BOUNCER, 5);
else
pOwner->UseStyleCharge(SKILL_BOUNCER, 2.5f);
pOwner->UseStyleCharge(SKILL_BOUNCER, GetMeleeDamage(m_bSwingSecondary, NULL) / 10);

// -------------------------
// Miss
Expand All @@ -603,6 +603,8 @@ void CWeaponSDKBase::Swing()
{
Hit( traceHit, m_bSwingSecondary );
}

pOwner->IncreasePunchesThrown();
}

Activity CWeaponSDKBase::ChooseIntersectionPointAndActivity( trace_t &hitTrace, const Vector &mins, const Vector &maxs, CSDKPlayer *pOwner )
Expand Down Expand Up @@ -782,10 +784,18 @@ float CWeaponSDKBase::GetMeleeDamage( bool bIsSecondary, CSDKPlayer* pVictim ) c
{
CSDKPlayer *pPlayer = ToSDKPlayer( GetOwner() );

// The heavier the damage the more it hurts.
float flDamage = RemapVal(GetSDKWpnData().iWeight, 7, 20, 45, 80);
float flDamage;

//bool bIsStockAttack = pPlayer && pPlayer->GetActiveSDKWeapon() && !pPlayer->GetActiveSDKWeapon()->IsMeleeWeapon();
bool bIsStockAttack = pPlayer && pPlayer->GetActiveSDKWeapon() && !pPlayer->GetActiveSDKWeapon()->IsMeleeWeapon();
if (bIsStockAttack)
{
// The heavier the damage the more it hurts.
flDamage = RemapVal(GetWeight(), 7, 20, 25, 45);
}
else {
// Get the damage from the weapon script.
flDamage = bIsSecondary ? GetSDKWpnData().m_iSecondaryDamage : GetSDKWpnData().m_iDamage;
}

if (pVictim)
{
Expand Down Expand Up @@ -1558,6 +1568,11 @@ void CWeaponSDKBase::ItemPostFrame( void )
pPlayer->DecreaseShotsFired();
}
}

if ( !( pPlayer->m_nButtons & IN_ATTACK2 ) )
{
pPlayer->ClearPunchesThrown();
}
}

ConVar da_drop_overflow_on_pickup("da_drop_overflow_on_pickup", "0", FCVAR_ARCHIVE | FCVAR_USERINFO | FCVAR_CLIENTDLL, "Enable to drop weapons in order to make room for what you pick up.");
Expand Down

0 comments on commit ebc32e4

Please sign in to comment.