Advertisement
Guest User

ScriptClasses.cpp

a guest
Jan 21st, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.10 KB | None | 0 0
  1. /*
  2. file:
  3. ScriptClasses.cpp
  4. desc:
  5. This file contains the class functions for various wrapped script
  6. commands. They have been set into basic groups - Script, Game,
  7. Player, (Special)Actor, Vehicle, and Marker.
  8. */
  9.  
  10. // Includes
  11. #include "ScriptClasses.h"
  12.  
  13.  
  14. // Externals
  15. extern ScriptScript* pScript;
  16. extern ScriptGame* pGame;
  17. extern ScriptPlayer* pPlayer;
  18.  
  19.  
  20. // Defines
  21. #define SCRIPT_WAIT(x) \
  22. { \
  23. pScript->Wait(x); \
  24. SetEvent(m_pMission->hContinue); \
  25. WaitForSingleObject(m_pMission->hExecute, INFINITE); \
  26. }
  27.  
  28.  
  29. // Functions
  30.  
  31. //--------------------------------------------------------------------------------
  32. // ScriptScript class functions.
  33. //
  34. ScriptScript::ScriptScript()
  35. {
  36.  
  37. }
  38.  
  39. ScriptScript::~ScriptScript()
  40. {
  41.  
  42. }
  43.  
  44. bool ScriptScript::ModelAvailable(DWORD dwModel)
  45. {
  46. return ScriptCommand(&is_model_available, dwModel)?true:false;
  47. }
  48.  
  49. void ScriptScript::CreateThread(int StartIP)
  50. {
  51. ScriptCommand(&create_thread, StartIP);
  52. }
  53.  
  54. void ScriptScript::TerminateThread()
  55. {
  56. ScriptCommand(&end_thread);
  57. }
  58.  
  59. void ScriptScript::NameThread(char ThreadName[8])
  60. {
  61. ScriptCommand(&name_thread, ThreadName);
  62. }
  63.  
  64. void ScriptScript::Wait(int msTime)
  65. {
  66. ScriptCommand(&wait, msTime);
  67. }
  68.  
  69. //--------------------------------------------------------------------------------
  70. // ScriptGame class functions.
  71. //
  72. ScriptGame::ScriptGame()
  73. {
  74.  
  75. }
  76.  
  77. ScriptGame::~ScriptGame()
  78. {
  79.  
  80. }
  81.  
  82. bool ScriptGame::Fading()
  83. {
  84. return ScriptCommand(&is_fading)?true:false;
  85. }
  86.  
  87. void ScriptGame::Fade(int Time, int InOut)
  88. {
  89. ScriptCommand(&set_fade_color, 0, 0, 0);
  90. ScriptCommand(&fade, Time, InOut);
  91. }
  92.  
  93. void ScriptGame::SetMaxWantedLevel(int MaxLevel)
  94. {
  95. ScriptCommand(&set_max_wanted_level, MaxLevel);
  96. }
  97.  
  98. void ScriptGame::SetWastedBustedCheck(bool Check)
  99. {
  100. ScriptCommand(&set_wasted_busted_check, Check);
  101. }
  102.  
  103. void ScriptGame::SetCurrentTime(int Hours, int Minutes)
  104. {
  105. ScriptCommand(&set_current_time, Hours, Minutes);
  106. }
  107.  
  108. void ScriptGame::RefreshScreen(float fX, float fY)
  109. {
  110. ScriptCommand(&refresh_screen, fX, fY);
  111. }
  112.  
  113. void ScriptGame::SetCamera(float fX, float fY, float fZ)
  114. {
  115. ScriptCommand(&set_camera, fX, fY, fZ);
  116. }
  117.  
  118. void ScriptGame::SetWeather(int Weather)
  119. {
  120. ScriptCommand(&set_weather, Weather);
  121. }
  122.  
  123. void ScriptGame::SelectInterior(int Interior)
  124. {
  125. ScriptCommand(&select_interior, Interior);
  126. }
  127.  
  128. void ScriptGame::PlayMusic(int iMusic)
  129. {
  130. ScriptCommand(&play_music, iMusic);
  131. }
  132.  
  133. void ScriptGame::TextStyledOneNumber(char Text[8], int iNumber, int iTime, int iStyle)
  134. {
  135. ScriptCommand(&text_1number_styled, Text, iNumber, iTime, iStyle);
  136. }
  137.  
  138. void ScriptGame::TextStyled(char Text[8], int iTime, int iStyle)
  139. {
  140. ScriptCommand(&text_styled, Text, iTime, iStyle);
  141. }
  142.  
  143. void ScriptGame::TextNow(char Text[8], int iTime, int iStyle)
  144. {
  145. ScriptCommand(&text_now, Text, iTime, iStyle);
  146. }
  147.  
  148. void ScriptGame::SetWidescreen(bool bWidescreen)
  149. {
  150. ScriptCommand(&toggle_widescreen, bWidescreen);
  151. }
  152.  
  153. void ScriptGame::SetCameraBehindPlayer()
  154. {
  155. ScriptCommand(&set_camera_behind_player);
  156. }
  157.  
  158. void ScriptGame::SetCameraOnVehicle(DWORD* pdwVehicle)
  159. {
  160. ScriptCommand(&camera_on_vehicle, pdwVehicle, 15, 2); // What are 15 + 2 for?
  161. }
  162.  
  163. void ScriptGame::PointCamera(float fX, float fY, float fZ, int iType)
  164. {
  165. ScriptCommand(&point_camera, fX, fY, fZ, iType);
  166. }
  167.  
  168. void ScriptGame::RestoreCameraJumpcut()
  169. {
  170. ScriptCommand(&restore_camera_jumpcut);
  171. }
  172.  
  173. void ScriptGame::SetCameraPosition(float fX1, float fY1, float fZ1, float fX2, float fY2, float fZ2)
  174. {
  175. ScriptCommand(&set_camera_position, fX1, fY1, fZ1, fX2, fY2, fZ2);
  176. }
  177.  
  178. void ScriptGame::SetWastedSpawnPosition(float fX, float fY, float fZ, float fZAngle)
  179. {
  180. ScriptCommand(&restart_if_wasted_at, fX, fY, fZ, fZAngle);
  181. }
  182.  
  183. void ScriptGame::SetBustedSpawnPosition(float fX, float fY, float fZ, float fZAngle)
  184. {
  185. ScriptCommand(&restart_if_busted_at, fX, fY, fZ, fZAngle);
  186. }
  187.  
  188. //--------------------------------------------------------------------------------
  189. // ScriptPlayer class functions.
  190. //
  191. ScriptPlayer::ScriptPlayer(float fX, float fY, float fZ)
  192. {
  193. ScriptCommand(&create_player, 0, fX, fY, fZ, &m_dwChar);
  194. ScriptCommand(&create_actor_from_player, &m_dwChar, &m_dwActor);
  195. }
  196.  
  197. ScriptPlayer::~ScriptPlayer()
  198. {
  199.  
  200. }
  201.  
  202. DWORD* ScriptPlayer::GetChar()
  203. {
  204. return &m_dwChar;
  205. }
  206.  
  207. DWORD* ScriptPlayer::GetActor()
  208. {
  209. return &m_dwActor;
  210. }
  211.  
  212. bool ScriptPlayer::NearPoint(float fX, float fY, float fZ, float fRX, float fRY, float fRZ, bool bSphere)
  213. {
  214. return ScriptCommand(&is_player_near_point_3d, &m_dwChar, fX, fY, fZ, fRX, fRY, fRZ, bSphere)?true:false;
  215. }
  216.  
  217. bool ScriptPlayer::NearPointOnFoot(float fX, float fY, float fZ, float fRX, float fRY, float fRZ, bool bSphere)
  218. {
  219. return ScriptCommand(&player_near_point_on_foot, &m_dwChar, fX, fY, fZ, fRX, fRY, fRZ, bSphere)?true:false;
  220. }
  221.  
  222. void ScriptPlayer::SetSkin(char Model[8])
  223. {
  224. ScriptCommand(&set_actor_skin, &m_dwActor, Model);
  225. ScriptCommand(&load_requested_models);
  226. ScriptCommand(&refresh_actor_skin, &m_dwActor);
  227. }
  228.  
  229. void ScriptPlayer::Freeze(bool bFrozen)
  230. {
  231. ScriptCommand(&freeze_player, &m_dwChar, bFrozen?0:1);
  232. }
  233.  
  234. void ScriptPlayer::ClearWantedLevel()
  235. {
  236. ScriptCommand(&clear_player_wanted_level, &m_dwChar);
  237. }
  238.  
  239. void ScriptPlayer::SetWantedLevel(int iLevel)
  240. {
  241. ScriptCommand(&set_player_wanted_level, &m_dwChar, iLevel);
  242. }
  243.  
  244. void ScriptPlayer::SetHealth(int iHealth)
  245. {
  246. ScriptCommand(&set_player_health, &m_dwChar, iHealth);
  247. }
  248.  
  249. void ScriptPlayer::SetZAngle(float fAngle)
  250. {
  251. ScriptCommand(&set_player_z_angle, &m_dwChar, fAngle);
  252. }
  253.  
  254. void ScriptPlayer::GiveWeapon(SCRIPT_MISSION* m_pMission,DWORD dwIDWeapon, DWORD dwWeapon, DWORD dwAmmo)
  255. {
  256. if (!pScript->ModelAvailable(dwIDWeapon))
  257. {
  258.  
  259. ScriptCommand(&request_model, dwIDWeapon);
  260. ScriptCommand(&load_requested_models);
  261. while (!pScript->ModelAvailable(dwIDWeapon)) SCRIPT_WAIT(0);
  262. }
  263. ScriptCommand(&give_player_weapon, &m_dwChar, dwWeapon, dwAmmo);
  264. }
  265.  
  266. void ScriptPlayer::GiveMoney(int iMoney)
  267. {
  268. ScriptCommand(&add_to_player_money, &m_dwChar, iMoney);
  269. }
  270.  
  271.  
  272.  
  273. //--------------------------------------------------------------------------------
  274. // ScriptActor class functions.
  275. //
  276. ScriptActor::ScriptActor(SCRIPT_MISSION* pMission, bool bKeepOnDestroy)
  277. {
  278. m_pMission = pMission;
  279. m_bKeepOnDestroy = bKeepOnDestroy;
  280. m_bSpawned = false;
  281. }
  282.  
  283. ScriptActor::~ScriptActor()
  284. {
  285. if (m_bSpawned)
  286. {
  287. ScriptCommand(m_bKeepOnDestroy?&remove_references_to_actor:&destroy_actor_fading, &m_dwActor);
  288. }
  289. }
  290.  
  291. DWORD* ScriptActor::GetActor()
  292. {
  293. return &m_dwActor;
  294. }
  295.  
  296. bool ScriptActor::Dead()
  297. {
  298. return ScriptCommand(&is_actor_dead, &m_dwActor)?true:false;
  299. }
  300.  
  301. bool ScriptActor::NearPoint(float fX, float fY, float fZ, float fRX, float fRY, float fRZ, bool bSphere)
  302. {
  303. return ScriptCommand(&is_actor_near_point_3d, &m_dwActor, fX, fY, fZ, fRX, fRY, fRZ, bSphere)?true:false;
  304. }
  305.  
  306. void ScriptActor::Spawn(int iPedType, DWORD dwModel, float fX, float fY, float fZ)
  307. {
  308. ScriptCommand(&request_model, dwModel);
  309. ScriptCommand(&load_requested_models);
  310. while (!pScript->ModelAvailable(dwModel)) SCRIPT_WAIT(0);
  311. ScriptCommand(&create_actor, iPedType, dwModel, fX, fY, fZ, &m_dwActor);
  312.  
  313. m_bSpawned = true;
  314. }
  315.  
  316. void ScriptActor::SpawnInPassengerSeat(DWORD* pdwVehicle, int iPedType, DWORD dwModel, int iSeat)
  317. {
  318. ScriptCommand(&request_model, dwModel);
  319. ScriptCommand(&load_requested_models);
  320. while (!pScript->ModelAvailable(dwModel)) SCRIPT_WAIT(0);
  321. ScriptCommand(&create_actor_in_passenger, pdwVehicle, iPedType, dwModel, iSeat, &m_dwActor);
  322.  
  323. m_bSpawned = true;
  324. }
  325.  
  326. void ScriptActor::SpawnInDriverSeat(DWORD* pdwVehicle, int iPedType, DWORD dwModel)
  327. {
  328. ScriptCommand(&request_model, dwModel);
  329. ScriptCommand(&load_requested_models);
  330. while (!pScript->ModelAvailable(dwModel)) SCRIPT_WAIT(0);
  331. ScriptCommand(&create_actor_in_driverseat, pdwVehicle, iPedType, dwModel, &m_dwActor);
  332.  
  333. m_bSpawned = true;
  334. }
  335.  
  336. void ScriptActor::GiveWeapon(DWORD dwIDWeapon, DWORD dwWeapon, DWORD dwAmmo)
  337. {
  338. if (!pScript->ModelAvailable(dwIDWeapon))
  339. {
  340. ScriptCommand(&request_model, dwIDWeapon);
  341. ScriptCommand(&load_requested_models);
  342. while (!pScript->ModelAvailable(dwIDWeapon)) SCRIPT_WAIT(0);
  343. }
  344. ScriptCommand(&give_actor_weapon, &m_dwActor, dwWeapon, dwAmmo);
  345. }
  346.  
  347. void ScriptActor::ResetFlags()
  348. {
  349. ScriptCommand(&reset_actor_flags, &m_dwActor);
  350. }
  351.  
  352. void ScriptActor::SetPedStats(DWORD dwPedStats)
  353. {
  354. ScriptCommand(&set_actor_ped_stats, &m_dwActor, dwPedStats);
  355. }
  356.  
  357. void ScriptActor::SetWander(bool bWander)
  358. {
  359. ScriptCommand(&toggle_actor_wander, &m_dwActor, bWander);
  360. }
  361.  
  362. void ScriptActor::TieToPlayer(DWORD* pdwPlayer)
  363. {
  364. ScriptCommand(&tie_actor_to_player, &m_dwActor, pdwPlayer);
  365. }
  366.  
  367. void ScriptActor::LeaveVehicle()
  368. {
  369. ScriptCommand(&make_actor_leave_vehicle, &m_dwActor);
  370. }
  371.  
  372. void ScriptActor::KillActor(DWORD* pdwActor)
  373. {
  374. ScriptCommand(&set_actor_to_kill_actor, &m_dwActor, pdwActor);
  375. }
  376.  
  377. void ScriptActor::KillPlayer(DWORD* pdwPlayer)
  378. {
  379. ScriptCommand(&set_actor_to_kill_player, &m_dwActor, pdwPlayer);
  380. }
  381.  
  382.  
  383.  
  384. //--------------------------------------------------------------------------------
  385. // ScriptSpecialActor class functions.
  386. //
  387. ScriptSpecialActor::ScriptSpecialActor(SCRIPT_MISSION* pMission, int iSlot, char Model[8])
  388. {
  389. m_pMission = pMission;
  390. m_iSlot = iSlot;
  391. ScriptCommand(&load_special_actor, iSlot, Model);
  392. ScriptCommand(&load_requested_models);
  393. m_pActor = new ScriptActor(m_pMission, false);
  394. }
  395.  
  396. ScriptSpecialActor::~ScriptSpecialActor()
  397. {
  398. delete m_pActor;
  399. }
  400.  
  401. DWORD* ScriptSpecialActor::GetActor()
  402. {
  403. return m_pActor->GetActor();
  404. }
  405.  
  406. bool ScriptSpecialActor::Dead()
  407. {
  408. return m_pActor->Dead();
  409. }
  410.  
  411. bool ScriptSpecialActor::NearPoint(float fX, float fY, float fZ, float fRX, float fRY, float fRZ, bool bSphere)
  412. {
  413. return m_pActor->NearPoint(fX, fY, fZ, fRX, fRY, fRZ, bSphere);
  414. }
  415.  
  416. void ScriptSpecialActor::Spawn(int iPedType, float fX, float fY, float fZ)
  417. {
  418. m_pActor->Spawn(iPedType, m_iSlot+108, fX, fY, fZ);
  419. }
  420.  
  421. void ScriptSpecialActor::SpawnInPassengerSeat(DWORD* pdwVehicle, int iPedType, int iSeat)
  422. {
  423. m_pActor->SpawnInPassengerSeat(pdwVehicle, iPedType, m_iSlot+108, iSeat);
  424. }
  425.  
  426. void ScriptSpecialActor::SpawnInDriverSeat(DWORD* pdwVehicle, int iPedType)
  427. {
  428. m_pActor->SpawnInDriverSeat(pdwVehicle, iPedType, m_iSlot+108);
  429. }
  430.  
  431. void ScriptSpecialActor::TieToPlayer(DWORD* pdwPlayer)
  432. {
  433. m_pActor->TieToPlayer(pdwPlayer);
  434. }
  435.  
  436. void ScriptSpecialActor::LeaveVehicle()
  437. {
  438. m_pActor->LeaveVehicle();
  439. }
  440.  
  441. void ScriptSpecialActor::SetWander(bool bWander)
  442. {
  443. m_pActor->SetWander(bWander);
  444. }
  445.  
  446.  
  447.  
  448. //--------------------------------------------------------------------------------
  449. // ScriptVehicle class functions.
  450. //
  451. ScriptVehicle::ScriptVehicle(SCRIPT_MISSION* pMission, DWORD dwModel, float fX, float fY, float fZ, bool bKeepOnDestroy)
  452. {
  453. m_pMission = pMission;
  454. m_bKeepOnDestroy = bKeepOnDestroy;
  455.  
  456. ScriptCommand(&request_model, dwModel);
  457. ScriptCommand(&load_requested_models);
  458. while (!pScript->ModelAvailable(dwModel)) SCRIPT_WAIT(0);
  459. ScriptCommand(&create_car, dwModel, fX, fY, fZ, &m_dwVehicle);
  460. }
  461.  
  462. ScriptVehicle::~ScriptVehicle()
  463. {
  464. ScriptCommand(m_bKeepOnDestroy?&remove_references_to_car:&destroy_car, &m_dwVehicle);
  465. }
  466.  
  467. DWORD* ScriptVehicle::GetVehicle()
  468. {
  469. return &m_dwVehicle;
  470. }
  471.  
  472. int ScriptVehicle::GetHealth()
  473. {
  474. int iHealth;
  475. ScriptCommand(&get_car_health, &m_dwVehicle, &iHealth);
  476. return iHealth;
  477. }
  478.  
  479. bool ScriptVehicle::NearPoint(float fX, float fY, float fZ, float fRX, float fRY, float fRZ, bool bSphere)
  480. {
  481. return ScriptCommand(&is_car_near_point_3d, &m_dwVehicle, fX, fY, fZ, fRX, fRY, fRZ, bSphere)?true:false;
  482. }
  483.  
  484. void ScriptVehicle::SetColour(int iPrimary, int iSecondary)
  485. {
  486. ScriptCommand(&set_car_color, &m_dwVehicle, iPrimary, iSecondary);
  487. }
  488.  
  489. void ScriptVehicle::SetZAngle(float fAngle)
  490. {
  491. ScriptCommand(&set_car_z_angle, &m_dwVehicle, fAngle);
  492. }
  493.  
  494. void ScriptVehicle::GetRelativeCoordinates(float fX, float fY, float fZ, float* pfX, float* pfY, float* pfZ)
  495. {
  496. ScriptCommand(&car_relative_coordinates, &m_dwVehicle, fX, fY, fZ, pfX, pfY, pfZ);
  497. }
  498.  
  499. void ScriptVehicle::DriveToOnRoad(float fX, float fY, float fZ)
  500. {
  501. ScriptCommand(&drive_car_to_point1, &m_dwVehicle, fX, fY, fZ);
  502. }
  503.  
  504. void ScriptVehicle::SetMaxSpeed(float fSpeed)
  505. {
  506. ScriptCommand(&set_car_max_speed, &m_dwVehicle, fSpeed);
  507. }
  508.  
  509. void ScriptVehicle::IgnoreTraffic(int iFlag)
  510. {
  511. ScriptCommand(&car_ignore_traffic, &m_dwVehicle, iFlag);
  512. }
  513.  
  514. void ScriptVehicle::SetImmuneToNonplayer(bool bImmune)
  515. {
  516. ScriptCommand(&set_car_immune_to_nonplayer, &m_dwVehicle, bImmune);
  517. }
  518.  
  519. void ScriptVehicle::SetDoorStatus(int iStatus)
  520. {
  521. ScriptCommand(&set_car_door_status, &m_dwVehicle, iStatus);
  522. }
  523.  
  524. void ScriptVehicle::SetSiren(bool bSiren)
  525. {
  526. ScriptCommand(&toggle_car_siren, &m_dwVehicle, bSiren);
  527. }
  528.  
  529. void ScriptVehicle::SetBehaviour(int iBehaviour)
  530. {
  531. ScriptCommand(&set_car_driver_behaviour, &m_dwVehicle, iBehaviour);
  532. }
  533.  
  534. //--------------------------------------------------------------------------------
  535. // ScriptMarker class functions.
  536. //
  537. ScriptMarker::ScriptMarker()
  538. {
  539. m_dwMarker = 0;
  540. }
  541.  
  542. ScriptMarker::~ScriptMarker()
  543. {
  544. if (m_bCreated)
  545. {
  546. ScriptCommand(&disable_marker, &m_dwMarker);
  547. }
  548. }
  549.  
  550. void ScriptMarker::TieToActor(DWORD* pdwActor, int iSize, int iType)
  551. {
  552. ScriptCommand(&tie_marker_to_actor, pdwActor, iSize, iType, &m_dwMarker);
  553. }
  554.  
  555. void ScriptMarker::TieToVehicle(DWORD* pdwVehicle, int iSize, int iType)
  556. {
  557. ScriptCommand(&tie_marker_to_car, pdwVehicle, iSize, iType, &m_dwMarker);
  558. }
  559.  
  560. void ScriptMarker::SphereAndIcon(float x, float y, float z, int iIcon)
  561. {
  562. ScriptCommand(&create_icon_marker_sphere, x, y, z, iIcon, &m_dwMarker);
  563. }
  564.  
  565. void ScriptMarker::ShowOnRadar(int iSize)
  566. {
  567. if (m_bCreated)
  568. {
  569. ScriptCommand(&show_on_radar, &m_dwMarker, iSize);
  570. }
  571. }
  572.  
  573. void ScriptMarker::SetColor(int iColour)
  574. {
  575. if (m_bCreated)
  576. {
  577. ScriptCommand(&set_marker_color, &m_dwMarker, iColour);
  578. }
  579. }
  580.  
  581.  
  582. //--------------------------------------------------------------------------------
  583. // ScriptPickUp class functions.
  584. //
  585. ScriptPickUp::ScriptPickUp(SCRIPT_MISSION* pMission)
  586. {
  587. m_pMission = pMission;
  588. m_dwPickUp= 0;
  589. m_bKeepForeever=false;
  590. }
  591.  
  592. ScriptPickUp::~ScriptPickUp()
  593. {
  594. if (!m_bKeepForeever)
  595. {
  596. ScriptCommand(&destroy_pickup,&m_dwPickUp);
  597. }
  598. }
  599.  
  600. void ScriptPickUp::CreatePickUp(DWORD dwIDModel, int iType, float fx, float fy, float fz)
  601. {
  602. if (!pScript->ModelAvailable(dwIDModel))
  603. {
  604. ScriptCommand(&request_model, dwIDModel);
  605. ScriptCommand(&load_requested_models);
  606. while (!pScript->ModelAvailable(dwIDModel)) SCRIPT_WAIT(0);
  607. }
  608. ScriptCommand(&create_pickup,dwIDModel,iType,fx,fy,fz,&m_dwPickUp);
  609. }
  610.  
  611. void ScriptPickUp::CreateWeaponPickUp(DWORD dwIDWeapon, DWORD dwWeapon, int iType,DWORD dwAmmo, float fx, float fy, float fz)
  612. {
  613. if (!pScript->ModelAvailable(dwIDWeapon))
  614. {
  615. ScriptCommand(&request_model, dwIDWeapon);
  616. ScriptCommand(&load_requested_models);
  617. while (!pScript->ModelAvailable(dwIDWeapon)) SCRIPT_WAIT(0);
  618. }
  619. ScriptCommand(&create_weapon_pickup,dwWeapon,iType,dwAmmo,fx,fy,fz,&m_dwPickUp);
  620. }
  621.  
  622. bool ScriptPickUp::IsPickedUp()
  623. {
  624. return ScriptCommand(&is_pickup_picked_up,&m_dwPickUp)?true:false;
  625. }
  626.  
  627. void ScriptPickUp::Keep(bool bKeepForever)
  628. {
  629. m_bKeepForeever=bKeepForever;
  630. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement