Replace all explosion sparks with new element (EMBR)

Replaces: BOMB sparks and flash, electrons + glass sparks, sparks from
IGNC, sparks from TNT explosion, and sparks from FWRK and FIRW.
This commit is contained in:
jacksonmj 2012-06-20 21:45:33 +01:00
parent 9b2c2a78a6
commit 1d5b081942
12 changed files with 262 additions and 202 deletions

View File

@ -223,6 +223,7 @@
#define PT_EXOT 145 #define PT_EXOT 145
#define OLD_PT_WIND 147 #define OLD_PT_WIND 147
#define PT_EMBR 147
#define PT_H2 148 #define PT_H2 148
#define PT_SOAP 149 #define PT_SOAP 149
#define PT_NBHL 150 #define PT_NBHL 150
@ -310,7 +311,6 @@ int graphics_CLST(GRAPHICS_FUNC_ARGS);
int graphics_CBNW(GRAPHICS_FUNC_ARGS); int graphics_CBNW(GRAPHICS_FUNC_ARGS);
int graphics_SPNG(GRAPHICS_FUNC_ARGS); int graphics_SPNG(GRAPHICS_FUNC_ARGS);
int graphics_LIFE(GRAPHICS_FUNC_ARGS); int graphics_LIFE(GRAPHICS_FUNC_ARGS);
int graphics_DUST(GRAPHICS_FUNC_ARGS);
int graphics_GRAV(GRAPHICS_FUNC_ARGS); int graphics_GRAV(GRAPHICS_FUNC_ARGS);
int graphics_WIFI(GRAPHICS_FUNC_ARGS); int graphics_WIFI(GRAPHICS_FUNC_ARGS);
int graphics_PRTI(GRAPHICS_FUNC_ARGS); int graphics_PRTI(GRAPHICS_FUNC_ARGS);
@ -354,6 +354,7 @@ int graphics_SOAP(GRAPHICS_FUNC_ARGS);
int graphics_EXOT(GRAPHICS_FUNC_ARGS); int graphics_EXOT(GRAPHICS_FUNC_ARGS);
int graphics_WARP(GRAPHICS_FUNC_ARGS); int graphics_WARP(GRAPHICS_FUNC_ARGS);
int graphics_stickmen(GRAPHICS_FUNC_ARGS); int graphics_stickmen(GRAPHICS_FUNC_ARGS);
int graphics_EMBR(GRAPHICS_FUNC_ARGS);
void TRON_init_graphics(); void TRON_init_graphics();
@ -389,6 +390,7 @@ int update_CLNE(UPDATE_FUNC_ARGS);
int update_COAL(UPDATE_FUNC_ARGS); int update_COAL(UPDATE_FUNC_ARGS);
int update_DEUT(UPDATE_FUNC_ARGS); int update_DEUT(UPDATE_FUNC_ARGS);
int update_DSTW(UPDATE_FUNC_ARGS); int update_DSTW(UPDATE_FUNC_ARGS);
int update_EMBR(UPDATE_FUNC_ARGS);
int update_FOG(UPDATE_FUNC_ARGS); int update_FOG(UPDATE_FUNC_ARGS);
int update_FRZW(UPDATE_FUNC_ARGS); int update_FRZW(UPDATE_FUNC_ARGS);
int update_FRZZ(UPDATE_FUNC_ARGS); int update_FRZZ(UPDATE_FUNC_ARGS);

View File

