Added STOR, a block that can store a single particle and release when charged

This commit is contained in:
Simon Robertshaw 2011-08-29 16:34:53 +01:00
parent 9c458b8851
commit 26269ff052
4 changed files with 61 additions and 4 deletions

View File

@ -139,6 +139,7 @@
#define PT_CO2 80
#define PT_DRIC 81
#define PT_CBNW 82
#define PT_STOR 83
#define PT_SPNG 90
#define PT_RIME 91
@ -324,6 +325,7 @@ int update_WIRE(UPDATE_FUNC_ARGS);
int update_GBMB(UPDATE_FUNC_ARGS);
int update_CO2(UPDATE_FUNC_ARGS);
int update_CBNW(UPDATE_FUNC_ARGS);
int update_STOR(UPDATE_FUNC_ARGS);
int update_MISC(UPDATE_FUNC_ARGS);
int update_legacy_PYRO(UPDATE_FUNC_ARGS);
@ -486,7 +488,7 @@ static const part_type ptypes[PT_NUM] =
{"CO2", PIXPACK(0x666666), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.1f, 0.1f, 1.0f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+273.15f, 88, "Carbon Dioxide", ST_GAS, TYPE_GAS, &update_CO2},
{"DRIC", PIXPACK(0xE0E0E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0005f* CFDS, 0, 0, 0, 0, 20, 1, 1, 100, SC_SOLIDS, 172.65f, 2, "Dry Ice.", ST_SOLID, TYPE_SOLID, NULL},
{"BUBW", 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, "Carbonated water. Conducts electricity. Freezes. Extinguishes fires.", ST_LIQUID, TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_CBNW},
/*FREE*/{"AMOE", PIXPACK(0xFF00FF), 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, "Amoeba! B357/S1358", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
{"STOR", PIXPACK(0x50DFDF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_POWERED, R_TEMP+0.0f +273.15f, 251, "Solid. Stores a single particle, releases when charged with PSCN, also passes to PIPE", ST_NONE, TYPE_SOLID, &update_STOR},
/*FREE*/{"MOVE", PIXPACK(0xFFFFFF), 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, "'Move' particles! Does not move things.. it is a life type B368/S245", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
/*FREE*/{"PGOL", PIXPACK(0xE05010), 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, "Pseudo Life! B357/S238", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
/*FREE*/{"DMOE", PIXPACK(0x500000), 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, "Diamoeba! B35678/S5678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL},
@ -659,7 +661,7 @@ static part_transition ptransitions[PT_NUM] =
/* CO2 */ {IPL, NT, IPH, NT, 194.65f,PT_DRIC, ITH, NT},
/* DRIC */ {IPL, NT, IPH, NT, ITL, NT, 195.65f,PT_CO2},
/* CBNW */ {IPL, NT, IPH, NT, 273.15f,PT_ICEI, 373.0f, PT_WTRV},
/*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* STOR */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},

View File

@ -152,6 +152,16 @@ int update_PIPE(UPDATE_FUNC_ARGS) {
parts[i].pavg[1] = parts[r>>8].ctype;
kill_part(r>>8);
}
else if ((parts[i].tmp&0xFF) == 0 && (r&0xFF)==PT_STOR && parts[r>>8].tmp && (ptypes[parts[r>>8].tmp].falldown!= 0 || ptypes[parts[r>>8].tmp].state == ST_GAS))
{
parts[i].tmp = parts[r>>8].tmp;
parts[i].temp = parts[r>>8].temp;
parts[i].flags = parts[r>>8].flags;
parts[i].pavg[0] = parts[r>>8].pavg[0];
parts[i].pavg[1] = parts[r>>8].pavg[1];
parts[r>>8].tmp = 0;
parts[r>>8].life = 0;
}
}
}
}

43
src/elements/stor.c Normal file
View File

@ -0,0 +1,43 @@
#include <element.h>
int update_STOR(UPDATE_FUNC_ARGS) {
int r, rx, ry, np, rx1, ry1;
if(parts[i].life && !parts[i].tmp)
parts[i].life--;
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>>8)>=NPART || !r)
continue;
if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && (r&0xFF)==parts[i].ctype && !(ptypes[(r&0xFF)].properties&TYPE_SOLID))
{
parts[i].tmp = parts[r>>8].type;
parts[i].temp = parts[r>>8].temp;
parts[i].flags = parts[r>>8].life;
parts[i].pavg[0] = parts[r>>8].tmp;
parts[i].pavg[1] = parts[r>>8].ctype;
kill_part(r>>8);
}
if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN)
{
for(rx1 = 1; rx1 >= -1; rx1--){
for(ry1 = 0; ry1 >= -1 && ry1 <= 1; ry1 = -ry1-ry1+1){ // Oscilate the Y starting at 0, 1, -1, 3, -5, etc (Though stop at -1)
np = create_part(-1,x+rx1,y+ry1,parts[i].tmp);
if (np!=-1)
{
parts[np].temp = parts[i].temp;
parts[np].life = parts[i].flags;
parts[np].tmp = parts[i].pavg[0];
parts[np].ctype = parts[i].pavg[1];
parts[i].tmp = 0;
parts[i].life = 10;
break;
}
}
}
}
}
return 0;
}

View File

@ -752,6 +752,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
if (pmap[y][x])
{
if ((
(pmap[y][x]&0xFF)==PT_STOR||
(pmap[y][x]&0xFF)==PT_CLNE||
(pmap[y][x]&0xFF)==PT_BCLN||
((pmap[y][x]&0xFF)==PT_PCLN&&t!=PT_PSCN&&t!=PT_NSCN)||
@ -759,11 +760,12 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a
)&&(
t!=PT_CLNE&&t!=PT_PCLN&&
t!=PT_BCLN&&t!=PT_STKM&&
t!=PT_STKM2&&t!=PT_PBCN)
t!=PT_STKM2&&t!=PT_PBCN&&
t!=PT_STOR)
)
{
parts[pmap[y][x]>>8].ctype = t;
if (t==PT_LIFE && v<NGOLALT) parts[pmap[y][x]>>8].tmp = v;
if (t==PT_LIFE && v<NGOLALT && (pmap[y][x]&0xFF)!=PT_STOR) parts[pmap[y][x]>>8].tmp = v;
}
return -1;
}