scriptcommands.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/scriptcommands.h $*
  25. * *
  26. * $Author:: Patrick $*
  27. * *
  28. * $Modtime:: 1/09/02 12:09p $*
  29. * *
  30. * $Revision:: 211 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef SCRIPTCOMMANDS_H
  36. #define SCRIPTCOMMANDS_H
  37. #ifndef VECTOR3_H
  38. #include "vector3.h"
  39. #endif
  40. #ifndef COMBATSOUND_H
  41. #include "combatsound.h"
  42. #endif
  43. #ifndef ACTIONPARAMS_H
  44. #include "actionparams.h"
  45. #endif
  46. /*
  47. ** DLL import/export macros
  48. */
  49. #ifdef BUILDING_DLL
  50. #define SCRIPT_DLL_COMMAND _declspec(dllimport)
  51. #else
  52. #define SCRIPT_DLL_COMMAND extern "C" _declspec(dllexport)
  53. #endif
  54. /*
  55. ** Types
  56. */
  57. class ScriptableGameObj;
  58. typedef ScriptableGameObj GameObject;
  59. class AudibleSoundClass;
  60. typedef AudibleSoundClass Sound2D;
  61. class Sound3DClass;
  62. typedef Sound3DClass Sound3D;
  63. class ScriptClass;
  64. class ScriptSaver;
  65. class ScriptLoader;
  66. /*
  67. ** Script Commands
  68. */
  69. /*
  70. ** MISC Script ENUMS
  71. */
  72. enum {
  73. OBJECTIVE_TYPE_PRIMARY = 1,
  74. OBJECTIVE_TYPE_SECONDARY,
  75. OBJECTIVE_TYPE_TERTIARY,
  76. OBJECTIVE_STATUS_PENDING = 0,
  77. OBJECTIVE_STATUS_ACCOMPLISHED,
  78. OBJECTIVE_STATUS_FAILED,
  79. OBJECTIVE_STATUS_HIDDEN,
  80. RADAR_BLIP_SHAPE_NONE = 0,
  81. RADAR_BLIP_SHAPE_HUMAN,
  82. RADAR_BLIP_SHAPE_VEHICLE,
  83. RADAR_BLIP_SHAPE_STATIONARY,
  84. RADAR_BLIP_SHAPE_OBJECTIVE,
  85. RADAR_BLIP_COLOR_NOD = 0,
  86. RADAR_BLIP_COLOR_GDI,
  87. RADAR_BLIP_COLOR_NEUTRAL,
  88. RADAR_BLIP_COLOR_MUTANT,
  89. RADAR_BLIP_COLOR_RENEGADE,
  90. RADAR_BLIP_COLOR_PRIMARY_OBJECTIVE,
  91. RADAR_BLIP_COLOR_SECONDARY_OBJECTIVE,
  92. RADAR_BLIP_COLOR_TERTIARY_OBJECTIVE,
  93. SCRIPT_PLAYERTYPE_SPECTATOR = -4, // -4
  94. SCRIPT_PLAYERTYPE_MUTANT, // -3
  95. SCRIPT_PLAYERTYPE_NEUTRAL, // -2
  96. SCRIPT_PLAYERTYPE_RENEGADE, // -1
  97. SCRIPT_PLAYERTYPE_NOD, // 0
  98. SCRIPT_PLAYERTYPE_GDI, // 1
  99. };
  100. /*
  101. ** Script Commands List
  102. */
  103. #define SCRIPT_COMMANDS_VERSION 174
  104. typedef struct {
  105. unsigned int Size;
  106. unsigned int Version;
  107. // Debug messages
  108. void (* Debug_Message )( char *format, ... );
  109. // Action Commands
  110. void ( * Action_Reset )( GameObject * obj, float priority );
  111. void ( * Action_Goto )( GameObject * obj, const ActionParamsStruct & params );
  112. void ( * Action_Attack )( GameObject * obj, const ActionParamsStruct & params );
  113. void ( * Action_Play_Animation )( GameObject * obj, const ActionParamsStruct & params );
  114. void ( * Action_Enter_Exit )( GameObject * obj, const ActionParamsStruct & params );
  115. void ( * Action_Face_Location )( GameObject * obj, const ActionParamsStruct & params );
  116. void ( * Action_Dock )( GameObject * obj, const ActionParamsStruct & params );
  117. void ( * Action_Follow_Input )( GameObject * obj, const ActionParamsStruct & params );
  118. void ( * Modify_Action )( GameObject * obj, int action_id, const ActionParamsStruct & params, bool modify_move = true, bool modify_attack = true );
  119. // Action information queries
  120. int ( * Get_Action_ID )( GameObject * obj );
  121. bool ( * Get_Action_Params )( GameObject * obj, ActionParamsStruct & params );
  122. bool ( * Is_Performing_Pathfind_Action )( GameObject * obj );
  123. // Physical control
  124. void ( * Set_Position )( GameObject * obj, const Vector3 & position );
  125. Vector3 ( * Get_Position )( GameObject * obj );
  126. Vector3 ( * Get_Bone_Position )( GameObject * obj, const char * bone_name );
  127. float ( * Get_Facing )( GameObject * obj );
  128. void ( * Set_Facing )( GameObject * obj, float degrees );
  129. // Collision Control
  130. void ( * Disable_All_Collisions )( GameObject * obj );
  131. void ( * Disable_Physical_Collisions )( GameObject * obj );
  132. void ( * Enable_Collisions )( GameObject * obj );
  133. // Object Management
  134. void ( * Destroy_Object )( GameObject * obj );
  135. GameObject * ( * Find_Object )( int obj_id );
  136. GameObject * ( * Create_Object )( const char * type_name, const Vector3 & position );
  137. GameObject * ( * Create_Object_At_Bone )( GameObject * host_obj, const char * new_obj_type_name, const char * bone_name );
  138. int ( * Get_ID )( GameObject * obj );
  139. int ( * Get_Preset_ID )( GameObject * obj );
  140. const char * ( * Get_Preset_Name )( GameObject * obj );
  141. void (*Attach_Script)(GameObject* object, const char* scriptName, const char* scriptParams);
  142. void (*Add_To_Dirty_Cull_List)(GameObject* object);
  143. // Timers
  144. void ( * Start_Timer )( GameObject * obj, ScriptClass * script, float duration, int timer_id );
  145. // Weapons
  146. void ( * Trigger_Weapon )( GameObject * obj, bool trigger, const Vector3 & target, bool primary = true );
  147. void ( * Select_Weapon )( GameObject * obj, const char * weapon_name );
  148. // Custom Script
  149. void ( * Send_Custom_Event )( GameObject * from, GameObject * to, int type = 0, int param = 0, float delay = 0 );
  150. void ( * Send_Damaged_Event )( GameObject * object, GameObject * damager );
  151. // Random Numbers
  152. float ( * Get_Random )( float min, float max );
  153. int ( * Get_Random_Int )( int min, int max ); // Get a random number between min and max-1, INCLUSIVE
  154. // Random Selection
  155. GameObject * ( * Find_Random_Simple_Object )( const char *preset_name );
  156. // Object Display
  157. void ( * Set_Model )( GameObject * obj, const char * model_name );
  158. void ( * Set_Animation )( GameObject * obj, const char * anim_name, bool looping, const char * sub_obj_name = NULL, float start_frame = 0.0F, float end_frame = -1.0F, bool is_blended = false );
  159. void ( * Set_Animation_Frame )( GameObject * obj, const char * anim_name, int frame );
  160. // Sounds
  161. // Note: Each sound creation function returns the ID of the new sound (0 on error)
  162. int ( * Create_Sound )( const char * sound_preset_name, const Vector3 & position, GameObject * creator );
  163. int ( * Create_2D_Sound )( const char * sound_preset_name );
  164. int ( * Create_2D_WAV_Sound )( const char * wav_filename );
  165. int ( * Create_3D_WAV_Sound_At_Bone )( const char * wav_filename, GameObject * obj, const char * bone_name );
  166. int ( * Create_3D_Sound_At_Bone )( const char * sound_preset_name, GameObject * obj, const char * bone_name );
  167. int ( * Create_Logical_Sound )( GameObject * creator, int type, const Vector3 & position, float radius );
  168. void ( * Start_Sound )( int sound_id );
  169. void ( * Stop_Sound )( int sound_id, bool destroy_sound = true );
  170. void ( * Monitor_Sound )( GameObject * game_obj, int sound_id );
  171. void ( * Set_Background_Music )( const char * wav_filename );
  172. void ( * Fade_Background_Music )( const char * wav_filename, int fade_out_time, int fade_in_time );
  173. void ( * Stop_Background_Music )( void );
  174. // Object Properties
  175. float ( * Get_Health )( GameObject * obj );
  176. float ( * Get_Max_Health )( GameObject * obj );
  177. void ( * Set_Health )( GameObject * obj, float health );
  178. float ( * Get_Shield_Strength )( GameObject * obj );
  179. float ( * Get_Max_Shield_Strength )( GameObject * obj );
  180. void ( * Set_Shield_Strength )( GameObject * obj, float strength );
  181. void ( * Set_Shield_Type )( GameObject * obj, const char * name );
  182. int ( * Get_Player_Type )( GameObject * obj );
  183. void ( * Set_Player_Type )( GameObject * obj, int type );
  184. // Math
  185. float ( * Get_Distance )( const Vector3 & p1, const Vector3 & p2 );
  186. // Set Camera Host
  187. void ( * Set_Camera_Host )( GameObject * obj );
  188. void ( * Force_Camera_Look )( const Vector3 & target );
  189. // Get the Star
  190. GameObject * ( * Get_The_Star )( void );
  191. GameObject * ( * Get_A_Star )( const Vector3 & pos );
  192. GameObject * ( * Find_Closest_Soldier )( const Vector3 & pos, float min_dist, float max_dist, bool only_human = true );
  193. bool ( * Is_A_Star )( GameObject * obj );
  194. // Object Control
  195. void ( * Control_Enable )( GameObject * obj, bool enable );
  196. // Hack
  197. const char * ( * Get_Damage_Bone_Name )( void );
  198. bool ( * Get_Damage_Bone_Direction )( void ); // true means shot in the back
  199. // Visibility
  200. bool ( * Is_Object_Visible)( GameObject * looker, GameObject * obj );
  201. void ( * Enable_Enemy_Seen)( GameObject * obj, bool enable = true );
  202. // Display Text
  203. void (* Set_Display_Color )( unsigned char red = 255, unsigned char green = 255, unsigned char blue = 255 );
  204. void (* Display_Text )( int string_id );
  205. void (* Display_Float )( float value, const char * format = "%f" );
  206. void (* Display_Int )( int value, const char * format = "%d" );
  207. // SaveLoad
  208. void (* Save_Data )( ScriptSaver & saver, int id, int size, void * data );
  209. void (* Save_Pointer )( ScriptSaver & saver, int id, void * pointer );
  210. bool (* Load_Begin )( ScriptLoader & loader, int * id );
  211. void (* Load_Data )( ScriptLoader & loader, int size, void * data );
  212. void (* Load_Pointer )( ScriptLoader & loader, void ** pointer );
  213. void (* Load_End )( ScriptLoader & loader );
  214. void (*Begin_Chunk)(ScriptSaver& saver, unsigned int chunkID);
  215. void (*End_Chunk)(ScriptSaver& saver);
  216. bool (*Open_Chunk)(ScriptLoader& loader, unsigned int* chunkID);
  217. void (*Close_Chunk)(ScriptLoader& loader);
  218. // Radar Effects
  219. void (* Clear_Radar_Markers )( void );
  220. void (* Clear_Radar_Marker )( int id );
  221. void (* Add_Radar_Marker )( int id, const Vector3& position, int shape_type, int color_type );
  222. void (* Set_Obj_Radar_Blip_Shape )( GameObject * obj, int shape_type ); // Set to -1 to reset default
  223. void (* Set_Obj_Radar_Blip_Color )( GameObject * obj, int color_type ); // Set to -1 to reset default
  224. void (* Enable_Radar )( bool enable );
  225. //
  226. // Map support
  227. //
  228. void (* Clear_Map_Cell )( int cell_x, int cell_y );
  229. void (* Clear_Map_Cell_By_Pos )( const Vector3 &world_space_pos );
  230. void (* Clear_Map_Cell_By_Pixel_Pos )( int pixel_pos_x, int pixel_pos_y );
  231. void (* Clear_Map_Region_By_Pos )( const Vector3 &world_space_pos, int pixel_radius );
  232. void (* Reveal_Map )( void );
  233. void (* Shroud_Map )( void );
  234. void (* Show_Player_Map_Marker )( bool onoff );
  235. //
  236. // Height DB access
  237. //
  238. float (* Get_Safe_Flight_Height )( float x_pos, float y_pos );
  239. // Explosions
  240. void (* Create_Explosion )( const char * explosion_def_name, const Vector3 & pos, GameObject * creator = NULL );
  241. void (* Create_Explosion_At_Bone )( const char * explosion_def_name, GameObject * object, const char * bone_name, GameObject * creator = NULL );
  242. // HUD
  243. void (* Enable_HUD )( bool enable );
  244. void (* Mission_Complete )( bool success );
  245. void (* Give_PowerUp )( GameObject * obj, const char * preset_name, bool display_on_hud = false );
  246. // Administration
  247. void (*Innate_Disable)(GameObject* object);
  248. void (*Innate_Enable)(GameObject* object);
  249. // Innate Soldier AI Enable/Disable (returns old value)
  250. bool (* Innate_Soldier_Enable_Enemy_Seen )( GameObject * obj, bool state );
  251. bool (* Innate_Soldier_Enable_Gunshot_Heard )( GameObject * obj, bool state );
  252. bool (* Innate_Soldier_Enable_Footsteps_Heard )( GameObject * obj, bool state );
  253. bool (* Innate_Soldier_Enable_Bullet_Heard )( GameObject * obj, bool state );
  254. bool (* Innate_Soldier_Enable_Actions )( GameObject * obj, bool state );
  255. void (* Set_Innate_Soldier_Home_Location )( GameObject * obj, const Vector3& home_pos, float home_radius = 999999 );
  256. void (* Set_Innate_Aggressiveness )( GameObject * obj, float aggressiveness );
  257. void (* Set_Innate_Take_Cover_Probability )( GameObject * obj, float probability );
  258. void (* Set_Innate_Is_Stationary )( GameObject * obj, bool stationary );
  259. void (* Innate_Force_State_Bullet_Heard )( GameObject * obj, const Vector3 & pos );
  260. void (* Innate_Force_State_Footsteps_Heard )( GameObject * obj, const Vector3 & pos );
  261. void (* Innate_Force_State_Gunshots_Heard )( GameObject * obj, const Vector3 & pos );
  262. void (* Innate_Force_State_Enemy_Seen )( GameObject * obj, GameObject * enemy );
  263. // Control of StaticAnimPhys
  264. void (* Static_Anim_Phys_Goto_Frame )( int obj_id, float frame, const char * anim_name = NULL );
  265. void (* Static_Anim_Phys_Goto_Last_Frame )( int obj_id, const char * anim_name = NULL );
  266. // Timing
  267. unsigned int (* Get_Sync_Time)( void );
  268. // Objectives
  269. void (* Add_Objective)( int id, int type, int status, int short_description_id, char * description_sound_filename = NULL, int long_description_id = 0 );
  270. void (* Remove_Objective)( int id );
  271. void (* Set_Objective_Status)( int id, int status );
  272. void (* Change_Objective_Type)( int id, int type );
  273. void (* Set_Objective_Radar_Blip)( int id, const Vector3 & position );
  274. void (* Set_Objective_Radar_Blip_Object)( int id, ScriptableGameObj * unit );
  275. void (* Set_Objective_HUD_Info)( int id, float priority, const char * texture_name, int message_id );
  276. void (* Set_Objective_HUD_Info_Position)( int id, float priority, const char * texture_name, int message_id, const Vector3 & position );
  277. // Camaera Shakes
  278. void (* Shake_Camera)( const Vector3 & pos, float radius = 25, float intensity = 0.25f, float duration = 1.5f );
  279. // Spawners
  280. void (* Enable_Spawner)( int id, bool enable );
  281. GameObject * (* Trigger_Spawner)( int id );
  282. // Vehicles
  283. void (* Enable_Engine)( GameObject* object, bool onoff );
  284. // Difficulty Level
  285. int (* Get_Difficulty_Level)( void );
  286. // Keys
  287. void (* Grant_Key)( GameObject* object, int key, bool grant = true );
  288. bool (* Has_Key)( GameObject* object, int key );
  289. // Hibernation
  290. void (* Enable_Hibernation)( GameObject * object, bool enable );
  291. void (* Attach_To_Object_Bone)( GameObject * object, GameObject * host_object, const char * bone_name );
  292. // Conversation
  293. int (* Create_Conversation)( const char *conversation_name, int priority = 0, float max_dist = 0, bool is_interruptable = true );
  294. void (* Join_Conversation)( GameObject * object, int active_conversation_id, bool allow_move = true, bool allow_head_turn = true, bool allow_face = true );
  295. void (* Join_Conversation_Facing)( GameObject * object, int active_conversation_id, int obj_id_to_face );
  296. void (* Start_Conversation)( int active_conversation_id, int action_id = 0 );
  297. void (* Monitor_Conversation)( GameObject * object, int active_conversation_id );
  298. void (* Start_Random_Conversation)( GameObject * object );
  299. void (* Stop_Conversation)( int active_conversation_id );
  300. void (* Stop_All_Conversations)( void );
  301. // Locked facing support
  302. void (* Lock_Soldier_Facing)( GameObject * object, GameObject * object_to_face, bool turn_body );
  303. void (* Unlock_Soldier_Facing)( GameObject * object );
  304. // Apply Damage
  305. void (* Apply_Damage)( GameObject * object, float amount, const char * warhead_name, GameObject * damager = NULL );
  306. // Soldier
  307. void (* Set_Loiters_Allowed)( GameObject * object, bool allowed );
  308. void (* Set_Is_Visible)( GameObject * object, bool visible );
  309. void (* Set_Is_Rendered)( GameObject * object, bool rendered );
  310. // Points
  311. float (* Get_Points)( GameObject * object );
  312. void (* Give_Points)( GameObject * object, float points, bool entire_team );
  313. // Money (points and money were separated 09/06/01)
  314. float (* Get_Money)( GameObject * object );
  315. void (* Give_Money)( GameObject * object, float money, bool entire_team );
  316. // Buildings
  317. bool (* Get_Building_Power)( GameObject * object );
  318. void (* Set_Building_Power)( GameObject * object, bool onoff );
  319. void (* Play_Building_Announcement)( GameObject * object, int text_id );
  320. GameObject * (* Find_Nearest_Building_To_Pos )( const Vector3 & position, const char * mesh_prefix );
  321. GameObject * (* Find_Nearest_Building )( GameObject * object, const char * mesh_prefix );
  322. // Zones
  323. int (* Team_Members_In_Zone)( GameObject * object, int player_type );
  324. // Background
  325. void (*Set_Clouds) (float cloudcover, float cloudgloominess, float ramptime);
  326. void (*Set_Lightning) (float intensity, float startdistance, float enddistance, float heading, float distribution, float ramptime);
  327. void (*Set_War_Blitz) (float intensity, float startdistance, float enddistance, float heading, float distribution, float ramptime);
  328. // Weather
  329. void (*Set_Wind) (float heading, float speed, float variability, float ramptime);
  330. void (*Set_Rain) (float density, float ramptime, bool prime);
  331. void (*Set_Snow) (float density, float ramptime, bool prime);
  332. void (*Set_Ash) (float density, float ramptime, bool prime);
  333. void (*Set_Fog_Enable) (bool enabled);
  334. void (*Set_Fog_Range) (float startdistance, float enddistance, float ramptime);
  335. // Stealth control
  336. void (*Enable_Stealth) (GameObject * object, bool onoff);
  337. // Sniper control
  338. void (*Cinematic_Sniper_Control) (bool enabled, float zoom);
  339. // File Access
  340. int (*Text_File_Open) ( const char * filename );
  341. bool (*Text_File_Get_String) ( int handle, char * buffer, int size );
  342. void (*Text_File_Close) ( int handle );
  343. // Vehicle Transitions
  344. void (*Enable_Vehicle_Transitions) ( GameObject * object, bool enable );
  345. // Player terminal support
  346. void (*Display_GDI_Player_Terminal) ();
  347. void (*Display_NOD_Player_Terminal) ();
  348. void (*Display_Mutant_Player_Terminal) ();
  349. // Encyclopedia support
  350. bool (*Reveal_Encyclopedia_Character) ( int object_id );
  351. bool (*Reveal_Encyclopedia_Weapon) ( int object_id );
  352. bool (*Reveal_Encyclopedia_Vehicle) ( int object_id );
  353. bool (*Reveal_Encyclopedia_Building) ( int object_id );
  354. void (*Display_Encyclopedia_Event_UI) ( void );
  355. void (* Scale_AI_Awareness)( float sight_scale, float hearing_scale );
  356. // Cinematic Freeze
  357. void (* Enable_Cinematic_Freeze)( GameObject * object, bool enable );
  358. void (* Expire_Powerup )( GameObject * object );
  359. // Hud stuff
  360. void (* Set_HUD_Help_Text )( int string_id, const Vector3 &color );
  361. void (* Enable_HUD_Pokable_Indicator )( GameObject * object, bool enable );
  362. void (* Enable_Innate_Conversations )( GameObject * object, bool enable );
  363. void (* Display_Health_Bar )( GameObject * object, bool display );
  364. // Shadow control. In certain cases we need to manually disable shadow casting
  365. // on an object. Cinematics with too many characters are an example of this.
  366. void (* Enable_Shadow) ( GameObject * object, bool enable );
  367. void (* Clear_Weapons) ( GameObject * object );
  368. void (* Set_Num_Tertiary_Objectives) ( int count );
  369. // Letterbox and screen fading controls
  370. void (* Enable_Letterbox) ( bool onoff, float seconds );
  371. void (* Set_Screen_Fade_Color) ( float r, float g, float b, float seconds );
  372. void (* Set_Screen_Fade_Opacity) ( float opacity, float seconds );
  373. } ScriptCommands;
  374. /*
  375. ** Build a class to wrap the struct
  376. */
  377. class ScriptCommandsClass {
  378. public:
  379. ScriptCommands *Commands;
  380. };
  381. /*
  382. ** Get Script Commands
  383. ** This should only be called in the host application
  384. ** and not from the DLL
  385. */
  386. ScriptCommands *Get_Script_Commands( void );
  387. #endif // SCRIPTCOMMANDS_H