Shield damage effect updates. Laser will cause shield to disable for 10 seconds.

This commit is contained in:
Steve 2015-11-18 16:04:12 +00:00
parent 044aedeb58
commit ede89eefd1
9 changed files with 121 additions and 41 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Binary file not shown.

View File

@ -55,6 +55,8 @@ void initBattle(void)
initBackground();
initEffects();
initHud();
initRadar();

View File

@ -66,6 +66,7 @@ extern void resetWaypoints(void);
extern void doPlayerSelect(void);
extern void destroyGrid(void);
extern void completeMission(void);
extern void initEffects(void);
extern App app;
extern Battle battle;

View File

@ -21,6 +21,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "effects.h"
static void setRandomFlameHue(Effect *e);
static void setRandomShieldHue(Effect *e);
static SDL_Texture *explosionTexture;
static SDL_Texture *shieldHitTexture;
void initEffects(void)
{
explosionTexture = getTexture("gfx/battle/explosion.png");
shieldHitTexture = getTexture("gfx/battle/shieldHit.png");
}
void doEffects(void)
{
@ -88,7 +98,6 @@ void drawEffects(void)
void addSmallFighterExplosion(void)
{
Effect *e;
SDL_Texture *t = getTexture("gfx/battle/explosion.png");
e = malloc(sizeof(Effect));
memset(e, 0, sizeof(Effect));
@ -99,7 +108,7 @@ void addSmallFighterExplosion(void)
e->x = self->x + (rand() % 16 - rand() % 16);
e->y = self->y + (rand() % 16 - rand() % 16);
e->texture = t;
e->texture = explosionTexture;
e->health = 0;
e->size = 32;
@ -115,7 +124,6 @@ void addFighterExplosion(void)
{
int i;
Effect *e;
SDL_Texture *t = getTexture("gfx/battle/explosion.png");
for (i = 0 ; i < 32 ; i++)
{
@ -132,7 +140,7 @@ void addFighterExplosion(void)
e->dx *= 0.025;
e->dy = (rand() % 25) - (rand() % 25);
e->dy *= 0.025;
e->texture = t;
e->texture = explosionTexture;
e->health = 0;
e->size = 32 + (rand() % 64);
e->r = 255;
@ -171,7 +179,6 @@ void addMissileExplosion(Bullet *b)
{
int i;
Effect *e;
SDL_Texture *t = getTexture("gfx/battle/explosion.png");
for (i = 0 ; i < 8 ; i++)
{
@ -188,7 +195,7 @@ void addMissileExplosion(Bullet *b)
e->dx *= 0.025;
e->dy = (rand() % 25) - (rand() % 25);
e->dy *= 0.025;
e->texture = t;
e->texture = explosionTexture;
e->health = 0;
e->size = 32 + (rand() % 64);
e->r = 255;
@ -223,29 +230,6 @@ void addMissileExplosion(Bullet *b)
}
}
static void setRandomFlameHue(Effect *e)
{
e->r = 255;
switch (rand() % 4)
{
case 0:
break;
case 1:
e->g = 128;
break;
case 2:
e->g = 255;
break;
case 3:
e->g = e->b = 255;
break;
}
}
void addEngineEffect(void)
{
Effect *e;
@ -266,7 +250,7 @@ void addEngineEffect(void)
e->x += rand() % 4;
e->x -= rand() % 4;
e->texture = getTexture("gfx/battle/explosion.png");
e->texture = explosionTexture;
e->health = 0;
e->size = 16;
e->r = 128;
@ -298,7 +282,7 @@ void addMissileEngineEffect(Bullet *b)
e->x += rand() % 4;
e->x -= rand() % 4;
e->texture = getTexture("gfx/battle/explosion.png");
e->texture = explosionTexture;
e->health = 0;
e->size = 12;
setRandomFlameHue(e);
@ -307,3 +291,76 @@ void addMissileEngineEffect(Bullet *b)
e->x -= e->size / 2;
e->y -= e->size / 2;
}
void addShieldSplinterEffect(Entity *ent)
{
int i;
Effect *e;
for (i = 0 ; i < 48 ; i++)
{
e = malloc(sizeof(Effect));
memset(e, 0, sizeof(Effect));
battle.effectTail->next = e;
battle.effectTail = e;
e->type = EFFECT_LINE;
e->x = ent->x;
e->y = ent->y;
e->dx = rand() % 64 - rand() % 64;
e->dx *= 0.1;
e->dy = rand() % 64 - rand() % 64;
e->dy *= 0.1;
e->a = 255;
setRandomShieldHue(e);
}
}
static void setRandomFlameHue(Effect *e)
{
e->r = 255;
switch (rand() % 4)
{
case 0:
break;
case 1:
e->g = 128;
break;
case 2:
e->g = 255;
break;
case 3:
e->g = e->b = 255;
break;
}
}
static void setRandomShieldHue(Effect *e)
{
e->b = 255;
switch (rand() % 4)
{
case 0:
e->g = 128;
break;
case 1:
e->g = 196;
break;
case 2:
e->g = 255;
break;
case 3:
e->r = e->g = 255;
break;
}
}

View File

@ -385,6 +385,8 @@ void applyFighterBrakes(void)
void damageFighter(Entity *f, int amount, long flags)
{
int prevShield = f->shield;
if (flags & BF_SYSTEM_DAMAGE)
{
f->systemPower = MAX(0, f->systemPower - amount);
@ -397,22 +399,36 @@ void damageFighter(Entity *f, int amount, long flags)
f->action = NULL;
}
}
else if (flags & BF_SHIELD_DAMAGE)
{
f->shield = MAX(-(FPS * 10), f->shield - amount);
if (f->shield <= 0 && prevShield > 0)
{
playBattleSound(SND_SHIELD_BREAK, f->x, f->y);
addShieldSplinterEffect(f);
}
}
else
{
f->shield -= amount;
if (f->shield < 0)
if (f->shield > 0)
{
f->health -= abs(f->shield);
f->shield = 0;
f->shield = MAX(0, f->shield - amount);
}
else
{
f->health -= amount;
f->armourHit = 255;
playBattleSound(SND_ARMOUR_HIT, f->x, f->y);
}
else if (f->shield > 0)
{
f->shieldHit = 255;
}
}
if (f->shield > 0)
{
f->shieldHit = 255;
playBattleSound(SND_SHIELD_HIT, f->x, f->y);
}
}

View File

@ -46,6 +46,7 @@ extern void attachRope(void);
extern char *readFile(char *filename);
extern long lookup(char *name);
extern long flagsToLong(char *flags);
extern void addShieldSplinterEffect(Entity *ent);
extern App app;
extern Battle battle;

View File

@ -92,8 +92,11 @@ void playBattleSound(int id, int x, int y)
static void loadSounds(void)
{
sounds[SND_ARMOUR_HIT] = Mix_LoadWAV("sound/275151__bird-man__gun-shot.ogg");
sounds[SND_SHIELD_HIT] = Mix_LoadWAV("sound/49678__ejfortin__energy-short-sword-7.ogg");
sounds[SND_PLASMA] = Mix_LoadWAV("sound/268344__julien-matthey__jm-noiz-laser-01.ogg");
sounds[SND_MAG] = Mix_LoadWAV("sound/18382__inferno__hvylas.ogg");
sounds[SND_LASER] = Mix_LoadWAV("sound/18382__inferno__hvylas.ogg");
sounds[SND_MAG] = Mix_LoadWAV("sound/146725__fins__laser.ogg");
sounds[SND_SHIELD_BREAK] = Mix_LoadWAV("sound/322603__clippysounds__glass-break.ogg");
sounds[SND_PARTICLE] = Mix_LoadWAV("sound/77087__supraliminal__laser-short.ogg");
sounds[SND_MISSILE] = Mix_LoadWAV("sound/65787__iwilldstroyu__laserrocket.ogg");
sounds[SND_BOOST] = Mix_LoadWAV("sound/18380__inferno__hvrl.ogg");