Cleaned up the effects reduction code and moved it to a separate method

This commit is contained in:
George Sokianos 2022-08-22 22:11:45 +01:00
parent 0ab9bfac9d
commit 29dd25a23a
2 changed files with 40 additions and 131 deletions

View File

@ -15,7 +15,7 @@
"group" : "options", "group" : "options",
"type" : "WT_SELECT", "type" : "WT_SELECT",
"text" : "Effects Reduction", "text" : "Effects Reduction",
"options" : "0;1;2", "options" : "0;1;2;3",
"x" : -1, "x" : -1,
"y" : 225, "y" : 225,
"w" : 400, "w" : 400,

View File

@ -24,6 +24,7 @@ static void setRandomFlameHue(Effect *e);
static void setRandomShieldHue(Effect *e); static void setRandomShieldHue(Effect *e);
static void resizeDrawList(void); static void resizeDrawList(void);
static int pointOnScreen(float x, float y); static int pointOnScreen(float x, float y);
static float calculateEffectsValue(unsigned int);
static AtlasImage *explosionTexture; static AtlasImage *explosionTexture;
static AtlasImage *shieldHitTexture; static AtlasImage *shieldHitTexture;
@ -202,11 +203,7 @@ void addBulletHitEffect(int x, int y, int r, int g, int b)
e->type = EFFECT_TEXTURE; e->type = EFFECT_TEXTURE;
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 16; e->size = calculateEffectsValue(16);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->x = x; e->x = x;
e->y = y; e->y = y;
@ -219,11 +216,7 @@ void addBulletHitEffect(int x, int y, int r, int g, int b)
e->g = g; e->g = g;
e->b = b; e->b = b;
e->a = 64; e->a = 64;
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
} }
} }
@ -241,20 +234,12 @@ void addSmallFighterExplosion(void)
e->x = self->x + (rand() % 16 - rand() % 16); e->x = self->x + (rand() % 16 - rand() % 16);
e->y = self->y + (rand() % 16 - rand() % 16); e->y = self->y + (rand() % 16 - rand() % 16);
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 32; e->size = calculateEffectsValue(32);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
setRandomFlameHue(e); setRandomFlameHue(e);
e->a = 128 + (rand() % 128); e->a = 128 + (rand() % 128);
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2; e->x -= e->size / 2;
e->y -= e->size / 2; e->y -= e->size / 2;
@ -274,20 +259,12 @@ void addDebrisFire(int x, int y)
e->x = x + (rand() % 8 - rand() % 8); e->x = x + (rand() % 8 - rand() % 8);
e->y = y + (rand() % 8 - rand() % 8); e->y = y + (rand() % 8 - rand() % 8);
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 4 + rand() % 12; e->size = calculateEffectsValue(4 + rand() % 12);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
setRandomFlameHue(e); setRandomFlameHue(e);
e->a = rand() % 256; e->a = rand() % 256;
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2; e->x -= e->size / 2;
e->y -= e->size / 2; e->y -= e->size / 2;
@ -314,21 +291,13 @@ void addSmallExplosion(void)
e->dy = (rand() % 25) - (rand() % 25); e->dy = (rand() % 25) - (rand() % 25);
e->dy *= 0.025; e->dy *= 0.025;
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 32 + (rand() % 64); e->size = calculateEffectsValue(32 + (rand() % 64));
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 255; e->r = 255;
setRandomFlameHue(e); setRandomFlameHue(e);
e->a = 128 + (rand() % 128); e->a = 128 + (rand() % 128);
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2; e->x -= e->size / 2;
e->y -= e->size / 2; e->y -= e->size / 2;
@ -350,11 +319,7 @@ void addSmallExplosion(void)
e->dy *= 0.1; e->dy *= 0.1;
e->a = 128; e->a = 128;
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
setRandomFlameHue(e); setRandomFlameHue(e);
} }
@ -377,21 +342,13 @@ void addMineExplosion(void)
e->x = self->x + rand() % 64 - rand() % 64; e->x = self->x + rand() % 64 - rand() % 64;
e->y = self->y + rand() % 64 - rand() % 64; e->y = self->y + rand() % 64 - rand() % 64;
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 64 + (rand() % 64); e->size = calculateEffectsValue(64 + (rand() % 64));
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 255; e->r = 255;
setRandomFlameHue(e); setRandomFlameHue(e);
e->a = 32 + (rand() % 192); e->a = 32 + (rand() % 192);
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2; e->x -= e->size / 2;
e->y -= e->size / 2; e->y -= e->size / 2;
@ -406,11 +363,7 @@ void addMineExplosion(void)
e->type = EFFECT_HALO; e->type = EFFECT_HALO;
e->x = self->x; e->x = self->x;
e->y = self->y; e->y = self->y;
e->size = 64; e->size = calculateEffectsValue(64);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->scaleAmount = 6; e->scaleAmount = 6;
e->texture = haloTexture; e->texture = haloTexture;
@ -419,11 +372,7 @@ void addMineExplosion(void)
e->b = 255; e->b = 255;
e->a = 128; e->a = 128;
e->health = 128; e->health = calculateEffectsValue(128);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
} }
void addLargeExplosion(void) void addLargeExplosion(void)
@ -447,21 +396,13 @@ void addLargeExplosion(void)
e->dy = (rand() % 25) - (rand() % 25); e->dy = (rand() % 25) - (rand() % 25);
e->dy *= 0.01; e->dy *= 0.01;
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 128 + (rand() % 512); e->size = calculateEffectsValue(128 + (rand() % 512));
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 255; e->r = 255;
setRandomFlameHue(e); setRandomFlameHue(e);
e->a = 128 + (rand() % 128); e->a = 128 + (rand() % 128);
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2; e->x -= e->size / 2;
e->y -= e->size / 2; e->y -= e->size / 2;
@ -476,11 +417,7 @@ void addLargeExplosion(void)
e->type = EFFECT_HALO; e->type = EFFECT_HALO;
e->x = self->x; e->x = self->x;
e->y = self->y; e->y = self->y;
e->size = 256; e->size = calculateEffectsValue(256);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->scaleAmount = 4; e->scaleAmount = 4;
e->texture = haloTexture; e->texture = haloTexture;
@ -489,11 +426,7 @@ void addLargeExplosion(void)
e->b = 255; e->b = 255;
e->a = 255; e->a = 255;
e->health = 255; e->health = calculateEffectsValue(255);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
} }
void addMissileExplosion(Bullet *b) void addMissileExplosion(Bullet *b)
@ -517,21 +450,13 @@ void addMissileExplosion(Bullet *b)
e->dy = (rand() % 25) - (rand() % 25); e->dy = (rand() % 25) - (rand() % 25);
e->dy *= 0.025; e->dy *= 0.025;
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 32 + (rand() % 64); e->size = calculateEffectsValue(32 + (rand() % 64));
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 255; e->r = 255;
setRandomFlameHue(e); setRandomFlameHue(e);
e->a = 128 + (rand() % 128); e->a = 128 + (rand() % 128);
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2; e->x -= e->size / 2;
e->y -= e->size / 2; e->y -= e->size / 2;
@ -553,11 +478,7 @@ void addMissileExplosion(Bullet *b)
e->dy *= 0.1; e->dy *= 0.1;
e->a = 128; e->a = 128;
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
setRandomFlameHue(e); setRandomFlameHue(e);
} }
@ -587,21 +508,13 @@ void addEngineEffect(void)
e->x += rand() % 4 - rand() % 4; e->x += rand() % 4 - rand() % 4;
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 16; e->size = calculateEffectsValue(16);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 128; e->r = 128;
e->g = 128; e->g = 128;
e->b = 255; e->b = 255;
e->a = 64; e->a = 64;
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2; e->x -= e->size / 2;
e->y -= e->size / 2; e->y -= e->size / 2;
@ -628,21 +541,13 @@ void addLargeEngineEffect(void)
e->x -= rand() % 4; e->x -= rand() % 4;
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 64; e->size = calculateEffectsValue(64);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
e->r = 128; e->r = 128;
e->g = 128; e->g = 128;
e->b = 255; e->b = 255;
e->a = 64; e->a = 64;
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2; e->x -= e->size / 2;
e->y -= e->size / 2; e->y -= e->size / 2;
@ -669,19 +574,11 @@ void addMissileEngineEffect(Bullet *b)
e->x -= rand() % 4; e->x -= rand() % 4;
e->texture = explosionTexture; e->texture = explosionTexture;
e->size = 12; e->size = calculateEffectsValue(12);
if (app.effects > 0)
{
e->size = e->size / (app.effects * 2);
}
setRandomFlameHue(e); setRandomFlameHue(e);
e->a = 128; e->a = 128;
e->health = e->a; e->health = calculateEffectsValue(e->a);
if (app.effects > 0)
{
e->health = e->health / (app.effects * 2);
}
e->x -= e->size / 2; e->x -= e->size / 2;
e->y -= e->size / 2; e->y -= e->size / 2;
@ -800,3 +697,15 @@ void destroyEffects(void)
effectsToDraw = NULL; effectsToDraw = NULL;
} }
static float calculateEffectsValue(unsigned int val)
{
#if defined(__amigaos4__)
if (app.effects)
{
return val>>(app.effects<<1);
}
#endif
return (float)val;
}