Advertisement
HolywoodJack

Wanted Level Editor in c++

May 22nd, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.05 KB | None | 0 0
  1. #include "plugin.h"
  2. #include "common.h"
  3. #include "CBaseModelInfo.h"
  4. #include "CCarAI.h"
  5. #include "CCarCtrl.h"
  6. #include "CDarkel.h"
  7. #include "CHud.h"
  8. #include "CCheat.h"
  9. #include "CPed.h"
  10. #include "CPlayerPed.h"
  11. #include "CPedModelInfo.h"
  12. #include "CModelInfo.h"
  13. #include "CObject.h"
  14. #include "CPickup.h"
  15. #include "CPickups.h"
  16. #include "CTheZones.h"
  17. #include "CVector.h"
  18. #include "CVehicle.h"
  19. #include "CVehicleModelInfo.h"
  20. #include "CPool.h"
  21. #include "CPools.h"
  22. #include "CStats.h"
  23. #include "CStreaming.h"
  24. #include "CWeaponModelInfo.h"
  25. #include <string>
  26. #include <algorithm>
  27. #include <array>
  28. #include <functional>
  29. #include <iostream>
  30. #include <sstream>
  31. #include <string>
  32. #include <vector>
  33.  
  34. #import <msxml6.dll> raw_interfaces_only
  35.  
  36. // using namespace MSXML2;
  37.  
  38. using namespace plugin;
  39.  
  40.  
  41. enum ePoliceCarOccupants : unsigned int {
  42. FOUR_OCCUPANTS,
  43. DRIVER_AND_GUNMAN,
  44. ONE_OCCUPANT,
  45. TWO_OCCUPANTS,
  46. EMPTY_VEHICLE
  47. };
  48.  
  49. enum ePedInCar : unsigned int {
  50. FIREMEN_IN_CAR,
  51. MEDICS_IN_CAR,
  52. SWAT_IN_CAR,
  53. COPS_IN_CAR,
  54. ARMY_IN_CAR,
  55. FBI_IN_CAR,
  56. COP_BIKER,
  57. TRAIN_DRIVER,
  58. RANDOM_PED_MODEL
  59. };
  60.  
  61. enum eRoadblockCops : unsigned int {
  62. ROADBLOCK_SWAT,
  63. ROADBLOCK_ARMY,
  64. ROADBLOCK_FBI,
  65. ROADBLOCK_COP,
  66. ROADBLOCK_DEF
  67. };
  68.  
  69. enum eLawEnforcementVehicle : unsigned int {
  70. LAW_VEHICLE,
  71. CIV_VEHICLE
  72. };
  73.  
  74. enum eUGLevelName : unsigned int {
  75. UG_COUNTRY_SIDE,
  76. UG_LOS_SANTOS,
  77. UG_SAN_FIERRO,
  78. UG_LAS_VENTURAS,
  79. UG_LIBERTY_CITY,
  80. UG_VICE_CITY,
  81. UG_ATLANTIS,
  82. UG_BULLWORTH,
  83. UG_MAIN_LAND_LIBERTY,
  84. UG_THE_DESERT
  85. };
  86.  
  87. enum eDriverModelForCar : unsigned int {
  88. LIMO_DRIVER,
  89. TAXI_DRIVER,
  90. HOTDOG_DELIVERY,
  91. SECURITY_GUARD,
  92. PIZZA_DELIVERY,
  93. FREEWAY_BIKE_DRIVER,
  94. BICYCLE_DRIVER,
  95. DRIVER_DEFAULT
  96. };
  97.  
  98. enum ePlaneMission : unsigned int {
  99. PLANE_ATTACK_PLAYER = 0x23,
  100. PLANE_FLY_IN_DIRECTION = 0x24,
  101. PLANE_FOLLOW_ENTITY = 0x25,
  102. PLANE_ATTACK_PLAYER_USING_DOG_FIGHT = 0x3F
  103. };
  104.  
  105. enum eHeliMission : unsigned int {
  106. HELI_ATTACK_PLAYER = 0x17,
  107. HELI_FOLLOW_ENTITY = 0x27,
  108. POLICE_HELI_CHASE_ENTITY = 0x28,
  109. HELI_LAND_AT_COORDS = 0x2F,
  110. HELI_KEEP_ENTITY_IN_VIEW = 0x33,
  111. MAKE_HELI_COME_CRASHING_DOWN = 0x3A
  112. };
  113.  
  114. char MaxStars;
  115. ushort MaxChaos = -1;
  116. int _cheatStringHashes;
  117. int maxChaosPntr;
  118. int maxWantedStarsPntr;
  119. int _playerStatsInteger;
  120. int bribesCollected;
  121. int StarLimit = 0x0C; int BribesCollected; byte heliSpeed = 0; bool addNewsHeli = false; bool enableJurisdiction = 1;
  122. int pedModel; int pedModelCase; int roadblockPed; int roadblockPedCase; int jurisdiction; int voice1; int voice2;
  123. int copCarByTown; int copPedByTown;
  124. uint lowestCase; uint highestCase; char maxSwitchTableValues; int SwitchTableStart;
  125. int vehType; int city;
  126. int table1; int table2; int table3; int table4; int table9;
  127. int table1Pos; int table2Pos; int table3Pos; int table4Pos; int table9Pos; int vehTypeBike;
  128.  
  129. DWORD copBikeByTown = plugin::patch::GetUInt(0x407C7C + 1);
  130. DWORD copBikePed = plugin::patch::GetUInt(0x407C6B + 1);
  131. int LoadedObjectInfo = plugin::patch::GetUInt(0x4044C7 + 3);
  132.  
  133. class WantedLevelEditor {
  134.  
  135. public:
  136. WantedLevelEditor() {
  137. // plugin::patch::Nop(0x41C140, 2); plugin::patch::Nop(0x41C142, 2); // NOP shotgunChance
  138. std::array<byte, 65536> TABLE_1; std::array<byte, 65536> TABLE_2;
  139. std::array<byte, 65536> TABLE_3; std::array<byte, 65536> TABLE_4; std::array<byte, 65536> TABLE_9;
  140. TABLE_1.fill(3); TABLE_2.fill(8); TABLE_3.fill(4); TABLE_4.fill(1);
  141.  
  142. TABLE_9.fill(6);
  143.  
  144. plugin::patch::SetUInt(0x41C0A6, 0x2246BF0F); plugin::patch::SetUInt(0x613A68, 0x2247BF0F);
  145. plugin::patch::SetUInt(0x46130F, 0x2247BF0F); plugin::patch::SetUInt(0x6D2370, 0x2241BF0F);
  146. plugin::patch::SetUChar(0x41C0A6 + 4, 5); plugin::patch::SetUChar(0x613A68 + 4, 5);
  147. plugin::patch::SetUChar(0x46130F + 4, 5); plugin::patch::SetUChar(0x6D2370 + 4, 5);
  148. plugin::patch::SetUInt(0x41C0A6 + 5, -400); plugin::patch::SetUInt(0x613A68 + 5, -400);
  149. plugin::patch::SetUInt(0x46130F + 5, -400); plugin::patch::SetUInt(0x6D2370 + 5, -400);
  150. plugin::patch::SetUInt(0x41C0B0, 65535); plugin::patch::SetUInt(0x613A72, 65535);
  151. plugin::patch::SetUInt(0x461319, 65535); plugin::patch::SetUInt(0x6D237A, 65535);
  152.  
  153. plugin::patch::SetUInt(0x6D16EE, 0x2246BF0F);
  154. plugin::patch::SetUChar(0x6D16EE + 0x0D, 5);
  155. plugin::patch::SetUInt(0x6D16EE + 0x0E, -400);
  156. plugin::patch::SetUInt(0x6D1700 + 1, 65535);
  157.  
  158. // ; CCarCtrl::ChoosePoliceCarModel();
  159. plugin::patch::SetUInt(0x421980, 0xE8FF6A53); plugin::patch::SetUInt(0x421984, 0x0014C8A8);
  160. // ; CCopPed::CCopPed(CPed *ped, int copType);
  161. plugin::patch::SetUInt(0x5DDC86, 0x2024448B); plugin::patch::SetUInt(0x5DDC8A, 0xF883DB33);
  162.  
  163. TABLE_2[7] = 0; TABLE_2[16] = 1; // MODEL_FIRETRUCK ; MODEL_AMBULAN
  164. TABLE_1[27] = 0; TABLE_2[27] = 2; TABLE_3[27] = 0; TABLE_4[27] = 0; // MODEL_ENFORCER
  165. TABLE_1[30] = 1; TABLE_2[30] = 3; // MODEL_PREDATOR
  166. TABLE_1[32] = 2; TABLE_2[32] = 4; TABLE_4[32] = 0; // MODEL_RHINO
  167. TABLE_1[33] = 3; TABLE_2[33] = 4; TABLE_3[33] = 1; TABLE_4[33] = 0; // MODEL_BARRACKS
  168. TABLE_1[90] = 0; TABLE_2[90] = 5; TABLE_3[90] = 2; TABLE_4[90] = 0; // MODEL_FBIRANCH
  169. TABLE_1[97] = 3; TABLE_2[97] = 3; TABLE_4[97] = 0; // MODEL_POLMAV
  170. TABLE_1[123] = 2; TABLE_2[123] = 6; TABLE_4[123] = 0; // MODEL_COPBIKE
  171. TABLE_1[196] = 3; TABLE_2[196] = 3; TABLE_3[196] = 3; TABLE_4[196] = 0; // MODEL_COPCARLA
  172. TABLE_1[197] = 3; TABLE_2[197] = 3; TABLE_3[197] = 3; TABLE_4[197] = 0; // MODEL_COPCARSF
  173. TABLE_1[198] = 3; TABLE_2[198] = 3; TABLE_3[198] = 3; TABLE_4[198] = 0; // MODEL_COPCARLV
  174. TABLE_1[199] = 3; TABLE_2[199] = 3; TABLE_3[199] = 3; TABLE_4[199] = 0; // MODEL_COPCARRU
  175. TABLE_4[128] = 0; TABLE_4[201] = 0;
  176.  
  177. TABLE_9[16] = 0; // MODEL_AMBULAN
  178. TABLE_9[20] = 1; TABLE_9[38] = 1; // MODEL_TAXI ; MODEL_CABBIE
  179. TABLE_9[27] = 2; // MODEL_ENFORCER
  180. TABLE_9[57] = 3; // MODEL_CADDY
  181. TABLE_9[188] = 4; // MODEL_HOTDOG
  182. TABLE_9[196] = 5; TABLE_9[197] = 5; TABLE_9[198] = 5; TABLE_9[199] = 5; // copCars
  183.  
  184. plugin::patch::SetPointer(0x41C0BD, &TABLE_1); plugin::patch::SetPointer(0x613A7F, &TABLE_2);
  185. plugin::patch::SetPointer(0x461322, &TABLE_3); plugin::patch::SetPointer(0x6D2383, &TABLE_4);
  186.  
  187. plugin::patch::SetPointer(0x6D1711 + 3, &TABLE_9);
  188.  
  189. // star7
  190. _cheatStringHashes = plugin::patch::GetUInt(0x438510 + 3);
  191. maxChaosPntr = plugin::patch::GetUInt(0x561C7A + 2);
  192. maxWantedStarsPntr = plugin::patch::GetUInt(0x48CB51 + 2);
  193. MaxStars = 11; // privateData
  194. plugin::patch::SetUInt(_cheatStringHashes + 0x014, 0); plugin::patch::SetUInt(_cheatStringHashes + 0x108, 0);
  195. plugin::patch::SetUShort(maxChaosPntr, MaxChaos);
  196. plugin::patch::SetUInt(0x561EF7 + 6, MaxChaos); plugin::patch::SetUInt(maxWantedStarsPntr, MaxStars);
  197. plugin::patch::SetUInt(0x561C70 + 6, MaxStars); plugin::patch::SetUInt(0x561EED + 6, MaxStars);
  198. plugin::patch::SetUChar(0x58DFE2 + 2, MaxStars); plugin::patch::SetUChar(0x72DF29 + 1, MaxStars);
  199. // jumpChange:
  200. plugin::patch::SetUInt(0x41CAB0, 0x7B870F); plugin::patch::SetUInt(0x561E77, 0x70870F);
  201. plugin::patch::SetUShort(0x5624A4, 0x5277); plugin::patch::SetUShort(0x6C74E3, 0x2377);
  202. plugin::patch::SetUShort(0x41FD01, 0x0E77); plugin::patch::SetUShort(0x41C9E0, 0x2977);
  203. plugin::patch::SetUShort(0x41CB80, 0x4F77); plugin::patch::SetUShort(0x4352F1, 0x0E77);
  204. plugin::patch::SetUShort(0x435331, 0x0E77); plugin::patch::Nop(0x561FB6, 2);
  205.  
  206. plugin::patch::Nop(0x6C6DF4, 6); // newsHeli
  207. plugin::patch::Nop(0x6B3810, 6); // newsHeli
  208. plugin::patch::Nop(0x562381, 7); // newsHeli
  209. plugin::patch::Nop(0x6B3C01, 7); // newsHeli
  210. plugin::patch::Nop(0x561C84, 7); // newsHeli
  211. plugin::patch::Nop(0x421A20, 5); // [star6 - 1 veh instead of 2 - tank only]
  212. plugin::patch::Nop(0x4219B7, 2); // [star4 - swat vehicles only]
  213. plugin::patch::Nop(0x561FB6, 2); // helisAfterStar6
  214. plugin::patch::SetUChar(0x4417E6 + 3, -1); // leaveTown
  215.  
  216. Events::gameProcessEvent += [] {
  217.  
  218. CWanted::bUseNewsHeliInAdditionToPolice = addNewsHeli; // privateData
  219.  
  220. CPed *playa = FindPlayerPed();
  221. CVehicle *veh = FindPlayerVehicle(-1, true);
  222. CWanted *Wanted = playa->m_pPlayerData->m_pWanted;
  223. DWORD star = Wanted->m_nWantedLevel;
  224. DWORD zone = CTheZones::m_CurrLevel;
  225. // std::string STARS = std::to_string(star);
  226. // std::string TOWN = std::to_string(zone);
  227.  
  228. for (int i = 0; i < CPools::ms_pPedPool->m_nSize; i++) {
  229. CPed *ped = CPools::ms_pPedPool->GetAt(i);
  230. if (ped) {
  231. if (ped->m_nPhysicalFlags.bAttachedToEntity) {
  232.  
  233. }
  234. }
  235. }
  236.  
  237. for (int i = 0; i < CPools::ms_pVehiclePool->m_nSize; i++) {
  238. CVehicle *veh = CPools::ms_pVehiclePool->GetAt(i);
  239. if (veh) {
  240. if (veh->m_nVehicleSubClass == VEHICLE_HELI) {
  241. if (veh->m_nCreatedBy == PERMANENT_VEHICLE) {
  242. DWORD newsHeliModel = plugin::patch::GetUInt(0x6C7A5E + 1);
  243. if (veh->m_nModelIndex != newsHeliModel) {
  244. veh->m_autoPilot.field_49 = heliSpeed; // privateData
  245. CDarkel::RegisterCarBlownUpByPlayer(veh, 1);
  246. if (veh->m_pDriver) {
  247. if (veh->m_pDriver->m_nPedState == PEDSTATE_DEAD) {
  248. veh->m_fHealth -= 2.5;
  249. if (veh->m_autoPilot.m_nCarMission == 57 || veh->m_autoPilot.m_nCarMission == 58) {
  250. veh->m_autoPilot.m_nCarMission = 58;
  251. }
  252. }
  253. } else {
  254. DWORD TABLE_1_begin = plugin::patch::GetUInt(0x41C0BA + 3);
  255. DWORD table1_index = veh->m_nModelIndex - 0x190 + TABLE_1_begin;
  256. byte table1_pos = plugin::patch::GetChar(table1_index);
  257.  
  258. veh->m_nCreatedBy = RANDOM_VEHICLE;
  259. CCarAI::AddPoliceCarOccupants(veh, 1);
  260. veh->m_nCreatedBy = PERMANENT_VEHICLE;
  261.  
  262. if (veh->m_nVehicleWeaponInUse == CAR_WEAPON_NOT_USED) {
  263. veh->m_autoPilot.m_nCarMission = POLICE_HELI_CHASE_ENTITY;
  264. veh->m_autoPilot.m_nCruiseSpeed = 0x64;
  265. } else {
  266. if (veh->m_nVehicleWeaponInUse == CAR_WEAPON_DOUBLE_ROCKET) {
  267. veh->m_autoPilot.m_nCarMission = HELI_ATTACK_PLAYER;
  268. veh->m_autoPilot.m_nCruiseSpeed = 0x64;
  269. // veh->m_autoPilot.m_aPathFindNodesInfo[6].m_wAreaId = 1000;
  270. }
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. }
  278.  
  279. // int brb = CStats::StatTypesInt[STAT_NUMBER_OF_POLICE_BRIBES];
  280. _playerStatsInteger = plugin::patch::GetUInt(0x558E59 + 3);
  281. bribesCollected = plugin::patch::GetUInt(_playerStatsInteger + STAT_NUMBER_OF_POLICE_BRIBES * 4);
  282.  
  283. if (MaxStars < StarLimit) {
  284. plugin::patch::SetUInt(0x561C70 + 6, MaxStars); plugin::patch::SetUInt(0x561EED + 6, MaxStars);
  285. plugin::patch::SetUChar(0x58DFE2 + 2, MaxStars);
  286. } else {
  287. plugin::patch::SetUInt(0x561C70 + 6, 11); plugin::patch::SetUInt(0x561EED + 6, 11);
  288. plugin::patch::SetUChar(0x58DFE2 + 2, 11);
  289. }
  290.  
  291. if (MaxStars == 4 || MaxStars == 5) {
  292. plugin::patch::SetUChar(0x561F80 + 3, MaxStars); plugin::patch::SetUChar(0x561F60 + 3, MaxStars);
  293. plugin::patch::SetUChar(0x561F40 + 3, MaxStars);
  294. } else {
  295. plugin::patch::SetUChar(0x561F80 + 3, 6); plugin::patch::SetUChar(0x561F60 + 3, 5);
  296. plugin::patch::SetUChar(0x561F40 + 3, 4);
  297. }
  298.  
  299. if (Wanted->m_nChaosLevel >= MaxChaos) {
  300. if (Wanted->m_nWantedLevel != MaxStars) {
  301. plugin::patch::SetUInt(0x561CA5 + 1, MaxChaos); plugin::patch::SetUInt(0x5624F8 + 2, MaxChaos + 20);
  302. plugin::patch::SetUChar(0x561CCD + 3, MaxStars); Wanted->CheatWantedLevel(MaxStars);
  303. }
  304. } else {
  305. if (Wanted->m_nChaosLevel >= 16700) {
  306. if (Wanted->m_nWantedLevel != 11) {
  307. plugin::patch::SetUInt(0x561CA5 + 1, 17100); plugin::patch::SetUInt(0x5624F8 + 2, 17120);
  308. plugin::patch::SetUChar(0x561CCD + 3, 11); Wanted->CheatWantedLevel(11);
  309. }
  310. } else {
  311. if (Wanted->m_nChaosLevel >= 14200) {
  312. if (Wanted->m_nWantedLevel != 10) {
  313. plugin::patch::SetUInt(0x561CA5 + 1, 14600); plugin::patch::SetUInt(0x5624F8 + 2, 14620);
  314. plugin::patch::SetUChar(0x561CCD + 3, 10); Wanted->CheatWantedLevel(10);
  315. }
  316. } else {
  317. if (Wanted->m_nChaosLevel >= 11700) {
  318. if (Wanted->m_nWantedLevel != 9) {
  319. plugin::patch::SetUInt(0x561CA5 + 1, 12100); plugin::patch::SetUInt(0x5624F8 + 2, 12120);
  320. plugin::patch::SetUChar(0x561CCD + 3, 9); Wanted->CheatWantedLevel(9);
  321. }
  322. } else {
  323. if (Wanted->m_nChaosLevel >= 9200) {
  324. if (Wanted->m_nWantedLevel != 8) {
  325. plugin::patch::SetUInt(0x561CA5 + 1, 9600); plugin::patch::SetUInt(0x5624F8 + 2, 9620);
  326. plugin::patch::SetUChar(0x561CCD + 3, 8); Wanted->CheatWantedLevel(8);
  327. }
  328. } else {
  329. if (Wanted->m_nChaosLevel >= 6700) {
  330. if (Wanted->m_nWantedLevel != 7) {
  331. plugin::patch::SetUInt(0x561CA5 + 1, 7100); plugin::patch::SetUInt(0x5624F8 + 2, 7120);
  332. plugin::patch::SetUChar(0x561CCD + 3, 7); Wanted->CheatWantedLevel(7);
  333. }
  334. } else {
  335. if (Wanted->m_nChaosLevel >= 4600) {
  336. if (Wanted->m_nWantedLevel != 6) {
  337. plugin::patch::SetUInt(0x561CA5 + 1, 4600); plugin::patch::SetUInt(0x5624F8 + 2, 4620);
  338. plugin::patch::SetUChar(0x561CCD + 3, 6); Wanted->CheatWantedLevel(6);
  339. }
  340. }
  341. }
  342. }
  343. }
  344. }
  345. }
  346. }
  347.  
  348. int ChaosValues[] = { 0, 50, 180, 550, 1200, 2400, 4600, 7100, 9600, 12100, 14600, 17100 };
  349. if (CCheat::m_CheatString[1] == 'R' && CCheat::m_CheatString[2] == 'A' &&
  350. CCheat::m_CheatString[3] == 'T' && CCheat::m_CheatString[4] == 'S') {
  351. if (CCheat::m_CheatString[0] <= '9') {
  352. byte currentLevel = CCheat::m_CheatString[0] - 0x30;
  353. DWORD chaosElem = ChaosValues[currentLevel];
  354. if (Wanted->m_nWantedLevel != currentLevel) {
  355. plugin::patch::SetUInt(0x561CA5 + 1, chaosElem); plugin::patch::SetUInt(0x5624F8 + 2, chaosElem + 20);
  356. plugin::patch::SetUChar(0x561CCD + 3, currentLevel); Wanted->CheatWantedLevel(currentLevel);
  357. CHud::SetHelpMessage("Wanted Level Cheat", 1, 0, 1);
  358. }
  359. }
  360. else {
  361. if (CCheat::m_CheatString[0] == 'S' && CCheat::m_CheatString[1] == 'R' &&
  362. CCheat::m_CheatString[2] == 'A' && CCheat::m_CheatString[3] == 'T' &&
  363. CCheat::m_CheatString[4] == 'S') {
  364. byte Digits = CCheat::m_CheatString[6] - 0x30; Digits *= 0x0A;
  365. byte Digit = CCheat::m_CheatString[5] - 0x30;
  366. byte currentLevel = Digits + Digit;
  367. DWORD chaosElem = ChaosValues[currentLevel];
  368. if (Wanted->m_nWantedLevel != currentLevel) {
  369. if (star <= 6) {
  370. currentLevel = 6;
  371. }
  372.  
  373. plugin::patch::SetUInt(0x561CA5 + 1, chaosElem);
  374. plugin::patch::SetUInt(0x5624F8 + 2, chaosElem + 20);
  375. plugin::patch::SetUChar(0x561CCD + 3, currentLevel);
  376. Wanted->CheatWantedLevel(currentLevel);
  377. CHud::SetHelpMessage("Wanted Level Cheat", 1, 0, 1);
  378. }
  379. }
  380. }
  381. }
  382.  
  383. // plugin::Random(0, 7);
  384.  
  385. // char gv = plugin::GetGameVersion();
  386. // MessageBoxA(NULL, "This is my MsgBox WOO ", "My MsgBox", MB_OK);
  387.  
  388. // unsigned char wlStar = rand() % 6;
  389.  
  390. //--------------------------------------------Data--------------------------------------------
  391. if (star <= 3) {
  392.  
  393. } else {
  394. if (star == 4) {
  395.  
  396. } else {
  397. if (star == 5) {
  398.  
  399. } else {
  400. if (star == 6) {
  401.  
  402. } else {
  403. if (star == 7) {
  404.  
  405. } else {
  406. if (star == 8) {
  407.  
  408. } else {
  409. if (star == 9) {
  410.  
  411. } else {
  412. if (star == 10) {
  413.  
  414. }
  415. }
  416. }
  417. }
  418. }
  419. }
  420. }
  421. }
  422. //--------------------------------------------Data--------------------------------------------
  423.  
  424.  
  425. WORD vehModelID = 5683;
  426. WORD pedModelID = MODEL_WMOMIB;
  427. eWeaponType weponType = WEAPON_AK47;
  428. // DWORD gunModelID = MODEL_AK47;
  429. byte Occupants = FOUR_OCCUPANTS;
  430. byte vehColour1 = 0;
  431. byte vehColour2 = 0;
  432.  
  433. WORD heliPilot = MODEL_LAPDM1;
  434. WORD heliModel = MODEL_HUNTER;
  435. byte heliOccupants = DRIVER_AND_GUNMAN;
  436. byte heliColour = 0;
  437.  
  438. WORD boatDriverID = MODEL_WMYSGRD;
  439. WORD boatModelID = MODEL_SQUALO;
  440. byte boatOccupants = DRIVER_AND_GUNMAN;
  441. byte boatColour = 0;
  442.  
  443. WORD planePilotID = MODEL_LAPDM1;
  444. WORD planeModelID = MODEL_RUSTLER;
  445. byte planeOccupants = DRIVER_AND_GUNMAN;
  446. byte planeColour = 0;
  447.  
  448. WORD bikerID = MODEL_WMOSCI;
  449. WORD bikeModelID = MODEL_NRG500;
  450. byte bikeOccupants = TWO_OCCUPANTS;
  451. byte bikeColour1 = 0;
  452. byte bikeColour2 = 0;
  453.  
  454. DWORD gunModelID = CPickups::ModelForWeapon(weponType);
  455.  
  456. table1 = plugin::patch::GetUInt(0x41C0BD); table2 = plugin::patch::GetUInt(0x613A7F);
  457. table3 = plugin::patch::GetUInt(0x461322); table4 = plugin::patch::GetUInt(0x6D2383);
  458. table9 = plugin::patch::GetUInt(0x6D1711 + 3);
  459.  
  460. lowestCase = 0 - plugin::patch::GetUInt(0x611904 + 1);
  461. maxSwitchTableValues = plugin::patch::GetUChar(0x611909 + 2);
  462. highestCase = lowestCase + maxSwitchTableValues++;
  463. SwitchTableStart = plugin::patch::GetUInt(0x61190E + 3);
  464.  
  465. // if (CStreaming::ms_streamingBufferSize >= vehModelID && CStreaming::ms_streamingBufferSize >= pedModelID &&
  466. // CStreaming::ms_streamingBufferSize >= gunModelID) {
  467. CBaseModelInfo *Model1 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[vehModelID]);
  468. CBaseModelInfo *Model2 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[pedModelID]);
  469. CBaseModelInfo *Model3 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[gunModelID]);
  470. if (Model1 > 0 && Model2 > 0 && Model3 > 0) {
  471. int modelType1 = Model1->GetModelType(); int modelType2 = Model2->GetModelType();
  472. int modelType3 = Model3->GetModelType();
  473. if (modelType1 == MODEL_INFO_VEHICLE && modelType2 == MODEL_INFO_PED && modelType3 == MODEL_INFO_WEAPON) {
  474. int vehLoadS = CStreaming::ms_aInfoForModel[vehModelID].m_nLoadState;
  475. int pedLoadS = CStreaming::ms_aInfoForModel[pedModelID].m_nLoadState;
  476. int gunLoadS = CStreaming::ms_aInfoForModel[gunModelID].m_nLoadState;
  477. if (vehLoadS == LOADSTATE_LOADED && pedLoadS == LOADSTATE_LOADED && gunLoadS == LOADSTATE_LOADED) {
  478.  
  479. plugin::patch::SetUChar(0x5DDCCC + 1, weponType); plugin::patch::SetUChar(0x68BBB6 + 1, weponType);
  480. plugin::patch::SetUChar(0x5DDDA0 + 1, weponType); plugin::patch::SetUChar(0x5DDDA9 + 1, weponType);
  481. plugin::patch::SetUChar(0x5DDDE0 + 1, weponType); plugin::patch::SetUChar(0x5DDDE9 + 1, weponType);
  482. plugin::patch::SetUChar(0x5DDE20 + 1, weponType); plugin::patch::SetUChar(0x5DDE29 + 1, weponType);
  483.  
  484. plugin::patch::SetUChar(0x6150BD + 1, weponType); plugin::patch::SetUChar(0x615085 + 1, weponType);
  485. plugin::patch::SetUChar(0x6150F3 + 1, weponType); plugin::patch::SetUChar(0x615114 + 1, weponType);
  486. plugin::patch::SetUChar(0x41C311 + 1, weponType);
  487. // modelInfo
  488. CVehicleModelInfo *vehModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[vehModelID]);
  489. vehModelInfo->m_nCurrentPrimaryColor = vehColour1;
  490. vehModelInfo->m_nCurrentSecondaryColor = vehColour2;
  491. vehModelInfo->m_nCurrentQuaternaryColor = vehColour1;
  492. vehModelInfo->m_nCurrentTertiaryColor = vehColour2;
  493. byte colVar = vehModelInfo->m_nNumColorVariations; byte num = 0;
  494. while (colVar >= num) {
  495. vehModelInfo->m_anPrimaryColors[num] = vehColour1; num++;
  496. vehModelInfo->m_anPrimaryColors[num] = vehColour2; num++;
  497. }
  498. vehModelInfo->m_nCompRules = 0;
  499. vehModelInfo->m_nFlags = 0;
  500. vehModelInfo->ms_compsUsed[0] = -1;
  501. vehModelInfo->ms_compsUsed[1] = -1;
  502. vehModelInfo->ms_compsUsed[2] = 0;
  503. vehModelInfo->ms_compsUsed[3] = 0;
  504. vehModelInfo->field_30 = 0;
  505. vehModelInfo->field_51 = 0;
  506. vehModelInfo->m_fDrawDistance = 2000.0;
  507. //
  508.  
  509. // switchCases
  510. table1Pos = vehModelID - 0x190 + table1; table2Pos = vehModelID - 0x190 + table2;
  511. table3Pos = vehModelID - 0x190 + table3; table4Pos = vehModelID - 0x190 + table4;
  512. table9Pos = vehModelID - 0x190 + table9;
  513. // door check
  514. if (Occupants == FOUR_OCCUPANTS) {
  515. if (vehModelInfo->m_nNumDoors == 1) {
  516. plugin::patch::SetUChar(table1Pos, ONE_OCCUPANT);
  517. } else {
  518. if (vehModelInfo->m_nNumDoors == 2 || vehModelInfo->m_nNumDoors == 3) {
  519. plugin::patch::SetUChar(table1Pos, TWO_OCCUPANTS);
  520. } else {
  521. if (vehModelInfo->m_nNumDoors >= 4) {
  522. plugin::patch::SetUChar(table1Pos, Occupants);
  523. }
  524. }
  525. }
  526. } else {
  527. if (Occupants == TWO_OCCUPANTS) {
  528. if (vehModelInfo->m_nNumDoors == 1) {
  529. plugin::patch::SetUChar(table1Pos, ONE_OCCUPANT);
  530. }
  531. } else {
  532. if (Occupants == ONE_OCCUPANT || Occupants == DRIVER_AND_GUNMAN) {
  533. plugin::patch::SetUChar(table1Pos, Occupants);
  534. }
  535. }
  536. }
  537.  
  538. if (star <= 3) {
  539. plugin::patch::SetUChar(table9Pos, 5);
  540. pedModel = COPS_IN_CAR; roadblockPed = ROADBLOCK_COP;
  541. pedModelCase = 0x613A8A; roadblockPedCase = 0x461378;
  542. jurisdiction = 0x5DDCA8;
  543. if (zone == UG_COUNTRY_SIDE) {
  544. CPedModelInfo *csherModelInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_CSHER]);
  545. voice1 = csherModelInfo->m_nVoice1; voice2 = csherModelInfo->m_nVoice2;
  546. }
  547. else {
  548. if (zone == UG_LOS_SANTOS) {
  549. CPedModelInfo *lsCopModelInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_LAPD1]);
  550. voice1 = lsCopModelInfo->m_nVoice1; voice2 = lsCopModelInfo->m_nVoice2;
  551. }
  552. else {
  553. if (zone == UG_SAN_FIERRO) {
  554. CPedModelInfo *sfCopModelInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_SFPD1]);
  555. voice1 = sfCopModelInfo->m_nVoice1; voice2 = sfCopModelInfo->m_nVoice2;
  556. }
  557. else {
  558. if (zone == UG_LAS_VENTURAS) {
  559. CPedModelInfo *lvCopModelInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_LVPD1]);
  560. voice1 = lvCopModelInfo->m_nVoice1; voice2 = lvCopModelInfo->m_nVoice2;
  561. }
  562. else {
  563. CPedModelInfo *dsherModelInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_DSHER]);
  564. voice1 = dsherModelInfo->m_nVoice1; voice2 = dsherModelInfo->m_nVoice2;
  565. }
  566. }
  567. }
  568. }
  569. pedModelCase = 0x613A8A; roadblockPedCase = 0x461378;
  570. jurisdiction = 0x5DDD8F;
  571. } else {
  572. if (star == 4) {
  573. plugin::patch::SetUChar(table9Pos, 2);
  574. CPedModelInfo *swatModelInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_SWAT]);
  575. voice1 = swatModelInfo->m_nVoice1; voice2 = swatModelInfo->m_nVoice2;
  576. pedModel = SWAT_IN_CAR; roadblockPed = ROADBLOCK_SWAT;
  577. pedModelCase = 0x613AA5; roadblockPedCase = 0x46132D;
  578. jurisdiction = 0x5DDD8F;
  579. } else {
  580. if (star == 5) {
  581. CPedModelInfo *fbiModelInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_FBI]);
  582. voice1 = fbiModelInfo->m_nVoice1; voice2 = fbiModelInfo->m_nVoice2;
  583. pedModel = FBI_IN_CAR; roadblockPed = ROADBLOCK_FBI;
  584. pedModelCase = 0x613AB4; roadblockPedCase = 0x461347;
  585. jurisdiction = 0x5DDDCF;
  586. } else {
  587. if (star >= 6) {
  588. CPedModelInfo *armyModelInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_ARMY]);
  589. voice1 = armyModelInfo->m_nVoice1; voice2 = armyModelInfo->m_nVoice2;
  590. pedModel = ARMY_IN_CAR; roadblockPed = ROADBLOCK_ARMY;
  591. pedModelCase = 0x613AC3; roadblockPedCase = 0x461361;
  592. jurisdiction = 0x5DDE0F;
  593. }
  594. }
  595. }
  596. }
  597.  
  598. CPedModelInfo *pedMod = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[pedModelID]);
  599. pedMod->m_fDrawDistance = 2000.0;
  600. pedMod->m_nFlags = 64;
  601. pedMod->m_nPedType = PED_TYPE_COP;
  602. pedMod->m_nStatType = 1;
  603. pedMod->m_nCarsCanDriveMask = 0x1FFF;
  604. pedMod->m_nPedFlags = 0;
  605. pedMod->m_nPedAudioType = PED_TYPE_EMG;
  606. pedMod->m_nVoice1 = voice1;
  607. pedMod->m_nVoice2 = voice2;
  608. pedMod->m_nVoiceId = voice1;
  609.  
  610. plugin::patch::SetUChar(table2Pos, pedModel);
  611. plugin::patch::SetUChar(table3Pos, roadblockPed);
  612. plugin::patch::SetUChar(table4Pos, LAW_VEHICLE);
  613. if (vehModelID >= lowestCase && vehModelID < highestCase) {
  614. plugin::patch::SetUChar(vehModelID - lowestCase + SwitchTableStart, DRIVER_DEFAULT);
  615. }
  616.  
  617. // CPopulation::AddPedInCar();
  618. plugin::patch::SetUInt(0x613BE8, pedModelCase); plugin::patch::SetUInt(0x613BEC, pedModelCase);
  619. plugin::patch::SetUInt(0x613BF0, pedModelCase); plugin::patch::SetUInt(0x613BF4, pedModelCase);
  620. plugin::patch::SetUInt(0x613BF8, 0x613A96);
  621.  
  622. // jurisdiction
  623. if (enableJurisdiction == true) {
  624. plugin::patch::SetUInt(0x5DDE5C, jurisdiction);
  625. } else {
  626. if (enableJurisdiction == false) {
  627. plugin::patch::SetUInt(0x5DDE5C, 0x5DDCA8);
  628. }
  629. }
  630.  
  631. vehType = CModelInfo::IsVehicleModelType(vehModelID);
  632. if (vehType == VEHICLE_AUTOMOBILE || vehType == VEHICLE_MTRUCK ||
  633. vehType == VEHICLE_BIKE || vehType == VEHICLE_BMX || vehType == VEHICLE_QUAD) {
  634. copCarByTown = plugin::patch::GetUInt(0x407C8D + 3);
  635. copPedByTown = plugin::patch::GetUInt(0x407C94 + 3);
  636. city = CTheZones::m_CurrLevel * 4; copCarByTown += city; copPedByTown += city;
  637. plugin::patch::SetUInt(copCarByTown, vehModelID); plugin::patch::SetUInt(0x4219B9 + 1, vehModelID);
  638. plugin::patch::SetUInt(0x4219E5 + 1, vehModelID); plugin::patch::SetUInt(0x421A29 + 2, vehModelID);
  639. //------------------------roadblock--------------
  640. plugin::patch::SetUInt(0x461BE6 + 1, vehModelID); plugin::patch::SetUInt(0x461BCB + 1, vehModelID);
  641. plugin::patch::SetUInt(0x461BB0 + 1, vehModelID);
  642. //------------------------roadblock--------------
  643. }
  644.  
  645. // peds
  646. plugin::patch::SetUInt(copPedByTown, pedModelID); plugin::patch::SetUInt(0x5DDD8F + 1, pedModelID);
  647. plugin::patch::SetUInt(0x5DDDCF + 1, pedModelID); plugin::patch::SetUInt(0x5DDE0F + 1, pedModelID);
  648. //-------------roadblockPed----------------------
  649. plugin::patch::SetUInt(0x461335 + 4, pedModelID); plugin::patch::SetUInt(0x46134F + 4, pedModelID);
  650. plugin::patch::SetUInt(0x461369 + 4, pedModelID);
  651. //-------------roadblockPed---------------------
  652.  
  653. // CPedModelInfo *fbiPed = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_SFR3]);
  654. // plugin::patch::SetUInt(0x6CD942, fbiPed->m_nVoice1);
  655. // plugin::patch::SetUInt(0x6CD78C, fbiPed->m_nVoice2);
  656. // plugin::patch::SetUInt(0x6C8F12, fbiPed->m_nVoiceId);
  657. } else {
  658. CStreaming::RequestModel(vehModelID, true);
  659. CStreaming::RequestModel(pedModelID, true);
  660. CStreaming::RequestModel(gunModelID, true);
  661. // CStreaming::LoadRequestedModels();
  662. }
  663.  
  664. CBaseModelInfo *Model6 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[bikeModelID]);
  665. CBaseModelInfo *Model7 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[bikerID]);
  666. if (Model6 > 0 && Model7 > 0) {
  667. int modelType6 = Model6->GetModelType(); int modelType7 = Model7->GetModelType();
  668. if (modelType6 == MODEL_INFO_VEHICLE && modelType7 == MODEL_INFO_PED) {
  669. int bikeLoadS = CStreaming::ms_aInfoForModel[bikeModelID].m_nLoadState;
  670. int bikeLoadSatte = CStreaming::ms_aInfoForModel[bikerID].m_nLoadState;
  671. if (bikeLoadS == LOADSTATE_LOADED && bikeLoadSatte == LOADSTATE_LOADED) {
  672. int vehTypeBike = CModelInfo::IsVehicleModelType(bikeModelID);
  673. if (vehTypeBike == VEHICLE_AUTOMOBILE || vehTypeBike == VEHICLE_MTRUCK ||
  674. vehTypeBike == VEHICLE_BIKE || vehTypeBike == VEHICLE_BMX || vehTypeBike == VEHICLE_QUAD) {
  675. // modelInfo
  676. CPedModelInfo *defBikerModInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_LAPDM1]);
  677. CPedModelInfo *bikerModInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[bikerID]);
  678. bikerModInfo->m_fDrawDistance = defBikerModInfo->m_fDrawDistance;
  679. bikerModInfo->m_nFlags = defBikerModInfo->m_nFlags;
  680. bikerModInfo->m_nPedType = defBikerModInfo->m_nPedType;
  681. bikerModInfo->m_nStatType = defBikerModInfo->m_nStatType;
  682. bikerModInfo->m_nCarsCanDriveMask = defBikerModInfo->m_nCarsCanDriveMask;
  683. bikerModInfo->m_nPedFlags = defBikerModInfo->m_nPedFlags;
  684. bikerModInfo->m_nPedAudioType = defBikerModInfo->m_nPedAudioType;
  685. bikerModInfo->m_nVoice1 = defBikerModInfo->m_nVoice1;
  686. bikerModInfo->m_nVoice2 = defBikerModInfo->m_nVoice2;
  687. bikerModInfo->m_nVoiceId = defBikerModInfo->m_nVoiceId;
  688.  
  689. CVehicleModelInfo *bikeModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[bikeModelID]);
  690. CVehicleModelInfo *defBikeModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_COPBIKE]);
  691. bikeModelInfo->m_nCurrentPrimaryColor = bikeColour1;
  692. bikeModelInfo->m_nCurrentSecondaryColor = bikeColour2;
  693. bikeModelInfo->m_nCurrentQuaternaryColor = bikeColour1;
  694. bikeModelInfo->m_nCurrentTertiaryColor = bikeColour2;
  695.  
  696. byte colVar2 = bikeModelInfo->m_nNumColorVariations; byte num2 = 0;
  697. while (colVar2 >= num2) {
  698. bikeModelInfo->m_anPrimaryColors[num2] = bikeColour1; num2++;
  699. bikeModelInfo->m_anPrimaryColors[num2] = bikeColour2; num2++;
  700. }
  701.  
  702. bikeModelInfo->m_nCompRules = defBikeModelInfo->m_nCompRules;
  703. bikeModelInfo->m_nFlags = defBikeModelInfo->m_nFlags;
  704. bikeModelInfo->ms_compsUsed[0] = defBikeModelInfo->ms_compsUsed[0];
  705. bikeModelInfo->ms_compsUsed[1] = defBikeModelInfo->ms_compsUsed[1];
  706. bikeModelInfo->ms_compsUsed[2] = defBikeModelInfo->ms_compsUsed[2];
  707. bikeModelInfo->ms_compsUsed[3] = defBikeModelInfo->ms_compsUsed[3];
  708. bikeModelInfo->field_30 = defBikeModelInfo->field_30;
  709. bikeModelInfo->field_51 = defBikeModelInfo->field_51;
  710. bikeModelInfo->m_fDrawDistance = defBikeModelInfo->m_fDrawDistance;
  711.  
  712. // switch cases
  713. DWORD tableBike1Pos = bikeModelID - 0x190 + table1;
  714. DWORD tableBike2Pos = bikeModelID - 0x190 + table2;
  715. DWORD tableBike3Pos = bikeModelID - 0x190 + table3;
  716. DWORD tableBike4Pos = bikeModelID - 0x190 + table4;
  717. DWORD tableBike9Pos = bikeModelID - 0x190 + table9;
  718.  
  719. // door check
  720. CVehicleModelInfo *vehModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[bikeModelID]);
  721. if (bikeOccupants == FOUR_OCCUPANTS) {
  722. if (vehModelInfo->m_nNumDoors == 1) {
  723. plugin::patch::SetUChar(tableBike1Pos, ONE_OCCUPANT);
  724. } else {
  725. if (vehModelInfo->m_nNumDoors == 2 || vehModelInfo->m_nNumDoors == 3) {
  726. plugin::patch::SetUChar(tableBike1Pos, TWO_OCCUPANTS);
  727. } else {
  728. if (vehModelInfo->m_nNumDoors >= 4) {
  729. plugin::patch::SetUChar(tableBike1Pos, bikeOccupants);
  730. }
  731. }
  732. }
  733. } else {
  734. if (bikeOccupants == TWO_OCCUPANTS) {
  735. if (vehModelInfo->m_nNumDoors == 1) {
  736. plugin::patch::SetUChar(tableBike1Pos, ONE_OCCUPANT);
  737. }
  738. } else {
  739. if (bikeOccupants == ONE_OCCUPANT || bikeOccupants == DRIVER_AND_GUNMAN) {
  740. plugin::patch::SetUChar(tableBike1Pos, bikeOccupants);
  741. }
  742. }
  743. }
  744.  
  745. plugin::patch::SetUChar(tableBike2Pos, COP_BIKER);
  746. plugin::patch::SetUChar(tableBike4Pos, LAW_VEHICLE);
  747.  
  748. if (bikeModelID >= lowestCase && bikeModelID < highestCase) {
  749. plugin::patch::SetUChar(bikeModelID - lowestCase + SwitchTableStart, DRIVER_DEFAULT);
  750. }
  751.  
  752. // Models
  753. copBikeByTown = plugin::patch::GetUInt(0x407C7C + 1);
  754. plugin::patch::SetUInt(copBikeByTown, bikeModelID);
  755. plugin::patch::SetUInt(0x41F2A2 + 1, bikeModelID);
  756. plugin::patch::SetUInt(0x461C19 + 2, bikeModelID);
  757. plugin::patch::SetUShort(0x6BD40F + 4, bikeModelID);
  758. plugin::patch::SetUInt(0x70BFE8 + 2, bikeModelID);
  759. plugin::patch::SetUShort(0x6D7E11 + 4, bikeModelID);
  760.  
  761. copBikePed = plugin::patch::GetUInt(0x407C6B + 1);
  762. plugin::patch::SetUInt(copBikePed, bikerID);
  763. plugin::patch::SetUInt(0x5DDD85 + 1, bikerID);
  764. }
  765. } else {
  766. CStreaming::RequestModel(bikeModelID, true);
  767. CStreaming::RequestModel(bikerID, true);
  768. // CStreaming::LoadRequestedModels();
  769. }
  770. }
  771. }
  772.  
  773. CBaseModelInfo *Model4 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[heliModel]);
  774. CBaseModelInfo *Model5 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[heliPilot]);
  775. if (Model4 > 0 && Model5 > 0) {
  776. int modelType4 = Model4->GetModelType(); int modelType5 = Model5->GetModelType();
  777. if (modelType4 == MODEL_INFO_VEHICLE && modelType5 == MODEL_INFO_PED) {
  778. int heliLoadState = CStreaming::ms_aInfoForModel[heliModel].m_nLoadState;
  779. int heliPilotLoadState = CStreaming::ms_aInfoForModel[heliPilot].m_nLoadState;
  780. if (heliLoadState == LOADSTATE_LOADED && heliPilotLoadState == LOADSTATE_LOADED) {
  781. int vehTypeHeli = CModelInfo::IsVehicleModelType(heliModel);
  782. if (vehTypeHeli == VEHICLE_HELI || vehTypeHeli == VEHICLE_PLANE) {
  783. // modelInfo
  784. CPedModelInfo *defHeliPilotModInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_LAPDM1]);
  785. CPedModelInfo *heliPilotModInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[heliPilot]);
  786. heliPilotModInfo->m_fDrawDistance = defHeliPilotModInfo->m_fDrawDistance;
  787. heliPilotModInfo->m_nFlags = defHeliPilotModInfo->m_nFlags;
  788. heliPilotModInfo->m_nPedType = defHeliPilotModInfo->m_nPedType;
  789. heliPilotModInfo->m_nStatType = defHeliPilotModInfo->m_nStatType;
  790. heliPilotModInfo->m_nCarsCanDriveMask = defHeliPilotModInfo->m_nCarsCanDriveMask;
  791. heliPilotModInfo->m_nPedFlags = defHeliPilotModInfo->m_nPedFlags;
  792. heliPilotModInfo->m_nPedAudioType = defHeliPilotModInfo->m_nPedAudioType;
  793. heliPilotModInfo->m_nVoice1 = defHeliPilotModInfo->m_nVoice1;
  794. heliPilotModInfo->m_nVoice2 = defHeliPilotModInfo->m_nVoice2;
  795. heliPilotModInfo->m_nVoiceId = defHeliPilotModInfo->m_nVoiceId;
  796.  
  797. CVehicleModelInfo *heliModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[heliModel]);
  798. CVehicleModelInfo *defheliModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_POLMAV]);
  799. heliModelInfo->m_nCurrentPrimaryColor = heliColour;
  800. heliModelInfo->m_nCurrentSecondaryColor = heliColour;
  801. heliModelInfo->m_nCurrentQuaternaryColor = heliColour;
  802. heliModelInfo->m_nCurrentTertiaryColor = heliColour;
  803.  
  804. byte colVar2 = heliModelInfo->m_nNumColorVariations; byte num3 = 0;
  805. while (colVar2 >= num3) {
  806. heliModelInfo->m_anPrimaryColors[num3] = heliColour; num3++;
  807. heliModelInfo->m_anPrimaryColors[num3] = heliColour; num3++;
  808. }
  809.  
  810. heliModelInfo->m_nCompRules = defheliModelInfo->m_nCompRules;
  811. heliModelInfo->m_nFlags = defheliModelInfo->m_nFlags;
  812. heliModelInfo->ms_compsUsed[0] = defheliModelInfo->ms_compsUsed[0];
  813. heliModelInfo->ms_compsUsed[1] = defheliModelInfo->ms_compsUsed[1];
  814. heliModelInfo->ms_compsUsed[2] = defheliModelInfo->ms_compsUsed[2];
  815. heliModelInfo->ms_compsUsed[3] = defheliModelInfo->ms_compsUsed[3];
  816. heliModelInfo->field_30 = defheliModelInfo->field_30;
  817. heliModelInfo->field_51 = defheliModelInfo->field_51;
  818. heliModelInfo->m_fDrawDistance = defheliModelInfo->m_fDrawDistance;
  819.  
  820. // switch cases
  821. DWORD tableHeli1Pos = heliModel - 0x190 + table1;
  822. DWORD tableHeli2Pos = heliModel - 0x190 + table2;
  823. DWORD tableHeli3Pos = heliModel - 0x190 + table3;
  824. DWORD tableHeli4Pos = heliModel - 0x190 + table4;
  825. DWORD tableHeli9Pos = heliModel - 0x190 + table9;
  826.  
  827. // door check
  828. CVehicleModelInfo *vehModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[heliModel]);
  829. if (heliOccupants == FOUR_OCCUPANTS) {
  830. if (vehModelInfo->m_nNumDoors == 1) {
  831. plugin::patch::SetUChar(tableHeli1Pos, ONE_OCCUPANT);
  832. } else {
  833. if (vehModelInfo->m_nNumDoors == 2 || vehModelInfo->m_nNumDoors == 3) {
  834. plugin::patch::SetUChar(tableHeli1Pos, TWO_OCCUPANTS);
  835. } else {
  836. if (vehModelInfo->m_nNumDoors >= 4) {
  837. plugin::patch::SetUChar(tableHeli1Pos, heliOccupants);
  838. }
  839. }
  840. }
  841. } else {
  842. if (heliOccupants == TWO_OCCUPANTS) {
  843. if (vehModelInfo->m_nNumDoors == 1) {
  844. plugin::patch::SetUChar(tableHeli1Pos, ONE_OCCUPANT);
  845. }
  846. } else {
  847. if (heliOccupants == ONE_OCCUPANT || heliOccupants == DRIVER_AND_GUNMAN) {
  848. plugin::patch::SetUChar(tableHeli1Pos, heliOccupants);
  849. }
  850. }
  851. }
  852.  
  853. plugin::patch::SetUChar(tableHeli2Pos, COP_BIKER);
  854. plugin::patch::SetUChar(tableHeli4Pos, LAW_VEHICLE);
  855.  
  856. if (heliModel >= lowestCase && heliModel < highestCase) {
  857. plugin::patch::SetUChar(heliModel - lowestCase + SwitchTableStart, DRIVER_DEFAULT);
  858. }
  859.  
  860. // Models
  861. plugin::patch::SetUInt(0x6C6589 + 1, heliModel);
  862. plugin::patch::SetUInt(0x40B890 + 1, heliModel);
  863. plugin::patch::SetUInt(0x40B840 + 1, heliModel);
  864. plugin::patch::SetUInt(0x6C79CE + 1, heliModel);
  865. plugin::patch::SetUInt(0x6CD37A + 1, heliModel);
  866.  
  867. copBikePed = plugin::patch::GetUInt(0x407C6B + 1);
  868. plugin::patch::SetUInt(copBikePed, heliPilot);
  869. plugin::patch::SetUInt(0x5DDD85 + 1, heliPilot);
  870.  
  871. LoadedObjectInfo = plugin::patch::GetUInt(0x4044C7 + 3);
  872. plugin::patch::SetUInt(0x6C7A96 + 2, heliModel * 0x14 + LoadedObjectInfo);
  873. }
  874. } else {
  875. CStreaming::RequestModel(heliModel, true);
  876. CStreaming::RequestModel(heliPilot, true);
  877. // CStreaming::LoadRequestedModels();
  878. }
  879. }
  880. }
  881.  
  882. CBaseModelInfo *Model8 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[planeModelID]);
  883. CBaseModelInfo *Model9 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[planePilotID]);
  884. if (Model8 > 0 && Model9 > 0) {
  885. int modelType8 = Model8->GetModelType(); int modelType9 = Model9->GetModelType();
  886. if (modelType8 == MODEL_INFO_VEHICLE && modelType9 == MODEL_INFO_PED) {
  887. int planeLoadState = CStreaming::ms_aInfoForModel[planeModelID].m_nLoadState;
  888. int planePilotIDLoadState = CStreaming::ms_aInfoForModel[planePilotID].m_nLoadState;
  889. if (planeLoadState == LOADSTATE_LOADED && planePilotIDLoadState == LOADSTATE_LOADED) {
  890. int vehTypePlane = CModelInfo::IsVehicleModelType(planeModelID);
  891. if (vehTypePlane == VEHICLE_HELI || vehTypePlane == VEHICLE_PLANE) {
  892. // modelInfo
  893. CPedModelInfo *defplanePilotIDModInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_ARMY]);
  894. CPedModelInfo *planePilotIDModInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[planePilotID]);
  895. planePilotIDModInfo->m_fDrawDistance = defplanePilotIDModInfo->m_fDrawDistance;
  896. planePilotIDModInfo->m_nFlags = defplanePilotIDModInfo->m_nFlags;
  897. planePilotIDModInfo->m_nPedType = defplanePilotIDModInfo->m_nPedType;
  898. planePilotIDModInfo->m_nStatType = defplanePilotIDModInfo->m_nStatType;
  899. planePilotIDModInfo->m_nCarsCanDriveMask = defplanePilotIDModInfo->m_nCarsCanDriveMask;
  900. planePilotIDModInfo->m_nPedFlags = defplanePilotIDModInfo->m_nPedFlags;
  901. planePilotIDModInfo->m_nPedAudioType = defplanePilotIDModInfo->m_nPedAudioType;
  902. planePilotIDModInfo->m_nVoice1 = defplanePilotIDModInfo->m_nVoice1;
  903. planePilotIDModInfo->m_nVoice2 = defplanePilotIDModInfo->m_nVoice2;
  904. planePilotIDModInfo->m_nVoiceId = defplanePilotIDModInfo->m_nVoiceId;
  905.  
  906. CVehicleModelInfo *planeModelIDInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[planeModelID]);
  907. CVehicleModelInfo *defplaneModelIDInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_HYDRA]);
  908. planeModelIDInfo->m_nCurrentPrimaryColor = planeColour;
  909. planeModelIDInfo->m_nCurrentSecondaryColor = planeColour;
  910. planeModelIDInfo->m_nCurrentQuaternaryColor = planeColour;
  911. planeModelIDInfo->m_nCurrentTertiaryColor = planeColour;
  912.  
  913. byte colVar2 = planeModelIDInfo->m_nNumColorVariations; byte num3 = 0;
  914. while (colVar2 >= num3) {
  915. planeModelIDInfo->m_anPrimaryColors[num3] = planeColour; num3++;
  916. planeModelIDInfo->m_anPrimaryColors[num3] = planeColour; num3++;
  917. }
  918.  
  919. planeModelIDInfo->m_nCompRules = defplaneModelIDInfo->m_nCompRules;
  920. planeModelIDInfo->m_nFlags = defplaneModelIDInfo->m_nFlags;
  921. planeModelIDInfo->ms_compsUsed[0] = defplaneModelIDInfo->ms_compsUsed[0];
  922. planeModelIDInfo->ms_compsUsed[1] = defplaneModelIDInfo->ms_compsUsed[1];
  923. planeModelIDInfo->ms_compsUsed[2] = defplaneModelIDInfo->ms_compsUsed[2];
  924. planeModelIDInfo->ms_compsUsed[3] = defplaneModelIDInfo->ms_compsUsed[3];
  925. planeModelIDInfo->field_30 = defplaneModelIDInfo->field_30;
  926. planeModelIDInfo->field_51 = defplaneModelIDInfo->field_51;
  927. planeModelIDInfo->m_fDrawDistance = defplaneModelIDInfo->m_fDrawDistance;
  928.  
  929. // switch cases
  930. DWORD tablePlane1Pos = planeModelID - 0x190 + table1;
  931. DWORD tablePlane2Pos = planeModelID - 0x190 + table2;
  932. DWORD tablePlane3Pos = planeModelID - 0x190 + table3;
  933. DWORD tablePlane4Pos = planeModelID - 0x190 + table4;
  934. DWORD tablePlane9Pos = planeModelID - 0x190 + table9;
  935.  
  936. // door check
  937. CVehicleModelInfo *vehModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[planeModelID]);
  938. if (planeOccupants == FOUR_OCCUPANTS) {
  939. if (vehModelInfo->m_nNumDoors == 1) {
  940. plugin::patch::SetUChar(tablePlane1Pos, ONE_OCCUPANT);
  941. } else {
  942. if (vehModelInfo->m_nNumDoors == 2 || vehModelInfo->m_nNumDoors == 3) {
  943. plugin::patch::SetUChar(tablePlane1Pos, TWO_OCCUPANTS);
  944. } else {
  945. if (vehModelInfo->m_nNumDoors >= 4) {
  946. plugin::patch::SetUChar(tablePlane1Pos, planeOccupants);
  947. }
  948. }
  949. }
  950. } else {
  951. if (planeOccupants == TWO_OCCUPANTS) {
  952. if (vehModelInfo->m_nNumDoors == 1) {
  953. plugin::patch::SetUChar(tablePlane1Pos, ONE_OCCUPANT);
  954. }
  955. } else {
  956. if (planeOccupants == ONE_OCCUPANT || planeOccupants == DRIVER_AND_GUNMAN) {
  957. plugin::patch::SetUChar(tablePlane1Pos, planeOccupants);
  958. }
  959. }
  960. }
  961.  
  962. if (star <= 3) {
  963. plugin::patch::SetUChar(tablePlane2Pos, COPS_IN_CAR);
  964. } else {
  965. if (star == 4) {
  966. plugin::patch::SetUChar(tablePlane2Pos, SWAT_IN_CAR);
  967. } else {
  968. if (star == 5) {
  969. plugin::patch::SetUChar(tablePlane2Pos, FBI_IN_CAR);
  970. } else {
  971. if (star >= 6) {
  972. plugin::patch::SetUChar(tablePlane2Pos, ARMY_IN_CAR);
  973. }
  974. }
  975. }
  976. }
  977.  
  978. plugin::patch::SetUChar(tablePlane4Pos, LAW_VEHICLE);
  979.  
  980. if (planeModelID >= lowestCase && planeModelID < highestCase) {
  981. plugin::patch::SetUChar(planeModelID - lowestCase + SwitchTableStart, DRIVER_DEFAULT);
  982. }
  983.  
  984. // Models
  985. int dwModelId = plugin::patch::GetUInt(0x6CD7E6 + 1);
  986. plugin::patch::SetUInt(dwModelId, planeModelID);
  987. plugin::patch::SetUInt(0x6CD93C + 6, planeModelID); // [DWORD]
  988. plugin::patch::SetUInt(0x6CD78B + 1, planeModelID); // [DWORD]
  989. plugin::patch::SetUInt(0x6A53BA + 1, planeModelID); // [DWORD]
  990. plugin::patch::SetUInt(0x6C8F10 + 2, planeModelID); // [DWORD]
  991.  
  992. // plugin::patch::SetUShort(0x5254D8 + 2, planeModelID); // [WORD]
  993. // plugin::patch::SetUShort(0x524679 + 2, planeModelID); // [WORD]
  994. // plugin::patch::SetUShort(0x6CC3B1 + 3, planeModelID); // [WORD]
  995. // plugin::patch::SetUShort(0x6B0842 + 3, planeModelID); // [WORD]
  996. // plugin::patch::SetUShort(0x527058 + 4, planeModelID); // [WORD]
  997. // plugin::patch::SetUShort(0x58E09F + 4, planeModelID); // [WORD]
  998. // plugin::patch::SetUShort(0x6CB4F3 + 4, planeModelID); // [WORD]
  999. // plugin::patch::SetUShort(0x6C9F1C + 2, planeModelID); // [WORD]
  1000. // plugin::patch::SetUShort(0x6C968E + 4, planeModelID); // [WORD]
  1001. // plugin::patch::SetUShort(0x6C9101 + 4, planeModelID); // [WORD]
  1002. // plugin::patch::SetUShort(0x6D9C04 + 4, planeModelID); // [WORD]
  1003. // plugin::patch::SetUShort(0x6D8FDA + 3, planeModelID); // [WORD]
  1004. // plugin::patch::SetUShort(0x6E39B8 + 4, planeModelID); // [WORD]
  1005. }
  1006. } else {
  1007. CStreaming::RequestModel(planeModelID, true);
  1008. CStreaming::RequestModel(planePilotID, true);
  1009. // CStreaming::LoadRequestedModels();
  1010. }
  1011. }
  1012. }
  1013.  
  1014. CBaseModelInfo *Model10 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[boatModelID]);
  1015. CBaseModelInfo *Model11 = reinterpret_cast<CBaseModelInfo *>(CModelInfo::ms_modelInfoPtrs[boatDriverID]);
  1016. if (Model10 > 0 && Model11 > 0) {
  1017. int modelType8 = Model10->GetModelType(); int modelType9 = Model11->GetModelType();
  1018. if (modelType8 == MODEL_INFO_VEHICLE && modelType9 == MODEL_INFO_PED) {
  1019. int boatLoadState = CStreaming::ms_aInfoForModel[boatModelID].m_nLoadState;
  1020. int boatDriverIDLoadState = CStreaming::ms_aInfoForModel[boatDriverID].m_nLoadState;
  1021. if (boatLoadState == LOADSTATE_LOADED && boatDriverIDLoadState == LOADSTATE_LOADED) {
  1022. int vehTypeBoat = CModelInfo::IsVehicleModelType(boatModelID);
  1023. if (vehTypeBoat == VEHICLE_BOAT) {
  1024. // modelInfo
  1025. CPedModelInfo *defboatDriverIDModInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_ARMY]);
  1026. CPedModelInfo *boatDriverIDModInfo = reinterpret_cast<CPedModelInfo *>(CModelInfo::ms_modelInfoPtrs[boatDriverID]);
  1027. boatDriverIDModInfo->m_fDrawDistance = defboatDriverIDModInfo->m_fDrawDistance;
  1028. boatDriverIDModInfo->m_nFlags = defboatDriverIDModInfo->m_nFlags;
  1029. boatDriverIDModInfo->m_nPedType = defboatDriverIDModInfo->m_nPedType;
  1030. boatDriverIDModInfo->m_nStatType = defboatDriverIDModInfo->m_nStatType;
  1031. boatDriverIDModInfo->m_nCarsCanDriveMask = defboatDriverIDModInfo->m_nCarsCanDriveMask;
  1032. boatDriverIDModInfo->m_nPedFlags = defboatDriverIDModInfo->m_nPedFlags;
  1033. boatDriverIDModInfo->m_nPedAudioType = defboatDriverIDModInfo->m_nPedAudioType;
  1034. boatDriverIDModInfo->m_nVoice1 = defboatDriverIDModInfo->m_nVoice1;
  1035. boatDriverIDModInfo->m_nVoice2 = defboatDriverIDModInfo->m_nVoice2;
  1036. boatDriverIDModInfo->m_nVoiceId = defboatDriverIDModInfo->m_nVoiceId;
  1037.  
  1038. CVehicleModelInfo *boatModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[boatModelID]);
  1039. CVehicleModelInfo *defboatModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[MODEL_HYDRA]);
  1040. boatModelInfo->m_nCurrentPrimaryColor = boatColour;
  1041. boatModelInfo->m_nCurrentSecondaryColor = boatColour;
  1042. boatModelInfo->m_nCurrentQuaternaryColor = boatColour;
  1043. boatModelInfo->m_nCurrentTertiaryColor = boatColour;
  1044.  
  1045. byte colVar2 = boatModelInfo->m_nNumColorVariations; byte num3 = 0;
  1046. while (colVar2 >= num3) {
  1047. boatModelInfo->m_anPrimaryColors[num3] = boatColour; num3++;
  1048. boatModelInfo->m_anPrimaryColors[num3] = boatColour; num3++;
  1049. }
  1050.  
  1051. boatModelInfo->m_nCompRules = defboatModelInfo->m_nCompRules;
  1052. boatModelInfo->m_nFlags = defboatModelInfo->m_nFlags;
  1053. boatModelInfo->ms_compsUsed[0] = defboatModelInfo->ms_compsUsed[0];
  1054. boatModelInfo->ms_compsUsed[1] = defboatModelInfo->ms_compsUsed[1];
  1055. boatModelInfo->ms_compsUsed[2] = defboatModelInfo->ms_compsUsed[2];
  1056. boatModelInfo->ms_compsUsed[3] = defboatModelInfo->ms_compsUsed[3];
  1057. boatModelInfo->field_30 = defboatModelInfo->field_30;
  1058. boatModelInfo->field_51 = defboatModelInfo->field_51;
  1059. boatModelInfo->m_fDrawDistance = defboatModelInfo->m_fDrawDistance;
  1060.  
  1061. // switch cases
  1062. DWORD tableBoat1Pos = boatModelID - 0x190 + table1;
  1063. DWORD tableBoat2Pos = boatModelID - 0x190 + table2;
  1064. DWORD tableBoat3Pos = boatModelID - 0x190 + table3;
  1065. DWORD tableBoat4Pos = boatModelID - 0x190 + table4;
  1066. DWORD tableBoat9Pos = boatModelID - 0x190 + table9;
  1067.  
  1068. // door check
  1069. CVehicleModelInfo *vehModelInfo = reinterpret_cast<CVehicleModelInfo *>(CModelInfo::ms_modelInfoPtrs[boatModelID]);
  1070. if (boatOccupants == FOUR_OCCUPANTS) {
  1071. if (vehModelInfo->m_nNumDoors == 1) {
  1072. plugin::patch::SetUChar(tableBoat1Pos, ONE_OCCUPANT);
  1073. } else {
  1074. if (vehModelInfo->m_nNumDoors == 2 || vehModelInfo->m_nNumDoors == 3) {
  1075. plugin::patch::SetUChar(tableBoat1Pos, TWO_OCCUPANTS);
  1076. } else {
  1077. if (vehModelInfo->m_nNumDoors >= 4) {
  1078. plugin::patch::SetUChar(tableBoat1Pos, boatOccupants);
  1079. }
  1080. }
  1081. }
  1082. } else {
  1083. if (boatOccupants == TWO_OCCUPANTS) {
  1084. if (vehModelInfo->m_nNumDoors == 1) {
  1085. plugin::patch::SetUChar(tableBoat1Pos, ONE_OCCUPANT);
  1086. }
  1087. } else {
  1088. if (boatOccupants == ONE_OCCUPANT || boatOccupants == DRIVER_AND_GUNMAN) {
  1089. plugin::patch::SetUChar(tableBoat1Pos, boatOccupants);
  1090. }
  1091. }
  1092. }
  1093.  
  1094. plugin::patch::SetUChar(tableBoat2Pos, COPS_IN_CAR);
  1095. // plugin::patch::SetUChar(tableBoat4Pos, LAW_VEHICLE);
  1096.  
  1097. if (boatModelID >= lowestCase && boatModelID < highestCase) {
  1098. plugin::patch::SetUChar(boatModelID - lowestCase + SwitchTableStart, DRIVER_DEFAULT);
  1099. }
  1100.  
  1101. // Models
  1102. plugin::patch::SetUInt(0x430501 + 1, boatModelID); // [DWORD]
  1103. plugin::patch::SetUInt(0x4304ED + 4, boatModelID); // [DWORD]
  1104. LoadedObjectInfo = plugin::patch::GetUInt(0x4044C7 + 3);
  1105. plugin::patch::SetUInt(0x4304E6 + 2, boatModelID * 0x14 + LoadedObjectInfo);
  1106. }
  1107. } else {
  1108. CStreaming::RequestModel(boatModelID, true);
  1109. CStreaming::RequestModel(boatDriverID, true);
  1110. // CStreaming::LoadRequestedModels();
  1111. }
  1112. }
  1113. }
  1114.  
  1115. }
  1116. }
  1117.  
  1118. };
  1119. }
  1120. } wantedLevelEditor;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement