#endif
#else
- rv = set_gfx_mode(GFX_AUTODETECT, 800, 600, 0, 0);
+ rv = set_gfx_mode(prefer_window ?
+ GFX_AUTODETECT_WINDOWED : GFX_AUTODETECT,
+ 800, 600, 0, 0);
#endif
if (rv != 0)
void gfx_draw_scanner (void)
{
- blit (scanner_image, gfx_screen, 0, 0, GFX_X_OFFSET, 385+GFX_Y_OFFSET, scanner_image->w, scanner_image->h);
+ set_clip(gfx_screen, GFX_X_OFFSET, 385 + GFX_Y_OFFSET,
+ GFX_X_OFFSET + scanner_image->w,
+ GFX_Y_OFFSET + scanner_image->h + 385);
+ blit (scanner_image, gfx_screen, 0, 0, GFX_X_OFFSET,
+ 385+GFX_Y_OFFSET, scanner_image->w, scanner_image->h);
}
void gfx_set_clip_region (int tx, int ty, int bx, int by)
int climbing;
int game_paused;
int have_joystick;
+int identify;
+int scanner_zoom = 1;
int find_input;
char find_name[20];
{
cross_timer = 5;
+ if (kbd_ctrl_pressed) {
+ dx *= 4;
+ dy *= 4;
+ }
+
if (current_screen == SCR_SHORT_RANGE)
{
cross_x += (dx * 4);
if (kbd_n_pressed)
n_pressed();
+ if (kbd_i_pressed == 1)
+ identify = !identify;
+ if (kbd_zoom_pressed == 1)
+ scanner_zoom ^= 3;
if (kbd_fire_pressed)
{
snd_play_midi (SND_ELITE_THEME, TRUE);
initialise_intro1();
+ identify = 0;
for (;;)
{
snd_play_midi (SND_BLUE_DANUBE, TRUE);
+ identify = 0;
initialise_intro2();
flight_speed = 3;
flight_speed = 6;
flight_roll = 0;
flight_climb = 0;
+ identify = 0;
clear_universe();
set_init_matrix (rotmat);
#include "planet.h"
#include "shipdata.h"
#include "space.h"
-
+#include "keyboard.h"
"Docked",
"Green",
"Yellow",
+ "Red",
"Red"
};
char str[100];
int i;
int x,y;
- int condition;
- int type;
current_screen = SCR_CMDR_STATUS;
sprintf (str, "%s", planet_name);
gfx_display_text (190, 74, str);
- if (docked)
- condition = 0;
- else
- {
- condition = 1;
-
- for (i = 0; i < MAX_UNIV_OBJECTS; i++)
- {
- type = universe[i].type;
-
- if ((type == SHIP_MISSILE) ||
- ((type > SHIP_ROCK) && (type < SHIP_DODEC)))
- {
- condition = 2;
- break;
- }
- }
-
- if ((condition == 2) && (energy < 128))
- condition = 3;
- }
-
gfx_display_colour_text (16, 90, "Condition:", GFX_COL_GREEN_1);
gfx_display_text (190, 90, condition_txt[condition]);
return;
item = &stock_market[hilite_item];
-
- if ((item->current_quantity == 0) ||
- (cmdr.credits < item->current_price))
+
+ do {
+ if ((item->current_quantity == 0) ||
+ (cmdr.credits < item->current_price))
return;
- cargo_held = total_cargo();
+ cargo_held = total_cargo();
- if ((item->units == TONNES) &&
- (cargo_held == cmdr.cargo_capacity))
+ if ((item->units == TONNES) &&
+ (cargo_held == cmdr.cargo_capacity))
return;
- cmdr.current_cargo[hilite_item]++;
- item->current_quantity--;
- cmdr.credits -= item->current_price;
+ cmdr.current_cargo[hilite_item]++;
+ item->current_quantity--;
+ cmdr.credits -= item->current_price;
- highlight_stock (hilite_item);
+ highlight_stock (hilite_item);
+ } while (kbd_ctrl_pressed);
}
void sell_stock (void)
{
struct stock_item *item;
-
- if ((!docked) || (cmdr.current_cargo[hilite_item] == 0))
+
+ do {
+ if ((!docked) || (cmdr.current_cargo[hilite_item] == 0))
return;
- item = &stock_market[hilite_item];
+ item = &stock_market[hilite_item];
- cmdr.current_cargo[hilite_item]--;
- item->current_quantity++;
- cmdr.credits += item->current_price;
+ cmdr.current_cargo[hilite_item]--;
+ item->current_quantity++;
+ cmdr.credits += item->current_price;
- highlight_stock (hilite_item);
+ highlight_stock (hilite_item);
+ } while (kbd_ctrl_pressed);
}
int laser_temp;
int detonate_bomb;
int auto_pilot;
+int prefer_window;
+int condition_x, condition_y, condition_r;
+int zoom_x, zoom_y;
+int condition = COND_DOCKED;
struct commander saved_cmdr =
{
#define FLG_SLOW (2048)
#define FLG_BOLD (4096)
#define FLG_POLICE (8192)
-
+#define FLG_TACTICAL (16384)
+#define FLG_TARGET (32768)
#define MAX_UNIV_OBJECTS 20
extern int scanner_cy;
extern int compass_centre_x;
extern int compass_centre_y;
+extern int prefer_window;
+extern int condition_x, condition_y, condition_r;
+extern int zoom_x, zoom_y;
+
+extern int condition;
+enum {
+ COND_DOCKED, COND_GREEN, COND_YELLOW, COND_RED, COND_ALERT
+};
extern int planet_render_style;
extern int detonate_bomb;
extern int witchspace;
extern int auto_pilot;
-
+extern int identify;
+extern int scanner_zoom;
void restore_saved_commander (void);
fprintf (fp, "%d\t\t# Instant dock: 0 = off, 1 = on\n", instant_dock);
fprintf (fp, "newscan.cfg\t# Name of scanner config file to use.\n");
+ fprintf (fp, "%d\t\t# Run in a window: 0 = off, 1 = on\n", prefer_window);
fclose (fp);
}
sscanf (str, "%d,%d", &compass_centre_x, &compass_centre_y);
compass_centre_y += 385;
+ read_cfg_line (str, sizeof(str), fp);
+ sscanf (str, "%d,%d,%d", &condition_x, &condition_y, &condition_r);
+ condition_y += 385;
+
+ read_cfg_line (str, sizeof(str), fp);
+ sscanf (str, "%d,%d", &zoom_x, &zoom_y);
+ zoom_y += 385;
+
fclose (fp);
}
read_cfg_line (str, sizeof(str), fp);
read_scanner_config_file (str);
+
+ read_cfg_line (str, sizeof(str), fp);
+ sscanf (str, "%d", &prefer_window);
fclose (fp);
}
int kbd_F12_pressed;
int kbd_y_pressed;
int kbd_n_pressed;
+int kbd_zoom_pressed;
int kbd_fire_pressed;
int kbd_ecm_pressed;
int kbd_energy_bomb_pressed;
int kbd_pause_pressed;
int kbd_resume_pressed;
int kbd_inc_speed_pressed;
+int kbd_i_pressed;
int kbd_dec_speed_pressed;
int kbd_up_pressed;
int kbd_down_pressed;
int kbd_backspace_pressed;
int kbd_space_pressed;
+static char old_key[KEY_MAX];
int kbd_keyboard_startup (void)
{
void kbd_poll_keyboard (void)
{
+ int i;
poll_keyboard();
+ for (i = 0; i < KEY_MAX; i++) {
+ if (!key[i])
+ continue;
+ key[i] = 1;
+ if (key[i] && old_key[i])
+ key[i] |= 2;
+ }
+ memcpy(old_key, key, KEY_MAX);
kbd_F1_pressed = key[KEY_F1];
kbd_F2_pressed = key[KEY_F2];
kbd_y_pressed = key[KEY_Y];
kbd_n_pressed = key[KEY_N];
+ kbd_zoom_pressed = key[KEY_Z];
kbd_fire_pressed = key[KEY_A];
kbd_ecm_pressed = key[KEY_E];
kbd_origin_pressed = key[KEY_O];
kbd_find_pressed = key[KEY_F];
+ kbd_i_pressed = key[KEY_I];
+
kbd_fire_missile_pressed = key[KEY_M];
kbd_target_missile_pressed = key[KEY_T];
kbd_unarm_missile_pressed = key[KEY_U];
extern int kbd_F12_pressed;
extern int kbd_y_pressed;
extern int kbd_n_pressed;
+extern int kbd_zoom_pressed;
extern int kbd_fire_pressed;
extern int kbd_ecm_pressed;
extern int kbd_energy_bomb_pressed;
extern int kbd_d_pressed;
extern int kbd_origin_pressed;
extern int kbd_find_pressed;
+extern int kbd_i_pressed;
extern int kbd_fire_missile_pressed;
extern int kbd_target_missile_pressed;
extern int kbd_unarm_missile_pressed;
flight_roll = 0;
flight_climb = 0;
flight_speed = 0;
+ identify = 0;
do
{
{
if (universe[i].flags & FLG_REMOVE)
{
- if (type == SHIP_VIPER)
+ if (type == SHIP_VIPER ||
+ !(universe[i].flags & FLG_TARGET))
cmdr.legal_status |= 64;
bounty = ship_list[type]->bounty;
if ((bounty != 0) && (!witchspace))
{
cmdr.credits += bounty;
- sprintf (str, "%d.%d CR", cmdr.credits / 10, cmdr.credits % 10);
+ sprintf (str, "Bounty: %d.%d CR", bounty / 10, bounty % 10);
info_message (str);
}
(universe[i].flags & FLG_CLOAKED))
continue;
- x = universe[i].location.x / 256;
- y = universe[i].location.y / 256;
- z = universe[i].location.z / 256;
+ x = universe[i].location.x * scanner_zoom / 256;
+ y = universe[i].location.y * scanner_zoom / 256;
+ z = universe[i].location.z * scanner_zoom / 256;
x1 = x;
y1 = -z / 4;
}
+
+void display_condition(void)
+{
+ static const int cc[] = { GFX_COL_BLACK, GFX_COL_GREEN_1, GFX_COL_YELLOW_1,
+ GFX_COL_RED, GFX_COL_RED };
+ int c = cc[condition];
+ if (condition == COND_ALERT && (mcount & 4))
+ c = GFX_COL_BLACK;
+ gfx_draw_filled_circle(condition_x, condition_y, condition_r, c);
+}
+
void update_console (void)
{
- gfx_set_clip_region (0, 0, 512, 512);
gfx_draw_scanner();
display_speed();
display_laser_temp();
display_fuel();
display_missiles();
+ update_condition();
- if (docked)
- return;
+ if (docked) {
+ gfx_set_clip_region (0, 0, 512, 512);
+ return;
+ }
update_scanner();
update_compass();
+ display_condition();
+
+ {
+ char buf[5];
+ sprintf(buf, "x%d", scanner_zoom);
+ gfx_display_text(zoom_x, zoom_y, buf);
+ }
if (ship_count[SHIP_CORIOLIS] || ship_count[SHIP_DODEC])
gfx_draw_sprite (IMG_BIG_S, 387, 490);
if (ecm_active)
gfx_draw_sprite (IMG_BIG_E, 115, 490);
+
+ gfx_set_clip_region (0, 0, 512, 512);
}
void increase_flight_roll (void)
hyper_distance = calc_distance_to_planet (docked_planet, hyperspace_planet);
- if ((hyper_distance == 0) || (hyper_distance > cmdr.fuel))
+ if ((docked_planet.a == hyperspace_planet.a &&
+ docked_planet.b == hyperspace_planet.b &&
+ docked_planet.c == hyperspace_planet.c &&
+ docked_planet.d == hyperspace_planet.d &&
+ docked_planet.e == hyperspace_planet.e &&
+ docked_planet.f == hyperspace_planet.f) ||
+ (hyper_distance > cmdr.fuel))
return;
destination_planet = hyperspace_planet;
generate_landscape(docked_planet.a * 251 + docked_planet.b);
set_init_matrix (rotmat);
add_new_ship (SHIP_PLANET, 0, 0, 65536, rotmat, 0, 0);
+ identify = 0;
+ scanner_zoom = 1;
rotmat[2].x = -rotmat[2].x;
rotmat[2].y = -rotmat[2].y;
{
if (ship_count[SHIP_CORIOLIS] || ship_count[SHIP_DODEC])
{
- snd_play_sample (SND_DOCK);
+ snd_play_sample (SND_DOCK);
dock_player();
current_screen = SCR_BREAK_PATTERN;
}
}
+
+void update_condition(void)
+{
+ if (docked)
+ condition = COND_DOCKED;
+ else if (energy < 50 || myship.altitude < 32 || myship.cabtemp > 224)
+ condition = COND_ALERT;
+ else if (energy < 128 || myship.altitude < 64 || myship.cabtemp > 192)
+ condition = COND_RED;
+ else {
+ int i;
+ condition = COND_GREEN;
+ if (myship.altitude < 128 || myship.cabtemp >= 128)
+ condition = COND_YELLOW;
+ for (i = 0; i < MAX_UNIV_OBJECTS; i++) {
+ struct univ_object *un = &universe[i];
+ if (un->type <= 0)
+ continue;
+ if (un->flags & FLG_HOSTILE) {
+ condition = COND_RED;
+ break;
+ }
+ if (condition == COND_GREEN &&
+ un->type != SHIP_ASTEROID && un->type != SHIP_CARGO &&
+ un->type != SHIP_ALLOY && un->type != SHIP_ROCK &&
+ un->type != SHIP_BOULDER && un->type != SHIP_ESCAPE_CAPSULE &&
+ un->type != SHIP_CORIOLIS && un->type != SHIP_DODEC)
+ condition = COND_YELLOW;
+ }
+ }
+}
void launch_player (void);
void engage_docking_computer (void);
+void display_condition(void);
+void update_condition(void);
#endif
int initial_flags[NO_OF_SHIPS + 1] =
{
0, // NULL,
- 0, // missile
+ FLG_TARGET, // missile
0, // coriolis
FLG_SLOW | FLG_FLY_TO_PLANET, // escape
- FLG_INACTIVE, // alloy
- FLG_INACTIVE, // cargo
- FLG_INACTIVE, // boulder
- FLG_INACTIVE, // asteroid
- FLG_INACTIVE, // rock
+ FLG_INACTIVE | FLG_TARGET, // alloy
+ FLG_INACTIVE | FLG_TARGET, // cargo
+ FLG_INACTIVE | FLG_TARGET, // boulder
+ FLG_INACTIVE | FLG_TARGET, // asteroid
+ FLG_INACTIVE | FLG_TARGET, // rock
FLG_FLY_TO_PLANET | FLG_SLOW, // shuttle
FLG_FLY_TO_PLANET | FLG_SLOW, // transporter
0, // cobra3
FLG_SLOW, // anaconda
FLG_SLOW, // hermit
FLG_BOLD | FLG_POLICE, // viper
- FLG_BOLD | FLG_ANGRY, // sidewinder
- FLG_BOLD | FLG_ANGRY, // mamba
- FLG_BOLD | FLG_ANGRY, // krait
- FLG_BOLD | FLG_ANGRY, // adder
- FLG_BOLD | FLG_ANGRY, // gecko
- FLG_BOLD | FLG_ANGRY, // cobra1
- FLG_SLOW | FLG_ANGRY, // worm
- FLG_BOLD | FLG_ANGRY, // cobra3
- FLG_BOLD | FLG_ANGRY, // asp2
- FLG_BOLD | FLG_ANGRY, // python
- FLG_POLICE, // fer_de_lance
- FLG_BOLD | FLG_ANGRY, // moray
- FLG_BOLD | FLG_ANGRY, // thargoid
- FLG_ANGRY, // thargon
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // sidewinder
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // mamba
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // krait
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // adder
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // gecko
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // cobra1
+ FLG_SLOW | FLG_ANGRY | FLG_TARGET, // worm
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // cobra3
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // asp2
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // python
+ FLG_POLICE, // fer_de_lance
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // moray
+ FLG_BOLD | FLG_ANGRY | FLG_TARGET, // thargoid
+ FLG_ANGRY | FLG_TARGET, // thargon
FLG_ANGRY, // constrictor
FLG_POLICE | FLG_CLOAKED, // cougar
0 // dodec
type = universe[un].type;
flags = universe[un].flags;
- if (flags & FLG_INACTIVE)
- return;
-
+ if (flags & FLG_INACTIVE) {
+ universe[un].flags |= FLG_TACTICAL;
+ return;
+ }
+
if ((type == SHIP_CORIOLIS) || (type == SHIP_DODEC))
{
universe[un].flags |= FLG_ANGRY;
{
universe[un].rotx = 4;
universe[un].acceleration = 2;
- universe[un].flags |= FLG_ANGRY;
+ universe[un].flags |= FLG_ANGRY | FLG_TACTICAL;
}
}
ns = &universe[newship];
ns->velocity = flight_speed * 2;
- ns->flags = FLG_ANGRY;
+ ns->flags |= FLG_TACTICAL;
ns->target = missile_target;
if (universe[missile_target].type > SHIP_ROCK)
activate_ecm (0);
return;
}
- }
+ }
+
+ if ((rand255() < 16) &&
+ (ship_count[SHIP_CORIOLIS] || ship_count[SHIP_DODEC])) {
+ activate_ecm(0);
+ return;
+ }
nvec = unit_vector(&vec);
direction = vector_dot_product (&nvec, &missile->rotmat[2]);
if (rand255() > 200)
{
launch_enemy (un, SHIP_SIDEWINDER + (rand255() & 3), FLG_ANGRY | FLG_HAS_ECM, 113);
- ship->flags |= FLG_INACTIVE;
+ ship->flags |= FLG_INACTIVE | FLG_TARGET;
}
return;
if ((type == SHIP_THARGLET) && (ship_count[SHIP_THARGOID] == 0))
{
- ship->flags = 0;
+ ship->flags &= FLG_TARGET | FLG_TACTICAL;
ship->velocity /= 2;
return;
}
(ship->missiles >= (rand255() & 31)))
{
ship->missiles--;
+ ship->flags |= FLG_TACTICAL;
if (type == SHIP_THARGOID)
launch_enemy (un, SHIP_THARGLET, FLG_ANGRY, ship->bravery);
else
{
launch_enemy (un, SHIP_MISSILE, FLG_ANGRY, 126);
+ ship->flags |= FLG_HOSTILE;
info_message ("INCOMING MISSILE");
}
return;
(ship_list[type]->laser_strength != 0))
{
if (direction <= -0.917)
- ship->flags |= FLG_FIRING | FLG_HOSTILE;
+ ship->flags |= FLG_FIRING | FLG_HOSTILE | FLG_TACTICAL;
if (direction <= -0.972)
{
newship = create_other_ship (SHIP_THARGOID);
if (newship != -1)
{
- universe[newship].flags = FLG_ANGRY | FLG_HAS_ECM;
+ universe[newship].flags = FLG_ANGRY | FLG_HAS_ECM | FLG_TARGET;
universe[newship].bravery = 113;
if (rand255() > 64)
- launch_enemy (newship, SHIP_THARGLET, FLG_ANGRY | FLG_HAS_ECM, 96);
+ launch_enemy (newship, SHIP_THARGLET, FLG_ANGRY | FLG_HAS_ECM,
+ 96);
+ in_battle = 1;
}
}
if (rnd & 1)
universe[newship].flags |= FLG_HAS_ECM;
-// if (rnd & 2)
-// universe[newship].flags |= FLG_ANGRY;
+ if (rnd > 200)
+ universe[newship].flags |= FLG_ANGRY | FLG_TARGET;
}
}
if (newship != -1)
{
- universe[newship].flags = FLG_ANGRY;
+ // universe[newship].flags = FLG_ANGRY;
if ((rand255() > 200) || (type == SHIP_CONSTRICTOR))
universe[newship].flags |= FLG_HAS_ECM;
universe[newship].bravery = ((rand255() * 2) | 64) & 127;
- in_battle = 1;
+ if (type == SHIP_FER_DE_LANCE) {
+ if (rand255() > 160)
+ universe[newship].flags |= FLG_ANGRY | FLG_TARGET;
+ else {
+ universe[newship].rotmat[2].z = -1.0;
+ universe[newship].rotz = rand255() & 7;
+ rnd = rand255();
+ universe[newship].velocity = (rnd & 31) | 16;
+ }
+ }
+
+ if (universe[newship].flags & FLG_ANGRY)
+ in_battle = 1;
}
}
if (newship != -1)
{
- universe[newship].flags = FLG_ANGRY;
+ universe[newship].flags |= FLG_ANGRY;
if (rand255() > 245)
universe[newship].flags |= FLG_HAS_ECM;
newship = add_new_ship (type, x, y, z, rotmat, 0, 0);
if (newship != -1)
{
- universe[newship].flags = FLG_ANGRY;
+ universe[newship].flags |= FLG_ANGRY | FLG_TARGET;
if (rand255() > 245)
universe[newship].flags |= FLG_HAS_ECM;
static struct point point_list[100];
+static void identify_ship(struct univ_object *univ)
+{
+ char buf[64];
+ int lasv;
+
+ lasv = ship_list[univ->type]->front_laser;
+ if (!(univ->flags & FLG_TACTICAL)) {
+#ifdef HACKING
+ unsigned flags = univ->flags;
+ sprintf(buf, "%s %s%s%s%s", ship_list[univ->type]->name,
+ (flags & FLG_ANGRY) ? "A" : "",
+ (flags & FLG_TARGET) ? "T" : "",
+ (flags & FLG_HOSTILE) ? "H" : "",
+ (flags & FLG_POLICE) ? "P" : "");
+#else
+ sprintf(buf, "%s", ship_list[univ->type]->name);
+#endif
+ } else {
+#ifdef HACKING
+ unsigned flags = univ->flags;
+ sprintf(buf, "%s (%d) %s%s%s%s", ship_list[univ->type]->name,
+ univ->energy,
+ (flags & FLG_ANGRY) ? "A" : "",
+ (flags & FLG_TARGET) ? "T" : "",
+ (flags & FLG_HOSTILE) ? "H" : "",
+ (flags & FLG_POLICE) ? "P" : "");
+#else
+ sprintf(buf, "%s (%d)", ship_list[univ->type]->name, univ->energy);
+#endif
+ }
+ gfx_display_text(point_list[lasv].x + 4, point_list[lasv].y + 4, buf);
+}
/*
* The following routine is used to draw a wireframe represtation of a ship.
gfx_draw_line (point_list[lasv].x, point_list[lasv].y,
univ->location.x > 0 ? 0 : 511, rand255() * 2);
}
+
+ if (identify)
+ identify_ship(univ);
}
univ->location.x > 0 ? 0 : 511, rand255() * 2,
point_list[lasv].z, col);
}
+
+ if (identify)
+ identify_ship(univ);
}
if ((cmdr.fuel_scoop == 0) || (universe[un].location.y >= 0) ||
(total_cargo() == cmdr.cargo_capacity))
{
+ universe[un].flags |= FLG_TARGET;
explode_object (un);
damage_ship (128 + (universe[un].energy / 2), universe[un].location.z > 0);
return;