1 /* c_jovian.hh 1.15 95/12/28 00:42:29 */
2 
3 
4 // xspacewarp by Greg Walker (gow@math.orst.edu)
5 
6 // This is free software. Non-profit redistribution and/or modification
7 // is allowed and welcome.
8 
9 
10 // class for describing jovians
11 
12 #ifndef _JOVIAN_
13 #define _JOVIAN_
14 
15 #include "c_combatant.hh"
16 #include <X11/Xlib.h>
17 #include "common.hh"
18 #include "space_objects.hh"
19 
20 
21 class Jovian: public Combatant
22 {
23 public:
24   Jovian();
what() const25   Identity what() const {return (JOVIAN);}
getid() const26   int getid() const {return (id);}
27   void setid(int i);
28   void die(Identity cause);
29   void draw(Drawable drawable, GC gc) const;
30   void update();
31   void energize();
getmaxerg() const32   int getmaxerg() const {return (maxerg);}
33   static void init_ai();		// initialize static AI data
34   static void setpop(int p);
35   static int getpop();
36   static void seticon(const char *str);
37   static int geticon_len();
setleapflag(bool b)38   static void setleapflag(bool b){leapflag = b;}
39   static void setleapable(int n);
40   static void addleapable(int n);
41   static void setraidable(int n);
42   static void addraidable(int n);
43 private:
44   int id;		// identification number for each instance.
45   void move(Direction dir); // ion thrusters
46   void leap(Ucoors uc);		// warpdrive
47   void shoot(Point to);		// fasers
48 
49   // static data
50 
51   static int pop;	// population of jovians remaining in game
52   static char icon[];
53   static const int icon_len;
54   static const int maxerg; // max energy for shields, thrust, warp, or fasers
55   static bool leapflag;	   // set this to false before invoking jovian ai
56 			   // functions each time jovian_to() gets called.
57 			   // The ai functions will set this to
58 			   // true if some jovian makes a leap. Afterwards,
59 			   // no jovians will leap until the next call on
60 			   // jovian_to() timeout. This way at most one
61 			   // jovian can make a leap on any call to
62 			   // jovian_to().
63   static bool raidflag;	   // Like leapflag but controls whether jovians
64 			   // are allowed to make a raid on a base. At most
65 			   // one raid is allowed per call on jovian_to().
66   static int leapable;	   // The number of jovians eligible for leaping;
67 			   // ie, their sectors contain neither a base nor
68 			   // the endever.
69   static int raidable;	   // The number of jovians eligible for mounting
70 			   // a raid on a base; ie, their sectors contain
71 			   // a base but not the endever.
72 
73 
74   // AI related functions and data
75 
76   void init_ai_flags(); // initialize the non-static ai data
77   Decision decide();
78   void act(Decision d);
79   // AI functions for filling in the Decision struct
80   Action pick_action();
81   Direction pick_direction();
82   Ucoors pick_sector();
83   Point pick_target();
84   Direction retreat_direction();
85   bool retreat_flag;	    // set to true if jovian is running away
86   bool forcedvert;          // set to true if jovian was forced to move
87 			    // vertically to go around an obstacle.
88   bool forcedhoriz;         // set to true if jovian was forced to move
89 			    // horizontally to go around an obstacle.
90   bool israiding;	    // set to true if this jovian is mounting
91 			    // a raid on a base. once set to true, the jovian
92 			    // will attack the base until destroyed. The
93 			    // flag gets reset back to false when the base is
94 			    // destroyed or when the endever enters the sector.
95   // bool blocked is declared in c_combatant.hh so it is easier to
96   // access in the c_combatant.cc functions.
97 };
98 
99 
100 // for keeping doubly linked list of jovians
101 
102 struct Jovian_rec
103 {
104   Jovian_rec *prev, *next;
105   Jovian *jov_pt;
106 };
107 
108 
109 #endif				// _JOVIAN_
110 
111 // end
112