Allow AI to fire rockets.

This commit is contained in:
Steve 2015-11-22 08:17:29 +00:00
parent bbd61bf8ba
commit f304e8ca5b
2 changed files with 23 additions and 7 deletions

View File

@ -371,6 +371,8 @@ static int hasClearShot(void)
static void preAttack(void) static void preAttack(void)
{ {
if (!self->reload) if (!self->reload)
{
if (!(self->aiFlags & AIF_MISSILE_BOAT))
{ {
/* force weapon selection, otherwise we'll keep using lasers / mag */ /* force weapon selection, otherwise we'll keep using lasers / mag */
canAttack(self->target); canAttack(self->target);
@ -384,6 +386,19 @@ static void preAttack(void)
fireMissile(self); fireMissile(self);
} }
} }
else
{
fireRocket(self);
self->reload = FPS;
/* don't constantly fire rockets like normal guns */
if (rand() % 5)
{
self->action = doAI;
}
}
}
} }
static void flyStraight(void) static void flyStraight(void)

View File

@ -36,6 +36,7 @@ extern int mod(int n, int x);
extern int getDistance(int x1, int y1, int x2, int y2); extern int getDistance(int x1, int y1, int x2, int y2);
extern void fireGuns(Entity *owner); extern void fireGuns(Entity *owner);
extern void fireMissile(Entity *owner); extern void fireMissile(Entity *owner);
extern void fireRocket(Entity *owner);
extern float getAngle(int x1, int y1, int x2, int y2); extern float getAngle(int x1, int y1, int x2, int y2);
extern void applyFighterThrust(void); extern void applyFighterThrust(void);
extern void applyFighterBrakes(void); extern void applyFighterBrakes(void);