Permalink
Browse files

Added diffusion code for tmp2 in EXOT starting at >100 so that electr…

…on patterns won't cause abrupt fission reactions. Also, rearranged air generation line that depends on tmp already so that it doesn't abruptly switch on past 5000 and then violenly explode, but slowly increments instead.
  • Loading branch information...
Catelite authored and simtr committed Jun 6, 2012
1 parent c07afe4 commit f77f1ab485b8e710421afb2551e9372784157d4d
Showing with 39 additions and 8 deletions.
  1. +37 −6 src/elements/exot.c
  2. +2 −2 src/elements/warp.c
View
@@ -16,7 +16,8 @@
#include <element.h>
int update_EXOT(UPDATE_FUNC_ARGS) {
- int r, rt, rx, ry, nb, rrx, rry;
+ 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) {
@@ -28,7 +29,7 @@ int update_EXOT(UPDATE_FUNC_ARGS) {
if (parts[r>>8].tmp2>2000)
if (1>rand()%100)
{
- parts[i].tmp2 += 50;
+ parts[i].tmp2 += 100;
}
}
}
@@ -38,19 +39,49 @@ int update_EXOT(UPDATE_FUNC_ARGS) {
parts[i].tmp = 250;
if (parts[i].tmp2<1)
parts[i].tmp2 = 1;
- else if (parts[i].tmp2>2500)
+ else if (parts[i].tmp2>6000)
{
- parts[i].tmp2 = 2500;
+ parts[i].tmp2 = 6000;
part_change_type(i, x, y, PT_WARP);
parts[i].temp = 10000;
}
else
- pv[y/CELL][x/CELL] += (parts[i].tmp2/2000) * CFDS;
+ pv[y/CELL][x/CELL] += (parts[i].tmp2*CFDS)/40000;
if (pv[y/CELL][x/CELL]>200 && parts[i].temp>9000 && parts[i].tmp2>200)
{
part_change_type(i, x, y, PT_WARP);
- parts[i].tmp2 = 2500;
+ 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;
+ }
+ }
+ }
+ }
+ }
return 0;
}
int graphics_EXOT(GRAPHICS_FUNC_ARGS)
View
@@ -21,8 +21,8 @@ int update_WARP(UPDATE_FUNC_ARGS) {
if (parts[i].tmp2>2000)
{
parts[i].temp = 10000;
- pv[y/CELL][x/CELL] += (parts[i].tmp2/2000) * CFDS;
- if (2>rand()%1000)
+ pv[y/CELL][x/CELL] += (parts[i].tmp2/5000) * CFDS;
+ if (2>rand()%100)
create_part(-3, x, y, PT_ELEC);
}
for ( trade = 0; trade<5; trade ++)

0 comments on commit f77f1ab

Please sign in to comment.