diff --git a/L4D2VR/config.txt b/L4D2VR/config.txt index af4ffba..5bb8443 100644 --- a/L4D2VR/config.txt +++ b/L4D2VR/config.txt @@ -2,14 +2,11 @@ TurnSpeed=0.15 SnapTurning=false SnapTurnAngle=45.0 LeftHanded=false -VRScale=43.2 -IPDScale=1.0 -6DOF=false -HudDistance=1.3 -HudSize=4.0 -HudAlwaysVisible=false -AimMode=2 -AntiAliasing=0 +VRScale=43.2 # Real word units to source units scale +IPDScale=1.0 # Scale of interpupillary distance +6DOF=true +AimMode=2 # 0 = None, 1 = Crosshair (does not work properly), 2 = Laser sight/beam +AntiAliasing=0 # 0, 2, 4 8 ViewmodelPosCustomOffsetX=0.0 ViewmodelPosCustomOffsetY=0.0 ViewmodelPosCustomOffsetZ=0.0 diff --git a/L4D2VR/hooks.cpp b/L4D2VR/hooks.cpp index 9a75163..eb01d0a 100644 --- a/L4D2VR/hooks.cpp +++ b/L4D2VR/hooks.cpp @@ -31,43 +31,18 @@ Hooks::Hooks(Game *game) //hkWriteUsercmdDeltaToBuffer.enableHook(); hkWriteUsercmd.enableHook(); - //hkAdjustEngineViewport.enableHook(); - //hkViewport.enableHook(); - //hkGetViewport.enableHook(); - hkCreateMove.enableHook(); - hkEyePosition.enableHook(); - - //hkDrawModelExecute.enableHook(); hkRenderView.enableHook(); - /*hkPushRenderTargetAndViewport.enableHook(); - hkPopRenderTargetAndViewport.enableHook();*/ - //hkVgui_Paint.enableHook(); - /*hkIsSplitScreen.enableHook(); - hkPrePushRenderTarget.enableHook();*/ - //hkGetFullScreenTexture.enableHook(); hkWeapon_ShootPosition.enableHook(); hkTraceFirePortal.enableHook(); + hkCWeaponPortalgun_FirePortal.enableHook(); + hkDrawSelf.enableHook(); hkPlayerPortalled.enableHook(); - //hkGetModeHeight.enableHook(); - /*hkVGui_GetHudBounds.enableHook(); - hkVGui_GetPanelBounds.enableHook(); - hkVGUI_UpdateScreenSpaceBounds.enableHook(); - hkSetBounds.enableHook(); - hkSetSize.enableHook(); - hkGetScreenSize.enableHook(); - hkGetHudSize.enableHook();*/ - - //hkPush2DView.enableHook(); - //hkRender.enableHook(); - - //hkGetClipRect.enableHook(); - //hkComputeError.enableHook(); hkUpdateObject.enableHook(); hkUpdateObjectVM.enableHook(); @@ -79,7 +54,7 @@ Hooks::Hooks(Game *game) hkGetViewModelFOV.enableHook(); hkSetDrawOnlyForSplitScreenUser.enableHook(); - hkClientThink.enableHook(); + //kClientThink.enableHook(); hkPrecache.enableHook(); hkCHudCrosshair_ShouldDraw.enableHook(); } @@ -155,6 +130,8 @@ int Hooks::initSourceHooks() LPVOID TraceFirePortalAddr = (LPVOID)(m_Game->m_Offsets->TraceFirePortalServer.address); hkTraceFirePortal.createHook(TraceFirePortalAddr, &dTraceFirePortal); + hkCWeaponPortalgun_FirePortal.createHook((LPVOID)m_Game->m_Offsets->CWeaponPortalgun_FirePortal.address, &dCWeaponPortalgun_FirePortal); + LPVOID DrawSelfAddr = (LPVOID)(m_Game->m_Offsets->DrawSelf.address); hkDrawSelf.createHook(DrawSelfAddr, &dDrawSelf); @@ -169,45 +146,8 @@ int Hooks::initSourceHooks() UTIL_IntersectRayWithPortal = (tUTIL_IntersectRayWithPortal)m_Game->m_Offsets->UTIL_IntersectRayWithPortal.address; UTIL_Portal_AngleTransform = (tUTIL_Portal_AngleTransform)m_Game->m_Offsets->UTIL_Portal_AngleTransform.address; - /*void *clientMode = nullptr; - while (!clientMode) - { - Sleep(10); - clientMode = **(void ***)(m_Game->m_Offsets->g_pClientMode.address); - } - - hkCreateMove.createHook( (*(void ***)clientMode)[23], dCreateMove );*/ - LPVOID CreateMoveAddr = (LPVOID)(m_Game->m_Offsets->CreateMove.address); hkCreateMove.createHook(CreateMoveAddr, &dCreateMove); - - LPVOID VGui_GetHudBoundsAddr = (LPVOID)(m_Game->m_Offsets->VGui_GetHudBounds.address); - hkVGui_GetHudBounds.createHook(VGui_GetHudBoundsAddr, &dVGui_GetHudBounds); - - hkVGui_GetPanelBounds.createHook((LPVOID)(m_Game->m_Offsets->VGui_GetPanelBounds.address), &dVGui_GetPanelBounds); - - hkVGUI_UpdateScreenSpaceBounds.createHook((LPVOID)(m_Game->m_Offsets->VGUI_UpdateScreenSpaceBounds.address), &dVGUI_UpdateScreenSpaceBounds); - hkVGui_GetTrueScreenSize.createHook((LPVOID)(m_Game->m_Offsets->VGui_GetTrueScreenSize.address), &dVGui_GetTrueScreenSize); - - //hkSetBounds.createHook((LPVOID)m_Game->m_Offsets->SetBoundsC.address, &dSetBounds); - hkSetBounds.createHook((LPVOID)m_Game->m_Offsets->SetBoundsE.address, &dSetBounds); - - //hkSetSize.createHook((LPVOID)(m_Game->m_Offsets->SetSizeC.address), &dSetSize); - //hkSetSize.createHook((LPVOID)(m_Game->m_Offsets->SetSizeE.address), &dSetSize); - hkSetSize.createHook((LPVOID)(m_Game->m_Offsets->SetSizeV.address), &dSetSize); - - hkGetScreenSize.createHook((LPVOID)(m_Game->m_Offsets->GetScreenSize.address), &dGetScreenSize); - hkGetHudSize.createHook((LPVOID)(m_Game->m_Offsets->GetHudSize.address), &dGetHudSize); - - LPVOID Push2DViewAddr = (LPVOID)(m_Game->m_Offsets->Push2DView.address); - hkPush2DView.createHook(Push2DViewAddr, &dPush2DView); - - LPVOID RenderAddr = (LPVOID)(m_Game->m_Offsets->Render.address); - hkRender.createHook(RenderAddr, &dRender); - - hkGetClipRect.createHook((LPVOID)(m_Game->m_Offsets->GetClipRect.address), &dGetClipRect); - - hkGetModeHeight.createHook((LPVOID)(m_Game->m_Offsets->GetModeHeight.address), &dGetModeHeight); // Grababbles hkComputeError.createHook((LPVOID)(m_Game->m_Offsets->ComputeError.address), &dComputeError); @@ -232,12 +172,9 @@ int Hooks::initSourceHooks() hkCHudCrosshair_ShouldDraw.createHook((LPVOID)m_Game->m_Offsets->CHudCrosshair_ShouldDraw.address, &dCHudCrosshair_ShouldDraw); // - hkClientThink.createHook((LPVOID)(m_Game->m_Offsets->ClientThink.address), &dClientThink); EntityIndex = (tEntindex)m_Game->m_Offsets->CBaseEntity_entindex.address; GetOwner = (tGetOwner)m_Game->m_Offsets->GetOwner.address; - hkCWeaponPortalgun_FirePortal.createHook((LPVOID)m_Game->m_Offsets->CWeaponPortalgun_FirePortal.address, &dCWeaponPortalgun_FirePortal); - return 1; } @@ -298,22 +235,10 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie if (m_Game->m_VguiSurface->IsCursorVisible()) return hkRenderView.fOriginal(ecx, setup, hudViewSetup, nClearFlags, whatToDraw); - VPanel* g_pFullscreenRootPanel = *(VPanel**)(m_Game->m_Offsets->g_pFullscreenRootPanel.address); - - /*int w, h; - g_pFullscreenRootPanel->GetSize(w, h);*/ + //VPanel* g_pFullscreenRootPanel = *(VPanel**)(m_Game->m_Offsets->g_pFullscreenRootPanel.address); IMaterialSystem* matSystem = m_Game->m_MaterialSystem; - /*int windowWidth, windowHeight; - m_Game->m_MaterialSystem->GetRenderContext()->GetWindowSize(windowWidth, windowHeight);*/ - - /*hudViewSetup.x = m_VR->m_RenderWidth - windowWidth; - hudViewSetup.y = m_VR->m_RenderHeight - windowHeight;*/ - - /*hudViewSetup.x = 500; - hudViewSetup.y = 250;*/ - hudViewSetup.width = m_VR->m_RenderWidth; hudViewSetup.height = m_VR->m_RenderHeight; hudViewSetup.fov = m_VR->m_Fov; @@ -329,8 +254,6 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie Vector vec = position - m_VR->m_SetupOrigin; float distance = sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z); - //std::cout << "dRenderView: " << distance << "\n"; - // Rudimentary portalling detection if (distance > 35) { //m_VR->m_RotationOffset.x += m_VR->m_PortalRotationOffset.x; @@ -379,10 +302,6 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie rndrContext->Release(); hkRenderView.fOriginal(ecx, leftEyeView, hudViewSetup, nClearFlags, whatToDraw); - //m_VR->m_HUDTexture - - //std::cout << "dRenderView - Left End\n"; - // Right eye CViewSetup tempAngle = QAngle(setup.angles.x, setup.angles.y, setup.angles.z); rightEyeView.origin = m_VR->TraceEye((uint32_t*)localPlayer, position, m_VR->GetViewOriginRight(position), tempAngle); @@ -393,7 +312,6 @@ void __fastcall Hooks::dRenderView(void *ecx, void *edx, CViewSetup &setup, CVie rndrContext->SetRenderTarget(m_VR->m_RightEyeTexture); rndrContext->Release(); hkRenderView.fOriginal(ecx, rightEyeView, hudViewSetup, nClearFlags, whatToDraw); - //std::cout << "dRenderView - Right End\n"; m_PushedHud = false; @@ -855,7 +773,7 @@ Vector* Hooks::dWeapon_ShootPosition(void* ecx, void* edx, Vector* eyePos) return result; } -void* Hooks::dCWeaponPortalgun_FirePortal(void* ecx, void* edx, bool bPortal2, Vector* pVector = 0) { +void* Hooks::dCWeaponPortalgun_FirePortal(void* ecx, void* edx, bool bPortal2, Vector* pVector) { bool wasTrue = m_VR->m_OverrideEyeAngles; m_VR->m_OverrideEyeAngles = true; @@ -876,8 +794,6 @@ bool __fastcall Hooks::dTraceFirePortal(void* ecx, void* edx, const Vector& vTra if (iPlacedBy == 2) { int localIndex = m_Game->m_EngineClient->GetLocalPlayer(); - std::cout << "dTraceFirePortal: " << ecx << "\n"; - auto owner = GetOwner(ecx); if (owner) { diff --git a/L4D2VR/hooks.h b/L4D2VR/hooks.h index 3bce258..de79560 100644 --- a/L4D2VR/hooks.h +++ b/L4D2VR/hooks.h @@ -37,6 +37,9 @@ struct Hook { int enableHook() { + if (!pTarget) + throw std::invalid_argument("pTarget is empty, did you miss a call to createHook?"); + MH_STATUS status = MH_EnableHook(pTarget); if (status != MH_OK) { diff --git a/L4D2VR/offsets.h b/L4D2VR/offsets.h index ea0f6e4..1ece3a6 100644 --- a/L4D2VR/offsets.h +++ b/L4D2VR/offsets.h @@ -79,10 +79,10 @@ class Offsets Offset VGui_GetPanelBounds = { "client.dll", 0x1CC350, "55 8B EC 8B 45 08 8B C8 83 E1 1F BA ? ? ? ?" }; Offset VGUI_UpdateScreenSpaceBounds = { "client.dll", 0x1CC8C0, "55 8B EC 83 EC 14 8B 45 0C 8B 4D 10 53 8B 5D 18 56 A3 ? ? ? ? 33 C0" }; - Offset VGui_GetTrueScreenSize = { "client.dll", 0x1CBCF0, "55 8B EC 8B 45 08 8B 0D ? ? ? ? 8B 55 0C 89 08 A1 ? ? ? ? 89 02 5D C3" }; + Offset VGui_GetTrueScreenSize = { "client.dll", 0x1CBCF0, "55 8B EC 8B 45 08 8B 0D ? ? ? ? 8B 55 0C 89 08 A1 ? ? ? ? 89 02 5D C3" };*/ Offset VGui_GetClientDLLRootPanel = { "client.dll", 0x26EDF0, "8B 0D ? ? ? ? 8B 01 8B 90 ? ? ? ? FF D2 8B 04 85 ? ? ? ? 8B 48 04" }; - Offset g_pFullscreenRootPanel = { "client.dll", 0x26EE20, "A1 ? ? ? ? C3", 2 };*/ + Offset g_pFullscreenRootPanel = { "client.dll", 0x26EE20, "A1 ? ? ? ? C3", 2 }; // Pointer laser Offset CreatePingPointer = { "client.dll", 0x280660, "55 8B EC 83 EC 14 53 56 8B F1 8B 8E ? ? ? ? 57 85 C9 74 30" }; diff --git a/L4D2VR/sdk/sdk.h b/L4D2VR/sdk/sdk.h index 437708e..45af9e7 100644 --- a/L4D2VR/sdk/sdk.h +++ b/L4D2VR/sdk/sdk.h @@ -2137,8 +2137,8 @@ class C_Portal_Player public: inline CWeaponPortalBase* GetActivePortalWeapon() { typedef CWeaponPortalBase* (__thiscall* tGetActivePortalWeapon)(void* thisptr); - static tGetActivePortalWeapon oGetActivePortalWeapon = (tGetActivePortalWeapon)(g_Game->m_Offsets->GetActivePortalWeapon.address); - + //static tGetActivePortalWeapon oGetActivePortalWeapon = (tGetActivePortalWeapon)(g_Game->m_Offsets->GetActivePortalWeapon.address); + static tGetActivePortalWeapon oGetActivePortalWeapon = (tGetActivePortalWeapon)(*(uintptr_t*)this + 968); return oGetActivePortalWeapon(this); }; diff --git a/L4D2VR/vr.cpp b/L4D2VR/vr.cpp index 1759d74..e970ce2 100644 --- a/L4D2VR/vr.cpp +++ b/L4D2VR/vr.cpp @@ -1429,10 +1429,10 @@ void VR::ParseConfigFile() parseOrDefault("LeftHanded", m_LeftHanded, false); parseOrDefault("VRScale", m_VRScale, 43.2f); parseOrDefault("IPDScale", m_IpdScale, 1.0f); - parseOrDefault("6DOF", m_6DOF, false); - parseOrDefault("HudDistance", m_HudDistance, 1.3f); + parseOrDefault("6DOF", m_6DOF, true); + /*parseOrDefault("HudDistance", m_HudDistance, 1.3f); parseOrDefault("HudSize", m_HudSize, 4.0f); - parseOrDefault("HudAlwaysVisible", m_HudAlwaysVisible, false); + parseOrDefault("HudAlwaysVisible", m_HudAlwaysVisible, false);*/ parseOrDefault("AimMode", m_AimMode, 2); parseOrDefault("AntiAliasing", m_AntiAliasing, 0); parseXYZOrDefaultZero("ViewmodelPosCustomOffset", m_ViewmodelPosCustomOffset);