Allow AI to drop mines.
This commit is contained in:
parent
58fb3e911b
commit
d178134a00
|
@ -52,9 +52,15 @@ static void moveToLeader(void);
|
||||||
static void wander(void);
|
static void wander(void);
|
||||||
static void doWander(void);
|
static void doWander(void);
|
||||||
static int selectWeaponForTarget(Entity *e);
|
static int selectWeaponForTarget(Entity *e);
|
||||||
|
static void deployMine(void);
|
||||||
|
|
||||||
void doAI(void)
|
void doAI(void)
|
||||||
{
|
{
|
||||||
|
if (self->aiFlags & AIF_DROPS_MINES)
|
||||||
|
{
|
||||||
|
deployMine();
|
||||||
|
}
|
||||||
|
|
||||||
if ((self->aiFlags & (AIF_AVOIDS_COMBAT | AIF_EVADE)) && nearEnemies())
|
if ((self->aiFlags & (AIF_AVOIDS_COMBAT | AIF_EVADE)) && nearEnemies())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -618,6 +624,21 @@ static int nearEnemies(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void deployMine(void)
|
||||||
|
{
|
||||||
|
Entity *mine;
|
||||||
|
|
||||||
|
if (!self->reload)
|
||||||
|
{
|
||||||
|
mine = spawnMine();
|
||||||
|
mine->x = self->x;
|
||||||
|
mine->y = self->y;
|
||||||
|
mine->side = self->side;
|
||||||
|
|
||||||
|
self->reload = FPS + (FPS * (rand() % 5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int nearMines(void)
|
static int nearMines(void)
|
||||||
{
|
{
|
||||||
int i, numMines;
|
int i, numMines;
|
||||||
|
@ -631,7 +652,7 @@ static int nearMines(void)
|
||||||
|
|
||||||
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
|
||||||
{
|
{
|
||||||
if (e->type == ET_MINE && getDistance(e->x, e->y, self->x, self->y) < 500)
|
if (e->side != self->side && e->type == ET_MINE && getDistance(e->x, e->y, self->x, self->y) < 500)
|
||||||
{
|
{
|
||||||
self->targetLocation.x += e->x;
|
self->targetLocation.x += e->x;
|
||||||
self->targetLocation.y += e->y;
|
self->targetLocation.y += e->y;
|
||||||
|
|
|
@ -38,6 +38,7 @@ extern void applyFighterBrakes(void);
|
||||||
extern void addHudMessage(SDL_Color c, char *format, ...);
|
extern void addHudMessage(SDL_Color c, char *format, ...);
|
||||||
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
||||||
extern char *getTranslatedString(char *string);
|
extern char *getTranslatedString(char *string);
|
||||||
|
extern Entity *spawnMine(void);
|
||||||
|
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
|
|
@ -118,6 +118,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define AIF_WANDERS (2 << 14)
|
#define AIF_WANDERS (2 << 14)
|
||||||
#define AIF_COVERS_RETREAT (2 << 15)
|
#define AIF_COVERS_RETREAT (2 << 15)
|
||||||
#define AIF_TARGET_FOCUS (2 << 16)
|
#define AIF_TARGET_FOCUS (2 << 16)
|
||||||
|
#define AIF_DROPS_MINES (2 << 17)
|
||||||
|
|
||||||
/* player abilities */
|
/* player abilities */
|
||||||
#define BOOST_RECHARGE_TIME (FPS * 7)
|
#define BOOST_RECHARGE_TIME (FPS * 7)
|
||||||
|
|
|
@ -81,6 +81,7 @@ void initLookups(void)
|
||||||
addLookup("AIF_WANDERS", AIF_WANDERS);
|
addLookup("AIF_WANDERS", AIF_WANDERS);
|
||||||
addLookup("AIF_COVERS_RETREAT", AIF_COVERS_RETREAT);
|
addLookup("AIF_COVERS_RETREAT", AIF_COVERS_RETREAT);
|
||||||
addLookup("AIF_TARGET_FOCUS", AIF_TARGET_FOCUS);
|
addLookup("AIF_TARGET_FOCUS", AIF_TARGET_FOCUS);
|
||||||
|
addLookup("AIF_DROPS_MINES", AIF_DROPS_MINES);
|
||||||
|
|
||||||
addLookup("DT_ANY", DT_ANY);
|
addLookup("DT_ANY", DT_ANY);
|
||||||
addLookup("DT_NO_SPIN", DT_NO_SPIN);
|
addLookup("DT_NO_SPIN", DT_NO_SPIN);
|
||||||
|
|
Loading…
Reference in New Issue