Customizable FRAY and INVS (#390)
This commit is contained in:
parent
3fbfb83b0e
commit
7078d7e528
1
.gitignore
vendored
1
.gitignore
vendored
@ -64,6 +64,5 @@ config.log
|
||||
*.pyc
|
||||
site_scons/site_tools/mfprogram/*.pyc
|
||||
site_scons/site_tools/gch/*.pyc
|
||||
others*
|
||||
|
||||
screenshot_*
|
||||
|
@ -2187,7 +2187,13 @@ int Simulation::eval_move(int pt, int nx, int ny, unsigned *rr)
|
||||
}
|
||||
else if ((r&0xFF) == PT_INVIS)
|
||||
{
|
||||
if (pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f)
|
||||
float pressureResistance = 0.0f;
|
||||
if (parts[r>>8].tmp > 0)
|
||||
pressureResistance = (float)parts[r>>8].tmp;
|
||||
else
|
||||
pressureResistance = 4.0f;
|
||||
|
||||
if (pv[ny/CELL][nx/CELL] < -pressureResistance || pv[ny/CELL][nx/CELL] > pressureResistance)
|
||||
result = 2;
|
||||
else
|
||||
result = 0;
|
||||
@ -2328,7 +2334,12 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
|
||||
}
|
||||
else if ((r&0xFF) == PT_INVIS)
|
||||
{
|
||||
if (pv[ny/CELL][nx/CELL]<=4.0f && pv[ny/CELL][nx/CELL]>=-4.0f)
|
||||
float pressureResistance = 0.0f;
|
||||
if (parts[r>>8].tmp > 0)
|
||||
pressureResistance = (float)parts[r>>8].tmp;
|
||||
else
|
||||
pressureResistance = 4.0f;
|
||||
if (pv[ny/CELL][nx/CELL] >= -pressureResistance && pv[ny/CELL][nx/CELL] <= pressureResistance)
|
||||
{
|
||||
part_change_type(i,x,y,PT_NEUT);
|
||||
parts[i].ctype = 0;
|
||||
|
@ -47,6 +47,11 @@ Element_FRAY::Element_FRAY()
|
||||
//#TPT-Directive ElementHeader Element_FRAY static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_FRAY::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
int curlen;
|
||||
if (parts[i].tmp > 0)
|
||||
curlen = parts[i].tmp;
|
||||
else
|
||||
curlen = 10;
|
||||
int r, nxx, nyy, len, nxi, nyi, rx, ry;
|
||||
for (rx=-1; rx<2; rx++)
|
||||
for (ry=-1; ry<2; ry++)
|
||||
@ -57,7 +62,7 @@ int Element_FRAY::update(UPDATE_FUNC_ARGS)
|
||||
continue;
|
||||
if ((r&0xFF)==PT_SPRK) {
|
||||
for (nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1, len = 0; ; nyy+=nyi, nxx+=nxi, len++) {
|
||||
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>10) {
|
||||
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>curlen) {
|
||||
break;
|
||||
}
|
||||
r = pmap[y+nyi+nyy][x+nxi+nxx];
|
||||
|
@ -48,10 +48,16 @@ Element_INVIS::Element_INVIS()
|
||||
//#TPT-Directive ElementHeader Element_INVIS static int update(UPDATE_FUNC_ARGS)
|
||||
int Element_INVIS::update(UPDATE_FUNC_ARGS)
|
||||
{
|
||||
if (sim->pv[y/CELL][x/CELL]>4.0f || sim->pv[y/CELL][x/CELL]<-4.0f)
|
||||
parts[i].tmp = 1;
|
||||
float pressureResistance = 0.0f;
|
||||
if (parts[i].tmp > 0)
|
||||
pressureResistance = (float) parts[i].tmp;
|
||||
else
|
||||
parts[i].tmp = 0;
|
||||
pressureResistance = 4.0f;
|
||||
|
||||
if (sim->pv[y/CELL][x/CELL] < -pressureResistance || sim->pv[y/CELL][x/CELL] > pressureResistance)
|
||||
parts[i].tmp2 = 1;
|
||||
else
|
||||
parts[i].tmp2 = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -59,7 +65,7 @@ int Element_INVIS::update(UPDATE_FUNC_ARGS)
|
||||
int Element_INVIS::graphics(GRAPHICS_FUNC_ARGS)
|
||||
{
|
||||
//pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f
|
||||
if(cpart->tmp)
|
||||
if(cpart->tmp2)
|
||||
{
|
||||
*cola = 100;
|
||||
*colr = 15;
|
||||
|
@ -258,7 +258,7 @@ int Element_TRON::trymovetron(Simulation * sim, int x, int y, int dir, int i, in
|
||||
//#TPT-Directive ElementHeader Element_TRON static bool canmovetron(Simulation * sim, int r, int len)
|
||||
bool Element_TRON::canmovetron(Simulation * sim, int r, int len)
|
||||
{
|
||||
if (!r || ((r&0xFF) == PT_SWCH && sim->parts[r>>8].life >= 10) || ((r&0xFF) == PT_INVIS && sim->parts[r>>8].tmp == 1))
|
||||
if (!r || ((r&0xFF) == PT_SWCH && sim->parts[r>>8].life >= 10) || ((r&0xFF) == PT_INVIS && sim->parts[r>>8].tmp2 == 1))
|
||||
return true;
|
||||
if ((((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL_DEC) && sim->parts[r>>8].life > 0)|| ((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL) && (sim->elements[r&0xFF].Properties & PROP_LIFE_DEC))) && sim->parts[r>>8].life < len)
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user