@ -28,7 +28,7 @@ part_type ptypes[PT_NUM] =
{ {
//Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description
{"", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Erases particles.", ST_NONE, 0, NULL, NULL}, {"", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Erases particles.", ST_NONE, 0, NULL, NULL},
{"DUST", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Flammable.", ST_SOLID, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, NULL, &graphics_DUST}, {"DUST", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Flammable.", ST_SOLID, TYPE_PART, NULL, NULL},
{"WATR", PIXPACK(0x2030D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Liquid. Conducts electricity. Freezes. Extinguishes fires.", ST_LIQUID, TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_WATR, NULL}, {"WATR", PIXPACK(0x2030D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Liquid. Conducts electricity. Freezes. Extinguishes fires.", ST_LIQUID, TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_WATR, NULL},
{"OIL", PIXPACK(0x404010), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 20, 0, 0, 5, 1, 1, 20, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Flammable.", ST_LIQUID, TYPE_LIQUID, NULL, NULL}, {"OIL", PIXPACK(0x404010), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 20, 0, 0, 5, 1, 1, 20, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Flammable.", ST_LIQUID, TYPE_LIQUID, NULL, NULL},
#ifdef REALISTIC #ifdef REALISTIC
@ -178,7 +178,7 @@ part_type ptypes[PT_NUM] =
{"TTAN", PIXPACK(0x909090), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 50, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Titanium, Higher melting temperature than other metals, blocks all air pressure", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW|PROP_LIFE_DEC, &update_TTAN, NULL}, {"TTAN", PIXPACK(0x909090), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 50, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Titanium, Higher melting temperature than other metals, blocks all air pressure", ST_SOLID, TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW|PROP_LIFE_DEC, &update_TTAN, NULL},
{"EXOT", PIXPACK(0x404040), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.0003f * CFDS, 2, 0, 0, 0, 2, 1, 1, 46, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 250, "Exotic matter. Explodes with excess exposure to electrons.", ST_LIQUID, TYPE_LIQUID, &update_EXOT, &graphics_EXOT}, {"EXOT", PIXPACK(0x404040), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.0003f * CFDS, 2, 0, 0, 0, 2, 1, 1, 46, SC_NUCLEAR, R_TEMP-2.0f +273.15f, 250, "Exotic matter. Explodes with excess exposure to electrons.", ST_LIQUID, TYPE_LIQUID, &update_EXOT, &graphics_EXOT},
/*FREE*/{"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, /*FREE*/{"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL},
/*FREE*/{"WIND", PIXPACK(0x101010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_SPECIAL, 0.0f, 40, "", ST_NONE, ST_NONE, NULL, NULL}, {"EMBR", PIXPACK(0xFFF288), 0.4f, 0.001f * CFDS, 0.99f, 0.90f, 0.0f, 0.07f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 0, 1, 30, SC_EXPLOSIVE, 500.0f +273.15f, 29, "Sparks. Formed by explosions.", ST_NONE, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL|PROP_SPARKSETTLE, &update_EMBR, &graphics_EMBR},
{"HYGN", PIXPACK(0x5070FF), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.10f, 0.00f, 3.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 251, "Combines with O2 to make WATR", ST_GAS, TYPE_GAS, &update_H2, NULL}, {"HYGN", PIXPACK(0x5070FF), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.10f, 0.00f, 3.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 251, "Combines with O2 to make WATR", ST_GAS, TYPE_GAS, &update_H2, NULL},
{"SOAP", PIXPACK(0xF5F5DC), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 35, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Soap. Creates bubbles.", ST_LIQUID, TYPE_LIQUID|PROP_NEUTPENETRATE|PROP_LIFE_DEC, &update_SOAP, NULL}, {"SOAP", PIXPACK(0xF5F5DC), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 35, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Soap. Creates bubbles.", ST_LIQUID, TYPE_LIQUID|PROP_NEUTPENETRATE|PROP_LIFE_DEC, &update_SOAP, NULL},
{"BHOL", PIXPACK(0x202020), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 186, "Black hole (Requires newtonian gravity)", ST_SOLID, TYPE_SOLID, &update_NBHL, NULL}, {"BHOL", PIXPACK(0x202020), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 186, "Black hole (Requires newtonian gravity)", ST_SOLID, TYPE_SOLID, &update_NBHL, NULL},

View File

@ -73,8 +73,8 @@ int update_BANG(UPDATE_FUNC_ARGS) {
{ {
if(!(rand()%15)) if(!(rand()%15))
{ {
create_part(i, x, y, PT_BOMB); create_part(i, x, y, PT_EMBR);
parts[i].tmp = 1; parts[i].tmp = 0;
parts[i].life = 50; parts[i].life = 50;
parts[i].temp = restrict_flt((MAX_TEMP/3)+otemp, MIN_TEMP, MAX_TEMP); parts[i].temp = restrict_flt((MAX_TEMP/3)+otemp, MIN_TEMP, MAX_TEMP);
parts[i].vx = rand()%20-10; parts[i].vx = rand()%20-10;

View File

@ -17,21 +17,6 @@
int update_BOMB(UPDATE_FUNC_ARGS) { int update_BOMB(UPDATE_FUNC_ARGS) {
int r, rx, ry, nb; int r, rx, ry, nb;
//Spark is used so much now that it should be a seperate element.
if (parts[i].tmp==1) {
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (ptypes[r&0xFF].properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID) && !(ptypes[r&0xFF].properties & PROP_SPARKSETTLE)) {
kill_part(i);
return 1;
}
}
} else if (parts[i].tmp==0) {
for (rx=-2; rx<3; rx++) for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++) for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
@ -39,7 +24,8 @@ int update_BOMB(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) { if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_EMBR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN)
{
int rad = 8; int rad = 8;
int nxi; int nxi;
int nxj; int nxj;
@ -48,9 +34,9 @@ int update_BOMB(UPDATE_FUNC_ARGS) {
for (nxi=-rad; nxi<=rad; nxi++) for (nxi=-rad; nxi<=rad; nxi++)
if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1) if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1)
if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) { if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) {
delete_part(x+nxi, y+nxj, 0);//it SHOULD kill anything but the exceptions above, doesn't seem to always work delete_part(x+nxi, y+nxj, 0);
pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f;
nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); nb = create_part(-3, x+nxi, y+nxj, PT_EMBR);
if (nb!=-1) { if (nb!=-1) {
parts[nb].tmp = 2; parts[nb].tmp = 2;
parts[nb].life = 2; parts[nb].life = 2;
@ -59,42 +45,24 @@ int update_BOMB(UPDATE_FUNC_ARGS) {
} }
for (nxj=-(rad+1); nxj<=(rad+1); nxj++) for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
for (nxi=-(rad+1); nxi<=(rad+1); nxi++) for (nxi=-(rad+1); nxi<=(rad+1); nxi++)
if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1) { if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1 && !(pmap[y+nxj][x+nxi]&0xFF)) {
nb = create_part(-1, x+nxi, y+nxj, PT_BOMB); nb = create_part(-3, x+nxi, y+nxj, PT_EMBR);
if (nb!=-1) { if (nb!=-1) {
parts[nb].tmp = 1; parts[nb].tmp = 0;
parts[nb].life = 50; parts[nb].life = 50;
parts[nb].temp = MAX_TEMP; parts[nb].temp = MAX_TEMP;
parts[nb].vx = rand()%20-10; parts[nb].vx = rand()%40-20;
parts[nb].vy = rand()%20-10; parts[nb].vy = rand()%40-20;
} }
} }
//create_parts(x, y, 9, 9, PT_BOMB);
//create_parts(x, y, 8, 8, PT_NONE);
kill_part(i); kill_part(i);
return 1; return 1;
} }
} }
}
return 0; return 0;
} }
int graphics_BOMB(GRAPHICS_FUNC_ARGS) int graphics_BOMB(GRAPHICS_FUNC_ARGS)
{ {
if (cpart->tmp==0) {
//Normal bomb
*pixel_mode |= PMODE_FLARE; *pixel_mode |= PMODE_FLARE;
} return 1;
else if(cpart->tmp==2)
{
//Flash
*pixel_mode = PMODE_FLAT | FIRE_ADD;
*colr = *colg = *colb = *firer = *fireg = *fireb = *firea = 255;
}
else
{
//Flying spark
*pixel_mode = PMODE_SPARK | PMODE_ADD;
*cola = 4*cpart->life;
}
return 0;
} }

