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/elements | |
| parent | cb05f5c77ea47e76017f0fc7c5f19495f49d3151 (diff) | |
| download | powder-856f9574b6bf92c1b15d8e4f1a04869182eb05fb.zip powder-856f9574b6bf92c1b15d8e4f1a04869182eb05fb.tar.gz | |
Change LCRy workings and add ELEC (wip)
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/elec.c | 69 | ||||
| -rw-r--r-- | src/elements/lcry.c | 48 | ||||
| -rw-r--r-- | src/elements/sprk.c | 7 |
3 files changed, 113 insertions, 11 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 |
