From cca3dedf7aee37346499890ec94d6744db192360 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 15 Nov 2015 23:23:03 +0000 Subject: [PATCH] Boost and speed limit tweaks. --- src/battle/fighters.c | 2 +- src/battle/player.c | 28 +++++++++++++++++++++++----- src/defs.h | 4 ++-- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/battle/fighters.c b/src/battle/fighters.c index d0806f7..1e98ea9 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -355,7 +355,7 @@ void applyFighterThrust(void) self->dy += -cos(TO_RAIDANS(self->angle)) * 0.1; self->thrust = sqrt((self->dx * self->dx) + (self->dy * self->dy)); - while (self->thrust > self->speed * self->speed) + if (self->thrust > self->speed * self->speed) { v = (self->speed / sqrt(self->thrust)); self->dx = v * self->dx; diff --git a/src/battle/player.c b/src/battle/player.c index 326a387..09526bc 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -26,6 +26,7 @@ static void selectMissionTarget(void); static void selectNewPlayer(int dir); static void initPlayerSelect(void); static void activateBoost(void); +static void deactivateBoost(void); static void activateECM(void); static int selectedPlayerIndex; @@ -68,11 +69,6 @@ void doPlayer(void) battle.boostTimer = MIN(battle.boostTimer + 1, BOOST_RECHARGE_TIME); battle.ecmTimer = MIN(battle.ecmTimer + 1, ECM_RECHARGE_TIME); - if (battle.boostTimer == (int)BOOST_FINISHED_TIME) - { - applyFighterThrust(); - } - if (player != NULL) { self = player; @@ -164,6 +160,11 @@ void doPlayer(void) } } } + + if (battle.boostTimer == (int)BOOST_FINISHED_TIME) + { + deactivateBoost(); + } } void initPlayerSelect(void) @@ -247,6 +248,23 @@ static void activateBoost(void) battle.boostTimer = 0; } +static void deactivateBoost(void) +{ + float v, thrust; + + thrust = -1; + + while (thrust != self->thrust) + { + thrust = self->thrust; + + v = (self->speed / sqrt(self->thrust)); + self->dx = v * self->dx; + self->dy = v * self->dy; + self->thrust = sqrt((self->dx * self->dx) + (self->dy * self->dy)); + } +} + static void activateECM(void) { battle.ecmTimer = 0; diff --git a/src/defs.h b/src/defs.h index ba56fc5..498d0d3 100644 --- a/src/defs.h +++ b/src/defs.h @@ -75,9 +75,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define EF_ALWAYS_FLEES (2 << 9) /* player abilities */ -#define BOOST_RECHARGE_TIME (FPS * 5) +#define BOOST_RECHARGE_TIME (FPS * 7) #define BOOST_FINISHED_TIME (FPS * 0.75) -#define ECM_RECHARGE_TIME (FPS * 5) +#define ECM_RECHARGE_TIME (FPS * 7) enum {