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.

402 lines
12 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_MAPITEMS_H
  7. #define TF_MAPITEMS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tf_shareddefs.h"
  12. class CTFPlayer;
  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. #if 0
  76. class CTFBaseItem : public CBaseAnimating
  77. {
  78. public:
  79. bool CheckExistence();
  80. public:
  81. int group_no;
  82. int goal_no;
  83. int goal_state; // TFGS_
  84. // Goal/Timer/GoalItem/Trigger existence checking
  85. int ex_skill_min; // Exists when the skill is >= this value
  86. int ex_skill_max; // Exists when the skill is <= this value
  87. string_t teamcheck; // TeamCheck entity that should be checked
  88. };
  89. class CTFGoal : public CTFBaseItem
  90. {
  91. public:
  92. DECLARE_CLASS( CTFGoal, CBaseAnimating );
  93. DECLARE_DATADESC();
  94. void Spawn( void );
  95. void StartGoal( void );
  96. void PlaceGoal( void );
  97. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  98. void tfgoal_touch( CBaseEntity *pOther );
  99. void DelayedResult();
  100. Class_T Classify ( void ) { return CLASS_TFGOAL; }
  101. void SetObjectCollisionBox( void );
  102. void tfgoal_timer_tick();
  103. void DoRespawn();
  104. public:
  105. //TFTODO: lots of these variables need to be put in the FGD file.
  106. int goal_effects; // TFGE_
  107. int goal_result; // TFGR_
  108. int playerclass; // One of the PC_ defines.
  109. float t_length; // Goal Criteria radius check
  110. // NOTE: In CTFGoal, these are overridden to mean: if they're not zero, then this goal only
  111. // affects players...
  112. int maxammo_shells; // ... with that team number
  113. int maxammo_nails; // ... without that team number
  114. int ammo_shells;
  115. int ammo_nails;
  116. int ammo_rockets;
  117. int ammo_cells;
  118. int ammo_medikit;
  119. int ammo_detpack;
  120. int no_grenades_1;
  121. int no_grenades_2;
  122. // Item Displaying details
  123. int display_item_status[4]; // Goal displays the status of these items
  124. string_t team_str_home; // Displayed when the item is at home base
  125. string_t team_str_moved; // Displayed when the item has been moved
  126. string_t team_str_carried; // Displayed when the item is being carried
  127. string_t non_team_str_home; // Displayed when the item is at home base
  128. string_t non_team_str_moved; // Displayed when the item has been moved
  129. string_t non_team_str_carried; // Displayed when the item is being carried
  130. float invincible_finished;
  131. float invisible_finished;
  132. float super_damage_finished;
  133. float radsuit_finished;
  134. int lives;
  135. int frags;
  136. float wait;
  137. float search_time; // Timer goal delay
  138. int item_list; // Used to keep track of which goalitems are
  139. // affecting the player at any time.
  140. // GoalItems use it to keep track of their own
  141. // mask to apply to a player's item_list
  142. float drop_time; // Time spent untouched before item return
  143. float armortype;
  144. int armorvalue;
  145. int armorclass; // Type of armor being worn;
  146. int count; // Change teamscores
  147. // Goal Size
  148. Vector goal_min;
  149. Vector goal_max;
  150. bool m_bAddBonuses;
  151. int items;
  152. int items_allowed;
  153. int else_goal;
  154. int if_goal_is_active;
  155. int if_goal_is_inactive;
  156. int if_goal_is_removed;
  157. int if_group_is_active;
  158. int if_group_is_inactive;
  159. int if_group_is_removed;
  160. int speed_reduction;
  161. int return_item_no;
  162. int if_item_has_moved;
  163. int if_item_hasnt_moved;
  164. int has_item_from_group;
  165. int hasnt_item_from_group;
  166. int goal_activation;
  167. int delay_time;
  168. int weapon;
  169. string_t owned_by_teamcheck;
  170. int owned_by;
  171. string_t noise;
  172. // Spawnpoint behaviour
  173. int remove_spawnpoint;
  174. int restore_spawnpoint;
  175. int remove_spawngroup;
  176. int restore_spawngroup;
  177. // These are the old centerprinting methods.
  178. // They now print using the large fancy text
  179. string_t broadcast; // Centerprinted to all, overridden by the next two
  180. string_t team_broadcast; // Centerprinted to AP's team members, but not the AP
  181. string_t non_team_broadcast; // Centerprinted to non AP's team members
  182. string_t owners_team_broadcast; // Centerprinted to the members of the team that own the Goal/Item
  183. string_t non_owners_team_broadcast; // Centerprinted to the members of the team that don't own the Goal/Item
  184. string_t team_drop; // Centerprinted to item owners team
  185. string_t non_team_drop; // Centerprinted to everone not on item owners team
  186. // These are new fields that print the old fashioned centerprint method
  187. string_t org_broadcast; // Centerprinted to all, overridden by the next two
  188. string_t org_team_broadcast; // Centerprinted to AP's team members, but not the AP
  189. string_t org_non_team_broadcast; // Centerprinted to non AP's team members
  190. string_t org_owners_team_broadcast; // Centerprinted to the members of the team that own the Goal/Item
  191. string_t org_non_owners_team_broadcast; // Centerprinted to the members of the team that don't own the Goal/Item
  192. string_t org_team_drop; // Centerprinted to item owners team
  193. string_t org_non_team_drop; // Centerprinted to everone not on item owners team
  194. string_t org_message; // Centerprinted to the AP upon activation
  195. string_t org_noise3;
  196. string_t org_noise4;
  197. // These still print the old centerprint fashion
  198. string_t netname_broadcast; // same as above, prepended by AP netname and bprinted
  199. string_t netname_team_broadcast; // same as above, prepended by AP netname and bprinted
  200. string_t netname_non_team_broadcast; // same as above, prepended by AP netname and bprinted
  201. string_t netname_owners_team_broadcast; // same as above, prepended by AP netname and bprinted
  202. string_t netname_team_drop; // same as above, prepended by AP netname and bprinted
  203. string_t netname_non_team_drop; // same as above, prepended by AP netname and bprinted
  204. string_t speak; // VOX Spoken to Everyone
  205. string_t AP_speak; // VOX Spoken the AP
  206. string_t team_speak; // VOX Spoken to AP's team_members, including the AP
  207. string_t non_team_speak; // VOX Spoken to non AP's team_members
  208. string_t owners_team_speak; // VOX Spoken to members of the team that own this Goal
  209. string_t non_owners_team_speak; // VOX Spoken to everyone bit the members of the team that own this Goal
  210. float m_flEndRoundTime;
  211. string_t m_iszEndRoundMsg_Team1_Win;
  212. string_t m_iszEndRoundMsg_Team2_Win;
  213. string_t m_iszEndRoundMsg_Team3_Win;
  214. string_t m_iszEndRoundMsg_Team4_Win;
  215. string_t m_iszEndRoundMsg_Team1_Lose;
  216. string_t m_iszEndRoundMsg_Team2_Lose;
  217. string_t m_iszEndRoundMsg_Team3_Lose;
  218. string_t m_iszEndRoundMsg_Team4_Lose;
  219. string_t m_iszEndRoundMsg_Team1;
  220. string_t m_iszEndRoundMsg_Team2;
  221. string_t m_iszEndRoundMsg_Team3;
  222. string_t m_iszEndRoundMsg_Team4;
  223. string_t m_iszEndRoundMsg_OwnedBy;
  224. string_t m_iszEndRoundMsg_NonOwnedBy;
  225. int all_active;
  226. int last_impulse; // The previous impulse command from this player
  227. int activate_goal_no;
  228. int inactivate_goal_no;
  229. int remove_goal_no;
  230. int restore_goal_no;
  231. int activate_group_no;
  232. int inactivate_group_no;
  233. int remove_group_no;
  234. int restore_group_no;
  235. BOOL do_triggerwork; // Overrides for trigger handling in TF Goals
  236. string_t killtarget; // Remove ents with this target
  237. string_t target;
  238. string_t message;
  239. // Score increases
  240. int increase_team[4]; // Increase the scores of teams
  241. int increase_team_owned_by; // Increase the score of the team that owns this entity
  242. EHANDLE enemy;
  243. Vector oldorigin;
  244. int axhitme; // Remove item from AP
  245. int remove_item_group;
  246. };
  247. class CTFGoalItem : public CTFGoal
  248. {
  249. public:
  250. void Spawn( void );
  251. void StartItem( void );
  252. void PlaceItem( void );
  253. Class_T Classify ( void ) { return CLASS_TFGOAL_ITEM; }
  254. void item_tfgoal_touch( CBaseEntity *pOther );
  255. void tfgoalitem_droptouch();
  256. void tfgoalitem_dropthink();
  257. void tfgoalitem_remove();
  258. void DoDrop( Vector vecOrigin );
  259. public:
  260. float m_flDroppedAt;
  261. float speed;
  262. int speed_reduction;
  263. float distance;
  264. float pain_finished;
  265. float attack_finished;
  266. Vector redrop_origin; // Original drop position
  267. int redrop_count; // Number of time's we redropped.
  268. };
  269. class CTFTimerGoal : public CTFGoal
  270. {
  271. public:
  272. void Spawn( void );
  273. Class_T Classify ( void ) { return CLASS_TFGOAL_TIMER; }
  274. };
  275. #if 0
  276. class CTFSpawn : public CTFBaseItem
  277. {
  278. public:
  279. void Spawn( void );
  280. void Activate( void );
  281. Class_T Classify ( void ) { return CLASS_TFSPAWN; }
  282. BOOL CheckTeam( int iTeamNo );
  283. EHANDLE m_pTeamCheck;
  284. };
  285. #endif
  286. class CBaseDelay : public CTFGoal
  287. {
  288. public:
  289. DECLARE_CLASS( CBaseDelay, CTFGoal );
  290. void SUB_UseTargets( CBaseEntity *pActivator, USE_TYPE useType, float value );
  291. void KeyValue( KeyValueData *pkvd );
  292. void DelayThink( void );
  293. virtual bool KeyValue( const char *szKeyName, const char *szValue );
  294. public:
  295. float m_flDelay;
  296. string_t m_iszKillTarget;
  297. int button;
  298. };
  299. class CTeamCheck : public CBaseDelay
  300. {
  301. public:
  302. void Spawn( void );
  303. void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
  304. BOOL TeamMatches( int iTeam );
  305. };
  306. // Global functions.
  307. CTFGoalItem* Finditem(int ino);
  308. void DisplayItemStatus(CTFGoal *Goal, CTFPlayer *Player, CTFGoalItem *Item);
  309. #endif
  310. #endif // TF_MAPITEMS_H