diff --git a/includes/powder.h b/includes/powder.h index 216ba9f4d..541b282e6 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -196,6 +196,7 @@ #define PT_EMP 134 #define PT_BREC 135 +#define PT_ELEC 136 #define PT_BOYL 141 @@ -311,6 +312,7 @@ int graphics_DEST(GRAPHICS_FUNC_ARGS); int graphics_EMP(GRAPHICS_FUNC_ARGS); int graphics_LIGH(GRAPHICS_FUNC_ARGS); int graphics_FIGH(GRAPHICS_FUNC_ARGS); +int graphics_ELEC(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: @@ -417,6 +419,7 @@ int update_DEST(UPDATE_FUNC_ARGS); int update_EMP(UPDATE_FUNC_ARGS); int update_LIGH(UPDATE_FUNC_ARGS); int update_FIGH(UPDATE_FUNC_ARGS); +int update_ELEC(UPDATE_FUNC_ARGS); int update_MISC(UPDATE_FUNC_ARGS); int update_legacy_PYRO(UPDATE_FUNC_ARGS); @@ -618,7 +621,7 @@ static const part_type ptypes[PT_NUM] = {"PQRT", PIXPACK(0x88BBBB), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.27f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 3, "Broken quartz.", ST_SOLID, TYPE_PART| PROP_HOT_GLOW, &update_QRTZ, &graphics_QRTZ}, {"EMP", PIXPACK(0x66AAFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.0f, 0.0f * CFDS, 0, 0, 0, 0, 3, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 121, "Breaks activated electronics.", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_EMP, &graphics_EMP}, {"BREL", PIXPACK(0x707060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.18f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken electronics", ST_SOLID, TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW, NULL, NULL}, - /*FREE*/{"COAG", PIXPACK(0x9ACD32), 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, "B378/S235678", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, + {"ELEC", PIXPACK(0xDFEFFF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, -1, SC_NUCLEAR, R_TEMP+200.0f+273.15f, 251, "Electrons", ST_GAS, TYPE_ENERGY|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_ELEC, &graphics_ELEC}, /*FREE*/{"WALL", PIXPACK(0x0047AB), 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, "B45678/S2345", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, /*FREE*/{"GNAR", PIXPACK(0xE5B73B), 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, "B1/S1", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, /*FREE*/{"REPL", PIXPACK(0x259588), 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, "B1357/S1357", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, diff --git a/src/elements/elec.c b/src/elements/elec.c new file mode 100644 index 000000000..f425d110d --- /dev/null +++ b/src/elements/elec.c @@ -0,0 +1,69 @@ +#include + +int update_ELEC(UPDATE_FUNC_ARGS) { + int r, rt, rx, ry, nb, rrx, rry; + float rr, rrr; + parts[i].pavg[0] = x; + parts[i].pavg[1] = y; + for (rx=-2; rx<=2; rx++) + for (ry=-2; ry<=2; ry++) + if (x+rx>=0 && y+ry>=0 && x+rx=0 && y+ry+rry>=0 && x+rx+rrx>8].life = 5+rand()%5; + } + if ((r&0xFF)==PT_NEUT) + { + part_change_type(r>>8, x+rx, y+ry, PT_H2); + parts[r>>8].life = 0; + parts[r>>8].ctype = 0; + } + if (ptypes[r&0xFF].properties & PROP_CONDUCTS) + { + create_part(-1, x+rx, y+ry, PT_SPRK); + kill_part(i); + return 1; + } + } + return 0; +} + +int graphics_ELEC(GRAPHICS_FUNC_ARGS) +{ + *firea = 70; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + + *pixel_mode |= FIRE_ADD; + return 0; +} diff --git a/src/elements/lcry.c b/src/elements/lcry.c index e03a3a452..e570c9014 100644 --- a/src/elements/lcry.c +++ b/src/elements/lcry.c @@ -1,11 +1,18 @@ #include -int update_LCRY(UPDATE_FUNC_ARGS) { - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - if (parts[i].life==10) +int update_LCRY(UPDATE_FUNC_ARGS) +{ + int r, rx, ry; + if(parts[i].tmp==1 || parts[i].tmp==0) { - int r, rx, ry; + if(parts[i].tmp==1) + { + if(parts[i].life<=0) + parts[i].tmp = 0; + else + parts[i].life--; + } + for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>0 && x+rx>8].tmp == 3) { - 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; + parts[r>>8].tmp = 1; } } } + else if(parts[i].tmp==2 || parts[i].tmp==3) + { + if(parts[i].tmp==2) + { + if(parts[i].life>=10) + parts[i].tmp = 3; + else + parts[i].life++; + } + + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].tmp == 0) + { + parts[r>>8].tmp = 2; + } + } + } + parts[i].tmp = parts[i].tmp; return 0; } diff --git a/src/elements/sprk.c b/src/elements/sprk.c index 93b0b40bd..623ecb754 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -130,11 +130,16 @@ int update_SPRK(UPDATE_FUNC_ARGS) { parts[r>>8].life = 9; } } - else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_GPMP||rt==PT_HSWC||rt==PT_PBCN||(rt==PT_LCRY&&abs(rx)<2&&abs(ry)<2))) // PROP_PTOGGLE, Maybe? We seem to use 2 different methods for handling actived elements, this one seems better. Yes, use this one for new elements, PCLN is different for compatibility with existing saves + else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_PUMP||rt==PT_GPMP||rt==PT_HSWC||rt==PT_PBCN)) // PROP_PTOGGLE, Maybe? We seem to use 2 different methods for handling actived elements, this one seems better. Yes, use this one for new elements, PCLN is different for compatibility with existing saves { if (ct==PT_PSCN) parts[r>>8].life = 10; else if (ct==PT_NSCN && parts[r>>8].life>=10) parts[r>>8].life = 9; } + else if ((ct==PT_PSCN||ct==PT_NSCN) && (rt==PT_LCRY&&abs(rx)<2&&abs(ry)<2)) + { + if (ct==PT_PSCN && parts[r>>8].tmp == 0) parts[r>>8].tmp = 2; + else if (ct==PT_NSCN && parts[r>>8].tmp == 3) parts[r>>8].tmp = 1; + } // ct = spark from material, rt = spark to material. Make conduct_sprk = 0 if conduction not allowed diff --git a/src/main.c b/src/main.c index 9be4bd7d6..d70eb560a 100644 --- a/src/main.c +++ b/src/main.c @@ -1034,6 +1034,23 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char } } } + if(ver>=67 && (ty==PT_LCRY)){ + //New LCRY uses TMP not life + if(parts[i-1].life>=10) + { + parts[i-1].life = 10; + parts[i-1].tmp = 3; + } + else if(parts[i-1].life<=0) + { + parts[i-1].life = 0; + parts[i-1].tmp = 0; + } + else if(parts[i-1].life < 10 && parts[i-1].life > 0) + { + parts[i-1].tmp = 1; + } + } if (!ptypes[parts[i-1].type].enabled) parts[i-1].type = PT_NONE; } diff --git a/src/powder.c b/src/powder.c index 59a805353..c8c2ef41f 100644 --- a/src/powder.c +++ b/src/powder.c @@ -138,6 +138,7 @@ void init_can_move() || t==PT_QRTZ || t==PT_PQRT) can_move[PT_PHOT][t] = 2; } + can_move[PT_ELEC][PT_LCRY] = 2; can_move[PT_PHOT][PT_LCRY] = 3;//varies according to LCRY life can_move[PT_NEUT][PT_INVIS] = 2; //whol eats anar @@ -169,7 +170,7 @@ int eval_move(int pt, int nx, int ny, unsigned *rr) result = can_move[pt][r&0xFF]; if (result==3) { - if (pt==PT_PHOT && (r&0xFF)==PT_LCRY) + if ((pt==PT_PHOT || pt==PT_ELEC) && (r&0xFF)==PT_LCRY) result = (parts[r>>8].life > 5)? 2 : 0; if ((r&0xFF)==PT_INVIS) { @@ -234,11 +235,11 @@ int try_move(int i, int x, int y, int nx, int ny) if ((r & 0xFF) < PT_NUM && ptypes[r&0xFF].hconduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10) && (r&0xFF)!=PT_FILT) parts[i].temp = parts[r>>8].temp = restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP); } - if (parts[i].type==PT_NEUT && ((r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_PBCN)) { + if ((parts[i].type==PT_NEUT || parts[i].type==PT_ELEC) && ((r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_PBCN)) { if (!parts[r>>8].ctype) - parts[r>>8].ctype = PT_NEUT; + parts[r>>8].ctype = parts[i].type; } - if ((r&0xFF)==PT_PRTI && (parts[i].type==PT_PHOT || parts[i].type==PT_NEUT)) + if ((r&0xFF)==PT_PRTI && (parts[i].type==PT_PHOT || parts[i].type==PT_NEUT || parts[i].type==PT_ELEC)) { int nnx, count; for (count=0; count<8; count++) @@ -413,7 +414,7 @@ int do_move(int i, int x, int y, float nxf, float nyf) kill_part(i); return -1; } - if (t==PT_PHOT||t==PT_NEUT) + if (t==PT_PHOT||t==PT_NEUT||t==PT_ELEC) photons[ny][nx] = t|(i<<8); else if (t) pmap[ny][nx] = t|(i<<8); @@ -658,7 +659,7 @@ inline void part_change_type(int i, int x, int y, int t)//changes the type of pa } parts[i].type = t; - if (t==PT_PHOT || t==PT_NEUT) + if (t==PT_PHOT || t==PT_NEUT || t==PT_ELEC) { photons[y][x] = t|(i<<8); if ((pmap[y][x]>>8)==i) @@ -819,7 +820,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a } return -1; } - if (photons[y][x] && (t==PT_PHOT||t==PT_NEUT)) + if (photons[y][x] && (t==PT_PHOT||t==PT_NEUT||t==PT_ELEC)) return -1; if (pfree == -1) return -1; @@ -983,6 +984,13 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a parts[i].vx = 3.0f*cosf(a); parts[i].vy = 3.0f*sinf(a); } + if (t==PT_ELEC) + { + float a = (rand()%360)*3.14159f/180.0f; + parts[i].life = 680; + parts[i].vx = 2.0f*cosf(a); + parts[i].vy = 2.0f*sinf(a); + } if (t==PT_STKM) { if (player.spwn==0) @@ -1054,7 +1062,7 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a if (t==PT_BIZR||t==PT_BIZRG) parts[i].ctype = 0x47FFFF; //and finally set the pmap/photon maps to the newly created particle - if (t==PT_PHOT||t==PT_NEUT) + if (t==PT_PHOT||t==PT_NEUT||t==PT_ELEC) photons[y][x] = t|(i<<8); if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_FIGH && t!=PT_PHOT && t!=PT_NEUT) pmap[y][x] = t|(i<<8); @@ -2160,7 +2168,7 @@ killed: stagnant = parts[i].flags & FLAG_STAGNANT; parts[i].flags &= ~FLAG_STAGNANT; - if ((t==PT_PHOT||t==PT_NEUT)) { + if ((t==PT_PHOT||t==PT_NEUT||t==PT_ELEC)) { if (t == PT_PHOT) { rt = pmap[fin_y][fin_x] & 0xFF; lt = pmap[y][x] & 0xFF; @@ -2249,7 +2257,7 @@ killed: kill_part(i); continue; } - if (!parts[i].ctype&&t!=PT_NEUT) { + if (!parts[i].ctype&&t!=PT_NEUT&&t!=PT_ELEC) { kill_part(i); continue; }