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

Forward for shove speed. #1

Open
eyal282 opened this issue Sep 17, 2023 · 0 comments
Open

Forward for shove speed. #1

eyal282 opened this issue Sep 17, 2023 · 0 comments

Comments

@eyal282
Copy link

eyal282 commented Sep 17, 2023

L4D2Direct_SetNextShoveTime from Left4dhooks should be enough to control shove speed after shoving is done.

`_DWORD *__usercall CTerrorWeapon::TrySwing@(
long double a1@,
__m128 a2@,
CTerrorWeapon *this,
float a4,
float a5,
float a6)
{
_DWORD *result; // eax
_DWORD *v7; // edi
int TeamNumber; // eax
int v9; // eax
int v10; // xmm0_4
float v11; // xmm1_4
float v12; // xmm0_4
float v13; // xmm1_4
float v14; // xmm0_4
int ShovePenalty; // esi
int v16; // edx
int v17; // eax
__m128 v18; // xmm2
float v19; // xmm0_4
__m128 v20; // xmm7
float v21; // xmm0_4
float v22; // xmm0_4
int v23; // eax
float v24; // xmm2_4
__m128 v25; // xmm0
CTerrorGameRules *v26; // [esp+0h] [ebp-48h]
CTerrorGameRules *v27; // [esp+0h] [ebp-48h]
int v28; // [esp+14h] [ebp-34h]
float v29; // [esp+18h] [ebp-30h]
float v30; // [esp+1Ch] [ebp-2Ch]
float v31; // [esp+20h] [ebp-28h]
float v32; // [esp+20h] [ebp-28h]
float v33; // [esp+20h] [ebp-28h]
float v34; // [esp+20h] [ebp-28h]
float v35; // [esp+2Ch] [ebp-1Ch]

result = (_DWORD )((int (__cdecl **)(CTerrorWeapon ))((_DWORD *)this + 1552))(this);
if ( (_BYTE)result )
return result;
result = (_DWORD *)CTerrorWeapon::GetPlayerOwner(this);
v7 = result;
if ( !result )
return result;
result = (_DWORD )((int (__cdecl **)(_DWORD *))(*result + 2264))(result);
if ( !(_BYTE)result )
return result;
result = (_DWORD )((int (__cdecl **)(_DWORD *))(*v7 + 2024))(v7);
if ( (_BYTE)result )
return result;
result = (_DWORD )((int (__cdecl **)(_DWORD *))(*v7 + 1368))(v7);
if ( (_BYTE)result )
return result;
result = (_DWORD *)CTerrorPlayer::IsLunging((CTerrorPlayer *)v7);
if ( (_BYTE)result )
return result;
if ( *((_BYTE *)v7 + 13276) )
return result;
if ( v7[3313] != -1
&& (char *)g_pEntityList + 16 * (v7[3313] & 0xFFF) != (void *)-4
&& *((_DWORD *)g_pEntityList + 4 * (v7[3313] & 0xFFF) + 2) == v7[3313] >> 12 )
{
if ( *((_DWORD *)g_pEntityList + 4 * (v7[3313] & 0xFFF) + 1) )
{
result = (_DWORD *)IntervalTimer::Now((IntervalTimer *)(v7 + 3314));
v33 = a1;
if ( (float)(v33 - *((float *)v7 + 3315)) > 1.0 )
return result;
}
}
result = (_DWORD *)CountdownTimer::Now((CountdownTimer *)(v7 + 3253));
v31 = a1;
if ( v31 < *((float *)v7 + 3255) )
return result;
if ( v7[3994] != -1 )
{
result = (char *)g_pEntityList + 16 * (v7[3994] & 0xFFF);
if ( result != (_DWORD *)-4
&& *((_DWORD *)g_pEntityList + 4 * (v7[3994] & 0xFFF) + 2) == v7[3994] >> 12
&& result[1] )
{
return result;
}
}
result = (_DWORD *)CTerrorPlayer::IsPummelVictim((CTerrorPlayer )v7);
if ( (_BYTE)result || !
((_BYTE *)this + 5424) )
return result;
CTerrorWeapon::SuppressHelpingHands(this, 0.0);
TeamNumber = CBaseEntity::GetTeamNumber((CBaseEntity )v7);
if ( (unsigned __int8)IsASurvivorTeam(TeamNumber) && !(
(unsigned __int8 (__cdecl **)(_DWORD *))(*v7 + 1912))(v7) )
{
ShovePenalty = CTerrorPlayer::GetShovePenalty((CTerrorPlayer *)v7);
if ( (unsigned __int8)CTerrorPlayer::IsAdrenalineActive((CTerrorPlayer *)v7) )
{
CTerrorPlayer::SetShovePenalty((CTerrorPlayer *)v7, 0);
v32 = 0.0;
goto LABEL_20;
}
v30 = *(float *)(gpGlobals + 12);
CTerrorPlayer::GetNextShoveTime((CTerrorPlayer *)v7);
v29 = a1;
v34 = *(float *)(dword_F9133C + 44);
if ( v34 != 0.0 )
{
if ( (unsigned __int8)CTerrorGameRules::IsCoopMode(v26) )
v16 = *(_DWORD *)(dword_F9115C + 48);
else
v16 = *(_DWORD *)(dword_F912DC + 48);
v28 = v16;
if ( (unsigned __int8)CTerrorGameRules::IsCoopMode(v27) )
v17 = *(_DWORD *)(dword_F910FC + 48);
else
v17 = *(_DWORD *)(dword_F9127C + 48);
if ( v34 >= (float)(v30 - v29) )
{
v22 = 1.0;
a2.m128_f32[0] = (float)v17;
}
else
{
a2.m128_f32[0] = (float)v17;
v18.m128_f32[0] = (float)(v30 - v29) - v34;
v19 = *(float *)(dword_F911BC + 44);
if ( v19 == 0.0 )
{
v20 = _mm_cmpgt_ss((__m128)0LL, v18);
LODWORD(v21) = _mm_andnot_ps(v20, a2).m128_u32[0] | LODWORD(v19) & v20.m128_i32[0];
}
else
{
v21 = fmaxf(fminf(1.0, v18.m128_f32[0] / v19), 0.0) * a2.m128_f32[0];
}
v22 = -v21;
}
v23 = (int)a2.m128_f32[0];
v24 = (float)ShovePenalty + v22;
if ( v24 <= a2.m128_f32[0] )
v23 = (int)fmaxf(v24, 0.0);
v32 = 0.0;
if ( v28 <= v23 )
{
v25.m128_f32[0] = (float)v23;
if ( a2.m128_f32[0] == (float)v28 )
LODWORD(v32) = *(_DWORD *)(dword_F9121C + 44) & _mm_cmple_ss(a2, v25).m128_u32[0];
else
v32 = fmaxf(fminf((float)(v25.m128_f32[0] - (float)v28) / (float)(a2.m128_f32[0] - (float)v28), 1.0), 0.0)
* *(float *)(dword_F9121C + 44);
}
CTerrorPlayer::SetShovePenalty((CTerrorPlayer *)v7, v23);
goto LABEL_20;
}
}
v32 = 0.0;
LABEL_20:
CountdownTimer::Start((CTerrorWeapon *)((char *)this + 5472), a5);
CountdownTimer::Start((CTerrorWeapon *)((char *)this + 5460), a4);
v9 = *(_DWORD *)this;
*((_BYTE *)this + 5496) = 1;
*((_DWORD *)this + 1506) = 0;
v10 = vec3_origin;
*((_DWORD *)this + 1507) = 0;
*((float *)this + 1375) = a6;
*((_DWORD *)this + 1371) = v10;
*((_DWORD *)this + 1372) = dword_103BCCC;
*((_DWORD )this + 1373) = dword_103BCD0;
(
(void (__cdecl **)(CTerrorWeapon *))(v9 + 1764))(this);
v35 = a4 + *(float *)(gpGlobals + 12);
if ( *((_BYTE *)this + 5209) )
{
v11 = *((float *)this + 1279);
v12 = fmaxf(a4 + *(float *)(gpGlobals + 12), v11);
if ( v11 != v12 )
{
CServerNetworkProperty::NetworkStateChanged();
*((float *)this + 1279) = v12;
}
v13 = *((float *)this + 1280);
v14 = fmaxf(v35, v13);
if ( v13 != v14 )
{
CServerNetworkProperty::NetworkStateChanged();
*((float *)this + 1280) = v14;
}
}
else
{
if ( v35 != *((float *)this + 1279) )
{
CServerNetworkProperty::NetworkStateChanged();
*((float *)this + 1279) = v35;
}
if ( v35 != *((float *)this + 1280) )
{
CServerNetworkProperty::NetworkStateChanged();
*((float )this + 1280) = v35;
}
}
(
(void (__cdecl **)(_DWORD *, _DWORD))(*v7 + 2268))(v7, v32 + v35);
return (_DWORD )((int (__cdecl **)(CTerrorWeapon ))((_DWORD *)this + 1756))(this);
}`

I believe by this pseudo code for "TrySwing" that if you hook "CountdownTimer::Start" you should have enough control by either changing the duration or L4D2Direct_SetNextShoveTime to control the shove speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant