Merge branch 'master' of git@github.com:FacialTurd/The-Powder-Toy.git

This commit is contained in:
jacob1 2013-05-29 20:36:34 -04:00
commit d6d20defde
20 changed files with 175 additions and 354 deletions

View File

@ -74,21 +74,21 @@ if GetOption("toolprefix"):
#Check for headers and libraries
if not GetOption("macosx"):
conf = Configure(env)
try:
env.ParseConfig('sdl-config --cflags')
env.ParseConfig('sdl-config --libs')
except:
if not conf.CheckLib("SDL"):
print "libSDL not found or not installed"
if(GetOption("sdl-dir")):
if not conf.CheckCHeader(GetOption("sdl-dir") + '/SDL.h'):
print "sdl headers not found or not installed"
raise SystemExit(1)
if(GetOption("sdl-dir")):
if not conf.CheckCHeader(GetOption("sdl-dir") + '/SDL.h'):
print "sdl headers not found or not installed"
else:
env.Append(CPPPATH=[GetOption("sdl-dir")])
else:
try:
env.ParseConfig('sdl-config --cflags')
env.ParseConfig('sdl-config --libs')
except:
if not conf.CheckLib("SDL"):
print "libSDL not found or not installed"
raise SystemExit(1)
else:
env.Append(CPPPATH=[GetOption("sdl-dir")])
#Find correct lua include dir
if not GetOption("nolua"):

View File

@ -16,8 +16,8 @@
#include "graphics/Graphics.h"
#if defined(LIN)
#include "icon.h"
#include <signal.h>
#endif
#include <signal.h>
#ifndef WIN
#include <unistd.h>
@ -377,7 +377,7 @@ ui::Engine * engine = NULL;
float currentWidth, currentHeight;
void EngineProcess()
{
int frameStart;
int frameStart = SDL_GetTicks();
float frameTime;
float frameTimeAvg = 0.0f, correctedFrameTimeAvg = 0.0f;
SDL_Event event;
@ -492,33 +492,9 @@ void EngineProcess()
}
if(engine->Broken()) { engine->UnBreak(); break; }
frameStart = SDL_GetTicks();
engine->Tick();
engine->Draw();
frameTime = SDL_GetTicks() - frameStart;
frameTimeAvg = (frameTimeAvg*(1.0f-0.2f)) + (0.2f*frameTime);
if(ui::Engine::Ref().FpsLimit > 2.0f)
{
float targetFrameTime = 1000.0f/((float)ui::Engine::Ref().FpsLimit);
if(targetFrameTime - frameTimeAvg > 0)
{
SDL_Delay((targetFrameTime - frameTimeAvg) + 0.5f);
frameTime = SDL_GetTicks() - frameStart;//+= (int)(targetFrameTime - frameTimeAvg);
}
}
correctedFrameTimeAvg = (correctedFrameTimeAvg*(1.0f-0.05f)) + (0.05f*frameTime);
fps = 1000.0f/correctedFrameTimeAvg;
engine->SetFps(fps);
if(frameStart-lastTick>250)
{
//Run client tick every second
lastTick = frameStart;
Client::Ref().Tick();
}
if(scale != engine->Scale || fullscreen != engine->Fullscreen)
{
sdl_scrn = SDLSetScreen(engine->Scale, engine->Fullscreen);
@ -533,6 +509,29 @@ void EngineProcess()
else
blit(engine->g->vid);
#endif
frameTime = SDL_GetTicks() - frameStart;
frameTimeAvg = (frameTimeAvg*(1.0f-0.2f)) + (0.2f*frameTime);
if(ui::Engine::Ref().FpsLimit > 2.0f)
{
float targetFrameTime = 1000.0f/((float)ui::Engine::Ref().FpsLimit);
if(targetFrameTime - frameTimeAvg > 0)
{
SDL_Delay((targetFrameTime - frameTimeAvg) + 0.5f);
frameTime = SDL_GetTicks() - frameStart;//+= (int)(targetFrameTime - frameTimeAvg);
}
}
correctedFrameTimeAvg = (correctedFrameTimeAvg*(1.0f-0.05f)) + (0.05f*frameTime);
fps = 1000.0f/correctedFrameTimeAvg;
engine->SetFps(fps);
frameStart = SDL_GetTicks();
if(frameStart-lastTick>250)
{
//Run client tick every second
lastTick = frameStart;
Client::Ref().Tick();
}
}
#ifdef DEBUG
std::cout << "Breaking out of EngineProcess" << std::endl;
@ -786,7 +785,6 @@ int main(int argc, char * argv[])
signal(SIGFPE, SigHandler);
signal(SIGILL, SigHandler);
signal(SIGABRT, SigHandler);
#endif
GameController * gameController = NULL;

View File

@ -261,6 +261,9 @@ AnyType TPTScriptInterface::tptS_set(std::deque<std::string> * words)
newValue = GetParticleType(((StringType)value).Value());
if (newValue < 0 || newValue >= PT_NUM)
{
// TODO: add element CAKE to invalidate this
if (!strcasecmp(((StringType)value).Value().c_str(),"cake"))
throw GeneralException("Cake is a lie, not an element");
throw GeneralException("Invalid element");
}
}

View File

@ -1217,7 +1217,7 @@ void GameView::BeginStampSelection()
{
selectMode = SelectStamp;
selectPoint1 = ui::Point(-1, -1);
buttonTip = "\x0F\xEF\xEF\x10\Click-and-drag to specify an area to create a stamp (right click = cancel)";
buttonTip = "\x0F\xEF\xEF\020Click-and-drag to specify an area to create a stamp (right click = cancel)";
buttonTipShow = 120;
}
@ -1397,7 +1397,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
{
selectMode = SelectCopy;
selectPoint1 = ui::Point(-1, -1);
buttonTip = "\x0F\xEF\xEF\x10\Click-and-drag to specify an area to copy (right click = cancel)";
buttonTip = "\x0F\xEF\xEF\020Click-and-drag to specify an area to copy (right click = cancel)";
buttonTipShow = 120;
}
break;
@ -1406,7 +1406,7 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
{
selectMode = SelectCut;
selectPoint1 = ui::Point(-1, -1);
buttonTip = "\x0F\xEF\xEF\x10\Click-and-drag to specify an area to copy then cut (right click = cancel)";
buttonTip = "\x0F\xEF\xEF\020Click-and-drag to specify an area to copy then cut (right click = cancel)";
buttonTipShow = 120;
}
break;

View File

@ -2915,6 +2915,7 @@ int Simulation::create_part(int p, int x, int y, int tv)
}
else
{
parts[i].type=0;
return -1;
}
create_part(-3,x,y,PT_SPAWN);
@ -2930,6 +2931,7 @@ int Simulation::create_part(int p, int x, int y, int tv)
}
else
{
parts[i].type=0;
return -1;
}
create_part(-3,x,y,PT_SPAWN2);
@ -2943,84 +2945,70 @@ int Simulation::create_part(int p, int x, int y, int tv)
case PT_TSNS:
parts[i].tmp2 = 2;
break;
case PT_FIGH:{
unsigned char fcount = 0;
while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++;
if (fcount < 100 && fighters[fcount].spwn==0)
{
parts[i].life = 100;
parts[i].tmp = fcount;
Element_STKM::STKM_init_legs(this, &fighters[fcount], i);
fighters[fcount].spwn = 1;
fighters[fcount].elem = PT_DUST;
fighters[fcount].rocketBoots = false;
fighcount++;
return i;
}
parts[i].type=0;
return -1;}
case PT_PHOT:{
float a = (rand()%8) * 0.78540f;
parts[i].life = 680;
parts[i].ctype = 0x3FFFFFFF;
parts[i].vx = 3.0f*cosf(a);
parts[i].vy = 3.0f*sinf(a);
break;}
case PT_ELEC:{
float a = (rand()%360)*3.14159f/180.0f;
parts[i].life = 680;
parts[i].vx = 2.0f*cosf(a);
parts[i].vy = 2.0f*sinf(a);
break;}
case PT_NEUT:{
float r = (rand()%128+128)/127.0f;
float a = (rand()%360)*3.14159f/180.0f;
parts[i].life = rand()%480+480;
parts[i].vx = r*cosf(a);
parts[i].vy = r*sinf(a);
break;}
case PT_TRON:{
int randhue = rand()%360;
int randomdir = rand()%4;
parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction
parts[i].tmp2 = 4;//tail
parts[i].life = 5;
break;}
case PT_LIGH:{
float gx, gy, gsize;
if (p!=-2)
{
parts[i].life=30;
parts[i].temp=parts[i].life*150.0f; // temperature of the lighting shows the power of the lighting
}
GetGravityField(x, y, 1.0f, 1.0f, gx, gy);
gsize = gx*gx+gy*gy;
if (gsize<0.0016f)
{
float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
gsize = sqrtf(gsize);
// randomness in weak gravity fields (more randomness with weaker fields)
gx += cosf(angle)*(0.04f-gsize);
gy += sinf(angle)*(0.04f-gsize);
}
parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+rand()%40-20+360)%360;
parts[i].tmp2 = 4;
break;}
default:
if (t==PT_FIGH)
{
unsigned char fcount = 0;
while (fcount < 100 && fcount < (fighcount+1) && fighters[fcount].spwn==1) fcount++;
if (fcount < 100 && fighters[fcount].spwn==0)
{
parts[i].x = (float)x;
parts[i].y = (float)y;
parts[i].type = PT_FIGH;
parts[i].vx = 0;
parts[i].vy = 0;
parts[i].life = 100;
parts[i].ctype = 0;
parts[i].tmp = fcount;
parts[i].temp = elements[t].Temperature;
Element_STKM::STKM_init_legs(this, &fighters[fcount], i);
fighters[fcount].spwn = 1;
fighters[fcount].elem = PT_DUST;
fighters[fcount].rocketBoots = false;
fighcount++;
return i;
}
return -1;
}
if (t==PT_PHOT)
{
float a = (rand()%8) * 0.78540f;
parts[i].life = 680;
parts[i].ctype = 0x3FFFFFFF;
parts[i].vx = 3.0f*cosf(a);
parts[i].vy = 3.0f*sinf(a);
}
if (t==PT_ELEC)
{
float a = (rand()%360)*3.14159f/180.0f;
parts[i].life = 680;
parts[i].vx = 2.0f*cosf(a);
parts[i].vy = 2.0f*sinf(a);
}
if (t==PT_NEUT)
{
float r = (rand()%128+128)/127.0f;
float a = (rand()%360)*3.14159f/180.0f;
parts[i].life = rand()%480+480;
parts[i].vx = r*cosf(a);
parts[i].vy = r*sinf(a);
}
if (t==PT_TRON)
{
int randhue = rand()%360;
int randomdir = rand()%4;
parts[i].tmp = 1|(randomdir<<5)|(randhue<<7);//set as a head and a direction
parts[i].tmp2 = 4;//tail
parts[i].life = 5;
}
if (t==PT_LIGH)
{
float gx, gy, gsize;
if (p!=-2)
{
parts[i].life=30;
parts[i].temp=parts[i].life*150.0f; // temperature of the lighting shows the power of the lighting
}
GetGravityField(x, y, 1.0f, 1.0f, gx, gy);
gsize = gx*gx+gy*gy;
if (gsize<0.0016f)
{
float angle = (rand()%6284)*0.001f;//(in radians, between 0 and 2*pi)
gsize = sqrtf(gsize);
// randomness in weak gravity fields (more randomness with weaker fields)
gx += cosf(angle)*(0.04f-gsize);
gy += sinf(angle)*(0.04f-gsize);
}
parts[i].tmp = (((int)(atan2f(-gy, gx)*(180.0f/M_PI)))+rand()%40-20+360)%360;
parts[i].tmp2 = 4;
}
break;
}
//and finally set the pmap/photon maps to the newly created particle

View File

@ -60,7 +60,7 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_CFLM && !(rand()%7))
if ((r&0xFF)==PT_CFLM && !(rand()%4))
{
sim->part_change_type(i,x,y,PT_CFLM);
parts[i].life = rand()%150+50;

View File

@ -42,82 +42,8 @@ Element_BCOL::Element_BCOL()
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &Element_BCOL::update;
Graphics = &Element_BCOL::graphics;
Update = &Element_COAL::update;
Graphics = &Element_COAL::graphics;
}
//#TPT-Directive ElementHeader Element_BCOL static int update(UPDATE_FUNC_ARGS)
int Element_BCOL::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, trade, temp;
if (parts[i].life<=0) {
sim->create_part(i, x, y, PT_FIRE);
return 1;
} else if (parts[i].life < 100) {
parts[i].life--;
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
}
/*if(100-parts[i].life > parts[i].tmp2)
parts[i].tmp2 = 100-parts[i].life;
if(parts[i].tmp2 < 0) parts[i].tmp2 = 0;
for ( trade = 0; trade<4; trade ++)
{
rx = rand()%5-2;
ry = rand()%5-2;
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion
{
int temp = parts[i].tmp2 - parts[r>>8].tmp2;
if(temp < 10)
continue;
if (temp ==1)
{
parts[r>>8].tmp2 ++;
parts[i].tmp2 --;
}
else if (temp>0)
{
parts[r>>8].tmp2 += temp/2;
parts[i].tmp2 -= temp/2;
}
}
}
}*/
if(parts[i].temp > parts[i].tmp2)
parts[i].tmp2 = parts[i].temp;
return 0;
}
//#TPT-Directive ElementHeader Element_BCOL static int graphics(GRAPHICS_FUNC_ARGS)
int Element_BCOL::graphics(GRAPHICS_FUNC_ARGS)
//Both COAL and Broken Coal
{
*colr += (cpart->tmp2-295.15f)/3;
if (*colr > 170)
*colr = 170;
if (*colr < *colg)
*colr = *colg;
*colg = *colb = *colr;
if((cpart->temp-295.15f) > 300.0f-200.0f)
{
float frequency = 3.1415/(2*300.0f-(300.0f-200.0f));
int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f);
*colr += sin(frequency*q) * 226;
*colg += sin(frequency*q*4.55 +3.14) * 34;
*colb += sin(frequency*q*2.22 +3.14) * 64;
}
return 0;
}
Element_BCOL::~Element_BCOL() {}

View File

