Initial Import
[glAntsMech.git] / glants_mech / linux / src / bot.h
blob9b23339b886649a36b676ee872ad98dd17bb709d
1 //
2 // bot.h
3 //
4 #ifndef _BOT_H_
5 #define _BOT_H_
7 // used for network
8 #define __VERSION__ 6
9 #define __OS__ "LIN"
11 typedef unsigned long DWORD;
12 typedef int bool;
14 #define ZeroMemory(S, N) memset((S), 0, (N))
16 #define true 1
17 #define false 0
19 // the number of commands in the
20 // command process
22 #define ATTACK_COMMAND 1
23 #define WANDER_COMMAND 2
24 #define MOVE_COMMAND 3
27 // use TAB to toggle between modes
29 #define THIRD_PERSON_MODE 1
30 #define FIRST_PERSON_MODE 2
33 // crosshairs
34 //
35 #define CROSSHAIRS_SCALE 4.5f
36 #define CROSSHAIRS_GROWTH 1.3f
38 #define LOOKAT_OFFSET 5.0f
39 #define CAMERA_BOT_OFFSET 8.0f
40 #define CAMERA_HEIGHT 3.2f
42 #define RELEASE_OBJECT(x) \
43 if (x != NULL) \
44 free(x); \
45 x = NULL \
48 // The multiplier for kills or
49 // just normal hits
51 #define SCORE_NORMAL 2.0f
52 #define SCORE_KILL 10.0f
55 // stars.cpp
57 #define MAX_RAND 4096 // 4096?
58 #define MAX_STARS 1200 // 2000
59 #define STAR_RADIUS 710.0
60 #define STAR_ROT_SPEED 0.1f;
63 #define __straight_steps (MAX_STRAIGHT_STEPS-MIN_STRAIGHT_STEPS)
65 #define __go_home_steps_2 (MAX_STRAIGHT_STEPS_2-MIN_STRAIGHT_STEPS_2)
68 // based on how much food is avaible
69 // respawn so many ants
70 #define USE_FOOD_RESPAWN 0
71 #define ANT_RESPAWN 8
72 #define FOOD_RESPAWN (ANT_RESPAWN * INITIAL_ANT_FOOD)
75 #define BEGIN_BOT glPushMatrix()
76 #define END_BOT glPopMatrix()
78 #define TURN_RIGHT 1
79 #define TURN_LEFT 2
82 #define MOVE_STATE 0
83 #define TURN_STATE 1
84 #define CHANGE_DIR_STATE 2
85 #define MOUNT_STATE 3
86 #define SHOOT_STATE 4
87 #define SET_TURN_STATE 6
88 #define SET_MOUNT_STATE 7
89 #define GENERATE_STATE 8
90 #define GENERATE_TURN 9
91 #define RECHECK_STATE 10
93 #define TEMP_STATE 99
94 #define GO_MOVE_COMMAND 999
95 #define GO_ATTACK_COMMAND 998
96 #define GO_WANDER_COMMAND 997
97 #define EXPLODE_STATE 995
99 #define ALIVE_STATE 1
100 #define DEAD_STATE 0
101 #define READY_STATE 2
104 #define GET_NEST_WIDTH (1.5f*nest.objects[0]->size[0])
105 #define GET_NEST_HWID (GET_NEST_WIDTH/2.0f)
106 #define NEST_FOOD_OBJECT nest.objects[0]->food
108 #define INVALID_BOT -1
110 // static bot
112 typedef struct tagStaticBot {
114 int list_id;
115 float position[3];
116 float rotation[3];
117 float size[3];
118 float color[3];
119 float state;
121 float food;
123 bool delete_flag; // deleted from pheromone list
125 float heading; // you can use rotation or heading
126 float linearv;
129 // for the collision
131 float travel; // distance traveled
132 float final_x;
133 float final_y;
134 float max_dist;
139 float old_x;
140 float old_y; // for drawing a line strip
142 // used with bullets
143 float virt_x;
144 float virt_y;
145 float virt_heading;
146 int owner; // owner of this bullet
148 struct tagStaticBot *next;
150 } StaticBot, *StaticBotPtr;
152 // functions for static bot
153 typedef struct tagDriverSentinel {
155 StaticBotPtr (*create)(int bot_id);
156 void (*destroy)(StaticBotPtr b);
157 void (*render)(StaticBotPtr boid);
158 void (*process)(StaticBotPtr b);
160 void (*generate)(void);
161 void (*shutdown)(void);
162 void (*drawall)(void);
164 StaticBot **objects;
166 int max_items;
168 } DriverSentinel, *DriverSentinelPtr;
171 typedef struct tagDriverBots {
173 float x;
174 float y;
175 float linearv; // speed
176 float size[3]; // scale
177 float heading; // direction
178 float target_dir; // target heading
179 float color[3];
180 int id;
181 int alive;
182 int numSteps; // how many steps ant has moved
183 float turning_speed;
185 int state; // what is bot doing
186 int straightSteps; // steps before changing direction
187 float food;
188 float foodstore;
189 int turn_rand;
190 int turn_direction;
192 bool go_home;
194 int gun_reset; // delay befor firing
195 int gun_index;
197 bool move_back; // for move and turn
200 // camera helper variables
201 float look_x;
202 float look_y;
203 float look_h; // look height, actually the y
204 float cam_x;
205 float cam_y;
206 int view_mode; // first or third person
208 float score;
209 int kills;
212 // the rectangle of the bot
213 // Note: you have to add
214 // the x,y to this value, but dont
215 // do to this variable, use temps
216 float x_min;
217 float x_max;
218 float y_min;
219 float y_max;
222 // crosshair object
224 int crosshair_state;
225 float crosshair_scale;
227 // Add the fire ant bullets
228 //StaticBot bullets[MAX_BULLETS];
229 StaticBot *bullets;
231 // Command interface
232 void (*run)(struct tagDriverBots *bot);
234 int last_command;
235 int command;
236 float attack_angle;
237 int target_moves;
238 int move_index;
239 int enemy_id;
241 } DriverBots, *DriverBotPtr;
243 void Super_LoadBots(void);
244 void Super_KillBots(void);
246 void Super_FireAnts(void);
247 void Super_KillFires(void);
249 // fireants.cpp
250 void Reset_FireAnts(void);
251 void Player_Control(bool *keys);
253 void LoadBotParms(DriverBotPtr bot_ptr);
255 void Wander_Command(DriverBotPtr bot);
256 void Move_Command(DriverBotPtr bot);
257 void Attack_Command(DriverBotPtr bot);
259 int GetStartState(int cmd);
260 int GetLastState(int cmd);
261 void Generate_Command(DriverBotPtr bot, int cmd);
263 void GenerateBots(void);
264 void ShutdownBots(void);
266 void DrawBots(void);
267 void InitFood(void);
269 int BruteCheckFood(DriverBotPtr bot);
270 void DropFood(DriverBotPtr bot, int id, float food_rate);
272 void CreateAnts(int food);
274 float FindAngle(float dir, float x1, float y1, float x2, float y2);
276 void CheckRespawn(void);
278 void ActivatePheromone(float x, float y, float dir);
280 DriverBotPtr CreateBot(int bot_id);
281 void DestroyBot(DriverBotPtr b);
282 void GetAntFood(DriverBotPtr bot);
283 void ResetBot(DriverBotPtr bot_ptr);
285 void GenerateFireAnts(void);
286 void ShutdownFireAnts(void);
287 void DrawFireAnts(void);
288 void AnimFireAnts(void);
290 bool CheckSight(DriverBotPtr bot, DriverBotPtr nme);
292 void MoveFire0(int dir, int turn);
294 void PositionBot(DriverBotPtr bot);
296 void AnimNetworkBots(void);
299 extern DriverSentinel nest;
300 extern DriverSentinel garden;
301 extern DriverSentinel trail_set;
304 #endif