DTEC, generates a spark when something with it's ctype is nearby

This commit is contained in:
jacob1 2012-08-10 10:20:05 -04:00 committed by jacksonmj
parent 355dcf50d2
commit d83774602f
4 changed files with 81 additions and 8 deletions

View File

@ -236,7 +236,8 @@
#define PT_FRAY 159 #define PT_FRAY 159
#define PT_REPL 160 #define PT_REPL 160
#define PT_PPIP 161 #define PT_PPIP 161
#define PT_NUM 162 #define PT_DTEC 162
#define PT_NUM 163
#define R_TEMP 22 #define R_TEMP 22
#define MAX_TEMP 9999 #define MAX_TEMP 9999
@ -389,6 +390,7 @@ int update_CLNE(UPDATE_FUNC_ARGS);
int update_COAL(UPDATE_FUNC_ARGS); int update_COAL(UPDATE_FUNC_ARGS);
int update_DEUT(UPDATE_FUNC_ARGS); int update_DEUT(UPDATE_FUNC_ARGS);
int update_DSTW(UPDATE_FUNC_ARGS); int update_DSTW(UPDATE_FUNC_ARGS);
int update_DTEC(UPDATE_FUNC_ARGS);
int update_EMBR(UPDATE_FUNC_ARGS); int update_EMBR(UPDATE_FUNC_ARGS);
int update_FOG(UPDATE_FUNC_ARGS); int update_FOG(UPDATE_FUNC_ARGS);
int update_FRZW(UPDATE_FUNC_ARGS); int update_FRZW(UPDATE_FUNC_ARGS);

View File

@ -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}, {"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}, {"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}, {"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 //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}, /* FRAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* REPL */ {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}, /* 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 // This is an enthalpy values table, converted into TPT imaginary units
@ -538,6 +540,7 @@ unsigned int platent[PT_NUM] =
/* FRAY */ 0, /* FRAY */ 0,
/* REPL */ 0, /* REPL */ 0,
/* PPIP */ 0, /* PPIP */ 0,
/* DTEC */ 0,
}; };
#undef IPL #undef IPL
#undef IPH #undef IPH

59
src/elements/dtec.c Normal file
View File

@ -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));
}

View File

@ -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]) if (pmap[y][x])
{ {
int pmaptype = (pmap[y][x]&0xFF);
if (( if ((
((pmap[y][x]&0xFF)==PT_STOR&&!(ptypes[t].properties&TYPE_SOLID))|| (pmaptype==PT_STOR&&!(ptypes[t].properties&TYPE_SOLID))||
(pmap[y][x]&0xFF)==PT_CLNE|| pmaptype==PT_CLNE||
(pmap[y][x]&0xFF)==PT_BCLN|| pmaptype==PT_BCLN||
(pmap[y][x]&0xFF)==PT_CONV|| pmaptype==PT_CONV||
((pmap[y][x]&0xFF)==PT_PCLN&&t!=PT_PSCN&&t!=PT_NSCN)|| (pmaptype==PT_PCLN&&t!=PT_PSCN&&t!=PT_NSCN)||
((pmap[y][x]&0xFF)==PT_PBCN&&t!=PT_PSCN&&t!=PT_NSCN) (pmaptype==PT_PBCN&&t!=PT_PSCN&&t!=PT_NSCN)
)&&( )&&(
t!=PT_CLNE&&t!=PT_PCLN&& t!=PT_CLNE&&t!=PT_PCLN&&
t!=PT_BCLN&&t!=PT_STKM&& 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; 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; 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; return -1;
} }
if (photons[y][x] && (ptypes[t].properties & TYPE_ENERGY)) 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: case PT_BIZR: case PT_BIZRG: case PT_BIZRS:
parts[i].ctype = 0x47FFFF; parts[i].ctype = 0x47FFFF;
break; break;
case PT_DTEC:
parts[i].tmp2 = 2;
break;
default: default:
if (t==PT_FIGH) if (t==PT_FIGH)
{ {