diff --git a/configure.ac b/configure.ac
index 140d73a..466dc64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@
# information. This file is offered as-is, without any warranty.
AC_PREREQ([2.69])
-AC_INIT([Project: Starfighter], [1.7.1-dev], [onpon4@riseup.net], [starfighter])
+AC_INIT([Project: Starfighter], [1.8-dev], [onpon4@riseup.net], [starfighter])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_CONFIG_SRCDIR([src/Starfighter.cpp])
AC_CONFIG_HEADERS([config.h])
diff --git a/src/alien.cpp b/src/alien.cpp
index be00488..a58723d 100644
--- a/src/alien.cpp
+++ b/src/alien.cpp
@@ -1731,29 +1731,23 @@ void alien_move(Object *alien)
{
if (alien->classDef == CD_ASTEROID)
{
- if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0))
- player.shield -= alien->shield;
+ player_damage(alien->shield, 0);
alien->shield = 0;
audio_playSound(SFX_EXPLOSION, alien->x, alien->y);
- player.hit = 5;
audio_playSound(SFX_HIT, player.x, player.y);
}
if (alien->classDef == CD_ASTEROID2)
{
- if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0))
- player.shield -= alien->shield;
+ player_damage(alien->shield, 0);
alien->shield = 0;
audio_playSound(SFX_EXPLOSION, alien->x, alien->y);
- player.hit = 5;
audio_playSound(SFX_HIT, player.x, player.y);
}
if (alien->classDef == CD_BARRIER)
{
- if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0))
- player.shield--;
- player.hit = 5;
+ player_damage(1, 0);
audio_playSound(SFX_HIT, player.x, player.y);
}
}
diff --git a/src/defs.h b/src/defs.h
index 6fbe540..6e9e891 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -764,4 +764,6 @@ const int maxHoming = 20;
const int maxDoubleHoming = 15;
const int maxMicroHoming = 10;
+const int rayDamageDelay = 10;
+
#endif
diff --git a/src/game.cpp b/src/game.cpp
index 907d9c4..06e698c 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -784,16 +784,7 @@ static void game_doBullets()
{
old_shield = player.shield;
- if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0))
- {
- if ((player.shield > engine.lowShield) &&
- (player.shield - bullet->damage <= engine.lowShield))
- info_setLine("!!! WARNING: SHIELD LOW !!!", FONT_RED);
-
- player.shield -= bullet->damage;
- LIMIT(player.shield, 0, player.maxShield);
- player.hit = 5;
- }
+ player_damage(bullet->damage, 0);
if (player.shield > 0)
{
@@ -1531,6 +1522,8 @@ static void game_doPlayer()
}
else
{
+ // Player is dead. At this point, the shield counts down to
+ // -100 and does death and explosion stuff along the way.
player.active = 0;
player.shield--;
if (player.shield == -1)
@@ -2458,6 +2451,19 @@ int game_mainLoop()
game_doExplosions();
game_doHud();
+ // Start delaying damage again gradually
+ if (player_damageDelay > 0)
+ {
+ if (player_resetDamageDelay)
+ {
+ player_damageDelay--;
+ }
+ else
+ {
+ player_resetDamageDelay = 1;
+ }
+ }
+
WRAP_ADD(engine.eventTimer, -1, 0, 60);
if (engine.paused)
diff --git a/src/player.cpp b/src/player.cpp
index d07b6cf..6184115 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -27,12 +27,16 @@ along with this program. If not, see .
#include "engine.h"
#include "game.h"
#include "gfx.h"
+#include "info.h"
+#include "player.h"
#include "screen.h"
#include "weapons.h"
#include "window.h"
Object player;
int player_chargerFired = 0;
+int player_damageDelay = 0;
+int player_resetDamageDelay = 0;
/*
Initialises the player for a new game.
@@ -80,6 +84,52 @@ void player_setTarget(int index)
engine.targetShield /= aliens[index].shield;
}
+void player_damage(int amount, int delay)
+{
+ int oldshield = player.shield;
+
+ player_resetDamageDelay = 0;
+
+ if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0) &&
+ ((!player.hit) ||
+ (game.difficulty == DIFFICULTY_ORIGINAL) ||
+ ((player.shield != engine.lowShield) &&
+ (player.shield != 1))))
+ {
+ if ((game.difficulty == DIFFICULTY_ORIGINAL) ||
+ (player_damageDelay >= delay))
+ {
+ player.shield -= amount;
+ }
+ else
+ player_damageDelay += amount;
+
+ LIMIT(player.shield, 0, player.maxShield);
+ player.hit = 5; // Damage flash timer
+
+ // Damage tiers (not in Classic mode)
+ if ((oldshield > engine.lowShield) &&
+ (player.shield <= engine.lowShield))
+ {
+ info_setLine("!!! WARNING: SHIELD LOW !!!", FONT_RED);
+ if (game.difficulty != DIFFICULTY_ORIGINAL)
+ {
+ player.shield = engine.lowShield;
+ player_damageDelay = 0;
+ }
+ }
+ else if ((oldshield > 1) && (player.shield <= 1))
+ {
+ info_setLine("!!! WARNING: SHIELD CRITICAL !!!", FONT_RED);
+ if (game.difficulty != DIFFICULTY_ORIGINAL)
+ {
+ player.shield = 1;
+ player_damageDelay = 0;
+ }
+ }
+ }
+}
+
void player_checkShockDamage(float x, float y)
{
float distX = fabsf(x - player.x);
@@ -98,9 +148,7 @@ void player_checkShockDamage(float x, float y)
if (distY >= 1)
distY /= 5;
- player.shield -= (int)(10 - distX);
- player.shield -= (int)(10 - distY);
- LIMIT(player.shield, 0, player.maxShield);
+ player_damage((int)((10 - distX) + (10 - distY)), 0);
player.hit = 10;
}
}
diff --git a/src/player.h b/src/player.h
index 0548c44..b191d0e 100644
--- a/src/player.h
+++ b/src/player.h
@@ -25,9 +25,12 @@ along with this program. If not, see .
extern Object player;
extern int player_chargerFired;
+extern int player_damageDelay;
+extern int player_resetDamageDelay;
void player_init();
void player_setTarget(int index);
+void player_damage(int amount, int delay);
void player_checkShockDamage(float x, float y);
void player_exit();
void player_flushInput();
diff --git a/src/ship.cpp b/src/ship.cpp
index 115191e..1d9d5f7 100644
--- a/src/ship.cpp
+++ b/src/ship.cpp
@@ -176,14 +176,7 @@ void ship_fireRay(Object *ship)
player.image[0]->h, ray.x, ray.y, ray.w, ray.h) &&
(!engine.cheatShield) && (engine.missionCompleteTimer == 0))
{
- if (player.shield > engine.lowShield)
- {
- if (player.shield - 1 <= engine.lowShield)
- {
- info_setLine("!!! WARNING: SHIELD LOW !!!", FONT_RED);
- }
- }
- player.shield--;
+ player_damage(1, rayDamageDelay);
explosion_add(player.x, player.y, SP_SMALL_EXPLOSION);
audio_playSound(SFX_HIT, player.x, player.y);