diff --git a/includes/powder.h b/includes/powder.h index 55dbd4115..5f965c815 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -201,6 +201,7 @@ #define PT_BANG 139 #define PT_IGNT 140 #define PT_BOYL 141 +#define PT_GEL 142 #define OLD_PT_WIND 147 #define PT_H2 148 @@ -322,6 +323,7 @@ int graphics_ELEC(GRAPHICS_FUNC_ARGS); int graphics_WIRE(GRAPHICS_FUNC_ARGS); int graphics_ACEL(GRAPHICS_FUNC_ARGS); int graphics_DCEL(GRAPHICS_FUNC_ARGS); +int graphics_GEL(GRAPHICS_FUNC_ARGS); #define UPDATE_FUNC_ARGS int i, int x, int y, int surround_space, int nt // to call another update function with same arguments: @@ -362,6 +364,7 @@ int update_FSEP(UPDATE_FUNC_ARGS); int update_FUSE(UPDATE_FUNC_ARGS); int update_FIRW(UPDATE_FUNC_ARGS); int update_FWRK(UPDATE_FUNC_ARGS); +int update_GEL(UPDATE_FUNC_ARGS); int update_GLAS(UPDATE_FUNC_ARGS); int update_GLOW(UPDATE_FUNC_ARGS); int update_GOO(UPDATE_FUNC_ARGS); diff --git a/src/elementdata.c b/src/elementdata.c index 82e1a6740..c480123b8 100644 --- a/src/elementdata.c +++ b/src/elementdata.c @@ -156,7 +156,7 @@ part_type ptypes[PT_NUM] = {"TNT", PIXPACK(0xC05050), 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_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Explosive.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE, &update_BANG, NULL}, {"IGNC", PIXPACK(0xC0B050), 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_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Ignition cord.", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE | PROP_SPARKSETTLE | PROP_LIFE_KILL, &update_IGNT, NULL}, {"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL, NULL}, - /*FREE*/{"LOTE", PIXPACK(0xFF0000), 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, "Behaves kinda like Living on the Edge S3458/B37/4", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, + {"GEL", PIXPACK(0xFF9900), 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, "Gel. A liquid with variable viscosity and heat conductivity", ST_LIQUID, TYPE_LIQUID|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_GEL, &graphics_GEL}, /*FREE*/{"FRG2", PIXPACK(0x00FF00), 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, "Like Frogs rule S124/B3/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, /*FREE*/{"STAR", PIXPACK(0x0000FF), 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, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, /*FREE*/{"FROG", PIXPACK(0x00AA00), 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, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, @@ -332,7 +332,7 @@ part_transition ptransitions[PT_NUM] = /* TNT */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* IGNP */ {IPL, NT, IPH, NT, ITL, NT, 673.0f, PT_FIRE}, /* BOYL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, - /*FREE*//* GOL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* GEL */ {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}, @@ -499,7 +499,7 @@ unsigned int platent[PT_NUM] = /* TNT */ 0, /* IGNP */ 0, /* BOYL */ 0, - /* FREE */ 0, + /* GEL */ 0, /* FREE */ 0, /* FREE */ 0, /* FREE */ 0, diff --git a/src/elements/gel.c b/src/elements/gel.c new file mode 100644 index 000000000..af10d7cd4 --- /dev/null +++ b/src/elements/gel.c @@ -0,0 +1,52 @@ +#include + +int update_GEL(UPDATE_FUNC_ARGS) { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8); + } + + char gel = 0; + if ((r&0xFF)==PT_GEL) + gel = 1; + + //Concentration diffusion + if (gel && (parts[r>>8].tmp+1)>8].tmp++; + parts[i].tmp--; + } + + float dx, dy; + dx = parts[i].x - parts[r>>8].x; + dy = parts[i].y - parts[r>>8].y; + + //Stickness + if ((dx*dx + dy*dy)>1.5 && (gel || !ptypes[r&0xFF].falldown || (fabs(rx)<2 && fabs(ry)<2))) + { + float per, nd; + nd = dx*dx + dy*dy - 0.5; + + per = 5*(1 - parts[i].tmp/100)*(nd/(dx*dx + dy*dy + nd) - 0.5); + if (ptypes[r&0xFF].state==ST_LIQUID) + per *= 0.1; + + dx *= per; dy *= per; + parts[i].vx += dx; parts[r>>8].vx -= dx; + parts[i].vy += dy; parts[r>>8].vy -= dy; + } + } + return 0; +} diff --git a/src/elements/newgraphics.c b/src/elements/newgraphics.c index af332fb25..cf7b9a89e 100644 --- a/src/elements/newgraphics.c +++ b/src/elements/newgraphics.c @@ -168,6 +168,14 @@ int graphics_WIFI(GRAPHICS_FUNC_ARGS) *pixel_mode |= EFFECT_LINES; return 0; } +int graphics_GEL(GRAPHICS_FUNC_ARGS) +{ + int q = cpart->tmp; + *colr = q*(32-255)/120+255; + *colg = q*(48-186)/120+186; + *colb = q*208/120; + return 0; +} int graphics_PRTI(GRAPHICS_FUNC_ARGS) { *firea = 8; diff --git a/src/powder.c b/src/powder.c index 6dc06554d..654f5addc 100644 --- a/src/powder.c +++ b/src/powder.c @@ -91,7 +91,7 @@ void init_can_move() for (rt=1;rt= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID)) {//some heat convection for liquids + if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID) && gel_scale>(rand()%250)) {//some heat convection for liquids r = pmap[y-2][x]; if (!(!r || parts[i].type != (r&0xFF))) { if (parts[i].temp>parts[r>>8].temp) { @@ -1856,20 +1860,20 @@ void update_particles_i(pixel *vid, int start, int inc) //heat transfer code h_count = 0; #ifdef REALISTIC - if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct) + if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale)) { float c_Cm = 0.0f; #else - if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct>(rand()%250)) + if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale)>(rand()%250)) { float c_Cm = 0.0f; #endif if (aheat_enable) { #ifdef REALISTIC - c_heat = parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight) + c_heat = parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256; - c_Cm = 96.645/ptypes[t].hconduct*fabs(ptypes[t].weight) + c_Cm = 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256; pt = c_heat/c_Cm; pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP); @@ -1892,14 +1896,19 @@ void update_particles_i(pixel *vid, int start, int inc) if (!r) continue; rt = r&0xFF; + if (rt&&ptypes[rt].hconduct&&(rt!=PT_HSWC||parts[r>>8].life==10) &&(t!=PT_FILT||(rt!=PT_BRAY&&rt!=PT_BIZR&&rt!=PT_BIZRG)) &&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG))) { surround_hconduct[j] = r>>8; #ifdef REALISTIC - c_heat += parts[r>>8].temp*96.645/ptypes[rt].hconduct*fabs(ptypes[rt].weight); - c_Cm += 96.645/ptypes[rt].hconduct*fabs(ptypes[rt].weight); + if (rt==PT_GEL) + gel_scale = parts[r>>8].tmp*2.55f; + else gel_scale = 1.0f; + + c_heat += parts[r>>8].temp*96.645/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight); + c_Cm += 96.645/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight); #else c_heat += parts[r>>8].temp; #endif @@ -1907,13 +1916,17 @@ void update_particles_i(pixel *vid, int start, int inc) } } #ifdef REALISTIC + if (t==PT_GEL) + gel_scale = parts[i].tmp*2.55f; + else gel_scale = 1.0f; + if (t == PT_PHOT) pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645); else - pt = (c_heat+parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*fabs(ptypes[t].weight)); + pt = (c_heat+parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight)); - c_heat += parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight); - c_Cm += 96.645/ptypes[t].hconduct*fabs(ptypes[t].weight); + c_heat += parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight); + c_Cm += 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight); parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP); #else pt = (c_heat+parts[i].temp)/(h_count+1);