Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
5.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef NPCEVENT_H
  8. #define NPCEVENT_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "eventlist.h"
  13. class CBaseAnimating;
  14. struct animevent_t
  15. {
  16. #ifdef CLIENT_DLL
  17. // see mstudioevent_for_client_server_t comment below
  18. union
  19. {
  20. unsigned short _event_highword;
  21. unsigned short event_newsystem;
  22. };
  23. unsigned short _event_lowword;
  24. #else
  25. // see mstudioevent_for_client_server_t comment below
  26. unsigned short _event_highword;
  27. union
  28. {
  29. unsigned short _event_lowword;
  30. unsigned short event_newsystem;
  31. };
  32. #endif
  33. const char *options;
  34. float cycle;
  35. float eventtime;
  36. int type;
  37. CBaseAnimating *pSource;
  38. bool m_bHandledByScript;
  39. // see mstudioevent_for_client_server_t comment below
  40. int Event_OldSystem( void ) const { return *static_cast< const int* >( static_cast< const void* >( &_event_highword ) ); }
  41. void Event_OldSystem( int nEvent ) { *static_cast< int* >( static_cast< void* >( &_event_highword ) ) = nEvent; }
  42. int Event( void ) const
  43. {
  44. if ( type & AE_TYPE_NEWEVENTSYSTEM )
  45. return event_newsystem;
  46. return Event_OldSystem();
  47. }
  48. void Event( int nEvent )
  49. {
  50. if ( type & AE_TYPE_NEWEVENTSYSTEM )
  51. {
  52. event_newsystem = nEvent;
  53. }
  54. else
  55. {
  56. Event_OldSystem( nEvent );
  57. }
  58. }
  59. };
  60. #define EVENT_SPECIFIC 0
  61. #define EVENT_SCRIPTED 1000 // see scriptevent.h
  62. #define EVENT_SHARED 2000
  63. #define EVENT_WEAPON 3000
  64. #define EVENT_CLIENT 5000
  65. #define NPC_EVENT_BODYDROP_LIGHT 2001
  66. #define NPC_EVENT_BODYDROP_HEAVY 2002
  67. #define NPC_EVENT_SWISHSOUND 2010
  68. #define NPC_EVENT_180TURN 2020
  69. #define NPC_EVENT_ITEM_PICKUP 2040
  70. #define NPC_EVENT_WEAPON_DROP 2041
  71. #define NPC_EVENT_WEAPON_SET_SEQUENCE_NAME 2042
  72. #define NPC_EVENT_WEAPON_SET_SEQUENCE_NUMBER 2043
  73. #define NPC_EVENT_WEAPON_SET_ACTIVITY 2044
  74. #define NPC_EVENT_LEFTFOOT 2050
  75. #define NPC_EVENT_RIGHTFOOT 2051
  76. #define NPC_EVENT_OPEN_DOOR 2060
  77. // !! DON'T CHANGE TO ORDER OF THESE. THEY ARE HARD CODED IN THE WEAPON QC FILES (YUCK!) !!
  78. #define EVENT_WEAPON_MELEE_HIT 3001
  79. #define EVENT_WEAPON_SMG1 3002
  80. #define EVENT_WEAPON_MELEE_SWISH 3003
  81. #define EVENT_WEAPON_SHOTGUN_FIRE 3004
  82. #define EVENT_WEAPON_THROW 3005
  83. #define EVENT_WEAPON_AR1 3006
  84. #define EVENT_WEAPON_AR2 3007
  85. #define EVENT_WEAPON_HMG1 3008
  86. #define EVENT_WEAPON_SMG2 3009
  87. #define EVENT_WEAPON_MISSILE_FIRE 3010
  88. #define EVENT_WEAPON_SNIPER_RIFLE_FIRE 3011
  89. #define EVENT_WEAPON_AR2_GRENADE 3012
  90. #define EVENT_WEAPON_THROW2 3013
  91. #define EVENT_WEAPON_PISTOL_FIRE 3014
  92. #define EVENT_WEAPON_RELOAD 3015
  93. #define EVENT_WEAPON_THROW3 3016
  94. #define EVENT_WEAPON_RELOAD_SOUND 3017 // Use this + EVENT_WEAPON_RELOAD_FILL_CLIP to prevent shooting during the reload animation
  95. #define EVENT_WEAPON_RELOAD_FILL_CLIP 3018
  96. #define EVENT_WEAPON_SMG1_BURST1 3101 // first round in a 3-round burst
  97. #define EVENT_WEAPON_SMG1_BURSTN 3102 // 2, 3 rounds
  98. #define EVENT_WEAPON_AR2_ALTFIRE 3103
  99. #define EVENT_WEAPON_SEQUENCE_FINISHED 3900
  100. // NOTE: MUST BE THE LAST WEAPON EVENT -- ONLY WEAPON EVENTS BETWEEN EVENT_WEAPON AND THIS
  101. #define EVENT_WEAPON_LAST 3999
  102. // Because the client and server have a shared memory space for event data,
  103. // but use different indexes for the event (servers cache them all upfront,
  104. // while client creates them as sequences fire) we're going to store the server
  105. // index in the low word and the client index in the high word.
  106. //
  107. // studio.h is a public header, so we'll use this matching struct to do the
  108. // conversion and not force us to macro all the code that checks the event member.
  109. // This struct's data MUST match mstudioevent_t
  110. //
  111. // BUT events that use the old event system use the entire dword which will always
  112. // match between client and server. Instead of wrapping everything in if checks,
  113. // for ( type & AE_TYPE_NEWEVENTSYSTEM ) we use the Event accessors to set/get
  114. // while doing the check under the hood.
  115. //
  116. // -Jeep
  117. struct mstudioevent_for_client_server_t
  118. {
  119. DECLARE_BYTESWAP_DATADESC();
  120. float cycle;
  121. #ifdef CLIENT_DLL
  122. union
  123. {
  124. // Client shares with the high word
  125. unsigned short _event_highword;
  126. unsigned short event_newsystem;
  127. };
  128. unsigned short _event_lowword; // Placeholder for the low word
  129. #else
  130. unsigned short _event_highword; // Placeholder for the high word
  131. union
  132. {
  133. // Server shares with the low word
  134. unsigned short _event_lowword;
  135. unsigned short event_newsystem;
  136. };
  137. #endif
  138. int type;
  139. inline const char * pszOptions( void ) const { return options; }
  140. char options[64];
  141. int szeventindex;
  142. inline char * const pszEventName( void ) const { return ((char *)this) + szeventindex; }
  143. // For setting and getting through Event, check the AE_TYPE_NEWEVENTSYSTEM flag to decide
  144. // if we should set/get just the short used by the client/server or use the whole int.
  145. int Event_OldSystem( void ) const { return *static_cast< const int* >( static_cast< const void* >( &_event_highword ) ); }
  146. void Event_OldSystem( int nEvent ) { *static_cast< int* >( static_cast< void* >( &_event_highword ) ) = nEvent; }
  147. int Event( void ) const
  148. {
  149. if ( type & AE_TYPE_NEWEVENTSYSTEM )
  150. return event_newsystem;
  151. return Event_OldSystem();
  152. }
  153. void Event( int nEvent )
  154. {
  155. if ( type & AE_TYPE_NEWEVENTSYSTEM )
  156. {
  157. event_newsystem = nEvent;
  158. }
  159. else
  160. {
  161. Event_OldSystem( nEvent );
  162. }
  163. }
  164. };
  165. #define mstudioevent_t mstudioevent_for_client_server_t
  166. #endif // NPCEVENT_H