Mines have a short radar range.

This commit is contained in:
Steve 2016-03-30 22:41:34 +01:00
parent 3646a9326a
commit daa8eff104
3 changed files with 71 additions and 54 deletions

View File

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mine.h" #include "mine.h"
static void think(void); static void think(void);
static void die(void);
static void lookForFighters(void); static void lookForFighters(void);
Entity *spawnMine(void) Entity *spawnMine(void)
@ -31,6 +32,8 @@ Entity *spawnMine(void)
mine->health = mine->maxHealth = 1; mine->health = mine->maxHealth = 1;
mine->texture = getTexture("gfx/entities/mine.png"); mine->texture = getTexture("gfx/entities/mine.png");
mine->action = think; mine->action = think;
mine->die = die;
mine->flags = EF_TAKES_DAMAGE+EF_SHORT_RADAR_RANGE;
return mine; return mine;
} }
@ -47,6 +50,13 @@ static void think(void)
lookForFighters(); lookForFighters();
} }
static void die(void)
{
addMineExplosion();
self->alive = ALIVE_DEAD;
}
static void lookForFighters(void) static void lookForFighters(void)
{ {
Entity *e, **candidates; Entity *e, **candidates;
@ -59,8 +69,6 @@ static void lookForFighters(void)
if (e->health > 0 && e->type == ET_FIGHTER && getDistance(self->x, self->y, e->x, e->y) <= 128) if (e->health > 0 && e->type == ET_FIGHTER && getDistance(self->x, self->y, e->x, e->y) <= 128)
{ {
self->health = 0; self->health = 0;
addMineExplosion();
} }
} }
} }

View File

@ -34,6 +34,7 @@ void drawRadar(void)
{ {
SDL_Rect r; SDL_Rect r;
Entity *e; Entity *e;
int dist, inRange;
blit(radarTexture, SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 1); blit(radarTexture, SCREEN_WIDTH - 85, SCREEN_HEIGHT - 85, 1);
@ -43,7 +44,13 @@ void drawRadar(void)
for (e = battle.entityHead.next ; e != NULL ; e = e->next) for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{ {
if (e->active && getDistance(e->x, e->y, player->x, player->y) / radarRanges[battle.radarRange] < 70) dist = getDistance(e->x, e->y, player->x, player->y);
if (e->active)
{
inRange = (!(e->flags & EF_SHORT_RADAR_RANGE)) ? (dist / radarRanges[battle.radarRange]) < 70 : dist < 500;
if (inRange)
{ {
r.x = SCREEN_WIDTH - 85; r.x = SCREEN_WIDTH - 85;
r.y = SCREEN_HEIGHT - 85; r.y = SCREEN_HEIGHT - 85;
@ -85,6 +92,7 @@ void drawRadar(void)
} }
} }
} }
}
void drawRadarRangeWarning(void) void drawRadarRangeWarning(void)
{ {

View File

@ -97,6 +97,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define EF_AI_LEADER (2 << 14) #define EF_AI_LEADER (2 << 14)
#define EF_ROPED_ATTACHED (2 << 15) #define EF_ROPED_ATTACHED (2 << 15)
#define EF_NO_KILL_INC (2 << 16) #define EF_NO_KILL_INC (2 << 16)
#define EF_SHORT_RADAR_RANGE (2 << 17)
#define AIF_NONE 0 #define AIF_NONE 0
#define AIF_FOLLOWS_PLAYER (2 << 0) #define AIF_FOLLOWS_PLAYER (2 << 0)