Team Fortress 2 Source Code as on 22/4/2020
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.

405 lines
13 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef TFC_MAPITEMS_H
  7. #define TFC_MAPITEMS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tfc_shareddefs.h"
  12. class CTFCPlayer;
  13. /*==================================================*/
  14. /* CTF Support defines */
  15. /*==================================================*/
  16. #define CTF_FLAG1 1
  17. #define CTF_FLAG2 2
  18. #define CTF_DROPOFF1 3
  19. #define CTF_DROPOFF2 4
  20. #define CTF_SCORE1 5
  21. #define CTF_SCORE2 6
  22. // Defines for GoalItem Removing from Player Methods
  23. #define GI_DROP_PLAYERDEATH 0 // Dropped by a dying player
  24. #define GI_DROP_REMOVEGOAL 1 // Removed by a Goal
  25. #define GI_DROP_PLAYERDROP 2 // Dropped by a player
  26. // Defines for methods of GoalItem returning
  27. #define GI_RET_DROP_DEAD 0 // Dropped by a dead player
  28. #define GI_RET_DROP_LIVING 1 // Dropped by a living player
  29. #define GI_RET_GOAL 2 // Returned by a Goal
  30. #define GI_RET_TIME 3 // Returned due to timeout
  31. // Defines for Goal States
  32. #define TFGS_ACTIVE 1
  33. #define TFGS_INACTIVE 2
  34. #define TFGS_REMOVED 3
  35. #define TFGS_DELAYED 4
  36. // Defines for Goal Result types : goal_result
  37. #define TFGR_SINGLE 1 // Goal can only be activated once
  38. #define TFGR_ADD_BONUSES 2 // Any Goals activated by this one give their bonuses
  39. #define TFGR_ENDGAME 4 // Goal fires Intermission, displays scores, and ends level
  40. #define TFGR_NO_ITEM_RESULTS 8 // GoalItems given by this Goal don't do results
  41. #define TFGR_REMOVE_DISGUISE 16 // Prevent/Remove undercover from any Spy
  42. #define TFGR_FORCE_RESPAWN 32 // Forces the player to teleport to a respawn point
  43. #define TFGR_DESTROY_BUILDINGS 64 // Destroys this player's buildings, if anys
  44. // Defines for Goal Item types, : goal_activation (in items)
  45. #define TFGI_GLOW 1 // Players carrying this GoalItem will glow
  46. #define TFGI_SLOW 2 // Players carrying this GoalItem will move at half-speed
  47. #define TFGI_DROP 4 // Players dying with this item will drop it
  48. #define TFGI_RETURN_DROP 8 // Return if a player with it dies
  49. #define TFGI_RETURN_GOAL 16 // Return if a player with it has it removed by a goal's activation
  50. #define TFGI_RETURN_REMOVE 32 // Return if it is removed by TFGI_REMOVE
  51. #define TFGI_REVERSE_AP 64 // Only pickup if the player _doesn't_ match AP Details
  52. #define TFGI_REMOVE 128 // Remove if left untouched for 2 minutes after being dropped
  53. #define TFGI_KEEP 256 // Players keep this item even when they die
  54. #define TFGI_ITEMGLOWS 512 // Item glows when on the ground
  55. #define TFGI_DONTREMOVERES 1024 // Don't remove results when the item is removed
  56. #define TFGI_DROPTOGROUND 2048 // Drop To Ground when spawning
  57. #define TFGI_CANBEDROPPED 4096 // Can be voluntarily dropped by players
  58. #define TFGI_SOLID 8192 // Is solid... blocks bullets, etc
  59. // For all these defines, see the tfortmap.txt that came with the zip
  60. // for complete descriptions.
  61. // Defines for Goal Activation types : goal_activation (in goals)
  62. #define TFGA_TOUCH 1 // Activated when touched
  63. #define TFGA_TOUCH_DETPACK 2 // Activated when touched by a detpack explosion
  64. #define TFGA_REVERSE_AP 4 // Activated when AP details are _not_ met
  65. #define TFGA_SPANNER 8 // Activated when hit by an engineer's spanner
  66. #define TFGA_DROPTOGROUND 2048 // Drop to Ground when spawning
  67. // Defines for Goal Effects types : goal_effect
  68. #define TFGE_AP 1 // AP is affected. Default.
  69. #define TFGE_AP_TEAM 2 // All of the AP's team.
  70. #define TFGE_NOT_AP_TEAM 4 // All except AP's team.
  71. #define TFGE_NOT_AP 8 // All except AP.
  72. #define TFGE_WALL 16 // If set, walls stop the Radius effects
  73. #define TFGE_SAME_ENVIRONMENT 32 // If set, players in a different environment to the Goal are not affected
  74. #define TFGE_TIMER_CHECK_AP 64 // If set, Timer Goals check their critera for all players fitting their effects
  75. class CTFBaseItem : public CBaseAnimating
  76. {
  77. public:
  78. bool CheckExistence();
  79. public:
  80. int group_no;
  81. int goal_no;
  82. int goal_state; // TFGS_
  83. // Goal/Timer/GoalItem/Trigger existence checking
  84. int ex_skill_min; // Exists when the skill is >= this value
  85. int ex_skill_max; // Exists when the skill is <= this value
  86. string_t teamcheck; // TeamCheck entity that should be checked
  87. };
  88. class CTFGoal : public CTFBaseItem
  89. {
  90. public:
  91. DECLARE_CLASS( CTFGoal, CBaseAnimating );
  92. DECLARE_DATADESC();
  93. void Spawn( void );
  94. void StartGoal( void );
  95. void PlaceGoal( void );
  96. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  97. void tfgoal_touch( CBaseEntity *pOther );
  98. void DelayedResult();
  99. Class_T Classify ( void ) { return CLASS_TFGOAL; }
  100. void SetObjectCollisionBox( void );
  101. void tfgoal_timer_tick();
  102. void DoRespawn();
  103. public:
  104. //TFCTODO: lots of these variables need to be put in the FGD file.
  105. int goal_effects; // TFGE_
  106. int goal_result; // TFGR_
  107. int playerclass; // One of the PC_ defines.
  108. float t_length; // Goal Criteria radius check
  109. // NOTE: In CTFGoal, these are overridden to mean: if they're not zero, then this goal only
  110. // affects players...
  111. int maxammo_shells; // ... with that team number
  112. int maxammo_nails; // ... without that team number
  113. int ammo_shells;
  114. int ammo_nails;
  115. int ammo_rockets;
  116. int ammo_cells;
  117. int ammo_medikit;
  118. int ammo_detpack;
  119. int no_grenades_1;
  120. int no_grenades_2;
  121. // Replacement_Model Stuff
  122. string_t replacement_model;
  123. int replacement_model_body;
  124. int replacement_model_skin;
  125. int replacement_model_flags;
  126. // Item Displaying details
  127. int display_item_status[4]; // Goal displays the status of these items
  128. string_t team_str_home; // Displayed when the item is at home base
  129. string_t team_str_moved; // Displayed when the item has been moved
  130. string_t team_str_carried; // Displayed when the item is being carried
  131. string_t non_team_str_home; // Displayed when the item is at home base
  132. string_t non_team_str_moved; // Displayed when the item has been moved
  133. string_t non_team_str_carried; // Displayed when the item is being carried
  134. float invincible_finished;
  135. float invisible_finished;
  136. float super_damage_finished;
  137. float radsuit_finished;
  138. int lives;
  139. int frags;
  140. float wait;
  141. float search_time; // Timer goal delay
  142. int item_list; // Used to keep track of which goalitems are
  143. // affecting the player at any time.
  144. // GoalItems use it to keep track of their own
  145. // mask to apply to a player's item_list
  146. float drop_time; // Time spent untouched before item return
  147. float armortype;
  148. int armorvalue;
  149. int armorclass; // Type of armor being worn;
  150. int count; // Change teamscores
  151. // Goal Size
  152. Vector goal_min;
  153. Vector goal_max;
  154. bool m_bAddBonuses;
  155. int items;
  156. int items_allowed;
  157. int else_goal;
  158. int if_goal_is_active;
  159. int if_goal_is_inactive;
  160. int if_goal_is_removed;
  161. int if_group_is_active;
  162. int if_group_is_inactive;
  163. int if_group_is_removed;
  164. int speed_reduction;
  165. int return_item_no;
  166. int if_item_has_moved;
  167. int if_item_hasnt_moved;
  168. int has_item_from_group;
  169. int hasnt_item_from_group;
  170. int goal_activation;
  171. int delay_time;
  172. int weapon;
  173. string_t owned_by_teamcheck;
  174. int owned_by;
  175. string_t noise;
  176. // Spawnpoint behaviour
  177. int remove_spawnpoint;
  178. int restore_spawnpoint;
  179. int remove_spawngroup;
  180. int restore_spawngroup;
  181. // These are the old centerprinting methods.
  182. // They now print using the large fancy text
  183. string_t broadcast; // Centerprinted to all, overridden by the next two
  184. string_t team_broadcast; // Centerprinted to AP's team members, but not the AP
  185. string_t non_team_broadcast; // Centerprinted to non AP's team members
  186. string_t owners_team_broadcast; // Centerprinted to the members of the team that own the Goal/Item
  187. string_t non_owners_team_broadcast; // Centerprinted to the members of the team that don't own the Goal/Item
  188. string_t team_drop; // Centerprinted to item owners team
  189. string_t non_team_drop; // Centerprinted to everone not on item owners team
  190. // These are new fields that print the old fashioned centerprint method
  191. string_t org_broadcast; // Centerprinted to all, overridden by the next two
  192. string_t org_team_broadcast; // Centerprinted to AP's team members, but not the AP
  193. string_t org_non_team_broadcast; // Centerprinted to non AP's team members
  194. string_t org_owners_team_broadcast; // Centerprinted to the members of the team that own the Goal/Item
  195. string_t org_non_owners_team_broadcast; // Centerprinted to the members of the team that don't own the Goal/Item
  196. string_t org_team_drop; // Centerprinted to item owners team
  197. string_t org_non_team_drop; // Centerprinted to everone not on item owners team
  198. string_t org_message; // Centerprinted to the AP upon activation
  199. string_t org_noise3;
  200. string_t org_noise4;
  201. // These still print the old centerprint fashion
  202. string_t netname_broadcast; // same as above, prepended by AP netname and bprinted
  203. string_t netname_team_broadcast; // same as above, prepended by AP netname and bprinted
  204. string_t netname_non_team_broadcast; // same as above, prepended by AP netname and bprinted
  205. string_t netname_owners_team_broadcast; // same as above, prepended by AP netname and bprinted
  206. string_t netname_team_drop; // same as above, prepended by AP netname and bprinted
  207. string_t netname_non_team_drop; // same as above, prepended by AP netname and bprinted
  208. string_t speak; // VOX Spoken to Everyone
  209. string_t AP_speak; // VOX Spoken the AP
  210. string_t team_speak; // VOX Spoken to AP's team_members, including the AP
  211. string_t non_team_speak; // VOX Spoken to non AP's team_members
  212. string_t owners_team_speak; // VOX Spoken to members of the team that own this Goal
  213. string_t non_owners_team_speak; // VOX Spoken to everyone bit the members of the team that own this Goal
  214. float m_flEndRoundTime;
  215. string_t m_iszEndRoundMsg_Team1_Win;
  216. string_t m_iszEndRoundMsg_Team2_Win;
  217. string_t m_iszEndRoundMsg_Team3_Win;
  218. string_t m_iszEndRoundMsg_Team4_Win;
  219. string_t m_iszEndRoundMsg_Team1_Lose;
  220. string_t m_iszEndRoundMsg_Team2_Lose;
  221. string_t m_iszEndRoundMsg_Team3_Lose;
  222. string_t m_iszEndRoundMsg_Team4_Lose;
  223. string_t m_iszEndRoundMsg_Team1;
  224. string_t m_iszEndRoundMsg_Team2;
  225. string_t m_iszEndRoundMsg_Team3;
  226. string_t m_iszEndRoundMsg_Team4;
  227. string_t m_iszEndRoundMsg_OwnedBy;
  228. string_t m_iszEndRoundMsg_NonOwnedBy;
  229. int all_active;
  230. int last_impulse; // The previous impulse command from this player
  231. int activate_goal_no;
  232. int inactivate_goal_no;
  233. int remove_goal_no;
  234. int restore_goal_no;
  235. int activate_group_no;
  236. int inactivate_group_no;
  237. int remove_group_no;
  238. int restore_group_no;
  239. BOOL do_triggerwork; // Overrides for trigger handling in TF Goals
  240. string_t killtarget; // Remove ents with this target
  241. string_t target;
  242. string_t message;
  243. // Score increases
  244. int increase_team[4]; // Increase the scores of teams
  245. int increase_team_owned_by; // Increase the score of the team that owns this entity
  246. EHANDLE enemy;
  247. Vector oldorigin;
  248. int axhitme; // Remove item from AP
  249. int remove_item_group;
  250. };
  251. class CTFGoalItem : public CTFGoal
  252. {
  253. public:
  254. void Spawn( void );
  255. void StartItem( void );
  256. void PlaceItem( void );
  257. Class_T Classify ( void ) { return CLASS_TFGOAL_ITEM; }
  258. void item_tfgoal_touch( CBaseEntity *pOther );
  259. void tfgoalitem_droptouch();
  260. void tfgoalitem_dropthink();
  261. void tfgoalitem_remove();
  262. void DoDrop( Vector vecOrigin );
  263. public:
  264. float m_flDroppedAt;
  265. float speed;
  266. int speed_reduction;
  267. float distance;
  268. float pain_finished;
  269. float attack_finished;
  270. Vector redrop_origin; // Original drop position
  271. int redrop_count; // Number of time's we redropped.
  272. };
  273. class CTFTimerGoal : public CTFGoal
  274. {
  275. public:
  276. void Spawn( void );
  277. Class_T Classify ( void ) { return CLASS_TFGOAL_TIMER; }
  278. };
  279. class CTFSpawn : public CTFBaseItem
  280. {
  281. public:
  282. void Spawn( void );
  283. void Activate( void );
  284. Class_T Classify ( void ) { return CLASS_TFSPAWN; }
  285. BOOL CheckTeam( int iTeamNo );
  286. EHANDLE m_pTeamCheck;
  287. };
  288. class CBaseDelay : public CTFGoal
  289. {
  290. public:
  291. DECLARE_CLASS( CBaseDelay, CTFGoal );
  292. void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value );
  293. void KeyValue( KeyValueData *pkvd );
  294. void DelayThink( void );
  295. virtual bool KeyValue( const char *szKeyName, const char *szValue );
  296. public:
  297. float m_flDelay;
  298. string_t m_iszKillTarget;
  299. int button;
  300. };
  301. class CTeamCheck : public CBaseDelay
  302. {
  303. public:
  304. void Spawn( void );
  305. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  306. BOOL TeamMatches( int iTeam );
  307. };
  308. // Global functions.
  309. CTFGoalItem* Finditem(int ino);
  310. void DisplayItemStatus(CTFGoal *Goal, CTFCPlayer *Player, CTFGoalItem *Item);
  311. #endif // TFC_MAPITEMS_H