Test_PDS.cpp 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /******************************************************************************
  19. *
  20. * FILE
  21. *
  22. * DESCRIPTION
  23. *
  24. * PROGRAMMER
  25. * Patrick Smith
  26. *
  27. * VERSION INFO
  28. * $Author: Byon_g $
  29. * $Revision: 31 $
  30. * $Modtime: 11/29/01 11:05a $
  31. * $Archive: /Commando/Code/Scripts/Test_PDS.cpp $
  32. *
  33. ******************************************************************************/
  34. #include "scripts.h"
  35. #include "dprint.h"
  36. DECLARE_SCRIPT(PDS_Generic_Test, "")
  37. {
  38. void Created (GameObject *game_obj)
  39. {
  40. Commands->Start_Timer(game_obj, this, 3.0F, 777);
  41. return ;
  42. }
  43. void Timer_Expired (GameObject *game_obj, int timer_id)
  44. {
  45. if (timer_id == 777) {
  46. GameObject *star = Commands->Get_The_Star ();
  47. if (star != NULL) {
  48. Vector3 pos = Commands->Get_Position (star);
  49. pos.Z = Commands->Get_Safe_Flight_Height (pos.X, pos.Y);
  50. Commands->Set_Position (game_obj, pos);
  51. }
  52. Commands->Start_Timer(game_obj, this, 3.0F, 777);
  53. }
  54. return ;
  55. }
  56. };
  57. DECLARE_SCRIPT(PDS_Test_Modify_Attack, "WaypathID=:int")
  58. {
  59. void Created (GameObject *game_obj)
  60. {
  61. Commands->Start_Timer(game_obj, this, 3.0F, 777);
  62. return ;
  63. }
  64. void Timer_Expired (GameObject *game_obj, int timer_id)
  65. {
  66. if (timer_id == 777) {
  67. Commands->Enable_Engine (game_obj, true);
  68. ActionParamsStruct params;
  69. params.Set_Basic (this, 100, 777);
  70. params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
  71. params.WaypathID = Get_Int_Parameter (0);
  72. params.WaypathSplined = true;
  73. params.AttackActive = false;
  74. params.AttackCheckBlocked = false;
  75. Commands->Action_Attack (game_obj, params);
  76. //params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
  77. //params.AttackCheckBlocked = false;
  78. //Commands->Action_Attack( game_obj, params );
  79. //Commands->Action_Goto( game_obj, params );
  80. Commands->Start_Timer(game_obj, this, 4.0F, 888);
  81. } else if (timer_id == 888) {
  82. ActionParamsStruct params;
  83. params.Set_Basic (this, 100, 777);
  84. params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
  85. params.WaypathID = Get_Int_Parameter (0);
  86. params.WaypathSplined = true;
  87. params.AttackActive = true;
  88. params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
  89. params.AttackCheckBlocked = false;
  90. Commands->Modify_Action (game_obj, 777, params);
  91. Commands->Start_Timer(game_obj, this, 4.0F, 999);
  92. } else if (timer_id == 999) {
  93. ActionParamsStruct params;
  94. params.Set_Basic (this, 100, 777);
  95. params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
  96. params.WaypathID = Get_Int_Parameter (0);
  97. params.WaypathSplined = true;
  98. params.AttackActive = false;
  99. params.AttackCheckBlocked = false;
  100. //params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
  101. Commands->Modify_Action (game_obj, 777, params);
  102. Commands->Start_Timer(game_obj, this, 4.0F, 888);
  103. }
  104. return ;
  105. }
  106. };
  107. DECLARE_SCRIPT(PDS_Test_Dock, "DockDestObjID=:int,DockEntranceObjID=:int")
  108. {
  109. void Created (GameObject *game_obj)
  110. {
  111. Commands->Start_Timer (game_obj, this, 3.0F, 777);
  112. return ;
  113. }
  114. void Timer_Expired (GameObject *game_obj, int timer_id)
  115. {
  116. if (timer_id != 777) {
  117. return ;
  118. }
  119. //
  120. // Lookup the objects which mark the destination (docked) position
  121. // and the entrance to the docking bay
  122. //
  123. GameObject *dest_obj = Commands->Find_Object (Get_Int_Parameter (0));
  124. GameObject *entrance_obj = Commands->Find_Object (Get_Int_Parameter (1));
  125. if (dest_obj != NULL && entrance_obj != NULL) {
  126. //
  127. // Start the vehicle's engine
  128. //
  129. //Commands->Enable_Engine (game_obj, true);
  130. //
  131. // Lookup the positions of the two docking markers
  132. //
  133. Vector3 dest_pos = Commands->Get_Position (dest_obj);
  134. Vector3 entrance_pos = Commands->Get_Position (entrance_obj);
  135. //
  136. // Dock the vehicle
  137. //
  138. ActionParamsStruct params;
  139. params.Set_Basic (this, 100, 777);
  140. params.Dock_Vehicle (dest_pos, entrance_pos);
  141. params.MoveSpeed = 1.0F;
  142. Commands->Action_Dock (game_obj, params);
  143. }
  144. return ;
  145. }
  146. };
  147. DECLARE_SCRIPT(PDS_Test_Conversation, "Conversation Name=:string,Soldier1_ID=0:int,Soldier2_ID=0:int,Soldier3_ID=0:int")
  148. {
  149. ////////////////////////////////////////////////////////////////////
  150. // Created
  151. ////////////////////////////////////////////////////////////////////
  152. void Created (GameObject *game_obj)
  153. {
  154. Commands->Start_Timer(game_obj, this, 3.0F, 777);
  155. return ;
  156. }
  157. ////////////////////////////////////////////////////////////////////
  158. // Timer_Expired
  159. ////////////////////////////////////////////////////////////////////
  160. void Action_Complete (GameObject * game_obj, int action_id, ActionCompleteReason complete_reason)
  161. {
  162. //
  163. // Just for kicks, make the unit crouch
  164. //
  165. if (action_id == 778) {
  166. Commands->Set_Animation (game_obj, "S_A_HUMAN.H_A_A0A0_L08", true);
  167. }
  168. return ;
  169. }
  170. ////////////////////////////////////////////////////////////////////
  171. // Custom
  172. ////////////////////////////////////////////////////////////////////
  173. void Custom (GameObject *game_obj, int event, int data, GameObject *sender)
  174. {
  175. if (event == CUSTOM_EVENT_CONVERSATION_BEGAN) {
  176. int test = 0;
  177. test ++;
  178. } else if (event == CUSTOM_EVENT_CONVERSATION_REMARK_STARTED) {
  179. int test = 0;
  180. test ++;
  181. } else if (event == CUSTOM_EVENT_CONVERSATION_REMARK_ENDED) {
  182. int test = 0;
  183. test ++;
  184. }
  185. return ;
  186. }
  187. ////////////////////////////////////////////////////////////////////
  188. // Timer_Expired
  189. ////////////////////////////////////////////////////////////////////
  190. void Timer_Expired (GameObject *game_obj, int timer_id)
  191. {
  192. if (timer_id != 777) {
  193. return ;
  194. }
  195. const char *conv_name = Get_Parameter (0);
  196. //
  197. // Create the conversation
  198. //
  199. int conv_id = Commands->Create_Conversation (conv_name);
  200. if (conv_id != -1) {
  201. int soldier1_id = Get_Int_Parameter (1);
  202. int soldier2_id = Get_Int_Parameter (2);
  203. int soldier3_id = Get_Int_Parameter (3);
  204. //
  205. // Have the participants join the conversation
  206. //
  207. Commands->Join_Conversation (game_obj, conv_id, true, true);
  208. if (soldier1_id == -1) {
  209. GameObject *soldier = Commands->Get_The_Star ();
  210. if (soldier != NULL) {
  211. Commands->Join_Conversation (soldier, conv_id, true, true);
  212. }
  213. } else if (soldier1_id != 0) {
  214. GameObject *soldier = Commands->Find_Object (soldier1_id);
  215. if (soldier != NULL) {
  216. Commands->Join_Conversation (soldier, conv_id, true, true);
  217. }
  218. }
  219. if (soldier2_id != 0) {
  220. GameObject *soldier = Commands->Find_Object (soldier2_id);
  221. if (soldier != NULL) {
  222. Commands->Join_Conversation (soldier, conv_id, true, true);
  223. }
  224. }
  225. if (soldier3_id != 0) {
  226. GameObject *soldier = Commands->Find_Object (soldier3_id);
  227. if (soldier != NULL) {
  228. Commands->Join_Conversation (soldier, conv_id, true, true);
  229. }
  230. }
  231. //
  232. // Begin the conversation
  233. //
  234. Commands->Start_Conversation (conv_id, 778);
  235. Commands->Monitor_Conversation (game_obj, conv_id);
  236. }
  237. return ;
  238. }
  239. };
  240. DECLARE_SCRIPT(PDS_Get_In_Vehicle_Do_Waypath, "VehicleID=:int,WaypathID=:int,V3Test=1.3 44.543 0:vector3")
  241. {
  242. bool m_StartedWaypath;
  243. ////////////////////////////////////////////////////////////////////
  244. // Created
  245. ////////////////////////////////////////////////////////////////////
  246. void Created (GameObject* game_obj)
  247. {
  248. //
  249. // Find the vehicle we want to get into
  250. //
  251. m_StartedWaypath = false;
  252. GameObject *dest_obj = Commands->Find_Object (Get_Int_Parameter (0));
  253. if (dest_obj != NULL) {
  254. //
  255. // Instruct our game object to goto the driver's side of the destination vehicle
  256. //
  257. Vector3 pos = Commands->Get_Position (dest_obj);
  258. // Commands->Action_Movement_Goto_Location (game_obj, pos, 1.0F);
  259. ActionParamsStruct params;
  260. params.Set_Basic( this, 50, 0 );
  261. params.Set_Movement( pos, 1, 1 );
  262. Commands->Action_Goto( game_obj, params );
  263. } else {
  264. DebugPrint ("Error! Cannot find destination for PDS_Get_In_Vehicle_Do_Waypath.\n");
  265. }
  266. return ;
  267. }
  268. ////////////////////////////////////////////////////////////////////
  269. // Movement_Complete
  270. ////////////////////////////////////////////////////////////////////
  271. // void Movement_Complete (GameObject *game_obj, MovementCompleteReason /*reason*/)
  272. void Action_Complete (GameObject * game_obj, int action_id, ActionCompleteReason complete_reason)
  273. {
  274. //
  275. // Now tell the object to follow the waypath
  276. //
  277. if (m_StartedWaypath == false) {
  278. // Commands->Action_Movement_Follow_Waypath (game_obj, Get_Int_Parameter(1), 0, 0, true);
  279. ActionParamsStruct params;
  280. params.Set_Basic( this, 50, 0 );
  281. params.Set_Movement( Vector3(0,0,0), 1, 1 );
  282. params.WaypathID = Get_Int_Parameter(1);
  283. Commands->Action_Goto( game_obj, params );
  284. m_StartedWaypath = true;
  285. }
  286. return ;
  287. }
  288. };
  289. DECLARE_SCRIPT(PDS_Test_Goto_Player, "")
  290. {
  291. void Created(GameObject* game_obj)
  292. {
  293. Commands->Start_Timer(game_obj, this, 3.0F, 777);
  294. }
  295. ////////////////////////////////////////////////////////////////////
  296. // Timer_Expired
  297. ////////////////////////////////////////////////////////////////////
  298. void Timer_Expired (GameObject *game_obj, int timer_id)
  299. {
  300. if (timer_id != 777) {
  301. return ;
  302. }
  303. ActionParamsStruct params;
  304. //params.ActionID = 777;
  305. params.Set_Basic( this, 50, 777 );
  306. params.Set_Movement( Commands->Get_The_Star (), 1, 2 );
  307. params.MoveFollow = false;
  308. Commands->Action_Goto( game_obj, params );
  309. return ;
  310. }
  311. void Action_Complete (GameObject * game_obj, int action_id, ActionCompleteReason complete_reason)
  312. {
  313. if (action_id == 777) {
  314. int test = 0;
  315. test ++;
  316. }
  317. return ;
  318. }
  319. };
  320. DECLARE_SCRIPT(PDS_Test_Goto_Loc, "ObjDestID=:int")
  321. {
  322. ////////////////////////////////////////////////////////////////////
  323. // Created
  324. ////////////////////////////////////////////////////////////////////
  325. void Created (GameObject* game_obj)
  326. {
  327. Commands->Start_Timer(game_obj, this, 3.0F, 777);
  328. return ;
  329. }
  330. ////////////////////////////////////////////////////////////////////
  331. // Timer_Expired
  332. ////////////////////////////////////////////////////////////////////
  333. void Timer_Expired (GameObject *game_obj, int timer_id)
  334. {
  335. if (timer_id != 777) {
  336. return ;
  337. }
  338. //
  339. // Find the destination 'object'
  340. //
  341. GameObject* dest_obj = Commands->Find_Object(Get_Int_Parameter(0));
  342. if (dest_obj != NULL) {
  343. //
  344. // Instruct our game object to goto the location of the destination object
  345. //
  346. Vector3 pos = Commands->Get_Position(dest_obj);
  347. // Commands->Action_Movement_Goto_Location(game_obj, pos, 3.0F);
  348. ActionParamsStruct params;
  349. params.Set_Basic( this, 50, 0 );
  350. params.Set_Movement( pos, 0.5F, 3 );
  351. Commands->Action_Goto( game_obj, params );
  352. } else {
  353. DebugPrint("Error! Cannot find destination for PDS_Test_Goto_Loc.\n");
  354. }
  355. return ;
  356. }
  357. };
  358. DECLARE_SCRIPT(PDS_Test_Follow_Player, "")
  359. {
  360. ////////////////////////////////////////////////////////////////////
  361. // Created
  362. ////////////////////////////////////////////////////////////////////
  363. void Created (GameObject *game_obj)
  364. {
  365. Commands->Start_Timer(game_obj, this, 3.0F, 777);
  366. return ;
  367. }
  368. void Poked( GameObject * obj, GameObject * poker )
  369. {
  370. Commands->Grant_Key (obj, 1, true);
  371. return ;
  372. }
  373. ////////////////////////////////////////////////////////////////////
  374. // Timer_Expired
  375. ////////////////////////////////////////////////////////////////////
  376. void Timer_Expired (GameObject *game_obj, int timer_id)
  377. {
  378. Commands->Innate_Disable (game_obj);
  379. // Commands->Action_Movement_Follow_Object (game_obj, Commands->Get_The_Star (), 2.0F);
  380. /*ActionParamsStruct params;
  381. params.Set_Basic( this, 50, 0 );
  382. params.Set_Movement( Commands->Get_The_Star (), 1, 15 );
  383. //params.Set_Attack( Commands->Get_The_Star (), 100, 15, true );
  384. //params.Set_Movement( Commands->Get_The_Star (), 1, 15 );
  385. params.MoveFollow = true;
  386. Commands->Action_Attack( game_obj, params );*/
  387. ActionParamsStruct params2;
  388. params2.Set_Basic( this, 50, 0 );
  389. params2.Set_Movement( Commands->Get_The_Star (), 1, 5 );
  390. params2.MoveFollow = true;
  391. Commands->Action_Goto( game_obj, params2 );
  392. return ;
  393. }
  394. };
  395. DECLARE_SCRIPT(PDS_Test_Follow_Waypath, "WaypathID=:int,WaypointStartID=:int,WaypointEndID=:int")
  396. {
  397. void Created (GameObject *game_obj)
  398. {
  399. Commands->Grant_Key (game_obj, 0);
  400. Commands->Grant_Key (game_obj, 1);
  401. Commands->Grant_Key (game_obj, 2);
  402. Commands->Grant_Key (game_obj, 3);
  403. Commands->Grant_Key (game_obj, 4);
  404. Commands->Grant_Key (game_obj, 5);
  405. Commands->Grant_Key (game_obj, 6);
  406. Commands->Grant_Key (game_obj, 7);
  407. Commands->Enable_Engine (game_obj, true);
  408. ActionParamsStruct params;
  409. params.Set_Basic( this, 100, 777 );
  410. params.Set_Movement( Vector3(0,0,0), 1, 5 );
  411. params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
  412. params.WaypathID = Get_Int_Parameter(0);
  413. params.WaypathSplined = true;
  414. params.AttackActive = false;
  415. params.AttackCheckBlocked = false;
  416. Commands->Action_Attack( game_obj, params );
  417. return ;
  418. }
  419. void Timer_Expired (GameObject *game_obj, int timer_id)
  420. {
  421. // Commands->Action_Movement_Follow_Waypath (game_obj, Get_Int_Parameter(0), Get_Int_Parameter(1), Get_Int_Parameter(2), true);
  422. if (timer_id == 777) {
  423. ActionParamsStruct params;
  424. params.Set_Basic (this, 100, 777);
  425. params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
  426. params.WaypathID = Get_Int_Parameter (0);
  427. params.WaypathSplined = true;
  428. params.AttackActive = false;
  429. params.AttackCheckBlocked = false;
  430. params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
  431. Commands->Modify_Action (game_obj, 777, params);
  432. //Commands->Action_Goto( game_obj, params );
  433. return ;
  434. }
  435. }
  436. void Damaged( GameObject * game_obj, GameObject * damager, float amount )
  437. {
  438. ActionParamsStruct params;
  439. params.Set_Basic (this, 100, 777);
  440. params.Set_Movement (Vector3 (0, 0, 0), 1, 1);
  441. params.WaypathID = Get_Int_Parameter (0);
  442. params.WaypathSplined = true;
  443. params.AttackActive = true;
  444. params.AttackCheckBlocked = false;
  445. params.Set_Attack (Commands->Get_The_Star (), 100, 0.5F, true);
  446. Commands->Modify_Action (game_obj, 777, params);
  447. // attack for a while, then go back to following the waypath
  448. Commands->Start_Timer(game_obj, this, 5.0F, 777);
  449. }
  450. };
  451. DECLARE_SCRIPT(PDS_Test_Harvester, "TiberiumID=:int,DriveToID=:int,EntranceID=:int,DockID=:int")
  452. {
  453. int m_State;
  454. GameObject * m_GameObj;
  455. ////////////////////////////////////////////////////////////////////
  456. // State
  457. ////////////////////////////////////////////////////////////////////
  458. enum
  459. {
  460. DRIVE_TO_TIBERIUM = 0,
  461. HARVEST_TIBERIUM,
  462. DRIVE_TO_REFINERY,
  463. DOCK_HARVESTER_STEP1,
  464. DOCK_HARVESTER_STEP2,
  465. UNLOAD_TIBERIUM,
  466. MAX_STATE
  467. };
  468. ////////////////////////////////////////////////////////////////////
  469. // Created
  470. ////////////////////////////////////////////////////////////////////
  471. void Created (GameObject *game_obj)
  472. {
  473. //
  474. // Initialize variables
  475. //
  476. m_State = DRIVE_TO_TIBERIUM;
  477. m_GameObj = game_obj;
  478. //
  479. // Process state
  480. //
  481. Think ();
  482. return ;
  483. }
  484. ////////////////////////////////////////////////////////////////////
  485. // Timer_Expired
  486. ////////////////////////////////////////////////////////////////////
  487. void Timer_Expired (GameObject *obj, int timer_id)
  488. {
  489. if (timer_id == 777) {
  490. Next_State ();
  491. }
  492. return ;
  493. }
  494. ////////////////////////////////////////////////////////////////////
  495. // Movement_Complete
  496. ////////////////////////////////////////////////////////////////////
  497. // void Movement_Complete (GameObject *obj, MovementCompleteReason reason)
  498. void Action_Complete (GameObject * game_obj, int action_id, ActionCompleteReason complete_reason)
  499. {
  500. Next_State ();
  501. return ;
  502. }
  503. ////////////////////////////////////////////////////////////////////
  504. // Next_State
  505. ////////////////////////////////////////////////////////////////////
  506. void Next_State (void)
  507. {
  508. //
  509. // Move on to the next state
  510. //
  511. m_State ++;
  512. if (m_State == MAX_STATE) {
  513. m_State = DRIVE_TO_TIBERIUM;
  514. }
  515. //
  516. // Process the new state
  517. //
  518. Think ();
  519. return ;
  520. }
  521. ////////////////////////////////////////////////////////////////////
  522. // Think
  523. ////////////////////////////////////////////////////////////////////
  524. void Think (void)
  525. {
  526. switch (m_State)
  527. {
  528. case DRIVE_TO_TIBERIUM:
  529. Drive_To_Obj (Get_Int_Parameter (0), false);
  530. break;
  531. case HARVEST_TIBERIUM:
  532. Commands->Start_Timer (m_GameObj, this, Commands->Get_Random (3.0F, 6.0F), 777);
  533. break;
  534. case DRIVE_TO_REFINERY:
  535. Drive_To_Obj (Get_Int_Parameter (1), false);
  536. break;
  537. case DOCK_HARVESTER_STEP1:
  538. Drive_To_Obj (Get_Int_Parameter (2), true);
  539. break;
  540. case DOCK_HARVESTER_STEP2:
  541. Drive_To_Obj (Get_Int_Parameter (3), true);
  542. break;
  543. case UNLOAD_TIBERIUM:
  544. Commands->Start_Timer (m_GameObj, this, Commands->Get_Random (2.0F, 4.0F), 777);
  545. break;
  546. }
  547. return ;
  548. }
  549. ////////////////////////////////////////////////////////////////////
  550. // Drive_To_Obj
  551. ////////////////////////////////////////////////////////////////////
  552. void Drive_To_Obj (int obj_id, bool force_backup)
  553. {
  554. //
  555. // Find the destination object
  556. //
  557. GameObject* dest_obj = Commands->Find_Object (obj_id);
  558. if (dest_obj != NULL) {
  559. //
  560. // Instruct our game object to goto the location of the destination object
  561. //
  562. Vector3 pos = Commands->Get_Position (dest_obj);
  563. if (force_backup == false) {
  564. // Commands->Action_Movement_Goto_Location (m_GameObj, pos, 1.0F);
  565. ActionParamsStruct params;
  566. params.Set_Basic( this, 50, 0 );
  567. params.Set_Movement( pos, 1, 1 );
  568. Commands->Action_Goto( m_GameObj, params );
  569. } else {
  570. // Commands->Action_Movement_Backup_Goto_Location (m_GameObj, pos, 1.0F);
  571. ActionParamsStruct params;
  572. params.Set_Basic( this, 50, 0 );
  573. params.Set_Movement( pos, 1, 1 );
  574. params.MoveBackup = true;
  575. Commands->Action_Goto( m_GameObj, params );
  576. }
  577. } else {
  578. DebugPrint("Error! Cannot find destination for PDS_Test_Harvester.\n");
  579. }
  580. return ;
  581. }
  582. };
  583. ////////////////////////////////////////////////////////////////////
  584. // Constants
  585. ////////////////////////////////////////////////////////////////////
  586. enum
  587. {
  588. INVENTORY_EMPTY = 0,
  589. INVENTORY_MEDKIT,
  590. };
  591. enum
  592. {
  593. CUSTOM_HAS_MEDKIT = 0,
  594. CUSTOM_GOT_OBJECT,
  595. };
  596. DECLARE_SCRIPT(PDS_Test_Inventory, "")
  597. {
  598. ////////////////////////////////////////////////////////////////////
  599. // Member data
  600. ////////////////////////////////////////////////////////////////////
  601. enum
  602. {
  603. INVENTORY_MAX = 4
  604. };
  605. int Inventory[INVENTORY_MAX];
  606. ////////////////////////////////////////////////////////////////////
  607. // Created
  608. ////////////////////////////////////////////////////////////////////
  609. void Created (GameObject *game_obj)
  610. {
  611. //
  612. // Clear the inventory
  613. //
  614. for (int index = 0; index < INVENTORY_MAX; index ++) {
  615. Inventory[index] = INVENTORY_MEDKIT;
  616. }
  617. return ;
  618. }
  619. ////////////////////////////////////////////////////////////////////
  620. // Custom
  621. ////////////////////////////////////////////////////////////////////
  622. void Custom (GameObject *game_obj, int event, int data, GameObject *sender)
  623. {
  624. if (event == CUSTOM_HAS_MEDKIT) {
  625. int *retval = (int *)data;
  626. if (retval != NULL) {
  627. (*retval) = 0;
  628. //
  629. // Check all the inventory slots for the medkit
  630. //
  631. for (int index = 0; index < INVENTORY_MAX; index ++) {
  632. if (Inventory[index] == INVENTORY_MEDKIT) {
  633. (*retval) = 1;
  634. break;
  635. }
  636. }
  637. }
  638. } else if (event == CUSTOM_GOT_OBJECT) {
  639. //
  640. // Find an empty slot in the inventory and stick this object into it
  641. //
  642. for (int index = 0; index < INVENTORY_MAX; index ++) {
  643. if (Inventory[index] == INVENTORY_EMPTY) {
  644. Inventory[index] = data;
  645. break;
  646. }
  647. }
  648. }
  649. return ;
  650. }
  651. };
  652. DECLARE_SCRIPT(PDS_Test_Bubba, "")
  653. {
  654. ////////////////////////////////////////////////////////////////////
  655. // Member data
  656. ////////////////////////////////////////////////////////////////////
  657. GameObject * GameObj;
  658. int State;
  659. ////////////////////////////////////////////////////////////////////
  660. // Constants
  661. ////////////////////////////////////////////////////////////////////
  662. enum
  663. {
  664. TIMER_GROAN = 444,
  665. };
  666. enum
  667. {
  668. STATE_DYING = 0,
  669. STATE_FOLLOWING,
  670. STATE_CRINGING
  671. };
  672. ////////////////////////////////////////////////////////////////////
  673. // Created
  674. ////////////////////////////////////////////////////////////////////
  675. void Created (GameObject *game_obj)
  676. {
  677. Commands->Clear_Map_Cell_By_Pos (Commands->Get_Position (game_obj));
  678. Commands->Clear_Map_Cell (0, 0);
  679. Commands->Clear_Map_Cell (10, 10);
  680. Commands->Clear_Map_Cell (19, 19);
  681. return ;
  682. }
  683. };
  684. DECLARE_SCRIPT(PDS_Test_Controller, "")
  685. {
  686. ////////////////////////////////////////////////////////////////////
  687. // Created
  688. ////////////////////////////////////////////////////////////////////
  689. void Created (GameObject *game_obj)
  690. {
  691. Commands->Start_Timer (game_obj, this, 2.0F, 777);
  692. return ;
  693. }
  694. ////////////////////////////////////////////////////////////////////
  695. // Timer_Expired
  696. ////////////////////////////////////////////////////////////////////
  697. void Timer_Expired (GameObject *game_obj, int timer_id)
  698. {
  699. if (timer_id == 777) {
  700. GameObject *the_player = Commands->Get_The_Star ();
  701. if (the_player != NULL) {
  702. Commands->Attach_Script (the_player, "PDS_Test_Inventory", "");
  703. }
  704. }
  705. return ;
  706. }
  707. };
  708. DECLARE_SCRIPT(PDS_Test_Gunboat, "")
  709. {
  710. ////////////////////////////////////////////////////////////////////
  711. // Member Data
  712. ////////////////////////////////////////////////////////////////////
  713. GameObject *GameObj;
  714. int State;
  715. ////////////////////////////////////////////////////////////////////
  716. // Constants
  717. ////////////////////////////////////////////////////////////////////
  718. enum
  719. {
  720. TIMER_ATTACK = 777,
  721. };
  722. enum
  723. {
  724. STATE_AT_BEACHHEAD = 0,
  725. STATE_AT_INLET,
  726. STATE_FIGHTING_BIG_GUN,
  727. STATE_IN_TRANSIT
  728. };
  729. ////////////////////////////////////////////////////////////////////
  730. // Created
  731. ////////////////////////////////////////////////////////////////////
  732. void Created (GameObject *game_obj)
  733. {
  734. GameObj = game_obj;
  735. State = STATE_AT_BEACHHEAD;
  736. Move_To_Next_Location ();
  737. //State = STATE_IN_TRANSIT;
  738. Commands->Enable_Engine (GameObj, true);
  739. Commands->Disable_All_Collisions (GameObj);
  740. Start_Attack ();
  741. return ;
  742. }
  743. ////////////////////////////////////////////////////////////////////
  744. // Start_Attack
  745. ////////////////////////////////////////////////////////////////////
  746. void Start_Attack (void)
  747. {
  748. if (State != STATE_IN_TRANSIT) {
  749. //Commands->Start_Timer (GameObj, this, Commands->Get_Random (10.0F, 12.0F), TIMER_ATTACK);
  750. }
  751. return ;
  752. }
  753. ////////////////////////////////////////////////////////////////////
  754. // Move_To_Next_Location
  755. ////////////////////////////////////////////////////////////////////
  756. void Move_To_Next_Location (void)
  757. {
  758. int waypath_id = 0;
  759. switch (State)
  760. {
  761. case STATE_AT_BEACHHEAD:
  762. waypath_id = 100050;
  763. break;
  764. case STATE_AT_INLET:
  765. waypath_id = 0;
  766. break;
  767. }
  768. if (waypath_id != 0) {
  769. ActionParamsStruct params;
  770. params.WaypathID = waypath_id;
  771. params.WaypointStartID = 0;
  772. params.WaypointEndID = 0;
  773. params.WaypathSplined = true;
  774. Commands->Action_Goto (GameObj, params);
  775. }
  776. return ;
  777. }
  778. ////////////////////////////////////////////////////////////////////
  779. // Timer_Expired
  780. ////////////////////////////////////////////////////////////////////
  781. void Timer_Expired (GameObject *game_obj, int timer_id)
  782. {
  783. if (timer_id == TIMER_ATTACK) {
  784. GameObject *the_player = Commands->Get_The_Star ();
  785. if (the_player != NULL) {
  786. Vector3 pos = Commands->Get_Position (the_player);
  787. //pos.X += Commands->Get_Random (-1.0F, 1.0F) * Commands->Get_Random (6.0F, 10.0F);
  788. //pos.Y += Commands->Get_Random (-1.0F, 1.0F) * Commands->Get_Random (6.0F, 10.0F);
  789. //pos.Z += Commands->Get_Random (-1.0F, 1.0F) * Commands->Get_Random (6.0F, 10.0F);
  790. ActionParamsStruct params;
  791. params.Set_Basic (this, 50, 0);
  792. params.Set_Attack (pos, 200, 0, true);
  793. Commands->Action_Attack (GameObj, params);
  794. Start_Attack ();
  795. }
  796. }
  797. return ;
  798. }
  799. };
  800. DECLARE_SCRIPT(PDS_Test_Sound, "")
  801. {
  802. int SoundID;
  803. bool IsPlaying;
  804. void Created (GameObject* game_obj)
  805. {
  806. IsPlaying = true;
  807. return ;
  808. }
  809. ////////////////////////////////////////////////////////////////////
  810. // Poked
  811. ////////////////////////////////////////////////////////////////////
  812. void Poked (GameObject * obj, GameObject * poker)
  813. {
  814. if (IsPlaying) {
  815. Commands->Stop_Sound (1700002, false);
  816. IsPlaying = false;
  817. } else {
  818. Commands->Start_Sound (1700002);
  819. IsPlaying = true;
  820. }
  821. return ;
  822. }
  823. ////////////////////////////////////////////////////////////////////
  824. // Custom
  825. ////////////////////////////////////////////////////////////////////
  826. void Custom (GameObject *game_obj, int event, int data, GameObject *sender)
  827. {
  828. if (event == CUSTOM_EVENT_SOUND_ENDED && data == SoundID) {
  829. int test = 0;
  830. test ++;
  831. }
  832. return ;
  833. }
  834. };