View File

@ -34,25 +34,31 @@ int update_ELEC(UPDATE_FUNC_ARGS) {
continue; continue;
if ((r&0xFF)==PT_GLAS) if ((r&0xFF)==PT_GLAS)
{ {
fire_r[y/CELL][x/CELL] += rand()%200; //D: Doesn't work with OpenGL, also shouldn't be here
fire_g[y/CELL][x/CELL] += rand()%200;
fire_b[y/CELL][x/CELL] += rand()%200;
for (rrx=-1; rrx<=1; rrx++) for (rrx=-1; rrx<=1; rrx++)
{ {
for (rry=-1; rry<=1; rry++) for (rry=-1; rry<=1; rry++)
{ {
if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx<XRES && y+ry+rry<YRES) { if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx<XRES && y+ry+rry<YRES) {
nb = create_part(-1, x+rx+rrx, y+ry+rry, PT_BOMB); nb = create_part(-1, x+rx+rrx, y+ry+rry, PT_EMBR);
if (nb!=-1) { if (nb!=-1) {
parts[nb].tmp = 1; parts[nb].tmp = 0;
parts[nb].life = 50; parts[nb].life = 50;
parts[nb].temp = 400.0f; parts[nb].temp = parts[i].temp*0.8f;
parts[nb].vx = rand()%20-10; parts[nb].vx = rand()%20-10;
parts[nb].vy = rand()%20-10; parts[nb].vy = rand()%20-10;
} }
} }
} }
} }
fire_r[y/CELL][x/CELL] += rand()%200; //D: Doesn't work with OpenGL, also shouldn't be here
fire_g[y/CELL][x/CELL] += rand()%200;
fire_b[y/CELL][x/CELL] += rand()%200;
/* possible alternative, but doesn't work well at the moment because FIRE_ADD divides firea by 8, so the glow isn't strong enough
create_part(i, x, y, PT_EMBR);
parts[i].tmp = 2;
parts[i].life = 2;
parts[i].ctype = ((rand()%200)<<16) | ((rand()%200)<<8) | (rand()%200);
*/
kill_part(i); kill_part(i);
return 1; return 1;
} }

