[Add] Propperly finished adding interference.

This commit is contained in:
Allanis 2014-05-02 23:31:17 +01:00
parent 389f818844
commit 06891d765d
4 changed files with 77 additions and 40 deletions

View File

@ -32,7 +32,7 @@
</planets> </planets>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>50</interference>
<nebulae volatility="0">0</nebulae> <nebulae volatility="0">0</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -57,11 +57,11 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>50</interference>
<nebulae volatility="0">0</nebulae> <nebulae volatility="0">0</nebulae>
<stars>160</stars> <stars>160</stars>
</general> </general>
</ssys> </ssys>
<ssys name="Raelid"> <ssys name="Raelid">
<fleets> <fleets>
<fleet chance="60">Draktharr Vendetta</fleet> <fleet chance="60">Draktharr Vendetta</fleet>
@ -92,7 +92,7 @@
</planets> </planets>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>100</interference>
<nebulae volatility="0">100</nebulae> <nebulae volatility="0">100</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -119,7 +119,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>250</interference>
<nebulae volatility="0">250</nebulae> <nebulae volatility="0">250</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -142,7 +142,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>600</interference>
<nebulae volatility="100">600</nebulae> <nebulae volatility="100">600</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -257,7 +257,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>100</interference>
<nebulae volatility="0">0</nebulae> <nebulae volatility="0">0</nebulae>
<stars>120</stars> <stars>120</stars>
</general> </general>
@ -310,7 +310,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>150</interference>
<nebulae volatility="0">150</nebulae> <nebulae volatility="0">150</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -354,7 +354,7 @@
</planets> </planets>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>400</interference>
<nebulae volatility="0">400</nebulae> <nebulae volatility="0">400</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -432,7 +432,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>700</interference>
<nebulae volatility="250">750</nebulae> <nebulae volatility="250">750</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -475,7 +475,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>300</interference>
<nebulae volatility="0">250</nebulae> <nebulae volatility="0">250</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -552,7 +552,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>200</interference>
<nebulae volatility="0">200</nebulae> <nebulae volatility="0">200</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -617,7 +617,7 @@
</planets> </planets>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>50</interference>
<nebulae volatility="0">0</nebulae> <nebulae volatility="0">0</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -656,7 +656,7 @@
</planets> </planets>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>100</interference>
<nebulae volatility="0">100</nebulae> <nebulae volatility="0">100</nebulae>
<stars>600</stars> <stars>600</stars>
</general> </general>
@ -675,7 +675,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>800</interference>
<nebulae volatility="300">800</nebulae> <nebulae volatility="300">800</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -720,7 +720,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>300</interference>
<nebulae volatility="0">200</nebulae> <nebulae volatility="0">200</nebulae>
<stars>300</stars> <stars>300</stars>
</general> </general>
@ -843,7 +843,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>100</interference>
<nebulae volatility="0">100</nebulae> <nebulae volatility="0">100</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -886,7 +886,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>450</interference>
<nebulae volatility="50">500</nebulae> <nebulae volatility="50">500</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -916,7 +916,7 @@
</planets> </planets>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>100</interference>
<nebulae volatility="0">100</nebulae> <nebulae volatility="0">100</nebulae>
<stars>600</stars> <stars>600</stars>
</general> </general>
@ -935,7 +935,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>350</interference>
<nebulae volatility="0">300</nebulae> <nebulae volatility="0">300</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -1050,7 +1050,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>500</interference>
<nebulae volatility="100">500</nebulae> <nebulae volatility="100">500</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -1070,7 +1070,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>650</interference>
<nebulae volatility="150">700</nebulae> <nebulae volatility="150">700</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -1101,7 +1101,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>200</interference>
<nebulae volatility="0">150</nebulae> <nebulae volatility="0">150</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -1181,7 +1181,7 @@
</planets> </planets>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>300</interference>
<nebulae volatility="0">0</nebulae> <nebulae volatility="0">0</nebulae>
<stars>100</stars> <stars>100</stars>
</general> </general>
@ -1199,7 +1199,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>800</interference>
<nebulae volatility="400">800</nebulae> <nebulae volatility="400">800</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -1244,7 +1244,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>350</interference>
<nebulae volatility="0">300</nebulae> <nebulae volatility="0">300</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -1278,7 +1278,7 @@
</planets> </planets>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>50</interference>
<nebulae volatility="0">0</nebulae> <nebulae volatility="0">0</nebulae>
<stars>400</stars> <stars>400</stars>
</general> </general>
@ -1297,7 +1297,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>950</interference>
<nebulae volatility="500">900</nebulae> <nebulae volatility="500">900</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -1318,7 +1318,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>50</interference>
<nebulae volatility="0">0</nebulae> <nebulae volatility="0">0</nebulae>
<stars>140</stars> <stars>140</stars>
</general> </general>
@ -1352,7 +1352,7 @@
</planets> </planets>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>50</interference>
<nebulae volatility="0">0</nebulae> <nebulae volatility="0">0</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -1476,7 +1476,7 @@
<planets/> <planets/>
<general> <general>
<asteroids>0</asteroids> <asteroids>0</asteroids>
<interference>0</interference> <interference>50</interference>
<nebulae volatility="0">0</nebulae> <nebulae volatility="0">0</nebulae>
<stars>500</stars> <stars>500</stars>
</general> </general>
@ -1517,4 +1517,4 @@
<stars>500</stars> <stars>500</stars>
</general> </general>
</ssys> </ssys>
</Systems> </Systems>

