Toolkit_Objectives.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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_Objectives.cpp
  22. *
  23. * DESCRIPTION
  24. * Designer Toolkit for Mission Construction - Objectives Subset
  25. *
  26. * PROGRAMMER
  27. * Design Team
  28. *
  29. * VERSION INFO
  30. * $Author: Ryan_v $
  31. * $Revision: 3 $
  32. * $Modtime: 11/30/00 2:41p $
  33. * $Archive: /Commando/Code/Scripts/Toolkit_Objectives.cpp $
  34. *
  35. ******************************************************************************/
  36. #include "toolkit.h"
  37. DECLARE_SCRIPT(M00_Objective_Controller_For_Objects_RMV, "Objective_ID:int, Objective_Type=1:int, Objective_Description_ID:int, Radar_Blip=1:int, Hidden=0:int, Object_ID:int, Custom_Type:int, Activate_Param=0:int, Unhide_Param=0:int, Success_Param:int, Failure_Param:int")
  38. {
  39. int objective_id, objective_type, object_id, custom_type;
  40. int activate, success, failure;
  41. int description_id;
  42. bool blip, hidden;
  43. REGISTER_VARIABLES()
  44. {
  45. SAVE_VARIABLE(objective_id, 1);
  46. SAVE_VARIABLE(objective_type, 2);
  47. SAVE_VARIABLE(object_id, 3);
  48. SAVE_VARIABLE(custom_type, 4);
  49. SAVE_VARIABLE(activate, 5);
  50. SAVE_VARIABLE(success, 6);
  51. SAVE_VARIABLE(failure, 7);
  52. SAVE_VARIABLE(description_id, 8);
  53. SAVE_VARIABLE(blip, 9);
  54. SAVE_VARIABLE(hidden, 10);
  55. }
  56. void Created(GameObject * obj)
  57. {
  58. hidden = (Get_Int_Parameter("Hidden") == 1) ? true : false;
  59. blip = (Get_Int_Parameter("Radar_Blip") == 1) ? true : false;
  60. objective_id = Get_Int_Parameter("Objective_ID");
  61. objective_type = Get_Int_Parameter("Objective_Type");
  62. description_id = Get_Int_Parameter("Objective_Description_ID");
  63. object_id = Get_Int_Parameter("Object_ID");
  64. custom_type = Get_Int_Parameter("Custom_Type");
  65. activate = Get_Int_Parameter("Activate_Param");
  66. success = Get_Int_Parameter("Success_Param");
  67. failure = Get_Int_Parameter("Failure_Param");
  68. if ((activate == 0) && (hidden == false))
  69. {
  70. switch (objective_type)
  71. {
  72. case 1: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, description_id);
  73. break;
  74. case 2: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_PENDING, description_id);
  75. break;
  76. case 3: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_PENDING, description_id);
  77. break;
  78. }
  79. if ((blip) && (Commands->Find_Object(object_id) != NULL))
  80. Commands->Set_Objective_Radar_Blip_Object(objective_id, Commands->Find_Object(object_id));
  81. }
  82. else if ((activate == 0) && (hidden == true))
  83. {
  84. switch (objective_type)
  85. {
  86. case 1: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_HIDDEN, description_id);
  87. break;
  88. case 2: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_HIDDEN, description_id);
  89. break;
  90. case 3: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_HIDDEN, description_id);
  91. break;
  92. }
  93. if ((blip) && (Commands->Find_Object(object_id) != NULL))
  94. Commands->Set_Objective_Radar_Blip_Object(objective_id, Commands->Find_Object(object_id));
  95. }
  96. }
  97. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  98. {
  99. if ((type == custom_type) && (param == activate))
  100. {
  101. switch (objective_type)
  102. {
  103. case 1: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, description_id);
  104. break;
  105. case 2: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_PENDING, description_id);
  106. break;
  107. case 3: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_PENDING, description_id);
  108. break;
  109. }
  110. if ((blip) && (Commands->Find_Object(object_id) != NULL))
  111. Commands->Set_Objective_Radar_Blip_Object(objective_id, Commands->Find_Object(object_id));
  112. }
  113. if ((type == custom_type) && (param == success))
  114. {
  115. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_ACCOMPLISHED);
  116. }
  117. if ((type == custom_type) && (param == failure))
  118. {
  119. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_FAILED);
  120. }
  121. if ((type == custom_type) && (hidden == true) && (param == Get_Int_Parameter("Unhide_Param")))
  122. {
  123. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_PENDING);
  124. }
  125. }
  126. };
  127. DECLARE_SCRIPT(M00_Objective_Controller_For_Locations_RMV, "Objective_ID:int, Objective_Type=1:int, Objective_Description_ID:int, Radar_Blip=1:int, Hidden=0:int, Location:vector3, Custom_Type:int, Activate_Param=0:int, Unhide_Param=0:int, Success_Param:int, Failure_Param:int")
  128. {
  129. int objective_id, objective_type, object_id, custom_type;
  130. int activate, success, failure;
  131. Vector3 location;
  132. int description_id;
  133. bool blip, hidden;
  134. REGISTER_VARIABLES()
  135. {
  136. SAVE_VARIABLE(objective_id, 1);
  137. SAVE_VARIABLE(objective_type, 2);
  138. SAVE_VARIABLE(object_id, 3);
  139. SAVE_VARIABLE(custom_type, 4);
  140. SAVE_VARIABLE(activate, 5);
  141. SAVE_VARIABLE(success, 6);
  142. SAVE_VARIABLE(failure, 7);
  143. SAVE_VARIABLE(description_id, 8);
  144. SAVE_VARIABLE(blip, 9);
  145. SAVE_VARIABLE(hidden, 10);
  146. SAVE_VARIABLE(location, 11);
  147. }
  148. void Created(GameObject * obj)
  149. {
  150. location = Get_Vector3_Parameter("Location");
  151. hidden = (Get_Int_Parameter("Hidden") == 1) ? true : false;
  152. blip = (Get_Int_Parameter("Radar_Blip") == 1) ? true : false;
  153. objective_id = Get_Int_Parameter("Objective_ID");
  154. objective_type = Get_Int_Parameter("Objective_Type");
  155. description_id = Get_Int_Parameter("Objective_Description_ID");
  156. custom_type = Get_Int_Parameter("Custom_Type");
  157. activate = Get_Int_Parameter("Activate_Param");
  158. success = Get_Int_Parameter("Success_Param");
  159. failure = Get_Int_Parameter("Failure_Param");
  160. if ((activate == 0) && (hidden == false))
  161. {
  162. switch (objective_type)
  163. {
  164. case 1: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, description_id);
  165. break;
  166. case 2: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_PENDING, description_id);
  167. break;
  168. case 3: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_PENDING, description_id);
  169. break;
  170. }
  171. if (blip)
  172. Commands->Set_Objective_Radar_Blip(objective_id, location);
  173. }
  174. else if ((activate == 0) && (hidden == true))
  175. {
  176. switch (objective_type)
  177. {
  178. case 1: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_HIDDEN, description_id);
  179. break;
  180. case 2: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_HIDDEN, description_id);
  181. break;
  182. case 3: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_HIDDEN, description_id);
  183. break;
  184. }
  185. if (blip)
  186. Commands->Set_Objective_Radar_Blip(objective_id, location);
  187. }
  188. }
  189. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  190. {
  191. if ((type == custom_type) && (param == activate))
  192. {
  193. switch (objective_type)
  194. {
  195. case 1: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, description_id);
  196. break;
  197. case 2: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_PENDING, description_id);
  198. break;
  199. case 3: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_PENDING, description_id);
  200. break;
  201. }
  202. if (blip)
  203. Commands->Set_Objective_Radar_Blip(objective_id, location);
  204. }
  205. if ((type == custom_type) && (param == success))
  206. {
  207. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_ACCOMPLISHED);
  208. }
  209. if ((type == custom_type) && (param == failure))
  210. {
  211. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_FAILED);
  212. }
  213. if ((type == custom_type) && (hidden == true) && (param == Get_Int_Parameter("Unhide_Param")))
  214. {
  215. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_PENDING);
  216. }
  217. }
  218. };
  219. DECLARE_SCRIPT(M00_Objective_Radar_Blip_On_Object_RMV, "Objective_ID:int, Activate_Type=0:int, Activate_Param=0:int")
  220. {
  221. void Created(GameObject * obj)
  222. {
  223. bool activate = ((Get_Int_Parameter("Activate_Type") == 0) && (Get_Int_Parameter("Activate_Param") == 0)) ? true : false;
  224. int objective_id = Get_Int_Parameter("Objective_ID");
  225. if (activate)
  226. Commands->Set_Objective_Radar_Blip_Object(objective_id, obj);
  227. }
  228. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  229. {
  230. int objective_id = Get_Int_Parameter("Objective_ID");
  231. if ((Get_Int_Parameter("Activate_Type") == type) && (Get_Int_Parameter("Activate_Param") == param))
  232. Commands->Set_Objective_Radar_Blip_Object(objective_id, obj);
  233. }
  234. };
  235. DECLARE_SCRIPT(M00_Objective_Controller_For_Objects_Multiple_Triggers_RMV, "Objective_ID:int, Objective_Type=1:int, Objective_Description_ID:int, Hidden=0:int, Custom_Type:int, Activate_Param=0:int, Number_Of_Triggers:int, Trigger_Param:int, Unhide_Param=0:int, Failure_Param:int")
  236. {
  237. int objective_id, objective_type, custom_type;
  238. int activate, number, trigger, failure;
  239. int so_far;
  240. bool hidden;
  241. int description_id;
  242. REGISTER_VARIABLES()
  243. {
  244. SAVE_VARIABLE(objective_id, 1);
  245. SAVE_VARIABLE(objective_type, 2);
  246. SAVE_VARIABLE(custom_type, 4);
  247. SAVE_VARIABLE(activate, 5);
  248. SAVE_VARIABLE(number, 6);
  249. SAVE_VARIABLE(failure, 7);
  250. SAVE_VARIABLE(description_id, 8);
  251. SAVE_VARIABLE(trigger, 9);
  252. SAVE_VARIABLE(hidden, 10);
  253. SAVE_VARIABLE(so_far, 3);
  254. }
  255. void Created(GameObject * obj)
  256. {
  257. hidden = (Get_Int_Parameter("Hidden") == 1) ? true : false;
  258. so_far = 0;
  259. objective_id = Get_Int_Parameter("Objective_ID");
  260. objective_type = Get_Int_Parameter("Objective_Type");
  261. description_id = Get_Int_Parameter("Objective_Description_ID");
  262. custom_type = Get_Int_Parameter("Custom_Type");
  263. activate = Get_Int_Parameter("Activate_Param");
  264. number = Get_Int_Parameter("Number_Of_Triggers");
  265. trigger = Get_Int_Parameter("Trigger_Param");
  266. failure = Get_Int_Parameter("Failure_Param");
  267. if ((activate == 0) && (hidden == false))
  268. {
  269. switch (objective_type)
  270. {
  271. case 1: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, description_id);
  272. break;
  273. case 2: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_PENDING, description_id);
  274. break;
  275. case 3: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_PENDING, description_id);
  276. break;
  277. }
  278. }
  279. else if ((activate == 0) && (hidden == true))
  280. {
  281. switch (objective_type)
  282. {
  283. case 1: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_HIDDEN, description_id);
  284. break;
  285. case 2: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_HIDDEN, description_id);
  286. break;
  287. case 3: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_HIDDEN, description_id);
  288. break;
  289. }
  290. }
  291. }
  292. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  293. {
  294. if ((type == custom_type) && (param == activate))
  295. {
  296. switch (objective_type)
  297. {
  298. case 1: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_PRIMARY, OBJECTIVE_STATUS_PENDING, description_id);
  299. break;
  300. case 2: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_SECONDARY, OBJECTIVE_STATUS_PENDING, description_id);
  301. break;
  302. case 3: Commands->Add_Objective(objective_id, OBJECTIVE_TYPE_TERTIARY, OBJECTIVE_STATUS_PENDING, description_id);
  303. break;
  304. }
  305. if (so_far >= number)
  306. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_ACCOMPLISHED);
  307. }
  308. if ((type == custom_type) && (param == trigger))
  309. {
  310. so_far++;
  311. if (so_far >= number)
  312. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_ACCOMPLISHED);
  313. }
  314. if ((type == custom_type) && (param == failure))
  315. {
  316. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_FAILED);
  317. }
  318. if ((type == custom_type) && (hidden == true) && (param == Get_Int_Parameter("Unhide_Param")))
  319. {
  320. Commands->Set_Objective_Status(objective_id, OBJECTIVE_STATUS_PENDING);
  321. }
  322. }
  323. };
  324. DECLARE_SCRIPT(M00_Global_Objective_Controller_RMV, "Set_Type:int, Set_Status:int, Remove:int")
  325. {
  326. int set_type, set_status, remove;
  327. int i_obj, i_new;
  328. float f_obj;
  329. void Created(GameObject * obj)
  330. {
  331. set_type = Get_Int_Parameter("Set_Type");
  332. set_status = Get_Int_Parameter("Set_Status");
  333. remove = Get_Int_Parameter("Remove");
  334. }
  335. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  336. {
  337. if (type == set_type)
  338. {
  339. f_obj = (float)param;
  340. f_obj /= 10.0;
  341. i_obj = int(f_obj);
  342. i_new = (f_obj - i_obj) * 10;
  343. switch (i_new) {
  344. case 1: Commands->Change_Objective_Type(i_obj, OBJECTIVE_TYPE_PRIMARY);
  345. case 2: Commands->Change_Objective_Type(i_obj, OBJECTIVE_TYPE_SECONDARY);
  346. case 3: Commands->Change_Objective_Type(i_obj, OBJECTIVE_TYPE_TERTIARY);
  347. }
  348. }
  349. else if (type == set_status)
  350. {
  351. f_obj = (float)param;
  352. f_obj /= 10.0;
  353. i_obj = int(f_obj);
  354. i_new = (f_obj - i_obj) * 10;
  355. switch (i_new) {
  356. case 1: Commands->Set_Objective_Status(i_obj, OBJECTIVE_STATUS_PENDING);
  357. case 2: Commands->Set_Objective_Status(i_obj, OBJECTIVE_STATUS_ACCOMPLISHED);
  358. case 3: Commands->Set_Objective_Status(i_obj, OBJECTIVE_STATUS_FAILED);
  359. case 4: Commands->Set_Objective_Status(i_obj, OBJECTIVE_STATUS_HIDDEN);
  360. }
  361. }
  362. else if (type == remove)
  363. {
  364. Commands->Remove_Objective(param);
  365. }
  366. }
  367. };