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

@ -372,16 +372,31 @@ static void preAttack(void)
{
if (!self->reload)
{
/* force weapon selection, otherwise we'll keep using lasers / mag */
canAttack(self->target);
if (self->guns[0].type && (self->missiles == 0 || rand() % 50 > 0))
if (!(self->aiFlags & AIF_MISSILE_BOAT))
{
fireGuns(self);
/* force weapon selection, otherwise we'll keep using lasers / mag */
canAttack(self->target);
if (self->guns[0].type && (self->missiles == 0 || rand() % 50 > 0))
{
fireGuns(self);
}
else if (self->missiles)
{
fireMissile(self);
}
}
else if (self->missiles)
else
{
fireMissile(self);
fireRocket(self);
self->reload = FPS;
/* don't constantly fire rockets like normal guns */
if (rand() % 5)
{
self->action = doAI;
}
}
}
}

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 void fireGuns(Entity *owner);
extern void fireMissile(Entity *owner);
extern void fireRocket(Entity *owner);
extern float getAngle(int x1, int y1, int x2, int y2);
extern void applyFighterThrust(void);
extern void applyFighterBrakes(void);