Advertisement
Guest User

MissionThreads.cpp

a guest
Jan 21st, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.14 KB | None | 0 0
  1. /*
  2. file:
  3. MissionThreads.cpp
  4. desc:
  5. This file contains the thread functions for the main, and mission scripts.
  6. */
  7.  
  8. // Inlcudes
  9. #include "MissionThreads.h"
  10. #include "GameScripting.h"
  11. #include "ScriptClasses.h"
  12.  
  13. // Externals
  14. extern ScriptScript* pScript; // Script stuff.
  15. extern ScriptGame* pGame; // Game stuff.
  16. extern ScriptPlayer* pPlayer; // Player stuff.
  17. extern GAME_SCRIPT_THREAD* gst;
  18. extern bool (*WastedBustedCheck)();
  19.  
  20.  
  21. // Defines
  22.  
  23. // The SCRIPT_WAIT() define is used with loops within a mission
  24. // thread to allow the execution of regular code to continue.
  25. #define SCRIPT_WAIT(x) \
  26. { \
  27. pScript->Wait(x); \
  28. SetEvent(pMission->hContinue); \
  29. WaitForSingleObject(pMission->hExecute, INFINITE); \
  30. }
  31.  
  32. // Used a the bottom of all mission thread functions to clean up.
  33. #define TERMINATE_THREAD() \
  34. { \
  35. pScript->TerminateThread(); \
  36. SetEvent(pMission->hContinue); \
  37. DelMission(pMission); \
  38. }
  39.  
  40. // Used at the top of all mission thread functions to wait for execution.
  41. #define INITIALISE_THREAD() \
  42. { \
  43. WaitForSingleObject(pMission->hExecute, INFINITE); \
  44. }
  45.  
  46. // Delete alloctaed memory safely.
  47. #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
  48.  
  49. // Used when on mission to cleanup markers, blips ,etc.
  50. #define ONMISSIONCLEANUP() {__asm call OnMissionCleanUp}
  51. #define RESUME() {__asm ret}
  52.  
  53. // Constants
  54. const VCPosition_t MissionStart = {-695.0f, 556.0f, 11.0f, 180.0f};
  55. const VCPosition_t MissionStart_sorup = {-680.0f, 556.0f, 11.0f, 180.0f};
  56. const VCPosition_t BikeShop = {-594.0f, 670.0f, 10.0f, 140.0f};
  57.  
  58.  
  59. // Globals
  60. bool bMissionEnded = true; // Mission ended flag.
  61.  
  62.  
  63. // Functions
  64.  
  65. //--------------------------------------------------------------------------------------------
  66. // func:
  67. // Mission_TheSample()
  68. //
  69. // desc:
  70. // This is the thread function for the one and only mission - "The Sample".
  71. //
  72. // params:
  73. // pMission
  74. // Passed via CreateThread() parameter.
  75. //
  76. // This is a pointer to the mission script strucutre for the mission assosiated
  77. // with this thread.
  78. //
  79. void Mission_TheSample(SCRIPT_MISSION* pMission)
  80. {
  81. INITIALISE_THREAD();
  82.  
  83. const VCPosition_t CopShop = {350.0f, -527.0f, 10.0f, 0.0f};
  84. const VCPosition_t SafeHouse = {-845.0f, -902.0f, 10.0f, 0.0f};
  85.  
  86. const VCPosition_t CopsStart = {-680.0f, 634.0f, 11.0f, 180.0f};
  87. const VCPosition_t PlayerCar = {-679.0f, 554.0f, 11.0f, 140.0f};
  88.  
  89. const float fCopsInitalSpeed = 20.0f;
  90. const float fCopsSpeedySpeed = 30.0f;
  91.  
  92. const int iRunningWantedLevel = 2;
  93. const int iEscapedWantedLevel = 3;
  94.  
  95. float fX, fY, fZ;
  96.  
  97. ScriptVehicle* pDebugCar = NULL;
  98. ScriptVehicle* pCopCar = NULL;
  99. ScriptVehicle* pSwatVan = NULL;
  100. ScriptVehicle* pFBICar = NULL;
  101. ScriptSpecialActor* pHilary = NULL;
  102. ScriptSpecialActor* pPhil = NULL;
  103. ScriptActor* pCopper1 = NULL;
  104. ScriptActor* pCopper2 = NULL;
  105. ScriptActor* pSwat1 = NULL;
  106. ScriptActor* pSwat2 = NULL;
  107. ScriptActor* pFed1 = NULL;
  108. ScriptActor* pFed2 = NULL;
  109. ScriptActor* pFed3 = NULL;
  110. ScriptActor* pFed4 = NULL;
  111. ScriptMarker* pSafeHouse = NULL;
  112. ScriptMarker* pSwatMarker = NULL;
  113. ScriptMarker* pPhilMarker = NULL;
  114. ScriptMarker* pHilaryMarker = NULL;
  115.  
  116. // Start mission intro
  117. pGame->TextStyled("!TITLE", 4000, 2);
  118. pPlayer->Freeze(true);
  119. pGame->Fade(1000, FADE_OUT);
  120. while (pGame->Fading()) SCRIPT_WAIT(0);
  121.  
  122. // Car for debugging.
  123. pDebugCar = new ScriptVehicle(pMission, CAR_SENTINEL, PlayerCar.x, PlayerCar.y, PlayerCar.z);
  124. pDebugCar->SetZAngle(PlayerCar.a);
  125. pDebugCar->SetColour(57, 57);
  126.  
  127. // Create the cop car.
  128. pCopCar = new ScriptVehicle(pMission, CAR_POLICE, CopsStart.x, CopsStart.y, CopsStart.z);
  129.  
  130. // Get position for swat van relaitve to cop car.
  131. pCopCar->GetRelativeCoordinates(0.0, 12.0, 0.0, &fX, &fY, &fZ);
  132. // Create swat van.
  133. pSwatVan = new ScriptVehicle(pMission, CAR_ENFORCER, fX, fY, fZ);
  134.  
  135. // Get position for fbi car relaitve to swat van.
  136. pSwatVan->GetRelativeCoordinates(0.0, 12.0, 0.0, &fX, &fY, &fZ);
  137. // Create fbi car.
  138. pFBICar = new ScriptVehicle(pMission, CAR_FBIRANCH, fX, fY, fZ);
  139.  
  140. // Create Hilary.
  141. pHilary = new ScriptSpecialActor(pMission, 1, MODEL_IGHLARY);
  142. // Spawn Hilary in the back of the swat van.
  143. pHilary->SpawnInPassengerSeat(pSwatVan->GetVehicle(), 3, 1);
  144. pHilary->SetWander(true);
  145.  
  146. // Create Phil.
  147. pPhil = new ScriptSpecialActor(pMission, 2, MODEL_IGPHIL2);
  148. // Spawn Phil in the back of the swat van.
  149. pPhil->SpawnInPassengerSeat(pSwatVan->GetVehicle(), 3, 2);
  150. pPhil->SetWander(true);
  151.  
  152. // Create and setup copper #1
  153. pCopper1 = new ScriptActor(pMission);
  154. pCopper1->SpawnInDriverSeat(pCopCar->GetVehicle(), 6, IDE_COP);
  155.  
  156. // Create and setup copper #2
  157. pCopper2 = new ScriptActor(pMission);
  158. pCopper2->SpawnInPassengerSeat(pCopCar->GetVehicle(), 6, IDE_COP, 0);
  159.  
  160. // Create and setup swat guy #1
  161. pSwat1 = new ScriptActor(pMission);
  162. pSwat1->SpawnInDriverSeat(pSwatVan->GetVehicle(), 6, IDE_SWAT);
  163.  
  164. // Create and setup swat guy #2
  165. pSwat2 = new ScriptActor(pMission);
  166. pSwat2->SpawnInPassengerSeat(pSwatVan->GetVehicle(), 6, IDE_SWAT, 0);
  167.  
  168. // Create and setup Fed #1
  169. pFed1 = new ScriptActor(pMission);
  170. pFed1->SpawnInDriverSeat(pFBICar->GetVehicle(), 6, IDE_FBI);
  171. pFed1->GiveWeapon(ID_MP5LGN,WEAPON_MP5LGN, 9999);
  172. pFed1->ResetFlags();
  173. pFed1->SetPedStats(16);
  174. pFed1->SetWander(true);
  175.  
  176. // Create and setup Fed #2
  177. pFed2 = new ScriptActor(pMission);
  178. pFed2->SpawnInPassengerSeat(pFBICar->GetVehicle(), 6, IDE_FBI, 0);
  179. pFed2->GiveWeapon(ID_MP5LGN,WEAPON_MP5LGN, 9999);
  180. pFed2->ResetFlags();
  181. pFed2->SetPedStats(16);
  182. pFed2->SetWander(true);
  183.  
  184. // Create and setup Fed #3
  185. pFed3 = new ScriptActor(pMission);
  186. pFed3->SpawnInPassengerSeat(pFBICar->GetVehicle(), 6, IDE_FBI, 1);
  187. pFed3->GiveWeapon(ID_MP5LGN,WEAPON_MP5LGN, 9999);
  188. pFed3->ResetFlags();
  189. pFed3->SetPedStats(16);
  190. pFed3->SetWander(true);
  191.  
  192. // Create and setup Fed #4
  193. pFed4 = new ScriptActor(pMission);
  194. pFed4->SpawnInPassengerSeat(pFBICar->GetVehicle(),6, IDE_FBI, 2);
  195. pFed4->GiveWeapon(ID_MP5LGN,WEAPON_MP5LGN, 9999);
  196. pFed4->ResetFlags();
  197. pFed4->SetPedStats(16);
  198. pFed4->SetWander(true);
  199.  
  200. // Ignore the traffic.
  201. pCopCar->IgnoreTraffic(2);
  202. pSwatVan->IgnoreTraffic(2);
  203. pFBICar->IgnoreTraffic(2);
  204.  
  205. // Only the player can damage them.
  206. pCopCar->SetImmuneToNonplayer(true);
  207. pSwatVan->SetImmuneToNonplayer(true);
  208. pFBICar->SetImmuneToNonplayer(true);
  209.  
  210. // Face them in the right direction.
  211. pCopCar->SetZAngle(CopsStart.a);
  212. pSwatVan->SetZAngle(CopsStart.a);
  213. pFBICar->SetZAngle(CopsStart.a);
  214.  
  215. // Give them a moderate speed.
  216. pCopCar->SetMaxSpeed(fCopsInitalSpeed);
  217. pSwatVan->SetMaxSpeed(fCopsInitalSpeed);
  218. pFBICar->SetMaxSpeed(fCopsInitalSpeed);
  219.  
  220. // NeeeeNooor, NeeeeNooor
  221. pCopCar->SetSiren(true);
  222. pSwatVan->SetSiren(true);
  223. pFBICar->SetSiren(true);
  224.  
  225. // Drive to the police headquaters.
  226. pCopCar->DriveToOnRoad(CopShop.x, CopShop.y, CopShop.z);
  227. pSwatVan->DriveToOnRoad(CopShop.x, CopShop.y, CopShop.z);
  228. pFBICar->DriveToOnRoad(CopShop.x, CopShop.y, CopShop.z);
  229.  
  230. pSwatVan->SetDoorStatus(2);
  231.  
  232. // Be nice! Give the player a gun...
  233. pPlayer->GiveWeapon(pMission,ID_M4, WEAPON_M4, 99);
  234. // ...and some health.
  235. pPlayer->SetHealth(100);
  236.  
  237. // Continue with intro.
  238. pSwatVan->GetRelativeCoordinates(-8.0, 30.0, 3.0, &fX, &fY, &fZ);
  239. pGame->SetCameraPosition(fX, fY, fZ, 0.0f, 0.0f, 0.0f);
  240. pGame->SetCameraOnVehicle(pSwatVan->GetVehicle());
  241. pGame->SetWidescreen(true);
  242. SCRIPT_WAIT(1000);
  243. pGame->Fade(1000, FADE_IN);
  244. while (pGame->Fading()) SCRIPT_WAIT(0);
  245. pGame->TextNow("!CAUGHT", 4000, 1);
  246. SCRIPT_WAIT(4000);
  247. pSwatVan->GetRelativeCoordinates(-8.0, 30.0, 3.0, &fX, &fY, &fZ);
  248. pGame->SetCameraPosition(fX, fY, fZ, 0.0f, 0.0f, 0.0f);
  249. pGame->SetCameraOnVehicle(pSwatVan->GetVehicle());
  250. pGame->TextNow("!TAKEN", 4000, 1);
  251. SCRIPT_WAIT(4000);
  252. pSwatVan->GetRelativeCoordinates(-8.0, 30.0, 3.0, &fX, &fY, &fZ);
  253. pGame->SetCameraPosition(fX, fY, fZ, 0.0f, 0.0f, 0.0f);
  254. pGame->SetCameraOnVehicle(pSwatVan->GetVehicle());
  255. pGame->TextNow("!GETEM", 4000, 1);
  256. SCRIPT_WAIT(4000);
  257. pGame->Fade(1000, FADE_OUT);
  258. while (pGame->Fading()) SCRIPT_WAIT(0);
  259. pPlayer->SetZAngle(MissionStart.a);
  260. pGame->RestoreCameraJumpcut();
  261. pGame->SetCameraBehindPlayer();
  262. pGame->SetWidescreen(false);
  263. pGame->Fade(1000, FADE_IN);
  264. while (pGame->Fading()) SCRIPT_WAIT(0);
  265. pGame->SetCameraPosition(MissionStart.x, MissionStart.y, MissionStart.z + 2.0f, 0.0f, 0.0f, 0.0f);
  266. pGame->PointCamera(PlayerCar.x, PlayerCar.y, PlayerCar.z, 1);
  267. SCRIPT_WAIT(500);
  268. pGame->TextNow("!SENTI", 2000, 1);
  269. SCRIPT_WAIT(2000);
  270. pGame->RestoreCameraJumpcut();
  271. pGame->SetCameraBehindPlayer();
  272. pPlayer->Freeze(false);
  273.  
  274. // Swat van marker.
  275. pSwatMarker = new ScriptMarker();
  276. pSwatMarker->TieToVehicle(pSwatVan->GetVehicle(), 2, 2);
  277. pSwatMarker->ShowOnRadar(3);
  278. pSwatMarker->SetColor(2);
  279.  
  280. bool bDoTheFedsKnow = false;
  281.  
  282. for (;;)
  283. {
  284. SCRIPT_WAIT(100);
  285.  
  286. // If the FBI car isn't burning...
  287. if (pFBICar->GetHealth() > 250)
  288. {
  289. // Fbi car - follow the swat van!
  290. pSwatVan->GetRelativeCoordinates(0.0, 12.0, 0.0, &fX, &fY, &fZ);
  291. pFBICar->DriveToOnRoad(fX, fY, fZ);
  292. }
  293.  
  294. if (WastedBustedCheck()) goto MissionFailed;
  295.  
  296. if (pPhil->Dead())
  297. {
  298. pGame->TextNow("!PHLDED", 5000, 1);
  299. goto MissionFailed;
  300. }
  301.  
  302. if (pHilary->Dead())
  303. {
  304. pGame->TextNow("!HILDED", 5000, 1);
  305. goto MissionFailed;
  306. }
  307.  
  308. if (pSwatVan->GetHealth() < 950) goto TheyAreOut;
  309.  
  310. if (pSwatVan->NearPoint(CopShop.x, CopShop.y, CopShop.z, 12.0f, 12.0f, 2.0f, 0))
  311. {
  312. pGame->TextNow("!GONNER", 5000, 1);
  313. goto MissionFailed;
  314. }
  315.  
  316. if (!bDoTheFedsKnow)
  317. {
  318. if (pSwatVan->GetHealth() < 1000)
  319. {
  320. bDoTheFedsKnow = true;
  321. pGame->TextNow("!THEYNO", 4000, 1);
  322. pPlayer->SetWantedLevel(iRunningWantedLevel);
  323. pCopCar->SetMaxSpeed(fCopsSpeedySpeed);
  324. pSwatVan->SetMaxSpeed(fCopsSpeedySpeed);
  325. pFBICar->SetMaxSpeed(fCopsSpeedySpeed);
  326. pCopCar->SetBehaviour(2);
  327. }
  328. }
  329. }
  330.  
  331. TheyAreOut:
  332. pPlayer->SetWantedLevel(3); // Turn up the heat.
  333.  
  334.  
  335. pSwatVan->SetMaxSpeed(0.0f); // Stop the van.
  336. SCRIPT_WAIT(1000); // Wait a sec.
  337.  
  338. // Get Phil and Hilary out of the van.
  339. pPhil->LeaveVehicle();
  340. pHilary->LeaveVehicle();
  341.  
  342. // Make the swat guys leave the van
  343. pSwat1->LeaveVehicle();
  344. pSwat2->LeaveVehicle();
  345. SCRIPT_WAIT(2000);
  346.  
  347. // Tell them to follow the player.
  348. pPhil->TieToPlayer(pPlayer->GetChar());
  349. pHilary->TieToPlayer(pPlayer->GetChar());
  350.  
  351. // Make the swat guys go after the escaped prisoners.
  352. pSwat1->KillActor(pPhil->GetActor());
  353. pSwat2->KillActor(pHilary->GetActor());
  354.  
  355. // Disable Swat van marker.
  356. SAFE_DELETE(pSwatMarker);
  357.  
  358.  
  359. // Phil's marker
  360. pPhilMarker = new ScriptMarker();
  361. pPhilMarker->TieToActor(pPhil->GetActor(), 4, 2);
  362. pPhilMarker->ShowOnRadar(3);
  363. pPhilMarker->SetColor(2);
  364.  
  365. // Hilary's marker
  366. pHilaryMarker = new ScriptMarker();
  367. pHilaryMarker->TieToActor(pHilary->GetActor(), 4, 2);
  368. pHilaryMarker->ShowOnRadar(3);
  369. pHilaryMarker->SetColor(4);
  370.  
  371. pSafeHouse = new ScriptMarker();
  372. pSafeHouse->SphereAndIcon(SafeHouse.x, SafeHouse.y, SafeHouse.z, 2);
  373.  
  374. pFBICar->SetMaxSpeed(0.0f); // Stop the FBI car.
  375. SCRIPT_WAIT(2000); // Wait a sec.
  376.  
  377. // If the FBI car isn't burning...
  378. if (pFBICar->GetHealth() > 250)
  379. {
  380. pFed2->LeaveVehicle(); // Make the passenger feds get out.
  381. pFed3->LeaveVehicle();
  382. pFed4->LeaveVehicle();
  383.  
  384. SCRIPT_WAIT(1000); // Wait for them to get out.
  385.  
  386. // Sic the passenger feds on the player!
  387. pFed2->KillPlayer(pPlayer->GetChar());
  388. pFed3->KillPlayer(pPlayer->GetChar());
  389. pFed4->KillPlayer(pPlayer->GetChar());
  390.  
  391. pFBICar->SetMaxSpeed(30.0f); // Give the FBi car some speed again.
  392. pFBICar->SetBehaviour(2); // Kill the player!
  393. }
  394.  
  395. pGame->TextNow("!GOGOGO", 4000, 1);
  396.  
  397. bool bBringMsg = false;
  398.  
  399. for (;;)
  400. {
  401. SCRIPT_WAIT(100);
  402.  
  403. if (WastedBustedCheck()) goto MissionFailed;
  404.  
  405. if (pPhil->Dead())
  406. {
  407. pGame->TextNow("!PHLDED", 5000, 1);
  408. goto MissionFailed;
  409. }
  410.  
  411. if (pHilary->Dead())
  412. {
  413. pGame->TextNow("!HILDED", 5000, 1);
  414. goto MissionFailed;
  415. }
  416.  
  417. if (pPlayer->NearPoint(SafeHouse.x, SafeHouse.y, SafeHouse.z, 6.0f, 6.0f, 2.0f, 0))
  418. {
  419. if ((pPhil->NearPoint(SafeHouse.x, SafeHouse.y, SafeHouse.z, 6.0f, 6.0f, 2.0f, 0)) &&
  420. (pHilary->NearPoint(SafeHouse.x, SafeHouse.y, SafeHouse.z, 6.0f, 6.0f, 2.0f, 0)))
  421. {
  422. pPlayer->ClearWantedLevel();
  423. pGame->TextStyledOneNumber("M_PASS", 25000, 5000, 1);
  424. pGame->PlayMusic(1);
  425. pPlayer->GiveMoney(25000);
  426. goto MissionCleanup;
  427. } else {
  428. if (!bBringMsg)
  429. {
  430. bBringMsg = true;
  431. pGame->TextNow("!BRING", 5000, 1);
  432. }
  433. }
  434. }
  435. }
  436.  
  437. MissionFailed:
  438. pGame->TextStyled("M_FAIL", 5000, 1);
  439.  
  440. MissionCleanup:
  441. SAFE_DELETE(pPhilMarker);
  442. SAFE_DELETE(pHilaryMarker);
  443. SAFE_DELETE(pSafeHouse);
  444.  
  445. SAFE_DELETE(pDebugCar);
  446.  
  447. SAFE_DELETE(pCopper1);
  448. SAFE_DELETE(pCopper1);
  449.  
  450. SAFE_DELETE(pSwat1);
  451. SAFE_DELETE(pSwat2);
  452.  
  453. SAFE_DELETE(pFed1);
  454. SAFE_DELETE(pFed2);
  455. SAFE_DELETE(pFed3);
  456. SAFE_DELETE(pFed4);
  457.  
  458. SAFE_DELETE(pCopCar);
  459. SAFE_DELETE(pSwatVan);
  460. SAFE_DELETE(pFBICar);
  461.  
  462. SAFE_DELETE(pHilary);
  463. SAFE_DELETE(pPhil);
  464.  
  465. bMissionEnded = true;
  466.  
  467. TERMINATE_THREAD();
  468. }
  469.  
  470.  
  471. //--------------------------------------------------------------------------------------------
  472. // func:
  473. // ThreadSorup()
  474. void Mission_Sorup(SCRIPT_MISSION* pMission)
  475. {
  476. INITIALISE_THREAD();
  477.  
  478. const VCPosition_t CopShop = {350.0f, -527.0f, 10.0f, 0.0f};
  479. const VCPosition_t SafeHouse = {-845.0f, -902.0f, 10.0f, 0.0f};
  480.  
  481. const VCPosition_t MeStart = {-680.0f, 634.0f, 11.0f, 180.0f};
  482. const VCPosition_t WeaponPickUp = {-679.0f, 554.0f, 11.0f, 140.0f};
  483.  
  484. float fX, fY, fZ;
  485.  
  486. ScriptMarker* pMyMarker = NULL;
  487. ScriptActor* pFed1 = NULL;
  488. ScriptPickUp* pMyPickUp=NULL;
  489. ScriptVehicle* pFBICar=NULL;
  490. ScriptVehicle* pMyCar=NULL;
  491.  
  492.  
  493. // Start mission intro
  494. pGame->TextStyled("!MY_TLE", 4000, 2);
  495. pPlayer->Freeze(true);
  496. pGame->Fade(1000, FADE_OUT);
  497. while (pGame->Fading()) SCRIPT_WAIT(0);
  498.  
  499. pMyCar = new ScriptVehicle(pMission,CAR_BLOODRA,MeStart.x,MeStart.y,MeStart.z);
  500. pMyCar->GetRelativeCoordinates(0.0f,12.0f,0.0f,&fX,&fY,&fZ);
  501. pFBICar = new ScriptVehicle(pMission, CAR_FBIRANCH, fX, fY, fZ);
  502.  
  503. pFed1 = new ScriptActor(pMission);
  504. pFed1->Spawn(6,IDE_FBI,WeaponPickUp.x,WeaponPickUp.y,WeaponPickUp.z);
  505. pFed1->GiveWeapon(ID_M4,WEAPON_M4, 9999);
  506. pFed1->ResetFlags();
  507. pFed1->SetPedStats(16);
  508. pFed1->SetWander(true);
  509. pFed1->SpawnInDriverSeat(pFBICar->GetVehicle(),6,IDE_FBI);
  510.  
  511. // Be nice! Give the player a gun...
  512. pPlayer->GiveWeapon(pMission,ID_M4, WEAPON_M4, 99);
  513. // ...and some health.
  514. pPlayer->SetHealth(100);
  515.  
  516.  
  517. pMyPickUp = new ScriptPickUp(pMission);
  518. pMyPickUp->CreatePickUp(ID_PETROLPUMP,3,WeaponPickUp.x,WeaponPickUp.y,WeaponPickUp.z);
  519.  
  520.  
  521.  
  522.  
  523. // Continue with intro.
  524. pGame->SetCameraPosition(MissionStart_sorup.x, MissionStart_sorup.y, MissionStart_sorup.z + 10.0f, 0.0f, 0.0f, 0.0f);
  525. pGame->SetCameraBehindPlayer();
  526. pGame->SetWidescreen(true);
  527. SCRIPT_WAIT(1000);
  528. pGame->Fade(1000, FADE_IN);
  529. while (pGame->Fading()) SCRIPT_WAIT(0);
  530. pGame->TextNow("!CAUGHT", 4000, 1);
  531. SCRIPT_WAIT(4000);
  532. pGame->TextNow("!GETEM", 4000, 1);
  533. SCRIPT_WAIT(4000);
  534. pGame->Fade(1000, FADE_OUT);
  535. while (pGame->Fading()) SCRIPT_WAIT(0);
  536. pPlayer->SetZAngle(MissionStart_sorup.a);
  537. pGame->RestoreCameraJumpcut();
  538. pGame->SetCameraBehindPlayer();
  539. pGame->SetWidescreen(false);
  540. pGame->Fade(1000, FADE_IN);
  541. while (pGame->Fading()) SCRIPT_WAIT(0);
  542. pGame->SetCameraPosition(MissionStart_sorup.x, MissionStart_sorup.y, MissionStart_sorup.z + 2.0f, 0.0f, 0.0f, 0.0f);
  543. pGame->PointCamera(WeaponPickUp.x, WeaponPickUp.y, WeaponPickUp.z, 1);
  544. SCRIPT_WAIT(500);
  545. pGame->TextNow("!SENTI", 2000, 1);
  546. SCRIPT_WAIT(2000);
  547. pGame->RestoreCameraJumpcut();
  548. pGame->SetCameraBehindPlayer();
  549. pPlayer->Freeze(false);
  550.  
  551.  
  552. // Mission passed Marker
  553. pMyMarker = new ScriptMarker();
  554. pMyMarker->SphereAndIcon(SafeHouse.x,SafeHouse.y,SafeHouse.z,39);
  555.  
  556.  
  557. for (;;)
  558. {
  559. SCRIPT_WAIT(100);
  560.  
  561. if (WastedBustedCheck()) goto MissionFailed;
  562.  
  563. // If the FBI car isn't burning...
  564. if (pFBICar->GetHealth() > 250)
  565. {
  566. // Fbi car - follow the swat van!
  567. pMyCar->GetRelativeCoordinates(0.0, 12.0, 0.0, &fX, &fY, &fZ);
  568. pFBICar->DriveToOnRoad(fX, fY, fZ);
  569. }
  570.  
  571. if (pPlayer->NearPoint(SafeHouse.x, SafeHouse.y, SafeHouse.z, 6.0f, 6.0f, 2.0f, 0))
  572. {
  573.  
  574. goto MissionPassed;
  575. }
  576. }
  577.  
  578.  
  579.  
  580. //Execution does not continue to here until a jump or break statement is specified in the FOR loop
  581. MissionPassed:
  582. pPlayer->ClearWantedLevel();
  583. pGame->TextStyledOneNumber("M_PASS", 25000, 5000, 1);
  584. pGame->PlayMusic(1);
  585. pPlayer->GiveMoney(25000);
  586. goto MissionCleanup;
  587.  
  588. MissionFailed:
  589. pGame->TextStyled("M_FAIL", 5000, 1);
  590.  
  591. MissionCleanup:
  592. SAFE_DELETE(pMyMarker);
  593. SAFE_DELETE(pFed1);
  594. SAFE_DELETE(pMyPickUp);
  595. SAFE_DELETE(pFBICar);
  596. SAFE_DELETE(pMyCar);
  597. bMissionEnded = true;
  598.  
  599. TERMINATE_THREAD();
  600. }
  601.  
  602. // Start mission
  603.  
  604. //--------------------------------------------------------------------------------------------
  605. // func:
  606. // MainScript()
  607. //
  608. // desc:
  609. // Thread function for the main script execution.
  610. //
  611. // params:
  612. // pMission
  613. // Pointer to the SCRIPT_MISSION structure for the main thread.
  614. //
  615. void MainScript(SCRIPT_MISSION* pMission)
  616. {
  617. WaitForSingleObject(pMission->hExecute, INFINITE);
  618.  
  619. ScriptVehicle* pBike = new ScriptVehicle(pMission, BIKE_PCJ600, BikeShop.x, BikeShop.y, BikeShop.z, false);
  620. pBike->SetZAngle(BikeShop.a);
  621. pBike->SetColour(57, 57);
  622.  
  623. pGame->TextStyled("!WELC_0", 4000, 2);
  624. pPlayer->Freeze(true);
  625. pGame->Fade(0, FADE_OUT);
  626. while (pGame->Fading()) SCRIPT_WAIT(0);
  627. pGame->SetWidescreen(true);
  628. pGame->Fade(1000, FADE_IN);
  629. pGame->TextNow("!WELC_1", 3000, 1);
  630. SCRIPT_WAIT(3100);
  631. pGame->TextNow("!WELC_2", 3000, 1);
  632. SCRIPT_WAIT(3100);
  633. pGame->Fade(1000, FADE_OUT);
  634. while (pGame->Fading()) SCRIPT_WAIT(0);
  635. pGame->SetWidescreen(false);
  636. pGame->Fade(1000, FADE_IN);
  637. while (pGame->Fading()) SCRIPT_WAIT(0);
  638. pPlayer->Freeze(false);
  639.  
  640.  
  641. ScriptMarker* pMissionMarker;
  642. ScriptMarker* pMissionMarker_sorup;
  643. bool OnMission = true; // Init to true to create the marker on first run through the loop.
  644. for (;;) //Main Script Loop
  645. {
  646. SCRIPT_WAIT(100);
  647.  
  648. if (!OnMission)
  649. {
  650. if (pPlayer->NearPointOnFoot(MissionStart.x, MissionStart.y, MissionStart.z, 1.5f, 2.0f, 2.0f, 0))
  651. {
  652. OnMission = true;
  653. ONMISSIONCLEANUP();
  654. AddMission(Mission_TheSample);
  655. }
  656. if (pPlayer->NearPointOnFoot(MissionStart_sorup.x,MissionStart_sorup.y,MissionStart_sorup.z,1.5f,2.0f,2.0f,0))
  657. {
  658. OnMission=true;
  659. ONMISSIONCLEANUP();
  660. AddMission(Mission_Sorup);
  661. }
  662. }
  663. else
  664. {
  665. if (bMissionEnded)
  666. {
  667. bMissionEnded = false;
  668. OnMission = false;
  669. pMissionMarker_sorup= new ScriptMarker();
  670. pMissionMarker_sorup->SphereAndIcon(MissionStart_sorup.x,MissionStart_sorup.y,MissionStart_sorup.z,2);
  671. pMissionMarker = new ScriptMarker();
  672. pMissionMarker->SphereAndIcon(MissionStart.x, MissionStart.y, MissionStart.z, 2);
  673. }
  674. }
  675. }
  676.  
  677. //Execution does not continue to here until a jump or break statement is specified in the FOR loop
  678. OnMissionCleanUp: SAFE_DELETE(pMissionMarker_sorup);
  679. SAFE_DELETE(pMissionMarker);
  680. RESUME();
  681. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement