summaryrefslogtreecommitdiff
path: root/src/simulation/elements
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-06-12 23:57:02 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-06-12 23:57:02 (GMT)
commit427670682ffaadc81aa6a2363d5b6428d14e1ad7 (patch)
treed3621a1bc26c8e4e614c2805ddf3b598c24e1d7b /src/simulation/elements
parent19d071f10b477059680baa905878c77dd7f6b80a (diff)
downloadpowder-427670682ffaadc81aa6a2363d5b6428d14e1ad7.zip
powder-427670682ffaadc81aa6a2363d5b6428d14e1ad7.tar.gz
TPT: EXOT
Diffstat (limited to 'src/simulation/elements')
-rw-r--r--src/simulation/elements/BREC.cpp19
-rw-r--r--src/simulation/elements/ELEC.cpp2
-rw-r--r--src/simulation/elements/EXOT.cpp169
-rw-r--r--src/simulation/elements/WARP.cpp20
4 files changed, 206 insertions, 4 deletions
diff --git a/src/simulation/elements/BREC.cpp b/src/simulation/elements/BREC.cpp
index 9668785..807d650 100644
--- a/src/simulation/elements/BREC.cpp
+++ b/src/simulation/elements/BREC.cpp
@@ -42,8 +42,23 @@ Element_BREC::Element_BREC()
HighTemperature = ITH;
HighTemperatureTransition = NT;
- Update = NULL;
+ Update = &Element_BREC::update;
Graphics = NULL;
}
-Element_BREC::~Element_BREC() {} \ No newline at end of file
+//#TPT-Directive ElementHeader Element_BREC static int update(UPDATE_FUNC_ARGS)
+int Element_BREC::update(UPDATE_FUNC_ARGS)
+{
+ int np;
+ if (1>rand()%200 && (sim->pv[y/CELL][x/CELL] > 30.0f) && parts[i].temp>9000 && parts[i].life>0)
+ {
+ sim->part_change_type(i, x ,y ,PT_EXOT);
+ parts[i].life = 1000;
+ }
+ if ((sim->pv[y/CELL][x/CELL] > 10.0f) && (parts[i].life>0)) {
+ parts[i].temp = parts[i].temp + (sim->pv[y/CELL][x/CELL])/8;
+ }
+ return 0;
+}
+
+Element_BREC::~Element_BREC() {}
diff --git a/src/simulation/elements/ELEC.cpp b/src/simulation/elements/ELEC.cpp
index 4081f83..c644f2f 100644
--- a/src/simulation/elements/ELEC.cpp
+++ b/src/simulation/elements/ELEC.cpp
@@ -127,6 +127,8 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
sim->kill_part(i);
return 1;
}
+ if ((r&0xFF)==PT_EXOT)
+ parts[r>>8].tmp2 += 5;
if ((sim->elements[r&0xFF].Properties & PROP_CONDUCTS) && ((r&0xFF)!=PT_NBLE||parts[i].temp<2273.15))
{
sim->create_part(-1, x+rx, y+ry, PT_SPRK);
diff --git a/src/simulation/elements/EXOT.cpp b/src/simulation/elements/EXOT.cpp
new file mode 100644
index 0000000..79cf9ec
--- /dev/null
+++ b/src/simulation/elements/EXOT.cpp
@@ -0,0 +1,169 @@
+#include "simulation/Elements.h"
+//#TPT-Directive ElementClass Element_EXOT PT_EXOT 145
+Element_EXOT::Element_EXOT()
+{
+ Identifier = "DEFAULT_PT_EXOT";
+ Name = "EXOT";
+ Colour = PIXPACK(0x808080);
+ MenuVisible = 1;
+ MenuSection = SC_NUCLEAR;
+ Enabled = 1;
+
+ Advection = 0.3f;
+ AirDrag = 0.02f * CFDS;
+ AirLoss = 0.95f;
+ Loss = 0.80f;
+ Collision = 0.0f;
+ Gravity = 0.15f;
+ Diffusion = 0.00f;
+ HotAir = 0.0003f * CFDS;
+ Falldown = 2;
+
+ Flammable = 0;
+ Explosive = 0;
+ Meltable = 0;
+ Hardness = 20;
+
+ Weight = 45;
+
+ Temperature = R_TEMP-2.0f +273.15f;
+ HeatConduct = 29;
+ Description = "Radioactive liquid";
+
+ State = ST_LIQUID;
+ Properties = TYPE_LIQUID|PROP_NEUTPENETRATE;
+
+ LowPressure = IPL;
+ LowPressureTransition = NT;
+ HighPressure = IPH;
+ HighPressureTransition = NT;
+ LowTemperature = ITL;
+ LowTemperatureTransition = NT;
+ HighTemperature = ITH;
+ HighTemperatureTransition = NT;
+
+ Update = &Element_EXOT::update;
+ Graphics = &Element_EXOT::graphics;
+}
+
+//#TPT-Directive ElementHeader Element_EXOT static int update(UPDATE_FUNC_ARGS)
+int Element_EXOT::update(UPDATE_FUNC_ARGS) {
+ int r, rt, rx, ry, nb, rrx, rry, trade, tym, t;
+ t = parts[i].type;
+ 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)
+ continue;
+ if ((r&0xFF)==PT_WARP)
+ {
+ if (parts[r>>8].tmp2>2000)
+ if (1>rand()%100)
+ {
+ parts[i].tmp2 += 100;
+ }
+ }
+ if (parts[i].tmp>245)
+ if (1>rand()%500)
+ if ((r&0xFF)!=PT_EXOT && (r&0xFF)!=PT_BREC && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_NBHL && (r&0xFF)!=PT_WARP)
+ sim->create_part(i, x, y, parts[r>>8].type);
+ }
+ parts[i].tmp--;
+ parts[i].tmp2--;
+ if (parts[i].tmp<1 || parts[i].tmp>250)
+ parts[i].tmp = 250;
+ if (parts[i].tmp2<1)
+ parts[i].tmp2 = 1;
+ else if (parts[i].tmp2>6000)
+ {
+ parts[i].tmp2 = 6000;
+ sim->part_change_type(i, x, y, PT_WARP);
+ parts[i].temp = 10000;
+ }
+ else
+ sim->pv[y/CELL][x/CELL] += (parts[i].tmp2*CFDS)/160000;
+ if (sim->pv[y/CELL][x/CELL]>200 && parts[i].temp>9000 && parts[i].tmp2>200)
+ {
+ sim->part_change_type(i, x, y, PT_WARP);
+ parts[i].tmp2 = 6000;
+ }
+ if (parts[i].tmp2>100)
+ {
+ for ( trade = 0; trade<9; trade ++)
+ {
+ rx = rand()%5-2;
+ ry = rand()%5-2;
+ 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)==t && (parts[i].tmp2>parts[r>>8].tmp2) && parts[r>>8].tmp2>=0 )//diffusion
+ {
+ tym = parts[i].tmp2 - parts[r>>8].tmp2;
+ if (tym ==1)
+ {
+ parts[r>>8].tmp2 ++;
+ parts[i].tmp2 --;
+ break;
+ }
+ if (tym>0)
+ {
+ parts[r>>8].tmp2 += tym/2;
+ parts[i].tmp2 -= tym/2;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (parts[i].temp<273.15f)
+ {
+ parts[i].vx = 0;
+ parts[i].vy = 0;
+ sim->pv[y/CELL][x/CELL] -= 0.01;
+ parts[i].tmp--;
+ }
+ return 0;
+
+}
+
+//#TPT-Directive ElementHeader Element_EXOT static int graphics(GRAPHICS_FUNC_ARGS)
+int Element_EXOT::graphics(GRAPHICS_FUNC_ARGS)
+{
+ int q = cpart->temp;
+ int b = cpart->tmp;
+ int c = cpart->tmp2;
+ if ((cpart->tmp2 - 1)>rand()%1000)
+ {
+ float frequency = 0.04045;
+ *colr = (sin(frequency*c + 4) * 127 + 150);
+ *colg = (sin(frequency*c + 6) * 127 + 150);
+ *colb = (sin(frequency*c + 8) * 127 + 150);
+ *firea = 100;
+ *firer = 0;
+ *fireg = 0;
+ *fireb = 0;
+ *pixel_mode |= PMODE_FLAT;
+ // *pixel_mode |= FIRE_ADD;
+ *pixel_mode |= PMODE_FLARE;
+ }
+ else
+ {
+ float frequency = 0.00045;
+ *colr = (sin(frequency*q + 4) * 127 + (b/1.7));
+ *colg = (sin(frequency*q + 6) * 127 + (b/1.7));
+ *colb = (sin(frequency*q + 8) * 127 + (b/1.7));
+ *cola = cpart->tmp / 6;
+ *firea = *cola;
+ *firer = *colr;
+ *fireg = *colg;
+ *fireb = *colb;
+ *pixel_mode |= FIRE_ADD;
+ *pixel_mode |= PMODE_BLUR;
+ }
+ return 0;
+}
+
+Element_EXOT::~Element_EXOT() {}
diff --git a/src/simulation/elements/WARP.cpp b/src/simulation/elements/WARP.cpp
index 596c1d9..bc19aa0 100644
--- a/src/simulation/elements/WARP.cpp
+++ b/src/simulation/elements/WARP.cpp
@@ -50,6 +50,13 @@ Element_WARP::Element_WARP()
int Element_WARP::update(UPDATE_FUNC_ARGS)
{
int trade, r, rx, ry;
+ if (parts[i].tmp2>2000)
+ {
+ parts[i].temp = 10000;
+ sim->pv[y/CELL][x/CELL] += (parts[i].tmp2/5000) * CFDS;
+ if (2>rand()%100)
+ sim->create_part(-3, x, y, PT_ELEC);
+ }
for ( trade = 0; trade<5; trade ++)
{
rx = rand()%3-1;
@@ -59,12 +66,14 @@ int Element_WARP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)!=PT_WARP&&(r&0xFF)!=PT_STKM&&(r&0xFF)!=PT_STKM2&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_BCLN&&(r&0xFF)!=PT_PCLN&&(10>=rand()%200))
+ if ((r&0xFF)!=PT_WARP&&(r&0xFF)!=PT_STKM&&(r&0xFF)!=PT_STKM2&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_BCLN&&(r&0xFF)!=PT_PCLN)
{
parts[i].x = parts[r>>8].x;
parts[i].y = parts[r>>8].y;
parts[r>>8].x = x;
parts[r>>8].y = y;
+ parts[r>>8].vx = (rand()%4)-1.5;
+ parts[r>>8].vy = (rand()%4)-2;
parts[i].life += 4;
pmap[y][x] = r;
pmap[y+ry][x+rx] = (i<<8)|parts[i].type;
@@ -75,5 +84,12 @@ int Element_WARP::update(UPDATE_FUNC_ARGS)
return 0;
}
+//#TPT-Directive ElementHeader Element_WARP static int graphics(GRAPHICS_FUNC_ARGS)
+int Element_WARP::graphics(GRAPHICS_FUNC_ARGS)
+{
+ *cola = 0;
+ *pixel_mode &= ~PMODE;
+ return 0;
+}
-Element_WARP::~Element_WARP() {} \ No newline at end of file
+Element_WARP::~Element_WARP() {}