From c3785bcfcec28883252e3ca53bf71263d18cfba1 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 23 Dec 2015 16:25:25 +0000 Subject: [PATCH] Allow the player to select and fire rockets, when using a bomber. --- src/battle/ai.c | 2 -- src/battle/bullets.c | 16 +++++++++++++++- src/battle/hud.c | 2 +- src/battle/player.c | 9 ++++++++- src/battle/player.h | 1 + src/defs.h | 3 ++- src/galaxy/stats.c | 2 ++ 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/battle/ai.c b/src/battle/ai.c index 80c3ff0..8ba7ae1 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -441,8 +441,6 @@ static void preAttack(void) { fireRocket(self); - self->reload = FPS; - /* don't constantly fire rockets like normal guns */ if (rand() % 3) { diff --git a/src/battle/bullets.c b/src/battle/bullets.c index be197c1..61bb342 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -155,7 +155,14 @@ static void checkCollisions(Bullet *b) } else if (b->owner == player) { - battle.stats[STAT_SHOTS_HIT]++; + if (b->type != BT_ROCKET) + { + battle.stats[STAT_SHOTS_HIT]++; + } + else + { + battle.stats[STAT_ROCKETS_HIT]++; + } } if (!(e->flags & EF_IMMORTAL)) @@ -339,6 +346,13 @@ void fireRocket(Entity *owner) b = createBullet(BT_ROCKET, owner->x, owner->y, owner); playBattleSound(b->sound, owner->x, owner->y); + + owner->reload = FPS; + + if (owner == player) + { + battle.stats[STAT_ROCKETS_FIRED]++; + } } void fireMissile(Entity *owner) diff --git a/src/battle/hud.c b/src/battle/hud.c index a8b6067..48cb399 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -40,7 +40,7 @@ static SDL_Texture *smallFighter; static SDL_Texture *arrowLeft; static SDL_Texture *arrowRight; static int numMessages; -static char *gunName[] = {"", "Particle Cannon", "Plasma Cannon", "Laser Cannon", "Mag Cannon"}; +static char *gunName[] = {"", "Particle Cannon", "Plasma Cannon", "Laser Cannon", "Mag Cannon", "Rockets"}; void initHud(void) { diff --git a/src/battle/player.c b/src/battle/player.c index eb798db..e142a8a 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -197,7 +197,14 @@ static void handleMouse(void) { if (app.mouse.button[SDL_BUTTON_LEFT] && !player->reload && player->guns[0].type) { - fireGuns(player); + if (player->selectedGunType != BT_ROCKET) + { + fireGuns(player); + } + else + { + fireRocket(player); + } } if (app.mouse.button[SDL_BUTTON_RIGHT]) diff --git a/src/battle/player.h b/src/battle/player.h index 51d9531..26bffb6 100644 --- a/src/battle/player.h +++ b/src/battle/player.h @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern void fireGuns(Entity *owner); extern void fireMissile(Entity *owner); +extern void fireRocket(Entity *owner); extern void applyFighterThrust(void); extern void applyFighterBrakes(void); extern int getDistance(int x1, int y1, int x2, int y2); diff --git a/src/defs.h b/src/defs.h index 6402b71..3fed5da 100644 --- a/src/defs.h +++ b/src/defs.h @@ -160,7 +160,6 @@ enum BT_MAG, BT_ROCKET, BT_MISSILE, - BT_FF, BT_MAX }; @@ -251,6 +250,8 @@ enum STAT_MISSIONS_COMPLETED, STAT_SHOTS_FIRED, STAT_SHOTS_HIT, + STAT_ROCKETS_FIRED, + STAT_ROCKETS_HIT, STAT_MISSILES_FIRED, STAT_MISSILES_HIT, STAT_ENEMIES_KILLED, diff --git a/src/galaxy/stats.c b/src/galaxy/stats.c index d4eaf32..6046408 100644 --- a/src/galaxy/stats.c +++ b/src/galaxy/stats.c @@ -28,6 +28,8 @@ static char *statDescription[] = { "Missons Completed", "Shots Fired", "Shots Hit", + "Rockets Fired", + "Rockets Hit", "Missiles Fired", "Missiles Hit", "Enemies Killed",