diff --git a/gfx/battle/shieldSplinter.png b/gfx/battle/shieldSplinter.png new file mode 100644 index 0000000..3bcfee1 Binary files /dev/null and b/gfx/battle/shieldSplinter.png differ diff --git a/sound/322603__clippysounds__glass-break.ogg b/sound/322603__clippysounds__glass-break.ogg new file mode 100644 index 0000000..11e4bd1 Binary files /dev/null and b/sound/322603__clippysounds__glass-break.ogg differ diff --git a/sound/49678__ejfortin__energy-short-sword-7.ogg b/sound/49678__ejfortin__energy-short-sword-7.ogg new file mode 100644 index 0000000..94dc06a Binary files /dev/null and b/sound/49678__ejfortin__energy-short-sword-7.ogg differ diff --git a/src/battle/battle.c b/src/battle/battle.c index 939385a..6a33ecf 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -55,6 +55,8 @@ void initBattle(void) initBackground(); + initEffects(); + initHud(); initRadar(); diff --git a/src/battle/battle.h b/src/battle/battle.h index 0a8f9cd..25ac097 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -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; diff --git a/src/battle/effects.c b/src/battle/effects.c index 3d12d25..5fd5c8c 100644 --- a/src/battle/effects.c +++ b/src/battle/effects.c @@ -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; + } +} diff --git a/src/battle/fighters.c b/src/battle/fighters.c index c8eda0a..ad60d10 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -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); } } diff --git a/src/battle/fighters.h b/src/battle/fighters.h index ec2466f..c67d170 100644 --- a/src/battle/fighters.h +++ b/src/battle/fighters.h @@ -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; diff --git a/src/system/sound.c b/src/system/sound.c index 2c1387c..75e6993 100644 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -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");