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.

102 lines
3.6 KiB

  1. // NextBotContextualQueryInterface.h
  2. // Queries within the context of the bot's current behavior state
  3. // Author: Michael Booth, June 2007
  4. //========= Copyright Valve Corporation, All rights reserved. ============//
  5. #ifndef _NEXT_BOT_CONTEXTUAL_QUERY_H_
  6. #define _NEXT_BOT_CONTEXTUAL_QUERY_H_
  7. class INextBot;
  8. class CBaseEntity;
  9. class CBaseCombatCharacter;
  10. class Path;
  11. class CKnownEntity;
  12. /**
  13. * Since behaviors can have several concurrent actions active, we ask
  14. * the topmost child action first, and if it defers, its parent, and so
  15. * on, until we get a definitive answer.
  16. */
  17. enum QueryResultType
  18. {
  19. ANSWER_NO,
  20. ANSWER_YES,
  21. ANSWER_UNDEFINED
  22. };
  23. // Can pass this into IContextualQuery::IsHindrance to see if any hindrance is ever possible
  24. #define IS_ANY_HINDRANCE_POSSIBLE ( (CBaseEntity*)0xFFFFFFFF )
  25. //----------------------------------------------------------------------------------------------------------------
  26. /**
  27. * The interface for queries that are dependent on the bot's current behavior state
  28. */
  29. class IContextualQuery
  30. {
  31. public:
  32. virtual ~IContextualQuery() { }
  33. virtual QueryResultType ShouldPickUp( const INextBot *me, CBaseEntity *item ) const; // if the desired item was available right now, should we pick it up?
  34. virtual QueryResultType ShouldHurry( const INextBot *me ) const; // are we in a hurry?
  35. virtual QueryResultType ShouldRetreat( const INextBot *me ) const; // is it time to retreat?
  36. virtual QueryResultType ShouldAttack( const INextBot *me, const CKnownEntity *them ) const; // should we attack "them"?
  37. virtual QueryResultType IsHindrance( const INextBot *me, CBaseEntity *blocker ) const; // return true if we should wait for 'blocker' that is across our path somewhere up ahead.
  38. virtual Vector SelectTargetPoint( const INextBot *me, const CBaseCombatCharacter *subject ) const; // given a subject, return the world space position we should aim at
  39. /**
  40. * Allow bot to approve of positions game movement tries to put him into.
  41. * This is most useful for bots derived from CBasePlayer that go through
  42. * the player movement system.
  43. */
  44. virtual QueryResultType IsPositionAllowed( const INextBot *me, const Vector &pos ) const;
  45. virtual const CKnownEntity * SelectMoreDangerousThreat( const INextBot *me,
  46. const CBaseCombatCharacter *subject,
  47. const CKnownEntity *threat1,
  48. const CKnownEntity *threat2 ) const; // return the more dangerous of the two threats to 'subject', or NULL if we have no opinion
  49. };
  50. inline QueryResultType IContextualQuery::ShouldPickUp( const INextBot *me, CBaseEntity *item ) const
  51. {
  52. return ANSWER_UNDEFINED;
  53. }
  54. inline QueryResultType IContextualQuery::ShouldHurry( const INextBot *me ) const
  55. {
  56. return ANSWER_UNDEFINED;
  57. }
  58. inline QueryResultType IContextualQuery::ShouldRetreat( const INextBot *me ) const
  59. {
  60. return ANSWER_UNDEFINED;
  61. }
  62. inline QueryResultType IContextualQuery::ShouldAttack( const INextBot *me, const CKnownEntity *them ) const
  63. {
  64. return ANSWER_UNDEFINED;
  65. }
  66. inline QueryResultType IContextualQuery::IsHindrance( const INextBot *me, CBaseEntity *blocker ) const
  67. {
  68. return ANSWER_UNDEFINED;
  69. }
  70. inline Vector IContextualQuery::SelectTargetPoint( const INextBot *me, const CBaseCombatCharacter *subject ) const
  71. {
  72. return vec3_origin;
  73. }
  74. inline QueryResultType IContextualQuery::IsPositionAllowed( const INextBot *me, const Vector &pos ) const
  75. {
  76. return ANSWER_UNDEFINED;
  77. }
  78. inline const CKnownEntity *IContextualQuery::SelectMoreDangerousThreat( const INextBot *me, const CBaseCombatCharacter *subject, const CKnownEntity *threat1, const CKnownEntity *threat2 ) const
  79. {
  80. return NULL;
  81. }
  82. #endif // _NEXT_BOT_CONTEXTUAL_QUERY_H_