From f304e8ca5b5a065fef700d03fd772f334196a6d3 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 22 Nov 2015 08:17:29 +0000 Subject: [PATCH] Allow AI to fire rockets. --- src/battle/ai.c | 29 ++++++++++++++++++++++------- src/battle/ai.h | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/battle/ai.c b/src/battle/ai.c index aece224..54aef6d 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -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; + } } } } diff --git a/src/battle/ai.h b/src/battle/ai.h index 074126d..8579789 100644 --- a/src/battle/ai.h +++ b/src/battle/ai.h @@ -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);