94
src/elements/embr.c Normal file
View File

@ -0,0 +1,94 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <element.h>
/* ctype - colour RRGGBB (optional)
* life - decremented each frame, disappears when life reaches zero
* tmp - mode
* 0 - BOMB sparks
* 1 - firework sparks (colour defaults to white)
* 2 - flash (colour defaults to white)
*/
int update_EMBR(UPDATE_FUNC_ARGS) {
int r, rx, ry, nb;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((ptypes[r&0xFF].properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(ptypes[r&0xFF].properties & PROP_SPARKSETTLE))
{
kill_part(i);
return 1;
}
}
return 0;
}
int graphics_EMBR(GRAPHICS_FUNC_ARGS)
{
if (cpart->ctype&0xFFFFFF)
{
int maxComponent;
*colr = (cpart->ctype&0xFF0000)>>16;
*colg = (cpart->ctype&0x00FF00)>>8;
*colb = (cpart->ctype&0x0000FF);
maxComponent = *colr;
if (*colg>maxComponent) maxComponent = *colg;
if (*colb>maxComponent) maxComponent = *colb;
if (maxComponent<60)//make sure it isn't too dark to see
{
float multiplier = 60.0f/maxComponent;
*colr *= multiplier;
*colg *= multiplier;
*colb *= multiplier;
}
}
else if (cpart->tmp != 0)
{
*colr = *colg = *colb = 255;
}
if (decorations_enable && cpart->dcolour)
{
int a = (cpart->dcolour>>24)&0xFF;
*colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8;
*colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8;
*colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8;
}
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
if (cpart->tmp==1)
{
*pixel_mode = FIRE_ADD | PMODE_BLEND | PMODE_GLOW;
*firea = (cpart->life-15)*4;
*cola = (cpart->life+15)*4;
}
else if (cpart->tmp==2)
{
*pixel_mode = PMODE_FLAT | FIRE_ADD;
*firea = 255;
}
else
{
*pixel_mode = PMODE_SPARK | PMODE_ADD;
if (cpart->life<64) *cola = 4*cpart->life;
}
return 0;
}

View File

