Test_DAK.cpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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: Darren_k $
  26. * $Revision: 25 $
  27. * $Modtime: 1/12/02 3:19p $
  28. * $Archive: /Commando/Code/Scripts/Test_DAK.cpp $
  29. *
  30. ******************************************************************************/
  31. #include "toolkit.h"
  32. DECLARE_SCRIPT (DAK_TestScriptOne, "")
  33. {
  34. void Damaged( GameObject *obj , GameObject *damager, float amount)
  35. {
  36. if ( Commands->Is_A_Star(damager) )
  37. {
  38. ActionParamsStruct params;
  39. params.Set_Basic( this, 1, 1 );
  40. params.Set_Movement( damager, RUN, 2 );
  41. Commands->Action_Goto( obj, params );
  42. }
  43. }
  44. };
  45. DECLARE_SCRIPT (DAK_PlayerSpotted, "")
  46. {
  47. void Damaged ( GameObject *obj , GameObject *damager, float amount)
  48. {
  49. GameObject * NodSAM = Commands->Find_Object (100012);
  50. if (NodSAM)
  51. {
  52. ActionParamsStruct params;
  53. params.Set_Basic( this, 1, 1 );
  54. params.Set_Movement( NodSAM, RUN, 1 );
  55. Commands->Action_Goto( obj, params );
  56. }
  57. else
  58. {
  59. ActionParamsStruct params;
  60. params.Set_Basic( this, 1, 1 );
  61. params.Set_Attack( damager, 20, 0, 1 );
  62. Commands->Action_Attack( obj, params );
  63. }
  64. }
  65. };
  66. DECLARE_SCRIPT ( DAK_Fire_Gas_Elec_Death_DAK, "DeathType:string" )
  67. {
  68. bool firsttime; // prevents an infinante loop each time obj is damaged by DeathType.
  69. void Damaged ( GameObject *obj, GameObject *damager, float amount )
  70. {
  71. // check to see if obj is at 25% or less of its health.
  72. if ( Commands->Get_Health ( obj ) <= 0.25 * Commands->Get_Max_Health ( obj ) )
  73. {
  74. // plays animation once.
  75. if ( firsttime == true )
  76. {
  77. firsttime = false;
  78. ActionParamsStruct params;
  79. params.Set_Basic( this, 99, 1 );
  80. // set animation based upon DeathType (Gas, Electric or Default to Fire)
  81. if ( strcmp( Get_Parameter( "DeathType" ), "Fire" ) )
  82. {
  83. params.Set_Animation( "S_A_HUMAN.H_A_FLMA",0 ); // fire death
  84. }
  85. else
  86. if ( strcmp( Get_Parameter( "DeathType" ), "Electic" ) )
  87. {
  88. params.Set_Animation( "S_A_HUMAN.H_A_6X05",0 ); // electric death
  89. }
  90. else params.Set_Animation( "S_A_HUMAN.H_A_FLMA",0 ); // gas death
  91. Commands->Action_Play_Animation( obj, params );
  92. // begin DeathType damage
  93. Commands->Apply_Damage( obj, 1.0f, Get_Parameter( "DeathType" ) );
  94. }
  95. }
  96. else
  97. {
  98. firsttime = true;
  99. }
  100. }
  101. void Action_Complete(GameObject * obj, int action_id, ActionCompleteReason reason)
  102. {
  103. if((action_id == 1) && (reason == ACTION_COMPLETE_NORMAL))
  104. {
  105. // animation is complete. kill obj.
  106. Commands->Apply_Damage (obj, 10000.0f, "Blamokiller");
  107. }
  108. }
  109. };
  110. DECLARE_SCRIPT(DAK_Vehicle_Regen_DAK, "" )
  111. {
  112. void Created ( GameObject *obj )
  113. {
  114. Commands->Send_Custom_Event ( obj, obj, 0, 0, 0 );
  115. }
  116. void Custom (GameObject* obj, int type, int param, GameObject* sender)
  117. {
  118. if ( type == 0 ) // regenerate health.
  119. {
  120. // check to see if health needs to be regenerated.
  121. if ( Commands->Get_Health ( obj ) < Commands->Get_Max_Health ( obj ) )
  122. {
  123. Commands->Apply_Damage (obj, -10, "RegenHealth", NULL);
  124. }
  125. // restart the timer
  126. Commands->Send_Custom_Event ( obj, obj, 0, 0, 5 );
  127. }
  128. }
  129. };
  130. DECLARE_SCRIPT(DAK_Electric_Death_DAK, "" )
  131. {
  132. void Created ( GameObject *obj )
  133. {
  134. int time = Commands->Get_Random(1, 3);
  135. Commands->Send_Custom_Event ( obj, obj, 0, 0, time );
  136. }
  137. void Damaged (GameObject *obj, GameObject *damager, float amount )
  138. {
  139. Commands->Send_Custom_Event ( obj, obj, 1, 0, 1 ); // wait a second before applying next ammount of damage.
  140. }
  141. void Custom ( GameObject *obj, int type, int param, GameObject *sender )
  142. {
  143. if ( type == 0 ) // create next soldier, attach script, kill yourself with electric damage.
  144. {
  145. Vector3 position = Commands->Get_Position (obj);
  146. position.X += Commands->Get_Random(-3, 3);
  147. position.Y += Commands->Get_Random(-3, 3);
  148. GameObject *new_object = Commands->Create_Object( "Nod_Minigunner_0_Def", position);
  149. Commands->Attach_Script (new_object, "DAK_Electric_Death_DAK", "");
  150. Commands->Apply_Damage (obj, 10, "Electric", NULL);
  151. }
  152. if ( type == 1 ) // apply next ammount of electric damage.
  153. {
  154. Commands->Apply_Damage (obj, 10, "Electric", NULL);
  155. }
  156. }
  157. };
  158. DECLARE_SCRIPT(DAK_PCT_Pokable_DAK, "" )
  159. {
  160. void Created ( GameObject *obj )
  161. {
  162. Commands->Enable_HUD_Pokable_Indicator( obj, true );
  163. // Commands->Display_Health_Bar( obj, false );
  164. }
  165. };
  166. DECLARE_SCRIPT( M00_BUILDING_EXPLODE_NO_DAMAGE_DAK, "" )
  167. {
  168. void Killed( GameObject *obj, GameObject *killer )
  169. {
  170. //Commands->Create_Explosion ( "Building_Explode_No_Damage", position, NULL );
  171. Commands->Shake_Camera( Commands->Get_Position( obj ), 25, 0.1f, 4.0f );
  172. }
  173. };