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.

195 lines
5.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: provides an interface for dlls to query information about players from the game dll
  4. //
  5. //=============================================================================//
  6. #ifndef IPLAYERINFO_H
  7. #define IPLAYERINFO_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "mathlib/vector.h"
  12. // helper class for user commands
  13. class CBotCmd
  14. {
  15. public:
  16. CBotCmd()
  17. {
  18. Reset();
  19. }
  20. virtual ~CBotCmd() { };
  21. void Reset()
  22. {
  23. command_number = 0;
  24. tick_count = 0;
  25. viewangles.Init();
  26. forwardmove = 0.0f;
  27. sidemove = 0.0f;
  28. upmove = 0.0f;
  29. buttons = 0;
  30. impulse = 0;
  31. weaponselect = 0;
  32. weaponsubtype = 0;
  33. random_seed = 0;
  34. mousedx = 0;
  35. mousedy = 0;
  36. hasbeenpredicted = false;
  37. }
  38. CBotCmd& operator =( const CBotCmd& src )
  39. {
  40. if ( this == &src )
  41. return *this;
  42. command_number = src.command_number;
  43. tick_count = src.tick_count;
  44. viewangles = src.viewangles;
  45. forwardmove = src.forwardmove;
  46. sidemove = src.sidemove;
  47. upmove = src.upmove;
  48. buttons = src.buttons;
  49. impulse = src.impulse;
  50. weaponselect = src.weaponselect;
  51. weaponsubtype = src.weaponsubtype;
  52. random_seed = src.random_seed;
  53. mousedx = src.mousedx;
  54. mousedy = src.mousedy;
  55. hasbeenpredicted = src.hasbeenpredicted;
  56. return *this;
  57. }
  58. // For matching server and client commands for debugging
  59. int command_number;
  60. // the tick the client created this command
  61. int tick_count;
  62. // Player instantaneous view angles.
  63. QAngle viewangles;
  64. // Intended velocities
  65. // forward velocity.
  66. float forwardmove;
  67. // sideways velocity.
  68. float sidemove;
  69. // upward velocity.
  70. float upmove;
  71. // Attack button states
  72. int buttons;
  73. // Impulse command issued.
  74. byte impulse;
  75. // Current weapon id
  76. int weaponselect;
  77. int weaponsubtype;
  78. int random_seed; // For shared random functions
  79. short mousedx; // mouse accum in x from create move
  80. short mousedy; // mouse accum in y from create move
  81. // Client only, tracks whether we've predicted this command at least once
  82. bool hasbeenpredicted;
  83. };
  84. abstract_class IPlayerInfo
  85. {
  86. public:
  87. // returns the players name (UTF-8 encoded)
  88. virtual const char *GetName() = 0;
  89. // returns the userid (slot number)
  90. virtual int GetUserID() = 0;
  91. // returns the string of their network (i.e Steam) ID
  92. virtual const char *GetNetworkIDString() = 0;
  93. // returns the team the player is on
  94. virtual int GetTeamIndex() = 0;
  95. // changes the player to a new team (if the game dll logic allows it)
  96. virtual void ChangeTeam( int iTeamNum ) = 0;
  97. // returns the number of kills this player has (exact meaning is mod dependent)
  98. virtual int GetFragCount() = 0;
  99. // returns the number of deaths this player has (exact meaning is mod dependent)
  100. virtual int GetDeathCount() = 0;
  101. // returns if this player slot is actually valid
  102. virtual bool IsConnected() = 0;
  103. // returns the armor/health of the player (exact meaning is mod dependent)
  104. virtual int GetArmorValue() = 0;
  105. // extensions added to V2
  106. // various player flags
  107. virtual bool IsHLTV() = 0;
  108. virtual bool IsPlayer() = 0;
  109. virtual bool IsFakeClient() = 0;
  110. virtual bool IsDead() = 0;
  111. virtual bool IsInAVehicle() = 0;
  112. virtual bool IsObserver() = 0;
  113. // player position and size
  114. virtual const Vector GetAbsOrigin() = 0;
  115. virtual const QAngle GetAbsAngles() = 0;
  116. virtual const Vector GetPlayerMins() = 0;
  117. virtual const Vector GetPlayerMaxs() = 0;
  118. // the name of the weapon currently being carried
  119. virtual const char *GetWeaponName() = 0;
  120. // the name of the player model in use
  121. virtual const char *GetModelName() = 0;
  122. // current player health
  123. virtual const int GetHealth() = 0;
  124. // max health value
  125. virtual const int GetMaxHealth() = 0;
  126. // the last user input from this player
  127. virtual CBotCmd GetLastUserCommand() = 0;
  128. virtual bool IsReplay() = 0;
  129. };
  130. #define INTERFACEVERSION_PLAYERINFOMANAGER "PlayerInfoManager002"
  131. abstract_class IPlayerInfoManager
  132. {
  133. public:
  134. virtual IPlayerInfo *GetPlayerInfo( edict_t *pEdict ) = 0;
  135. virtual CGlobalVars *GetGlobalVars() = 0;
  136. };
  137. abstract_class IBotController
  138. {
  139. public:
  140. // change the bots position
  141. virtual void SetAbsOrigin( Vector & vec ) = 0;
  142. virtual void SetAbsAngles( QAngle & ang ) = 0;
  143. virtual void SetLocalOrigin( const Vector& origin ) = 0;
  144. virtual const Vector GetLocalOrigin( void ) = 0;
  145. virtual void SetLocalAngles( const QAngle& angles ) = 0;
  146. virtual const QAngle GetLocalAngles( void ) = 0;
  147. // strip them of weapons, etc
  148. virtual void RemoveAllItems( bool removeSuit ) = 0;
  149. // give them a weapon
  150. virtual void SetActiveWeapon( const char *WeaponName ) = 0;
  151. // check various effect flags
  152. virtual bool IsEFlagSet( int nEFlagMask ) = 0;
  153. // fire a virtual move command to the bot
  154. virtual void RunPlayerMove( CBotCmd *ucmd ) = 0;
  155. };
  156. #define INTERFACEVERSION_PLAYERBOTMANAGER "BotManager001"
  157. abstract_class IBotManager
  158. {
  159. public:
  160. virtual IBotController *GetBotController( edict_t *pEdict ) = 0;
  161. // create a new bot and spawn it into the server
  162. virtual edict_t *CreateBot( const char *botname ) = 0;
  163. };
  164. #endif // IPLAYERINFO_H