@ -14,10 +14,11 @@
*/ */
#include <element.h> #include <element.h>
#include "hmap.h"
int update_FIRW(UPDATE_FUNC_ARGS) { int update_FIRW(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt, np; int r, rx, ry, rt, np;
if (parts[i].tmp==0) { if (parts[i].tmp<=0) {
for (rx=-1; rx<2; rx++) for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++) for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
@ -29,52 +30,42 @@ int update_FIRW(UPDATE_FUNC_ARGS) {
if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR) if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR)
{ {
parts[i].tmp = 1; parts[i].tmp = 1;
parts[i].life = rand()%50+60; parts[i].life = rand()%40+60;
} }
} }
} }
else if (parts[i].tmp==1) { else if (parts[i].tmp==1) {
if (parts[i].life==0) { if (parts[i].life<=0) {
parts[i].tmp=2; parts[i].tmp=2;
} else { } else {
float newVel = parts[i].life/25; // TODO: different gravity modes + Newtonian gravity
parts[i].flags &= ~FLAG_STAGNANT; parts[i].vy = -parts[i].life*0.04f - 0.1f;
/* TODO:
if ((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) {
parts[i].vy = -newVel;
ly-=newVel;
iy-=newVel;
}*/
parts[i].vy = -newVel;
} }
} }
else if (parts[i].tmp==2) { else if (parts[i].tmp>=2) {
int col = rand()%200+4; float angle, magnitude;
int tmul; int caddress = (rand()%200)*3;
for (rx=-2; rx<3; rx++) int n;
for (ry=-2; ry<3; ry++) unsigned col = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2]));
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) for (n=0; n<40; n++)
{ {
tmul = rand()%7; np = create_part(-3, x, y, PT_EMBR);
np = create_part(-1, x+rx, y+ry, PT_FIRW);
if (np>-1) if (np>-1)
{ {
parts[np].vx = (rand()%3-1)*tmul; magnitude = ((rand()%60)+40)*0.05f;
parts[np].vy = (rand()%3-1)*tmul; angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
parts[np].tmp = col; parts[np].vx = parts[i].vx + cosf(angle)*magnitude;
parts[np].life = rand()%100+100; parts[np].vy = parts[i].vy + sinf(angle)*magnitude - 2.5f;
parts[np].temp = 6000.0f; parts[np].ctype = col;
parts[np].tmp = 1;
parts[np].life = rand()%40+70;
parts[np].temp = (rand()%500)+5750.0f;
parts[np].dcolour = parts[i].dcolour; parts[np].dcolour = parts[i].dcolour;
} }
} }
pv[y/CELL][x/CELL] += 20; pv[y/CELL][x/CELL] += 8.0f;
kill_part(i); kill_part(i);
return 1; return 1;
} else if (parts[i].tmp>=3) {
if (parts[i].life<=0) {
kill_part(i);
return 1;
}
} }
return 0; return 0;
} }

View File

@ -34,33 +34,29 @@ int update_FWRK(UPDATE_FUNC_ARGS) {
parts[i].life=0; parts[i].life=0;
if ((parts[i].life<3&&parts[i].life>0)||(parts[i].vy>6&&parts[i].life>0)) if ((parts[i].life<3&&parts[i].life>0)||(parts[i].vy>6&&parts[i].life>0))
{ {
int q = (rand()%255+1); int r = (rand()%245+11);
int w = (rand()%255+1); int g = (rand()%245+11);
int e = (rand()%255+1); int b = (rand()%245+11);
for (rx=-1; rx<2; rx++) int n;
for (ry=-2; ry<3; ry++) float angle, magnitude;
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) unsigned col = (r<<16) | (g<<8) | b;
for (n=0; n<40; n++)
{ {
if (5>=rand()%8) np = create_part(-3, x, y, PT_EMBR);
if (np>-1)
{ {
if (!pmap[y+ry][x+rx]) magnitude = ((rand()%60)+40)*0.05f;
{ angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
np = create_part(-1, x+rx, y+ry , PT_DUST); parts[np].vx = parts[i].vx + cosf(angle)*magnitude;
pv[y/CELL][x/CELL] += 2.00f*CFDS; parts[np].vy = parts[i].vy + sinf(angle)*magnitude - 2.5f;
if (np!=-1) parts[np].ctype = col;
{ parts[np].tmp = 1;
parts[np].vy = -(rand()%10-1); parts[np].life = rand()%40+70;
parts[np].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ; parts[np].temp = (rand()%500)+5750.0f;
parts[np].life= rand()%37+18;
parts[np].tmp=q;
parts[np].tmp2=w;
parts[np].ctype=e;
parts[np].temp= rand()%20+6000;
parts[np].dcolour = parts[i].dcolour; parts[np].dcolour = parts[i].dcolour;
} }
} }
} pv[y/CELL][x/CELL] += 8.0f;
}
kill_part(i); kill_part(i);
return 1; return 1;
} }

View File

