summaryrefslogtreecommitdiff
path: root/src/simulation
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulation')
-rw-r--r--src/simulation/Simulation.cpp11
-rw-r--r--src/simulation/elements/ACID.cpp10
-rw-r--r--src/simulation/elements/SOAP.cpp2
-rw-r--r--src/simulation/elements/VIRS.cpp145
-rw-r--r--src/simulation/elements/VRSG.cpp49
-rw-r--r--src/simulation/elements/VRSS.cpp49
6 files changed, 255 insertions, 11 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index abf107d..7d466a4 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -2284,7 +2284,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
return 0;
}
}
- if (((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR))
+ else if (((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR))
{
if ((elements[parts[i].type].Properties & TYPE_ENERGY))
{
@@ -2307,7 +2307,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
if (y<ny && (pmap[y+1][x]&0xFF) == PT_CNCT) //check below CNCT for another CNCT
return 0;
}
- else if(parts[i].type==PT_GBMB)
+ else if(parts[i].type == PT_GBMB)
{
if (parts[i].life>0)
return 0;
@@ -2967,11 +2967,14 @@ int Simulation::create_part(int p, int x, int y, int tv)
parts[i].ctype = 0x47FFFF;
break;
case PT_DTEC:
- parts[i].tmp2 = 2;
- break;
case PT_TSNS:
parts[i].tmp2 = 2;
break;
+ case PT_VIRS:
+ case PT_VRSS:
+ case PT_VRSG:
+ parts[i].pavg[1] = 250;
+ break;
case PT_FIGH:
{
unsigned char fcount = 0;
diff --git a/src/simulation/elements/ACID.cpp b/src/simulation/elements/ACID.cpp
index e078551..4ea94ff 100644
--- a/src/simulation/elements/ACID.cpp
+++ b/src/simulation/elements/ACID.cpp
@@ -48,7 +48,7 @@ Element_ACID::Element_ACID()
//#TPT-Directive ElementHeader Element_ACID static int update(UPDATE_FUNC_ARGS)
int Element_ACID::update(UPDATE_FUNC_ARGS)
- {
+{
int r, rx, ry, trade, np;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
@@ -95,7 +95,7 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
}
}
}
- for ( trade = 0; trade<2; trade ++)
+ for (trade = 0; trade<2; trade++)
{
rx = rand()%5-2;
ry = rand()%5-2;
@@ -109,8 +109,8 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
int temp = parts[i].life - parts[r>>8].life;
if (temp==1)
{
- parts[r>>8].life ++;
- parts[i].life --;
+ parts[r>>8].life++;
+ parts[i].life--;
}
else if (temp>0)
{
@@ -126,7 +126,6 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
//#TPT-Directive ElementHeader Element_ACID static int graphics(GRAPHICS_FUNC_ARGS)
int Element_ACID::graphics(GRAPHICS_FUNC_ARGS)
-
{
int s = cpart->life;
if (s>75) s = 75; //These two should not be here.
@@ -140,5 +139,4 @@ int Element_ACID::graphics(GRAPHICS_FUNC_ARGS)
return 0;
}
-
Element_ACID::~Element_ACID() {}
diff --git a/src/simulation/elements/SOAP.cpp b/src/simulation/elements/SOAP.cpp
index de7055d..fb88287 100644
--- a/src/simulation/elements/SOAP.cpp
+++ b/src/simulation/elements/SOAP.cpp
@@ -28,7 +28,7 @@ Element_SOAP::Element_SOAP()
Temperature = R_TEMP-2.0f +273.15f;
HeatConduct = 29;
- Description = "Soap. Creates bubbles. Washes off deco color.";
+ Description = "Soap. Creates bubbles, washes off deco color, and cures virus.";
State = ST_LIQUID;
Properties = TYPE_LIQUID|PROP_NEUTPENETRATE|PROP_LIFE_DEC;
diff --git a/src/simulation/elements/VIRS.cpp b/src/simulation/elements/VIRS.cpp
new file mode 100644
index 0000000..a4a8800
--- /dev/null
+++ b/src/simulation/elements/VIRS.cpp
@@ -0,0 +1,145 @@
+#include "simulation/Elements.h"
+//#TPT-Directive ElementClass Element_VIRS PT_VIRS 174
+Element_VIRS::Element_VIRS()
+{
+ Identifier = "DEFAULT_PT_VIRS";
+ Name = "VIRS";
+ Colour = PIXPACK(0xFE11F6);
+ MenuVisible = 1;
+ MenuSection = SC_LIQUID;
+ Enabled = 1;
+
+ Advection = 0.6f;
+ AirDrag = 0.01f * CFDS;
+ AirLoss = 0.98f;
+ Loss = 0.95f;
+ Collision = 0.0f;
+ Gravity = 0.1f;
+ Diffusion = 0.00f;
+ HotAir = 0.000f * CFDS;
+ Falldown = 2;
+
+ Flammable = 100;
+ Explosive = 0;
+ Meltable = 0;
+ Hardness = 20;
+
+ Weight = 31;
+
+ Temperature = 72.0f + 273.15f;
+ HeatConduct = 251;
+ Description = "Virus. Turns everything it touches into virus.";
+
+ State = ST_LIQUID;
+ Properties = TYPE_LIQUID|PROP_DEADLY;
+
+ LowPressure = IPL;
+ LowPressureTransition = NT;
+ HighPressure = IPH;
+ HighPressureTransition = NT;
+ LowTemperature = 305.0f;
+ LowTemperatureTransition = PT_VRSS;
+ HighTemperature = 673.0f;
+ HighTemperatureTransition = PT_VRSG;
+
+ Update = &Element_VIRS::update;
+
+}
+
+//#TPT-Directive ElementHeader Element_VIRS static int update(UPDATE_FUNC_ARGS)
+int Element_VIRS::update(UPDATE_FUNC_ARGS)
+{
+ //pavg[0] measures how many frames until it is cured (0 if still actively spreading and not being cured)
+ //pavg[1] measures how many frames until it dies
+ int r, rx, ry, rndstore = rand();
+ if (parts[i].pavg[0])
+ {
+ parts[i].pavg[0] -= (rndstore&0x1) ? 0:1;
+ //has been cured, so change back into the original element
+ if (!parts[i].pavg[0])
+ {
+ sim->part_change_type(i,x,y,parts[i].tmp2);
+ parts[i].tmp2 = 0;
+ parts[i].pavg[0] = 0;
+ parts[i].pavg[1] = 0;
+ return 0;
+ }
+ }
+ //decrease pavg[1] so it slowly dies
+ if (parts[i].pavg[1] > 0)
+ {
+ if (((rndstore>>1)&0xD) < 1)
+ {
+ parts[i].pavg[1]--;
+ //if pavg[1] is now 0 and it's not in the process of being cured, kill it
+ if (!parts[i].pavg[1] && !parts[i].pavg[0])
+ {
+ sim->kill_part(i);
+ return 1;
+ }
+ }
+ }
+
+ //none of the things in the below loop happen while virus is being cured
+ if (parts[i].pavg[0])
+ return 0;
+
+ for (rx=-1; rx<2; rx++)
+ {
+ //reset rndstore, one random can last through 3 locations and reduce rand() calling by up to 6x as much
+ rndstore = rand();
+ for (ry=-1; ry<2; ry++)
+ {
+ if (BOUNDS_CHECK && (rx || ry))
+ {
+ r = pmap[y+ry][x+rx];
+ if (!r)
+ continue;
+
+ //spread "being cured" state
+ if (((r&0xFF) == PT_VIRS || (r&0xFF) == PT_VRSS || (r&0xFF) == PT_VRSG) && parts[r>>8].pavg[0])
+ {
+ parts[i].pavg[0] = parts[r>>8].pavg[0] + (((rndstore&0x7)>>1) ? 2:1);
+ rndstore = rndstore >> 3;
+ return 0;
+ }
+ //soap cures virus
+ else if ((r&0xFF) == PT_SOAP)
+ {
+ parts[i].pavg[0] += 10;
+ if (!((rndstore&0x7)>>1))
+ sim->kill_part(r>>8);
+ return 0;
+ }
+ //transforms things into virus here
+ else if ((r&0xFF) != PT_VIRS && (r&0xFF) != PT_VRSS && (r&0xFF) != PT_VRSG && (r&0xFF) != PT_DMND)
+ {
+ if (!((rndstore&0xF)>>1))
+ {
+ parts[r>>8].tmp2 = (r&0xFF);
+ parts[r>>8].pavg[0] = 0;
+ if (parts[i].pavg[1])
+ parts[r>>8].pavg[1] = parts[i].pavg[1] + ((rndstore>>4) ? 1:0);
+ else
+ parts[r>>8].pavg[1] = 0;
+ if (parts[r>>8].temp < 305.0f)
+ sim->part_change_type(r>>8,x,y,PT_VRSS);
+ else if (parts[r>>8].temp > 673.0f)
+ sim->part_change_type(r>>8,x,y,PT_VRSG);
+ else
+ sim->part_change_type(r>>8,x,y,PT_VIRS);
+ }
+ rndstore = rndstore >> 5;
+ }
+ //protons make VIRS last forever
+ else if ((sim->photons[y+ry][x+rx]&0xFF) == PT_PROT)
+ {
+ parts[i].pavg[1] = 0;
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+Element_VIRS::~Element_VIRS() {}
diff --git a/src/simulation/elements/VRSG.cpp b/src/simulation/elements/VRSG.cpp
new file mode 100644
index 0000000..8c699d7
--- /dev/null
+++ b/src/simulation/elements/VRSG.cpp
@@ -0,0 +1,49 @@
+#include "simulation/Elements.h"
+//#TPT-Directive ElementClass Element_VRSG PT_VRSG 176
+Element_VRSG::Element_VRSG()
+{
+ Identifier = "DEFAULT_PT_VRSG";
+ Name = "VRSG";
+ Colour = PIXPACK(0xFE68FE);
+ MenuVisible = 0;
+ MenuSection = SC_GAS;
+ Enabled = 1;
+
+ Advection = 1.0f;
+ AirDrag = 0.01f * CFDS;
+ AirLoss = 0.99f;
+ Loss = 0.30f;
+ Collision = -0.1f;
+ Gravity = 0.0f;
+ Diffusion = 0.75f;
+ HotAir = 0.000f * CFDS;
+ Falldown = 0;
+
+ Flammable = 500;
+ Explosive = 0;
+ Meltable = 0;
+ Hardness = 0;
+
+ Weight = 1;
+
+ Temperature = 522.0f + 273.15f;
+ HeatConduct = 251;
+ Description = "Gas Virus. Turns everything it touches into virus.";
+
+ State = ST_GAS;
+ Properties = TYPE_GAS|PROP_DEADLY;
+
+ LowPressure = IPL;
+ LowPressureTransition = NT;
+ HighPressure = IPH;
+ HighPressureTransition = NT;
+ LowTemperature = 673.0f;
+ LowTemperatureTransition = PT_VIRS;
+ HighTemperature = ITH;
+ HighTemperatureTransition = NT;
+
+ Update = &Element_VIRS::update;
+
+}
+
+Element_VRSG::~Element_VRSG() {}
diff --git a/src/simulation/elements/VRSS.cpp b/src/simulation/elements/VRSS.cpp
new file mode 100644
index 0000000..903a5f7
--- /dev/null
+++ b/src/simulation/elements/VRSS.cpp
@@ -0,0 +1,49 @@
+#include "simulation/Elements.h"
+//#TPT-Directive ElementClass Element_VRSS PT_VRSS 175
+Element_VRSS::Element_VRSS()
+{
+ Identifier = "DEFAULT_PT_VRSS";
+ Name = "VRSS";
+ Colour = PIXPACK(0xD408CD);
+ MenuVisible = 0;
+ MenuSection = SC_SOLIDS;
+ Enabled = 1;
+
+ Advection = 0.0f;
+ AirDrag = 0.00f * CFDS;
+ AirLoss = 0.90f;
+ Loss = 0.00f;
+ Collision = 0.0f;
+ Gravity = 0.0f;
+ Diffusion = 0.00f;
+ HotAir = 0.000f * CFDS;
+ Falldown = 0;
+
+ Flammable = 5;
+ Explosive = 0;
+ Meltable = 0;
+ Hardness = 1;
+
+ Weight = 100;
+
+ Temperature = R_TEMP+ 273.15f;
+ HeatConduct = 251;
+ Description = "Solid Virus. Turns everything it touches into virus.";
+
+ State = ST_SOLID;
+ Properties = TYPE_SOLID|PROP_DEADLY;
+
+ LowPressure = IPL;
+ LowPressureTransition = NT;
+ HighPressure = IPH;
+ HighPressureTransition = NT;
+ LowTemperature = ITL;
+ LowTemperatureTransition = NT;
+ HighTemperature = 305.0f;
+ HighTemperatureTransition = PT_VIRS;
+
+ Update = &Element_VIRS::update;
+
+}
+
+Element_VRSS::~Element_VRSS() {}