Test_DAY.cpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. *
  22. * DESCRIPTION
  23. *
  24. * VERSION INFO
  25. * $Author: David_y $
  26. * $Revision: 75 $
  27. * $Modtime: 1/14/02 12:40a $
  28. * $Archive: /Commando/Code/Scripts/Test_DAY.cpp $
  29. *
  30. ******************************************************************************/
  31. #include "toolkit.h"
  32. DECLARE_SCRIPT(M00_Screenshot_Poser_DAY, "Anim_Name:string" )
  33. {
  34. void Created( GameObject *obj )
  35. {
  36. Commands->Set_Loiters_Allowed( obj, false );
  37. Commands->Innate_Disable( obj );
  38. Commands->Innate_Soldier_Enable_Enemy_Seen( obj, false );
  39. Commands->Innate_Soldier_Enable_Gunshot_Heard( obj, false );
  40. Commands->Innate_Soldier_Enable_Footsteps_Heard( obj, false );
  41. Commands->Innate_Soldier_Enable_Bullet_Heard( obj, false );
  42. Commands->Innate_Soldier_Enable_Actions( obj, false );
  43. ActionParamsStruct params;
  44. params.Set_Basic( this, 99, 0 );
  45. params.Set_Animation( Get_Parameter( "Anim_Name" ), true );
  46. Commands->Action_Play_Animation( obj, params );
  47. }
  48. void Action_Complete( GameObject * obj, int action_id, ActionCompleteReason complete_reason )
  49. {
  50. if ( action_id == 0 )
  51. {
  52. ActionParamsStruct params;
  53. params.Set_Basic( this, 99, 0 );
  54. params.Set_Animation( Get_Parameter( "Anim_Name" ), true );
  55. Commands->Action_Play_Animation( obj, params );
  56. }
  57. }
  58. };
  59. DECLARE_SCRIPT (DAY_TestScriptOne, "")
  60. {
  61. int action;
  62. void Created ( GameObject * obj )
  63. {
  64. action = 1;
  65. ActionParamsStruct params;
  66. params.Set_Basic( this, 99, 1 );
  67. params.Set_Movement( Commands->Get_Position( Commands->Find_Object(100077) ), 0.6f, 1.0f, false );
  68. params.Set_Attack( Commands->Find_Object(100079), 40.0f, 0.0f, true );
  69. params.AttackCrouched = true;
  70. params.MoveCrouched = true;
  71. Commands->Action_Attack( obj, params );
  72. Commands->Send_Custom_Event( obj, obj, 0, 0, 5.0f );
  73. }
  74. void Custom( GameObject *obj, int type, int param, GameObject *sender)
  75. {
  76. if ( action == 1 )
  77. {
  78. action = 2;
  79. ActionParamsStruct params;
  80. params.Set_Basic( this, 99, 2 );
  81. params.Set_Movement( Commands->Get_Position( Commands->Find_Object(100078) ), 0.6f, 1.0f, false );
  82. params.Set_Attack( Commands->Find_Object(100079), 40.0f, 0.0f, true );
  83. params.AttackCrouched = true;
  84. params.MoveCrouched = true;
  85. params.AttackCheckBlocked = false;
  86. Commands->Action_Attack( obj, params );
  87. Commands->Send_Custom_Event( obj, obj, 0, 0, 5.0f );
  88. }
  89. else
  90. {
  91. action = 1;
  92. ActionParamsStruct params;
  93. params.Set_Basic( this, 99, 1 );
  94. params.Set_Movement( Commands->Get_Position( Commands->Find_Object(100077) ), 0.6f, 1.0f, false );
  95. params.Set_Attack( Commands->Find_Object(100079), 40.0f, 0.0f, true );
  96. params.AttackCrouched = true;
  97. params.MoveCrouched = true;
  98. Commands->Action_Attack( obj, params );
  99. Commands->Send_Custom_Event( obj, obj, 0, 0, 5.0f );
  100. }
  101. }
  102. };
  103. DECLARE_SCRIPT (DAY_TestScriptTwo, "")
  104. {
  105. void Created( GameObject *obj )
  106. {
  107. Commands->Innate_Disable(obj);
  108. }
  109. };
  110. DECLARE_SCRIPT (DAY_TestScriptThree, "")
  111. {
  112. void Created( GameObject *obj )
  113. {
  114. Commands->Create_Explosion( "Explosion_Rocket_Gunboat_M01", Commands->Get_Position(obj), obj);
  115. }
  116. };
  117. DECLARE_SCRIPT (DAY_VTOL_CircleAttack, "")
  118. {
  119. int damager_id;
  120. Vector3 Get_Circle_Position( GameObject *obj, GameObject *target , float radius , float reverseprob)
  121. {
  122. double theta_angle = 90;
  123. float reverse = Commands->Get_Random(0.0f,1.0f);
  124. if ( reverse < reverseprob)
  125. {
  126. theta_angle *= -1;
  127. }
  128. Vector3 position = Commands->Get_Position(obj);
  129. Vector3 targetlocation = Commands->Get_Position( target ) - position;
  130. targetlocation.Normalize();
  131. targetlocation *= radius;
  132. targetlocation.Rotate_Z(DEG_TO_RADF(theta_angle));
  133. targetlocation += position;
  134. targetlocation.Z += Commands->Get_Safe_Flight_Height( targetlocation.X, targetlocation.Y );
  135. return targetlocation;
  136. }
  137. void Created( GameObject *obj )
  138. {
  139. }
  140. void Damaged( GameObject *obj , GameObject *damager, float amount )
  141. {
  142. if ( damager )
  143. {
  144. damager_id = Commands->Get_ID(damager);
  145. }
  146. Commands->Send_Custom_Event( obj, obj, 1, 1, 0.0f );
  147. }
  148. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  149. {
  150. if ( type == 1 )
  151. {
  152. if ( param == 1 )
  153. {
  154. GameObject *target = Commands->Find_Object(damager_id);
  155. if (target)
  156. {
  157. ActionParamsStruct params;
  158. params.Set_Basic( this, 99, 1 );
  159. params.Set_Movement(Get_Circle_Position( obj, target, 5.0f, 0.1f ), 1.0f, 1.0f, false );
  160. params.Set_Attack(target, 40.0f, 0.0f, true );
  161. Commands->Action_Attack( obj, params );
  162. Commands->Send_Custom_Event( obj, obj, 1, 1, 5.0f );
  163. }
  164. }
  165. }
  166. }
  167. };
  168. DECLARE_SCRIPT (M00_GrantPowerup_Created, "WeaponDef:string")
  169. {
  170. void Created( GameObject *obj)
  171. {
  172. const char *Weapon = Get_Parameter( "WeaponDef" );
  173. Commands->Give_PowerUp( obj, Weapon, false );
  174. }
  175. };
  176. DECLARE_SCRIPT (M00_VisceroidInnate_DAY, "")
  177. {
  178. void Created( GameObject *obj )
  179. {
  180. Commands->Set_Loiters_Allowed( obj, false );
  181. Commands->Set_Animation( obj, "C_Visceroid.C_Visceroid", true );
  182. }
  183. void Killed( GameObject *obj, GameObject *killer )
  184. {
  185. Commands->Set_Animation( obj, "C_Visceroid.C_Visceroid_Die", false );
  186. }
  187. };
  188. // Generic script to replace destroyed models (Turrets, etc)
  189. DECLARE_SCRIPT (M00_DestroyedStateObject_DAY, "OriginalModelFacing:float,DestroyedModelPreset:string")
  190. {
  191. void Destroyed( GameObject *obj )
  192. {
  193. Vector3 object_pos = Commands->Get_Position(obj);
  194. GameObject *DestroyedModel;
  195. DestroyedModel = Commands->Create_Object( Get_Parameter("DestroyedModelPreset"), object_pos );
  196. Commands->Set_Facing( DestroyedModel, Get_Float_Parameter("OriginalModelFAcing") );
  197. }
  198. };
  199. // For playing ambient sounds on characters - DAY
  200. DECLARE_SCRIPT(M00_Play_Sound_Object_Bone_DAY, "Sound_Preset:string, Frequency_Min=-1.0:float, Frequency_Max:float")
  201. {
  202. void Created(GameObject * obj)
  203. {
  204. if (Get_Int_Parameter("Frequency_Min") == -1)
  205. {
  206. Timer_Expired(obj, 0);
  207. }
  208. else
  209. {
  210. float time = Commands->Get_Random(Get_Float_Parameter("Frequency_Min"), Get_Float_Parameter("Frequency_Max"));
  211. Commands->Start_Timer(obj, this, time, 0);
  212. }
  213. }
  214. void Timer_Expired(GameObject * obj, int timer_id)
  215. {
  216. const char * sound = Get_Parameter("Sound_Preset");
  217. Vector3 pos = Commands->Get_Position(obj);
  218. pos += Get_Vector3_Parameter("Offset");
  219. int id;
  220. Commands->Debug_Message("Playing 3D Sound\n");
  221. id = Commands->Create_3D_Sound_At_Bone( sound, obj, "ROOTTRANSFORM" );
  222. Commands->Monitor_Sound(obj, id);
  223. }
  224. void Custom(GameObject * obj, int type, int param, GameObject * sender)
  225. {
  226. if (type == CUSTOM_EVENT_SOUND_ENDED)
  227. {
  228. if (Get_Int_Parameter("Frequency_Min") < 0 )
  229. {
  230. float time = Commands->Get_Random(Get_Float_Parameter("Frequency_Min"), Get_Float_Parameter("Frequency_Max"));
  231. Commands->Start_Timer(obj, this, time, 0);
  232. }
  233. }
  234. }
  235. };
  236. DECLARE_SCRIPT (M00_PlayAnimation_DestroyObject_DAY, "AnimationName:string")
  237. {
  238. void Created( GameObject * obj )
  239. {
  240. const char * animname = Get_Parameter("AnimationName");
  241. Commands->Set_Animation( obj, animname, 0 );
  242. }
  243. void Animation_Complete( GameObject * obj, const char * animation_name )
  244. {
  245. Commands->Destroy_Object(obj);
  246. }
  247. };
  248. DECLARE_SCRIPT (M00_Disable_Loiter_DAY, "")
  249. {
  250. void Created( GameObject * obj )
  251. {
  252. Commands->Set_Loiters_Allowed( obj , false );
  253. }
  254. void Custom( GameObject * obj, int type, int param, GameObject * sender )
  255. {
  256. if ( type == M00_LOITER_ENABLE_TOGGLE )
  257. {
  258. Commands->Set_Loiters_Allowed( obj, true );
  259. }
  260. }
  261. };
  262. DECLARE_SCRIPT (M00_Cinematic_Kill_Object_DAY, "")
  263. {
  264. void Created( GameObject * obj )
  265. {
  266. Commands->Apply_Damage( obj, 10000.0f, "BlamoKiller", NULL );
  267. }
  268. };
  269. DECLARE_SCRIPT (M00_Set_Background_Music_DAY, "MusicFile:string")
  270. {
  271. void Created( GameObject * obj )
  272. {
  273. Commands->Set_Background_Music( Get_Parameter("MusicFile") );
  274. }
  275. };