diff --git a/L4D2VR/game.h b/L4D2VR/game.h index ce92fe3..9678f69 100644 --- a/L4D2VR/game.h +++ b/L4D2VR/game.h @@ -31,6 +31,7 @@ struct Player QAngle controllerAngle; Vector controllerPos; bool isMeleeing; + bool isNewSwing; QAngle prevControllerAngle; Player() @@ -38,6 +39,7 @@ struct Player controllerAngle({ 0,0,0 }), controllerPos({ 0,0,0 }), isMeleeing(false), + isNewSwing(false), prevControllerAngle({ 0,0,0 }) {} }; diff --git a/L4D2VR/hooks.cpp b/L4D2VR/hooks.cpp index 74f7c56..6f31cc3 100644 --- a/L4D2VR/hooks.cpp +++ b/L4D2VR/hooks.cpp @@ -281,20 +281,26 @@ float __fastcall Hooks::dProcessUsercmds(void *ecx, void *edx, edict_t *player, if (curWep) { int wepID = curWep->GetWeaponID(); - if (wepID == 19) + if (wepID == 19) // melee weapon { + if (m_Game->m_PlayersVRInfo[index].isNewSwing) + { + m_Game->m_PlayersVRInfo[index].isNewSwing = false; + curWep->entitiesHitThisSwing = 0; + } + typedef void *(__thiscall *tGetMeleeWepInfo)(void *thisptr); static tGetMeleeWepInfo oGetMeleeWepInfo = (tGetMeleeWepInfo)(m_Game->m_Offsets->GetMeleeWeaponInfo.address); void *meleeWepInfo = oGetMeleeWepInfo(curWep); Vector initialForward, initialRight, initialUp; QAngle::AngleVectors(m_Game->m_PlayersVRInfo[index].prevControllerAngle, &initialForward, &initialRight, &initialUp); - Vector initialMeleeDirection = VectorRotate(initialForward, initialRight, 75.0); + Vector initialMeleeDirection = VectorRotate(initialForward, initialRight, 50.0); VectorNormalize(initialMeleeDirection); Vector finalForward, finalRight, finalUp; QAngle::AngleVectors(m_Game->m_PlayersVRInfo[index].controllerAngle, &finalForward, &finalRight, &finalUp); - Vector finalMeleeDirection = VectorRotate(finalForward, finalRight, 75.0); + Vector finalMeleeDirection = VectorRotate(finalForward, finalRight, 50.0); VectorNormalize(finalMeleeDirection); Vector pivot; @@ -320,6 +326,10 @@ float __fastcall Hooks::dProcessUsercmds(void *ecx, void *edx, edict_t *player, } } } + else + { + m_Game->m_PlayersVRInfo[index].isNewSwing = true; + } m_Game->m_PlayersVRInfo[index].prevControllerAngle = m_Game->m_PlayersVRInfo[index].controllerAngle; @@ -399,7 +409,7 @@ int Hooks::dWriteUsercmd(void *buf, CUserCmd *to, CUserCmd *from) int rollEncoding = (((int)controllerAngles.z + 180) / 2 * 10000000); to->command_number += rollEncoding; - if (VectorLength(m_VR->m_RightControllerPose.TrackedDeviceVel) > .9) + if (VectorLength(m_VR->m_RightControllerPose.TrackedDeviceVel) > 1.1) { to->command_number *= -1; // Signal to server that melee swing in motion } diff --git a/L4D2VR/sdk/sdk_server.h b/L4D2VR/sdk/sdk_server.h index af14598..42ac287 100644 --- a/L4D2VR/sdk/sdk_server.h +++ b/L4D2VR/sdk/sdk_server.h @@ -415,7 +415,11 @@ class Server_WeaponCSBase virtual void sub_1024C590() = 0; virtual void sub_1024C5A0() = 0; virtual void sub_1024C5B0() = 0; -}; + + char pad_0000[6124]; //0x0000 + int entitiesHitThisSwing; //0x17F0 +}; //Size: 0x17F4 +static_assert(sizeof(Server_WeaponCSBase) == 0x17F4); class Server_BaseEntity {