1 #ifndef NETHER_HEADER 2 #define NETHER_HEADER 3 4 5 // #define _WRITE_REPORT_ 6 7 8 #define COLISION_TEST_THRESHOLD 9.0 9 #define INTRO_TIME 60 10 #define END_TIME 260 11 12 /* BULLET SPEED: */ 13 #define BULLET_SPEED 0.1f 14 #define CANNON_PERSISTENCE 40 15 #define MISSILE_PERSISTENCE 60 16 #define PHASER_PERSISTENCE 40 17 18 /* GAME STATES: */ 19 #define STATE_PLAYING 0 20 #define STATE_CONSTRUCTION 1 21 #define STATE_PAUSE 2 22 #define STATE_SAVINGGAME 3 23 #define STATE_LOADINGGAME 4 24 25 /* BUTTON NAMES: */ 26 #define TIME_BUTTON 1 27 #define STATUS_BUTTON 2 28 #define RESOURCE_BUTTON 3 29 #define ROBOT1_BUTTON 4 30 #define ROBOT2_BUTTON 5 31 #define ROBOT3_BUTTON 6 32 #define ROBOT4_BUTTON 7 33 #define COMBAT1_BUTTON 8 34 #define COMBAT2_BUTTON 9 35 #define COMBAT3_BUTTON 10 36 #define COMBAT4_BUTTON 11 37 #define COMBAT5_BUTTON 12 38 #define COMBAT6_BUTTON 13 39 #define ORDERS1_BUTTON 14 40 #define ORDERS2_BUTTON 15 41 #define ORDERS3_BUTTON 16 42 #define ORDERS4_BUTTON 17 43 #define ORDERS5_BUTTON 18 44 #define ORDERS_BUTTON 19 45 #define TARGET1_BUTTON 20 46 #define TARGET2_BUTTON 21 47 #define TARGET3_BUTTON 22 48 49 #define GENERAL_MENU 0 50 #define ROBOT_MENU 1 51 #define DIRECTCONTROL_MENU 2 52 #define COMBATMODE_MENU 3 53 #define DIRECTCONTROL2_MENU 4 54 #define ORDERS_MENU 5 55 #define SELECTDISTANCE_MENU 6 56 #define TARGETD_MENU 7 57 #define TARGETC_MENU 8 58 59 #define ALL_MENUS 9 60 61 /* SHIP OPERATORS: */ 62 #define OP_NONE -1 63 #define OP_LEFT 0 64 #define OP_RIGHT 1 65 #define OP_FORWARD 2 66 #define OP_BACKWARD 3 67 #define OP_UP 4 68 69 /* TERRAINS: */ 70 #define T_GRASS 0 71 #define T_SAND 1 72 #define T_MOUNTAINS 2 73 #define T_HOLE 3 74 #define T_BUILDING 4 75 #define T_SHIP 5 76 #define T_ROBOT 6 77 #define T_EROBOT 7 78 #define T_OUT 8 79 80 /* RESOURCES: */ 81 #define R_GENERAL 0 82 #define R_ELECTRONICS 1 83 #define R_NUCLEAR 2 84 #define R_PHASERS 3 85 #define R_MISSILES 4 86 #define R_CANNONS 5 87 #define R_CHASSIS 6 88 89 /* BUILDINGS & WALLS: */ 90 #define B_FENCE 0 91 #define B_WALL1 1 92 #define B_WALL2 2 93 #define B_WALL3 3 94 #define B_WALL4 4 95 #define B_WALL5 5 96 #define B_WALL6 6 97 #define B_FACTORY_ELECTRONICS 7 98 #define B_FACTORY_NUCLEAR 8 99 #define B_FACTORY_PHASERS 9 100 #define B_FACTORY_MISSILES 10 101 #define B_FACTORY_CANNONS 11 102 #define B_FACTORY_CHASSIS 12 103 #define B_WARBASE 13 104 105 /* ROBOT PROGRAMS AND OPERATORS: */ 106 #define ROBOTOP_NONE -1 107 #define ROBOTOP_FORWARD 0 108 #define ROBOTOP_LEFT 1 109 #define ROBOTOP_RIGHT 2 110 #define ROBOTOP_CANNONS 3 111 #define ROBOTOP_MISSILES 4 112 #define ROBOTOP_PHASERS 5 113 #define ROBOTOP_NUCLEAR 6 114 115 #define PROGRAM_NONE -1 116 #define PROGRAM_FORWARD 0 117 #define PROGRAM_STOPDEFEND 1 118 #define PROGRAM_ADVANCE 2 119 #define PROGRAM_RETREAT 3 120 #define PROGRAM_DESTROY 4 121 #define PROGRAM_CAPTURE 5 122 123 #define P_PARAM_ROBOTS 1 124 #define P_PARAM_WARBASES 2 125 #define P_PARAM_NFACTORIES 3 126 #define P_PARAM_EFACTORIES 4 127 128 /* ARTIFICIAL INTELLIGENCE STATES: */ 129 #define AI_STATE_EXPANDING 0 130 #define AI_STATE_FIGHTING 1 131 #define AI_STATE_DEFENDING 2 132 #define AI_STATE_CONQUERING 3 133 #define AI_STATE_DESTROYING 4 134 135 136 137 138 139 class STATUSBUTTON { 140 public: 141 int ID; 142 int sx,sy; 143 int x,y; 144 char text1[80]; 145 char text2[80]; 146 147 int status; 148 float r,g,b; 149 }; 150 151 152 class BUILDING { 153 public: 154 int type; 155 Vector pos; 156 int owner; 157 158 int status; /* This variable controls the status of the building: if its free, or being captured */ 159 /* by some of the players. */ 160 }; 161 162 163 class ROBOT { 164 public: 165 ROBOT(); 166 bool valid(void); 167 float piecez(int piece); 168 bool bullethit(int type); 169 170 int traction; 171 bool pieces[5]; 172 173 int program; 174 int program_parameter; 175 Vector program_goal; 176 177 int op; 178 bool shipover; 179 int firetimer; 180 int strength; 181 182 Vector pos; 183 int angle; 184 CMC cmc; 185 186 /* Animation variables: */ 187 int electronics_state; 188 int chassis_state; 189 }; 190 191 192 class BULLET { 193 public: 194 BULLET(void); 195 BULLET(int t,Vector p,int a,ROBOT *r); 196 197 int type; 198 int step; 199 200 Vector pos; 201 int angle; 202 ROBOT *owner; /* The robot who fired this bullet */ 203 204 CMC cmc; 205 }; 206 207 208 class EXPLOSION { 209 public: 210 EXPLOSION(void); 211 EXPLOSION(Vector p,int sz); 212 213 Vector pos; 214 int step; 215 int size; 216 }; 217 218 219 class PARTICLE { 220 public: 221 PARTICLE(void); 222 PARTICLE(Vector p,Vector speed1,Vector speed2,float sz1,float sz2,float r,float g,float b,float a1,float a2,int lifetime); 223 224 Vector pos,speed1,speed2; 225 float size1,size2; 226 float r,g,b; 227 float a1,a2; 228 int lifetime,acttime; 229 }; 230 231 232 class AI_OPERATOR { 233 public: 234 Vector newpos; 235 int first_robotop; 236 int cost; 237 int previous; 238 bool deadend; 239 bool used; 240 }; 241 242 243 class NETHER { 244 public: 245 NETHER(char *mapname); 246 ~NETHER(); 247 248 void loadobjects(); 249 void deleteobjects(); 250 251 bool gamecycle(int w,int h); 252 void gameredraw(int w,int h); 253 void refresh_display_lists(void); 254 255 bool save_game(char *filename); 256 bool load_game(char *filename); 257 bool save_debug_report(char *filename); 258 259 private: 260 bool cycle(unsigned char *keyboard); 261 bool construction_cycle(unsigned char *keyboard); 262 bool option_cycle(unsigned char *keyboard); 263 264 void draw(int w,int h); 265 void draw_game(bool shadows); 266 void draw_radar(void); 267 void draw_status(void); 268 void construction_draw(int w,int h); 269 void options_draw(int w,int h); 270 271 bool loadmap(char *file); 272 void drawmap(bool shadows); 273 274 float MapMaxZ(float x[2],float y[2]); 275 int MapTerrain(float x, float y); 276 int WorseMapTerrain(float x[2], float y[2]); 277 278 bool ShipCollision(C3DObject *ship,float x,float y,float z); 279 bool RobotCollision(ROBOT *r,bool complete); 280 bool BulletCollision(BULLET *b,ROBOT **r); 281 282 void DrawBullet(BULLET *bullet,bool shadows); 283 void DrawRobot(ROBOT *robot,int owner,bool shadows); 284 void RobotCost(int player,ROBOT *r,int *res); 285 int RobotCost(ROBOT *r); 286 CMC RobotCMC(ROBOT *r,int owner); 287 CMC BulletCMC(BULLET *r); 288 void DrawParticle(PARTICLE *p); 289 bool CycleParticle(PARTICLE *p); 290 291 float RobotSpeed(int traction,int terrain); 292 int RobotRotationSpeed(int traction,int terrain); 293 bool Walkable(int traction,int terrain); 294 295 int SFX_volume(Vector pos); 296 297 void newbutton(int ID,int x,int y,int sx,int sy,char *t1,char *t2,float r,float g,float b); 298 void newbuttondelayed(int ID,int x,int y,int sx,int sy,char *t1,char *t2,float r,float g,float b); 299 void killbutton(int ID); 300 STATUSBUTTON *getbutton(int ID); 301 void newmenu(int menu); 302 void killmenu(int menu); 303 304 void AI_enemy(void); 305 ROBOT *AI_enemy_newrobot(int state,Vector pos); 306 void AI_precomputations(void); 307 void AI_deleteprecomputations(void); 308 void AI_release(void); 309 int AI_WorseMapTerrain(int x,int y,int dx,int dy); 310 void AI_newrobot(Vector pos,int owner); 311 int AI_killrobot(Vector pos); 312 void AI_moverobot(Vector oldpos,Vector newpos,int owner); 313 void AI_removebuilding(Vector pos); 314 void AI_availableoperators(Vector pos,int angle,int traction,List<AI_OPERATOR> *l); 315 bool AI_expandoperators(int x,int y,int angle,int traction,int previous,int oldcost,int depth); 316 int AI_searchengine(Vector pos,int angle,int goaltype,Vector goalpos,int traction,int depth); 317 void AI_resetsearch(Vector pos,int depth); 318 int AI_program_advance(int amount,Vector pos,int angle,int traction,bool electronics,int player,bool *pieces); 319 int AI_program_retreat(int amount,Vector pos,int angle,int traction,bool electronics,int player,bool *pieces); 320 int AI_program_capture(int goal,Vector *program_goal,Vector pos,int angle,int traction,bool electronics,int player,bool *pieces); 321 int AI_program_destroy(int goal,Vector *program_goal,Vector pos,int angle,int traction,bool electronics,int player,bool *pieces); 322 int AI_program_stopdefend(Vector *program_goal,Vector pos,int angle,int traction,bool electronics,int player,bool *pieces); 323 void AI_rankoperators_advance(List<AI_OPERATOR> *l); 324 void AI_rankoperators_retreat(List<AI_OPERATOR> *l); 325 void AI_rankoperators_capture(List<AI_OPERATOR> *l,Vector goal); 326 AI_OPERATOR *AI_chooseoperator(List<AI_OPERATOR> *l,int factor); 327 int AI_robothere(Vector pos); 328 int AI_RealShotPaths(int x,int y,int player,int persistence); 329 330 /* Game variables: */ 331 int map_w,map_h; 332 int *map; 333 float lightpos[4]; 334 Vector lightposv; 335 unsigned char old_keyboard[322]; 336 337 float zoom; 338 Vector camera,viewp; 339 Vector shipp; 340 bool shiplanded; 341 int ship_op,ship_op2,ship_op3; 342 int ship_timemoving; 343 344 List<BUILDING> buildings; 345 List<ROBOT> robots[2]; 346 List<BULLET> bullets; 347 List<EXPLOSION> explosions; 348 List<PARTICLE> particles; 349 350 int day,hour,minute,second; 351 int resources[2][7]; 352 int statistics[2][8]; 353 354 float animation_timer; 355 int construction_pointer; 356 bool construction[8]; 357 int game_state; 358 ROBOT in_construction; 359 ROBOT *controlled; 360 361 int game_finished; 362 int game_started; 363 364 /* Graphics: */ 365 int n_objs; 366 C3DObject **tile; 367 float *tile_r,*tile_g,*tile_b; 368 Shadow3DObject *ship; 369 int n_buildings; 370 Shadow3DObject **building_tile; 371 int n_pieces; 372 Piece3DObject **piece_tile[2]; 373 C3DObject *construction_tile[3]; 374 C3DObject *message_tile[3]; 375 int n_bullets; 376 Piece3DObject **bullet_tile; 377 378 /* Status variables: */ 379 List<STATUSBUTTON> buttons; 380 int act_menu; 381 int act_button; 382 int redrawmenu,redrawradar; 383 bool recomputestatistics; 384 385 /* Option/Pause menu variables: */ 386 int option_menu; 387 388 /* Artificial intelligence variables: */ 389 int *discreetmap; 390 int *bk_discreetmap; 391 AI_OPERATOR **searchmap; 392 int *atackmap; 393 394 /* Sonido: */ 395 Mix_Chunk *S_shot,*S_explosion,*S_select,*S_wrong,*S_construction; 396 397 398 }; 399 400 #endif 401