summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacksonmj <mj-pt@jacksonmj.co.uk>2012-06-20 20:45:33 (GMT)
committer jacksonmj <mj-pt@jacksonmj.co.uk>2012-06-20 21:15:45 (GMT)
commit1d5b08194291db72c05e68eed592e8fcb6101c63 (patch)
tree39945df4b183ef2bbcaf0cc1432a3a02b547f5f6 /src
parent9b2c2a78a6f4ba4fb13f04f17a649caeaf416d8d (diff)
downloadpowder-1d5b08194291db72c05e68eed592e8fcb6101c63.zip
powder-1d5b08194291db72c05e68eed592e8fcb6101c63.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/elementdata.c4
-rw-r--r--src/elements/bang.c4
-rw-r--r--src/elements/bomb.c108
-rw-r--r--src/elements/elec.c18
-rw-r--r--src/elements/embr.c94
-rw-r--r--src/elements/firw.c65
-rw-r--r--src/elements/fwrk.c50
-rw-r--r--src/elements/ignt.c4
-rw-r--r--src/elements/newgraphics.c51
-rw-r--r--src/powder.c9
-rw-r--r--src/save.c53
11 files changed, 259 insertions, 201 deletions
diff --git a/src/elementdata.c b/src/elementdata.c
index fc3d8df..ddcb9b2 100644
--- a/src/elementdata.c
+++ b/src/elementdata.c
@@ -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
{"", 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},
{"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
@@ -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},
{"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*/{"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},
{"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},
diff --git a/src/elements/bang.c b/src/elements/bang.c
index d827f33..1a2a1ec 100644
--- a/src/elements/bang.c
+++ b/src/elements/bang.c
@@ -73,8 +73,8 @@ int update_BANG(UPDATE_FUNC_ARGS) {
{
if(!(rand()%15))
{
- create_part(i, x, y, PT_BOMB);
- parts[i].tmp = 1;
+ create_part(i, x, y, PT_EMBR);
+ parts[i].tmp = 0;
parts[i].life = 50;
parts[i].temp = restrict_flt((MAX_TEMP/3)+otemp, MIN_TEMP, MAX_TEMP);
parts[i].vx = rand()%20-10;
diff --git a/src/elements/bomb.c b/src/elements/bomb.c
index e8544c9..f60c86b 100644
--- a/src/elements/bomb.c
+++ b/src/elements/bomb.c
@@ -17,84 +17,52 @@
int update_BOMB(UPDATE_FUNC_ARGS) {
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))
+ for (rx=-2; rx<3; rx++)
+ for (ry=-2; ry<3; 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 ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_EMBR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN)
{
- 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 (ry=-2; ry<3; 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 ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) {
- int rad = 8;
- int nxi;
- int nxj;
- pmap[y][x] = 0;
- for (nxj=-rad; nxj<=rad; nxj++)
- for (nxi=-rad; nxi<=rad; nxi++)
- 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) {
- delete_part(x+nxi, y+nxj, 0);//it SHOULD kill anything but the exceptions above, doesn't seem to always work
- pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f;
- nb = create_part(-1, x+nxi, y+nxj, PT_BOMB);
- if (nb!=-1) {
- parts[nb].tmp = 2;
- parts[nb].life = 2;
- parts[nb].temp = MAX_TEMP;
- }
- }
- for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
- for (nxi=-(rad+1); nxi<=(rad+1); nxi++)
- if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1) {
- nb = create_part(-1, x+nxi, y+nxj, PT_BOMB);
+ int rad = 8;
+ int nxi;
+ int nxj;
+ pmap[y][x] = 0;
+ for (nxj=-rad; nxj<=rad; nxj++)
+ for (nxi=-rad; nxi<=rad; nxi++)
+ 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) {
+ delete_part(x+nxi, y+nxj, 0);
+ pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f;
+ nb = create_part(-3, x+nxi, y+nxj, PT_EMBR);
if (nb!=-1) {
- parts[nb].tmp = 1;
- parts[nb].life = 50;
+ parts[nb].tmp = 2;
+ parts[nb].life = 2;
parts[nb].temp = MAX_TEMP;
- parts[nb].vx = rand()%20-10;
- parts[nb].vy = rand()%20-10;
}
}
- //create_parts(x, y, 9, 9, PT_BOMB);
- //create_parts(x, y, 8, 8, PT_NONE);
- kill_part(i);
- return 1;
- }
+ for (nxj=-(rad+1); nxj<=(rad+1); nxj++)
+ for (nxi=-(rad+1); nxi<=(rad+1); nxi++)
+ 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(-3, x+nxi, y+nxj, PT_EMBR);
+ if (nb!=-1) {
+ parts[nb].tmp = 0;
+ parts[nb].life = 50;
+ parts[nb].temp = MAX_TEMP;
+ parts[nb].vx = rand()%40-20;
+ parts[nb].vy = rand()%40-20;
+ }
+ }
+ kill_part(i);
+ return 1;
}
- }
+ }
return 0;
}
int graphics_BOMB(GRAPHICS_FUNC_ARGS)
{
- if (cpart->tmp==0) {
- //Normal bomb
- *pixel_mode |= PMODE_FLARE;
- }
- 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;
+ *pixel_mode |= PMODE_FLARE;
+ return 1;
}
diff --git a/src/elements/elec.c b/src/elements/elec.c
index 3d8471d..bafe939 100644
--- a/src/elements/elec.c
+++ b/src/elements/elec.c
@@ -34,25 +34,31 @@ int update_ELEC(UPDATE_FUNC_ARGS) {
continue;
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 (rry=-1; rry<=1; rry++)
{
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) {
- parts[nb].tmp = 1;
+ parts[nb].tmp = 0;
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].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);
return 1;
}
diff --git a/src/elements/embr.c b/src/elements/embr.c
new file mode 100644
index 0000000..16c4e70
--- /dev/null
+++ b/src/elements/embr.c
@@ -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;
+}
diff --git a/src/elements/firw.c b/src/elements/firw.c
index 5bb8f3d..3f392b6 100644
--- a/src/elements/firw.c
+++ b/src/elements/firw.c
@@ -14,10 +14,11 @@
*/
#include <element.h>
+#include "hmap.h"
int update_FIRW(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt, np;
- if (parts[i].tmp==0) {
+ if (parts[i].tmp<=0) {
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))
@@ -29,52 +30,42 @@ int update_FIRW(UPDATE_FUNC_ARGS) {
if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR)
{
parts[i].tmp = 1;
- parts[i].life = rand()%50+60;
+ parts[i].life = rand()%40+60;
}
}
}
else if (parts[i].tmp==1) {
- if (parts[i].life==0) {
+ if (parts[i].life<=0) {
parts[i].tmp=2;
} else {
- float newVel = parts[i].life/25;
- parts[i].flags &= ~FLAG_STAGNANT;
- /* 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;
+ // TODO: different gravity modes + Newtonian gravity
+ parts[i].vy = -parts[i].life*0.04f - 0.1f;
}
}
- else if (parts[i].tmp==2) {
- int col = rand()%200+4;
- int tmul;
- for (rx=-2; rx<3; rx++)
- for (ry=-2; ry<3; ry++)
- if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
- {
- tmul = rand()%7;
- np = create_part(-1, x+rx, y+ry, PT_FIRW);
- if (np>-1)
- {
- parts[np].vx = (rand()%3-1)*tmul;
- parts[np].vy = (rand()%3-1)*tmul;
- parts[np].tmp = col;
- parts[np].life = rand()%100+100;
- parts[np].temp = 6000.0f;
- parts[np].dcolour = parts[i].dcolour;
- }
- }
- pv[y/CELL][x/CELL] += 20;
+ else if (parts[i].tmp>=2) {
+ float angle, magnitude;
+ int caddress = (rand()%200)*3;
+ int n;
+ unsigned col = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2]));
+ for (n=0; n<40; n++)
+ {
+ np = create_part(-3, x, y, PT_EMBR);
+ if (np>-1)
+ {
+ magnitude = ((rand()%60)+40)*0.05f;
+ angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
+ parts[np].vx = parts[i].vx + cosf(angle)*magnitude;
+ parts[np].vy = parts[i].vy + sinf(angle)*magnitude - 2.5f;
+ 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;
+ }
+ }
+ pv[y/CELL][x/CELL] += 8.0f;
kill_part(i);
return 1;
- } else if (parts[i].tmp>=3) {
- if (parts[i].life<=0) {
- kill_part(i);
- return 1;
- }
}
return 0;
}
diff --git a/src/elements/fwrk.c b/src/elements/fwrk.c
index 173b6e7..f54877b 100644
--- a/src/elements/fwrk.c
+++ b/src/elements/fwrk.c
@@ -34,33 +34,29 @@ int update_FWRK(UPDATE_FUNC_ARGS) {
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 w = (rand()%255+1);
- int e = (rand()%255+1);
- for (rx=-1; rx<2; rx++)
- for (ry=-2; ry<3; ry++)
- if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
- {
- if (5>=rand()%8)
- {
- if (!pmap[y+ry][x+rx])
- {
- np = create_part(-1, x+rx, y+ry , PT_DUST);
- pv[y/CELL][x/CELL] += 2.00f*CFDS;
- if (np!=-1)
- {
- parts[np].vy = -(rand()%10-1);
- parts[np].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
- 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;
- }
- }
- }
- }
+ int r = (rand()%245+11);
+ int g = (rand()%245+11);
+ int b = (rand()%245+11);
+ int n;
+ float angle, magnitude;
+ unsigned col = (r<<16) | (g<<8) | b;
+ for (n=0; n<40; n++)
+ {
+ np = create_part(-3, x, y, PT_EMBR);
+ if (np>-1)
+ {
+ magnitude = ((rand()%60)+40)*0.05f;
+ angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
+ parts[np].vx = parts[i].vx + cosf(angle)*magnitude;
+ parts[np].vy = parts[i].vy + sinf(angle)*magnitude - 2.5f;
+ 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;
+ }
+ }
+ pv[y/CELL][x/CELL] += 8.0f;
kill_part(i);
return 1;
}
diff --git a/src/elements/ignt.c b/src/elements/ignt.c
index 36f48a3..bf706bc 100644
--- a/src/elements/ignt.c
+++ b/src/elements/ignt.c
@@ -40,9 +40,9 @@ int update_IGNT(UPDATE_FUNC_ARGS) {
{
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) {
- parts[nb].tmp = 1;
+ parts[nb].tmp = 0;
parts[nb].life = 30;
parts[nb].vx = rand()%20-10;
parts[nb].vy = rand()%20-10;
diff --git a/src/elements/newgraphics.c b/src/elements/newgraphics.c
index 946afc8..c8581f6 100644
--- a/src/elements/newgraphics.c
+++ b/src/elements/newgraphics.c
@@ -117,29 +117,6 @@ int graphics_LIFE(GRAPHICS_FUNC_ARGS)
*colb = PIXB(pc);
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)
{
*colr = 20;
@@ -497,33 +474,7 @@ int graphics_HFLM(GRAPHICS_FUNC_ARGS)
}
int graphics_FIRW(GRAPHICS_FUNC_ARGS)
{
- if(cpart->tmp>=3)
- {
- 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)
+ if(cpart->tmp > 0)
{
*pixel_mode |= PMODE_GLOW;
}
diff --git a/src/powder.c b/src/powder.c
index 9dd2fd1..fd01dd6 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -184,6 +184,7 @@ void init_can_move()
can_move[PT_ANAR][PT_WHOL] = 1;
can_move[PT_ANAR][PT_NWHL] = 1;
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);
- if ((r&0xFF)==PT_BOMB && parts[i].type==PT_BOMB && parts[i].tmp == 1)
- e = 2;
-
/* half-silvered mirror */
if (!e && parts[i].type==PT_PHOT &&
(((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].tmp = 244;
break;
+ case PT_EMBR:
+ parts[i].life = 50;
+ break;
case PT_STKM:
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);
// Count number of particles at each location, for excess stacking check
// (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]++;
}
}
diff --git a/src/save.c b/src/save.c
index 9a10235..e8990db 100644
--- a/src/save.c
+++ b/src/save.c
@@ -22,6 +22,7 @@
#include "save.h"
#include "gravity.h"
#include "BSON.h"
+#include "hmap.h"
//Pop
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 *freeIndices = NULL;
int blockX, blockY, blockW, blockH, fullX, fullY, fullW, fullH;
+ int saved_version = inputData[4];
bson b;
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;
//From newer version
- if(inputData[4] > SAVE_VERSION)
+ if(saved_version > SAVE_VERSION)
{
fprintf(stderr, "Save from newer version\n");
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)
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)
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]));
+ }
+ }
}
}