summaryrefslogtreecommitdiff
path: root/src/simulation/elements/PLNT.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/simulation/elements/PLNT.cpp')
-rw-r--r--src/simulation/elements/PLNT.cpp66
1 files changed, 39 insertions, 27 deletions
diff --git a/src/simulation/elements/PLNT.cpp b/src/simulation/elements/PLNT.cpp
index 6e8202c..dd8928c 100644
--- a/src/simulation/elements/PLNT.cpp
+++ b/src/simulation/elements/PLNT.cpp
@@ -55,36 +55,48 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
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)==PT_WATR && 1>(rand()%250))
- {
- np = sim->create_part(r>>8,x+rx,y+ry,PT_PLNT);
- if (np<0) continue;
- parts[np].life = 0;
- }
- else if ((r&0xFF)==PT_LAVA && 1>(rand()%250))
- {
- sim->part_change_type(i,x,y,PT_FIRE);
- parts[i].life = 4;
- }
- else if (((r&0xFF)==PT_SMKE || (r&0xFF)==PT_CO2) && (1>rand()%250))
- {
- sim->kill_part(r>>8);
- parts[i].life = rand()%60 + 60;
- }
- else if (surround_space && ((r&0xFF)==PT_WOOD) && (1>rand()%20) && (abs(rx+ry)<=2) && (sim->VINE_MODE || parts[i].tmp==1) )
+ switch (r&0xFF)
{
- int nnx = rand()%3 -1;
- int nny = rand()%3 -1;
- if (x+rx+nnx>=0 && y+ry+nny>0 && x+rx+nnx<XRES && y+ry+nny<YRES && (nnx || nny))
+ case PT_WATR:
+ if (!(rand()%250))
{
- if (pmap[y+ry+nny][x+rx+nnx])
- continue;
- np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE);
+ np = sim->create_part(r>>8,x+rx,y+ry,PT_PLNT);
if (np<0) continue;
- parts[np].temp = parts[i].temp;
+ parts[np].life = 0;
}
+ break;
+ case PT_LAVA:
+ if (!(rand()%250))
+ {
+ sim->part_change_type(i,x,y,PT_FIRE);
+ parts[i].life = 4;
+ }
+ break;
+ case PT_SMKE:
+ case PT_CO2:
+ if (!(rand()%250))
+ {
+ sim->kill_part(r>>8);
+ parts[i].life = rand()%60 + 60;
+ }
+ break;
+ case PT_WOOD:
+ if (surround_space && !(rand()%20) && (abs(rx+ry)<=2) && (sim->VINE_MODE || parts[i].tmp==1))
+ {
+ int nnx = rand()%3 -1;
+ int nny = rand()%3 -1;
+ if (x+rx+nnx>=0 && y+ry+nny>0 && x+rx+nnx<XRES && y+ry+nny<YRES && (nnx || nny))
+ {
+ if (pmap[y+ry+nny][x+rx+nnx])
+ continue;
+ np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE);
+ if (np<0) continue;
+ parts[np].temp = parts[i].temp;
+ }
+ }
+ break;
+ default:
+ continue;
}
}
if (parts[i].life==2)
@@ -123,4 +135,4 @@ int Element_PLNT::graphics(GRAPHICS_FUNC_ARGS)
}
-Element_PLNT::~Element_PLNT() {} \ No newline at end of file
+Element_PLNT::~Element_PLNT() {}