More electricity rewrite.
This commit is contained in:
parent
74f6ee8eb5
commit
685ede0643
@ -261,8 +261,10 @@ int update_SLTW(UPDATE_FUNC_ARGS);
|
||||
int update_SPAWN(UPDATE_FUNC_ARGS);
|
||||
int update_SPAWN2(UPDATE_FUNC_ARGS);
|
||||
int update_SPNG(UPDATE_FUNC_ARGS);
|
||||
int update_SPRK(UPDATE_FUNC_ARGS);
|
||||
int update_STKM(UPDATE_FUNC_ARGS);
|
||||
int update_STKM2(UPDATE_FUNC_ARGS);
|
||||
int update_SWCH(UPDATE_FUNC_ARGS);
|
||||
int update_THDR(UPDATE_FUNC_ARGS);
|
||||
int update_THRM(UPDATE_FUNC_ARGS);
|
||||
int update_VINE(UPDATE_FUNC_ARGS);
|
||||
@ -367,7 +369,7 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"GOO", PIXPACK(0x804000), 0.1f, 0.00f * CFDS, 0.97f, 0.50f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 12, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 75, "Solid. Deforms and disappears under pressure.", TYPE_SOLID | PROP_NEUTPENETRATE, NULL},
|
||||
{"ICE", PIXPACK(0xA0C0FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0003f* CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP-50.0f+273.15f, 46, "Solid. Freezes water. Crushes under pressure. Cools down air.", TYPE_SOLID, NULL},
|
||||
{"METL", PIXPACK(0x404060), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Conducts electricity. Meltable.", TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, NULL},
|
||||
{"SPRK", PIXPACK(0xFFFF80), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electricity. Conducted by metal and water.", TYPE_SOLID, NULL},
|
||||
{"SPRK", PIXPACK(0xFFFF80), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Electricity. Conducted by metal and water.", TYPE_SOLID, &update_SPRK},
|
||||
{"SNOW", PIXPACK(0xC0E0FF), 0.7f, 0.01f * CFDS, 0.96f, 0.90f, -0.1f, 0.05f, 0.01f, -0.00005f* CFDS,1, 0, 0, 0, 20, 1, 50, SC_POWDERS, R_TEMP-30.0f+273.15f, 46, "Light particles.", TYPE_PART, NULL},
|
||||
{"WOOD", PIXPACK(0xC0A040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 15, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 164, "Solid. Flammable.", TYPE_SOLID, NULL},
|
||||
{"NEUT", PIXPACK(0x20E0FF), 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, SC_NUCLEAR, R_TEMP+4.0f +273.15f, 60, "Neutrons. Interact with matter in odd ways.", TYPE_ENERGY, NULL},
|
||||
@ -408,7 +410,7 @@ static const part_type ptypes[PT_NUM] =
|
||||
{"BTRY", PIXPACK(0x858505), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Generates Electricity.", TYPE_SOLID, &update_BTRY},
|
||||
{"LCRY", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Liquid Crystal. Changes colour when charged. (PSCN Charges, NSCN Discharges)", TYPE_SOLID, NULL},
|
||||
{"STKM", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", 0, &update_STKM},
|
||||
{"SWCH", PIXPACK(0x103B11), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Only conducts when switched on. (PSCN switches on, NSCN switches off)", TYPE_SOLID, NULL},
|
||||
{"SWCH", PIXPACK(0x103B11), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Only conducts when switched on. (PSCN switches on, NSCN switches off)", TYPE_SOLID, &update_SWCH},
|
||||
{"SMKE", PIXPACK(0x222222), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.001f * CFDS, 1, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+320.0f+273.15f, 88, "Smoke", TYPE_GAS, NULL},
|
||||
{"DESL", PIXPACK(0x440000), 1.0f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.0f, 0.0f * CFDS, 2, 2, 0, 0, 5, 1, 15, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Explodes under high pressure and temperatures", TYPE_LIQUID, NULL},
|
||||
{"COAL", PIXPACK(0x222222), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 20, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 200, "Solid. Burns slowly.", TYPE_SOLID, &update_COAL},
|
||||
|
7
src/elements/.directory
Normal file
7
src/elements/.directory
Normal file
@ -0,0 +1,7 @@
|
||||
[Dolphin]
|
||||
AdditionalInfo=3
|
||||
Timestamp=2011,1,7,22,19,43
|
||||
ViewMode=1
|
||||
|
||||
[Settings]
|
||||
ShowDotFiles=true
|
168
src/elements/sprk.c
Normal file
168
src/elements/sprk.c
Normal file
@ -0,0 +1,168 @@
|
||||
#include <powder.h>
|
||||
|
||||
int update_SPRK(UPDATE_FUNC_ARGS) {
|
||||
int r, rt, conduct_sprk, nearp, pavg, ct = parts[i].ctype;
|
||||
if (parts[i].life<=0)
|
||||
{
|
||||
parts[i].type = ct;
|
||||
if (ct!=PT_METL&&ct!=PT_PTCT&&ct!=PT_NTCT&&ct!=PT_IRON&&ct!=PT_BMTL&&ct!=PT_BRMT&&ct!=PT_LRBD&&ct!=PT_RBDM&&ct!=PT_BTRY&&ct!=PT_NBLE&&ct!=PT_QRTZ)
|
||||
parts[i].temp = R_TEMP + 273.15f;
|
||||
if (!ct)
|
||||
ct = PT_METL;
|
||||
parts[i].type = ct;
|
||||
parts[i].life = 4;
|
||||
if (ct == PT_WATR)
|
||||
parts[i].life = 64;
|
||||
if (ct == PT_SLTW)
|
||||
parts[i].life = 54;
|
||||
if (ct == PT_SWCH)
|
||||
parts[i].life = 14;
|
||||
return 0;
|
||||
}
|
||||
if (ct==PT_SPRK)
|
||||
{
|
||||
kill_part(i);
|
||||
return 1;
|
||||
}
|
||||
else if (ct==PT_ETRD&&parts[i].life==1)
|
||||
{
|
||||
nearp = nearest_part(i, PT_ETRD);
|
||||
if (nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL)
|
||||
{
|
||||
create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, 0, PT_PLSM);
|
||||
parts[i].type = PT_ETRD;
|
||||
ct = parts[i].ctype = PT_NONE;
|
||||
parts[i].life = 20;
|
||||
parts[nearp].type = PT_SPRK;
|
||||
parts[nearp].life = 9;
|
||||
parts[nearp].ctype = PT_ETRD;
|
||||
}
|
||||
}
|
||||
else if (ct==PT_NBLE&&parts[i].life<=1)
|
||||
{
|
||||
parts[i].life = rand()%150+50;
|
||||
parts[i].type = PT_PLSM;
|
||||
parts[i].ctype = PT_NBLE;
|
||||
parts[i].temp = 3500;
|
||||
pv[y/CELL][x/CELL] += 1;
|
||||
}
|
||||
else if (ct==PT_IRON) {
|
||||
for (nx=-1; nx<2; nx++)
|
||||
for (ny=-1; ny<2; ny++)
|
||||
if (x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
|
||||
{
|
||||
r = pmap[y+ny][x+nx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
continue;
|
||||
if (((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) ||
|
||||
((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) ||
|
||||
((r&0xFF) == PT_WATR && 30>(rand()/(RAND_MAX/1000))))
|
||||
{
|
||||
parts[r>>8].type=PT_O2;
|
||||
//parts[r>>8].tmp=(rand()/(RAND_MAX/10))+20;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (nx=-2; nx<3; nx++)
|
||||
for (ny=-2; ny<3; ny++)
|
||||
if (x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
|
||||
{
|
||||
r = pmap[y+ny][x+nx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
continue;
|
||||
rt = parts[r>>8].type;
|
||||
conduct_sprk = 1;
|
||||
|
||||
|
||||
pavg = parts_avg(r>>8, i,PT_INSL);
|
||||
if ((rt==PT_SWCH||(rt==PT_SPRK&&parts[r>>8].ctype==PT_SWCH)) && pavg!=PT_INSL) // make sparked SWCH turn off correctly
|
||||
{
|
||||
if (rt==PT_SWCH&&ct==PT_PSCN&&parts[r>>8].life<10) {
|
||||
parts[r>>8].life = 10;
|
||||
}
|
||||
if (ct==PT_NSCN) {
|
||||
parts[r>>8].type = PT_SWCH;
|
||||
parts[r>>8].ctype = PT_NONE;
|
||||
parts[r>>8].life = 9;
|
||||
}
|
||||
}
|
||||
else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_HSWC||rt==PT_PCLN||(rt==PT_LCRY&&abs(nx)<2&&abs(ny)<2)))
|
||||
{
|
||||
if (ct==PT_PSCN) parts[r>>8].life = 10;
|
||||
else if (ct==PT_NSCN) parts[r>>8].life = 9;
|
||||
}
|
||||
|
||||
|
||||
// ct = spark from material, rt = spark to material. Make conduct_sprk = 0 if conduction not allowed
|
||||
|
||||
if (pavg == PT_INSL) conduct_sprk = 0;
|
||||
if (!(ptypes[rt].properties&PROP_CONDUCTS||rt==PT_INST)) conduct_sprk = 0;
|
||||
if (abs(nx)+abs(ny)>=4 &&ct!=PT_SWCH&&rt!=PT_SWCH)
|
||||
conduct_sprk = 0;
|
||||
|
||||
|
||||
if (ct==PT_METL && (rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR||(rt==PT_SPRK&&(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT))))
|
||||
{
|
||||
parts[r>>8].temp = 473.0f;
|
||||
if (rt==PT_NTCT||rt==PT_PTCT)
|
||||
conduct_sprk = 0;
|
||||
}
|
||||
if (ct==PT_NTCT && !(rt==PT_PSCN || rt==PT_NTCT || (rt==PT_NSCN&&parts[i].temp>373.0f)))
|
||||
conduct_sprk = 0;
|
||||
if (ct==PT_PTCT && !(rt==PT_PSCN || rt==PT_PTCT || (rt==PT_NSCN&&parts[i].temp<373.0f)))
|
||||
conduct_sprk = 0;
|
||||
if (ct==PT_INWR && !(rt==PT_NSCN || rt==PT_INWR || rt==PT_PSCN))
|
||||
conduct_sprk = 0;
|
||||
if (ct==PT_NSCN && rt==PT_PSCN)
|
||||
conduct_sprk = 0;
|
||||
if (ct==PT_ETRD && (parts[i].life!=5||!(rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)))
|
||||
conduct_sprk = 0;
|
||||
if (ct==PT_INST&&rt!=PT_NSCN) conduct_sprk = 0;
|
||||
if (ct==PT_SWCH && (rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR))
|
||||
conduct_sprk = 0;
|
||||
if (rt==PT_QRTZ && !((ct==PT_NSCN||ct==PT_METL||ct==PT_PSCN||ct==PT_QRTZ) && (parts[r>>8].temp<173.15||pv[(y+ny)/CELL][(x+nx)/CELL]>8)))
|
||||
conduct_sprk = 0;
|
||||
if (rt==PT_NTCT && !(ct==PT_NSCN || ct==PT_NTCT || (ct==PT_PSCN&&parts[r>>8].temp>373.0f)))
|
||||
conduct_sprk = 0;
|
||||
if (rt==PT_PTCT && !(ct==PT_NSCN || ct==PT_PTCT || (ct==PT_PSCN&&parts[r>>8].temp<373.0f)))
|
||||
conduct_sprk = 0;
|
||||
if (rt==PT_INWR && !(ct==PT_NSCN || ct==PT_INWR || ct==PT_PSCN))
|
||||
conduct_sprk = 0;
|
||||
if (rt==PT_INST&&ct!=PT_PSCN)
|
||||
conduct_sprk = 0;
|
||||
|
||||
if (conduct_sprk) {
|
||||
if (ct==PT_ETRD) {
|
||||
parts[i].type = PT_ETRD;
|
||||
parts[i].ctype = PT_NONE;
|
||||
parts[i].life = 20;
|
||||
parts[r>>8].type = PT_SPRK;
|
||||
parts[r>>8].life = 4;
|
||||
parts[r>>8].ctype = rt;
|
||||
}
|
||||
else if (rt==PT_WATR||rt==PT_SLTW) {
|
||||
if (parts[r>>8].life==0 && (parts[i].life<2 || ((r>>8)<i && parts[i].life<3)))
|
||||
{
|
||||
parts[r>>8].type = PT_SPRK;
|
||||
if (rt==PT_WATR) parts[r>>8].life = 6;
|
||||
else parts[r>>8].life = 5;
|
||||
parts[r>>8].ctype = rt;
|
||||
}
|
||||
}
|
||||
else if (rt==PT_INST) {
|
||||
if (parts[i].life>=3&&parts[r>>8].life==0)
|
||||
{
|
||||
flood_parts(x+nx,y+ny,PT_SPRK,PT_INST,-1);//spark the wire
|
||||
}
|
||||
}
|
||||
else if (parts[r>>8].life==0 && (parts[i].life<3 || ((r>>8)<i && parts[i].life<4))) {
|
||||
parts[r>>8].life = 4;
|
||||
parts[r>>8].ctype = rt;
|
||||
rt = parts[r>>8].type = PT_SPRK;
|
||||
if (parts[r>>8].temp+10.0f<673.0f&&!legacy_enable&&(rt==PT_METL||rt==PT_BMTL||rt==PT_BRMT||rt==PT_PSCN||rt==PT_NSCN||rt==PT_ETRD||rt==PT_NBLE||rt==PT_IRON))
|
||||
parts[r>>8].temp = parts[r>>8].temp+10.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
30
src/elements/swch.c
Normal file
30
src/elements/swch.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include <powder.h>
|
||||
|
||||
int update_SWCH(UPDATE_FUNC_ARGS) {
|
||||
int r, rt;
|
||||
for (nx=-2; nx<3; nx++)
|
||||
for (ny=-2; ny<3; ny++)
|
||||
if (x+nx>=0 && y+ny>0 &&
|
||||
x+nx<XRES && y+ny<YRES && (nx || ny))
|
||||
{
|
||||
r = pmap[y+ny][x+nx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
continue;
|
||||
if (parts_avg(i,r>>8,PT_INSL)!=PT_INSL) {
|
||||
rt = parts[r>>8].type; // not r&0xFF because pmap is not yet always updated (TODO)
|
||||
if (rt==PT_SWCH)
|
||||
{
|
||||
if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0)
|
||||
parts[i].life = 9;
|
||||
else if (parts[i].life==0&&parts[r>>8].life==10)
|
||||
parts[i].life = 10;
|
||||
}
|
||||
else if (rt==PT_SPRK&&parts[i].life==10&&parts[r>>8].ctype!=PT_PSCN&&parts[r>>8].ctype!=PT_NSCN) {
|
||||
parts[i].type = PT_SPRK;
|
||||
parts[i].ctype = PT_SWCH;
|
||||
parts[i].life = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
224
src/powder.c
224
src/powder.c
@ -1301,7 +1301,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
//printf("parts[%d].type: %d\n", i, parts[i].type);
|
||||
|
||||
|
||||
if (parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_NBLE && t!=PT_STKM && t!=PT_STKM2 && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_SPNG && t!=PT_DEUT)
|
||||
if (parts[i].life && t!=PT_ACID && t!=PT_COAL && t!=PT_WOOD && t!=PT_STKM && t!=PT_STKM2 && t!=PT_FUSE && t!=PT_FSEP && t!=PT_BCOL && t!=PT_GOL && t!=PT_SPNG && t!=PT_DEUT)
|
||||
{
|
||||
if (!(parts[i].life==10&&(t==PT_SWCH||t==PT_LCRY||t==PT_PCLN||t==PT_HSWC||t==PT_PUMP)))
|
||||
parts[i].life--;
|
||||
@ -1782,23 +1782,6 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((t==PT_SPRK||parts[i].type==PT_SPRK) && parts[i].ctype==PT_IRON) {
|
||||
for (nx=-1; nx<2; nx++)
|
||||
for (ny=-1; ny<2; ny++)
|
||||
if (x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
|
||||
{
|
||||
r = pmap[y+ny][x+nx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
continue;
|
||||
if (((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) ||
|
||||
((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) ||
|
||||
((r&0xFF) == PT_WATR && 30>(rand()/(RAND_MAX/1000))))
|
||||
{
|
||||
parts[r>>8].type=PT_O2;
|
||||
//parts[r>>8].tmp=(rand()/(RAND_MAX/10))+20;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (t==PT_NEUT)
|
||||
{
|
||||
rt = 3 + (int)pv[y/CELL][x/CELL];
|
||||
@ -1994,23 +1977,6 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
parts[i].temp = 0;
|
||||
}
|
||||
}
|
||||
else if (t==PT_INST)
|
||||
{
|
||||
for (nx=-2; nx<3; nx++)
|
||||
for (ny=-2; ny<3; ny++)
|
||||
if (x+nx>=0 && y+ny>0 &&
|
||||
x+nx<XRES && y+ny<YRES && (nx || ny) && abs(nx)+abs(ny)<4)
|
||||
{
|
||||
r = pmap[y+ny][x+nx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
continue;
|
||||
else if (parts[r>>8].type==PT_SPRK&&(parts[r>>8].ctype==PT_PSCN)&&(parts[r>>8].life>=3)&&parts[i].life==0&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL)
|
||||
{
|
||||
flood_parts(x,y,PT_SPRK,PT_INST,-1);//spark the wire
|
||||
//parts[r>>8].type=parts[r>>8].ctype;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (t==PT_LCRY&&parts[i].life==10)
|
||||
{
|
||||
for (nx=-1; nx<2; nx++)
|
||||
@ -2030,26 +1996,7 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (t==PT_SWCH&&parts[i].life==10)
|
||||
{
|
||||
for (nx=-2; nx<3; nx++)
|
||||
for (ny=-2; ny<3; ny++)
|
||||
if (x+nx>=0 && y+ny>0 &&
|
||||
x+nx<XRES && y+ny<YRES && (nx || ny))
|
||||
{
|
||||
r = pmap[y+ny][x+nx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
continue;
|
||||
if ((r&0xFF) == PT_SWCH&&parts_avg(i,r>>8,PT_INSL)!=PT_INSL)
|
||||
{
|
||||
if (parts[r>>8].life<10&&parts[r>>8].life>0)
|
||||
parts[i].life = 9;
|
||||
else if (parts[r>>8].life==0)
|
||||
parts[r>>8].life = 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (t==PT_PCLN||t==PT_HSWC||t==PT_PUMP&&parts[i].life==10)
|
||||
else if ((t==PT_PCLN||t==PT_HSWC||t==PT_PUMP)&&parts[i].life==10)
|
||||
{
|
||||
for (nx=-2; nx<3; nx++)
|
||||
for (ny=-2; ny<3; ny++)
|
||||
@ -2068,173 +2015,6 @@ void update_particles_i(pixel *vid, int start, int inc)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t==PT_SPRK) {
|
||||
ct = parts[i].ctype;
|
||||
|
||||
if (parts[i].life<=0)
|
||||
{
|
||||
t = ct;
|
||||
if (t!=PT_METL&&t!=PT_PTCT&&t!=PT_NTCT&&t!=PT_IRON&&t!=PT_BMTL&&t!=PT_BRMT&&t!=PT_LRBD&&t!=PT_RBDM&&t!=PT_BTRY&&t!=PT_NBLE&&t!=PT_QRTZ)
|
||||
parts[i].temp = R_TEMP + 273.15f;
|
||||
if (!t)
|
||||
t = PT_METL;
|
||||
parts[i].type = t;
|
||||
parts[i].life = 4;
|
||||
if (t == PT_WATR)
|
||||
parts[i].life = 64;
|
||||
if (t == PT_SLTW)
|
||||
parts[i].life = 54;
|
||||
if (t == PT_SWCH)
|
||||
parts[i].life = 15;
|
||||
}
|
||||
if (ct==PT_SPRK)
|
||||
{
|
||||
kill_part(i);
|
||||
continue;
|
||||
}
|
||||
else if (ct==PT_ETRD&&parts[i].life==1)
|
||||
{
|
||||
nearp = nearest_part(i, PT_ETRD);
|
||||
if (nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL)
|
||||
{
|
||||
create_line((int)parts[i].x, (int)parts[i].y, (int)parts[nearp].x, (int)parts[nearp].y, 0, 0, PT_PLSM);
|
||||
t = parts[i].type = PT_ETRD;
|
||||
ct = parts[i].ctype = PT_NONE;
|
||||
parts[i].life = 20;
|
||||
parts[nearp].type = PT_SPRK;
|
||||
parts[nearp].life = 9;
|
||||
parts[nearp].ctype = PT_ETRD;
|
||||
}
|
||||
}
|
||||
for (nx=-2; nx<3; nx++)
|
||||
for (ny=-2; ny<3; ny++)
|
||||
if (x+nx>=0 && y+ny>0 && x+nx<XRES && y+ny<YRES && (nx || ny))
|
||||
{
|
||||
r = pmap[y+ny][x+nx];
|
||||
if ((r>>8)>=NPART || !r)
|
||||
continue;
|
||||
rt = parts[r>>8].type;
|
||||
conduct_sprk = 1;
|
||||
|
||||
|
||||
pavg = parts_avg(r>>8, i,PT_INSL);
|
||||
if ((rt==PT_SWCH||(rt==PT_SPRK&&parts[r>>8].ctype==PT_SWCH)) && pavg!=PT_INSL)
|
||||
{
|
||||
if (rt==PT_SWCH) {
|
||||
if (ct==PT_PSCN) {
|
||||
if (parts[r>>8].life<10) parts[r>>8].life = 10;
|
||||
}
|
||||
else if (ct==PT_NSCN) parts[r>>8].life = 9;
|
||||
else if (parts[r>>8].life==10) {
|
||||
parts[r>>8].type = PT_SPRK;
|
||||
parts[r>>8].ctype = PT_SWCH;
|
||||
parts[r>>8].life = 4;
|
||||
}
|
||||
}
|
||||
else if (ct==PT_NSCN) { // make sparked SWCH turn off correctly
|
||||
parts[r>>8].type = PT_SWCH;
|
||||
parts[r>>8].ctype = PT_NONE;
|
||||
parts[r>>8].life = 9;
|
||||
}
|
||||
}
|
||||
else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_HSWC||rt==PT_PCLN||(rt==PT_LCRY&&abs(nx)<2&&abs(ny)<2)))
|
||||
{
|
||||
if (ct==PT_PSCN) parts[r>>8].life = 10;
|
||||
else if (ct==PT_NSCN) parts[r>>8].life = 9;
|
||||
}
|
||||
|
||||
|
||||
if (pavg == PT_INSL) conduct_sprk = 0;
|
||||
if (t!=PT_SPRK) conduct_sprk = 0;
|
||||
if (!(ptypes[rt].properties&PROP_CONDUCTS)) conduct_sprk = 0;
|
||||
|
||||
// ct = spark from material, rt = spark to material. Make conduct_sprk = 0 if conduction not allowed
|
||||
if (ct==PT_METL && (rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR||(rt==PT_SPRK&&(parts[r>>8].ctype==PT_NTCT||parts[r>>8].ctype==PT_PTCT)))) {
|
||||
parts[r>>8].temp = 473.0f;
|
||||
if (rt==PT_NTCT||rt==PT_PTCT)
|
||||
conduct_sprk = 0;
|
||||
}
|
||||
if (abs(nx)+abs(ny)>=4 &&ct!=PT_SWCH&&rt!=PT_SWCH)
|
||||
conduct_sprk = 0;
|
||||
if (ct==PT_NSCN&&rt==PT_PSCN)
|
||||
conduct_sprk = 0;
|
||||
if (rt==PT_NTCT) {
|
||||
if (ct==PT_NSCN || ct==PT_NTCT || (ct==PT_PSCN&&parts[r>>8].temp>373.0f)) {}
|
||||
else conduct_sprk = 0;
|
||||
}
|
||||
if (ct==PT_NTCT) {
|
||||
if (rt==PT_PSCN || rt==PT_NTCT || (rt==PT_NSCN&&parts[i].temp>373.0f)) {}
|
||||
else conduct_sprk = 0;
|
||||
}
|
||||
if (rt==PT_PTCT) {
|
||||
if (ct==PT_NSCN || ct==PT_PTCT || (ct==PT_PSCN&&parts[r>>8].temp<373.0f)) {}
|
||||
else conduct_sprk = 0;
|
||||
}
|
||||
if (ct==PT_PTCT) {
|
||||
if (rt==PT_PSCN || rt==PT_PTCT || (rt==PT_NSCN&&parts[i].temp<373.0f)) {}
|
||||
else conduct_sprk = 0;
|
||||
}
|
||||
if (rt==PT_INWR) {
|
||||
if (ct==PT_NSCN || ct==PT_INWR || ct==PT_PSCN) {}
|
||||
else conduct_sprk = 0;
|
||||
}
|
||||
if (ct==PT_INWR) {
|
||||
if (rt==PT_NSCN || rt==PT_INWR || rt==PT_PSCN) {}
|
||||
else conduct_sprk = 0;
|
||||
}
|
||||
if (ct==PT_INST&&rt!=PT_NSCN) conduct_sprk = 0;
|
||||
if (rt==PT_INST&&ct!=PT_PSCN) conduct_sprk = 0;
|
||||
if (ct==PT_SWCH&&(rt==PT_PSCN||rt==PT_NSCN||rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR)) conduct_sprk = 0;
|
||||
if (rt==PT_QRTZ) {
|
||||
if ((ct==PT_NSCN||ct==PT_METL||ct==PT_PSCN||ct==PT_QRTZ) && (parts[r>>8].temp<173.15||pv[(y+ny)/CELL][(x+nx)/CELL]>8)) {}
|
||||
else conduct_sprk = 0;
|
||||
}
|
||||
if (conduct_sprk) {
|
||||
if (rt==PT_WATR||rt==PT_SLTW) {
|
||||
if (parts[r>>8].life==0 && (parts[i].life<2 || ((r>>8)<i && parts[i].life<3)))
|
||||
{
|
||||
parts[r>>8].type = PT_SPRK;
|
||||
if (rt==PT_WATR) parts[r>>8].life = 6;
|
||||
else parts[r>>8].life = 5;
|
||||
parts[r>>8].ctype = rt;
|
||||
}
|
||||
}
|
||||
else if (parts[r>>8].life==0 && (parts[i].life<3 || ((r>>8)<i && parts[i].life<4))) {
|
||||
parts[r>>8].life = 4;
|
||||
parts[r>>8].ctype = rt;
|
||||
rt = parts[r>>8].type = PT_SPRK;
|
||||
if (parts[r>>8].temp+10.0f<673.0f&&!legacy_enable&&(rt==PT_METL||rt==PT_BMTL||rt==PT_BRMT||rt==PT_PSCN||rt==PT_NSCN||rt==PT_ETRD||rt==PT_NBLE||rt==PT_IRON))
|
||||
parts[r>>8].temp = parts[r>>8].temp+10.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (ct==PT_ETRD&&parts[i].life==5)
|
||||
{
|
||||
if (rt==PT_METL||rt==PT_ETRD||rt==PT_BMTL||rt==PT_BRMT||rt==PT_LRBD||rt==PT_RBDM||rt==PT_PSCN||rt==PT_NSCN)
|
||||
{
|
||||
t = parts[i].type = PT_ETRD;
|
||||
parts[i].ctype = PT_NONE;
|
||||
parts[i].life = 20;
|
||||
parts[r>>8].type = PT_SPRK;
|
||||
parts[r>>8].life = 4;
|
||||
parts[r>>8].ctype = rt;
|
||||
}
|
||||
}
|
||||
else if (ct==PT_NBLE&&parts[i].life<=1)
|
||||
{
|
||||
parts[i].life = rand()%150+50;
|
||||
t = parts[i].type = PT_PLSM;
|
||||
ct = parts[i].ctype = PT_NBLE;
|
||||
parts[i].temp = 3500;
|
||||
pv[y/CELL][x/CELL] += 1;
|
||||
}
|
||||
else if (ct==PT_SWCH&&parts[i].life<=0)
|
||||
{
|
||||
t = parts[i].type = PT_SWCH;
|
||||
parts[i].life = 14;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t==PT_FIRE || t==PT_PLSM || t==PT_LAVA || t==PT_SPRK || fe || (t==PT_PHOT&&(1>rand()%10)))
|
||||
{
|
||||
for (nx=-2; nx<3; nx++)
|
||||
|
Loading…
Reference in New Issue
Block a user