Toolkit_Explosions.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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_Explosions.cpp
  22. *
  23. * DESCRIPTION
  24. * Designer Toolkit for Mission Construction - Explosions Subset
  25. *
  26. * PROGRAMMER
  27. * Design Team
  28. *
  29. * VERSION INFO
  30. * $Author: David_y $
  31. * $Revision: 5 $
  32. * $Modtime: 10/25/01 3:36p $
  33. * $Archive: /Commando/Code/Scripts/Toolkit_Explosions.cpp $
  34. *
  35. ******************************************************************************/
  36. #include "toolkit.h"
  37. /*
  38. Editor Script - M00_Explosion_Create_RMV
  39. This creates an explosion at a location.
  40. Parameters:
  41. Explosion_Name = The name of the explosion type to make.
  42. Origin = The Vector3 location of the explosion.
  43. */
  44. DECLARE_SCRIPT(M00_Explosion_Create_RMV, "Start_Now=0:int, Create_At_Obj=0:int, Receive_Type:int, Receive_Param_On=1:int, Explosion_Name:string, Origin:vector3, Debug_Mode=0:int")
  45. {
  46. Vector3 explosion_origin;
  47. int custom_type;
  48. int parameter;
  49. bool debug_mode;
  50. void Created(GameObject * obj)
  51. {
  52. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  53. if (Get_Int_Parameter("Create_At_Obj"))
  54. {
  55. explosion_origin = Commands->Get_Position(obj);
  56. }
  57. else
  58. {
  59. explosion_origin = Get_Vector3_Parameter("Origin");
  60. }
  61. custom_type = Get_Int_Parameter("Receive_Type");
  62. parameter = Get_Int_Parameter("Receive_Param_On");
  63. if (Get_Int_Parameter("Start_Now"))
  64. {
  65. SCRIPT_DEBUG_MESSAGE(("M00_Explosion_Create_RMV ACTIVATED.\n"));
  66. Commands->Create_Explosion(Get_Parameter("Explosion_Name"), explosion_origin, obj);
  67. }
  68. }
  69. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  70. {
  71. SCRIPT_DEBUG_MESSAGE(("M00_Explosion_Create_RMV received custom type %d, param %d.\n", type, param));
  72. if ((type == custom_type) && (param == parameter))
  73. {
  74. SCRIPT_DEBUG_MESSAGE(("M00_Explosion_Create_RMV ACTIVATED.\n"));
  75. Commands->Create_Explosion(Get_Parameter("Explosion_Name"), explosion_origin, obj);
  76. }
  77. }
  78. };
  79. /*
  80. Editor Script - M00_Explosion_Create_At_Bone_RMV
  81. This creates an explosion on a specific bone of an object.
  82. Parameters:
  83. Explosion_Name = The name of the explosion to create.
  84. Object_ID = The ID of the object to create the explosion on.
  85. Bone_Name = The bone name to create the explosion on.
  86. */
  87. DECLARE_SCRIPT(M00_Explosion_Create_At_Bone_RMV, "Start_Now=0:int, Receive_Type:int, Receive_Param_On:int, Explosion_Name:string, Object_ID:int, Bone_Name:string, Debug_Mode=0:int")
  88. {
  89. int target_id;
  90. int custom_type;
  91. int parameter;
  92. bool debug_mode;
  93. void Created(GameObject * obj)
  94. {
  95. debug_mode = (Get_Int_Parameter("Debug_Mode") == 1) ? true : false;
  96. custom_type = Get_Int_Parameter("Receive_Type");
  97. parameter = Get_Int_Parameter("Receive_Param_On");
  98. target_id = Get_Int_Parameter("Object_ID");
  99. if (Get_Int_Parameter("Start_Now"))
  100. {
  101. SCRIPT_DEBUG_MESSAGE(("M00_Explosion_Create_At_Bone_RMV ACTIVATED.\n"));
  102. if (Commands->Find_Object(target_id) != NULL)
  103. Commands->Create_Explosion_At_Bone(Get_Parameter("Explosion_Name"), Commands->Find_Object(target_id), Get_Parameter("Bone_Name"), obj);
  104. }
  105. }
  106. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  107. {
  108. SCRIPT_DEBUG_MESSAGE(("M00_Explosion_Create_At_Bone_RMV received custom type %d, param %d.\n", type, param));
  109. if ((type == custom_type) && (param == parameter))
  110. {
  111. SCRIPT_DEBUG_MESSAGE(("M00_Explosion_Create_At_Bone_RMV ACTIVATED.\n"));
  112. if (Commands->Find_Object(target_id) != NULL)
  113. Commands->Create_Explosion_At_Bone(Get_Parameter("Explosion_Name"), Commands->Find_Object(target_id), Get_Parameter("Bone_Name"), obj);
  114. }
  115. }
  116. };
  117. DECLARE_SCRIPT(M00_Create_Random_Explosion_DLS, "Explosion_Name:string, Delay_Min=0.0f:float, Delay_Max=4.0f:float, Loc_ID0=0:int, Loc_ID1=0:int, Loc_ID2=0:int, Loc_ID3=0:int, Loc_ID4=0:int, Loc_ID5=0:int, Loc_ID6=0:int, Loc_ID7=0:int, Loc_ID8=0:int, Loc_ID9=0:int")
  118. {
  119. bool active;
  120. int random;
  121. int last;
  122. int loc_id[10];
  123. enum{EXPLODE};
  124. // Register variables to be Auto-Saved
  125. // All variables must have a unique ID, less than 256, that never changes
  126. REGISTER_VARIABLES()
  127. {
  128. SAVE_VARIABLE( active, 1 );
  129. SAVE_VARIABLE( random, 2 );
  130. SAVE_VARIABLE( last, 3 );
  131. }
  132. void Created(GameObject * obj)
  133. {
  134. loc_id[0] = Get_Int_Parameter("Loc_ID0");
  135. loc_id[1] = Get_Int_Parameter("Loc_ID1");
  136. loc_id[2] = Get_Int_Parameter("Loc_ID2");
  137. loc_id[3] = Get_Int_Parameter("Loc_ID3");
  138. loc_id[4] = Get_Int_Parameter("Loc_ID4");
  139. loc_id[5] = Get_Int_Parameter("Loc_ID5");
  140. loc_id[6] = Get_Int_Parameter("Loc_ID6");
  141. loc_id[7] = Get_Int_Parameter("Loc_ID7");
  142. loc_id[8] = Get_Int_Parameter("Loc_ID8");
  143. loc_id[9] = Get_Int_Parameter("Loc_ID9");
  144. active = false;
  145. random = 0;
  146. last = 0;
  147. }
  148. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  149. {
  150. if(type == M00_CREATE_RANDOM_EXPLOSION && param == 1)
  151. {
  152. active = true;
  153. float delay = Commands->Get_Random(Get_Float_Parameter("Delay_Min"), Get_Float_Parameter("Delay_Max"));
  154. Commands->Start_Timer (obj, this, delay, EXPLODE);
  155. }
  156. if(type == M00_CREATE_RANDOM_EXPLOSION && param == 0)
  157. {
  158. active = false;
  159. }
  160. }
  161. void Timer_Expired(GameObject* obj, int timer_id)
  162. {
  163. if(timer_id == EXPLODE && active)
  164. {
  165. while (random == last || loc_id[random] == 0)
  166. {
  167. random = Commands->Get_Random_Int(0, 9);
  168. }
  169. Commands->Create_Explosion(Get_Parameter("Explosion_Name"), Commands->Get_Position(Commands->Find_Object(loc_id[random])), obj);
  170. last = random;
  171. float delay = Commands->Get_Random(Get_Float_Parameter("Delay_Min"), Get_Float_Parameter("Delay_Max"));
  172. Commands->Start_Timer (obj, this, delay, EXPLODE);
  173. }
  174. }
  175. };
  176. DECLARE_SCRIPT( M00_NukeStrike_Anim, "")
  177. {
  178. void Created(GameObject * obj)
  179. {
  180. Commands->Send_Custom_Event( obj, obj, 0, 1, 206/30 );
  181. Commands->Send_Custom_Event( obj, obj, 0, 2, 250/30 );
  182. Commands->Send_Custom_Event( obj, obj, 0, 3, 350/30 );
  183. GameObject *Nuke;
  184. Nuke = Commands->Create_Object( "Generic_Cinematic", Commands->Get_Position(obj) );
  185. if ( Nuke )
  186. {
  187. Commands->Set_Model( Nuke, "XG_AG_Nuke" );
  188. Commands->Attach_Script( Nuke, "M00_PlayAnimation_DestroyObject_DAY", "Nuke_Missle.Nuke_Missle");
  189. Commands->Create_3D_Sound_At_Bone( "SFX.Nuclear_Strike_Buildup", Nuke, "ROOTTRANSFORM" );
  190. }
  191. }
  192. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  193. {
  194. if ( type == 1 )
  195. {
  196. GameObject *NukeCloud;
  197. NukeCloud = Commands->Create_Object( "Generic_Cinematic", Commands->Get_Position(obj) );
  198. if ( NukeCloud )
  199. {
  200. Commands->Set_Model( NukeCloud, "XG_AG_Nukecloud" );
  201. Commands->Attach_Script( NukeCloud, "M00_PlayAnimation_DestroyObject_DAY", "Nuke_cloud.Nuke_cloud");
  202. }
  203. Commands->Shake_Camera( Commands->Get_Position(obj), 2.0f, 0.5f, 2.0f );
  204. }
  205. else if ( type == 2 )
  206. {
  207. Commands->Shake_Camera( Commands->Get_Position(obj), 2.0f, 1.0f, 3.0f );
  208. }
  209. else if ( type == 3 )
  210. {
  211. GameObject *NukeCloudTwo;
  212. NukeCloudTwo = Commands->Create_Object( "Generic_Cinematic", Commands->Get_Position(obj) );
  213. if ( NukeCloudTwo )
  214. {
  215. Commands->Set_Model( NukeCloudTwo, "XG_AG_NukeCloud" );
  216. Commands->Attach_Script( NukeCloudTwo, "M00_PlayAnimation_DestroyObject_DAY", "XG_Nukecloud_02");
  217. }
  218. }
  219. }
  220. };