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:
parent
828b56d4df
commit
ded0be314e
|
@ -7,7 +7,7 @@
|
||||||
# information. This file is offered as-is, without any warranty.
|
# information. This file is offered as-is, without any warranty.
|
||||||
|
|
||||||
AC_PREREQ([2.69])
|
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])
|
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
|
||||||
AC_CONFIG_SRCDIR([src/Starfighter.cpp])
|
AC_CONFIG_SRCDIR([src/Starfighter.cpp])
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
|
@ -1726,29 +1726,23 @@ void alien_move(Object *alien)
|
||||||
{
|
{
|
||||||
if (alien->classDef == CD_ASTEROID)
|
if (alien->classDef == CD_ASTEROID)
|
||||||
{
|
{
|
||||||
if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0))
|
player_damage(alien->shield);
|
||||||
player.shield -= alien->shield;
|
|
||||||
alien->shield = 0;
|
alien->shield = 0;
|
||||||
audio_playSound(SFX_EXPLOSION, alien->x, alien->y);
|
audio_playSound(SFX_EXPLOSION, alien->x, alien->y);
|
||||||
player.hit = 5;
|
|
||||||
audio_playSound(SFX_HIT, player.x, player.y);
|
audio_playSound(SFX_HIT, player.x, player.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alien->classDef == CD_ASTEROID2)
|
if (alien->classDef == CD_ASTEROID2)
|
||||||
{
|
{
|
||||||
if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0))
|
player_damage(alien->shield);
|
||||||
player.shield -= alien->shield;
|
|
||||||
alien->shield = 0;
|
alien->shield = 0;
|
||||||
audio_playSound(SFX_EXPLOSION, alien->x, alien->y);
|
audio_playSound(SFX_EXPLOSION, alien->x, alien->y);
|
||||||
player.hit = 5;
|
|
||||||
audio_playSound(SFX_HIT, player.x, player.y);
|
audio_playSound(SFX_HIT, player.x, player.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alien->classDef == CD_BARRIER)
|
if (alien->classDef == CD_BARRIER)
|
||||||
{
|
{
|
||||||
if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0))
|
player_damage(1);
|
||||||
player.shield--;
|
|
||||||
player.hit = 5;
|
|
||||||
audio_playSound(SFX_HIT, player.x, player.y);
|
audio_playSound(SFX_HIT, player.x, player.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
src/game.cpp
13
src/game.cpp
|
@ -784,16 +784,7 @@ static void game_doBullets()
|
||||||
{
|
{
|
||||||
old_shield = player.shield;
|
old_shield = player.shield;
|
||||||
|
|
||||||
if ((!engine.cheatShield) && (engine.missionCompleteTimer == 0))
|
player_damage(bullet->damage);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.shield > 0)
|
if (player.shield > 0)
|
||||||
{
|
{
|
||||||
|
@ -1531,6 +1522,8 @@ static void game_doPlayer()
|
||||||
}
|
}
|
||||||
else
|
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.active = 0;
|
||||||
player.shield--;
|
player.shield--;
|
||||||
if (player.shield == -1)
|
if (player.shield == -1)
|
||||||
|
|
|
@ -27,6 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
#include "info.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "weapons.h"
|
#include "weapons.h"
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
@ -80,6 +81,33 @@ void player_setTarget(int index)
|
||||||
engine.targetShield /= aliens[index].shield;
|
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)
|
void player_checkShockDamage(float x, float y)
|
||||||
{
|
{
|
||||||
float distX = fabsf(x - player.x);
|
float distX = fabsf(x - player.x);
|
||||||
|
|
|
@ -28,6 +28,7 @@ extern int player_chargerFired;
|
||||||
|
|
||||||
void player_init();
|
void player_init();
|
||||||
void player_setTarget(int index);
|
void player_setTarget(int index);
|
||||||
|
void player_damage(int amount);
|
||||||
void player_checkShockDamage(float x, float y);
|
void player_checkShockDamage(float x, float y);
|
||||||
void player_exit();
|
void player_exit();
|
||||||
void player_flushInput();
|
void player_flushInput();
|
||||||
|
|
|
@ -176,14 +176,7 @@ void ship_fireRay(Object *ship)
|
||||||
player.image[0]->h, ray.x, ray.y, ray.w, ray.h) &&
|
player.image[0]->h, ray.x, ray.y, ray.w, ray.h) &&
|
||||||
(!engine.cheatShield) && (engine.missionCompleteTimer == 0))
|
(!engine.cheatShield) && (engine.missionCompleteTimer == 0))
|
||||||
{
|
{
|
||||||
if (player.shield > engine.lowShield)
|
player_damage(1);
|
||||||
{
|
|
||||||
if (player.shield - 1 <= engine.lowShield)
|
|
||||||
{
|
|
||||||
info_setLine("!!! WARNING: SHIELD LOW !!!", FONT_RED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
player.shield--;
|
|
||||||
|
|
||||||
explosion_add(player.x, player.y, SP_SMALL_EXPLOSION);
|
explosion_add(player.x, player.y, SP_SMALL_EXPLOSION);
|
||||||
audio_playSound(SFX_HIT, player.x, player.y);
|
audio_playSound(SFX_HIT, player.x, player.y);
|
||||||
|
|
Loading…
Reference in New Issue