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,45 +44,52 @@ 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)
{ {
r.x = SCREEN_WIDTH - 85; inRange = (!(e->flags & EF_SHORT_RADAR_RANGE)) ? (dist / radarRanges[battle.radarRange]) < 70 : dist < 500;
r.y = SCREEN_HEIGHT - 85;
r.x -= (player->x - e->x) / radarRanges[battle.radarRange]; if (inRange)
r.y -= (player->y - e->y) / radarRanges[battle.radarRange];
r.x--;
r.y--;
switch (e->side)
{ {
case SIDE_ALLIES: r.x = SCREEN_WIDTH - 85;
SDL_SetRenderDrawColor(app.renderer, 0, 255, 0, 255); r.y = SCREEN_HEIGHT - 85;
break;
case SIDE_PIRATE: r.x -= (player->x - e->x) / radarRanges[battle.radarRange];
case SIDE_PANDORAN: r.y -= (player->y - e->y) / radarRanges[battle.radarRange];
case SIDE_REBEL:
SDL_SetRenderDrawColor(app.renderer, 255, 0, 0, 255);
break;
case SIDE_NONE: r.x--;
r.y--;
switch (e->side)
{
case SIDE_ALLIES:
SDL_SetRenderDrawColor(app.renderer, 0, 255, 0, 255);
break;
case SIDE_PIRATE:
case SIDE_PANDORAN:
case SIDE_REBEL:
SDL_SetRenderDrawColor(app.renderer, 255, 0, 0, 255);
break;
case SIDE_NONE:
SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 255);
break;
}
if (e == player->target)
{
SDL_SetRenderDrawColor(app.renderer, 255, 255, 0, 255);
}
if (e == battle.missionTarget)
{
SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 255); SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 255);
break; }
}
if (e == player->target) SDL_RenderFillRect(app.renderer, &r);
{
SDL_SetRenderDrawColor(app.renderer, 255, 255, 0, 255);
} }
if (e == battle.missionTarget)
{
SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 255);
}
SDL_RenderFillRect(app.renderer, &r);
} }
} }
} }

View File

@ -79,24 +79,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define BF_SHIELD_DAMAGE (2 << 2) #define BF_SHIELD_DAMAGE (2 << 2)
#define BF_EXPLODES (2 << 3) #define BF_EXPLODES (2 << 3)
#define EF_NONE 0 #define EF_NONE 0
#define EF_NO_KILL (2 << 0) #define EF_NO_KILL (2 << 0)
#define EF_DISABLED (2 << 1) #define EF_DISABLED (2 << 1)
#define EF_IMMORTAL (2 << 2) #define EF_IMMORTAL (2 << 2)
#define EF_MISSION_TARGET (2 << 3) #define EF_MISSION_TARGET (2 << 3)
#define EF_NO_MT_BOX (2 << 4) #define EF_NO_MT_BOX (2 << 4)
#define EF_HAS_ROPE (2 << 5) #define EF_HAS_ROPE (2 << 5)
#define EF_COLLECTS_ITEMS (2 << 6) #define EF_COLLECTS_ITEMS (2 << 6)
#define EF_MUST_DISABLE (2 << 7) #define EF_MUST_DISABLE (2 << 7)
#define EF_RETREATING (2 << 8) #define EF_RETREATING (2 << 8)
#define EF_NO_EPIC (2 << 9) #define EF_NO_EPIC (2 << 9)
#define EF_STATIC (2 << 10) #define EF_STATIC (2 << 10)
#define EF_TAKES_DAMAGE (2 << 11) #define EF_TAKES_DAMAGE (2 << 11)
#define EF_SECONDARY_TARGET (2 << 12) #define EF_SECONDARY_TARGET (2 << 12)
#define EF_AI_TARGET (2 << 13) #define EF_AI_TARGET (2 << 13)
#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)