Toolkit_Siege.cpp 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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_Siege.cpp
  22. *
  23. * DESCRIPTION
  24. * Designer Toolkit for Mission Construction - Siege Subset
  25. *
  26. * PROGRAMMER
  27. * Design Team
  28. *
  29. * VERSION INFO
  30. * $Author: Ryan_v $
  31. * $Revision: 5 $
  32. * $Modtime: 11/03/00 1:36p $
  33. * $Archive: /Commando/Code/Scripts/Toolkit_Siege.cpp $
  34. *
  35. ******************************************************************************/
  36. #include "toolkit.h"
  37. DECLARE_SCRIPT(M00_Siege_Zone_RAD, "Start_Now=1:int, Receive_Type:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, Wander_Distance=3.0:float, My_Group_ID=0:int, Attraction_Radius=20.0:float, Debug_Mode=0:int")
  38. {
  39. int my_actor_id;
  40. int my_group_id;
  41. bool script_active;
  42. bool debug_mode;
  43. void Created (GameObject* obj)
  44. {
  45. float rnd_value;
  46. rnd_value = Commands->Get_Random(0.1f, 1.0f);
  47. my_actor_id = 0;
  48. my_group_id = Get_Int_Parameter("My_Group_ID");
  49. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  50. if (Get_Int_Parameter("Start_Now"))
  51. {
  52. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD ACTIVATED.\n"));
  53. script_active = true;
  54. Commands->Start_Timer (obj, this, rnd_value, M00_TIMER_SIEGE_ZONE);
  55. }
  56. else
  57. {
  58. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD IS NOT ACTIVE!\n"));
  59. script_active = false;
  60. }
  61. }
  62. void Timer_Expired (GameObject * obj, int timer_id)
  63. {
  64. float rnd_value;
  65. GameObject* actor_obj;
  66. Vector3 my_loc;
  67. my_loc = Commands->Get_Position(obj);
  68. if (timer_id == M00_TIMER_SIEGE_ZONE)
  69. {
  70. if (my_actor_id)
  71. {
  72. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD has a registered actor.\n"));
  73. actor_obj = Commands->Find_Object(my_actor_id);
  74. if (actor_obj)
  75. {
  76. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD has found the registered actor.\n"));
  77. Commands->Send_Custom_Event (obj, actor_obj, M00_CUSTOM_SIEGE_ZONE_CHECKING_ACTOR, 0, 0.0f);
  78. }
  79. else
  80. {
  81. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD cannot find the actor, clearing zone.\n"));
  82. my_actor_id = 0;
  83. }
  84. }
  85. else
  86. {
  87. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD has no actor, shouting for one.\n"));
  88. Commands->Create_Logical_Sound(obj, M00_SOUND_SIEGE_ZONE, my_loc, Get_Float_Parameter("Attraction_Radius"));
  89. }
  90. if (script_active)
  91. {
  92. rnd_value = Commands->Get_Random(4.0f, 8.0f);
  93. Commands->Start_Timer (obj, this, rnd_value, M00_TIMER_SIEGE_ZONE);
  94. }
  95. }
  96. }
  97. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  98. {
  99. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD has received a custom of type %d, param %d.\n", type, param));
  100. if ((!my_actor_id) && (type == M00_CUSTOM_SIEGE_ACTOR_GROUP_CHECK))
  101. {
  102. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD has an actor attempting to register.\n"));
  103. if ((param == my_group_id) && (sender))
  104. {
  105. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD verified that this actor is with the same group.\n"));
  106. my_actor_id = Commands->Get_ID (sender);
  107. Commands->Send_Custom_Event (obj, sender, M00_CUSTOM_SIEGE_ZONE_VERIFICATION, 0, 0.0f);
  108. }
  109. }
  110. if ((my_actor_id) && (param == my_actor_id) && (type == M00_CUSTOM_SIEGE_ACTOR_IS_DEAD))
  111. {
  112. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD was told that its actor is dead.\n"));
  113. my_actor_id = 0;
  114. }
  115. if ((my_actor_id) && (type == M00_CUSTOM_SIEGE_ACTOR_RESPONDING) && (sender))
  116. {
  117. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD has an actor responding.\n"));
  118. if (param == my_actor_id)
  119. {
  120. Vector3 my_loc;
  121. my_loc = Commands->Get_Position(obj);
  122. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD has verified that this is its actor - setting position.\n"));
  123. Commands->Set_Innate_Soldier_Home_Location(sender, my_loc, Get_Float_Parameter("Wander_Distance"));
  124. }
  125. else
  126. {
  127. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD is registered to the wrong actor - clearing.\n"));
  128. my_actor_id = 0;
  129. Commands->Send_Custom_Event (obj, sender, M00_CUSTOM_SIEGE_ACTOR_UNREGISTER, 0, 0.0f);
  130. }
  131. }
  132. if (type == Get_Int_Parameter("Receive_Type"))
  133. {
  134. if (param == Get_Int_Parameter("Receive_Param_On"))
  135. {
  136. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD ACTIVATED.\n"));
  137. script_active = true;
  138. float rnd_value;
  139. rnd_value = Commands->Get_Random(0.1f, 1.0f);
  140. Commands->Start_Timer (obj, this, rnd_value, M00_TIMER_SIEGE_ZONE);
  141. }
  142. if (param == Get_Int_Parameter("Receive_Param_Off"))
  143. {
  144. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD DEACTIVATED.\n"));
  145. script_active = false;
  146. }
  147. }
  148. if (type == M00_CUSTOM_SIEGE_OBJECT_GROUP_CHANGE)
  149. {
  150. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Zone_RAD is being ordered to change its group to %d.\n", param));
  151. my_group_id = param;
  152. }
  153. }
  154. };
  155. DECLARE_SCRIPT(M00_Siege_Actor_RAD, "Start_Now=1:int, Receive_Type:int, Receive_Param_On=1:int, Receive_Param_Off=0:int, My_Group_ID=0:int, Debug_Mode=0:int")
  156. {
  157. int registered_zone;
  158. int my_group_id;
  159. bool script_active;
  160. bool debug_mode;
  161. void Created (GameObject* obj)
  162. {
  163. registered_zone = 0;
  164. my_group_id = Get_Int_Parameter("My_Group_ID");
  165. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  166. if (Get_Int_Parameter("Start_Now"))
  167. {
  168. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD ACTIVATED.\n"));
  169. script_active = true;
  170. }
  171. else
  172. {
  173. script_active = false;
  174. }
  175. }
  176. void Sound_Heard (GameObject * obj, const CombatSound & sound)
  177. {
  178. if (script_active)
  179. {
  180. if ((sound.Type == M00_SOUND_SIEGE_ZONE) && (!registered_zone))
  181. {
  182. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD has heard a zone shouting for an actor, sound ID = %d.\n", sound.Type));
  183. Commands->Send_Custom_Event (obj, sound.Creator, M00_CUSTOM_SIEGE_ACTOR_GROUP_CHECK, my_group_id, 0.0f);
  184. }
  185. }
  186. }
  187. void Custom (GameObject * obj, int type, int param, GameObject * sender)
  188. {
  189. int my_id;
  190. my_id = Commands->Get_ID(obj);
  191. if ((!registered_zone) && (type == M00_CUSTOM_SIEGE_ZONE_VERIFICATION))
  192. {
  193. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD is registering with a siege zone.\n"));
  194. registered_zone = Commands->Get_ID(sender);
  195. }
  196. if (type == M00_CUSTOM_SIEGE_ZONE_CHECKING_ACTOR)
  197. {
  198. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD is being checked for proper ID.\n"));
  199. Commands->Send_Custom_Event (obj, sender, M00_CUSTOM_SIEGE_ACTOR_RESPONDING, my_id, 0.0f);
  200. }
  201. if (type == M00_CUSTOM_SIEGE_ACTOR_UNREGISTER)
  202. {
  203. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD is being told to unregister the zone.\n"));
  204. registered_zone = 0;
  205. }
  206. if (type == M00_CUSTOM_SIEGE_OBJECT_GROUP_CHANGE)
  207. {
  208. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD is being told to change its group to %d.\n", param));
  209. my_group_id = param;
  210. }
  211. if (type == Get_Int_Parameter("Receive_Type"))
  212. {
  213. if (param == Get_Int_Parameter("Receive_Param_On"))
  214. {
  215. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD ACTIVATED.\n"));
  216. script_active = true;
  217. }
  218. if (param == Get_Int_Parameter("Receive_Param_Off"))
  219. {
  220. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD DEACTIVATED.\n"));
  221. script_active = false;
  222. }
  223. }
  224. }
  225. void Destroyed (GameObject* obj)
  226. {
  227. int my_id;
  228. GameObject* zone_obj;
  229. my_id = Commands->Get_ID(obj);
  230. if (registered_zone)
  231. {
  232. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD has been destroyed.\n"));
  233. zone_obj = Commands->Find_Object(registered_zone);
  234. if (zone_obj)
  235. {
  236. SCRIPT_DEBUG_MESSAGE(("M00_Siege_Actor_RAD found its siege zone, unregistering.\n"));
  237. Commands->Send_Custom_Event (obj, zone_obj, M00_CUSTOM_SIEGE_ACTOR_IS_DEAD, my_id, 0.0f);
  238. }
  239. }
  240. }
  241. };