convert line ends
[canaan.git] / prj / cam / src / ai / aicombat.h
blob357078fb5dea79e449a37a5c0e0f4440cbcdab91
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 ///////////////////////////////////////////////////////////////////////////////
7 // $Header: r:/t2repos/thief2/src/ai/aicombat.h,v 1.26 1999/08/05 16:45:47 Justin Exp $
8 //
9 //
11 #ifndef __AICOMBAT_H
12 #define __AICOMBAT_H
14 #include <dynarray.h>
16 #include <aibasabl.h>
17 #include <aicblink.h>
18 #include <aiutils.h>
20 #pragma once
21 #pragma pack(4)
23 class cAISubCombat;
25 ///////////////////////////////////////////////////////////////////////////////
27 // Publish ability and all associated link and property types
30 BOOL AIInitCombatAbility(IAIManager *);
31 BOOL AITermCombatAbility();
33 ///////////////////////////////////////////////////////////////////////////////
35 // CLASS: cAICombat
38 class cAICombat : public cAIAbility
40 public:
41 cAICombat();
43 // Standard component methods
44 STDMETHOD_(const char *, GetName)();
45 STDMETHOD_(void, Init)();
46 STDMETHOD_(void, Term)();
48 STDMETHOD_(BOOL, Save)(ITagFile *);
49 STDMETHOD_(BOOL, Load)(ITagFile *);
51 // Notifications
52 STDMETHOD_(void, OnActionProgress)(IAIAction * pAction);
53 STDMETHOD_(void, OnAlertness)(ObjID source,
54 eAIAwareLevel previous,
55 eAIAwareLevel current,
56 const sAIAlertness * pRaw);
57 STDMETHOD_(void, OnDamage)(const sDamageMsg *pMsg, ObjID realCulpritID);
58 STDMETHOD_(void, OnWeapon)(eWeaponEvent ev, ObjID victim, ObjID culprit);
59 STDMETHOD_(void, OnProperty)(IProperty *, const sPropertyListenMsg *);
60 STDMETHOD_(void, OnSound)(const sSoundInfo *, const sAISoundType * pType);
61 STDMETHOD_(void, OnGoalChange)(const cAIGoal * pPrevious, const cAIGoal * pGoal);
62 // @TBD (toml 07-27-98): need onmode
64 // Update the status of the current goal
65 STDMETHOD_(eAIResult, UpdateGoal)(cAIGoal *);
67 // Ability flow
68 STDMETHOD (SuggestMode) (sAIModeSuggestion *);
69 STDMETHOD (SuggestGoal) (cAIGoal * pPrevious, cAIGoal ** ppNew);
70 STDMETHOD (SuggestActions)(cAIGoal * pGoal, const cAIActions & previous, cAIActions * pNew);
72 // misc
73 STDMETHOD_(void, SetTargetAlertnessThreshold)(eAIAwareLevel threshold) {m_targetAlertnessThreshold = threshold;}
75 public:
76 // Functions potentially useful to both descendants and contained classes
77 ObjID GetTarget();
78 const mxs_vector & GetTargetLoc();
80 BOOL CanPlayReactCharge();
81 void SetPlayedReactCharge();
83 protected:
84 ObjID SeekCombat();
85 ObjID SelectTarget();
86 void SetTarget(ObjID);
88 void CheckLostContact(); // See if we need to play the LostContact concept.
90 BOOL IsHostileToward(ObjID);
91 eAIAwareLevel GetTargetAlertnessThreshold(void) const {return m_targetAlertnessThreshold;}
93 // over-ride these for ability specific targetting behavior
94 virtual BOOL IsValidTarget(ObjID object); // Is this valid for acquiring or retaining?
95 virtual BOOL IsAcquirableTarget(const sAIAwareness& awareness); // Is this valid to acquire?
96 virtual BOOL IsRetainableTarget(const sAIAwareness& awareness); // Is this valid to retain?
97 virtual eAIPriority TargetPriority(ObjID object); // How good is this target?
99 private:
100 void SignalSubGoals() {}
102 void UpdateTargets();
103 ObjID TargetScan();
105 enum
107 kWasDamaged = kBaseFirstAvailFlag,
108 kWasThreatened = (kWasDamaged << 1),
110 kCombatFirstAvailFlag = (kWasThreatened << 1)
113 cAITimer m_TargetRefreshTimer;
114 cAIRandomTimer m_ReactChargeTimer;
115 cAIRandomTimer m_LostContactTimer;
116 ObjID m_LostContactWith;
117 eAIAwareLevel m_targetAlertnessThreshold; // level at which identifying a combat target becomes easier
119 int m_lastTargetSwitch;
122 ///////////////////////////////////////
124 inline BOOL cAICombat::CanPlayReactCharge()
126 return m_ReactChargeTimer.Expired();
129 ///////////////////////////////////////
131 inline void cAICombat::SetPlayedReactCharge()
133 m_ReactChargeTimer.Reset();
136 ///////////////////////////////////////////////////////////////////////////////
138 #pragma pack()
139 #endif /* !__AICOMBAT_H */