View File

@ -96,7 +96,7 @@ static unsigned int player_timer = 0; /**< For death and such. */
static Vec2 player_cam; /**< Again, for death etc. */ static Vec2 player_cam; /**< Again, for death etc. */
/* For interference. */ /* For interference. */
static int interference_layer = 0; /**< Layer of the current interference. */ static int interference_layer = 0; /**< Layer of the current interference. */
static double interference_alpha = 0.; /**< Alpha of the current interference layer. */ double interference_alpha = 0.; /**< Alpha of the current interference layer. */
static double interference_t = 0.; /**< Interference timer to control transitions. */ static double interference_t = 0.; /**< Interference timer to control transitions. */
static int* missions_done = NULL; /**< Saves position of completed missions. */ static int* missions_done = NULL; /**< Saves position of completed missions. */

View File

@ -78,6 +78,11 @@ static Star* stars = NULL; /* Star array. */
static int nstars = 0; /* Total stars. */ static int nstars = 0; /* Total stars. */
static int mstars = 0; /* Memory stars are taking. */ static int mstars = 0; /* Memory stars are taking. */
/* Interference. */
extern double interference_alpha; /* player.c */
static double interference_target; /**< Target alpha level .*/
static double interference_timer = 0.; /**< Interference timer. */
extern int planet_target; /* player.c */ extern int planet_target; /* player.c */
/* Intern. */ /* Intern. */
@ -96,7 +101,7 @@ static PlanetClass planetclass_get(const char a);
extern void player_message(const char* fmt, ...); extern void player_message(const char* fmt, ...);
void planets_minimap(const double res, const double w, void planets_minimap(const double res, const double w,
const double h, const RadarShape shape); const double h, const RadarShape shape, double alpha);
int space_sysSave(xmlTextWriterPtr writer); int space_sysSave(xmlTextWriterPtr writer);
int space_sysLoad(xmlNodePtr parent); int space_sysLoad(xmlNodePtr parent);
@ -105,7 +110,7 @@ int space_sysLoad(xmlNodePtr parent);
#define PIXEL(x,y) if((shape == RADAR_RECT && ABS(x)<w/2. && ABS(y)<h/2.) || \ #define PIXEL(x,y) if((shape == RADAR_RECT && ABS(x)<w/2. && ABS(y)<h/2.) || \
(shape == RADAR_CIRCLE && (((x)*(x)+(y)*(y)) <= rc))) glVertex2i((x),(y)) (shape == RADAR_CIRCLE && (((x)*(x)+(y)*(y)) <= rc))) glVertex2i((x),(y))
void planets_minimap(const double res, const double w, void planets_minimap(const double res, const double w,
const double h, const RadarShape shape) { const double h, const RadarShape shape, double alpha) {
int i; int i;
int cx, cy, x, y, r, rc; int cx, cy, x, y, r, rc;
double p; double p;
@ -124,7 +129,7 @@ void planets_minimap(const double res, const double w,
col = &cRadar_tPlanet; col = &cRadar_tPlanet;
else if((col != &cHostile) && !planet_hasService(planet, PLANET_SERVICE_BASIC)) else if((col != &cHostile) && !planet_hasService(planet, PLANET_SERVICE_BASIC))
col = &cInert; /* Override non-hostile planets without services. */ col = &cInert; /* Override non-hostile planets without services. */
COLOUR(*col); ACOLOUR(*col, alpha);
/* Some parameters. */ /* Some parameters. */
r = (int)(cur_system->planets[i]->gfx_space->sw / res); r = (int)(cur_system->planets[i]->gfx_space->sw / res);
@ -416,6 +421,7 @@ void space_update(const double dt) {
if(cur_system == NULL) return; /* Can't update a null system. */ if(cur_system == NULL) return; /* Can't update a null system. */
/* Spawning. */
if(space_spawn) { if(space_spawn) {
spawn_timer -= dt; spawn_timer -= dt;
@ -444,6 +450,36 @@ void space_update(const double dt) {
pilot_hit(player, NULL, 0, DAMAGE_TYPE_RADIATION, pilot_hit(player, NULL, 0, DAMAGE_TYPE_RADIATION,
pow2(cur_system->nebu_volatility) / 500. * dt); pow2(cur_system->nebu_volatility) / 500. * dt);
} }
/* Interference. */
if(cur_system->interference > 0.) {
/* Always dark. */
if(cur_system->interference >= 1000.)
interference_alpha = 1.;
/* Normal scenario. */
else {
interference_timer -= dt;
if(interference_timer < 0.) {
interference_timer += (1000. - cur_system->interference) / 1000. *
(3. + NormalInverse(0.25 + 0.95*RNGF()));
interference_target = cur_system->interference/1000. * 3. *
(1. + NormalInverse(0.25 + 0.95*RNGF()));
}
/* Head towards target. */
if(fabs(interference_alpha - interference_target) > 1e-05) {
/* Assymptotic. */
interference_alpha += (interference_target - interference_alpha) * dt;
/* Limit alpha to [0. -1.]. */
if(interference_alpha > 1.)
interference_alpha = 1.;
else if(interference_alpha < 0.)
interference_alpha = 0.;
}
}
}
} }
/** /**
@ -551,6 +587,7 @@ void space_init(const char* sysname) {
weapon_clear(); /* Get rid of all the weapons. */ weapon_clear(); /* Get rid of all the weapons. */
spfx_clear(); /* Remove of explosions. */ spfx_clear(); /* Remove of explosions. */
space_spawn = 1; /* Spawn is enabled by default. */ space_spawn = 1; /* Spawn is enabled by default. */
interference_timer = 0; /* Restart timer. */
/* Clear player escorts since they don't automatically follow. */ /* Clear player escorts since they don't automatically follow. */
if(player) { if(player) {
@ -974,7 +1011,7 @@ static StarSystem* system_parse(StarSystem* sys, const xmlNodePtr parent) {
} }
else if(xml_isNode(cur, "interference")) { else if(xml_isNode(cur, "interference")) {
flags |= FLAG_INTEFERENCESET; flags |= FLAG_INTEFERENCESET;
sys->interference = xml_getFloat(cur)/100; sys->interference = xml_getFloat(cur);
} }
else if(xml_isNode(cur, "nebulae")) { else if(xml_isNode(cur, "nebulae")) {
ptrc = xml_nodeProp(cur, "volatility"); ptrc = xml_nodeProp(cur, "volatility");

View File

@ -106,7 +106,7 @@ static void think_seeker(Weapon* w, const double dt);
static void think_beam(Weapon* w, const double dt); static void think_beam(Weapon* w, const double dt);
/* Extern. */ /* Extern. */
void weapon_minimap(const double res, const double w, void weapon_minimap(const double res, const double w,
const double h, const RadarShape shape); const double h, const RadarShape shape, double alpha);
/** /**
* @fn void weapon_minimap(const double res, const double w, * @fn void weapon_minimap(const double res, const double w,
@ -123,13 +123,13 @@ void weapon_minimap(const double res, const double w,
(shape == RADAR_CIRCLE && (((x)*(x)+(y)*(y)) <= rc))) \ (shape == RADAR_CIRCLE && (((x)*(x)+(y)*(y)) <= rc))) \
glVertex2i((x),(y)) /**< Set a pixel if within range. */ glVertex2i((x),(y)) /**< Set a pixel if within range. */
void weapon_minimap(const double res, const double w, void weapon_minimap(const double res, const double w,
const double h, const RadarShape shape) { const double h, const RadarShape shape, double alpha) {
int i, rc; int i, rc;
double x, y; double x, y;
/* Begin the points. */ /* Begin the points. */
glBegin(GL_POINTS); glBegin(GL_POINTS);
COLOUR(cRadar_weap); ACOLOUR(cRadar_weap, alpha);
if(shape == RADAR_CIRCLE) if(shape == RADAR_CIRCLE)
rc = (int)(w*w); rc = (int)(w*w);