summaryrefslogtreecommitdiff
path: root/src/simulation/elements
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-09-02 01:52:38 (GMT)
committer jacob1 <jfu614@gmail.com>2013-09-02 01:52:38 (GMT)
commitf1145f31f52f1089fed4c7f390f5384f040b4771 (patch)
tree3fa26b80978696e9390e248666183d28bad04fa2 /src/simulation/elements
parentb2957dc1c9b2f025727a57063f2e252647918fc2 (diff)
downloadpowder-f1145f31f52f1089fed4c7f390f5384f040b4771.zip
powder-f1145f31f52f1089fed4c7f390f5384f040b4771.tar.gz
new element: PROT (protons) TODO: proton colliders to produce heavier elements
Diffstat (limited to 'src/simulation/elements')
-rw-r--r--src/simulation/elements/ELEC.cpp3
-rw-r--r--src/simulation/elements/EXOT.cpp58
-rw-r--r--src/simulation/elements/PROT.cpp99
-rw-r--r--src/simulation/elements/PRTO.cpp4
4 files changed, 141 insertions, 23 deletions
diff --git a/src/simulation/elements/ELEC.cpp b/src/simulation/elements/ELEC.cpp
index 8ab4af1..56e90b3 100644
--- a/src/simulation/elements/ELEC.cpp
+++ b/src/simulation/elements/ELEC.cpp
@@ -91,6 +91,7 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
sim->create_part(r>>8, x+rx, y+ry, PT_H2);
return 1;
case PT_NEUT:
+ case PT_PROT: // this is the correct reaction, not NEUT, but leaving NEUT in anyway
sim->part_change_type(r>>8, x+rx, y+ry, PT_H2);
parts[r>>8].life = 0;
parts[r>>8].ctype = 0;
@@ -124,8 +125,6 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
return 0;
}
-
-
//#TPT-Directive ElementHeader Element_ELEC static int graphics(GRAPHICS_FUNC_ARGS)
int Element_ELEC::graphics(GRAPHICS_FUNC_ARGS)
diff --git a/src/simulation/elements/EXOT.cpp b/src/simulation/elements/EXOT.cpp
index df075e0..e2f6e41 100644
--- a/src/simulation/elements/EXOT.cpp
+++ b/src/simulation/elements/EXOT.cpp
@@ -47,11 +47,13 @@ Element_EXOT::Element_EXOT()
}
//#TPT-Directive ElementHeader Element_EXOT static int update(UPDATE_FUNC_ARGS)
-int Element_EXOT::update(UPDATE_FUNC_ARGS) {
+int Element_EXOT::update(UPDATE_FUNC_ARGS)
+{
int r, rt, rx, ry, nb, rrx, rry, trade, tym;
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
- if (BOUNDS_CHECK && (rx || ry)) {
+ if (BOUNDS_CHECK && (rx || ry))
+ {
r = pmap[y+ry][x+rx];
if (!r)
continue;
@@ -65,11 +67,14 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) {
}
else if (rt == PT_EXOT)
{
+ if (parts[r>>8].ctype == PT_PROT)
+ parts[i].ctype = PT_PROT;
if (parts[r>>8].life == 1500 && !(rand()%1000))
parts[i].life = 1500;
}
else if (rt == PT_LAVA)
{
+ //turn molten TTAN or molten GOLD to molten VIBR
if (parts[r>>8].ctype == PT_TTAN || parts[r>>8].ctype == PT_GOLD)
{
if (!(rand()%10))
@@ -79,66 +84,71 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) {
return 1;
}
}
+ //molten VIBR will kill the leftover EXOT though, so the VIBR isn't killed later
else if (parts[r>>8].ctype == PT_VIBR)
{
- if (1>rand()%1000)
+ if (!(rand()%1000))
{
sim->kill_part(i);
return 1;
}
}
}
- if ((parts[i].tmp>245) && (parts[i].life>1000))
+ if (parts[i].tmp > 245 && parts[i].life > 1000)
if (rt!=PT_EXOT && rt!=PT_BREC && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PRTI && rt!=PT_PRTO && rt!=PT_PCLN && rt!=PT_VOID && rt!=PT_NBHL && rt!=PT_WARP)
{
sim->create_part(i, x, y, rt);
- return 0;
+ return 1;
}
}
+
parts[i].tmp--;
parts[i].tmp2--;
- if (parts[i].tmp<1 || parts[i].tmp>250)
+ //reset tmp every 250 frames, gives EXOT it's slow flashing effect
+ if (parts[i].tmp < 1 || parts[i].tmp > 250)
parts[i].tmp = 250;
- if (parts[i].tmp2<1)
+
+ if (parts[i].tmp2 < 1)
parts[i].tmp2 = 1;
- else if (parts[i].tmp2>6000)
+ else if (parts[i].tmp2 > 6000)
{
parts[i].tmp2 = 10000;
- if (parts[i].life<1001)
+ if (parts[i].life < 1001)
{
sim->part_change_type(i, x, y, PT_WARP);
return 0;
}
}
- else if(parts[i].life<1001)
+ else if(parts[i].life < 1001)
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)
{
parts[i].tmp2 = 6000;
sim->part_change_type(i, x, y, PT_WARP);
return 0;
}
- if (parts[i].tmp2>100)
+ if (parts[i].tmp2 > 100)
{
- for ( trade = 0; trade<9; trade ++)
+ 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))
+ if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF)==PT_EXOT && (parts[i].tmp2>parts[r>>8].tmp2) && parts[r>>8].tmp2>=0 )//diffusion
+ if ((r&0xFF)==PT_EXOT && (parts[i].tmp2 > parts[r>>8].tmp2) && parts[r>>8].tmp2 >= 0) //diffusion
{
tym = parts[i].tmp2 - parts[r>>8].tmp2;
- if (tym ==1)
+ if (tym == 1)
{
- parts[r>>8].tmp2 ++;
- parts[i].tmp2 --;
+ parts[r>>8].tmp2++;
+ parts[i].tmp2--;
break;
}
- if (tym>0)
+ if (tym > 0)
{
parts[r>>8].tmp2 += tym/2;
parts[i].tmp2 -= tym/2;
@@ -148,7 +158,17 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) {
}
}
}
- if (parts[i].temp<273.15f)
+ if (parts[i].ctype == PT_PROT)
+ {
+ if (parts[i].temp < 50.0f)
+ {
+ sim->create_part(i, x, y, PT_CFLM);
+ return 1;
+ }
+ else
+ parts[i].temp -= 1.0f;
+ }
+ else if (parts[i].temp < 273.15f)
{
parts[i].vx = 0;
parts[i].vy = 0;
diff --git a/src/simulation/elements/PROT.cpp b/src/simulation/elements/PROT.cpp
new file mode 100644
index 0000000..87f8e4c
--- /dev/null
+++ b/src/simulation/elements/PROT.cpp
@@ -0,0 +1,99 @@
+#include "simulation/Elements.h"
+//#TPT-Directive ElementClass Element_PROT PT_PROT 173
+Element_PROT::Element_PROT()
+{
+ Identifier = "DEFAULT_PT_PROT";
+ Name = "PROT";
+ Colour = PIXPACK(0x990000);
+ MenuVisible = 1;
+ MenuSection = SC_NUCLEAR;
+ Enabled = 1;
+
+ Advection = 0.0f;
+ AirDrag = 0.00f * CFDS;
+ AirLoss = 1.00f;
+ Loss = 1.00f;
+ Collision = -.99f;
+ Gravity = 0.0f;
+ Diffusion = 0.00f;
+ HotAir = 0.000f * CFDS;
+ Falldown = 0;
+
+ Flammable = 0;
+ Explosive = 0;
+ Meltable = 0;
+ Hardness = 0;
+
+ Weight = -1;
+
+ Temperature = R_TEMP+273.15f;
+ HeatConduct = 61;
+ Description = "Protons. Transfer heat to materials, and removes sparks.";
+
+ State = ST_GAS;
+ Properties = TYPE_ENERGY|PROP_LIFE_KILL;
+
+ LowPressure = IPL;
+ LowPressureTransition = NT;
+ HighPressure = IPH;
+ HighPressureTransition = NT;
+ LowTemperature = ITL;
+ LowTemperatureTransition = NT;
+ HighTemperature = ITH;
+ HighTemperatureTransition = NT;
+
+ Update = &Element_PROT::update;
+ Graphics = &Element_PROT::graphics;
+}
+
+//#TPT-Directive ElementHeader Element_PROT static int update(UPDATE_FUNC_ARGS)
+int Element_PROT::update(UPDATE_FUNC_ARGS)
+{
+ sim->pv[y/CELL][x/CELL] -= .005f;
+ int under = pmap[y][x];
+ //set off explosives (only when hot because it wasn't as fun when it made an entire save explode)
+ if (parts[i].temp > 273.15f+500.0f && (sim->elements[under&0xFF].Flammable || sim->elements[under&0xFF].Explosive || (under&0xFF) == PT_BANG))
+ {
+ sim->create_part(under>>8, x, y, PT_FIRE);
+ parts[under>>8].temp += restrict_flt(sim->elements[under&0xFF].Flammable*5, MIN_TEMP, MAX_TEMP);
+ sim->pv[y/CELL][x/CELL] += 1.00f;
+ }
+ //remove active sparks
+ else if ((under&0xFF) == PT_SPRK)
+ {
+ sim->part_change_type(under>>8, x, y, parts[under>>8].ctype);
+ parts[under>>8].life = 44+parts[under>>8].life;
+ parts[under>>8].ctype = 0;
+ }
+ //prevent inactive sparkable elements from being sparked
+ else if ((sim->elements[under&0xFF].Properties&PROP_CONDUCTS) && parts[under>>8].life <= 4)
+ {
+ parts[under>>8].life = 40+parts[under>>8].life;
+ }
+ else if ((under&0xFF) == PT_EXOT)
+ parts[under>>8].ctype = PT_PROT;
+
+ //make temp of other things closer to it's own temperature. This will change temp of things that don't conduct, and won't change the PROT's temperature
+ if (under)
+ {
+ parts[under>>8].temp -= restrict_flt((parts[under>>8].temp-parts[i].temp)/4.0f, MIN_TEMP, MAX_TEMP);
+ }
+ //else, slowly kill it if it's not inside an element
+ else
+ parts[i].life--;
+ return 0;
+}
+
+//#TPT-Directive ElementHeader Element_PROT static int graphics(GRAPHICS_FUNC_ARGS)
+int Element_PROT::graphics(GRAPHICS_FUNC_ARGS)
+{
+ *firea = 20;
+ *firer = 250;
+ *fireg = 128;
+ *fireb = 128;
+
+ *pixel_mode |= FIRE_ADD;
+ return 1;
+}
+
+Element_PROT::~Element_PROT() {}
diff --git a/src/simulation/elements/PRTO.cpp b/src/simulation/elements/PRTO.cpp
index 6ec11b4..1eae7ce 100644
--- a/src/simulation/elements/PRTO.cpp
+++ b/src/simulation/elements/PRTO.cpp
@@ -85,7 +85,7 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
sim->create_part(-1,x-1,y+1,PT_SPRK);
sim->create_part(-1,x-1,y,PT_SPRK);
sim->create_part(-1,x-1,y-1,PT_SPRK);
- sim->portalp[parts[i].tmp][randomness][nnx] = sim->emptyparticle;
+ memset(&sim->portalp[parts[i].tmp][randomness][nnx], 0, sizeof(Particle));
break;
}
else if (sim->portalp[parts[i].tmp][randomness][nnx].type)
@@ -132,7 +132,7 @@ int Element_PRTO::update(UPDATE_FUNC_ARGS)
parts[np] = sim->portalp[parts[i].tmp][randomness][nnx];
parts[np].x = x+rx;
parts[np].y = y+ry;
- sim->portalp[parts[i].tmp][randomness][nnx] = sim->emptyparticle;
+ memset(&sim->portalp[parts[i].tmp][randomness][nnx], 0, sizeof(Particle));
break;
}
}