From efc7565b6fb2958d7b50229178cd59835d06f9a0 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 26 Aug 2011 11:56:46 +0100 Subject: [PATCH] More stuff for CO2 --- includes/powder.h | 15 ++++++---- src/elements/cbnw.c | 71 +++++++++++++++++++++++++++++++++++++++++++++ src/elements/co2.c | 7 +++++ src/elements/plnt.c | 2 +- src/graphics.c | 11 +++++++ 5 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 src/elements/cbnw.c diff --git a/includes/powder.h b/includes/powder.h index 2b33f0098..1f6896467 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -137,6 +137,8 @@ #define PT_LIFE 78 #define PT_DLAY 79 #define PT_CO2 80 +#define PT_DRIC 81 +#define PT_CBNW 82 #define PT_SPNG 90 #define PT_RIME 91 @@ -321,6 +323,7 @@ int update_DLAY(UPDATE_FUNC_ARGS); 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_MISC(UPDATE_FUNC_ARGS); int update_legacy_PYRO(UPDATE_FUNC_ARGS); @@ -480,9 +483,9 @@ static const part_type ptypes[PT_NUM] = {"MORT", PIXPACK(0xE0E0E0), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, 1, -1, SC_CRACKER2, R_TEMP+4.0f +273.15f, 60, "Steam Train.", ST_NONE, TYPE_PART, &update_MORT}, {"LIFE", PIXPACK(0x0CAC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 1, 100, SC_LIFE, 9000.0f, 40, "Game Of Life! B3/S23", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, {"DLAY", PIXPACK(0x753590), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_POWERED, 4.0f+273.15f, 0, "Conducts with temperature-dependent delay. (use HEAT/COOL).", ST_SOLID, TYPE_SOLID, &update_DLAY}, - {"CO2", PIXPACK(0x666666), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.1f, 0.1f, 0.5f, 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}, - /*FREE*/{"2x2", PIXPACK(0xFFFF00), 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, "2x2! B36/S125", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, - /*FREE*/{"DANI", PIXPACK(0x00FFFF), 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, "Day and Night! B3678/S34678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL}, + {"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}, /*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}, @@ -653,9 +656,9 @@ static part_transition ptransitions[PT_NUM] = /* MORT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* LIFE */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* DLAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, - /* CO2 */ {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}, + /* 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}, /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, diff --git a/src/elements/cbnw.c b/src/elements/cbnw.c new file mode 100644 index 000000000..7329f96d6 --- /dev/null +++ b/src/elements/cbnw.c @@ -0,0 +1,71 @@ +#include + +int update_CBNW(UPDATE_FUNC_ARGS) { + int r, rx, ry, oldt; + oldt = parts[i].tmp; + if (parts[i].tmp>0) + parts[i].tmp--; + if(!(rand()%200)) + { + parts[i].tmp2 = rand()%40; + } else if(parts[i].tmp2!=20) { + parts[i].tmp2 -= (parts[i].tmp2>20)?1:-1; + } + if(oldt==1) + { + //Explode + if(!(rand()%2)) + { + part_change_type(i,x,y,PT_WATR); + } else { + pv[y/CELL][x/CELL] += 0.5f; + part_change_type(i,x,y,PT_CO2); + } + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_SALT && parts[i].tmp == 0 && 1>(rand()%250)) + { + //Start explode + parts[i].tmp = (rand()%100)+50; + } + if ((r&0xFF)==PT_CBNW) + { + if(!parts[i].tmp && parts[r>>8].tmp) + { + parts[i].tmp = parts[r>>8].tmp; + if((r>>8)>i) //If the other particle hasn't been life updated + parts[i].tmp--; + } + else if(parts[i].tmp && !parts[r>>8].tmp) + { + parts[r>>8].tmp = parts[i].tmp; + if((r>>8)>i) //If the other particle hasn't been life updated + parts[r>>8].tmp++; + } + } + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500)) + { + part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + } + if ((r&0xFF)==PT_FIRE){ + kill_part(r>>8); + if(1>(rand()%150)){ + kill_part(i); + return 1; + } + } + /*if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) Concrete+Water to paste, not very popular + { + part_change_type(i,x,y,PT_PSTE); + kill_part(r>>8); + }*/ + } + return 0; +} diff --git a/src/elements/co2.c b/src/elements/co2.c index 9c5463a4f..e9114a8cb 100644 --- a/src/elements/co2.c +++ b/src/elements/co2.c @@ -9,6 +9,13 @@ int update_CO2(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if ((r>>8)>=NPART || !r) continue; + if ((r&0xFF)==PT_FIRE){ + kill_part(r>>8); + if(1>(rand()%150)){ + kill_part(i); + return 1; + } + } /*if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) Concrete+Water to paste, not very popular { part_change_type(i,x,y,PT_PSTE); diff --git a/src/elements/plnt.c b/src/elements/plnt.c index 2ca38dde7..5baec2f67 100644 --- a/src/elements/plnt.c +++ b/src/elements/plnt.c @@ -20,7 +20,7 @@ int update_PLNT(UPDATE_FUNC_ARGS) { part_change_type(i,x,y,PT_FIRE); parts[i].life = 4; } - else if ((r&0xFF)==PT_SMKE && (1>rand()%250)) + else if (((r&0xFF)==PT_SMKE || (r&0xFF)==PT_CO2) && (1>rand()%250)) { kill_part(r>>8); parts[i].life = rand()%60 + 60; diff --git a/src/graphics.c b/src/graphics.c index 3ea811fdc..1016adb65 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -2138,6 +2138,17 @@ void draw_parts(pixel *vid) cb = cb>255?255:cb; blendpixel(vid, nx, ny, cr, cg, cb, 255); } + else if (t==PT_CBNW) + { + int z = parts[i].tmp2 - 20;//speckles! + cr = z * 1 + PIXR(ptypes[t].pcolors); + cg = z * 2 + PIXG(ptypes[t].pcolors); + cb = z * 8 + PIXB(ptypes[t].pcolors); + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } else if (t==PT_SPNG) { cr = PIXR(ptypes[t].pcolors) - parts[i].life*15;