Merge branch 'master' of git.savannah.nongnu.org:/srv/git/starfighter
This commit is contained in:
commit
0ba13df0d7
|
@ -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])
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -764,4 +764,6 @@ const int maxHoming = 20;
|
|||
const int maxDoubleHoming = 15;
|
||||
const int maxMicroHoming = 10;
|
||||
|
||||
const int rayDamageDelay = 10;
|
||||
|
||||
#endif
|
||||
|
|
26
src/game.cpp
26
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)
|
||||
|
|
|
@ -27,12 +27,16 @@ 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 "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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,9 +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, int delay);
|
||||
void player_checkShockDamage(float x, float y);
|
||||
void player_exit();
|
||||
void player_flushInput();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue