Improved damaged nerfing

Limited damage prevention to only at the "low" and "critical" levels,
plus added a delay for when damage is first inflicted by rays.

This prevents ships with multiple concentrated shots from having
a disadvantage, and it helps make rays easier to avoid at the same
time (just get out of the ray in time and you don't take damage).
Of course, neither of these apply to Classic difficulty, although
the ray damage delay does apply to Nightmare difficulty (which,
given how unpredictable rays are, I think is quite reasonable).
This commit is contained in:
Julie Marchant 2019-05-11 02:15:36 -04:00
parent ded0be314e
commit 3b7bb45e28
6 changed files with 38 additions and 9 deletions

View File

@ -1726,7 +1726,7 @@ void alien_move(Object *alien)
{
if (alien->classDef == CD_ASTEROID)
{
player_damage(alien->shield);
player_damage(alien->shield, 0);
alien->shield = 0;
audio_playSound(SFX_EXPLOSION, alien->x, alien->y);
audio_playSound(SFX_HIT, player.x, player.y);
@ -1734,7 +1734,7 @@ void alien_move(Object *alien)
if (alien->classDef == CD_ASTEROID2)
{
player_damage(alien->shield);
player_damage(alien->shield, 0);
alien->shield = 0;
audio_playSound(SFX_EXPLOSION, alien->x, alien->y);
audio_playSound(SFX_HIT, player.x, player.y);
@ -1742,7 +1742,7 @@ void alien_move(Object *alien)
if (alien->classDef == CD_BARRIER)
{
player_damage(1);
player_damage(1, 0);
audio_playSound(SFX_HIT, player.x, player.y);
}
}

View File

@ -764,4 +764,6 @@ const int maxHoming = 20;
const int maxDoubleHoming = 15;
const int maxMicroHoming = 10;
const int rayDamageDelay = 10;
#endif

View File

@ -784,7 +784,7 @@ static void game_doBullets()
{
old_shield = player.shield;
player_damage(bullet->damage);
player_damage(bullet->damage, 0);
if (player.shield > 0)
{
@ -2451,6 +2451,16 @@ int game_mainLoop()
game_doExplosions();
game_doHud();
// Start delaying damage again gradually
if (player_resetDamageDelay)
{
LIMIT_ADD(player_damageDelay, -1, 0, 100);
}
else
{
player_resetDamageDelay = 1;
}
WRAP_ADD(engine.eventTimer, -1, 0, 60);
if (engine.paused)

View File

@ -34,6 +34,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
Object player;
int player_chargerFired = 0;
int player_damageDelay = 0;
int player_resetDamageDelay = 0;
/*
Initialises the player for a new game.
@ -81,13 +83,26 @@ void player_setTarget(int index)
engine.targetShield /= aliens[index].shield;
}
void player_damage(int amount)
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.hit) ||
(game.difficulty == DIFFICULTY_ORIGINAL) ||
((player.shield != engine.lowShield) &&
(player.shield != 1))))
{
player.shield -= amount;
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

View File

@ -25,10 +25,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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);
void player_damage(int amount, int delay);
void player_checkShockDamage(float x, float y);
void player_exit();
void player_flushInput();

View File

@ -176,7 +176,7 @@ void ship_fireRay(Object *ship)
player.image[0]->h, ray.x, ray.y, ray.w, ray.h) &&
(!engine.cheatShield) && (engine.missionCompleteTimer == 0))
{
player_damage(1);
player_damage(1, rayDamageDelay);
explosion_add(player.x, player.y, SP_SMALL_EXPLOSION);
audio_playSound(SFX_HIT, player.x, player.y);