Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ShipAI.h
Go to the documentation of this file.
1 /* Project STARSHATTER
2  John DiCamillo
3  Copyright © 1997-2002. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: ShipAI.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Common base class and interface for low-level ship AI
13 */
14 
15 #ifndef ShipAI_h
16 #define ShipAI_h
17 
18 #include "Types.h"
19 #include "SteerAI.h"
20 
21 // +--------------------------------------------------------------------+
22 
23 class Ship;
24 class Shot;
25 class Instruction;
26 class TacticalAI;
27 class Farcaster;
28 
29 // +--------------------------------------------------------------------+
30 
31 class ShipAI : public SteerAI
32 {
33 public:
34  ShipAI(SimObject* s);
35  virtual ~ShipAI();
36 
37  virtual void ExecFrame(double seconds);
38  virtual int Subframe() const { return true; }
39 
40  virtual Ship* GetShip() const { return ship; }
41 
42  virtual Ship* GetWard() const;
43  virtual void SetWard(Ship* s);
44  virtual Ship* GetThreat() const { return threat; }
45  virtual void SetThreat(Ship* s);
46  virtual Ship* GetSupport() const { return support; }
47  virtual void SetSupport(Ship* s);
48  virtual Ship* GetRumor() const { return rumor; }
49  virtual void SetRumor(Ship* s);
50  virtual Shot* GetThreatMissile() const { return threat_missile; }
51  virtual void SetThreatMissile(Shot* s);
52  virtual Instruction* GetNavPoint() const { return navpt; }
53  virtual void SetNavPoint(Instruction* n) { navpt = n; }
54  virtual Point GetPatrol() const;
55  virtual void SetPatrol(const Point& p);
56  virtual void ClearPatrol();
57  virtual void ClearRumor();
58  virtual void ClearTactical();
59 
60  virtual Farcaster* GetFarcaster() { return farcaster; }
61 
62  // convert the goal point from world to local coords:
63  virtual void FindObjective();
64 
65  virtual void Splash(const Ship* targ);
66  virtual void SetTarget(SimObject* targ, System* sub=0);
67  virtual void DropTarget(double drop_time=1.5);
68  virtual double DropTime() const { return drop_time; }
69  virtual void SetBracket(bool bracket);
70  virtual void SetIdentify(bool identify);
71 
72  virtual void SetFormationDelta(const Point& point);
73 
74  virtual bool Update(SimObject* obj);
75  virtual const char* GetObserverName() const;
76 
77  virtual int GetAILevel() const { return ai_level; }
78 
79 protected:
80  // accumulate behaviors:
81  virtual void Navigator();
82 
83  // behaviors:
84  virtual bool AvoidTestSingleObject(SimObject* obj,
85  const Point& bearing,
86  double avoid_dist,
87  double& avoid_time,
88  Steer& steer);
89 
90  virtual Steer AvoidCloseObject(SimObject* obj);
91  virtual Steer AvoidCollision();
92  virtual Steer AvoidTerrain();
93  virtual Steer SeekTarget();
94  virtual Steer EvadeThreat();
95 
96  virtual Point ClosingVelocity();
97 
98  // compute the goal point in world coords based on current ai state:
99  virtual void FindObjectiveTarget(SimObject* tgt);
100  virtual void FindObjectiveNavPoint();
101  virtual void FindObjectiveFormation();
102  virtual void FindObjectivePatrol();
103  virtual void FindObjectiveQuantum();
104  virtual void FindObjectiveFarcaster(SimRegion* src, SimRegion* dst);
105 
106  // fire on target if appropriate:
107  virtual void AdjustDefenses();
108  virtual void FireControl();
109  virtual void HelmControl();
110  virtual void ThrottleControl();
111  virtual void NavlightControl();
112 
113  virtual void CheckTarget();
114 
126 
128  double slot_dist;
129 
130  double throttle;
131  double old_throttle;
132  double seconds;
133  double drop_time;
134  double brake;
137 
140  bool bracket;
141  bool identify;
142  bool hold;
143  bool takeoff;
144 
145  int patrol;
147  int ai_level;
148 };
149 
150 // +--------------------------------------------------------------------+
151 
152 #endif ShipAI_h
153