@ -96,7 +96,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
//Start explode
parts[i].tmp = rand()%25;//(rand()%100)+50;
}
else if((sim->elements[r&0xFF].Properties&TYPE_SOLID) && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%13333))
else if((sim->elements[r&0xFF].Properties&TYPE_SOLID) && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%6667))
{
sim->part_change_type(i,x,y,PT_CO2);
parts[i].ctype = 5;
@ -131,7 +131,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
}
else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){
sim->kill_part(r>>8);
if(1>(rand()%50)){
if(!(rand()%50)){
sim->kill_part(i);
return 1;
}

View File

@ -57,7 +57,7 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
{
if (parts[i].ctype==5 && !(rand()%27))
if (parts[i].ctype==5 && !(rand()%2000))
{
if (sim->create_part(-1, x+rx, y+ry, PT_WATR)>=0)
parts[i].ctype = 0;
@ -66,12 +66,12 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
}
if ((r&0xFF)==PT_FIRE){
sim->kill_part(r>>8);
if(!(rand()%50)){
if(!(rand()%30)){
sim->kill_part(i);
return 1;
}
}
else if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%83))
else if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%50))
{
sim->part_change_type(r>>8, x+rx, y+ry, PT_CBNW);
if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet

View File

@ -49,7 +49,7 @@ Element_COAL::Element_COAL()
//#TPT-Directive ElementHeader Element_COAL static int update(UPDATE_FUNC_ARGS)
int Element_COAL::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, trade, temp;
int r, rx, ry, trade, temp, t = parts[i].type;
if (parts[i].life<=0) {
sim->create_part(i, x, y, PT_FIRE);
return 1;
@ -57,13 +57,16 @@ int Element_COAL::update(UPDATE_FUNC_ARGS)
parts[i].life--;
sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE);
}
if ((sim->pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40)
parts[i].tmp=39;
else if (parts[i].tmp<40&&parts[i].tmp>0)
parts[i].tmp--;
else if (parts[i].tmp<=0) {
sim->create_part(i, x, y, PT_BCOL);
return 1;
if (t == PT_COAL)
{
if ((sim->pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40)
parts[i].tmp=39;
else if (parts[i].tmp<40&&parts[i].tmp>0)
parts[i].tmp--;
else if (parts[i].tmp<=0) {
sim->create_part(i, x, y, PT_BCOL);
return 1;
}
}
/*if(100-parts[i].life > parts[i].tmp2)
parts[i].tmp2 = 100-parts[i].life;

View File

@ -58,7 +58,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
switch (r&0xFF)
{
case PT_SALT:
if (!(rand()%83))
if (!(rand()%50))
{
sim->part_change_type(i,x,y,PT_SLTW);
// on average, convert 3 DSTW to SLTW before SALT turns into SLTW
@ -67,20 +67,20 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
}
break;
case PT_SLTW:
if (!(rand()%3333))
if (!(rand()%2000))
{
sim->part_change_type(i,x,y,PT_SLTW);
break;
}
case PT_WATR:
if (!(rand()%166))
if (!(rand()%100))
{
sim->part_change_type(i,x,y,PT_WATR);
}
break;
case PT_RBDM:
case PT_LRBD:
if ((sim->legacy_enable||parts[i].temp>12.0f) && !(rand()%166))
if ((sim->legacy_enable||parts[i].temp>12.0f) && !(rand()%100))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
@ -88,7 +88,7 @@ int Element_DSTW::update(UPDATE_FUNC_ARGS)
break;
case PT_FIRE:
sim->kill_part(r>>8);
if(!(rand()%50)){
if(!(rand()%30)){
sim->kill_part(i);
return 1;
}

View File

@ -63,14 +63,14 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS)
continue;
if ((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW)
{
if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%333))
if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%200))
{
sim->part_change_type(i,x,y,PT_SLTW);
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
return 0;
}
}
else if (((r&0xFF)==PT_FRZZ) && (parts[i].ctype=PT_FRZW) && !(rand()%333))
else if (((r&0xFF)==PT_FRZZ) && (parts[i].ctype=PT_FRZW) && !(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI);
}
return 0;

View File

@ -58,7 +58,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
switch (r&0xFF)
{
case PT_WATR:
if (!(rand()%83))
if (!(rand()%50))
{
np = sim->create_part(r>>8,x+rx,y+ry,PT_PLNT);
if (np<0) continue;
@ -66,7 +66,7 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
}
break;
case PT_LAVA:
if (!(rand()%83))
if (!(rand()%50))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
@ -74,14 +74,14 @@ int Element_PLNT::update(UPDATE_FUNC_ARGS)
break;
case PT_SMKE:
case PT_CO2:
if (!(rand()%83))
if (!(rand()%50))
{
sim->kill_part(r>>8);
parts[i].life = rand()%60 + 60;
}
break;
case PT_WOOD:
if (surround_space && !(rand()%7) && (abs(rx+ry)<=2) && (sim->VINE_MODE || parts[i].tmp==1))
if (surround_space && !(rand()%4) && (abs(rx+ry)<=2) && (sim->VINE_MODE || parts[i].tmp==1))
{
int nnx = rand()%3 -1;
int nny = rand()%3 -1;

View File

@ -26,7 +26,7 @@ Element_PQRT::Element_PQRT()
Weight = 90;
Temperature = R_TEMP+0.0f +273.15f;
Temperature = R_TEMP+273.15f;
HeatConduct = 3;
Description = "Powdered quartz, broken form of QRTZ.";
@ -42,113 +42,8 @@ Element_PQRT::Element_PQRT()
HighTemperature = 2573.15f;
HighTemperatureTransition = PT_LAVA;
Update = &Element_PQRT::update;
Graphics = &Element_PQRT::graphics;
Update = &Element_QRTZ::update;
Graphics = &Element_QRTZ::graphics;
}
//#TPT-Directive ElementHeader Element_PQRT static int update(UPDATE_FUNC_ARGS)
int Element_PQRT::update(UPDATE_FUNC_ARGS)
{
int r, tmp, trade, rx, ry, np;
// absorb SLTW
if (parts[i].ctype!=-1)
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
else if ((r&0xFF)==PT_SLTW && !(rand()%833))
{
sim->kill_part(r>>8);
parts[i].ctype ++;
}
}
// grow and diffuse
if (parts[i].ctype>0)
{
bool stopgrow=false;
int rnd, sry, srx;
for ( trade = 0; trade<9; trade ++)
{
rnd = rand()%0x3FF;
rx = (rnd%5)-2;
srx = (rnd%3)-1;
rnd = rnd>>3;
ry = (rnd%5)-2;
sry = (rnd%3)-1;
if (BOUNDS_CHECK && (rx || ry))
{
if (!stopgrow)//try to grow
{
if (!pmap[y+sry][x+srx] && parts[i].ctype!=0)
{
np = sim->create_part(-1,x+srx,y+sry,PT_QRTZ);
if (np>-1)
{
parts[np].tmp = parts[i].tmp;
parts[i].ctype--;
if (rand()%2)
{
parts[np].ctype=-1;//dead qrtz
}
else if (!parts[i].ctype && !(rand()%15))
{
parts[i].ctype=-1;
}
stopgrow=true;
}
}
}
//diffusion
r = pmap[y+ry][x+rx];
if (!r)
continue;
else if ((r&0xFF)==PT_PQRT && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )
{
tmp = parts[i].ctype - parts[r>>8].ctype;
if (tmp ==1)
{
parts[r>>8].ctype ++;
parts[i].ctype --;
break;
}
if (tmp>0)
{
parts[r>>8].ctype += tmp/2;
parts[i].ctype -= tmp/2;
break;
}
}
}
}
}
return 0;
}
//#TPT-Directive ElementHeader Element_PQRT static int graphics(GRAPHICS_FUNC_ARGS)
int Element_PQRT::graphics(GRAPHICS_FUNC_ARGS)
//QRTZ and PQRT
{
int t = cpart->type, z = cpart->tmp - 5;//speckles!
/*if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz
{
float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f));
int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f);
*colr += sin(frequency*q) * 226 + (z * 16);
*colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16);
*colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16);
}
else*/
{
*colr += z * 16;
*colg += z * 16;
*colb += z * 16;
}
return 0;
}
Element_PQRT::~Element_PQRT() {}

View File

@ -26,7 +26,7 @@ Element_QRTZ::Element_QRTZ()
Weight = 100;
Temperature = R_TEMP+0.0f +273.15f;
Temperature = R_TEMP+273.15f;
HeatConduct = 3;
Description = "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures.";
@ -49,23 +49,26 @@ Element_QRTZ::Element_QRTZ()
//#TPT-Directive ElementHeader Element_QRTZ static int update(UPDATE_FUNC_ARGS)
int Element_QRTZ::update(UPDATE_FUNC_ARGS)
{
int r, tmp, trade, rx, ry, np;
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = sim->pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3))
int r, tmp, trade, rx, ry, np, t = parts[i].type;
if (t == PT_QRTZ)
{
sim->part_change_type(i,x,y,PT_PQRT);
parts[i].pavg[0] = parts[i].pavg[1];
parts[i].pavg[1] = sim->pv[y/CELL][x/CELL];
if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3))
{
sim->part_change_type(i,x,y,PT_PQRT);
}
}
// absorb SLTW
if (parts[i].ctype!=-1)
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry))
{
r = pmap[y+ry][x+rx];
if (!r)
continue;
else if ((r&0xFF)==PT_SLTW && !(rand()%2500))
else if ((r&0xFF)==PT_SLTW && !(rand()%500))
{
sim->kill_part(r>>8);
parts[i].ctype ++;
@ -111,7 +114,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
else if ((r&0xFF)==PT_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )
else if ((r&0xFF)==PT_QRTZ && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0)
{
tmp = parts[i].ctype - parts[r>>8].ctype;
if (tmp ==1)

View File

@ -58,16 +58,16 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS)
switch (r&0xFF)
{
case PT_SALT:
if (!(rand()%3333))
if (!(rand()%2000))
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
break;
case PT_PLNT:
if (!(rand()%66))
if (!(rand()%40))
sim->kill_part(r>>8);
break;
case PT_RBDM:
case PT_LRBD:
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%166))
if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
@ -78,7 +78,7 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS)
if (parts[r>>8].ctype!=PT_WATR)
{
sim->kill_part(r>>8);
if(!(rand()%150)){
if(!(rand()%30)){
sim->kill_part(i);
return 1;
}

View File

@ -210,7 +210,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
bool moved = false;
if (dl>dr)
{
if (!sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
{
playerp->accs[2] = -3*gvy-3*gvx;
playerp->accs[3] = 3*gvx-3*gvy;
@ -221,7 +221,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
}
else
{
if (!sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
{
playerp->accs[6] = -3*gvy-3*gvx;
playerp->accs[7] = 3*gvx-3*gvy;
@ -260,7 +260,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
bool moved = false;
if (dl<dr)
{
if (!sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
if (INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL))
{
playerp->accs[2] = 3*gvy-3*gvx;
playerp->accs[3] = -3*gvx-3*gvy;
@ -271,7 +271,7 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
}
else
{
if (!sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
if (INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
{
playerp->accs[6] = 3*gvy-3*gvx;
playerp->accs[7] = -3*gvx-3*gvy;
@ -337,7 +337,8 @@ int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) {
}
}
}
else if (!sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL) || !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL))
else if ((INBOND(playerp->legs[4], playerp->legs[5]) && !sim->eval_move(t, playerp->legs[4], playerp->legs[5], NULL)) ||
(INBOND(playerp->legs[12], playerp->legs[13]) && !sim->eval_move(t, playerp->legs[12], playerp->legs[13], NULL)))
{
parts[i].vx -= 4*gvx;
parts[i].vy -= 4*gvy;

View File

@ -57,14 +57,14 @@ int Element_WATR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_SALT && !(rand()%83))
if ((r&0xFF)==PT_SALT && !(rand()%50))
{
sim->part_change_type(i,x,y,PT_SLTW);
// on average, convert 3 WATR to SLTW before SALT turns into SLTW
if (!(rand()%3))
sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW);
}
else if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%166))
else if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;
@ -72,12 +72,16 @@ int Element_WATR::update(UPDATE_FUNC_ARGS)
}
else if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){
sim->kill_part(r>>8);
if(!(rand()%50)){
if(!(rand()%30)){
sim->kill_part(i);
return 1;
}
}
/*if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) Concrete+Water to paste, not very popular
else if ((r&0xFF)==PT_SLTW && !(rand()%2000))
{
sim->part_change_type(i,x,y,PT_SLTW);
}
/*if ((r&0xFF)==PT_CNCT && !(rand()%100)) Concrete+Water to paste, not very popular
{
part_change_type(i,x,y,PT_PSTE);
sim.kill_part(r>>8);

View File

@ -57,7 +57,7 @@ int Element_WTRV::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && !(rand()%166))
if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && !(rand()%100))
{
sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4;

View File

@ -57,7 +57,7 @@ int Element_YEST::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
if ((r&0xFF)==PT_DYST && !(rand()%10) && !sim->legacy_enable)
if ((r&0xFF)==PT_DYST && !(rand()%6) && !sim->legacy_enable)
{
sim->part_change_type(i,x,y,PT_DYST);
}