MissionDemo.cpp 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855
  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. * MissionDemo.cpp
  22. *
  23. * DESCRIPTION
  24. * Mission Demo Specific Scripts
  25. *
  26. * PROGRAMMER
  27. * Rich Donnelly
  28. *
  29. * VERSION INFO
  30. * $Author: Byon_g $
  31. * $Revision: 7 $
  32. * $Modtime: 11/29/01 11:05a $
  33. * $Archive: /Commando/Code/Scripts/MissionDemo.cpp $
  34. *
  35. ******************************************************************************/
  36. #include "scripts.h"
  37. #include "toolkit.h"
  38. // Predefined Constants
  39. #define M02_OBJCONTROLLER 1111112
  40. #define M02_AREACOUNT 26
  41. // Mission Objective Controller and Initializer
  42. DECLARE_SCRIPT(MDD_Objective_Controller, "")
  43. {
  44. int convoy_trucks;
  45. REGISTER_VARIABLES()
  46. {
  47. SAVE_VARIABLE( convoy_trucks, 1 );
  48. }
  49. void Created(GameObject * obj)
  50. {
  51. //DEMO
  52. Commands->Enable_HUD (false);
  53. GameObject * camera = Commands->Create_Object("Invisible_Object", Vector3(0,0,0));
  54. if (camera)
  55. {
  56. Commands->Attach_Script(camera, "Test_Cinematic", "XG_DemoCam.txt");
  57. }
  58. int id = Commands->Create_Conversation("Demo_Intro");
  59. Commands->Join_Conversation(NULL, id);
  60. Commands->Join_Conversation(STAR, id);
  61. Commands->Start_Conversation(id);
  62. //DEMO
  63. // Set up the expected number of convoy trucks for the objective.
  64. convoy_trucks = 3;
  65. // Prevent the Objective Controller from hibernating
  66. Commands->Enable_Hibernation(obj, false);
  67. // Turn on the first primary objective (Locate the Missing Scientists)
  68. // Turn on the tertiary objectives (if any)
  69. //DEMO Commands->Add_Objective(201, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, IDS_M02_OBJECTIVE_01);
  70. //DEMO Commands->Add_Objective(222, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_HIDDEN, IDS_M02_OBJECTIVE_22);
  71. //DEMO Commands->Add_Objective(223, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_HIDDEN, IDS_M02_OBJECTIVE_23);
  72. }
  73. // This custom receives requests to activate and deactivate objectives
  74. // Type = Objective ID
  75. // Param 0 = Activate this objective (Pending)
  76. // Param 1 = Complete this objective (Accomplished)
  77. // Param 2 = Fail this objective (Failed)
  78. // Param 3 = Convoy truck special - counting
  79. };
  80. DECLARE_SCRIPT (MDD_Respawn_Controller, "")
  81. {
  82. bool active_area [M02_AREACOUNT];
  83. bool area_spawn_heli_drop_01_active [M02_AREACOUNT];
  84. bool area_spawn_heli_drop_02_active [M02_AREACOUNT];
  85. bool area_spawn_parachute_active [M02_AREACOUNT];
  86. char area_unit_count [M02_AREACOUNT];
  87. char area_unit_max [M02_AREACOUNT];
  88. int area_officer [M02_AREACOUNT];
  89. int spawner_rotator;
  90. int replacement_vehicle;
  91. int destroyed_sam;
  92. int destroyed_silo;
  93. REGISTER_VARIABLES()
  94. {
  95. SAVE_VARIABLE( active_area, 1);
  96. SAVE_VARIABLE( area_spawn_heli_drop_01_active, 2);
  97. SAVE_VARIABLE( area_spawn_heli_drop_02_active, 3);
  98. SAVE_VARIABLE( area_spawn_parachute_active, 4);
  99. SAVE_VARIABLE( area_unit_count, 5);
  100. SAVE_VARIABLE( area_unit_max, 6);
  101. SAVE_VARIABLE( area_officer, 7);
  102. SAVE_VARIABLE( spawner_rotator, 8);
  103. SAVE_VARIABLE( replacement_vehicle, 9);
  104. SAVE_VARIABLE( destroyed_sam, 10);
  105. SAVE_VARIABLE( destroyed_silo, 11);
  106. }
  107. void Created (GameObject *obj)
  108. {
  109. int counter;
  110. counter = 0;
  111. spawner_rotator = 0;
  112. replacement_vehicle = -1;
  113. destroyed_sam = 0;
  114. destroyed_silo = 0;
  115. while (counter < ARRAY_ELEMENT_COUNT(active_area))
  116. {
  117. active_area [counter] = false;
  118. area_unit_count [counter] = 0;
  119. area_officer [counter] = 0;
  120. area_unit_max [counter] = 4;
  121. area_spawn_heli_drop_01_active [counter] = false;
  122. area_spawn_heli_drop_02_active [counter] = false;
  123. area_spawn_parachute_active [counter] = false;
  124. // Turning the actives to true in here means they do not occur in the area
  125. // provided you don't turn them off later on in the mission.
  126. counter++;
  127. }
  128. // Drop the first Humm-Vee into the start area.
  129. //DEMO Call_GDI_HummVee (0);
  130. // Wake up the A25 units.
  131. //DEMO Commands->Send_Custom_Event(obj, Commands->Find_Object(400985), 0, 0);
  132. //DEMO Turn on A25
  133. GameObject * object = Commands->Find_Object(M02_OBJCONTROLLER);
  134. if (object)
  135. {
  136. Commands->Send_Custom_Event(obj, object, 104, 25);
  137. Commands->Send_Custom_Event(obj, Commands->Find_Object(401741), 0, 0);
  138. }
  139. // Call the ORCA strike intro.
  140. //DEMO GameObject * chinook_obj1 = Commands->Create_Object("Invisible_Object", Vector3(0,0,0));
  141. /*if (chinook_obj1)
  142. {
  143. Commands->Attach_Script(chinook_obj1, "Test_Cinematic", "X2A_OrcaStrike.txt");
  144. }*/
  145. Commands->Start_Timer(obj, this, 3.0f, 2);
  146. //DEMO
  147. Commands->Start_Timer(obj, this, 10.0f, 99);
  148. Commands->Start_Timer(obj, this, 5.0f, 100);
  149. Commands->Start_Timer(obj, this, 60.0f, 101);
  150. //DEMO
  151. }
  152. void Call_GDI_HummVee (int area_id)
  153. {
  154. Vector3 drop_loc = Vector3(-87.2f,-13.1f,-40.1f);
  155. float facing = 102.9f;
  156. GameObject * chinook_obj1 = Commands->Create_Object("Invisible_Object", drop_loc);
  157. if (chinook_obj1)
  158. {
  159. Commands->Set_Facing(chinook_obj1, facing);
  160. Commands->Attach_Script(chinook_obj1, "Test_Cinematic", "X2I_GDI_Drop_HummVee.txt");
  161. }
  162. }
  163. void Call_GDI_PowerUp (int area_id)
  164. {
  165. Vector3 drop_loc = Vector3(511.3f,680.3f,-21.2f);
  166. float facing = 146.6f;
  167. GameObject * chinook_obj1 = Commands->Create_Object("Invisible_Object", drop_loc);
  168. if (chinook_obj1)
  169. {
  170. Commands->Set_Facing(chinook_obj1, facing);
  171. Commands->Attach_Script(chinook_obj1, "Test_Cinematic", "X2I_GDI_Drop_PowerUp.txt");
  172. }
  173. }
  174. void Timer_Expired(GameObject * obj, int timer_id)
  175. {
  176. if (timer_id == 2)
  177. {
  178. // Count through each area, check if it is active.
  179. int counter;
  180. counter = 0;
  181. while (counter < ARRAY_ELEMENT_COUNT(active_area))
  182. {
  183. if (active_area[counter])
  184. {
  185. // Check if the area still has an officer associated.
  186. if (area_officer[counter])
  187. {
  188. GameObject* officer = Commands->Find_Object(area_officer[counter]);
  189. if (officer)
  190. {
  191. Check_Respawns (counter);
  192. }
  193. }
  194. }
  195. counter++;
  196. }
  197. Commands->Debug_Message (">>>>>>>>>>>>>>>> UNIT COUNT = %i, UNIT MAX = %i.\n",area_unit_count[25],area_unit_max[25]);
  198. int players_difficulty = Commands->Get_Difficulty_Level();
  199. float timer_length = 25 - (10 * (players_difficulty));
  200. Commands->Start_Timer(obj, this, timer_length, 2);
  201. }
  202. //DEMO
  203. else if (timer_id == 99)
  204. {
  205. GameObject *buggy = Commands->Create_Object ("GDI_Orca", Vector3(506.590f,470.752f,-40.590f));
  206. if (buggy)
  207. {
  208. Commands->Attach_Script (buggy, "MDD_Flying_Vehicle", "0");
  209. }
  210. }
  211. else if (timer_id == 100)
  212. {
  213. GameObject *buggy = Commands->Create_Object ("Nod_Apache", Vector3(587.296f,504.567f,-44.034f));
  214. if (buggy)
  215. {
  216. Commands->Attach_Script (buggy, "MDD_Flying_Vehicle", "1");
  217. }
  218. }
  219. else if (timer_id == 101)
  220. {
  221. area_unit_count [25] = 0;
  222. Commands->Start_Timer(obj, this, 60.0f, 101);
  223. }
  224. //DEMO
  225. }
  226. void Check_Respawns (int area_id)
  227. {
  228. // Can this particular area handle respawns?
  229. // Count through the spawn sequence until all units have been accounted for.
  230. int counter;
  231. int stop_point;
  232. bool stopped_counter;
  233. int spawner_buffer = 0;
  234. stopped_counter = false;
  235. counter = Get_Int_Random(0,2);
  236. stop_point = counter;
  237. int tempcount = area_unit_count[area_id];
  238. while (tempcount < area_unit_max [area_id])
  239. {
  240. if (!stopped_counter)
  241. {
  242. // Check which respawn type I can use.
  243. switch (counter)
  244. {
  245. case (0):
  246. {
  247. if (!area_spawn_heli_drop_01_active[area_id])
  248. {
  249. if ((area_unit_max[area_id] - tempcount) > 2)
  250. {
  251. area_spawn_heli_drop_01_active[area_id] = true;
  252. tempcount += 3;
  253. Use_Heli_Drop_01(area_id);
  254. }
  255. }
  256. break;
  257. }
  258. case (1):
  259. {
  260. if (!area_spawn_heli_drop_02_active[area_id])
  261. {
  262. if ((area_unit_max[area_id] - tempcount) > 1)
  263. {
  264. area_spawn_heli_drop_02_active[area_id] = true;
  265. tempcount += 2;
  266. Use_Heli_Drop_02(area_id);
  267. }
  268. }
  269. break;
  270. }
  271. case (2):
  272. {
  273. if (!area_spawn_parachute_active[area_id])
  274. {
  275. if ((area_unit_max[area_id] - tempcount) > 2)
  276. {
  277. area_spawn_parachute_active[area_id] = true;
  278. Use_Parachute_Drop(area_id);
  279. tempcount += 3;
  280. }
  281. }
  282. break;
  283. }
  284. }
  285. }
  286. else
  287. {
  288. spawner_buffer++;
  289. if (spawner_buffer < 3)
  290. {
  291. tempcount ++;
  292. Use_Spawners (area_id);
  293. }
  294. else
  295. {
  296. tempcount = area_unit_max[area_id];
  297. }
  298. }
  299. if (!stopped_counter)
  300. {
  301. counter++;
  302. if (counter > 2)
  303. {
  304. counter = 0;
  305. }
  306. if (counter == stop_point)
  307. {
  308. stopped_counter = true;
  309. }
  310. }
  311. }
  312. }
  313. // This uses a helicopter to drop three units.
  314. void Use_Heli_Drop_01 (int area_id)
  315. {
  316. Vector3 drop_location;
  317. float facing;
  318. const char* cinematic;
  319. const char* textfile;
  320. const char* parameters;
  321. cinematic = "Test_Cinematic";
  322. parameters = "25,107";
  323. textfile = "X2I_Drop03_Area25.txt";
  324. drop_location = Vector3(546.5f,274.5f,-45.0f);
  325. facing = 30.0f;
  326. GameObject * chinook_obj1 = Commands->Create_Object("Invisible_Object", drop_location);
  327. if (chinook_obj1)
  328. {
  329. Commands->Set_Facing(chinook_obj1, facing);
  330. Commands->Attach_Script(chinook_obj1, "M02_Reset_Spawn", parameters);
  331. Commands->Attach_Script(chinook_obj1, cinematic, textfile);
  332. }
  333. }
  334. // This uses a different helicopter route to drop two units.
  335. void Use_Heli_Drop_02 (int area_id)
  336. {
  337. Vector3 drop_location;
  338. float facing;
  339. const char* cinematic;
  340. const char* textfile;
  341. const char* parameters;
  342. cinematic = "Test_Cinematic";
  343. parameters = "25,108";
  344. textfile = "X2I_Drop02_Area25.txt";
  345. drop_location = Vector3(558.6f,381.7f,-51.1f);
  346. facing = -75.6f;
  347. GameObject * chinook_obj2 = Commands->Create_Object("Invisible_Object", drop_location);
  348. if (chinook_obj2)
  349. {
  350. Commands->Set_Facing(chinook_obj2, facing);
  351. Commands->Attach_Script(chinook_obj2, "M02_Reset_Spawn", parameters);
  352. Commands->Attach_Script(chinook_obj2, cinematic, textfile);
  353. }
  354. }
  355. // This uses a cargo plane parachute drop to drop three units.
  356. void Use_Parachute_Drop (int area_id)
  357. {
  358. Vector3 drop_location;
  359. float facing;
  360. const char* cinematic;
  361. const char* textfile;
  362. const char* parameters;
  363. cinematic = "Test_Cinematic";
  364. textfile = "X2I_Para03_Area25.txt";
  365. parameters = "25,109";
  366. drop_location = Vector3(598.7f,342.2f,-62.7f);
  367. facing = 173.9f;
  368. GameObject * plane_obj = Commands->Create_Object("Invisible_Object", drop_location);
  369. if (plane_obj)
  370. {
  371. Commands->Set_Facing(plane_obj, facing);
  372. Commands->Attach_Script(plane_obj, "M02_Reset_Spawn", parameters);
  373. Commands->Attach_Script(plane_obj, cinematic, textfile);
  374. }
  375. }
  376. // This uses the regular spawners to generate one unit.
  377. bool Use_Spawners (int area_id)
  378. {
  379. int spawner_id;
  380. const char *spawner_params;
  381. spawner_id = 0;
  382. spawner_params = "0,0,-1";
  383. spawner_rotator++;
  384. if (spawner_rotator > 2)
  385. {
  386. spawner_rotator = 0;
  387. }
  388. switch (spawner_rotator)
  389. {
  390. case (0):
  391. {
  392. spawner_id = 401462;
  393. break;
  394. }
  395. case (1):
  396. {
  397. spawner_id = 401463;
  398. break;
  399. }
  400. default:
  401. {
  402. spawner_id = 401464;
  403. break;
  404. }
  405. }
  406. spawner_params = "25,0,-1";
  407. GameObject * spawn1 = Commands->Trigger_Spawner(spawner_id);
  408. if (spawn1)
  409. {
  410. Commands->Attach_Script(spawn1, "MDD_Nod_Soldier", spawner_params);
  411. return true;
  412. }
  413. else
  414. {
  415. return false;
  416. }
  417. }
  418. void Custom (GameObject *obj, int type, int param, GameObject *sender)
  419. {
  420. if (type == 101)
  421. {
  422. // A unit has died, subtract him from his area (param).
  423. area_unit_count [param]--;
  424. if (area_unit_count [param] < 0)
  425. {
  426. area_unit_count [param] = 0;
  427. }
  428. }
  429. else if (type == 102)
  430. {
  431. // A specific area is requesting a forced spawn if possible.
  432. Check_Respawns (param);
  433. }
  434. else if (type == 103)
  435. {
  436. // A unit is registering with the area unit count.
  437. area_unit_count [param]++;
  438. }
  439. else if (type == 104)
  440. {
  441. // An area is being activated. Turn on the area.
  442. active_area [param] = true;
  443. }
  444. else if (type == 105)
  445. {
  446. // An area is being deactivated.
  447. active_area [param] = false;
  448. }
  449. else if (type == 106)
  450. {
  451. // An officer is registering with his area.
  452. if (sender)
  453. {
  454. area_officer[param] = Commands->Get_ID(sender);
  455. }
  456. }
  457. else if (type == 107)
  458. {
  459. // A Heli_01 spawner type is attempting to reset itself.
  460. area_spawn_heli_drop_01_active[param] = false;
  461. }
  462. else if (type == 108)
  463. {
  464. // A Heli_02 spawner type is attempting to reset itself.
  465. area_spawn_heli_drop_02_active[param] = false;
  466. }
  467. else if (type == 109)
  468. {
  469. // A Parachute spawner type is attempting to reset itself.
  470. area_spawn_parachute_active[param] = false;
  471. }
  472. else if (type == 111)
  473. {
  474. // A request to spawn a new vehicle for the commando has been made.
  475. Replacement_Vehicle (obj, param);
  476. }
  477. else if (type == 112)
  478. {
  479. // A player controlled vehicle has been destroyed, turn on the ability to make a new one
  480. replacement_vehicle = param;
  481. }
  482. else if (type == 113)
  483. {
  484. // A request has been made to call in a GDI power-up drop.
  485. Call_GDI_PowerUp (3);
  486. }
  487. else if (type == 114)
  488. {
  489. // Reset the unit area count to zero.
  490. area_unit_count [param] = 0;
  491. }
  492. else if (type == 115)
  493. {
  494. // Destroyed SAM on the bridge - add to count, determine if both are destroyed.
  495. destroyed_sam++;
  496. if (destroyed_sam > 1)
  497. {
  498. // Drop a Medium Tank on the bridge.
  499. replacement_vehicle = 6;
  500. Replacement_Vehicle (obj, 6);
  501. }
  502. }
  503. else if (type == 116)
  504. {
  505. // Destroyed Tiberium Silo - add to count, determine if both are destroyed.
  506. destroyed_silo++;
  507. if (destroyed_silo > 1)
  508. {
  509. // Complete this mission objective.
  510. Commands->Send_Custom_Event (obj, obj, 222, 1);
  511. }
  512. }
  513. //DEMO
  514. else if (type == 180)
  515. {
  516. Commands->Start_Timer(obj, this, 20.0f, 99);
  517. }
  518. else if (type == 181)
  519. {
  520. Commands->Start_Timer(obj, this, 20.0f, 100);
  521. }
  522. }
  523. // When a player controlled vehicle is destroyed, it sends a custom to this controller
  524. // to turn on the ability to create a new vehicle in a certain area.
  525. // Another object then sends a custom to check for new vehicle creation. If the flag for
  526. // creating a new vehicle for this area is active, it is reset and the vehicle is delivered.
  527. void Replacement_Vehicle (GameObject *obj, int area_id)
  528. {
  529. Vector3 drop_loc = Vector3(0.0f,0.0f,0.0f);
  530. float facing = 0.0f;
  531. const char* textfile = "X2I_GDI_Drop_HummVee.txt";
  532. bool nocinematic = false;
  533. switch (area_id)
  534. {
  535. case (0):
  536. {
  537. drop_loc = Vector3(161.6f,27.6f,-18.0f);
  538. facing = 115.4f;
  539. textfile = "X2I_GDI_Drop_HummVee.txt";
  540. break;
  541. }
  542. case (1):
  543. {
  544. drop_loc = Vector3(494.652f,128.786f,-56.159f);
  545. facing = 90.0f;
  546. GameObject *buggy = Commands->Create_Object ("Nod_Buggy", drop_loc);
  547. if (buggy)
  548. {
  549. Commands->Set_Facing (buggy, facing);
  550. Commands->Attach_Script (buggy, "M02_Player_Vehicle", "3");
  551. }
  552. nocinematic = true;
  553. break;
  554. }
  555. case (2):
  556. {
  557. drop_loc = Vector3(471.4f,716.0f,-17.1f);
  558. facing = -30.0f;
  559. textfile = "X2I_GDI_Drop_MediumTank.txt";
  560. break;
  561. }
  562. case (4):
  563. {
  564. drop_loc = Vector3(429.672f, 894.045f, 4.354f);
  565. facing = -25.0f;
  566. GameObject *buggy = Commands->Create_Object ("Nod_Light_Tank", drop_loc);
  567. if (buggy)
  568. {
  569. Commands->Set_Facing (buggy, facing);
  570. Commands->Attach_Script (buggy, "M02_Player_Vehicle", "5");
  571. }
  572. nocinematic = true;
  573. break;
  574. }
  575. case (5):
  576. {
  577. drop_loc = Vector3(611.1f, 1164.9f, 4.6f);
  578. facing = -39.7f;
  579. GameObject *buggy = Commands->Create_Object ("Nod_Recon_Bike", drop_loc);
  580. if (buggy)
  581. {
  582. Commands->Set_Facing (buggy, facing);
  583. Commands->Attach_Script (buggy, "M02_Player_Vehicle", "6");
  584. }
  585. nocinematic = true;
  586. break;
  587. }
  588. case (6):
  589. {
  590. drop_loc = Vector3(785.3f,893.9f,21.8f);
  591. facing = -42.0f;
  592. textfile = "X2I_GDI_Drop_MediumTank.txt";
  593. break;
  594. }
  595. case (14):
  596. {
  597. drop_loc = Vector3(1229.37f, 742.89f, 27.03f);
  598. facing = 85.0f;
  599. GameObject *buggy = Commands->Create_Object ("Nod_Recon_Bike", drop_loc);
  600. if (buggy)
  601. {
  602. Commands->Set_Facing (buggy, facing);
  603. Commands->Attach_Script (buggy, "M02_Player_Vehicle", "14");
  604. }
  605. nocinematic = true;
  606. break;
  607. }
  608. }
  609. if (!nocinematic)
  610. {
  611. GameObject * chinook_obj1 = Commands->Create_Object("Invisible_Object", drop_loc);
  612. if (chinook_obj1)
  613. {
  614. Commands->Set_Facing(chinook_obj1, facing);
  615. Commands->Attach_Script(chinook_obj1, "Test_Cinematic", textfile);
  616. }
  617. }
  618. }
  619. };
  620. DECLARE_SCRIPT (MDD_Nod_Soldier, "Area_Number:int,Area_Officer:int,Pre_Placed:int")
  621. {
  622. Vector3 my_home_point;
  623. bool no_return_home;
  624. int officeranimcounter;
  625. bool initial_damage;
  626. float initial_health;
  627. bool enemy_seen;
  628. REGISTER_VARIABLES()
  629. {
  630. SAVE_VARIABLE( my_home_point, 1);
  631. SAVE_VARIABLE( no_return_home, 2);
  632. SAVE_VARIABLE( officeranimcounter, 3);
  633. }
  634. void Created (GameObject *obj)
  635. {
  636. officeranimcounter = 0;
  637. no_return_home = false;
  638. enemy_seen = false;
  639. initial_damage = false;
  640. initial_health = 0.0f;
  641. // Set the unit's home point, save the value.
  642. Vector3 my_home_point = Commands->Get_Position(obj);
  643. Commands->Set_Innate_Soldier_Home_Location(obj, my_home_point, 20.0f);
  644. // Turn hibernation off for a moment.
  645. Commands->Enable_Hibernation (obj, false);
  646. // Start the timer to register with the controller.
  647. Commands->Start_Timer(obj, this, 1.0f, 1);
  648. //DEMO
  649. Commands->Start_Timer(obj, this, 10.0f, 8);
  650. //DEMO
  651. // If the unit is spawned, do not disturb it.
  652. // If the unit is preplaced, turn of actions.
  653. // If the unit is flown in, order it to move to the commando.
  654. int preplaced = Get_Int_Parameter("Pre_Placed");
  655. if (!preplaced)
  656. {
  657. // Give spawned units a green key for the Hand of Nod.
  658. Commands->Grant_Key (obj, 1, true);
  659. //DEMOGameObject *starobj = Commands->Get_A_Star (my_home_point);
  660. GameObject *starobj = Commands->Find_Object(403063);
  661. //DEMO
  662. if (starobj)
  663. {
  664. ActionParamsStruct params;
  665. params.Set_Basic(this, 71, 0);
  666. params.Set_Movement(starobj, RUN, 5.0f, 0);
  667. Commands->Action_Goto(obj, params);
  668. }
  669. }
  670. else
  671. {
  672. if (preplaced > 0)
  673. {
  674. // Turn off all actions for preplaced soldiers.
  675. Commands->Innate_Disable (obj);
  676. }
  677. }
  678. }
  679. void Enemy_Seen (GameObject * obj, GameObject * enemy)
  680. {
  681. enemy_seen = true;
  682. }
  683. void Sound_Heard (GameObject * obj, const CombatSound & sound)
  684. {
  685. // If an objective shouts, respond to it, letting it know the area is not cleared.
  686. if (sound.Type == 1000)
  687. {
  688. if (sound.Creator)
  689. {
  690. Commands->Send_Custom_Event(obj, sound.Creator, 100, 1);
  691. }
  692. }
  693. // If a zone shouts to return to home points, do so.
  694. else if ((sound.Type > 1049) && (sound.Type < 1100) && (!no_return_home))
  695. {
  696. int area_id = (sound.Type - 1050);
  697. int area_num = Get_Int_Parameter("Area_Number");
  698. if (area_num == area_id)
  699. {
  700. // Tell this unit to return to its home point, conserving unit counts.
  701. ActionParamsStruct params;
  702. params.Set_Basic(this, 99, 0);
  703. params.Set_Movement(my_home_point, RUN, 20.0f, false);
  704. Commands->Modify_Action (obj, 0, params, true, false);
  705. }
  706. }
  707. }
  708. void Timer_Expired (GameObject *obj, int timer_id)
  709. {
  710. if (timer_id == 1)
  711. {
  712. // Register with the respawn controller - send my area number.
  713. int officer = Get_Int_Parameter("Area_Officer");
  714. int preplaced = Get_Int_Parameter("Pre_Placed");
  715. int param = Get_Int_Parameter("Area_Number");
  716. GameObject * object = Commands->Find_Object(M02_OBJCONTROLLER);
  717. if (object)
  718. {
  719. // Register with the respawn controller.
  720. Commands->Send_Custom_Event(obj, object, 103, param);
  721. if (officer)
  722. {
  723. // Unit is a preplaced officer. Register as an officer and hibernate.
  724. Commands->Set_Innate_Take_Cover_Probability (obj, 100.0f);
  725. Commands->Send_Custom_Event(obj, object, 106, param);
  726. }
  727. else
  728. {
  729. if (preplaced > 0)
  730. {
  731. // SPECIAL CASE SETUP: Force fire routine for Rocket Soldiers.
  732. if (preplaced == 4)
  733. {
  734. if ((param == 0) || (param == 3) || (param == 6) || (param == 10) || (param == 16) || (param == 21))
  735. {
  736. no_return_home = true;
  737. Commands->Start_Timer(obj, this, 15.0f, 4);
  738. }
  739. }
  740. // Soldiers in start cinematic begin self-destruct.
  741. if ((preplaced == 2) && (param == 99))
  742. {
  743. ActionParamsStruct params;
  744. params.Set_Basic(this, 99, 0);
  745. params.Set_Attack(STAR, 150.0f, 0.0f, true);
  746. Commands->Action_Attack(obj, params);
  747. Commands->Start_Timer(obj, this, 5.0, 6);
  748. }
  749. }
  750. else
  751. {
  752. // Unit is not pre-placed, activate cleanup code and do not hibernate if not in the interior areas.
  753. Commands->Start_Timer(obj, this, 15.0f, 2);
  754. }
  755. }
  756. }
  757. //DEMO Commands->Enable_Hibernation (obj, 1);
  758. }
  759. else if (timer_id == 2)
  760. {
  761. // Cleanup code - find the nearest star, check distance, then check visibility
  762. Vector3 myloc = Commands->Get_Position(obj);
  763. //DEMO GameObject *star_obj = Commands->Get_A_Star(myloc);
  764. GameObject *star_obj = Commands->Find_Object(403063);
  765. //DEMO
  766. if (star_obj)
  767. {
  768. Vector3 starloc = Commands->Get_Position(star_obj);
  769. float distance = Commands->Get_Distance (myloc, starloc);
  770. //DEMOif (distance > 70.0f)
  771. if (distance > 300.0f)
  772. {
  773. bool visibility = Commands->Is_Object_Visible(star_obj, obj);
  774. if (!visibility)
  775. {
  776. Commands->Apply_Damage(obj, 10000.0f, "Blamokiller");
  777. }
  778. else
  779. {
  780. Force_Move (obj);
  781. }
  782. }
  783. else
  784. {
  785. Force_Move (obj);
  786. }
  787. }
  788. Commands->Start_Timer(obj, this, 15.0f, 2);
  789. }
  790. else if (timer_id == 3)
  791. {
  792. // Force movement code to prevent irregular activity.
  793. Force_Move (obj);
  794. Commands->Start_Timer(obj, this, 15.0f, 3);
  795. }
  796. else if (timer_id == 4)
  797. {
  798. // Force fire at star code to prevent irregular activity.
  799. Vector3 myloc;
  800. myloc = Commands->Get_Position(obj);
  801. GameObject* starobj = Commands->Get_A_Star(myloc);
  802. if (starobj)
  803. {
  804. Vector3 starloc;
  805. float distance;
  806. starloc = Commands->Get_Position(starobj);
  807. distance = Commands->Get_Distance(myloc, starloc);
  808. if (distance < 150.0f)
  809. {
  810. ActionParamsStruct params;
  811. params.Set_Basic(this, 90, 0);
  812. params.Set_Attack(starobj, 150.0f, 0.0f, true);
  813. Commands->Action_Attack(obj, params);
  814. }
  815. }
  816. Commands->Start_Timer(obj, this, 15.0f, 4);
  817. }
  818. else if (timer_id == 5)
  819. {
  820. // An officer is trying to play an animation.
  821. Vector3 playerloc = Commands->Get_Position (STAR);
  822. Vector3 myloc = Commands->Get_Position(obj);
  823. float distance = Commands->Get_Distance(myloc, playerloc);
  824. if (distance > 10.0f)
  825. {
  826. officeranimcounter++;
  827. if (officeranimcounter > 2)
  828. {
  829. officeranimcounter = 0;
  830. }
  831. switch (officeranimcounter)
  832. {
  833. case (0):
  834. {
  835. GameObject *nearsoldier = Commands->Find_Closest_Soldier (myloc, 1.0f, 50.0f);
  836. if ((nearsoldier) && (nearsoldier != STAR))
  837. {
  838. ActionParamsStruct params;
  839. params.Set_Basic(this, 99, 0);
  840. Vector3 soldierloc = Commands->Get_Position (nearsoldier);
  841. params.Set_Animation ("H_A_J18C", false);
  842. params.Set_Face_Location (soldierloc, 4.0f);
  843. Commands->Action_Play_Animation (obj, params);
  844. }
  845. break;
  846. }
  847. case (1):
  848. {
  849. if (STAR)
  850. {
  851. ActionParamsStruct params;
  852. params.Set_Basic(this, 99, 0);
  853. params.Set_Animation ("H_A_J23C", false);
  854. params.Set_Face_Location (playerloc, 4.0f);
  855. Commands->Action_Play_Animation (obj, params);
  856. }
  857. break;
  858. }
  859. default:
  860. {
  861. if (STAR)
  862. {
  863. ActionParamsStruct params;
  864. params.Set_Basic(this, 99, 0);
  865. params.Set_Animation ("H_A_J27C", false);
  866. params.Set_Face_Location (playerloc, 4.0f);
  867. Commands->Action_Play_Animation (obj, params);
  868. }
  869. break;
  870. }
  871. }
  872. }
  873. Commands->Start_Timer(obj, this, 10.0f, 5);
  874. }
  875. else if (timer_id == 6)
  876. {
  877. Commands->Apply_Damage(obj, 10000.0f, "Blamokiller");
  878. }
  879. else if (timer_id == 7)
  880. {
  881. if (!enemy_seen)
  882. {
  883. // Time to move the chem-warrior. Pick a new location.
  884. Vector3 newloc;
  885. int rndnum = (Get_Int_Random(0.0f,1.0f) * 5);
  886. switch (rndnum)
  887. {
  888. case (0):
  889. {
  890. newloc = Vector3(1301.55f,617.89f,19.66f);
  891. break;
  892. }
  893. case (1):
  894. {
  895. newloc = Vector3(1340.65f,655.04f,19.51f);
  896. break;
  897. }
  898. case (2):
  899. {
  900. newloc = Vector3(1310.67f,694.74f,19.71f);
  901. break;
  902. }
  903. default:
  904. {
  905. newloc = Vector3(1242.26f,646.04f,19.65f);
  906. break;
  907. }
  908. }
  909. ActionParamsStruct params;
  910. params.Set_Basic(this, 31, 0);
  911. params.Set_Movement(newloc, WALK, 10.0f, false);
  912. Commands->Action_Goto(obj, params);
  913. }
  914. else
  915. {
  916. Force_Move (obj);
  917. }
  918. Commands->Start_Timer(obj, this, 30.0f, 7);
  919. }
  920. //DEMO
  921. else if (timer_id == 8)
  922. {
  923. Vector3 mydemopos = Commands->Get_Position (obj);
  924. GameObject* starobj = Commands->Find_Object(403063);
  925. if (starobj)
  926. {
  927. Commands->Send_Custom_Event (obj, starobj, 100, 0);
  928. }
  929. Commands->Start_Timer(obj, this, 10.0f, 8);
  930. }
  931. //DEMO
  932. }
  933. void Force_Move (GameObject* obj)
  934. {
  935. Vector3 mypos = Commands->Get_Position(obj);
  936. //DEMO GameObject *starobj = Commands->Get_A_Star (mypos);
  937. GameObject *starobj = Commands->Find_Object(403063);
  938. //DEMO
  939. if (starobj)
  940. {
  941. ActionParamsStruct params;
  942. params.Set_Basic(this, 90, 0);
  943. params.Set_Movement(starobj, RUN, 10.0f, 0);
  944. params.Set_Attack(starobj, 150.0f, 0.0f, true);
  945. Commands->Action_Attack(obj, params);
  946. }
  947. }
  948. void Killed (GameObject *obj, GameObject *killer)
  949. {
  950. // Tell the respawn controller I am dead.
  951. int param;
  952. param = Get_Int_Parameter("Area_Number");
  953. GameObject * object = Commands->Find_Object(M02_OBJCONTROLLER);
  954. if (object)
  955. {
  956. Commands->Send_Custom_Event (obj, object, 101, param);
  957. }
  958. if (param == 3)
  959. {
  960. int officer = Get_Int_Parameter("Area_Officer");
  961. if (officer)
  962. {
  963. // If a Medium Tank is needed for A03, drop it.
  964. Commands->Send_Custom_Event (obj, object, 111, 2);
  965. }
  966. }
  967. }
  968. void Custom (GameObject *obj, int type, int param, GameObject *sender)
  969. {
  970. if ((type == 0) && (param == 0))
  971. {
  972. Commands->Innate_Enable (obj);
  973. // If the unit is a preplaced minigunner, forced movement code is activated for this unit.
  974. int preplaced = Get_Int_Parameter("Pre_Placed");
  975. if (preplaced == 2)
  976. {
  977. int myid = Commands->Get_ID(obj);
  978. if ((myid != 400512) || (myid != 400513))
  979. {
  980. Commands->Start_Timer(obj, this, 1.0f, 3);
  981. }
  982. }
  983. else if (preplaced == 1)
  984. {
  985. // Unit is an officer, start the animation timer.
  986. Commands->Start_Timer(obj, this, 10.0f, 5);
  987. }
  988. else if (preplaced == 6)
  989. {
  990. // Unit is a chem-warrior, start low priority wandering.
  991. Commands->Start_Timer(obj, this, 1.0f, 7);
  992. }
  993. else if (preplaced == 5)
  994. {
  995. int areanum = Get_Int_Parameter("Area_Number");
  996. if (areanum == 19)
  997. {
  998. // Unit is a technician, who plays an animation in front of a terminal.
  999. ActionParamsStruct params;
  1000. params.Set_Basic(this, 31, 100);
  1001. params.Set_Animation ("H_A_CON2", true);
  1002. Commands->Action_Play_Animation (obj, params);
  1003. }
  1004. }
  1005. }
  1006. if (type == 99)
  1007. {
  1008. if (param == 214)
  1009. {
  1010. // An Objective or Building is asking to be repaired.
  1011. ActionParamsStruct params;
  1012. params.Set_Basic(this, 99, 214);
  1013. params.Set_Movement(sender, RUN, 10.0f, 0);
  1014. Vector3 senderpos = Commands->Get_Position(sender);
  1015. senderpos.Z -= 1.0f;
  1016. params.Set_Attack(senderpos, 10.0f, 0.0f, false);
  1017. Commands->Action_Attack(obj, params);
  1018. }
  1019. else if (param == 202)
  1020. {
  1021. ActionParamsStruct params;
  1022. params.Set_Basic(this, 50, 214);
  1023. params.Set_Movement(Vector3(1113.61f,877.4f,17.15f), RUN, 10.0f, 0);
  1024. params.Set_Attack(Vector3(1113.61f,877.4f,17.15f), 10.0f, 0.0f, false);
  1025. Commands->Action_Attack(obj, params);
  1026. }
  1027. else if (param == 217)
  1028. {
  1029. ActionParamsStruct params;
  1030. params.Set_Basic(this, 50, 214);
  1031. params.Set_Movement(Vector3(1062.24f,978.38f,-16.85f), RUN, 10.0f, 0);
  1032. params.Set_Attack(Vector3(1062.24f,978.38f,-16.85f), 10.0f, 0.0f, false);
  1033. Commands->Action_Attack(obj, params);
  1034. }
  1035. }
  1036. if (!initial_damage)
  1037. {
  1038. if (type == CUSTOM_EVENT_FALLING_DAMAGE)
  1039. {
  1040. initial_health = Commands->Get_Health(obj);
  1041. }
  1042. }
  1043. }
  1044. void Damaged( GameObject * obj, GameObject *damager, float amount)
  1045. {
  1046. if (!initial_damage && damager == NULL)
  1047. {
  1048. initial_damage = true;
  1049. Commands->Set_Health(obj, initial_health);
  1050. }
  1051. }
  1052. };
  1053. // SOLDIER TYPE PARAMETERS FOR GDI
  1054. // 1 = Rocket Soldier
  1055. // 2 = Minigunner Officer
  1056. // 3 = Minigunner Enlisted
  1057. // 4 = Grenadier Enlisted
  1058. DECLARE_SCRIPT (MDD_GDI_Soldier, "Area_ID:int, Soldier_Type=0:int")
  1059. {
  1060. bool stop_following;
  1061. //DEMO
  1062. Vector3 startloc;
  1063. //DEMO
  1064. REGISTER_VARIABLES()
  1065. {
  1066. SAVE_VARIABLE( stop_following, 1);
  1067. }
  1068. void Created(GameObject* obj)
  1069. {
  1070. //DEMO
  1071. Commands->Enable_Hibernation(obj, false);
  1072. startloc = Commands->Get_Position(obj);
  1073. //DEMO
  1074. stop_following = false;
  1075. // Special case checks for preplaced soldiers - A01 currently, others to come.
  1076. int area_id = Get_Int_Parameter("Area_ID");
  1077. if (area_id == 1)
  1078. {
  1079. Commands->Innate_Disable (obj);
  1080. }
  1081. else
  1082. {
  1083. // Default spawned following unit - Give orders to stay near the commando on a timer.
  1084. Commands->Start_Timer(obj, this, 1.0f, 1);
  1085. }
  1086. }
  1087. void Timer_Expired(GameObject * obj, int timer_id)
  1088. {
  1089. if (timer_id == 1)
  1090. {
  1091. int type = Get_Int_Parameter("Soldier_Type");
  1092. if (type < 12)
  1093. {
  1094. Commands->Apply_Damage(obj, 10000.0f, "Blamokiller");
  1095. }
  1096. if (!stop_following)
  1097. {
  1098. // Follow the commando.
  1099. //Start this check timer again.
  1100. Vector3 mypos = Commands->Get_Position(obj);
  1101. //DEMO GameObject *starobj = Commands->Get_A_Star (mypos);
  1102. GameObject *starobj = Commands->Find_Object(403063);
  1103. //DEMO
  1104. if (starobj)
  1105. {
  1106. ActionParamsStruct params;
  1107. params.Set_Basic(this, 71, 0);
  1108. params.Set_Movement(starobj, 1.0f, 10.0f, 0);
  1109. Commands->Action_Goto(obj, params);
  1110. }
  1111. else
  1112. {
  1113. stop_following = true;
  1114. }
  1115. //DEBUG good time to make a quip or comment.
  1116. }
  1117. Commands->Start_Timer(obj, this, 10.0f, 1);
  1118. }
  1119. }
  1120. void Sound_Heard (GameObject * obj, const CombatSound & sound)
  1121. {
  1122. if ((sound.Type > 1099) && (sound.Type < 1199))
  1123. {
  1124. // Make sure this is the sound this unit is supposed to react to.
  1125. int area_id = Get_Int_Parameter("Area_ID");
  1126. if ((sound.Type - 1100) == area_id)
  1127. {
  1128. stop_following = true;
  1129. switch (area_id)
  1130. {
  1131. case (0):
  1132. {
  1133. Vector3 guard_tower_loc = Vector3(128.3f,22.3f,-9.6f);
  1134. ActionParamsStruct params;
  1135. params.Set_Basic(this, 81, 0);
  1136. params.Set_Movement(guard_tower_loc, WALK, 1.0f, 0);
  1137. Commands->Action_Goto(obj, params);
  1138. //DEBUG say something to the commando here indicating a position hold.
  1139. break;
  1140. }
  1141. case (2):
  1142. {
  1143. Vector3 house_loc = Vector3(648.77f,300.74f,-59.99f);
  1144. ActionParamsStruct params;
  1145. params.Set_Basic(this, 81, 0);
  1146. params.Set_Movement(house_loc, WALK, 1.0f, 0);
  1147. Commands->Action_Goto(obj, params);
  1148. //DEBUG say something to the commando here indicating a position hold.
  1149. break;
  1150. }
  1151. }
  1152. }
  1153. }
  1154. }
  1155. void Custom (GameObject *obj, int type, int param, GameObject *sender)
  1156. {
  1157. if ((type == 0) && (param == 0))
  1158. {
  1159. // A zone is trying to enable actions for this soldier.
  1160. Commands->Innate_Enable (obj);
  1161. }
  1162. }
  1163. //DEMO
  1164. void Destroyed (GameObject* obj)
  1165. {
  1166. int type = Get_Int_Parameter("Soldier_Type");
  1167. switch (type)
  1168. {
  1169. case (12):
  1170. {
  1171. GameObject * soldier = Commands->Create_Object("GDI_Grenadier_2SF", startloc);
  1172. if (soldier)
  1173. {
  1174. Commands->Attach_Script(soldier, "MDD_GDI_Soldier", "25, 12");
  1175. }
  1176. break;
  1177. }
  1178. case (13):
  1179. {
  1180. GameObject * soldier = Commands->Create_Object("GDI_MiniGunner_2SF", startloc);
  1181. if (soldier)
  1182. {
  1183. Commands->Attach_Script(soldier, "MDD_GDI_Soldier", "25, 13");
  1184. }
  1185. break;
  1186. }
  1187. case (14):
  1188. {
  1189. GameObject * soldier = Commands->Create_Object("GDI_RocketSoldier_2SF", startloc);
  1190. if (soldier)
  1191. {
  1192. Commands->Attach_Script(soldier, "MDD_GDI_Soldier", "25, 14");
  1193. }
  1194. break;
  1195. }
  1196. }
  1197. }
  1198. //DEMO
  1199. };
  1200. DECLARE_SCRIPT (MDD_Stationary_Vehicle,"Area_ID:int")
  1201. {
  1202. void Created (GameObject* obj)
  1203. {
  1204. //DEMO
  1205. Commands->Set_Shield_Type (obj, "Blamo");
  1206. Commands->Enable_Enemy_Seen (obj, true);
  1207. //DEMO
  1208. int area_id;
  1209. area_id = Get_Int_Parameter("Area_ID");
  1210. // Area One is a conflict area, other stationary vehicles in conflict areas must be paused as well
  1211. //DEMO Commands->Enable_Enemy_Seen (obj, false);
  1212. if (area_id == 99)
  1213. {
  1214. Commands->Start_Timer(obj, this, 6.0f, 1);
  1215. }
  1216. }
  1217. void Enemy_Seen (GameObject * obj, GameObject * enemy)
  1218. {
  1219. ActionParamsStruct params;
  1220. params.Set_Basic(this, 90, 0);
  1221. params.Set_Attack(enemy, 300.0f, 0.0f, true);
  1222. params.AttackCheckBlocked = false;
  1223. Commands->Action_Attack(obj, params);
  1224. Commands->Start_Timer(obj, this, 5.0f, 2);
  1225. }
  1226. void Sound_Heard (GameObject * obj, const CombatSound & sound)
  1227. {
  1228. // If an objective shouts, respond to it, letting it know the area is not cleared.
  1229. if (sound.Type == 1000)
  1230. {
  1231. if (sound.Creator)
  1232. {
  1233. int player_type = Commands->Get_Player_Type (obj);
  1234. if (player_type == SCRIPT_PLAYERTYPE_NOD)
  1235. {
  1236. Commands->Send_Custom_Event(obj, sound.Creator, 100, 1);
  1237. }
  1238. }
  1239. }
  1240. }
  1241. void Custom (GameObject *obj, int type, int param, GameObject *sender)
  1242. {
  1243. if ((type == 0) && (param == 0))
  1244. {
  1245. // A zone is trying to enable actions for this vehicle.
  1246. Commands->Enable_Enemy_Seen (obj, true);
  1247. }
  1248. }
  1249. void Timer_Expired(GameObject * obj, int timer_id)
  1250. {
  1251. if (timer_id == 1)
  1252. {
  1253. Commands->Apply_Damage (obj, 10000.0f, "Blamokiller");
  1254. }
  1255. else if (timer_id == 2)
  1256. {
  1257. Commands->Action_Reset (obj, 100);
  1258. }
  1259. }
  1260. };
  1261. DECLARE_SCRIPT (MDD_Nod_Apache, "Area_ID:int")
  1262. {
  1263. int waypath_id;
  1264. REGISTER_VARIABLES()
  1265. {
  1266. SAVE_VARIABLE( waypath_id, 1);
  1267. }
  1268. void Created (GameObject* obj)
  1269. {
  1270. int area_id = Get_Int_Parameter("Area_ID");
  1271. float timer_len = 1.0f;
  1272. //First waypath means area for looping Apaches, it is set when timer expires, and then uses real IDs.
  1273. switch (area_id)
  1274. {
  1275. case (0):
  1276. {
  1277. waypath_id = 0;
  1278. timer_len = 8.0f;
  1279. break;
  1280. }
  1281. case (15):
  1282. {
  1283. waypath_id = 1;
  1284. timer_len = 15.0f;
  1285. break;
  1286. }
  1287. case (24):
  1288. {
  1289. waypath_id = 24;
  1290. break;
  1291. }
  1292. }
  1293. Commands->Enable_Engine(obj, true);
  1294. Commands->Disable_Physical_Collisions(obj);
  1295. Commands->Start_Timer(obj, this, timer_len, 1);
  1296. Commands->Start_Timer(obj, this, 15.0f, 3);
  1297. }
  1298. void Timer_Expired(GameObject * obj, int timer_id)
  1299. {
  1300. if (timer_id == 1)
  1301. {
  1302. // Delayed initial action.
  1303. switch (waypath_id)
  1304. {
  1305. case (0): // Area 0 Apache delay timer expired, start movement
  1306. {
  1307. waypath_id = 400296;
  1308. break;
  1309. }
  1310. case (1): // Area 15 Apache delay timer expired, start movement.
  1311. {
  1312. waypath_id = 401169;
  1313. break;
  1314. }
  1315. case (24):
  1316. {
  1317. waypath_id = 400544;
  1318. break;
  1319. }
  1320. case (400296):
  1321. {
  1322. waypath_id = 400304;
  1323. break;
  1324. }
  1325. case (400304):
  1326. {
  1327. waypath_id = 400310;
  1328. break;
  1329. }
  1330. case (400310):
  1331. {
  1332. waypath_id = 400304;
  1333. break;
  1334. }
  1335. case (400544):
  1336. {
  1337. waypath_id = -1;
  1338. break;
  1339. }
  1340. case (401169):
  1341. {
  1342. waypath_id = 401173;
  1343. break;
  1344. }
  1345. case (401173):
  1346. {
  1347. waypath_id = 401180;
  1348. break;
  1349. }
  1350. case (401180):
  1351. {
  1352. waypath_id = 401173;
  1353. break;
  1354. }
  1355. }
  1356. if (waypath_id != -1)
  1357. {
  1358. ActionParamsStruct params;
  1359. params.Set_Basic(this, 90, 0);
  1360. params.Set_Movement(Vector3(0,0,0), 0.2 + (0.1 * DIFFICULTY), 5.0f);
  1361. params.WaypathID = waypath_id;
  1362. params.WaypathSplined = true;
  1363. params.Set_Attack(STAR, 200.0f, 0.0f, true);
  1364. params.AttackCheckBlocked = false;
  1365. params.AttackActive = false;
  1366. Commands->Action_Attack(obj, params);
  1367. }
  1368. Commands->Start_Timer(obj, this, 5.0f, 2);
  1369. }
  1370. else if (timer_id == 2)
  1371. {
  1372. // Time to start firing, and move again in a second.
  1373. Vector3 myloc = Commands->Get_Position(obj);
  1374. //DEMO
  1375. GameObject* target = Commands->Find_Object(403063);
  1376. //DEMO
  1377. ActionParamsStruct params;
  1378. params.Set_Basic(this, 90, 0);
  1379. params.Set_Movement(myloc, 0.0, 5.0f);
  1380. //DEMO params.Set_Attack(STAR, 200.0f, 0.0f, true);
  1381. params.Set_Attack(target, 200.0f, 0.0f, true);
  1382. //DEMO
  1383. params.AttackCheckBlocked = false;
  1384. params.AttackActive = true;
  1385. Commands->Action_Attack(obj, params);
  1386. Commands->Start_Timer(obj, this, 5.0f, 1);
  1387. }
  1388. else if (timer_id == 3)
  1389. {
  1390. // Cleanup code - find the nearest star, check distance.
  1391. float distance;
  1392. Vector3 myloc;
  1393. Vector3 starloc;
  1394. myloc = Commands->Get_Position(obj);
  1395. GameObject *star_obj = Commands->Get_A_Star(myloc);
  1396. if (star_obj)
  1397. {
  1398. starloc = Commands->Get_Position(star_obj);
  1399. distance = Commands->Get_Distance (myloc, starloc);
  1400. //DEMO if (distance > 300.0f)
  1401. if (distance > 3000.0f)
  1402. //DEMO
  1403. {
  1404. Commands->Apply_Damage(obj, 10000.0f, "Blamokiller");
  1405. }
  1406. }
  1407. Commands->Start_Timer(obj, this, 15.0f, 3);
  1408. }
  1409. }
  1410. // If an objective shouts, respond to it, letting it know the area is not cleared.
  1411. void Sound_Heard (GameObject * obj, const CombatSound & sound)
  1412. {
  1413. if (sound.Type == 1000)
  1414. {
  1415. if (sound.Creator)
  1416. {
  1417. Commands->Send_Custom_Event(obj, sound.Creator, 100, 1);
  1418. }
  1419. }
  1420. }
  1421. };
  1422. DECLARE_SCRIPT (MDD_Nod_Stealth, "")
  1423. {
  1424. bool nofiring;
  1425. void Created (GameObject* obj)
  1426. {
  1427. Commands->Enable_Hibernation(obj, false);
  1428. nofiring = true;
  1429. Commands->Enable_Enemy_Seen (obj, true);
  1430. ActionParamsStruct params;
  1431. params.Set_Basic(this, 99, 0);
  1432. params.Set_Movement(Vector3(0,0,0), 2.5f, 1.0f);
  1433. params.WaypathID = 401465;
  1434. Commands->Action_Goto(obj, params);
  1435. Commands->Start_Timer(obj, this, 10.0f, 1);
  1436. Commands->Start_Timer(obj, this, 2.0f, 3);
  1437. }
  1438. void Enemy_Seen (GameObject * obj, GameObject * enemy)
  1439. {
  1440. if (!nofiring)
  1441. {
  1442. nofiring = true;
  1443. ActionParamsStruct params;
  1444. params.Set_Basic(this, 99, 0);
  1445. params.Set_Attack(enemy, 200.0f, 0.0f, true);
  1446. params.AttackActive = true;
  1447. Commands->Action_Attack (obj, params);
  1448. Commands->Start_Timer(obj, this, 10.0f, 2);
  1449. }
  1450. }
  1451. void Timer_Expired(GameObject * obj, int timer_id)
  1452. {
  1453. if (timer_id == 1)
  1454. {
  1455. nofiring = false;
  1456. }
  1457. else if (timer_id == 2)
  1458. {
  1459. ActionParamsStruct params;
  1460. params.Set_Basic(this, 99, 0);
  1461. params.Set_Movement(Vector3(0,0,0), 2.5f, 1.0f);
  1462. params.WaypathID = 401465;
  1463. Commands->Action_Goto(obj, params);
  1464. Commands->Start_Timer(obj, this, 10.0f, 1);
  1465. }
  1466. else if (timer_id == 3)
  1467. {
  1468. Vector3 myloc = Commands->Get_Position (obj);
  1469. Commands->Create_Logical_Sound (obj, 1999, myloc, 10.0f);
  1470. Commands->Start_Timer(obj, this, 2.0f, 3);
  1471. }
  1472. }
  1473. void Destroyed (GameObject* obj)
  1474. {
  1475. GameObject * nodtank = Commands->Create_Object("Nod_Stealth_Tank", Vector3(598.777f,479.691f,-55.824f));
  1476. if (nodtank)
  1477. {
  1478. Commands->Set_Facing(nodtank, -100.0f);
  1479. Commands->Attach_Script(nodtank, "MDD_Nod_Stealth", "");
  1480. }
  1481. }
  1482. };
  1483. DECLARE_SCRIPT (MDD_Flying_Vehicle, "Unit_ID:int")
  1484. {
  1485. void Created (GameObject* obj)
  1486. {
  1487. Commands->Enable_Hibernation(obj, false);
  1488. Commands->Enable_Enemy_Seen (obj, true);
  1489. int unit_id = Get_Int_Parameter ("Unit_ID");
  1490. int waypath_id = 0;
  1491. if (unit_id)
  1492. {
  1493. waypath_id = 402786;
  1494. }
  1495. else
  1496. {
  1497. waypath_id = 402768;
  1498. }
  1499. Commands->Enable_Engine(obj, true);
  1500. Commands->Disable_Physical_Collisions(obj);
  1501. ActionParamsStruct params;
  1502. params.Set_Basic(this, 99, 0);
  1503. params.Set_Movement(Vector3(0,0,0), 2.5f, 1.0f);
  1504. params.WaypathID = waypath_id;
  1505. params.WaypathSplined = true;
  1506. Commands->Action_Goto(obj, params);
  1507. Commands->Start_Timer(obj, this, 15.0f, 1);
  1508. }
  1509. void Enemy_Seen (GameObject * obj, GameObject * enemy)
  1510. {
  1511. ActionParamsStruct params;
  1512. params.Set_Basic(this, 92, 2);
  1513. params.AttackCheckBlocked = false;
  1514. params.Set_Attack(enemy, 300.0f, 0.0f, true);
  1515. Commands->Action_Attack(obj, params);
  1516. }
  1517. void Timer_Expired(GameObject * obj, int timer_id)
  1518. {
  1519. if (timer_id == 1)
  1520. {
  1521. Vector3 myloc = Commands->Get_Position(obj);
  1522. ActionParamsStruct params;
  1523. params.Set_Basic(this, 99, 1);
  1524. params.Set_Movement(myloc, 0.0, 5.0f);
  1525. Commands->Action_Goto(obj, params);
  1526. Commands->Start_Timer(obj, this, 10.0f, 2);
  1527. }
  1528. else if (timer_id == 2)
  1529. {
  1530. int waypath_id = 0;
  1531. ActionParamsStruct params;
  1532. params.Set_Basic(this, 99, 0);
  1533. params.Set_Movement(Vector3(0,0,0), 2.5f, 1.0f);
  1534. int unit_id = Get_Int_Parameter ("Unit_ID");
  1535. if (unit_id)
  1536. {
  1537. waypath_id = 402798;
  1538. }
  1539. else
  1540. {
  1541. waypath_id = 402777;
  1542. }
  1543. params.WaypathID = waypath_id;
  1544. params.WaypathSplined = true;
  1545. Commands->Action_Goto(obj, params);
  1546. Commands->Start_Timer(obj, this, 15.0f, 3);
  1547. }
  1548. else
  1549. {
  1550. Commands->Apply_Damage(obj, 10000.0f, "Blamokiller");
  1551. }
  1552. }
  1553. void Destroyed (GameObject* obj)
  1554. {
  1555. GameObject * object = Commands->Find_Object(M02_OBJCONTROLLER);
  1556. if (object)
  1557. {
  1558. int unit_id = Get_Int_Parameter ("Unit_ID");
  1559. if (!unit_id)
  1560. {
  1561. Commands->Send_Custom_Event(obj, object, 180, 0);
  1562. }
  1563. else
  1564. {
  1565. Commands->Send_Custom_Event(obj, object, 181, 0);
  1566. }
  1567. }
  1568. }
  1569. };
  1570. DECLARE_SCRIPT (MDD_Commando, "")
  1571. {
  1572. void Created (GameObject* obj)
  1573. {
  1574. Commands->Control_Enable (obj, false);
  1575. Commands->Set_Shield_Type (obj, "Blamo");
  1576. }
  1577. };
  1578. DECLARE_SCRIPT (MDD_Havoc_Unit, "")
  1579. {
  1580. bool forcemove;
  1581. void Created (GameObject* obj)
  1582. {
  1583. Commands->Enable_Hibernation(obj, false);
  1584. forcemove = true;
  1585. Commands->Set_Shield_Type (obj, "Blamo");
  1586. Commands->Set_Shield_Strength (obj, 100.0f);
  1587. Commands->Start_Timer(obj, this, 5.0f, 1);
  1588. // move to the center of the field
  1589. ActionParamsStruct params;
  1590. params.Set_Basic(this, 99, 1);
  1591. params.Set_Movement(Vector3(544.119f,339.562f,-60.75f), 1.0, 20.0f);
  1592. Commands->Action_Goto(obj, params);
  1593. }
  1594. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  1595. {
  1596. if ((type == 100) && (param == 0))
  1597. {
  1598. if (forcemove)
  1599. {
  1600. forcemove = false;
  1601. ActionParamsStruct params;
  1602. params.Set_Basic(this, 70, 1);
  1603. params.Set_Movement(sender, 1.0, 1.0f);
  1604. Commands->Action_Goto(obj, params);
  1605. }
  1606. }
  1607. }
  1608. void Timer_Expired(GameObject * obj, int timer_id)
  1609. {
  1610. if (timer_id == 1)
  1611. {
  1612. forcemove = true;
  1613. Commands->Start_Timer(obj, this, 10.0f, 1);
  1614. }
  1615. }
  1616. void Sound_Heard (GameObject * obj, const CombatSound & sound)
  1617. {
  1618. if (sound.Type == 1999)
  1619. {
  1620. if (sound.Creator)
  1621. {
  1622. ActionParamsStruct params;
  1623. params.Set_Basic(this, 99, 1);
  1624. params.Set_Movement(Vector3(544.119f,339.562f,-60.75f), 1.0, 20.0f);
  1625. Commands->Action_Goto(obj, params);
  1626. }
  1627. }
  1628. }
  1629. };