diff options
| author | jacob1 <jfu614@gmail.com> | 2012-08-10 14:20:05 (GMT) |
|---|---|---|
| committer | jacksonmj <mj-pt@jacksonmj.co.uk> | 2012-09-02 20:48:58 (GMT) |
| commit | d83774602f0e5a547ce171bc1ca785b594018ec6 (patch) | |
| tree | 39a51a670699f78bf129dae34cda7ee16db92063 /src | |
| parent | 355dcf50d2292b7505696ffbb85be4daa27a7930 (diff) | |
| download | powder-d83774602f0e5a547ce171bc1ca785b594018ec6.zip powder-d83774602f0e5a547ce171bc1ca785b594018ec6.tar.gz | |
DTEC, generates a spark when something with it's ctype is nearby
Diffstat (limited to 'src')
| -rw-r--r-- | src/elementdata.c | 5 | ||||
| -rw-r--r-- | src/elements/dtec.c | 59 | ||||
| -rw-r--r-- | src/powder.c | 21 |
3 files changed, 78 insertions, 7 deletions
diff --git a/src/elementdata.c b/src/elementdata.c index 7c226c0..e7803fe 100644 --- a/src/elementdata.c +++ b/src/elementdata.c @@ -192,7 +192,8 @@ part_type ptypes[PT_NUM] = {"FIGH", PIXPACK(0xFFE0A0), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Fighter. Tries to kill stickmen.", ST_NONE, 0, &update_FIGH, &graphics_STKM}, {"FRAY", PIXPACK(0x00BBFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_FORCE, 20.0f+0.0f +273.15f, 0, "Force Emitter. Push or pull objects based on temp value, use like ARAY", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_FRAY, NULL}, {"RPEL", PIXPACK(0x99CC00), 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_FORCE, 20.0f+0.0f +273.15f, 0, "Repel or attract particles based on temp value.", ST_NONE, TYPE_SOLID, &update_REPL, NULL}, - {"PPIP", PIXPACK(0x444466), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_POWERED, 273.15f, 0, "Powered version of pipe", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_PIPE, &graphics_PIPE}, + {"PPIP", PIXPACK(0x444466), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_POWERED, 273.15f, 0, "Powered pipe", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_PIPE, &graphics_PIPE}, + {"DTEC", PIXPACK(0xFD9D18), 0.0f, 0.00f * CFDS, 0.96f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+273.15f, 0, "Creates a spark when something with its ctype is nearby", ST_SOLID, TYPE_SOLID, &update_DTEC, NULL}, //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description }; @@ -370,6 +371,7 @@ part_transition ptransitions[PT_NUM] = /* FRAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* REPL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* PPIP */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, + /* DTEC */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, }; // This is an enthalpy values table, converted into TPT imaginary units @@ -538,6 +540,7 @@ unsigned int platent[PT_NUM] = /* FRAY */ 0, /* REPL */ 0, /* PPIP */ 0, + /* DTEC */ 0, }; #undef IPL #undef IPH diff --git a/src/elements/dtec.c b/src/elements/dtec.c new file mode 100644 index 0000000..28058e7 --- /dev/null +++ b/src/elements/dtec.c @@ -0,0 +1,59 @@ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <element.h> + +int update_DTEC(UPDATE_FUNC_ARGS) { + int r, rx, ry, rt, rd = parts[i].tmp2; + if (rd > 25) parts[i].tmp2 = rd = 25; + if (parts[i].life) + { + parts[i].life = 0; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; 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; + rt = parts[r>>8].type; + if (parts_avg(i,r>>8,PT_INSL) != PT_INSL) + { + if ((ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && in_radius(rd, rx, ry)) + { + parts[r>>8].life = 4; + parts[r>>8].ctype = rt; + part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + } + } + } + } + for (rx=-rd; rx<rd+1; rx++) + for (ry=-rd; ry<rd+1; 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 (parts[r>>8].type == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[r>>8].tmp)) + parts[i].life = 1; + } + return 0; +} + +int in_radius(int rd, int x, int y) +{ + return (pow((double)x,2)*pow((double)rd,2)+pow((double)y,2)*pow((double)rd,2)<=pow((double)rd,2)*pow((double)rd,2)); +}
\ No newline at end of file diff --git a/src/powder.c b/src/powder.c index ce3e4a9..71e8596 100644 --- a/src/powder.c +++ b/src/powder.c @@ -876,13 +876,14 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a { if (pmap[y][x]) { + int pmaptype = (pmap[y][x]&0xFF); if (( - ((pmap[y][x]&0xFF)==PT_STOR&&!(ptypes[t].properties&TYPE_SOLID))|| - (pmap[y][x]&0xFF)==PT_CLNE|| - (pmap[y][x]&0xFF)==PT_BCLN|| - (pmap[y][x]&0xFF)==PT_CONV|| - ((pmap[y][x]&0xFF)==PT_PCLN&&t!=PT_PSCN&&t!=PT_NSCN)|| - ((pmap[y][x]&0xFF)==PT_PBCN&&t!=PT_PSCN&&t!=PT_NSCN) + (pmaptype==PT_STOR&&!(ptypes[t].properties&TYPE_SOLID))|| + pmaptype==PT_CLNE|| + pmaptype==PT_BCLN|| + pmaptype==PT_CONV|| + (pmaptype==PT_PCLN&&t!=PT_PSCN&&t!=PT_NSCN)|| + (pmaptype==PT_PBCN&&t!=PT_PSCN&&t!=PT_NSCN) )&&( t!=PT_CLNE&&t!=PT_PCLN&& t!=PT_BCLN&&t!=PT_STKM&& @@ -893,6 +894,11 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a parts[pmap[y][x]>>8].ctype = t; if (t==PT_LIFE && v<NGOLALT && (pmap[y][x]&0xFF)!=PT_STOR) parts[pmap[y][x]>>8].tmp = v; } + else if (pmaptype == PT_DTEC && pmaptype != t) + { + parts[pmap[y][x]>>8].ctype = t; + if (t==PT_LIFE && v<NGOLALT) parts[pmap[y][x]>>8].tmp = v; + } return -1; } if (photons[y][x] && (ptypes[t].properties & TYPE_ENERGY)) @@ -1114,6 +1120,9 @@ inline int create_part(int p, int x, int y, int tv)//the function for creating a case PT_BIZR: case PT_BIZRG: case PT_BIZRS: parts[i].ctype = 0x47FFFF; break; + case PT_DTEC: + parts[i].tmp2 = 2; + break; default: if (t==PT_FIGH) { |
