Added a damage-control mechanic.

Limits the damage you take somewhat. Basically, this is intended
to prevent sudden deaths; if it doesn't look like you're dying,
you probably won't suddenly get axed. Of course, this is disabled
in Classic difficulty.
This commit is contained in:
Julie Marchant 2019-05-10 21:09:34 -04:00
parent 828b56d4df
commit ded0be314e
6 changed files with 37 additions and 28 deletions

View File

@ -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])

View File

@ -1726,29 +1726,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);
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);
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);
audio_playSound(SFX_HIT, player.x, player.y);
}
}

View File

@ -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);
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)

View File

@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "engine.h"
#include "game.h"
#include "gfx.h"
#include "info.h"
#include "screen.h"
#include "weapons.h"
#include "window.h"
@ -80,6 +81,33 @@ void player_setTarget(int index)
engine.targetShield /= aliens[index].shield;
}
void player_damage(int amount)
{
int oldshield = player.shield;
if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0) &&
((!player.hit) || (game.difficulty == DIFFICULTY_ORIGINAL)))
{
player.shield -= 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;
}
else if ((oldshield > 1) && (player.shield <= 1))
{
info_setLine("!!! WARNING: SHIELD CRITICAL !!!", FONT_RED);
if (game.difficulty != DIFFICULTY_ORIGINAL)
player.shield = 1;
}
}
}
void player_checkShockDamage(float x, float y)
{
float distX = fabsf(x - player.x);

View File

@ -28,6 +28,7 @@ extern int player_chargerFired;
void player_init();
void player_setTarget(int index);
void player_damage(int amount);
void player_checkShockDamage(float x, float y);
void player_exit();
void player_flushInput();

View File

@ -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);
explosion_add(player.x, player.y, SP_SMALL_EXPLOSION);
audio_playSound(SFX_HIT, player.x, player.y);