@ -40,9 +40,9 @@ int update_IGNT(UPDATE_FUNC_ARGS) {
{ {
if(rand()%3) if(rand()%3)
{ {
int nb = create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_BOMB); int nb = create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_EMBR);
if (nb!=-1) { if (nb!=-1) {
parts[nb].tmp = 1; parts[nb].tmp = 0;
parts[nb].life = 30; parts[nb].life = 30;
parts[nb].vx = rand()%20-10; parts[nb].vx = rand()%20-10;
parts[nb].vy = rand()%20-10; parts[nb].vy = rand()%20-10;

View File

@ -117,29 +117,6 @@ int graphics_LIFE(GRAPHICS_FUNC_ARGS)
*colb = PIXB(pc); *colb = PIXB(pc);
return 0; return 0;
} }
int graphics_DUST(GRAPHICS_FUNC_ARGS)
{
if(cpart->life >= 1)
{
*firea = 120;
*firer = *colr = cpart->tmp2;
*fireg = *colg = cpart->tmp;
*fireb = *colb = cpart->ctype;
if (decorations_enable && cpart->dcolour)
{
int a = (cpart->dcolour>>24)&0xFF;
*firer = *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8;
*fireg = *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8;
*fireb = *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8;
}
*pixel_mode |= PMODE_GLOW | FIRE_ADD;
/**firea = 255;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;*/
}
return 0;
}
int graphics_GRAV(GRAPHICS_FUNC_ARGS) int graphics_GRAV(GRAPHICS_FUNC_ARGS)
{ {
*colr = 20; *colr = 20;
@ -497,33 +474,7 @@ int graphics_HFLM(GRAPHICS_FUNC_ARGS)
} }
int graphics_FIRW(GRAPHICS_FUNC_ARGS) int graphics_FIRW(GRAPHICS_FUNC_ARGS)
{ {
if(cpart->tmp>=3) if(cpart->tmp > 0)
{
int caddress = restrict_flt(restrict_flt((float)(cpart->tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
*colr = (unsigned char)firw_data[caddress];
*colg = (unsigned char)firw_data[caddress+1];
*colb = (unsigned char)firw_data[caddress+2];
if (decorations_enable && cpart->dcolour)
{
int a = (cpart->dcolour>>24)&0xFF;
*colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8;
*colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8;
*colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8;
}
*firea = cpart->life*4;
if(*firea > 240)
*firea = 240;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
*pixel_mode = PMODE_NONE; //Clear default, don't draw pixel
*pixel_mode |= FIRE_ADD;
//Returning 0 means dynamic, do not cache
}
else if(cpart->tmp > 0)
{ {
*pixel_mode |= PMODE_GLOW; *pixel_mode |= PMODE_GLOW;
} }

View File

@ -184,6 +184,7 @@ void init_can_move()
can_move[PT_ANAR][PT_WHOL] = 1; can_move[PT_ANAR][PT_WHOL] = 1;
can_move[PT_ANAR][PT_NWHL] = 1; can_move[PT_ANAR][PT_NWHL] = 1;
can_move[PT_THDR][PT_THDR] = 2; can_move[PT_THDR][PT_THDR] = 2;
can_move[PT_EMBR][PT_EMBR] = 2;
} }
/* /*
@ -254,9 +255,6 @@ int try_move(int i, int x, int y, int nx, int ny)
e = eval_move(parts[i].type, nx, ny, &r); e = eval_move(parts[i].type, nx, ny, &r);
if ((r&0xFF)==PT_BOMB && parts[i].type==PT_BOMB && parts[i].tmp == 1)
e = 2;
/* half-silvered mirror */ /* half-silvered mirror */
if (!e && parts[i].type==PT_PHOT && if (!e && parts[i].type==PT_PHOT &&
(((r&0xFF)==PT_BMTL && rand()<RAND_MAX/2) || (((r&0xFF)==PT_BMTL && rand()<RAND_MAX/2) ||
@ -1033,6 +1031,9 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
parts[i].life = 1000; parts[i].life = 1000;
parts[i].tmp = 244; parts[i].tmp = 244;
break; break;
case PT_EMBR:
parts[i].life = 50;
break;
case PT_STKM: case PT_STKM:
if (player.spwn==0) if (player.spwn==0)
{ {
@ -2870,7 +2871,7 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but
pmap[y][x] = t|(i<<8); pmap[y][x] = t|(i<<8);
// Count number of particles at each location, for excess stacking check // Count number of particles at each location, for excess stacking check
// (does not include energy particles or THDR - currently no limit on stacking those) // (does not include energy particles or THDR - currently no limit on stacking those)
if (t!=PT_THDR) if (t!=PT_THDR && t!=PT_EMBR)
pmap_count[y][x]++; pmap_count[y][x]++;
} }
} }

View File

@ -22,6 +22,7 @@
#include "save.h" #include "save.h"
#include "gravity.h" #include "gravity.h"
#include "BSON.h" #include "BSON.h"
#include "hmap.h"
//Pop //Pop
pixel *prerender_save(void *save, int size, int *width, int *height) pixel *prerender_save(void *save, int size, int *width, int *height)
@ -854,6 +855,7 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c
int i, freeIndicesCount, x, y, returnCode = 0, j; int i, freeIndicesCount, x, y, returnCode = 0, j;
int *freeIndices = NULL; int *freeIndices = NULL;
int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH; int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
int saved_version = inputData[4];
bson b; bson b;
bson_iterator iter; bson_iterator iter;
@ -870,7 +872,7 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c
fullH = blockH*CELL; fullH = blockH*CELL;
//From newer version //From newer version
if(inputData[4] > SAVE_VERSION) if(saved_version > SAVE_VERSION)
{ {
fprintf(stderr, "Save from newer version\n"); fprintf(stderr, "Save from newer version\n");
return 2; return 2;
@ -1386,6 +1388,31 @@ int parse_save_OPS(void *save, int size, int replace, int x0, int y0, unsigned c
} }
if (!ptypes[partsptr[newIndex].type].enabled) if (!ptypes[partsptr[newIndex].type].enabled)
partsptr[newIndex].type = PT_NONE; partsptr[newIndex].type = PT_NONE;
if (saved_version<81)
{
if (partsptr[newIndex].type==PT_BOMB && partsptr[newIndex].tmp!=0)
{
partsptr[newIndex].type = PT_EMBR;
partsptr[newIndex].ctype = 0;
if (partsptr[newIndex].tmp==1)
partsptr[newIndex].tmp = 0;
}
if (partsptr[newIndex].type==PT_DUST && partsptr[newIndex].life>0)
{
partsptr[newIndex].type = PT_EMBR;
partsptr[newIndex].ctype = (partsptr[newIndex].tmp2<<16) | (partsptr[newIndex].tmp<<8) | partsptr[newIndex].ctype;
partsptr[newIndex].tmp = 1;
}
if (partsptr[newIndex].type==PT_FIRW && partsptr[newIndex].tmp>=2)
{
int caddress = restrict_flt(restrict_flt((float)(partsptr[newIndex].tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
partsptr[newIndex].type = PT_EMBR;
partsptr[newIndex].tmp = 1;
partsptr[newIndex].ctype = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2]));
}
}
} }
} }
} }
@ -2116,6 +2143,30 @@ int parse_save_PSv(void *save, int size, int replace, int x0, int y0, unsigned c
} }
if (!ptypes[parts[i-1].type].enabled) if (!ptypes[parts[i-1].type].enabled)
parts[i-1].type = PT_NONE; parts[i-1].type = PT_NONE;
if (ver<81)
{
if (parts[i-1].type==PT_BOMB && parts[i-1].tmp!=0)
{
parts[i-1].type = PT_EMBR;
parts[i-1].ctype = 0;
if (parts[i-1].tmp==1)
parts[i-1].tmp = 0;
}
if (parts[i-1].type==PT_DUST && parts[i-1].life>0)
{
parts[i-1].type = PT_EMBR;
parts[i-1].ctype = (parts[i-1].tmp2<<16) | (parts[i-1].tmp<<8) | parts[i-1].ctype;
parts[i-1].tmp = 1;
}
if (parts[i-1].type==PT_FIRW && parts[i-1].tmp>=2)
{
int caddress = restrict_flt(restrict_flt((float)(parts[i-1].tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3);
parts[i-1].type = PT_EMBR;
parts[i-1].tmp = 1;
parts[i-1].ctype = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2]));
}
}
} }
} }