Advertisement
HolywoodJack

TheNewFunction

Aug 29th, 2019
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. #include "plugin.h"
  2. #include "../injector/injector.hpp"
  3.  
  4.  
  5. static int _Z16FindPlayetWantedj = 0x56E230;
  6. static int _Z13FindPlayerPedj = 0x56E210;
  7. static int _ZN4CPed23DoWeHaveWeaponAvailableE11eWeaponType = 0x5DF300;
  8. static int _ZN11CWeaponInfo13GetWeaponInfoE11eWeaponTypea = 0x743C60;
  9. static int _ZN4CPed16SetCurrentWeaponE11eWeaponType = 0x5E6280;
  10.  
  11. __declspec(naked) void NewFunction() {
  12. _asm {
  13. push esi
  14. push -1
  15. call _Z16FindPlayetWantedj
  16. mov eax,[eax+0x2C]
  17. mov esi,[esp+0x0C]
  18. add esp,4
  19. cmp eax,1
  20. jle loc_68BB03
  21. movsx ecx,byte ptr [esi+0x718]
  22. imul ecx,ecx,0x1C
  23. mov edx,[ecx+esi+0x5A0]
  24. test edx,edx
  25. je loc_68BB9C
  26. cmp eax,1
  27.  
  28. loc_68BB03:
  29. jne loc_68BBBD
  30. push -1
  31. call _Z13FindPlayerPedj
  32. mov ecx,[eax+0x568]
  33. add esp,4
  34. test ecx,ecx
  35. jne loc_68BBBD
  36. cmp dword ptr [esi+0x530],31
  37. je loc_68BBBD
  38. push 3
  39. mov ecx,esi
  40. call _ZN4CPed23DoWeHaveWeaponAvailableE11eWeaponType
  41. test al,al
  42. je loc_68BB9C
  43. push -1
  44. call _Z13FindPlayerPedj
  45. movsx edx,byte ptr [eax+0x718]
  46. imul edx,edx,0x1C
  47. mov eax,[edx+eax+0x5A0]
  48. push 1
  49. push eax
  50. call _ZN11CWeaponInfo13GetWeaponInfoE11eWeaponTypea
  51. mov ecx,[eax]
  52. add esp,0x0C
  53. cmp ecx,1
  54. je loc_68BB9C
  55. push -1
  56. call _Z13FindPlayerPedj
  57. movsx ecx,byte ptr [eax+0x718]
  58. imul ecx,ecx,0x1C
  59. mov eax,[ecx+eax+0x5A0]
  60. push 1
  61. push eax
  62. call _ZN11CWeaponInfo13GetWeaponInfoE11eWeaponTypea
  63. mov ecx,[eax]
  64. add esp,0x0C
  65. cmp ecx,2
  66. je loc_68BB9C
  67. push 3
  68. mov ecx,esi
  69. call _ZN4CPed16SetCurrentWeaponE11eWeaponType
  70. pop esi
  71. ret 4
  72.  
  73. loc_68BB9C:
  74. push 19
  75. mov ecx,esi
  76. call _ZN4CPed23DoWeHaveWeaponAvailableE11eWeaponType
  77. test al,al
  78. mov ecx,esi
  79. je loc_68BBB6
  80. push 19
  81. call _ZN4CPed16SetCurrentWeaponE11eWeaponType
  82. pop esi
  83. ret 4
  84.  
  85. loc_68BBB6:
  86. push 16
  87. call _ZN4CPed16SetCurrentWeaponE11eWeaponType
  88.  
  89. loc_68BBBD:
  90. pop esi
  91. ret 4
  92. }
  93. }
  94.  
  95. using namespace plugin;
  96.  
  97. class TheNewProject {
  98. public:
  99. TheNewProject() {
  100. Events::gameProcessEvent += [] {
  101. plugin::patch::Nop(0x68BAD0, 8);
  102. injector::MakeJMP(0x68BAD0, NewFunction);
  103. };
  104. }
  105. } theNewProject;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement