Toolkit_Triggers.cpp 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429
  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_Triggers.cpp
  22. *
  23. * DESCRIPTION
  24. * Designer Toolkit for Mission Construction - Triggers Subset
  25. *
  26. * PROGRAMMER
  27. * Design Team
  28. *
  29. * VERSION INFO
  30. * $Author: Byon_g $
  31. * $Revision: 5 $
  32. * $Modtime: 11/29/01 11:05a $
  33. * $Archive: /Commando/Code/Scripts/Toolkit_Triggers.cpp $
  34. *
  35. ******************************************************************************/
  36. #include "toolkit.h"
  37. /*
  38. Associated Custom Types:
  39. Trigger Activation/Deactivation Customs - Send 1 for On, 0 for Off:
  40. M00_CUSTOM_TRIGGER_ACTIVATE_ALL
  41. M00_CUSTOM_TRIGGER_ACTIVATE_KILLED
  42. M00_CUSTOM_TRIGGER_ACTIVATE_DESTROYED
  43. M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED
  44. M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_EXITED
  45. M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED_OR_EXITED
  46. M00_CUSTOM_TRIGGER_ACTIVATE_ENEMY_SEEN
  47. M00_CUSTOM_TRIGGER_ACTIVATE_DAMAGED
  48. M00_CUSTOM_TRIGGER_ACTIVATE_WAYPATH_COMPLETE
  49. M00_CUSTOM_TRIGGER_ACTIVATE_ANIMATION_COMPLETE
  50. M00_CUSTOM_TRIGGER_TIMER_EXPIRED
  51. */
  52. /*
  53. Function - M00_Controller_Trigger_RMV
  54. This script handles all operations of triggers.
  55. Parameters:
  56. GameObject * obj = The object that is sending the trigger.
  57. GameObject * target = The target of the trigger.
  58. float time_lower_bound = A time fluctuator to delay activation.
  59. float time_upper_bound = A time fluctuator to delay activation.
  60. int custom_type = The type of the custom to send.
  61. int custom_param = The parameter of the custom to send.
  62. */
  63. void M00_Controller_Trigger_RMV (GameObject * obj, GameObject * target, float time_lower_bound, float time_upper_bound, int custom_type, int custom_param)
  64. {
  65. if ((time_lower_bound == 0.0) && (time_upper_bound == 0.0))
  66. {
  67. if (target)
  68. Commands->Send_Custom_Event(obj, target, custom_type, custom_param);
  69. }
  70. else if ((time_lower_bound != 0.0) && (time_upper_bound == 0.0))
  71. {
  72. if (target)
  73. Commands->Send_Custom_Event(obj, target, custom_type, custom_param, time_lower_bound);
  74. }
  75. else if (time_upper_bound != 0.0)
  76. {
  77. float random_time = Commands->Get_Random(time_lower_bound, time_upper_bound);
  78. if (target)
  79. Commands->Send_Custom_Event(obj, target, custom_type, custom_param, random_time);
  80. }
  81. };
  82. /*
  83. Editor Script - M00_Trigger_When_Killed_RMV
  84. This script triggers when the object it is attached to is killed.
  85. */
  86. DECLARE_SCRIPT(M00_Trigger_When_Killed_RMV, "Start_Now=1:int, Receive_Type=1:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
  87. {
  88. bool script_enabled;
  89. bool debug_mode;
  90. REGISTER_VARIABLES()
  91. {
  92. SAVE_VARIABLE(script_enabled, 1);
  93. SAVE_VARIABLE(debug_mode, 2);
  94. }
  95. void Created(GameObject * obj)
  96. {
  97. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  98. if (Get_Int_Parameter("Start_Now"))
  99. {
  100. script_enabled = true;
  101. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV ENABLED.\n"));
  102. }
  103. else
  104. {
  105. script_enabled = false;
  106. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV DISABLED.\n"));
  107. }
  108. }
  109. void Killed(GameObject * obj, GameObject * killer)
  110. {
  111. int target_id = Get_Int_Parameter("Target_ID");
  112. float time_low = Get_Float_Parameter("Min_Delay");
  113. float time_up = Get_Float_Parameter("Max_Delay");
  114. int param = Get_Int_Parameter("Send_Param");
  115. int type = Get_Int_Parameter("Send_Type");
  116. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  117. if (script_enabled)
  118. {
  119. SCRIPT_DEBUG_MESSAGE (("Unit killed with active M00_Trigger_When_Killed_RMV attached.\n"));
  120. if (target_id > 0)
  121. {
  122. target = Commands->Find_Object(target_id);
  123. }
  124. if (target)
  125. {
  126. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV found its target object.\n"));
  127. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  128. }
  129. else
  130. {
  131. SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Killed_RMV could not find its target object, id = %d!\n", target_id));
  132. }
  133. }
  134. }
  135. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  136. {
  137. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV received custom type %d, param %d.\n", type, param));
  138. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_KILLED) || (type == Get_Int_Parameter("Receive_Type")))
  139. {
  140. if (param == Get_Int_Parameter("Receive_Param_On"))
  141. {
  142. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV ENABLED.\n"));
  143. script_enabled = true;
  144. }
  145. if (param == Get_Int_Parameter("Receive_Param_Off"))
  146. {
  147. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Killed_RMV DISABLED.\n"));
  148. script_enabled = false;
  149. }
  150. }
  151. }
  152. };
  153. /*
  154. Editor Script - M00_Trigger_When_Destroyed_RMV
  155. This script triggers when the object it is attached to is destroyed.
  156. */
  157. DECLARE_SCRIPT(M00_Trigger_When_Destroyed_RMV, "Start_Now=1:int, Receive_Type=2:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
  158. {
  159. bool script_enabled;
  160. bool debug_mode;
  161. REGISTER_VARIABLES()
  162. {
  163. SAVE_VARIABLE(script_enabled, 1);
  164. SAVE_VARIABLE(debug_mode, 2);
  165. }
  166. void Created(GameObject * obj)
  167. {
  168. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  169. if (Get_Int_Parameter("Start_Now"))
  170. {
  171. script_enabled = true;
  172. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV ENABLED.\n"));
  173. }
  174. else
  175. {
  176. script_enabled = false;
  177. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV DISABLED.\n"));
  178. }
  179. }
  180. void Destroyed(GameObject * obj)
  181. {
  182. int target_id = Get_Int_Parameter("Target_ID");
  183. float time_low = Get_Float_Parameter("Min_Delay");
  184. float time_up = Get_Float_Parameter("Max_Delay");
  185. int param = Get_Int_Parameter("Send_Param");
  186. int type = Get_Int_Parameter("Send_Type");
  187. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  188. if (script_enabled)
  189. {
  190. SCRIPT_DEBUG_MESSAGE (("Unit destroyed with active M00_Trigger_When_Destroyed_RMV attached.\n"));
  191. if (target_id > 0)
  192. {
  193. target = Commands->Find_Object(target_id);
  194. }
  195. if (target)
  196. {
  197. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV found its target object.\n"));
  198. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  199. }
  200. else
  201. {
  202. SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Destroyed_RMV could not find its target object, id = %d!\n", target_id));
  203. }
  204. }
  205. }
  206. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  207. {
  208. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV received custom type %d, param %d.\n", type, param));
  209. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_DESTROYED) || (type == Get_Int_Parameter("Receive_Type")))
  210. {
  211. if (param == Get_Int_Parameter("Receive_Param_On"))
  212. {
  213. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV ENABLED.\n"));
  214. script_enabled = true;
  215. }
  216. if (param == Get_Int_Parameter("Receive_Param_Off"))
  217. {
  218. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Destroyed_RMV DISABLED.\n"));
  219. script_enabled = false;
  220. }
  221. }
  222. }
  223. };
  224. /*
  225. Editor Script - M00_Trigger_When_Created_RMV
  226. This script triggers when the object it is attached to is created.
  227. NOTE that this script has no ability to be enabled/disabled.
  228. */
  229. DECLARE_SCRIPT(M00_Trigger_When_Created_RMV, "Target_ID:int, Send_Type:int, Send_Parameter:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
  230. {
  231. bool debug_mode;
  232. REGISTER_VARIABLES()
  233. {
  234. SAVE_VARIABLE(debug_mode, 1);
  235. }
  236. void Created(GameObject * obj)
  237. {
  238. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  239. SCRIPT_DEBUG_MESSAGE (("Unit created with active M00_Trigger_When_Created_RMV attached.\n"));
  240. int target_id = Get_Int_Parameter("Target_ID");
  241. float time_low = Get_Float_Parameter("Min_Delay");
  242. float time_up = Get_Float_Parameter("Max_Delay");
  243. int param = Get_Int_Parameter("Send_Param");
  244. int type = Get_Int_Parameter("Send_Type");
  245. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  246. if (target_id > 0)
  247. {
  248. target = Commands->Find_Object(target_id);
  249. }
  250. if (target)
  251. {
  252. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Created_RMV found its target object.\n"));
  253. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  254. }
  255. else
  256. {
  257. SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Created_RMV could not find its target object, id = %d!\n", target_id));
  258. }
  259. }
  260. };
  261. /*
  262. Editor Script - M00_Trigger_Zone_Entered_RMV
  263. This script triggers when the zone it is attached to is entered.
  264. Parameters:
  265. Trigger_Count = How many times this trigger will fire.
  266. Triggerer = Who can activate this trigger.
  267. Special Information:
  268. Values for Triggerer: 0 = Anyone, 1 = Commando Only, 2 = Non-Commando only
  269. Values for Trigger_Count: Enter 0 for infinite triggering.
  270. */
  271. DECLARE_SCRIPT(M00_Trigger_Zone_Entered_RMV, "Start_Now=1:int, Receive_Type=3:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Triggerer=0:int, Debug_Mode=0:int")
  272. {
  273. bool script_enabled;
  274. bool debug_mode;
  275. int trigger_count;
  276. typedef enum
  277. {
  278. ANYONE,
  279. COMMANDO,
  280. NONCOMMANDO
  281. } EntererType;
  282. EntererType allowed;
  283. REGISTER_VARIABLES()
  284. {
  285. SAVE_VARIABLE(script_enabled, 1);
  286. SAVE_VARIABLE(debug_mode, 2);
  287. SAVE_VARIABLE(trigger_count, 3);
  288. SAVE_VARIABLE(allowed, 4);
  289. }
  290. void Created(GameObject * obj)
  291. {
  292. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  293. trigger_count = Get_Int_Parameter("Trigger_Count");
  294. if (Get_Int_Parameter("Start_Now"))
  295. {
  296. script_enabled = true;
  297. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV ENABLED.\n"));
  298. }
  299. else
  300. {
  301. script_enabled = false;
  302. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV DISABLED.\n"));
  303. }
  304. }
  305. void Entered(GameObject * obj, GameObject * enterer)
  306. {
  307. if (script_enabled)
  308. {
  309. if (trigger_count == 1)
  310. {
  311. script_enabled = false;
  312. }
  313. if (trigger_count > 0)
  314. {
  315. SCRIPT_DEBUG_MESSAGE (("Zone entered with active M00_Trigger_Zone_Entered_RMV attached.\n"));
  316. trigger_count--;
  317. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV has %d triggers remaining.\n", trigger_count));
  318. }
  319. int target_id = Get_Int_Parameter("Target_ID");
  320. float time_low = Get_Float_Parameter("Min_Delay");
  321. float time_up = Get_Float_Parameter("Max_Delay");
  322. int param = Get_Int_Parameter("Send_Param");
  323. int type = Get_Int_Parameter("Send_Type");
  324. int who = Get_Int_Parameter("Triggerer");
  325. switch (who)
  326. {
  327. case (0):
  328. {
  329. allowed = ANYONE;
  330. break;
  331. }
  332. case (1):
  333. {
  334. allowed = COMMANDO;
  335. break;
  336. }
  337. case (2):
  338. {
  339. allowed = NONCOMMANDO;
  340. break;
  341. }
  342. }
  343. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  344. if (target_id > 0)
  345. {
  346. target = Commands->Find_Object(target_id);
  347. }
  348. if (target)
  349. {
  350. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV found its target object.\n"));
  351. if ((allowed == COMMANDO) && (enterer == Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
  352. {
  353. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV triggered properly.\n"));
  354. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  355. }
  356. else if ((allowed == NONCOMMANDO) && (enterer != Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
  357. {
  358. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV triggered properly.\n"));
  359. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  360. }
  361. else if (allowed == ANYONE)
  362. {
  363. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV triggered properly.\n"));
  364. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  365. }
  366. }
  367. else
  368. {
  369. SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_Zone_Entered_RMV did not find its target object, id = %d!\n", target_id));
  370. }
  371. }
  372. }
  373. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  374. {
  375. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV received custom type %d, param %d.\n", type, param));
  376. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED) || (type == Get_Int_Parameter("Receive_Type")))
  377. {
  378. if (param == Get_Int_Parameter("Receive_Param_On"))
  379. {
  380. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV ENABLED.\n"));
  381. script_enabled = true;
  382. trigger_count = Get_Int_Parameter("Trigger_Count");
  383. }
  384. if (param == Get_Int_Parameter("Receive_Param_Off"))
  385. {
  386. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_RMV DISABLED.\n"));
  387. script_enabled = false;
  388. }
  389. }
  390. }
  391. };
  392. /*
  393. Editor Script - M00_Trigger_Zone_Exited_RMV
  394. This script triggers when the zone it is attached to is exited.
  395. Parameters:
  396. Trigger_Count = How many times this trigger will fire.
  397. Triggerer = Who can activate this trigger.
  398. Special Information:
  399. Values for Triggerer: 0 = Anyone, 1 = Commando Only, 2 = Non-Commando only
  400. Values for Trigger_Count: Enter 0 for infinite triggering.
  401. */
  402. DECLARE_SCRIPT(M00_Trigger_Zone_Exited_RMV, "Start_Now=1:int, Receive_Type=4:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Triggerer=0:int, Debug_Mode=0:int")
  403. {
  404. bool script_enabled;
  405. bool debug_mode;
  406. int trigger_count;
  407. typedef enum
  408. {
  409. ANYONE,
  410. COMMANDO,
  411. NONCOMMANDO
  412. } EntererType;
  413. EntererType allowed;
  414. REGISTER_VARIABLES()
  415. {
  416. SAVE_VARIABLE(script_enabled, 1);
  417. SAVE_VARIABLE(debug_mode, 2);
  418. SAVE_VARIABLE(trigger_count, 3);
  419. SAVE_VARIABLE(allowed, 4);
  420. }
  421. void Created(GameObject * obj)
  422. {
  423. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  424. trigger_count = Get_Int_Parameter("Trigger_Count");
  425. if (Get_Int_Parameter("Start_Now"))
  426. {
  427. script_enabled = true;
  428. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV ENABLED.\n"));
  429. }
  430. else
  431. {
  432. script_enabled = false;
  433. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV DISABLED.\n"));
  434. }
  435. }
  436. void Exited(GameObject * obj, GameObject * enterer)
  437. {
  438. if (script_enabled)
  439. {
  440. if (trigger_count == 1)
  441. {
  442. script_enabled = false;
  443. }
  444. if (trigger_count > 0)
  445. {
  446. SCRIPT_DEBUG_MESSAGE (("Zone exited with active M00_Trigger_Zone_Exited_RMV attached.\n"));
  447. trigger_count--;
  448. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV has %d triggers remaining.\n", trigger_count));
  449. }
  450. int target_id = Get_Int_Parameter("Target_ID");
  451. float time_low = Get_Float_Parameter("Min_Delay");
  452. float time_up = Get_Float_Parameter("Max_Delay");
  453. int param = Get_Int_Parameter("Send_Param");
  454. int type = Get_Int_Parameter("Send_Type");
  455. int who = Get_Int_Parameter("Triggerer");
  456. switch (who)
  457. {
  458. case (0):
  459. {
  460. allowed = ANYONE;
  461. break;
  462. }
  463. case (1):
  464. {
  465. allowed = COMMANDO;
  466. break;
  467. }
  468. case (2):
  469. {
  470. allowed = NONCOMMANDO;
  471. break;
  472. }
  473. }
  474. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  475. if (target_id > 0)
  476. {
  477. target = Commands->Find_Object(target_id);
  478. }
  479. if (target)
  480. {
  481. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV found its target object.\n"));
  482. if ((allowed == COMMANDO) && (enterer == Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
  483. {
  484. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV triggered properly.\n"));
  485. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  486. }
  487. else if ((allowed == NONCOMMANDO) && (enterer != Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
  488. {
  489. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV triggered properly.\n"));
  490. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  491. }
  492. else if (allowed == ANYONE)
  493. {
  494. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV triggered properly.\n"));
  495. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  496. }
  497. }
  498. else
  499. {
  500. SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_Zone_Exited_RMV could not find its target object, id = %d!\n", target_id));
  501. }
  502. }
  503. }
  504. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  505. {
  506. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV received custom type %d, param %d.\n", type, param));
  507. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED) || (type == Get_Int_Parameter("Receive_Type")))
  508. {
  509. if (param == Get_Int_Parameter("Receive_Param_On"))
  510. {
  511. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV ENABLED.\n"));
  512. script_enabled = true;
  513. trigger_count = Get_Int_Parameter("Trigger_Count");
  514. }
  515. if (param == Get_Int_Parameter("Receive_Param_Off"))
  516. {
  517. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Exited_RMV DISABLED.\n"));
  518. script_enabled = false;
  519. }
  520. }
  521. }
  522. };
  523. /*
  524. Editor Script - M00_Trigger_Zone_Entered_Or_Exited_RMV
  525. This script triggers when the zone it is attached to is entered or exited.
  526. Parameters:
  527. Trigger_Count = How many times this trigger will fire.
  528. Triggerer = Who can activate this trigger.
  529. Special Information:
  530. Values for Triggerer: 0 = Anyone, 1 = Commando Only, 2 = Non-Commando only
  531. Values for Trigger_Count: Enter 0 for infinite triggering.
  532. */
  533. DECLARE_SCRIPT(M00_Trigger_Zone_Entered_Or_Exited_RMV, "Start_Now=1:int, Receive_Type=5:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Triggerer=0:int, Debug_Mode=0:int")
  534. {
  535. bool script_enabled;
  536. bool debug_mode;
  537. int trigger_count;
  538. typedef enum
  539. {
  540. ANYONE,
  541. COMMANDO,
  542. NONCOMMANDO
  543. } EntererType;
  544. EntererType allowed;
  545. void Created(GameObject * obj)
  546. {
  547. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  548. trigger_count = Get_Int_Parameter("Trigger_Count");
  549. if (Get_Int_Parameter("Start_Now"))
  550. {
  551. script_enabled = true;
  552. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV ENABLED.\n"));
  553. }
  554. else
  555. {
  556. script_enabled = false;
  557. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV DISABLED.\n"));
  558. }
  559. }
  560. void Exited(GameObject * obj, GameObject * enterer)
  561. {
  562. if (script_enabled)
  563. {
  564. if (trigger_count == 1)
  565. {
  566. script_enabled = false;
  567. }
  568. if (trigger_count > 0)
  569. {
  570. SCRIPT_DEBUG_MESSAGE (("Zone exited with active M00_Trigger_Zone_Entered_Or_Exited_RMV attached.\n"));
  571. trigger_count--;
  572. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV has %d triggers remaining.\n", trigger_count));
  573. }
  574. int target_id = Get_Int_Parameter("Target_ID");
  575. float time_low = Get_Float_Parameter("Min_Delay");
  576. float time_up = Get_Float_Parameter("Max_Delay");
  577. int param = Get_Int_Parameter("Send_Param");
  578. int type = Get_Int_Parameter("Send_Type");
  579. int who = Get_Int_Parameter("Triggerer");
  580. switch (who)
  581. {
  582. case (0):
  583. {
  584. allowed = ANYONE;
  585. break;
  586. }
  587. case (1):
  588. {
  589. allowed = COMMANDO;
  590. break;
  591. }
  592. case (2):
  593. {
  594. allowed = NONCOMMANDO;
  595. break;
  596. }
  597. }
  598. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  599. if (target_id > 0)
  600. {
  601. target = Commands->Find_Object(target_id);
  602. }
  603. if (target)
  604. {
  605. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV found its target object.\n"));
  606. if ((allowed == COMMANDO) && (enterer == Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
  607. {
  608. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
  609. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  610. }
  611. else if ((allowed == NONCOMMANDO) && (enterer != Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
  612. {
  613. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
  614. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  615. }
  616. else if (allowed == ANYONE)
  617. {
  618. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
  619. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  620. }
  621. }
  622. else
  623. {
  624. SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_Zone_Entered_Or_Exited_RMV did not find its target object, id = %d!\n", target_id));
  625. }
  626. }
  627. }
  628. void Entered(GameObject * obj, GameObject * enterer)
  629. {
  630. if (script_enabled)
  631. {
  632. if (trigger_count == 1)
  633. {
  634. script_enabled = false;
  635. }
  636. if (trigger_count > 0)
  637. {
  638. SCRIPT_DEBUG_MESSAGE (("Zone entered with active M00_Trigger_Zone_Entered_Or_Exited_RMV attached.\n"));
  639. trigger_count--;
  640. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV has %d triggers remaining.\n", trigger_count));
  641. }
  642. int target_id = Get_Int_Parameter("Target_ID");
  643. float time_low = Get_Float_Parameter("Min_Delay");
  644. float time_up = Get_Float_Parameter("Max_Delay");
  645. int param = Get_Int_Parameter("Send_Param");
  646. int type = Get_Int_Parameter("Send_Type");
  647. int who = Get_Int_Parameter("Triggerer");
  648. switch (who)
  649. {
  650. case (0):
  651. {
  652. allowed = ANYONE;
  653. break;
  654. }
  655. case (1):
  656. {
  657. allowed = COMMANDO;
  658. break;
  659. }
  660. case (2):
  661. {
  662. allowed = NONCOMMANDO;
  663. break;
  664. }
  665. }
  666. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  667. if (target_id > 0)
  668. {
  669. target = Commands->Find_Object(target_id);
  670. }
  671. if (target)
  672. {
  673. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV found its target object.\n"));
  674. if ((allowed == COMMANDO) && (enterer == Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
  675. {
  676. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
  677. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  678. }
  679. else if ((allowed == NONCOMMANDO) && (enterer != Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f))))
  680. {
  681. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
  682. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  683. }
  684. else if (allowed == ANYONE)
  685. {
  686. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV triggered properly.\n"));
  687. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  688. }
  689. }
  690. else
  691. {
  692. SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_Zone_Entered_Or_Exited_RMV could not find its target object, id = %d!\n", target_id));
  693. }
  694. }
  695. }
  696. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  697. {
  698. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV received custom type %d, param %d.\n", type, param));
  699. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ZONE_ENTERED) || (type == Get_Int_Parameter("Receive_Type")))
  700. {
  701. if (param == Get_Int_Parameter("Receive_Param_On"))
  702. {
  703. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV ENABLED.\n"));
  704. script_enabled = true;
  705. trigger_count = Get_Int_Parameter("Trigger_Count");
  706. }
  707. if (param == Get_Int_Parameter("Receive_Param_Off"))
  708. {
  709. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_Zone_Entered_Or_Exited_RMV DISABLED.\n"));
  710. script_enabled = false;
  711. }
  712. }
  713. }
  714. };
  715. /*
  716. Editor Script - M00_Trigger_When_Enemy_Seen_RMV
  717. This script triggers when an enemy is seen.
  718. Parameters:
  719. Trigger_Count = How many times this trigger will fire. Enter 0 for infinite.
  720. */
  721. DECLARE_SCRIPT(M00_Trigger_When_Enemy_Seen_RMV, "Start_Now=1:int, Receive_Type=6:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Parameter:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Debug_Mode=0:int")
  722. {
  723. bool script_enabled;
  724. int trigger_count;
  725. bool debug_mode;
  726. void Created(GameObject * obj)
  727. {
  728. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  729. trigger_count = Get_Int_Parameter("Trigger_Count");
  730. if (Get_Int_Parameter("Start_Now"))
  731. {
  732. script_enabled = true;
  733. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV ENABLED.\n"));
  734. }
  735. else
  736. {
  737. script_enabled = false;
  738. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV DISABLED.\n"));
  739. }
  740. }
  741. void Enemy_Seen(GameObject * obj, GameObject * enemy)
  742. {
  743. if (script_enabled)
  744. {
  745. if (trigger_count == 1)
  746. {
  747. script_enabled = false;
  748. }
  749. if (trigger_count > 0)
  750. {
  751. SCRIPT_DEBUG_MESSAGE (("Enemy seen by unit with active M00_Trigger_When_Enemy_Seen_RMV attached.\n"));
  752. trigger_count--;
  753. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV has %d triggers remaining.\n", trigger_count));
  754. }
  755. int target_id = Get_Int_Parameter("Target_ID");
  756. float time_low = Get_Float_Parameter("Min_Delay");
  757. float time_up = Get_Float_Parameter("Max_Delay");
  758. int param = Get_Int_Parameter("Send_Param");
  759. int type = Get_Int_Parameter("Send_Type");
  760. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  761. if (target_id > 0)
  762. {
  763. target = Commands->Find_Object(target_id);
  764. }
  765. if (target)
  766. {
  767. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV has found its target object.\n"));
  768. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  769. }
  770. else
  771. {
  772. SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Enemy_Seen_RMV could not find its target object, id = %d!\n", target_id));
  773. }
  774. }
  775. }
  776. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  777. {
  778. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV received custom type %d, param %d.\n", type, param));
  779. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ENEMY_SEEN) || (type == Get_Int_Parameter("Receive_Type")))
  780. {
  781. if (param == Get_Int_Parameter("Receive_Param_On"))
  782. {
  783. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV ENABLED.\n"));
  784. script_enabled = true;
  785. trigger_count = Get_Int_Parameter("Trigger_Count");
  786. }
  787. if (param == Get_Int_Parameter("Receive_Param_Off"))
  788. {
  789. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Enemy_Seen_RMV DISABLED.\n"));
  790. script_enabled = false;
  791. }
  792. }
  793. }
  794. };
  795. /*
  796. Editor Script - M00_Trigger_When_Damaged_RMV
  797. This script triggers when the unit is damaged.
  798. Parameters:
  799. Trigger_Count = How many times this will trigger.
  800. */
  801. DECLARE_SCRIPT(M00_Trigger_When_Damaged_RMV, "Start_Now=1:int, Receive_Type=7:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Debug_Mode=0:int")
  802. {
  803. bool script_enabled;
  804. int trigger_count;
  805. bool debug_mode;
  806. void Created(GameObject * obj)
  807. {
  808. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  809. trigger_count = Get_Int_Parameter("Trigger_Count");
  810. if (Get_Int_Parameter("Start_Now"))
  811. {
  812. script_enabled = true;
  813. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV ENABLED.\n"));
  814. }
  815. else
  816. {
  817. script_enabled = false;
  818. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV DISABLED.\n"));
  819. }
  820. }
  821. void Damaged(GameObject * obj, GameObject * damager, float amount)
  822. {
  823. if (script_enabled)
  824. {
  825. if (trigger_count == 1)
  826. {
  827. script_enabled = false;
  828. }
  829. if (trigger_count > 0)
  830. {
  831. SCRIPT_DEBUG_MESSAGE (("Unit damaged with active M00_Trigger_When_Damaged_RMV attached.\n"));
  832. trigger_count--;
  833. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV has %d triggers remaining.\n", trigger_count));
  834. }
  835. int target_id = Get_Int_Parameter("Target_ID");
  836. float time_low = Get_Float_Parameter("Min_Delay");
  837. float time_up = Get_Float_Parameter("Max_Delay");
  838. int param = Get_Int_Parameter("Send_Param");
  839. int type = Get_Int_Parameter("Send_Type");
  840. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  841. if (target_id > 0)
  842. {
  843. target = Commands->Find_Object(target_id);
  844. }
  845. if (target)
  846. {
  847. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV found the target object.\n"));
  848. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  849. }
  850. else
  851. {
  852. SCRIPT_DEBUG_MESSAGE (("ERROR - M00_Trigger_When_Damaged_RMV could not find the target object, id = %d!\n", target_id));
  853. }
  854. }
  855. }
  856. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  857. {
  858. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV received custom type %d,param %d.\n", type, param));
  859. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_DAMAGED) || (type == Get_Int_Parameter("Receive_Type")))
  860. {
  861. if (param == Get_Int_Parameter("Receive_Param_On"))
  862. {
  863. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV ENABLED.\n"));
  864. script_enabled = true;
  865. trigger_count = Get_Int_Parameter("Trigger_Count");
  866. }
  867. if (param == Get_Int_Parameter("Receive_Param_Off"))
  868. {
  869. SCRIPT_DEBUG_MESSAGE (("M00_Trigger_When_Damaged_RMV DISABLED.\n"));
  870. script_enabled = false;
  871. }
  872. }
  873. }
  874. };
  875. /*
  876. Editor Script - M00_Trigger_When_Action_Complete_RMV
  877. This script triggers when the unit completes any action. It is designed to respond to
  878. a particular Action ID.
  879. Parameters:
  880. Trigger_Count = How many times this will trigger.
  881. */
  882. DECLARE_SCRIPT(M00_Trigger_When_Action_Complete_RMV, "Start_Now=1:int, Receive_Type=8:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Action_ID:int, Trigger_Count=0:int, Debug_Mode=0:int")
  883. {
  884. bool script_enabled;
  885. int trigger_count;
  886. bool debug_mode;
  887. void Created(GameObject * obj)
  888. {
  889. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  890. trigger_count = Get_Int_Parameter("Trigger_Count");
  891. if (Get_Int_Parameter("Start_Now"))
  892. {
  893. script_enabled = true;
  894. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV_ENABLED.\n"));
  895. }
  896. else
  897. {
  898. script_enabled = false;
  899. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV DISABLED.\n"));
  900. }
  901. }
  902. void Action_Complete(GameObject * obj, int action_id)
  903. {
  904. if (script_enabled)
  905. {
  906. if (trigger_count == 1)
  907. {
  908. script_enabled = false;
  909. }
  910. if (trigger_count > 0)
  911. {
  912. SCRIPT_DEBUG_MESSAGE(("Action complete by unit with active M00_Trigger_When_Action_Complete_RMV attached.\n"));
  913. trigger_count--;
  914. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV has %d triggers remaining.\n", trigger_count));
  915. }
  916. int target_id = Get_Int_Parameter("Target_ID");
  917. float time_low = Get_Float_Parameter("Min_Delay");
  918. float time_up = Get_Float_Parameter("Max_Delay");
  919. int param = Get_Int_Parameter("Send_Param");
  920. int type = Get_Int_Parameter("Send_Type");
  921. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  922. if (target_id > 0)
  923. {
  924. target = Commands->Find_Object(target_id);
  925. }
  926. if (target)
  927. {
  928. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV found its target object.\n"));
  929. if (action_id == Get_Int_Parameter("Action_ID"))
  930. {
  931. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  932. }
  933. }
  934. else
  935. {
  936. SCRIPT_DEBUG_MESSAGE(("ERROR - M00_Trigger_When_Action_Complete_RMV cannot find its target object, id = %d!\n", target_id));
  937. }
  938. }
  939. }
  940. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  941. {
  942. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV received custom type %d, param %d.\n", type, param));
  943. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ACTION_COMPLETE) || (type == Get_Int_Parameter("Receive_Type")))
  944. {
  945. if (param == Get_Int_Parameter("Receive_Param_On"))
  946. {
  947. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV ENABLED.\n"));
  948. script_enabled = true;
  949. trigger_count = Get_Int_Parameter("Trigger_Count");
  950. }
  951. if (param == Get_Int_Parameter("Receive_Param_Off"))
  952. {
  953. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Action_Complete_RMV DISABLED.\n"));
  954. script_enabled = false;
  955. }
  956. }
  957. }
  958. };
  959. /*
  960. Editor Script - M00_Trigger_When_Animation_Complete_RMV
  961. This script triggers when the unit completes an animation.
  962. Parameters:
  963. Animation_Name = The name of the animation that is completing.
  964. Trigger_Count = How many times this will trigger.
  965. */
  966. DECLARE_SCRIPT(M00_Trigger_When_Animation_Complete_RMV, "Start_Now=1:int, Receive_Type=9:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Target_ID:int, Animation_Name:string, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Trigger_Count=0:int, Debug_Mode=0:int")
  967. {
  968. bool script_enabled;
  969. int trigger_count;
  970. bool debug_mode;
  971. void Created(GameObject * obj)
  972. {
  973. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  974. trigger_count = Get_Int_Parameter("Trigger_Count");
  975. if (Get_Int_Parameter("Start_Now"))
  976. {
  977. script_enabled = true;
  978. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV ENABLED.\n"));
  979. }
  980. else
  981. {
  982. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV DISABLED.\n"));
  983. script_enabled = false;
  984. }
  985. }
  986. void Animation_Complete(GameObject * obj, const char * name)
  987. {
  988. if (script_enabled)
  989. {
  990. SCRIPT_DEBUG_MESSAGE(("Animation complete by unit with active M00_Trigger_When_Animation_Complete_RMV attached.\n"));
  991. if (trigger_count == 1)
  992. {
  993. script_enabled = false;
  994. }
  995. if (trigger_count > 0)
  996. {
  997. trigger_count--;
  998. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV has %d triggers remaining.\n", trigger_count));
  999. }
  1000. int target_id = Get_Int_Parameter("Target_ID");
  1001. float time_low = Get_Float_Parameter("Min_Delay");
  1002. float time_up = Get_Float_Parameter("Max_Delay");
  1003. int param = Get_Int_Parameter("Send_Param");
  1004. int type = Get_Int_Parameter("Send_Type");
  1005. const char *anim = Get_Parameter("Animation_Name");
  1006. GameObject *target = Commands->Get_A_Star(Vector3(0.0f,0.0f,0.0f));
  1007. if (target_id > 0)
  1008. {
  1009. target = Commands->Find_Object(target_id);
  1010. }
  1011. if (target)
  1012. {
  1013. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV found its target object.\n"));
  1014. if (stricmp(anim, name))
  1015. {
  1016. M00_Controller_Trigger_RMV(obj, target, time_low, time_up, type, param);
  1017. }
  1018. }
  1019. else
  1020. {
  1021. SCRIPT_DEBUG_MESSAGE(("ERROR - M00_Trigger_When_Animation_Complete_RMV cannot find its target object, id = %d!\n", target_id));
  1022. }
  1023. }
  1024. }
  1025. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  1026. {
  1027. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV received custom type %d, param %d.\n", type, param));
  1028. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_ACTIVATE_ANIMATION_COMPLETE) || (type == Get_Int_Parameter("Receive_Type")))
  1029. {
  1030. if (param == Get_Int_Parameter("Receive_Param_On"))
  1031. {
  1032. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV ENABLED.\n"));
  1033. script_enabled = true;
  1034. trigger_count = Get_Int_Parameter("Trigger_Count");
  1035. }
  1036. if (param == Get_Int_Parameter("Receive_Param_Off"))
  1037. {
  1038. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_When_Animation_Complete_RMV DISABLED.\n"));
  1039. script_enabled = false;
  1040. }
  1041. }
  1042. }
  1043. };
  1044. DECLARE_SCRIPT(M00_Trigger_Timer_Expired_RAD, "Start_Now=0:int, Receive_Type=15:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Timer_Min=0.0:float, Timer_Max=1.0:float, Trigger_Count=0:int, Target_ID:int, Send_Type:int, Send_Param:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
  1045. {
  1046. bool debug_mode;
  1047. bool script_active;
  1048. int trigger_count;
  1049. void Created(GameObject* obj)
  1050. {
  1051. script_active = false;
  1052. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  1053. if (Get_Int_Parameter("Start_Now"))
  1054. {
  1055. Start_Now(obj);
  1056. }
  1057. }
  1058. void Start_Now(GameObject* obj)
  1059. {
  1060. script_active = true;
  1061. trigger_count = Get_Int_Parameter("Trigger_Count");
  1062. if (trigger_count <= 0)
  1063. {
  1064. trigger_count = -1;
  1065. }
  1066. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD ENABLED.\n"));
  1067. Set_Timer(obj);
  1068. }
  1069. void Set_Timer(GameObject* obj)
  1070. {
  1071. float timer_min;
  1072. float timer_max;
  1073. float timer_value;
  1074. timer_min = Get_Float_Parameter("Timer_Min");
  1075. timer_max = Get_Float_Parameter("Timer_Max");
  1076. if (timer_max > timer_min)
  1077. {
  1078. timer_value = Commands->Get_Random(timer_min, timer_max);
  1079. }
  1080. else
  1081. {
  1082. timer_value = timer_min;
  1083. }
  1084. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD is starting the timer.\n"));
  1085. Commands->Start_Timer (obj, this, timer_value, M00_TIMER_TRIGGER_EXPIRED);
  1086. }
  1087. void Timer_Expired (GameObject * obj, int timer_id)
  1088. {
  1089. SCRIPT_DEBUG_MESSAGE(("A timer has expired on M00_Trigger_Timer_Expired_RAD.\n"));
  1090. if (script_active)
  1091. {
  1092. if (trigger_count > 0)
  1093. {
  1094. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD has %d triggers remaining.\n", trigger_count));
  1095. trigger_count--;
  1096. }
  1097. if (trigger_count)
  1098. {
  1099. GameObject* target_obj;
  1100. int target_id;
  1101. int min_delay;
  1102. int max_delay;
  1103. int delay_value;
  1104. target_id = Get_Int_Parameter("Target_ID");
  1105. if (timer_id == M00_TIMER_TRIGGER_EXPIRED)
  1106. {
  1107. target_obj = Commands->Find_Object(target_id);
  1108. if (target_obj)
  1109. {
  1110. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD found its target object.\n"));
  1111. min_delay = Get_Float_Parameter("Min_Delay");
  1112. max_delay = Get_Float_Parameter("Max_Delay");
  1113. if (max_delay > min_delay)
  1114. {
  1115. delay_value = Commands->Get_Random(min_delay, max_delay);
  1116. }
  1117. else
  1118. {
  1119. delay_value = min_delay;
  1120. }
  1121. Commands->Send_Custom_Event (obj, target_obj, Get_Int_Parameter("Send_Type"), Get_Int_Parameter("Send_Param"), delay_value);
  1122. }
  1123. }
  1124. else
  1125. {
  1126. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD cannot find its target object, id = %d!\n", target_id));
  1127. }
  1128. Set_Timer(obj);
  1129. }
  1130. }
  1131. }
  1132. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  1133. {
  1134. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD received custom type %d, param %d.\n", type, param));
  1135. if ((type == M00_CUSTOM_TRIGGER_ACTIVATE_ALL) || (type == M00_CUSTOM_TRIGGER_TIMER_EXPIRED) || (type == Get_Int_Parameter("Receive_Type")))
  1136. {
  1137. if (param == Get_Int_Parameter("Receive_Param_On"))
  1138. {
  1139. script_active = true;
  1140. trigger_count = Get_Int_Parameter("Trigger_Count");
  1141. Start_Now(obj);
  1142. }
  1143. if (param == Get_Int_Parameter("Receive_Param_Off"))
  1144. {
  1145. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_Timer_Expired_RAD DISABLED.\n"));
  1146. script_active = false;
  1147. }
  1148. }
  1149. }
  1150. };
  1151. /*
  1152. Custom Parameter Settings:
  1153. 0 = Turn this state sequence off.
  1154. -1 = Advance to the next state.
  1155. 1+ = Adjust to this particular numbered state.
  1156. */
  1157. DECLARE_SCRIPT(M00_Trigger_State_Sequence_RAD, "Start_Now=0:int, Receive_Type:int, Num_States=2:int, Loop_States=0:int, Send_Type:int, Target_ID:int, Min_Delay=0.0:float, Max_Delay=0.0:float, Debug_Mode=0:int")
  1158. {
  1159. int state_num;
  1160. bool debug_mode;
  1161. void Created(GameObject* obj)
  1162. {
  1163. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  1164. state_num = 1;
  1165. if (Get_Int_Parameter("Start_Now"))
  1166. {
  1167. Send_Custom(obj);
  1168. }
  1169. }
  1170. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  1171. {
  1172. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_State_Sequence_RAD received custom type %d, param %d.\n", type, param));
  1173. if (type == Get_Int_Parameter("Receive_Type"))
  1174. {
  1175. if (param < 0)
  1176. {
  1177. // Advance to the next state.
  1178. state_num++;
  1179. if (state_num > Get_Int_Parameter("Num_States"))
  1180. {
  1181. if (Get_Int_Parameter("Loop_States"))
  1182. {
  1183. state_num = 1;
  1184. }
  1185. else
  1186. {
  1187. state_num = 0;
  1188. }
  1189. }
  1190. Send_Custom(obj);
  1191. }
  1192. if (param > 0)
  1193. {
  1194. // Adjust to this numbered state.
  1195. state_num = param;
  1196. if (state_num > Get_Int_Parameter("Num_States"))
  1197. {
  1198. if (Get_Int_Parameter("Loop_States"))
  1199. {
  1200. state_num = 1;
  1201. }
  1202. else
  1203. {
  1204. state_num = 0;
  1205. }
  1206. }
  1207. Send_Custom(obj);
  1208. }
  1209. if (!param)
  1210. {
  1211. // Turn this state engine off.
  1212. state_num = 0;
  1213. }
  1214. }
  1215. }
  1216. void Send_Custom(GameObject* obj)
  1217. {
  1218. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_State_Sequence_RAD is sending its state custom.\n"));
  1219. GameObject* target_obj;
  1220. int target_id;
  1221. float min_delay;
  1222. float max_delay;
  1223. float delay_value;
  1224. if (state_num)
  1225. {
  1226. target_id = Get_Int_Parameter("Target_ID");
  1227. target_obj = Commands->Find_Object(target_id);
  1228. if (target_obj)
  1229. {
  1230. SCRIPT_DEBUG_MESSAGE(("M00_Trigger_State_Sequence_RAD found its target object.\n"));
  1231. min_delay = Get_Float_Parameter("Min_Delay");
  1232. max_delay = Get_Float_Parameter("Max_Delay");
  1233. if (max_delay > min_delay)
  1234. {
  1235. delay_value = Commands->Get_Random(min_delay, max_delay);
  1236. }
  1237. else
  1238. {
  1239. delay_value = min_delay;
  1240. }
  1241. Commands->Send_Custom_Event (obj, target_obj, Get_Int_Parameter("Send_Type"), state_num, delay_value);
  1242. }
  1243. else
  1244. {
  1245. SCRIPT_DEBUG_MESSAGE(("ERROR - M00_Trigger_State_Sequence_RAD could not find its target object, id = %d!\n", target_id));
  1246. }
  1247. }
  1248. }
  1249. };