diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-30 16:22:33 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-30 16:22:33 (GMT) |
| commit | 856f9574b6bf92c1b15d8e4f1a04869182eb05fb (patch) | |
| tree | e526e307cd8c5b61ccbad09b0c94ddfbdab52cde /src | |
| parent | cb05f5c77ea47e76017f0fc7c5f19495f49d3151 (diff) | |
| download | powder-856f9574b6bf92c1b15d8e4f1a04869182eb05fb.zip powder-856f9574b6bf92c1b15d8e4f1a04869182eb05fb.tar.gz | |
Change LCRy workings and add ELEC (wip)
Diffstat (limited to 'src')
| -rw-r--r-- | src/elements/elec.c | 69 | ||||
| -rw-r--r-- | src/elements/lcry.c | 48 | ||||
| -rw-r--r-- | src/elements/sprk.c | 7 | ||||
| -rw-r--r-- | src/main.c | 17 | ||||
| -rw-r--r-- | src/powder.c | 28 |
5 files changed, 148 insertions, 21 deletions
diff --git a/src/elements/elec.c b/src/elements/elec.c new file mode 100644 index 0000000..f425d11 --- /dev/null +++ b/src/elements/elec.c @@ -0,0 +1,69 @@ +#include <element.h> + +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<XRES && y+ry<YRES) { + r = pmap[y+ry][x+rx]; + if (!r) + r = photons[y+ry][x+rx]; + if (!r) + continue; + if ((r&0xFF)==PT_GLAS) + { + fire_r[y/CELL][x/CELL] += rand()%200; //D: Doesn't work with OpenGL, also should be here + fire_g[y/CELL][x/CELL] += rand()%200; + fire_b[y/CELL][x/CELL] += rand()%200; + for (rrx=-2; rrx<=2; rrx++) + { + for (rry=-2; rry<=2; rry++) + { + if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx<XRES && y+ry+rry<YRES) { + nb = create_part(-1, x+rx+rrx, y+ry+rry, PT_BOMB); + if (nb!=-1) { + parts[nb].tmp = 1; + parts[nb].life = 50; + parts[nb].temp = 400.0f; + parts[nb].vx = rand()%20-10; + parts[nb].vy = rand()%20-10; + } + } + } + } + kill_part(i); + return 1; + } + if ((r&0xFF)==PT_LCRY) + { + parts[r>>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 e03a3a4..e570c90 100644 --- a/src/elements/lcry.c +++ b/src/elements/lcry.c @@ -1,11 +1,18 @@ #include <element.h> -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<XRES && y+ry<YRES && (rx || ry)) @@ -13,14 +20,35 @@ int update_LCRY(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_LCRY) + if ((r&0xFF)==PT_LCRY && parts[r>>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<XRES && y+ry<YRES && (rx || ry)) + { + r = pmap[y+ry][x+rx]; + if (!r) + continue; + if ((r&0xFF)==PT_LCRY && parts[r>>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 93b0b40..623ecb7 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 @@ -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 59a8053..c8c2ef4 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; } |
