Test_DME.cpp 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  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. * VERSION INFO
  25. * $Author: Dan_e $
  26. * $Revision: 39 $
  27. * $Modtime: 1/07/02 2:51p $
  28. * $Archive: /Commando/Code/Scripts/Test_DME.cpp $
  29. *
  30. ******************************************************************************/
  31. #include "toolkit.h"
  32. #define DME_OCCUPIED 13000
  33. DECLARE_SCRIPT (DME_Test_Powerup, "")
  34. {
  35. int reward_type;
  36. REGISTER_VARIABLES()
  37. {
  38. SAVE_VARIABLE(reward_type, 1);
  39. }
  40. void Killed( GameObject * obj, GameObject * killer )
  41. {
  42. Commands->Trigger_Spawner ( 100022 );
  43. reward_type = Get_Int_Random(0, 7);
  44. Vector3 enemy_loc = Commands->Get_Position ( obj );
  45. enemy_loc.Z += 1.0f;
  46. switch (reward_type)
  47. {
  48. case 0:
  49. {
  50. GameObject *spawn_objectarmor;
  51. spawn_objectarmor = Commands->Create_Object( "Spawner Created Special Effect", enemy_loc );
  52. if (spawn_objectarmor)
  53. {
  54. Commands->Attach_Script( spawn_objectarmor, "M00_Create_Anim_Effect_DAY", "C4_EX1A.C4_EX1A");
  55. }
  56. GameObject *armor;
  57. armor = Commands->Create_Object ( "Armor 025 PowerUp", enemy_loc );
  58. Commands->Attach_Script (armor, "DME_Destroy_Item", "15.0f");
  59. break;
  60. }
  61. case 1:
  62. {
  63. GameObject *spawn_objectarmor;
  64. spawn_objectarmor = Commands->Create_Object( "Spawner Created Special Effect", enemy_loc );
  65. if (spawn_objectarmor)
  66. {
  67. Commands->Attach_Script( spawn_objectarmor, "M00_Create_Anim_Effect_DAY", "C4_EX1A.C4_EX1A");
  68. }
  69. GameObject *armor;
  70. armor = Commands->Create_Object ( "Armor 050 PowerUp", enemy_loc );
  71. Commands->Attach_Script (armor, "DME_Destroy_Item", "15.0f");
  72. break;
  73. }
  74. case 2:
  75. {
  76. GameObject *spawn_objectarmor;
  77. spawn_objectarmor = Commands->Create_Object( "Spawner Created Special Effect", enemy_loc );
  78. if (spawn_objectarmor)
  79. {
  80. Commands->Attach_Script( spawn_objectarmor, "M00_Create_Anim_Effect_DAY", "C4_EX1A.C4_EX1A");
  81. }
  82. GameObject *armor;
  83. armor = Commands->Create_Object ( "Armor 100 PowerUp", enemy_loc );
  84. Commands->Attach_Script (armor, "DME_Destroy_Item", "15.0f");
  85. break;
  86. }
  87. case 3:
  88. {
  89. GameObject *spawn_objectarmor;
  90. spawn_objectarmor = Commands->Create_Object( "Spawner Created Special Effect", enemy_loc );
  91. if (spawn_objectarmor)
  92. {
  93. Commands->Attach_Script( spawn_objectarmor, "M00_Create_Anim_Effect_DAY", "C4_EX1A.C4_EX1A");
  94. }
  95. GameObject *armor;
  96. armor = Commands->Create_Object ( "Health 025 PowerUp", enemy_loc );
  97. Commands->Attach_Script (armor, "DME_Destroy_Item", "15.0f");
  98. break;
  99. }
  100. case 4:
  101. {
  102. GameObject *spawn_objectarmor;
  103. spawn_objectarmor = Commands->Create_Object( "Spawner Created Special Effect", enemy_loc );
  104. if (spawn_objectarmor)
  105. {
  106. Commands->Attach_Script( spawn_objectarmor, "M00_Create_Anim_Effect_DAY", "C4_EX1A.C4_EX1A");
  107. }
  108. GameObject *armor;
  109. armor = Commands->Create_Object ( "Health 050 PowerUp", enemy_loc );
  110. Commands->Attach_Script (armor, "DME_Destroy_Item", "15.0f");
  111. break;
  112. }
  113. case 5:
  114. {
  115. GameObject *spawn_objectarmor;
  116. spawn_objectarmor = Commands->Create_Object( "Spawner Created Special Effect", enemy_loc );
  117. if (spawn_objectarmor)
  118. {
  119. Commands->Attach_Script( spawn_objectarmor, "M00_Create_Anim_Effect_DAY", "C4_EX1A.C4_EX1A");
  120. }
  121. GameObject *armor;
  122. armor = Commands->Create_Object ( "Health 100 PowerUp", enemy_loc );
  123. Commands->Attach_Script (armor, "DME_Destroy_Item", "15.0f");
  124. break;
  125. }
  126. case 6:
  127. {
  128. GameObject *spawn_objectarmor;
  129. spawn_objectarmor = Commands->Create_Object( "Spawner Created Special Effect", enemy_loc );
  130. if (spawn_objectarmor)
  131. {
  132. Commands->Attach_Script( spawn_objectarmor, "M00_Create_Anim_Effect_DAY", "C4_EX1A.C4_EX1A");
  133. }
  134. GameObject *armor;
  135. armor = Commands->Create_Object ( "Shotgun Weapon PowerUps", enemy_loc );
  136. Commands->Attach_Script (armor, "DME_Destroy_Item", "15.0f");
  137. break;
  138. }
  139. case 7:
  140. {
  141. GameObject *spawn_objectarmor;
  142. spawn_objectarmor = Commands->Create_Object( "Spawner Created Special Effect", enemy_loc );
  143. if (spawn_objectarmor)
  144. {
  145. Commands->Attach_Script( spawn_objectarmor, "M00_Create_Anim_Effect_DAY", "C4_EX1A.C4_EX1A");
  146. }
  147. GameObject *armor;
  148. armor = Commands->Create_Object ( "MiniGun Weapon PowerUps", enemy_loc );
  149. Commands->Attach_Script (armor, "DME_Destroy_Item", "15.0f");
  150. break;
  151. }
  152. default:
  153. {
  154. Commands->Debug_Message ("********NO POWER-UP CREATED********");
  155. break;
  156. }
  157. }
  158. }
  159. };
  160. DECLARE_SCRIPT (DME_Destroy_Item, "timer_length: float")
  161. {
  162. void Created( GameObject * obj )
  163. {
  164. float timer_length = Get_Float_Parameter("timer_length");
  165. Commands->Start_Timer(obj, this, timer_length, 10);
  166. }
  167. void Timer_Expired (GameObject* obj, int timer_id)
  168. {
  169. if (timer_id ==10)
  170. {
  171. Commands->Destroy_Object (obj);
  172. }
  173. }
  174. };
  175. DECLARE_SCRIPT (DME_Waypath_test, "")
  176. {
  177. void Created ( GameObject * obj )
  178. {
  179. ActionParamsStruct params;
  180. params.Set_Basic( this, 100, 10 );
  181. params.Set_Movement( Vector3(0,0,0), 1.5f, 0 );
  182. params.WaypathID = 100036;
  183. params.WaypointStartID = 100037;
  184. params.WaypointEndID = 100039;
  185. params.WaypathSplined = true;
  186. Commands->Action_Goto( obj, params );
  187. }
  188. };
  189. DECLARE_SCRIPT (DME_Test_Ejected_Soldier, "")
  190. {
  191. void Killed ( GameObject * obj, GameObject * killer )
  192. {
  193. Vector3 spawn_loc = Commands->Get_Position ( obj );
  194. spawn_loc.Z -= 30.0f;
  195. GameObject *spawn_objectsoldier;
  196. spawn_objectsoldier = Commands->Create_Object( "Spawner Created Special Effect", spawn_loc );
  197. GameObject *soldier;
  198. soldier = Commands->Create_Object ( "Nod_Technician_0", spawn_loc );
  199. Commands->Attach_Script (soldier, "DME_Test_Paradrop", "");
  200. }
  201. };
  202. DECLARE_SCRIPT (DME_Test_Paradrop, "")
  203. {
  204. void Created ( GameObject * obj )
  205. {
  206. /*Vector3 loc = Commands->Get_Position ( obj );
  207. GameObject *para1;
  208. para1 = Commands->Create_Object_At_Bone (obj, "Generic_Cinematic", "C HEAD");
  209. Commands->Attach_To_Object_Bone( obj, para1, "C HEAD" );
  210. Commands->Set_Model(para1, "X5D_Parachute");
  211. Commands->Set_Animation(para1, "X5D_Parachute.X5D_ParaC_1", false);
  212. Commands->Create_3D_Sound_At_Bone("parachute_open", para1, "ROOTTRANSFORM");*/
  213. Commands->Start_Timer (obj, this, .8385f, 10);
  214. Vector3 loc = Commands->Get_Position ( obj );
  215. float facing = Commands->Get_Facing(obj);
  216. GameObject *box1 = Commands->Create_Object("Generic_Cinematic", loc);
  217. Commands->Set_Model(box1, "X5D_Box01");
  218. Commands->Set_Facing(box1, facing);
  219. Commands->Set_Animation(box1, "X5D_Box01.X5D_Box01", false);
  220. GameObject *soldier1;
  221. soldier1 = Commands->Create_Object_At_Bone(box1, "Nod_Technician_0", "Box01");
  222. Commands->Set_Facing(soldier1, facing);
  223. Commands->Attach_Script(soldier1, "RMV_Trigger_Killed", "1144444, 1000, 1000");
  224. Commands->Attach_To_Object_Bone( soldier1, box1, "Box01" );
  225. Commands->Set_Animation(soldier1, "s_a_human.H_A_X5D_ParaT_1", false);
  226. }
  227. void Timer_Expired (GameObject* obj, int timer_id)
  228. {
  229. if (timer_id == 10)
  230. {
  231. GameObject *para1;
  232. Vector3 loc = Commands->Get_Position ( obj );
  233. loc.Z += 1.5;
  234. float facing = Commands->Get_Facing(obj);
  235. para1 = Commands->Create_Object("Generic_Cinematic", loc);
  236. Commands->Set_Facing(para1, facing);
  237. Commands->Set_Model(para1, "X5D_Parachute");
  238. Commands->Set_Animation(para1, "X5D_Parachute.X5D_ParaC_1", false);
  239. Commands->Create_3D_Sound_At_Bone("parachute_open", para1, "ROOTTRANSFORM");
  240. Commands->Attach_Script(para1, "M03_No_More_Parachute", "");
  241. }
  242. }
  243. };
  244. DECLARE_SCRIPT (DME_Test_Worker_Wander, "Work_Area=3:int")
  245. {
  246. int loc_id [20], count, choice, last_loc, poke_choice;
  247. int area_range, area_start, area_end;
  248. char area_anim [9];
  249. bool work_done[20], star_seen, poked, reward_given, anim_playing;
  250. float facing;
  251. Vector3 location;
  252. GameObject *destination_object;
  253. void init () //initializes count and work_done values.
  254. {
  255. int x;
  256. count = 0;
  257. for (x = area_start; x <= area_end; x++)
  258. {
  259. work_done [x] = 1;
  260. }
  261. }
  262. void Custom (GameObject* obj, int type, int param, GameObject* sender) //recieves custom from dave's arrow as to if the location is occupied or not.
  263. { //100 not occupied, 200 is occupied.
  264. if (type == DME_OCCUPIED && param == 100)
  265. {
  266. Commands->Send_Custom_Event(obj, sender, 70, 70); //if not occupied, sends custom to set status to occupied.
  267. }
  268. else if (type == 200 && param == 200)
  269. {
  270. Commands->Debug_Message("Custom received on worker type: %d param: %d sender_id %d. \n", type, param, Commands->Get_ID(sender));
  271. Worker_Loop (obj); //if occupied, tells worker to choose a now location.
  272. }
  273. }
  274. void Worker_Loop ( GameObject * obj ) //this is the main function that checks if the location is occupied
  275. { //and if it is not, tells the servant to go to that location.
  276. if (count == area_range)
  277. {
  278. init ();
  279. }
  280. GameObject *work_loc;
  281. choice = Get_Int_Random (area_start, area_end);
  282. while (work_done [choice] == 0 || choice == last_loc)
  283. {
  284. choice = Get_Int_Random (area_start, area_end);
  285. }
  286. work_done [choice] = 0;
  287. last_loc = choice;
  288. count++;
  289. destination_object = Commands->Find_Object (loc_id [choice]);
  290. Commands->Send_Custom_Event(obj, destination_object, 50, 50, 0.5f);
  291. work_loc = Commands->Find_Object (loc_id [choice]);
  292. location = Commands->Get_Position ( work_loc );
  293. facing = Commands->Get_Facing (work_loc);
  294. ActionParamsStruct params;
  295. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN - 1, 90 );
  296. params.Set_Movement( location, WALK, 0.0f );
  297. Commands->Action_Goto( obj, params );
  298. }
  299. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason ) //this is called when the servant reaches the destination location.
  300. { //the purpose of this function is to have the servant perform their destination animation.
  301. Vector3 current_loc = Commands->Get_Position ( obj );
  302. float distance = Commands->Get_Distance ( current_loc, location );
  303. if (action_id == 90)
  304. {
  305. if (star_seen == false && distance <= 3.0f)
  306. {
  307. anim_playing = true;
  308. Commands->Start_Timer (obj, this, 2.0f, 500);
  309. Commands->Set_Facing(obj, facing);
  310. ActionParamsStruct params;
  311. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 1);
  312. params.Set_Animation( area_anim, true );
  313. Commands->Action_Play_Animation (obj, params);
  314. }
  315. }
  316. }
  317. void Created ( GameObject * obj ) //this is the created function for the servant, it sets up most of the variables.
  318. {
  319. int work_area = Get_Int_Parameter("Work_Area");
  320. Commands->Set_Player_Type( obj, 0 );
  321. Commands->Innate_Disable( obj );
  322. poke_choice = 3; //Get_Int_Random (1, 3);
  323. star_seen = false;
  324. reward_given = false;
  325. poked = false;
  326. anim_playing = false;
  327. loc_id [0] = 100001; //these are the dave's arrow id's for all 3 work areas.
  328. loc_id [1] = 100002;
  329. loc_id [2] = 100003;
  330. loc_id [3] = 2000217;
  331. loc_id [4] = 2000218;
  332. loc_id [5] = 2000219;
  333. loc_id [6] = 2000220;
  334. loc_id [7] = 2000221;
  335. loc_id [8] = 2000222;
  336. loc_id [9] = 2000223;
  337. loc_id [10] = 2000224;
  338. loc_id [11] = 2000225;
  339. loc_id [12] = 2000226;
  340. loc_id [13] = 2000227;
  341. loc_id [14] = 2000228;
  342. loc_id [15] = 2000229;
  343. loc_id [16] = 2000230;
  344. loc_id [17] = 2000231;
  345. loc_id [18] = 2000232;
  346. loc_id [19] = 2000233;
  347. //Area 1 Variables.
  348. if (work_area == 1)
  349. {
  350. area_range = 3;
  351. area_start = 0;
  352. area_end = 2;
  353. sprintf(area_anim, "%s", "H_A_a0f0");
  354. }
  355. //Area 2 Variables.
  356. else if (work_area == 2)
  357. {
  358. area_range = 4;
  359. area_start = 12;
  360. area_end = 15;
  361. sprintf(area_anim, "%s", "H_A_a0f0");
  362. }
  363. //Area 3 Variables.
  364. else if (work_area == 3)
  365. {
  366. area_range = 4;
  367. area_start = 16;
  368. area_end = 19;
  369. sprintf(area_anim, "%s", "H_A_a0f0");
  370. }
  371. init ();
  372. Worker_Loop (obj);
  373. }
  374. void Timer_Expired (GameObject* obj, int timer_id)
  375. {
  376. if (timer_id == 500) //this timer resets the servant from his animation loop and calls Worker_Loop to send him to a new location.
  377. {
  378. anim_playing = false;
  379. Commands->Action_Reset(obj, 99);
  380. Commands->Set_Animation( obj, NULL, false );
  381. destination_object = Commands->Find_Object (loc_id [choice]);
  382. Commands->Send_Custom_Event(obj, destination_object, 90, 90);
  383. Worker_Loop (obj);
  384. }
  385. else if (timer_id == 510) //this timer resets the servant after seeing the star. He completes his animation and returns to work.
  386. {
  387. star_seen = false;
  388. Commands->Action_Reset(obj, 99);
  389. Commands->Set_Animation( obj, "H_A_HOST_L1B", false );
  390. Commands->Set_Animation_Frame(obj, "H_A_HOST_L1B", 16);
  391. Worker_Loop (obj);
  392. }
  393. else if (timer_id == 520) //this timer is a general reset after being poked.
  394. {
  395. poked = false;
  396. Commands->Set_Player_Type( obj, 0 );
  397. Worker_Loop ( obj );
  398. }
  399. else if (timer_id == 530) //this timer resets the servant after giving the star assistance.
  400. {
  401. poked = false;
  402. Worker_Loop ( obj );
  403. }
  404. }
  405. void Enemy_Seen (GameObject* obj, GameObject* enemy) //this function sets the servant in a "don't hurt me!" stance (based on a timer)
  406. {
  407. if (star_seen == false)
  408. {
  409. if (anim_playing == false)
  410. {
  411. destination_object = Commands->Find_Object (loc_id [choice]);
  412. Commands->Send_Custom_Event(obj, destination_object, 90, 90);
  413. star_seen = true;
  414. Commands->Start_Timer (obj, this, 9.0f, 510);
  415. const char *conv_name = ("IDS_M06_DME");
  416. int conv_id = Commands->Create_Conversation (conv_name);
  417. Commands->Join_Conversation(obj, conv_id, false, false);
  418. Commands->Start_Conversation (conv_id, 1);
  419. ActionParamsStruct params;
  420. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN, 1);
  421. params.Set_Animation( "H_A_HOST_L1B", true );
  422. Commands->Action_Play_Animation (obj, params);
  423. }
  424. }
  425. }
  426. void Poked(GameObject * obj, GameObject * poker) //function runs from a pre-defined random poke_choice.
  427. {
  428. if (poked == !true)
  429. {
  430. Commands->Set_Player_Type( obj, -2 );
  431. destination_object = Commands->Find_Object (loc_id [choice]);
  432. Commands->Send_Custom_Event(obj, destination_object, 90, 90);
  433. poked = true;
  434. switch (poke_choice)
  435. {
  436. case 1: //call for guards
  437. {
  438. Commands->Start_Timer (obj, this, 5.0f, 520);
  439. const char *conv_name = ("IDS_M06_DME02");
  440. int conv_id = Commands->Create_Conversation (conv_name);
  441. Commands->Join_Conversation(obj, conv_id, false, false);
  442. Commands->Start_Conversation (conv_id, 1);
  443. Commands->Create_Logical_Sound(obj, SOUND_TYPE_GUNSHOT, Commands->Get_Position(obj), 75.0f);
  444. }
  445. break;
  446. case 2: //sound alarm
  447. {
  448. Commands->Start_Timer (obj, this, 5.0f, 520);
  449. const char *conv_name = ("IDS_M06_D05");
  450. int conv_id = Commands->Create_Conversation (conv_name);
  451. Commands->Join_Conversation(obj, conv_id, false, false);
  452. Commands->Start_Conversation (conv_id, 1);
  453. }
  454. break;
  455. case 3: //give assistance
  456. {
  457. if (reward_given == false)
  458. {
  459. Commands->Action_Reset(obj, 99);
  460. Commands->Set_Animation( obj, "H_A_HOST_L1B", false );
  461. Commands->Set_Animation_Frame(obj, "H_A_HOST_L1B", 16);
  462. reward_given = true; //records that the reward has been given.
  463. int reward_type = Get_Int_Random(0, 5);
  464. Commands->Start_Timer (obj, this, 5.0f, 530);
  465. const char *conv_name = ("IDS_M06_DME3"); //starts conversation.
  466. int conv_id = Commands->Create_Conversation (conv_name);
  467. Commands->Join_Conversation(obj, conv_id, false, false);
  468. Commands->Start_Conversation (conv_id, 1);
  469. Vector3 pos = Commands->Get_Position(obj); //specifies drop location and plays droping anim.
  470. float facing = Commands->Get_Facing(obj);
  471. Commands->Set_Animation( obj, "H_A_J12C", false );
  472. float a = cos(DEG_TO_RADF(facing)) * 1.5;
  473. float b = sin(DEG_TO_RADF(facing)) * 1.5;
  474. Vector3 powerup_loc = pos + Vector3(a, b, 0.5f);
  475. switch (reward_type) //random reward type.
  476. {
  477. case 0:
  478. {
  479. Commands->Create_Object("Armor 025 PowerUp", powerup_loc);
  480. }
  481. break;
  482. case 1:
  483. {
  484. Commands->Create_Object("Armor 050 PowerUp", powerup_loc);
  485. }
  486. break;
  487. case 2:
  488. {
  489. Commands->Create_Object("Armor 100 PowerUp", powerup_loc);
  490. }
  491. break;
  492. case 3:
  493. {
  494. Commands->Create_Object("Health 025 PowerUp", powerup_loc);
  495. }
  496. break;
  497. case 4:
  498. {
  499. Commands->Create_Object("Health 025 PowerUp", powerup_loc);
  500. }
  501. break;
  502. case 5:
  503. {
  504. Commands->Create_Object("Health 025 PowerUp", powerup_loc);
  505. }
  506. break;
  507. }
  508. }
  509. else
  510. {
  511. Commands->Start_Timer (obj, this, 3.0f, 530);
  512. }
  513. }
  514. break;
  515. default:
  516. {
  517. Commands->Debug_Message ("********poke_choice out of range");
  518. break;
  519. }
  520. }
  521. }
  522. }
  523. };
  524. DECLARE_SCRIPT (DME_Test_Work_Area, "") //this script needs to be placed on all daves arrows.
  525. { //the script takes and returns customs to tell servants if a location is occupied.
  526. bool occupied; //type & param info:
  527. //50 - is destination occupied?
  528. void Created( GameObject * obj ) // 100 - no
  529. { // 200 - yes
  530. occupied = false; //70 - change occupied status to true
  531. } //90 - change occupied status to false
  532. void Custom (GameObject* obj, int type, int param, GameObject* sender)
  533. {
  534. if (type == 50 && param == 50)
  535. {
  536. if (!occupied)
  537. {
  538. Commands->Debug_Message("Not occupied\n");
  539. Commands->Send_Custom_Event(obj, sender, DME_OCCUPIED, 100);
  540. }
  541. else
  542. {
  543. Commands->Debug_Message("Occupied\n");
  544. Commands->Send_Custom_Event(obj, sender, 200, 200);
  545. }
  546. }
  547. else if (type == 70 && param == 70)
  548. {
  549. occupied = true;
  550. }
  551. else if (type == 90 && param == 90)
  552. {
  553. occupied = false;
  554. }
  555. }
  556. };
  557. DECLARE_SCRIPT (M05_Tank_Drop_01_DME, "")
  558. {
  559. bool entered;
  560. void Created ( GameObject * obj)
  561. {
  562. entered = false;
  563. }
  564. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  565. {
  566. if (entered == false)
  567. {
  568. if (type == CUSTOM_EVENT_VEHICLE_ENTERED && Commands->Is_A_Star(sender))
  569. {
  570. entered = true;
  571. Vector3 drop_loc;
  572. drop_loc.X = -476.07f;
  573. drop_loc.Y = -130.76f;
  574. drop_loc.Z = 13.020f;
  575. float facing = 337.603f;
  576. GameObject * chinook_obj = Commands->Create_Object ( "Invisible_Object", drop_loc);
  577. Commands->Set_Facing(chinook_obj, facing);
  578. Commands->Attach_Script(chinook_obj, "Test_Cinematic", "M05_XG_VehicleDrop1.txt");
  579. }
  580. }
  581. }
  582. };
  583. DECLARE_SCRIPT (M05_Tank_Attack_DME, "")
  584. {
  585. bool attacking, first;
  586. enum{ATTACK_OVER};
  587. // Register variables to be Auto-Saved
  588. // All variables must have a unique ID, less than 256, that never changes
  589. REGISTER_VARIABLES()
  590. {
  591. SAVE_VARIABLE( attacking, 1 );
  592. }
  593. void Created (GameObject * obj)
  594. {
  595. Commands->Enable_Enemy_Seen( obj, true);
  596. attacking = false;
  597. first = true;
  598. }
  599. void Enemy_Seen(GameObject * obj, GameObject *enemy )
  600. {
  601. ActionParamsStruct params;
  602. Vector3 current_loc;
  603. Vector3 enemy_loc;
  604. current_loc = Commands->Get_Position ( obj );
  605. enemy_loc = Commands->Get_Position ( enemy );
  606. if ((Commands->Get_Distance(current_loc, enemy_loc)) < 65)
  607. {
  608. if(!attacking && first)
  609. {
  610. attacking = true;
  611. first = false;
  612. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN, 1 );
  613. params.Set_Attack (enemy, 65.0f, 3.0f, 1);
  614. params.AttackCheckBlocked = true;
  615. Commands->Action_Attack( obj, params );
  616. Commands->Start_Timer(obj, this, 5.0f, ATTACK_OVER);
  617. }
  618. }
  619. else if (!attacking && !first)
  620. {
  621. attacking = true;
  622. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN, 1 );
  623. params.Set_Attack (enemy, 250.0f, 3.0f, 1);
  624. params.AttackCheckBlocked = true;
  625. Commands->Action_Attack( obj, params );
  626. Commands->Start_Timer(obj, this, 5.0f, ATTACK_OVER);
  627. }
  628. }
  629. void Timer_Expired (GameObject* obj, int timer_id)
  630. {
  631. ActionParamsStruct params;
  632. if(timer_id == ATTACK_OVER)
  633. {
  634. attacking = false;
  635. }
  636. }
  637. };
  638. DECLARE_SCRIPT (M05_Tech_Wander_DME, "Work_Area=1:int")
  639. {
  640. int loc_id [7], count, choice, last_loc, poke_choice;
  641. int area_range, area_start, area_end;
  642. char area_anim [9];
  643. bool work_done[20], star_seen, poked, reward_given, anim_playing;
  644. float facing;
  645. Vector3 location;
  646. GameObject *destination_object;
  647. void init () //initializes count and work_done values.
  648. {
  649. int x;
  650. count = 0;
  651. for (x = area_start; x <= area_end; x++)
  652. {
  653. work_done [x] = 1;
  654. }
  655. }
  656. void Custom (GameObject* obj, int type, int param, GameObject* sender) //recieves custom from dave's arrow as to if the location is occupied or not.
  657. { //100 not occupied, 200 is occupied.
  658. if (type == DME_OCCUPIED && param == 100)
  659. {
  660. Commands->Send_Custom_Event(obj, sender, 70, 70); //if not occupied, sends custom to set status to occupied.
  661. }
  662. else if (type == 200 && param == 200)
  663. {
  664. Commands->Debug_Message("Custom received on worker type: %d param: %d sender_id %d. \n", type, param, Commands->Get_ID(sender));
  665. Worker_Loop (obj); //if occupied, tells worker to choose a now location.
  666. }
  667. }
  668. void Worker_Loop ( GameObject * obj ) //this is the main function that checks if the location is occupied
  669. { //and if it is not, tells the servant to go to that location.
  670. if (count == area_range)
  671. {
  672. init ();
  673. }
  674. GameObject *work_loc;
  675. choice = Get_Int_Random (area_start, area_end);
  676. while (work_done [choice] == 0 || choice == last_loc)
  677. {
  678. choice = Get_Int_Random (area_start, area_end);
  679. }
  680. work_done [choice] = 0;
  681. last_loc = choice;
  682. count++;
  683. destination_object = Commands->Find_Object (loc_id [choice]);
  684. Commands->Send_Custom_Event(obj, destination_object, 50, 50, 0.5f);
  685. work_loc = Commands->Find_Object (loc_id [choice]);
  686. location = Commands->Get_Position ( work_loc );
  687. facing = Commands->Get_Facing (work_loc);
  688. ActionParamsStruct params;
  689. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN - 1, 90 );
  690. params.Set_Movement( location, WALK, 0.0f );
  691. Commands->Action_Goto( obj, params );
  692. }
  693. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason ) //this is called when the servant reaches the destination location.
  694. { //the purpose of this function is to have the servant perform their destination animation.
  695. Vector3 current_loc = Commands->Get_Position ( obj );
  696. float distance = Commands->Get_Distance ( current_loc, location );
  697. if (action_id == 90)
  698. {
  699. if (star_seen == false && distance <= 3.0f)
  700. {
  701. anim_playing = true;
  702. Commands->Start_Timer (obj, this, 2.0f, 500);
  703. Commands->Set_Facing(obj, facing);
  704. ActionParamsStruct params;
  705. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN + 5, 1);
  706. params.Set_Animation( area_anim, true );
  707. Commands->Action_Play_Animation (obj, params);
  708. }
  709. }
  710. }
  711. void Created ( GameObject * obj ) //this is the created function for the servant, it sets up most of the variables.
  712. {
  713. int work_area = Get_Int_Parameter("Work_Area");
  714. Commands->Set_Player_Type( obj, 0 );
  715. Commands->Innate_Disable( obj );
  716. poke_choice = 3; //Get_Int_Random (1, 3);
  717. star_seen = false;
  718. reward_given = false;
  719. anim_playing = false;
  720. loc_id [0] = 2000025; //these are the dave's arrow id's for all 3 work areas.
  721. loc_id [1] = 2000026;
  722. loc_id [2] = 2000027;
  723. loc_id [3] = 2000028;
  724. loc_id [4] = 2000031;
  725. loc_id [5] = 2000032;
  726. loc_id [6] = 2000030;
  727. //Area 1 Variables.
  728. if (work_area == 1)
  729. {
  730. area_range = 7;
  731. area_start = 0;
  732. area_end = 6;
  733. sprintf(area_anim, "%s", "H_A_a0f0");
  734. }
  735. init ();
  736. Worker_Loop (obj);
  737. }
  738. void Timer_Expired (GameObject* obj, int timer_id)
  739. {
  740. if (timer_id == 500) //this timer resets the servant from his animation loop and calls Worker_Loop to send him to a new location.
  741. {
  742. anim_playing = false;
  743. Commands->Action_Reset(obj, 99);
  744. Commands->Set_Animation( obj, NULL, false );
  745. destination_object = Commands->Find_Object (loc_id [choice]);
  746. Commands->Send_Custom_Event(obj, destination_object, 90, 90);
  747. Worker_Loop (obj);
  748. }
  749. else if (timer_id == 510) //this timer resets the servant after seeing the star. He completes his animation and returns to work.
  750. {
  751. star_seen = false;
  752. Commands->Action_Reset(obj, 99);
  753. Commands->Set_Animation( obj, "H_A_HOST_L1B", false );
  754. Commands->Set_Animation_Frame(obj, "H_A_HOST_L1B", 16);
  755. Worker_Loop (obj);
  756. }
  757. }
  758. void Enemy_Seen (GameObject* obj, GameObject* enemy) //this function sets the servant in a "don't hurt me!" stance (based on a timer)
  759. {
  760. if (star_seen == false)
  761. {
  762. if (anim_playing == false)
  763. {
  764. destination_object = Commands->Find_Object (loc_id [choice]);
  765. Commands->Send_Custom_Event(obj, destination_object, 90, 90);
  766. star_seen = true;
  767. Commands->Start_Timer (obj, this, 9.0f, 510);
  768. const char *conv_name = ("IDS_M06_DME");
  769. int conv_id = Commands->Create_Conversation (conv_name);
  770. Commands->Join_Conversation(obj, conv_id, false, false);
  771. Commands->Start_Conversation (conv_id, 1);
  772. ActionParamsStruct params;
  773. params.Set_Basic( this, INNATE_PRIORITY_ENEMY_SEEN, 1);
  774. params.Set_Animation( "H_A_HOST_L1B", true );
  775. Commands->Action_Play_Animation (obj, params);
  776. }
  777. }
  778. }
  779. };
  780. DECLARE_SCRIPT (test_Ssm_Trigger, "")
  781. {
  782. void Damaged( GameObject * obj, GameObject * damager, float amount )
  783. {
  784. if (damager == STAR)
  785. {
  786. Commands->Send_Custom_Event (obj, obj, M00_LAUNCH_SSM, 0);
  787. }
  788. }
  789. };
  790. DECLARE_SCRIPT(DME_Cinematic_Test, "")
  791. {
  792. void Created (GameObject * obj)
  793. {
  794. /* Commands->Enable_Hibernation(obj, false);
  795. Commands->Set_Player_Type(obj, PLAYERTYPE_NEUTRAL );
  796. Commands->Create_Object ( "XG_TransprtBone", Vector3(0.0f, 0.0f, 0.0f));*/
  797. }
  798. void Damaged( GameObject * obj, GameObject * damager, float amount )
  799. {
  800. /* GameObject * chinook_obj0 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  801. Commands->Set_Facing(chinook_obj0, 0.0f);
  802. Commands->Attach_Script(chinook_obj0, "Test_Cinematic", "X7A_TrnsptCt_00.txt");
  803. GameObject * chinook_obj1 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  804. Commands->Set_Facing(chinook_obj1, 0.0f);
  805. Commands->Attach_Script(chinook_obj1, "Test_Cinematic", "X7A_TrnsptCt_01.txt");*/
  806. GameObject * chinook_obj2 = Commands->Create_Object ( "Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  807. Commands->Set_Facing(chinook_obj2, 0.0f);
  808. Commands->Attach_Script(chinook_obj2, "Test_Cinematic", "X10D_CHTroopdrop1.txt");
  809. // GameObject * napc = Commands->Create_Object("Invisible_Object", Vector3(0.0f, 0.0f, 0.0f));
  810. // Commands->Set_Model(napc, "e_chopperdust1");
  811. /* Commands->Send_Custom_Event(obj, Commands->Find_Object(100001), M07_EVAC_INN, 1, 0.0f);
  812. Commands->Enable_Spawner(100002, true);
  813. Commands->Enable_Spawner(100004, true);
  814. Commands->Enable_Spawner(100005, true);
  815. Commands->Enable_Spawner(100006, true);
  816. Commands->Enable_Spawner(100007, true);*/
  817. }
  818. };
  819. //////////////////////////////////////////////////////////////////////////
  820. // //
  821. // MISSION X0 //
  822. // //
  823. //////////////////////////////////////////////////////////////////////////