My favorites | Sign in
Project Home Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 3 attachment: AimSync.cpp.patch (5.3 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
--- trunk/Client/Core/AimSync.cpp
+++ trunk/Client/Core/AimSync.cpp
@@ -1,170 +0,0 @@
-//============== IV: Multiplayer - http://code.iv-multiplayer.com ==============
-//
-// File: AimSync.cpp
-// Project: Client.Core
-// Author(s): jenksta
-// License: See LICENSE in root directory
-//
-//==============================================================================
-
-#include "AimSync.h"
-#include "COffsets.h"
-#include <Patcher/CPatcher.h>
-#include "CIVPed.h"
-#include "CIVPlayerPed.h"
-#include "CContextDataManager.h"
-#include <CLogFile.h>
-
-DWORD dwFunc = NULL;
-IVPed * g_pIKPed = NULL;
-CVector3 * g_vecWeaponAimTarget = NULL;
-IVPed * g_pWeaponPed = NULL;
-CVector3 * g_vecWeaponShotSource = NULL;
-CVector3 * g_vecWeaponShotTarget = NULL;
-
-#include "CChatWindow.h"
-extern CChatWindow * g_pChatWindow;
-
-void StoreAimTarget(IVPed * pPed, CVector3 * vecWeaponTarget)
-{
- // Do we have a valid ped pointer and target pointer?
- if(pPed && vecWeaponTarget)
- {
- // Get the remote players context data
- CContextData * pContextData = CContextDataManager::GetContextData((IVPlayerPed *)pPed);
-
- // Do we have a valid context data?
- if(pContextData)
- {
- // Is this the local player?
- if(pContextData->GetPlayerInfo()->GetPlayerNumber() == 0)
- {
- pContextData->SetWeaponAimTarget(*vecWeaponTarget);
- g_pChatWindow->AddInfoMessage("StoreAimTargetLocal(0x%x, (%f, %f, %f))", pPed, vecWeaponTarget->fX, vecWeaponTarget->fY, vecWeaponTarget->fZ);
- }
- else
- {
- pContextData->GetWeaponAimTarget(*vecWeaponTarget);
- g_pChatWindow->AddInfoMessage("StoreAimTarget(0x%x, (%f, %f, %f))", pPed, vecWeaponTarget->fX, vecWeaponTarget->fY, vecWeaponTarget->fZ);
- }
- }
- else
- CLogFile::Printf("StoreAimTarget Warning: Invalid Player Ped");
- }
-}
-
-void StoreShotSourceTarget(IVPed * pPed, CVector3 * pWeaponSource, CVector3 * pWeaponTarget)
-{
- // Do we have a valid ped pointer, source pointer and target pointer?
- if(pPed && pWeaponSource && pWeaponTarget)
- {
- // Get the remote players context data
- CContextData * pContextData = CContextDataManager::GetContextData((IVPlayerPed *)pPed);
-
- // Do we have a valid context data?
- if(pContextData)
- {
- // Is this the local player?
- if(pContextData->GetPlayerInfo()->GetPlayerNumber() == 0)
- {
- pContextData->SetWeaponShotSource(*pWeaponSource);
- pContextData->SetWeaponShotTarget(*pWeaponTarget);
- }
- else
- {
- pContextData->GetWeaponShotSource(*pWeaponSource);
- pContextData->GetWeaponShotTarget(*pWeaponTarget);
- }
- }
- else
- CLogFile::Printf("StoreShotSourceTarget Warning: Invalid Player Ped");
- }
-}
-
-void _declspec(naked) CIKManager__AimWeapon()
-{
- _asm
- {
- push ebp
- mov ebp, esp
- mov eax, [ecx+40h] // CIKManager + 0x40 = CPed * pPed
- mov g_pIKPed, eax
- mov eax, [ebp+8]
- mov g_vecWeaponAimTarget, eax
- pop ebp
- pushad
- }
-
- StoreAimTarget(g_pIKPed, g_vecWeaponAimTarget);
- dwFunc = (CGame::GetBase() + 0x950D66);
-
- _asm
- {
- popad
- push ebp
- mov ebp, esp
- and esp, 0FFFFFFF0h
- jmp dwFunc
- }
-}
-
-void _declspec(naked) CWeapon__Fire_Hook()
-{
- _asm
- {
- push ebp
- mov ebp, esp
- mov eax, [ebp+8h]
- mov g_pWeaponPed, eax
- // [ebp+0Ch] = pSourceMatrix (Matrix34 *)
- mov eax, [ebp+10h]
- mov g_vecWeaponShotSource, eax
- mov eax, [ebp+14h]
- mov g_vecWeaponShotTarget, eax
- pop ebp
- pushad
- }
-
- StoreShotSourceTarget(g_pWeaponPed, g_vecWeaponShotSource, g_vecWeaponShotTarget);
- dwFunc = (CGame::GetBase() + 0x97D7C6);
-
- _asm
- {
- popad
- push ebp
- mov ebp, esp
- and esp, 0FFFFFFF0h
- jmp dwFunc
- }
-}
-
-void InstallAimSyncHooks()
-{
- // For some reason when the aim/fire tasks are triggered
- // for remote players instead of the local player the
- // CIKManager::AimWeapon function isn't called, tried
- // disabling player ped checks below but still doesn't call
- // Disable local player checks for weapon aiming
- //*(BYTE *)(CGame::GetBase() + 0xCC797F) = 0x90;//
- //*(BYTE *)(CGame::GetBase() + 0xCC7980) = 0xE9;//
- /*CPatcher::InstallNopPatch((CGame::GetBase() + 0x89C7A0), 21);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xA61763), 13);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xA60F7A), 13);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xA60BF9), 13);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xCC7978), 26);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xCC9D94), 26);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0x8969E9), 9);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xA94E39), 7);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xA94E67), 13);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xBD71B0), 7);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xBD71BB), 11);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xCC8191), 18);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xCC7978), 26);
- CPatcher::InstallNopPatch((CGame::GetBase() + 0xCCAA84), 16);*/
-
- // Hook for the CIKManager::AimWeapon function
- CPatcher::InstallJmpPatch((CGame::GetBase() + 0x950D60), (DWORD)CIKManager__AimWeapon);
-
- // Hook for the CWeapon::Fire function
- CPatcher::InstallJmpPatch((CGame::GetBase() + 0x97D7C0), (DWORD)CWeapon__Fire_Hook);
-}
Powered by Google Project Hosting