Allow manual switching of targets (closest). Disallow firing of missiles if target is too far away.
This commit is contained in:
parent
85364c6f55
commit
c3d07ea5a2
|
@ -94,14 +94,23 @@ void doPlayer(void)
|
||||||
|
|
||||||
if (app.keyboard[SDL_SCANCODE_RETURN] && player->missiles.ammo && player->target)
|
if (app.keyboard[SDL_SCANCODE_RETURN] && player->missiles.ammo && player->target)
|
||||||
{
|
{
|
||||||
fireMissile(player);
|
if (getDistance(player->x, player->y, player->target->x, player->target->y) <= 1000)
|
||||||
|
{
|
||||||
|
fireMissile(player);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
addHudMessage(colors.white, "Target not in range");
|
||||||
|
}
|
||||||
|
|
||||||
app.keyboard[SDL_SCANCODE_RETURN] = 0;
|
app.keyboard[SDL_SCANCODE_RETURN] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!player->target || player->target->health <= 0 || player->target->systemPower <= 0 || getDistance(player->x, player->y, player->target->x, player->target->y) > 1000)
|
if (!player->target || player->target->health <= 0 || player->target->systemPower <= 0 || app.keyboard[SDLK_t])
|
||||||
{
|
{
|
||||||
selectTarget();
|
selectTarget();
|
||||||
|
|
||||||
|
app.keyboard[SDLK_t] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!battle.missionTarget)
|
if (!battle.missionTarget)
|
||||||
|
@ -150,12 +159,7 @@ static void selectTarget(void)
|
||||||
|
|
||||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||||
{
|
{
|
||||||
if (!e->active)
|
if (e->active && e != player && e->type == ET_FIGHTER && e->side != player->side && e->alive == ALIVE_ALIVE)
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e != player && e->type == ET_FIGHTER && e->side != player->side && e->alive == ALIVE_ALIVE)
|
|
||||||
{
|
{
|
||||||
dist = getDistance(self->x, self->y, e->x, e->y);
|
dist = getDistance(self->x, self->y, e->x, e->y);
|
||||||
if (dist < closest)
|
if (dist < closest)
|
||||||
|
@ -177,12 +181,7 @@ static void selectMissionTarget(void)
|
||||||
|
|
||||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||||
{
|
{
|
||||||
if (!e->active)
|
if (e->active && e->flags & EF_MISSION_TARGET && e->alive == ALIVE_ALIVE)
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e->flags & EF_MISSION_TARGET && e->alive == ALIVE_ALIVE)
|
|
||||||
{
|
{
|
||||||
if (battle.missionTarget == NULL)
|
if (battle.missionTarget == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,8 +29,10 @@ extern void applyFighterThrust(void);
|
||||||
extern void applyFighterBrakes(void);
|
extern void applyFighterBrakes(void);
|
||||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
extern int getDistance(int x1, int y1, int x2, int y2);
|
||||||
extern void failIncompleteObjectives(void);
|
extern void failIncompleteObjectives(void);
|
||||||
|
extern void addHudMessage(SDL_Color c, char *format, ...);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
|
extern Colors colors;
|
||||||
extern Entity *player;
|
extern Entity *player;
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
|
|
Loading…
Reference in New Issue