Toolkit.cpp 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065
  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. * Toolkit.cpp
  22. *
  23. * DESCRIPTION
  24. * Designer Toolkit for Mission Construction - Debug and Notation Subset
  25. *
  26. * PROGRAMMER
  27. * Design Team
  28. *
  29. * VERSION INFO
  30. * $Author: Dan_e $
  31. * $Revision: 185 $
  32. * $Modtime: 3/15/02 12:53p $
  33. * $Archive: /Commando/Code/Scripts/Toolkit.cpp $
  34. *
  35. ******************************************************************************/
  36. #include "toolkit.h"
  37. #include "mission1.h"
  38. /* GENERAL TOOLKIT INFORMATION
  39. 1. All toolkit systems are listed in categories of system type: Actions, Explosions, etc.
  40. 2. All toolkit systems are sub-categorized in the order of functions, then interfaces.
  41. 3. The following Parameter Standardization is used for all scripts, and is not repeated.
  42. Each script has the appropriate parameters from this list, always in this order:
  43. SCRIPT PARAMETER DESCRIPTION SCRIPT TYPES
  44. Start_Now Set this to 1 to activate upon creation. Triggers and Controllers
  45. Receive_Type Custom expected for activation/deactivation Triggers and Controllers
  46. Receive_Param_On Custom Parameter to activate this script Triggers and Controllers
  47. Receive_Param_Off Custom Parameter to deactivate this script Triggers and Controllers
  48. Target_ID The ID of the object to receive a custom. Triggers Only
  49. Send_Type The Custom Type to send to the object. Triggers Only
  50. Send_Param The Custom Paramter to send to the object. Triggers Only
  51. Min_Delay The minimum wait time for the custom. Triggers Only
  52. Max_Delay The maximum wait time for the custom. Triggers Only
  53. Action_Priority Priority level of the action applied. Action Controllers Only
  54. Action_ID The ID of the action applied. Action Controllers Only
  55. (varies) Various required parameters for the script Triggers and Controllers
  56. Debug_Mode Set this to 1 for debug information. Triggers and Controllers
  57. */
  58. /******************************************************************************
  59. *
  60. * Toolkit Script Debuggers
  61. *
  62. ******************************************************************************/
  63. DECLARE_SCRIPT(M00_Debug_Text_File_RMV, "Description=Object:string, Filename=DebugLog.txt:string")
  64. {
  65. const char *filename, *desc;
  66. FILE *file;
  67. time_t start_time, current_time;
  68. char* Reason_Lookup(ActionCompleteReason reason)
  69. {
  70. char* reasons[] = {
  71. "ACTION_COMPLETE_NORMAL",
  72. "ACTION_COMPLETE_LOW_PRIORITY",
  73. "ACTION_COMPLETE_PATH_BAD_START",
  74. "ACTION_COMPLETE_PATH_BAD_DEST",
  75. "ACTION_COMPLETE_MOVE_NO_PROGRESS_MADE",
  76. "ACTION_COMPLETE_ATTACK_OUT_OF_RANGE"
  77. };
  78. return reasons[(int)reason];
  79. }
  80. void Created(GameObject * obj)
  81. {
  82. current_time = time(NULL);
  83. desc = Get_Parameter("Description");
  84. filename = Get_Parameter("Filename");
  85. file = fopen(filename, "wt");
  86. fprintf(file, "%s [ID %d] created.\n", desc, Commands->Get_ID(obj));
  87. }
  88. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  89. {
  90. current_time = time(NULL);
  91. fprintf(file, "%s [ID %d] received custom event of type %d and param %d. Sender was object %d. %3.1f sec.\n", desc, Commands->Get_ID(obj), type, param, Commands->Get_ID(sender), difftime(current_time, start_time));
  92. }
  93. void Damaged(GameObject * obj, GameObject * damager, float amount)
  94. {
  95. current_time = time(NULL);
  96. fprintf(file, "%s [ID %d] damaged by object %d. %3.1f sec.\n", desc, Commands->Get_ID(obj), Commands->Get_ID(damager), difftime(current_time, start_time));
  97. }
  98. void Sound_Heard( GameObject * obj, const CombatSound & sound )
  99. {
  100. // fprintf(file, "%s [ID %d] heard a sound. %3.1f sec.\n", desc, Commands->Get_ID(obj), current_time);
  101. }
  102. void Enemy_Seen( GameObject * obj, GameObject * enemy)
  103. {
  104. current_time = time(NULL);
  105. fprintf(file, "%s [ID %d] saw enemy: object %d. %3.1f sec.\n", desc, Commands->Get_ID(obj), Commands->Get_ID(enemy), difftime(current_time, start_time));
  106. }
  107. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  108. {
  109. current_time = time(NULL);
  110. fprintf(file, "Action %d complete on %s [ID %d] -- Reason: %s. %3.1f sec.\n", action_id, desc, Commands->Get_ID(obj), Reason_Lookup(reason), difftime(current_time, start_time));
  111. }
  112. void Killed(GameObject * obj, GameObject * killer)
  113. {
  114. current_time = time(NULL);
  115. fprintf(file, "%s [ID %d] killed by object %d. %3.1f sec.\n", desc, Commands->Get_ID(obj), Commands->Get_ID(killer), difftime(current_time, start_time));
  116. }
  117. void Destroyed(GameObject * obj)
  118. {
  119. fclose(file);
  120. }
  121. };
  122. /******************************************************************************
  123. *
  124. * Other Scripts
  125. *
  126. ******************************************************************************/
  127. #if 0
  128. DECLARE_SCRIPT(M00_Activate_Weapon_At_Object_On_Frame_RMV, "Frame:int, Primary_Weapon=1:int, Duration:float, Target_ID:int, Start_Timer_ID:int, Stop_Timer_ID")
  129. {
  130. float frame;
  131. bool primary;
  132. float duration;
  133. int start_id;
  134. int stop_id;
  135. int target_id;
  136. GameObject *target;
  137. void Created(GameObject * obj)
  138. {
  139. frame = (float)Get_Int_Parameter("Frame");
  140. primary = (Get_Int_Parameter("Primary_Weapon") == 1) ? true : false;
  141. duration = Get_Float_Parameter("Duration");
  142. start_id = Get_Int_Parameter("Start_Timer_ID");
  143. stop_id = Get_Int_Parameter("Stop_Timer_ID");
  144. target_id = Get_Int_Parameter("Target_ID");
  145. target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  146. if (target_id > 0)
  147. target = Commands->Find_Object(target_id);
  148. Commands->Start_Timer(obj, this, frame/30, start_id);
  149. }
  150. void Timer_Expired(GameObject * obj, int timer_id)
  151. {
  152. if (timer_id == start_id)
  153. {
  154. Vector3 position = Commands->Get_Position(target);
  155. Commands->Trigger_Weapon(obj, true, position, primary);
  156. Commands->Start_Timer(obj, this, duration, stop_id);
  157. }
  158. if (timer_id == stop_id)
  159. {
  160. Vector3 position = Commands->Get_Position(target);
  161. Commands->Trigger_Weapon(obj, false, position, primary);
  162. }
  163. }
  164. };
  165. DECLARE_SCRIPT(M00_Activate_Weapon_At_Object_On_Timer_RMV, "Delay:float, Primary_Weapon=1:int, Duration:float, Target_ID:int, Start_Timer_ID:int, Stop_Timer_ID:int")
  166. {
  167. float time;
  168. bool primary;
  169. float duration;
  170. int start_id;
  171. int stop_id;
  172. int target_id;
  173. GameObject *target;
  174. void Created(GameObject * obj)
  175. {
  176. time = Get_Float_Parameter("Delay");
  177. primary = (Get_Int_Parameter("Primary_Weapon") == 1) ? true : false;
  178. duration = Get_Float_Parameter("Duration");
  179. start_id = Get_Int_Parameter("Start_Timer_ID");
  180. stop_id = Get_Int_Parameter("Stop_Timer_ID");
  181. target_id = Get_Int_Parameter("Target_ID");
  182. target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  183. if (target_id > 0)
  184. target = Commands->Find_Object(target_id);
  185. Commands->Start_Timer(obj, this, time, start_id);
  186. }
  187. void Timer_Expired(GameObject * obj, int timer_id)
  188. {
  189. if (timer_id == start_id)
  190. {
  191. Vector3 position = Commands->Get_Position(target);
  192. Commands->Trigger_Weapon(obj, true, position, primary);
  193. Commands->Start_Timer(obj, this, duration, stop_id);
  194. }
  195. if (timer_id == stop_id)
  196. {
  197. Vector3 position = Commands->Get_Position(target);
  198. Commands->Trigger_Weapon(obj, false, position, primary);
  199. }
  200. }
  201. };
  202. DECLARE_SCRIPT(M00_Activate_Weapon_At_Location_On_Frame_RMV, "Frame:int, Primary_Weapon=1:int, Duration:float, Target:vector3, Start_Timer_ID:int, Stop_Timer_ID")
  203. {
  204. float frame;
  205. bool primary;
  206. float duration;
  207. int start_id;
  208. int stop_id;
  209. Vector3 target;
  210. void Created(GameObject * obj)
  211. {
  212. frame = (float)Get_Int_Parameter("Frame");
  213. primary = (Get_Int_Parameter("Primary_Weapon") == 1) ? true : false;
  214. duration = Get_Float_Parameter("Duration");
  215. start_id = Get_Int_Parameter("Start_Timer_ID");
  216. stop_id = Get_Int_Parameter("Stop_Timer_ID");
  217. target = Get_Vector3_Parameter("Target");
  218. Commands->Start_Timer(obj, this, frame/30, start_id);
  219. }
  220. void Timer_Expired(GameObject * obj, int timer_id)
  221. {
  222. if (timer_id == start_id)
  223. {
  224. Commands->Trigger_Weapon(obj, true, target, primary);
  225. Commands->Start_Timer(obj, this, duration, stop_id);
  226. }
  227. if (timer_id == stop_id)
  228. {
  229. Commands->Trigger_Weapon(obj, false, target, primary);
  230. }
  231. }
  232. };
  233. DECLARE_SCRIPT(M00_Activate_Weapon_At_Location_On_Timer_RMV, "Delay:float, Primary_Weapon=1:int, Duration:float, Target:vector3, Start_Timer_ID:int, Stop_Timer_ID:int")
  234. {
  235. float time;
  236. bool primary;
  237. float duration;
  238. int start_id;
  239. int stop_id;
  240. Vector3 target;
  241. void Created(GameObject * obj)
  242. {
  243. time = Get_Float_Parameter("Delay");
  244. primary = (Get_Int_Parameter("Primary_Weapon") == 1) ? true : false;
  245. duration = Get_Float_Parameter("Duration");
  246. start_id = Get_Int_Parameter("Start_Timer_ID");
  247. stop_id = Get_Int_Parameter("Stop_Timer_ID");
  248. target = Get_Vector3_Parameter("Target");
  249. Commands->Start_Timer(obj, this, time, start_id);
  250. }
  251. void Timer_Expired(GameObject * obj, int timer_id)
  252. {
  253. if (timer_id == start_id)
  254. {
  255. Commands->Trigger_Weapon(obj, true, target, primary);
  256. Commands->Start_Timer(obj, this, duration, stop_id);
  257. }
  258. if (timer_id == stop_id)
  259. {
  260. Commands->Trigger_Weapon(obj, false, target, primary);
  261. }
  262. }
  263. };
  264. #endif
  265. DECLARE_SCRIPT(M00_Disable_Physical_Collision_JDG, "")
  266. {
  267. void Created( GameObject * obj )
  268. {
  269. Commands->Disable_Physical_Collisions ( obj );
  270. }
  271. };
  272. DECLARE_SCRIPT(M00_Enable_Physical_Collision_JDG, "")
  273. {
  274. void Created( GameObject * obj )
  275. {
  276. Commands->Enable_Collisions ( obj );
  277. }
  278. };
  279. DECLARE_SCRIPT(M00_C130_Explosion, "")
  280. {
  281. void Killed(GameObject * obj, GameObject * killer)
  282. {
  283. Commands->Create_Explosion_At_Bone("Explosion_Cargo_Plane", obj, "BODYMAIN");
  284. //JDG updated this script due to explosion preset name change--07/27/2001
  285. }
  286. };
  287. DECLARE_SCRIPT(M00_Monitor_Attached_Primary, "")
  288. {
  289. bool object_detached;
  290. int attached_object_id;
  291. enum{OBJECT_DETACHED};
  292. // Register variables to be Auto-Saved
  293. // All variables must have a unique ID, less than 256, that never changes
  294. REGISTER_VARIABLES()
  295. {
  296. SAVE_VARIABLE( object_detached, 1 );
  297. }
  298. void Created (GameObject * obj)
  299. {
  300. object_detached = false;
  301. attached_object_id = 0;
  302. }
  303. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  304. {
  305. ActionParamsStruct params;
  306. if(type == M00_CUSTOM_OBJECT_ATTACHED_PRIMARY)
  307. {
  308. attached_object_id = Commands->Get_ID(sender);
  309. Commands->Start_Timer (obj, this, param / 30.0f, OBJECT_DETACHED);
  310. }
  311. }
  312. void Timer_Expired(GameObject * obj, int timer_id)
  313. {
  314. if (timer_id == OBJECT_DETACHED)
  315. {
  316. object_detached = true;
  317. }
  318. }
  319. void Killed (GameObject * obj, GameObject * killer)
  320. {
  321. if(!object_detached)
  322. {
  323. Commands->Apply_Damage( Commands->Find_Object(attached_object_id), 10000.0f, "DEATH");
  324. }
  325. }
  326. };
  327. /***********************************************************************************************************
  328. The two following scripts are a controller and a script for a gerneric barrel explosion chain rection.
  329. You only need to place the controller in your level and enter the Vector3's and barrel types as editor parameters
  330. See Joe G for further details
  331. ****************************************************************************************************************/
  332. DECLARE_SCRIPT(M00_5MetalBarrels_ChainRxn_Controller_JDG, "Barrel01_Location:vector3, Barrel01_Type (1-8):int, Barrel01_Facing = 0:float, Barrel02_Location:vector3, Barrel02_Type (1-8):int, Barrel02_Facing = 0:float, Barrel03_Location:vector3, Barrel03_Type (1-8):int, Barrel03_Facing = 0:float, Barrel04_Location:vector3, Barrel04_Type (1-8):int, Barrel04_Facing = 0:float, Barrel05_Location:vector3, Barrel05_Type (1-8):int, Barrel05_Facing = 0:float")
  333. {
  334. Vector3 barrel_01_location;
  335. Vector3 barrel_02_location;
  336. Vector3 barrel_03_location;
  337. Vector3 barrel_04_location;
  338. Vector3 barrel_05_location;
  339. int barrel_01_type;
  340. int barrel_02_type;
  341. int barrel_03_type;
  342. int barrel_04_type;
  343. int barrel_05_type;
  344. int barrel_01_id;
  345. int barrel_02_id;
  346. int barrel_03_id;
  347. int barrel_04_id;
  348. int barrel_05_id;
  349. float barrel_01_facing;
  350. float barrel_02_facing;
  351. float barrel_03_facing;
  352. float barrel_04_facing;
  353. float barrel_05_facing;
  354. REGISTER_VARIABLES()
  355. {
  356. SAVE_VARIABLE(barrel_01_location, 1);
  357. SAVE_VARIABLE(barrel_02_location, 2);
  358. SAVE_VARIABLE(barrel_03_location, 3);
  359. SAVE_VARIABLE(barrel_04_location, 4);
  360. SAVE_VARIABLE(barrel_05_location, 5);
  361. SAVE_VARIABLE(barrel_01_type, 6);
  362. SAVE_VARIABLE(barrel_02_type, 7);
  363. SAVE_VARIABLE(barrel_03_type, 8);
  364. SAVE_VARIABLE(barrel_04_type, 9);
  365. SAVE_VARIABLE(barrel_05_type, 10);
  366. SAVE_VARIABLE(barrel_01_id, 11);
  367. SAVE_VARIABLE(barrel_02_id, 12);
  368. SAVE_VARIABLE(barrel_03_id, 13);
  369. SAVE_VARIABLE(barrel_04_id, 14);
  370. SAVE_VARIABLE(barrel_05_id, 15);
  371. SAVE_VARIABLE(barrel_01_facing, 16);
  372. SAVE_VARIABLE(barrel_02_facing, 17);
  373. SAVE_VARIABLE(barrel_03_facing, 18);
  374. SAVE_VARIABLE(barrel_04_facing, 19);
  375. SAVE_VARIABLE(barrel_05_facing, 20);
  376. }
  377. void Created( GameObject * obj )
  378. {
  379. barrel_01_location = Get_Vector3_Parameter("Barrel01_Location");
  380. barrel_02_location = Get_Vector3_Parameter("Barrel02_Location");
  381. barrel_03_location = Get_Vector3_Parameter("Barrel03_Location");
  382. barrel_04_location = Get_Vector3_Parameter("Barrel04_Location");
  383. barrel_05_location = Get_Vector3_Parameter("Barrel05_Location");
  384. barrel_01_type = Get_Int_Parameter("Barrel01_Type (1-8)");
  385. barrel_01_type -= 1;
  386. barrel_02_type = Get_Int_Parameter("Barrel02_Type (1-8)");
  387. barrel_02_type -= 1;
  388. barrel_03_type = Get_Int_Parameter("Barrel03_Type (1-8)");
  389. barrel_03_type -= 1;
  390. barrel_04_type = Get_Int_Parameter("Barrel04_Type (1-8)");
  391. barrel_04_type -= 1;
  392. barrel_05_type = Get_Int_Parameter("Barrel05_Type (1-8)");
  393. barrel_05_type -= 1;
  394. barrel_01_facing = Get_Float_Parameter("Barrel01_Facing");
  395. barrel_02_facing = Get_Float_Parameter("Barrel02_Facing");
  396. barrel_03_facing = Get_Float_Parameter("Barrel03_Facing");
  397. barrel_04_facing = Get_Float_Parameter("Barrel04_Facing");
  398. barrel_05_facing = Get_Float_Parameter("Barrel05_Facing");
  399. char *simple_barrels[8] =
  400. {
  401. "Simple_MetalDrum_01",
  402. "Simple_MetalDrum_02",
  403. "Simple_MetalDrum_03",
  404. "Simple_MetalDrum_04",
  405. "Simple_MetalDrum_05",
  406. "Simple_MetalDrum_06",
  407. "Simple_MetalDrum_07",
  408. "Simple_MetalDrum_08",
  409. };
  410. char *barrels_animations[8] =
  411. {
  412. "DSP_METDRUM01.DSP_METDRUM01",
  413. "DSP_METDRUM02.DSP_METDRUM02",
  414. "DSP_METDRUM03.DSP_METDRUM03",
  415. "DSP_METDRUM04.DSP_METDRUM04",
  416. "DSP_METDRUM05.DSP_METDRUM05",
  417. "DSP_METDRUM06.DSP_METDRUM06",
  418. "DSP_METDRUM07.DSP_METDRUM07",
  419. "DSP_METDRUM08.DSP_METDRUM08",
  420. };
  421. int controller_id = Commands->Get_ID ( obj );
  422. char controller[16];
  423. sprintf (controller, "%d", controller_id);
  424. GameObject * barrel_01 = Commands->Create_Object ( simple_barrels[barrel_01_type], barrel_01_location );
  425. Commands->Set_Animation_Frame ( barrel_01, barrels_animations[barrel_01_type], 0 );
  426. barrel_01_id = Commands->Get_ID ( barrel_01 );
  427. Commands->Set_Facing ( barrel_01, barrel_01_facing );
  428. Commands->Attach_Script(barrel_01, "M00_ChainRxn_Barrel_JDG", controller);
  429. GameObject * barrel_02 = Commands->Create_Object ( simple_barrels[barrel_02_type], barrel_02_location );
  430. Commands->Set_Animation_Frame ( barrel_02, barrels_animations[barrel_02_type ], 0 );
  431. barrel_02_id = Commands->Get_ID ( barrel_02 );
  432. Commands->Set_Facing ( barrel_02, barrel_02_facing );
  433. Commands->Attach_Script(barrel_02, "M00_ChainRxn_Barrel_JDG", controller);
  434. GameObject * barrel_03 = Commands->Create_Object ( simple_barrels[barrel_03_type], barrel_03_location );
  435. Commands->Set_Animation_Frame ( barrel_03, barrels_animations[barrel_03_type], 0 );
  436. barrel_03_id = Commands->Get_ID ( barrel_03 );
  437. Commands->Set_Facing ( barrel_03, barrel_03_facing );
  438. Commands->Attach_Script(barrel_03, "M00_ChainRxn_Barrel_JDG", controller);
  439. GameObject * barrel_04 = Commands->Create_Object ( simple_barrels[barrel_04_type], barrel_04_location );
  440. Commands->Set_Animation_Frame ( barrel_04, barrels_animations[barrel_04_type], 0 );
  441. barrel_04_id = Commands->Get_ID ( barrel_04 );
  442. Commands->Set_Facing ( barrel_04, barrel_04_facing );
  443. Commands->Attach_Script(barrel_04, "M00_ChainRxn_Barrel_JDG", controller);
  444. GameObject * barrel_05 = Commands->Create_Object ( simple_barrels[barrel_05_type], barrel_05_location );
  445. Commands->Set_Animation_Frame ( barrel_05, barrels_animations[barrel_05_type], 0 );
  446. barrel_05_id = Commands->Get_ID ( barrel_05 );
  447. Commands->Set_Facing ( barrel_05, barrel_05_facing );
  448. Commands->Attach_Script(barrel_05, "M00_ChainRxn_Barrel_JDG", controller);
  449. }
  450. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  451. {
  452. if (type == 0)
  453. {
  454. if (param == M01_IVE_BEEN_KILLED_JDG)
  455. {
  456. GameObject * barrel_01 = Commands->Find_Object ( barrel_01_id );
  457. GameObject * barrel_02 = Commands->Find_Object ( barrel_02_id );
  458. GameObject * barrel_03 = Commands->Find_Object ( barrel_03_id );
  459. GameObject * barrel_04 = Commands->Find_Object ( barrel_04_id );
  460. GameObject * barrel_05 = Commands->Find_Object ( barrel_05_id );
  461. if (sender == barrel_01)//barrel 01 has been destroyed--tell #2 to self destruct
  462. {
  463. Commands->Send_Custom_Event ( obj, barrel_01, barrel_01_type, M01_MODIFY_YOUR_ACTION_JDG, 0 );
  464. if (barrel_02 != NULL)
  465. {
  466. float delayTimer = Commands->Get_Random ( 0.25f, 0.5f );
  467. Commands->Send_Custom_Event ( obj, barrel_02, barrel_02_type, M01_MODIFY_YOUR_ACTION_JDG, delayTimer );
  468. }
  469. }
  470. else if (sender == barrel_02)//barrel 02 has been destroyed--tell #1 and #3 to self destruct
  471. {
  472. Commands->Send_Custom_Event ( obj, barrel_02, barrel_02_type, M01_MODIFY_YOUR_ACTION_JDG, 0 );
  473. if (barrel_01 != NULL)
  474. {
  475. float delayTimer = Commands->Get_Random ( 0.25f, 0.5f );
  476. Commands->Send_Custom_Event ( obj, barrel_01, barrel_01_type, M01_MODIFY_YOUR_ACTION_JDG, delayTimer );
  477. }
  478. if (barrel_03 != NULL)
  479. {
  480. float delayTimer = Commands->Get_Random ( 0.25f, 0.5f );
  481. Commands->Send_Custom_Event ( obj, barrel_03, barrel_03_type, M01_MODIFY_YOUR_ACTION_JDG, delayTimer );
  482. }
  483. }
  484. else if (sender == barrel_03)//barrel 03 has been destroyed--tell #2 and #4 to self destruct
  485. {
  486. Commands->Send_Custom_Event ( obj, barrel_03, barrel_03_type, M01_MODIFY_YOUR_ACTION_JDG, 0 );
  487. if (barrel_02 != NULL)
  488. {
  489. float delayTimer = Commands->Get_Random ( 0.25f, 0.5f );
  490. Commands->Send_Custom_Event ( obj, barrel_02, barrel_02_type, M01_MODIFY_YOUR_ACTION_JDG, delayTimer );
  491. }
  492. if (barrel_04 != NULL)
  493. {
  494. float delayTimer = Commands->Get_Random ( 0.25f, 0.5f );
  495. Commands->Send_Custom_Event ( obj, barrel_04, barrel_04_type, M01_MODIFY_YOUR_ACTION_JDG, delayTimer );
  496. }
  497. }
  498. else if (sender == barrel_04)//barrel 04 has been destroyed--tell #3 and #5 to self destruct
  499. {
  500. Commands->Send_Custom_Event ( obj, barrel_04, barrel_04_type, M01_MODIFY_YOUR_ACTION_JDG, 0 );
  501. if (barrel_03 != NULL)
  502. {
  503. float delayTimer = Commands->Get_Random ( 0.25f, 0.5f );
  504. Commands->Send_Custom_Event ( obj, barrel_03, barrel_03_type, M01_MODIFY_YOUR_ACTION_JDG, delayTimer );
  505. }
  506. if (barrel_05 != NULL)
  507. {
  508. float delayTimer = Commands->Get_Random ( 0.25f, 0.5f );
  509. Commands->Send_Custom_Event ( obj, barrel_05, barrel_05_type, M01_MODIFY_YOUR_ACTION_JDG, delayTimer );
  510. }
  511. }
  512. else if (sender == barrel_05)//barrel 05 has been destroyed--tell #4 to self destruct
  513. {
  514. Commands->Send_Custom_Event ( obj, barrel_05, barrel_05_type, M01_MODIFY_YOUR_ACTION_JDG, 0 );
  515. if (barrel_04 != NULL)
  516. {
  517. float delayTimer = Commands->Get_Random ( 0.25f, 0.5f );
  518. Commands->Send_Custom_Event ( obj, barrel_04, barrel_04_type, M01_MODIFY_YOUR_ACTION_JDG, delayTimer );
  519. }
  520. }
  521. }
  522. }
  523. }
  524. };
  525. DECLARE_SCRIPT(M00_ChainRxn_Barrel_JDG, "Controller_ID :int")
  526. {
  527. int controller_id;
  528. bool deadYet;
  529. REGISTER_VARIABLES()
  530. {
  531. SAVE_VARIABLE(controller_id, 1);
  532. SAVE_VARIABLE(deadYet, 2);
  533. }
  534. void Created( GameObject * obj )
  535. {
  536. deadYet = false;
  537. controller_id = Get_Int_Parameter("Controller_ID");
  538. }
  539. void Damaged( GameObject * obj, GameObject * damager, float amount )
  540. {
  541. if (obj && deadYet == false && damager == STAR)
  542. {
  543. Commands->Set_Health ( obj, 0.25f );
  544. GameObject * controller = Commands->Find_Object ( controller_id );
  545. if (controller != NULL)
  546. {
  547. Commands->Send_Custom_Event ( obj, controller, 0, M01_IVE_BEEN_KILLED_JDG, 0 );
  548. }
  549. }
  550. else
  551. {
  552. Commands->Set_Health ( obj, 0.25f );
  553. }
  554. }
  555. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  556. {
  557. if (param == M01_MODIFY_YOUR_ACTION_JDG && deadYet == false)//you've been ordered to blow up--DO IT!
  558. {
  559. deadYet = true;
  560. int number = type;
  561. Vector3 myPosition = Commands->Get_Position ( obj );
  562. Commands->Create_Explosion ( "Explosion_Mine_Remote_01", myPosition, NULL );
  563. char *barrels_animations[8] =
  564. {
  565. "DSP_METDRUM01.DSP_METDRUM01",//there's no #1 yet
  566. "DSP_METDRUM02.DSP_METDRUM02",
  567. "DSP_METDRUM03.DSP_METDRUM03",
  568. "DSP_METDRUM04.DSP_METDRUM04",
  569. "DSP_METDRUM05.DSP_METDRUM05",
  570. "DSP_METDRUM06.DSP_METDRUM06",//there's no #6 yet
  571. "DSP_METDRUM07.DSP_METDRUM07",
  572. "DSP_METDRUM08.DSP_METDRUM08",
  573. };
  574. int barrels_endframe[8] =
  575. {
  576. 28,//1
  577. 15,//2
  578. 20,//3
  579. 8,//4
  580. 8,//5
  581. 27,//6
  582. 8,//7
  583. 8,//8
  584. };
  585. Commands->Set_Animation ( obj, barrels_animations[number], false, NULL, 0, barrels_endframe[number] );
  586. Commands->Set_Health ( obj, 0.25f );
  587. GameObject * controller = Commands->Find_Object ( controller_id );
  588. if (controller != NULL)
  589. {
  590. Commands->Send_Custom_Event ( obj, controller, 0, M01_IVE_BEEN_KILLED_JDG, 0 );
  591. }
  592. }
  593. }
  594. };
  595. /* M00_Advanced_Guard_Tower
  596. This script handles the functionality of the Advanced Guard Tower in both single and multiplayer
  597. environments. Attach this script to the AGT Building Controller, and center the building
  598. controller directly on the top of the tower roof.
  599. When created this script:
  600. - Creates four guard tower machine guns at the corners of the building
  601. - Attaches another script to the machine guns to allow them enemy_seen capability.
  602. - Creates a missile object at the top of the building.
  603. - Attaches another script to the missile object to allow it to respond to the guns.
  604. - The guns use enemy_seen to spot, and inform the missile when it is time to fire.
  605. */
  606. DECLARE_SCRIPT (M00_Advanced_Guard_Tower, "")
  607. {
  608. int missile_id;
  609. int gun_01_id;
  610. int gun_02_id;
  611. int gun_03_id;
  612. int gun_04_id;
  613. bool can_fire;
  614. //Adding unneeded save/load variables just to be safe -- 2/12/2002 JDG.
  615. REGISTER_VARIABLES()
  616. {
  617. SAVE_VARIABLE(missile_id, 1);
  618. SAVE_VARIABLE(gun_01_id, 2);
  619. SAVE_VARIABLE(gun_02_id, 3);
  620. SAVE_VARIABLE(gun_03_id, 4);
  621. SAVE_VARIABLE(gun_04_id, 5);
  622. SAVE_VARIABLE(can_fire, 6);
  623. }
  624. void Created (GameObject* obj)
  625. {
  626. can_fire = true;
  627. Commands->Enable_Hibernation (obj, false);
  628. missile_id = 0;
  629. gun_01_id = 0;
  630. gun_02_id = 0;
  631. gun_03_id = 0;
  632. gun_04_id = 0;
  633. // Create the four guns associated with this object.
  634. Vector3 my_location = Commands->Get_Position (obj);
  635. Vector3 gun_01_pos = my_location;
  636. Vector3 gun_02_pos = my_location;
  637. Vector3 gun_03_pos = my_location;
  638. Vector3 gun_04_pos = my_location;
  639. Vector3 missile_loc = my_location;
  640. missile_loc.Z += 6.0f;
  641. gun_01_pos.X = gun_01_pos.X + 5.179f;
  642. gun_01_pos.Y = gun_01_pos.Y - 4.239f;
  643. gun_01_pos.Z = gun_01_pos.Z - 9.0f;
  644. gun_02_pos.X = gun_02_pos.X + 5.161f;
  645. gun_02_pos.Y = gun_02_pos.Y + 3.272f;
  646. gun_02_pos.Z = gun_02_pos.Z - 9.0f;
  647. gun_03_pos.X = gun_03_pos.X - 4.491f;
  648. gun_03_pos.Y = gun_03_pos.Y + 3.257f;
  649. gun_03_pos.Z = gun_03_pos.Z - 9.0f;
  650. gun_04_pos.X = gun_04_pos.X - 5.133f;
  651. gun_04_pos.Y = gun_04_pos.Y - 4.366f;
  652. gun_04_pos.Z = gun_04_pos.Z - 9.0f;
  653. GameObject * missile_object = Commands->Create_Object ("GDI_AGT", missile_loc);
  654. if (missile_object)
  655. {
  656. Commands->Attach_Script (missile_object, "M00_Advanced_Guard_Tower_Missile", "");
  657. missile_id = Commands->Get_ID (missile_object);
  658. }
  659. GameObject * gun_01 = Commands->Create_Object ("GDI_Ceiling_Gun_AGT", gun_01_pos);
  660. if (gun_01)
  661. {
  662. Commands->Attach_Script (gun_01, "M00_Advanced_Guard_Tower_Gun", "");
  663. gun_01_id = Commands->Get_ID (gun_01);
  664. }
  665. GameObject * gun_02 = Commands->Create_Object ("GDI_Ceiling_Gun_AGT", gun_02_pos);
  666. if (gun_02)
  667. {
  668. Commands->Attach_Script (gun_02, "M00_Advanced_Guard_Tower_Gun", "");
  669. gun_02_id = Commands->Get_ID (gun_02);
  670. }
  671. GameObject * gun_03 = Commands->Create_Object ("GDI_Ceiling_Gun_AGT", gun_03_pos);
  672. if (gun_03)
  673. {
  674. Commands->Attach_Script (gun_03, "M00_Advanced_Guard_Tower_Gun", "");
  675. gun_03_id = Commands->Get_ID (gun_03);
  676. }
  677. GameObject * gun_04 = Commands->Create_Object ("GDI_Ceiling_Gun_AGT", gun_04_pos);
  678. if (gun_04)
  679. {
  680. Commands->Attach_Script (gun_04, "M00_Advanced_Guard_Tower_Gun", "");
  681. gun_04_id = Commands->Get_ID (gun_04);
  682. }
  683. Commands->Start_Timer (obj, this, 1.0f, 1);
  684. Commands->Start_Timer (obj, this, 1.0f, 2);
  685. }
  686. void Killed( GameObject * obj, GameObject * killer )
  687. {
  688. //telling AGT guns that AGT has been killed (2/12/2002 JDG)
  689. GameObject * gun_01 = Commands->Find_Object (gun_01_id);
  690. GameObject * gun_02 = Commands->Find_Object (gun_02_id);
  691. GameObject * gun_03 = Commands->Find_Object (gun_03_id);
  692. GameObject * gun_04 = Commands->Find_Object (gun_04_id);
  693. if (gun_01 != NULL)
  694. {
  695. Commands->Send_Custom_Event (obj, gun_01, 3, 0, 0);//tells gun 01 to reset action and lets him know AGT is dead -- JDG 2/12/02
  696. }
  697. if (gun_02 != NULL)
  698. {
  699. Commands->Send_Custom_Event (obj, gun_02, 3, 0, 0);//tells gun 02 to reset action and lets him know AGT is dead -- JDG 2/12/02
  700. }
  701. if (gun_03 != NULL)
  702. {
  703. Commands->Send_Custom_Event (obj, gun_03, 3, 0, 0);//tells gun 03 to reset action and lets him know AGT is dead -- JDG 2/12/02
  704. }
  705. if (gun_04 != NULL)
  706. {
  707. Commands->Send_Custom_Event (obj, gun_04, 3, 0, 0);//tells gun 04 to reset action and lets him know AGT is dead -- JDG 2/12/02
  708. }
  709. }
  710. void Timer_Expired (GameObject * obj, int timer_id)
  711. {
  712. GameObject * gun_01 = Commands->Find_Object (gun_01_id);
  713. GameObject * gun_02 = Commands->Find_Object (gun_02_id);
  714. GameObject * gun_03 = Commands->Find_Object (gun_03_id);
  715. GameObject * gun_04 = Commands->Find_Object (gun_04_id);
  716. if (timer_id == 1)
  717. {
  718. if (gun_01)
  719. {
  720. Commands->Send_Custom_Event (obj, gun_01, 1, missile_id);
  721. }
  722. if (gun_02)
  723. {
  724. Commands->Send_Custom_Event (obj, gun_02, 1, missile_id);
  725. }
  726. if (gun_03)
  727. {
  728. Commands->Send_Custom_Event (obj, gun_03, 1, missile_id);
  729. }
  730. if (gun_04)
  731. {
  732. Commands->Send_Custom_Event (obj, gun_04, 1, missile_id);
  733. }
  734. }
  735. else if (timer_id == 2)
  736. {
  737. float health = Commands->Get_Health (obj);
  738. bool power = Commands->Get_Building_Power (obj);
  739. if ((!health) || (!power))
  740. {
  741. if (gun_01)
  742. {
  743. Commands->Send_Custom_Event (obj, gun_01, 2, 0);
  744. }
  745. if (gun_02)
  746. {
  747. Commands->Send_Custom_Event (obj, gun_02, 2, 0);
  748. }
  749. if (gun_03)
  750. {
  751. Commands->Send_Custom_Event (obj, gun_03, 2, 0);
  752. }
  753. if (gun_04)
  754. {
  755. Commands->Send_Custom_Event (obj, gun_04, 2, 0);
  756. }
  757. }
  758. else if ((power) && (can_fire))
  759. {
  760. if (gun_01)
  761. {
  762. Commands->Send_Custom_Event (obj, gun_01, 2, 1);
  763. }
  764. if (gun_02)
  765. {
  766. Commands->Send_Custom_Event (obj, gun_02, 2, 1);
  767. }
  768. if (gun_03)
  769. {
  770. Commands->Send_Custom_Event (obj, gun_03, 2, 1);
  771. }
  772. if (gun_04)
  773. {
  774. Commands->Send_Custom_Event (obj, gun_04, 2, 1);
  775. }
  776. }
  777. Commands->Start_Timer (obj, this, 1.0f, 2);
  778. }
  779. }
  780. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  781. {
  782. GameObject * gun_01 = Commands->Find_Object (gun_01_id);
  783. GameObject * gun_02 = Commands->Find_Object (gun_02_id);
  784. GameObject * gun_03 = Commands->Find_Object (gun_03_id);
  785. GameObject * gun_04 = Commands->Find_Object (gun_04_id);
  786. if (type == 1)
  787. {
  788. can_fire = true;
  789. if (gun_01)
  790. {
  791. Commands->Send_Custom_Event (obj, gun_01, 2, 1);
  792. }
  793. if (gun_02)
  794. {
  795. Commands->Send_Custom_Event (obj, gun_02, 2, 1);
  796. }
  797. if (gun_03)
  798. {
  799. Commands->Send_Custom_Event (obj, gun_03, 2, 1);
  800. }
  801. if (gun_04)
  802. {
  803. Commands->Send_Custom_Event (obj, gun_04, 2, 1);
  804. }
  805. }
  806. else if (!type)
  807. {
  808. can_fire = false;
  809. if (gun_01)
  810. {
  811. Commands->Send_Custom_Event (obj, gun_01, 2, 0);
  812. }
  813. if (gun_02)
  814. {
  815. Commands->Send_Custom_Event (obj, gun_02, 2, 0);
  816. }
  817. if (gun_03)
  818. {
  819. Commands->Send_Custom_Event (obj, gun_03, 2, 0);
  820. }
  821. if (gun_04)
  822. {
  823. Commands->Send_Custom_Event (obj, gun_04, 2, 0);
  824. }
  825. }
  826. }
  827. };
  828. DECLARE_SCRIPT (M00_Advanced_Guard_Tower_Gun, "")
  829. {
  830. int missile_object;
  831. bool agt_is_dead;
  832. //Adding unneeded save/load variables just to be safe -- 2/12/2002 JDG.
  833. REGISTER_VARIABLES()
  834. {
  835. SAVE_VARIABLE(missile_object, 1);
  836. SAVE_VARIABLE(agt_is_dead, 2);
  837. }
  838. void Created (GameObject * obj)
  839. {
  840. Commands->Set_Shield_Type (obj, "Blamo");
  841. Commands->Enable_Hibernation (obj, false);
  842. Commands->Innate_Enable (obj);
  843. Commands->Enable_Enemy_Seen (obj, true);
  844. missile_object = 0;
  845. agt_is_dead = false;
  846. }
  847. void Enemy_Seen (GameObject * obj, GameObject * enemy)
  848. {
  849. if (agt_is_dead == false)
  850. {
  851. GameObject * missile_obj = Commands->Find_Object (missile_object);
  852. if (missile_obj)
  853. {
  854. int enemy_id = Commands->Get_ID (enemy);
  855. Commands->Send_Custom_Event (obj, missile_obj, 1, enemy_id);
  856. }
  857. Vector3 my_loc = Commands->Get_Position (obj);
  858. Vector3 enemy_loc = Commands->Get_Position (enemy);
  859. float distance = Commands->Get_Distance (my_loc, enemy_loc);
  860. if (distance > 20.0f)
  861. {
  862. ActionParamsStruct params;
  863. params.Set_Basic(this, 100, 1);
  864. params.Set_Attack(enemy, 300.0f, 0.0f, true);
  865. params.AttackCheckBlocked = false;
  866. Commands->Action_Attack(obj, params);
  867. Commands->Start_Timer (obj, this, 10.0f, 1);
  868. }
  869. }
  870. }
  871. void Timer_Expired (GameObject * obj, int timer_id)
  872. {
  873. if (timer_id == 1)
  874. {
  875. Commands->Action_Reset (obj, 100.0f);
  876. }
  877. }
  878. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  879. {
  880. if (type == 1)
  881. {
  882. missile_object = param;
  883. }
  884. else if (type == 2)
  885. {
  886. if (param == 0)
  887. {
  888. Commands->Enable_Enemy_Seen (obj, false);
  889. }
  890. else
  891. {
  892. Commands->Enable_Enemy_Seen (obj, true);
  893. }
  894. }
  895. else if (type == 3)//AGT has been killed...reset your action and prevent further firing -- 02/12/2002 JDG
  896. {
  897. agt_is_dead = true;
  898. Commands->Action_Reset (obj, 100.0f);
  899. }
  900. }
  901. };
  902. DECLARE_SCRIPT (M00_Advanced_Guard_Tower_Missile, "")
  903. {
  904. bool firing;
  905. void Created (GameObject * obj)
  906. {
  907. Commands->Set_Is_Rendered (obj, false);
  908. Commands->Enable_Hibernation (obj, false);
  909. firing = false;
  910. }
  911. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  912. {
  913. if (type == 1)
  914. {
  915. GameObject * enemy = Commands->Find_Object (param);
  916. if (enemy)
  917. {
  918. Vector3 my_position = Commands->Get_Position (obj);
  919. Vector3 enemy_position = Commands->Get_Position (enemy);
  920. float distance = Commands->Get_Distance (my_position, enemy_position);
  921. if (distance > 30.0f)
  922. {
  923. if (!firing)
  924. {
  925. firing = true;
  926. ActionParamsStruct params;
  927. params.Set_Basic(this, 100, 1);
  928. params.Set_Attack(enemy, 300.0f, 0.0f, true);
  929. params.AttackCheckBlocked = false;
  930. Commands->Action_Attack(obj, params);
  931. Commands->Start_Timer (obj, this, 1.0f, 1);
  932. }
  933. }
  934. }
  935. }
  936. }
  937. void Timer_Expired (GameObject * obj, int timer_id)
  938. {
  939. if (timer_id == 1)
  940. {
  941. Commands->Action_Reset (obj, 100);
  942. firing = false;
  943. }
  944. }
  945. };
  946. DECLARE_SCRIPT (M00_Purchase_Terminal_GDI, "")
  947. {
  948. void Poked (GameObject * obj, GameObject * poker)
  949. {
  950. Commands->Display_GDI_Player_Terminal ();
  951. }
  952. };
  953. DECLARE_SCRIPT (M00_Purchase_Terminal_NOD, "")
  954. {
  955. void Poked (GameObject * obj, GameObject * poker)
  956. {
  957. Commands->Display_NOD_Player_Terminal ();
  958. }
  959. };
  960. DECLARE_SCRIPT (M00_Purchase_Terminal_Mutant, "")
  961. {
  962. void Poked (GameObject * obj, GameObject * poker)
  963. {
  964. Commands->Display_Mutant_Player_Terminal ();
  965. }
  966. };
  967. DECLARE_SCRIPT (M00_Nod_Turret, "")
  968. {
  969. int token_01_id;
  970. int token_02_id;
  971. int token_03_id;
  972. REGISTER_VARIABLES()
  973. {
  974. SAVE_VARIABLE (token_01_id, 1);
  975. SAVE_VARIABLE (token_02_id, 2);
  976. SAVE_VARIABLE (token_03_id, 3);
  977. }
  978. void Created (GameObject * obj)
  979. {
  980. Commands->Enable_Hibernation (obj, false);
  981. Commands->Innate_Enable (obj);
  982. Commands->Enable_Enemy_Seen (obj, true);
  983. Vector3 my_position = Commands->Get_Position (obj);
  984. Vector3 token_01_pos = my_position;
  985. Vector3 token_02_pos = my_position;
  986. Vector3 token_03_pos = my_position;
  987. token_01_pos.X -= 10.0f;
  988. token_01_pos.Y -= 10.0f;
  989. token_01_pos.Z += 2.0f;
  990. token_02_pos.X += 10.0f;
  991. token_02_pos.Z += 2.0f;
  992. token_03_pos.X += 10.0f;
  993. token_03_pos.Y -= 10.0f;
  994. token_03_pos.Z += 2.0f;
  995. GameObject * token_01 = Commands->Create_Object ("Invisible_Object", token_01_pos);
  996. if (token_01)
  997. {
  998. token_01_id = Commands->Get_ID (token_01);
  999. }
  1000. token_01 = Commands->Create_Object ("Invisible_Object", token_02_pos);
  1001. if (token_01)
  1002. {
  1003. token_02_id = Commands->Get_ID (token_01);
  1004. }
  1005. token_01 = Commands->Create_Object ("Invisible_Object", token_03_pos);
  1006. if (token_01)
  1007. {
  1008. token_03_id = Commands->Get_ID (token_01);
  1009. }
  1010. Commands->Start_Timer (obj, this, 10.0f, 1);
  1011. }
  1012. void Timer_Expired (GameObject * obj, int timer_id)
  1013. {
  1014. if (timer_id == 1)
  1015. {
  1016. int rnd_num = Get_Int_Random(0,2);
  1017. switch (rnd_num)
  1018. {
  1019. case (0):
  1020. {
  1021. GameObject * token_01 = Commands->Find_Object (token_01_id);
  1022. if (token_01)
  1023. {
  1024. ActionParamsStruct params;
  1025. params.Set_Basic(this, 70, 1);
  1026. params.Set_Attack(token_01, 0.0f, 0.0f, true);
  1027. Commands->Action_Attack(obj, params);
  1028. }
  1029. break;
  1030. }
  1031. case (1):
  1032. {
  1033. GameObject * token_02 = Commands->Find_Object (token_02_id);
  1034. if (token_02)
  1035. {
  1036. ActionParamsStruct params;
  1037. params.Set_Basic(this, 70, 1);
  1038. params.Set_Attack(token_02, 0.0f, 0.0f, true);
  1039. Commands->Action_Attack(obj, params);
  1040. }
  1041. break;
  1042. }
  1043. default:
  1044. {
  1045. GameObject * token_03 = Commands->Find_Object (token_03_id);
  1046. if (token_03)
  1047. {
  1048. ActionParamsStruct params;
  1049. params.Set_Basic(this, 70, 1);
  1050. params.Set_Attack(token_03, 0.0f, 0.0f, true);
  1051. Commands->Action_Attack(obj, params);
  1052. }
  1053. }
  1054. }
  1055. Commands->Start_Timer (obj, this, 10.0f, 1);
  1056. }
  1057. else if (timer_id == 2)
  1058. {
  1059. Commands->Action_Reset (obj, 100.0f);
  1060. }
  1061. }
  1062. void Enemy_Seen (GameObject * obj, GameObject * enemy)
  1063. {
  1064. Vector3 target_pos = Commands->Get_Position (enemy);
  1065. target_pos.Z -= 0.5f;
  1066. ActionParamsStruct params;
  1067. params.Set_Basic(this, 100, 2);
  1068. params.Set_Attack(target_pos, 300.0f, 0.0f, true);
  1069. params.AttackCheckBlocked = false;
  1070. Commands->Action_Attack(obj, params);
  1071. Commands->Start_Timer (obj, this, 2.0f, 2);
  1072. }
  1073. void Killed(GameObject * obj, GameObject * killer)
  1074. {
  1075. Vector3 myPositon = Commands->Get_Position ( obj );
  1076. float myFacing = Commands->Get_Facing ( obj );
  1077. GameObject * destroyedTurret = Commands->Create_Object ( "Nod_Turret_Destroyed", myPositon);
  1078. Commands->Set_Facing ( destroyedTurret, myFacing );
  1079. }
  1080. void Action_Complete (GameObject * obj, int action_id, ActionCompleteReason complete_reason)
  1081. {
  1082. if (action_id == 2)
  1083. {
  1084. Commands->Action_Reset (obj, 100.0f);
  1085. }
  1086. }
  1087. };
  1088. DECLARE_SCRIPT(M00_Nod_Obelisk_CNC, "Controller_ID=0:int")
  1089. {
  1090. int obelisk_id;
  1091. REGISTER_VARIABLES()
  1092. {
  1093. SAVE_VARIABLE (obelisk_id, 1);
  1094. }
  1095. void Created (GameObject * obj)
  1096. {
  1097. obelisk_id = 0;
  1098. Vector3 my_location = Commands->Get_Position (obj);
  1099. my_location.Z += 45.0f;
  1100. GameObject * obelisk = Commands->Create_Object ("Nod_Obelisk", my_location);
  1101. if (obelisk)
  1102. {
  1103. Commands->Attach_Script (obelisk, "M00_Obelisk_Weapon_CNC", "");
  1104. Commands->Start_Timer (obj, this, 1.0f, 1);
  1105. obelisk_id = Commands->Get_ID (obelisk);
  1106. // Send Obelisk Weapon ID to controller identified through parameter Controller_ID
  1107. Commands->Send_Custom_Event (obj, Commands->Find_Object(Get_Int_Parameter("Controller_ID")), M00_OBELISK_WEAPON_ID, Commands->Get_ID(obelisk), 0);
  1108. }
  1109. }
  1110. void Killed( GameObject * obj, GameObject * killer )
  1111. {
  1112. GameObject * obelisk = Commands->Find_Object(obelisk_id);
  1113. if (obelisk != NULL)
  1114. {
  1115. Commands->Send_Custom_Event (obj, obelisk, 3, 0, 0);//this custom tells the obelisk weapon that the obelisk has been destroyed -- 02/12/2002 JDG
  1116. }
  1117. }
  1118. void Timer_Expired (GameObject * obj, int timer_id)
  1119. {
  1120. if (timer_id == 1)
  1121. {
  1122. float health = Commands->Get_Health (obj);
  1123. bool power = Commands->Get_Building_Power (obj);
  1124. if ((!health) || (!power))
  1125. {
  1126. GameObject * obelisk = Commands->Find_Object (obelisk_id);
  1127. if (obelisk)
  1128. {
  1129. Commands->Send_Custom_Event (obj, obelisk, 1, 0);
  1130. }
  1131. }
  1132. else if (power)
  1133. {
  1134. GameObject * obelisk = Commands->Find_Object (obelisk_id);
  1135. if (obelisk)
  1136. {
  1137. Commands->Send_Custom_Event (obj, obelisk, 1, 1);
  1138. }
  1139. }
  1140. Commands->Start_Timer (obj, this, 1.0f, 1);
  1141. }
  1142. }
  1143. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  1144. {
  1145. if ((type == 1) && (param == 1))
  1146. {
  1147. // Custom received to destroy obelisk weapon.
  1148. GameObject * obelisk = Commands->Find_Object (obelisk_id);
  1149. if (obelisk)
  1150. {
  1151. Commands->Destroy_Object (obelisk);
  1152. }
  1153. }
  1154. }
  1155. };
  1156. DECLARE_SCRIPT (M00_Obelisk_Weapon_CNC, "")
  1157. {
  1158. bool able_to_fire;
  1159. int current_target;
  1160. int powerup_effect_id;
  1161. float range;
  1162. bool obelisk_is_dead;//adding bool trying to eliminate lingering firing bug -- 02/12/2002 JDG
  1163. REGISTER_VARIABLES()
  1164. {
  1165. SAVE_VARIABLE (able_to_fire, 1);
  1166. SAVE_VARIABLE (current_target, 2);
  1167. SAVE_VARIABLE (powerup_effect_id, 3);
  1168. SAVE_VARIABLE (range, 4);
  1169. SAVE_VARIABLE (obelisk_is_dead, 5);
  1170. }
  1171. void Created (GameObject * obj)
  1172. {
  1173. obelisk_is_dead = false;
  1174. range = 150.0f;
  1175. powerup_effect_id = 0;
  1176. current_target = 0;
  1177. able_to_fire = true;
  1178. Commands->Set_Player_Type (obj, SCRIPT_PLAYERTYPE_NOD);
  1179. Commands->Set_Is_Rendered (obj, false);
  1180. Commands->Enable_Enemy_Seen (obj, true);
  1181. Commands->Enable_Hibernation (obj, false);
  1182. Commands->Innate_Enable (obj);
  1183. Vector3 my_position = Commands->Get_Position (obj);
  1184. GameObject * effect = Commands->Create_Object ("Obelisk Effect", my_position);
  1185. if (effect)
  1186. {
  1187. powerup_effect_id = Commands->Get_ID (effect);
  1188. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 0);
  1189. }
  1190. }
  1191. void Enemy_Seen(GameObject * obj, GameObject *enemy )
  1192. {
  1193. if (obelisk_is_dead == false)//adding extra safety check here -- 02/12/2002 JDG
  1194. {
  1195. int enemy_id = Commands->Get_ID (enemy);
  1196. Commands->Send_Custom_Event (obj, obj, 2, enemy_id);
  1197. }
  1198. }
  1199. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  1200. {
  1201. if (type == 1)
  1202. {
  1203. if (param == 0)
  1204. {
  1205. Commands->Enable_Enemy_Seen (obj, false);
  1206. able_to_fire = false;
  1207. ActionParamsStruct params;
  1208. params.Set_Basic (this, 100, 0);
  1209. params.Set_Attack (obj, 0.0f, 0.0f, true);
  1210. Commands->Action_Attack (obj, params);
  1211. Commands->Action_Reset (obj, 100.0f);
  1212. Destroy_Obelisk_Effect ();
  1213. }
  1214. else
  1215. {
  1216. Commands->Enable_Enemy_Seen (obj, true);
  1217. able_to_fire = true;
  1218. }
  1219. }
  1220. else if (type == 2)
  1221. {
  1222. if (obelisk_is_dead == false)//adding extra safety check here -- 02/12/2002 JDG
  1223. {
  1224. if (able_to_fire)
  1225. {
  1226. GameObject * target_obj = Commands->Find_Object (param);
  1227. if (target_obj)
  1228. {
  1229. Vector3 enemy_position = Commands->Get_Position (target_obj);
  1230. Vector3 my_position = Commands->Get_Position (obj);
  1231. float distance = Commands->Get_Distance (my_position, enemy_position);
  1232. enemy_position.Z = 0.0f;
  1233. my_position.Z = 0.0f;
  1234. float difference = Commands->Get_Distance (my_position, enemy_position);
  1235. if ((difference > 15.0f) && (distance < range))
  1236. {
  1237. current_target = param;
  1238. able_to_fire = false;
  1239. Commands->Start_Timer (obj, this, 2.0f, 1);
  1240. GameObject * effect = Commands->Find_Object (powerup_effect_id);
  1241. if (effect)
  1242. {
  1243. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 1);
  1244. }
  1245. my_position.Z -= 20.0f;
  1246. Commands->Create_Sound ("Obelisk_Warm_Up", my_position, obj);
  1247. }
  1248. else
  1249. {
  1250. Destroy_Obelisk_Effect ();
  1251. Commands->Action_Reset (obj, 100.0f);
  1252. }
  1253. }
  1254. }
  1255. }
  1256. }
  1257. else if (type == 3)//obelisk has been killed, reset action and prevent further firing -- 02/12/2002 JDG
  1258. {
  1259. obelisk_is_dead = true;
  1260. Destroy_Obelisk_Effect ();
  1261. Commands->Action_Reset (obj, 100.0f);
  1262. }
  1263. }
  1264. void Timer_Expired (GameObject * obj, int timer_id)
  1265. {
  1266. if (obelisk_is_dead == false)//adding extra safety check here -- 02/12/2002 JDG
  1267. {
  1268. if (timer_id == 1)
  1269. {
  1270. GameObject * target_obj = Commands->Find_Object (current_target);
  1271. if (target_obj)
  1272. {
  1273. Vector3 my_position = Commands->Get_Position (obj);
  1274. Vector3 enemy_position = Commands->Get_Position (target_obj);
  1275. float distance = Commands->Get_Distance (my_position, enemy_position);
  1276. enemy_position.Z = 0.0f;
  1277. my_position.Z = 0.0f;
  1278. float difference = Commands->Get_Distance (my_position, enemy_position);
  1279. if ((difference > 15.0f) && (distance < range))
  1280. {
  1281. ActionParamsStruct params;
  1282. params.Set_Basic (this, 100, 0);
  1283. params.Set_Attack (target_obj, range, 0.0f, true);
  1284. Commands->Action_Attack (obj, params);
  1285. current_target = 0;
  1286. Commands->Start_Timer (obj, this, 2.0f, 2);
  1287. }
  1288. else
  1289. {
  1290. Destroy_Obelisk_Effect ();
  1291. Commands->Action_Reset (obj, 100.0f);
  1292. able_to_fire = true;
  1293. }
  1294. }
  1295. else
  1296. {
  1297. Destroy_Obelisk_Effect ();
  1298. Commands->Action_Reset (obj, 100.0f);
  1299. able_to_fire = true;
  1300. }
  1301. }
  1302. else if (timer_id == 2)
  1303. {
  1304. Destroy_Obelisk_Effect ();
  1305. able_to_fire = true;
  1306. }
  1307. }
  1308. }
  1309. void Destroy_Obelisk_Effect (void)
  1310. {
  1311. if (powerup_effect_id)
  1312. {
  1313. GameObject * effect = Commands->Find_Object (powerup_effect_id);
  1314. if (effect)
  1315. {
  1316. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 0);
  1317. }
  1318. }
  1319. }
  1320. };
  1321. DECLARE_SCRIPT(M00_Nod_Obelisk, "Controller_ID=0:int")
  1322. {
  1323. int obelisk_id;
  1324. REGISTER_VARIABLES()
  1325. {
  1326. SAVE_VARIABLE (obelisk_id, 1);
  1327. }
  1328. void Created (GameObject * obj)
  1329. {
  1330. obelisk_id = 0;
  1331. Vector3 my_location = Commands->Get_Position (obj);
  1332. my_location.Z += 45.0f;
  1333. GameObject * obelisk = Commands->Create_Object ("Nod_Obelisk", my_location);
  1334. if (obelisk)
  1335. {
  1336. Commands->Attach_Script (obelisk, "M00_Obelisk_Weapon", "");
  1337. Commands->Start_Timer (obj, this, 1.0f, 1);
  1338. obelisk_id = Commands->Get_ID (obelisk);
  1339. // Send Obelisk Weapon ID to controller identified through parameter Controller_ID
  1340. int controller_id = Get_Int_Parameter("Controller_ID");
  1341. Commands->Send_Custom_Event (obj, Commands->Find_Object(controller_id), M00_OBELISK_WEAPON_ID, Commands->Get_ID(obelisk), 4.0f);
  1342. }
  1343. }
  1344. void Timer_Expired (GameObject * obj, int timer_id)
  1345. {
  1346. if (timer_id == 1)
  1347. {
  1348. float health = Commands->Get_Health (obj);
  1349. bool power = Commands->Get_Building_Power (obj);
  1350. if ((!health) || (!power))
  1351. {
  1352. GameObject * obelisk = Commands->Find_Object (obelisk_id);
  1353. if (obelisk)
  1354. {
  1355. Commands->Send_Custom_Event (obj, obelisk, 1, 0);
  1356. }
  1357. }
  1358. else if (power)
  1359. {
  1360. GameObject * obelisk = Commands->Find_Object (obelisk_id);
  1361. if (obelisk)
  1362. {
  1363. Commands->Send_Custom_Event (obj, obelisk, 1, 1);
  1364. }
  1365. }
  1366. Commands->Start_Timer (obj, this, 1.0f, 1);
  1367. }
  1368. }
  1369. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  1370. {
  1371. if ((type == 1) && (param == 1))
  1372. {
  1373. // Custom received to destroy obelisk weapon.
  1374. GameObject * obelisk = Commands->Find_Object (obelisk_id);
  1375. if (obelisk)
  1376. {
  1377. Commands->Destroy_Object (obelisk);
  1378. }
  1379. }
  1380. }
  1381. };
  1382. DECLARE_SCRIPT (M00_Obelisk_Weapon, "")
  1383. {
  1384. bool able_to_fire;
  1385. int current_target;
  1386. int powerup_effect_id;
  1387. REGISTER_VARIABLES()
  1388. {
  1389. SAVE_VARIABLE (able_to_fire, 1);
  1390. SAVE_VARIABLE (current_target, 2);
  1391. SAVE_VARIABLE (powerup_effect_id, 3);
  1392. }
  1393. void Created (GameObject * obj)
  1394. {
  1395. powerup_effect_id = 0;
  1396. current_target = 0;
  1397. able_to_fire = true;
  1398. Commands->Set_Player_Type (obj, SCRIPT_PLAYERTYPE_NOD);
  1399. Commands->Set_Is_Rendered (obj, false);
  1400. Commands->Enable_Enemy_Seen (obj, true);
  1401. Commands->Enable_Hibernation (obj, false);
  1402. Commands->Innate_Enable (obj);
  1403. Vector3 my_position = Commands->Get_Position (obj);
  1404. GameObject * effect = Commands->Create_Object ("Obelisk Effect", my_position);
  1405. if (effect)
  1406. {
  1407. powerup_effect_id = Commands->Get_ID (effect);
  1408. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 0);
  1409. }
  1410. }
  1411. void Enemy_Seen(GameObject * obj, GameObject *enemy )
  1412. {
  1413. int enemy_id = Commands->Get_ID (enemy);
  1414. Commands->Send_Custom_Event (obj, obj, 2, enemy_id);
  1415. }
  1416. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  1417. {
  1418. if (type == 1)
  1419. {
  1420. if (param == 0)
  1421. {
  1422. Commands->Enable_Enemy_Seen (obj, false);
  1423. able_to_fire = false;
  1424. ActionParamsStruct params;
  1425. params.Set_Basic (this, 100, 0);
  1426. params.Set_Attack (obj, 0.0f, 0.0f, true);
  1427. Commands->Action_Attack (obj, params);
  1428. Commands->Action_Reset (obj, 100.0f);
  1429. Destroy_Obelisk_Effect ();
  1430. }
  1431. else
  1432. {
  1433. Commands->Enable_Enemy_Seen (obj, true);
  1434. able_to_fire = true;
  1435. }
  1436. }
  1437. else if (type == 2)
  1438. {
  1439. if (able_to_fire)
  1440. {
  1441. GameObject * target_obj = Commands->Find_Object (param);
  1442. if (target_obj)
  1443. {
  1444. Vector3 enemy_position = Commands->Get_Position (target_obj);
  1445. Vector3 my_position = Commands->Get_Position (obj);
  1446. float distance = Commands->Get_Distance (my_position, enemy_position);
  1447. enemy_position.Z = 0.0f;
  1448. my_position.Z = 0.0f;
  1449. float difference = Commands->Get_Distance (my_position, enemy_position);
  1450. if ((difference > 15.0f) && (distance < 70.0f))
  1451. {
  1452. current_target = param;
  1453. able_to_fire = false;
  1454. Commands->Start_Timer (obj, this, 2.5f, 1);
  1455. GameObject * effect = Commands->Find_Object (powerup_effect_id);
  1456. if (effect)
  1457. {
  1458. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 1);
  1459. }
  1460. my_position.Z -= 20.0f;
  1461. Commands->Create_Sound ("Obelisk_Warm_Up", my_position, obj);
  1462. }
  1463. else
  1464. {
  1465. Destroy_Obelisk_Effect ();
  1466. Commands->Action_Reset (obj, 100.0f);
  1467. }
  1468. }
  1469. }
  1470. }
  1471. }
  1472. void Timer_Expired (GameObject * obj, int timer_id)
  1473. {
  1474. if (timer_id == 1)
  1475. {
  1476. GameObject * target_obj = Commands->Find_Object (current_target);
  1477. if (target_obj)
  1478. {
  1479. Vector3 my_position = Commands->Get_Position (obj);
  1480. Vector3 enemy_position = Commands->Get_Position (target_obj);
  1481. float distance = Commands->Get_Distance (my_position, enemy_position);
  1482. enemy_position.Z = 0.0f;
  1483. my_position.Z = 0.0f;
  1484. float difference = Commands->Get_Distance (my_position, enemy_position);
  1485. if ((difference > 15.0f) && (distance < 70.0f))
  1486. {
  1487. ActionParamsStruct params;
  1488. params.Set_Basic (this, 100, 0);
  1489. params.Set_Attack (target_obj, 150.0f, 0.0f, true);
  1490. Commands->Action_Attack (obj, params);
  1491. current_target = 0;
  1492. Commands->Start_Timer (obj, this, 2.0f, 2);
  1493. }
  1494. else
  1495. {
  1496. Destroy_Obelisk_Effect ();
  1497. Commands->Action_Reset (obj, 100.0f);
  1498. able_to_fire = true;
  1499. }
  1500. }
  1501. else
  1502. {
  1503. Destroy_Obelisk_Effect ();
  1504. Commands->Action_Reset (obj, 100.0f);
  1505. able_to_fire = true;
  1506. }
  1507. }
  1508. else if (timer_id == 2)
  1509. {
  1510. Destroy_Obelisk_Effect ();
  1511. able_to_fire = true;
  1512. }
  1513. }
  1514. void Destroy_Obelisk_Effect (void)
  1515. {
  1516. if (powerup_effect_id)
  1517. {
  1518. GameObject * effect = Commands->Find_Object (powerup_effect_id);
  1519. if (effect)
  1520. {
  1521. Commands->Set_Animation_Frame (effect, "OBL_POWERUP.OBL_POWERUP", 0);
  1522. }
  1523. }
  1524. }
  1525. };
  1526. DECLARE_SCRIPT (M00_Select_Empty_Hands, "On_Created=1:int")
  1527. {
  1528. void Created (GameObject * obj)
  1529. {
  1530. bool on_created = (Get_Int_Parameter("On_Created") == 1) ? true : false;
  1531. if(on_created)
  1532. {
  1533. Commands->Select_Weapon(obj, NULL );
  1534. }
  1535. }
  1536. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  1537. {
  1538. if(type == M00_SELECT_EMPTY_HANDS)
  1539. {
  1540. Commands->Select_Weapon(obj, NULL );
  1541. }
  1542. }
  1543. };
  1544. DECLARE_SCRIPT(M00_ArmorMedal_TextMessage_JDG, "")
  1545. {
  1546. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  1547. {
  1548. if ( type == CUSTOM_EVENT_POWERUP_GRANTED )
  1549. {
  1550. Commands->Set_HUD_Help_Text ( IDS_M00DSGN_DSGN1009I1DSGN_TXT, TEXT_COLOR_OBJECTIVE_PRIMARY );
  1551. }
  1552. }
  1553. };
  1554. DECLARE_SCRIPT(M00_HealthMedal_TextMessage_JDG, "")
  1555. {
  1556. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  1557. {
  1558. if ( type == CUSTOM_EVENT_POWERUP_GRANTED )
  1559. {
  1560. Commands->Set_HUD_Help_Text ( IDS_M00DSGN_DSGN1008I1DSGN_TXT, TEXT_COLOR_OBJECTIVE_PRIMARY );
  1561. }
  1562. }
  1563. };
  1564. DECLARE_SCRIPT(M00_Change_L3Mutant_RadarMarker_JDG, "")
  1565. {
  1566. void Created( GameObject * obj )
  1567. {
  1568. Commands->Set_Obj_Radar_Blip_Color ( obj, RADAR_BLIP_COLOR_MUTANT );
  1569. }
  1570. };
  1571. DECLARE_SCRIPT(M00_SSM_DLS, "")
  1572. {
  1573. int ssm_missile_id;
  1574. bool launched;
  1575. // Register variables to be Auto-Saved
  1576. // All variables must have a unique ID, less than 256, that never changes
  1577. REGISTER_VARIABLES()
  1578. {
  1579. SAVE_VARIABLE( ssm_missile_id, 1 );
  1580. SAVE_VARIABLE( launched, 2 );
  1581. }
  1582. void Created (GameObject * obj)
  1583. {
  1584. launched = false;
  1585. GameObject * ssm_missile = Commands->Create_Object_At_Bone(obj, "Saveable_Invisible_Object", "V_LAUNCHER");
  1586. Commands->Set_Model(ssm_missile, "V_AG_NOD_SSM_MS");
  1587. Commands->Attach_To_Object_Bone(ssm_missile, obj, "V_LAUNCHER");
  1588. ssm_missile_id = Commands->Get_ID(ssm_missile);
  1589. }
  1590. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  1591. {
  1592. if(type == M00_LAUNCH_SSM)
  1593. {
  1594. Commands->Set_Animation(obj, "V_NOD_SSM.V_NOD_SSM", 0);
  1595. Commands->Set_Animation(Commands->Find_Object(ssm_missile_id), "v_nod_ssm_Missl.v_nod_ssm_Missl", 0);
  1596. Commands->Start_Timer(obj, this, 7.0f, 66000);
  1597. }
  1598. }
  1599. void Timer_Expired (GameObject *obj, int Timer_ID)
  1600. {
  1601. if (Timer_ID == 66000)
  1602. {
  1603. launched = true;
  1604. }
  1605. }
  1606. void Killed (GameObject *obj, GameObject *killer)
  1607. {
  1608. if (!launched)
  1609. {
  1610. Commands->Destroy_Object (Commands->Find_Object (ssm_missile_id));
  1611. }
  1612. }
  1613. };
  1614. DECLARE_SCRIPT(M00_Generic_Conv_DME, "ConvName:string")
  1615. {
  1616. void Created (GameObject *obj)
  1617. {
  1618. int id = Commands->Create_Conversation(Get_Parameter( "ConvName" ), 99, 2000, false);
  1619. Commands->Join_Conversation(obj, id);
  1620. Commands->Start_Conversation(id, 100000);
  1621. Commands->Monitor_Conversation(obj, id);
  1622. }
  1623. };
  1624. DECLARE_SCRIPT (M00_Damage_Modifier_DME, "Damage_multiplier:float, Star_Modifier=1:int, NotStar_Modifier=1:int, Killable_By_Star=1:int, Killable_by_NotStar=1:int")
  1625. {
  1626. float current_health, last_health, damage_tally;
  1627. int star_killable, notStar_killable;
  1628. int star_modifier, notStar_modifier;
  1629. bool mod_on;
  1630. REGISTER_VARIABLES()
  1631. {
  1632. SAVE_VARIABLE( current_health, 1 );
  1633. SAVE_VARIABLE( last_health, 2 );
  1634. SAVE_VARIABLE( damage_tally, 3 );
  1635. SAVE_VARIABLE( star_killable, 4 );
  1636. SAVE_VARIABLE( notStar_killable, 5 );
  1637. SAVE_VARIABLE( star_modifier, 6 );
  1638. SAVE_VARIABLE( notStar_modifier, 7 );
  1639. SAVE_VARIABLE( mod_on, 8 );
  1640. }
  1641. void Created (GameObject *obj)
  1642. {
  1643. mod_on = true;
  1644. last_health = Commands->Get_Health (obj);
  1645. damage_tally = 0;
  1646. star_killable = Get_Int_Parameter("Killable_By_Star");
  1647. notStar_killable = Get_Int_Parameter("Killable_ByNotStar");
  1648. star_modifier = Get_Int_Parameter("Star_Modifier");
  1649. notStar_modifier = Get_Int_Parameter("NotStar_Modifier");
  1650. }
  1651. void Custom (GameObject *obj, int type, int param, GameObject *sender)
  1652. {
  1653. if (type == M00_ENABLE_DAMAGE_MOD)
  1654. {
  1655. if (param == 1)
  1656. {
  1657. mod_on = true;
  1658. }
  1659. if (param == 0)
  1660. {
  1661. mod_on = false;
  1662. }
  1663. }
  1664. }
  1665. void Damaged( GameObject * obj, GameObject * damager, float amount )
  1666. {
  1667. if (mod_on)
  1668. {
  1669. float damage;
  1670. if ((!star_modifier && damager == STAR && star_killable) || (!notStar_modifier && damager != STAR && notStar_killable))
  1671. {
  1672. last_health = Commands->Get_Health (obj);
  1673. }
  1674. if ((star_modifier && damager == STAR && star_killable) || (notStar_modifier && damager != STAR && notStar_killable))
  1675. {
  1676. current_health = Commands->Get_Health (obj);
  1677. if (current_health == 0)
  1678. {
  1679. damage = ((last_health - current_health) + damage_tally);
  1680. }
  1681. else
  1682. {
  1683. damage = (last_health - current_health);
  1684. }
  1685. float mod_damage = (damage * (Get_Float_Parameter("Damage_multiplier")));
  1686. damage_tally += mod_damage;
  1687. Commands->Set_Health (obj, (last_health - mod_damage));
  1688. last_health = Commands->Get_Health (obj);
  1689. current_health = Commands->Get_Health (obj);
  1690. }
  1691. if ((star_modifier && damager == STAR && !star_killable) || (notStar_modifier && damager != STAR && !notStar_killable))
  1692. {
  1693. current_health = Commands->Get_Health (obj);
  1694. if (current_health == 0)
  1695. {
  1696. damage = ((last_health - current_health));
  1697. }
  1698. else
  1699. {
  1700. damage = (last_health - current_health);
  1701. }
  1702. float mod_damage = (damage * (Get_Float_Parameter("Damage_multiplier")));
  1703. Commands->Set_Health (obj, (last_health - mod_damage));
  1704. last_health = Commands->Get_Health (obj);
  1705. current_health = Commands->Get_Health (obj);
  1706. }
  1707. }
  1708. }
  1709. };
  1710. DECLARE_SCRIPT (M00_Base_Defense, "MinAttackDistance=0:int, MaxAttackDistance=300:int, AttackTimer=10:int")
  1711. {
  1712. int token_01_id;
  1713. int token_02_id;
  1714. int token_03_id;
  1715. int player_type;
  1716. REGISTER_VARIABLES()
  1717. {
  1718. SAVE_VARIABLE (token_01_id, 1);
  1719. SAVE_VARIABLE (token_02_id, 2);
  1720. SAVE_VARIABLE (token_03_id, 3);
  1721. SAVE_VARIABLE (player_type, 4);
  1722. }
  1723. void Created (GameObject * obj)
  1724. {
  1725. // find out what my team preset is.
  1726. player_type = Commands->Get_Player_Type( obj );
  1727. Commands->Debug_Message( "***** Player Type Saved *****\n" );
  1728. Commands->Enable_Hibernation (obj, false);
  1729. Commands->Innate_Enable (obj);
  1730. Commands->Enable_Enemy_Seen (obj, true);
  1731. Vector3 my_position = Commands->Get_Position (obj);
  1732. Vector3 token_01_pos = my_position;
  1733. Vector3 token_02_pos = my_position;
  1734. Vector3 token_03_pos = my_position;
  1735. token_01_pos.X -= 10.0f;
  1736. token_01_pos.Y -= 10.0f;
  1737. token_01_pos.Z += 2.0f;
  1738. token_02_pos.X += 10.0f;
  1739. token_02_pos.Z += 2.0f;
  1740. token_03_pos.X += 10.0f;
  1741. token_03_pos.Y -= 10.0f;
  1742. token_03_pos.Z += 2.0f;
  1743. GameObject * token_01 = Commands->Create_Object ("Invisible_Object", token_01_pos);
  1744. if (token_01)
  1745. {
  1746. token_01_id = Commands->Get_ID (token_01);
  1747. }
  1748. token_01 = Commands->Create_Object ("Invisible_Object", token_02_pos);
  1749. if (token_01)
  1750. {
  1751. token_02_id = Commands->Get_ID (token_01);
  1752. }
  1753. token_01 = Commands->Create_Object ("Invisible_Object", token_03_pos);
  1754. if (token_01)
  1755. {
  1756. token_03_id = Commands->Get_ID (token_01);
  1757. }
  1758. Commands->Start_Timer (obj, this, 10.0f, 1);
  1759. }
  1760. void Timer_Expired (GameObject * obj, int timer_id)
  1761. {
  1762. if (timer_id == 1)
  1763. {
  1764. int rnd_num = Get_Int_Random(0,2);
  1765. switch (rnd_num)
  1766. {
  1767. case (0):
  1768. {
  1769. GameObject * token_01 = Commands->Find_Object (token_01_id);
  1770. if (token_01)
  1771. {
  1772. ActionParamsStruct params;
  1773. params.Set_Basic(this, 70, 1);
  1774. params.Set_Attack(token_01, 0.0f, 0.0f, true);
  1775. Commands->Action_Attack(obj, params);
  1776. }
  1777. break;
  1778. }
  1779. case (1):
  1780. {
  1781. GameObject * token_02 = Commands->Find_Object (token_02_id);
  1782. if (token_02)
  1783. {
  1784. ActionParamsStruct params;
  1785. params.Set_Basic(this, 70, 1);
  1786. params.Set_Attack(token_02, 0.0f, 0.0f, true);
  1787. Commands->Action_Attack(obj, params);
  1788. }
  1789. break;
  1790. }
  1791. default:
  1792. {
  1793. GameObject * token_03 = Commands->Find_Object (token_03_id);
  1794. if (token_03)
  1795. {
  1796. ActionParamsStruct params;
  1797. params.Set_Basic(this, 70, 1);
  1798. params.Set_Attack(token_03, 0.0f, 0.0f, true);
  1799. Commands->Action_Attack(obj, params);
  1800. }
  1801. }
  1802. }
  1803. Commands->Start_Timer (obj, this, 10.0f, 1);
  1804. }
  1805. else if (timer_id == 2)
  1806. {
  1807. Commands->Action_Reset (obj, 100.0f);
  1808. }
  1809. }
  1810. void Enemy_Seen (GameObject * obj, GameObject * enemy)
  1811. {
  1812. Vector3 my_loc = Commands->Get_Position (obj);
  1813. Vector3 enemy_loc = Commands->Get_Position (enemy);
  1814. float distance = Commands->Get_Distance (my_loc, enemy_loc);
  1815. if (distance > Get_Int_Parameter("MinAttackDistance") )
  1816. {
  1817. ActionParamsStruct params;
  1818. params.Set_Basic(this, 100, 2);
  1819. params.Set_Attack(enemy, Get_Int_Parameter("MaxAttackDistance"), 0.0f, true);
  1820. params.AttackCheckBlocked = false;
  1821. Commands->Action_Attack(obj, params);
  1822. Commands->Start_Timer (obj, this, Get_Int_Parameter( "AttackTimer"), 2);
  1823. }
  1824. }
  1825. void Action_Complete (GameObject * obj, int action_id, ActionCompleteReason complete_reason)
  1826. {
  1827. if (action_id == 2)
  1828. {
  1829. Commands->Action_Reset (obj, 100.0f);
  1830. }
  1831. }
  1832. void Exited (GameObject* obj, GameObject* exiter)
  1833. {
  1834. // set team back to my preset.
  1835. Commands->Set_Player_Type( obj, player_type );
  1836. Commands->Debug_Message( "***** Player Type Exited *****\n" );
  1837. }
  1838. };