CFLM defusses VIBR, a few speed improvements to VIBR

This commit is contained in:
jacob1 2013-03-23 10:53:49 -04:00
parent 29e2604f57
commit c50e12df28
2 changed files with 76 additions and 50 deletions

View File

@ -2140,7 +2140,7 @@ int LuaScriptInterface::Command(std::string command)
std::string LuaScriptInterface::FormatCommand(std::string command)
{
if(command[0] == '!')
if(command != "" && command[0] == '!')
{
return "!"+legacy->FormatCommand(command.substr(1));
}

View File

@ -58,7 +58,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
parts[i].tmp++;
parts[i].temp -= 3;
}
if (parts[i].temp < 271.65f)
else if (parts[i].temp < 271.65f)
{
parts[i].tmp--;
parts[i].temp += 3;
@ -69,7 +69,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
parts[i].tmp += 7;
sim->pv[y/CELL][x/CELL]--;
}
if (sim->pv[y/CELL][x/CELL] < -2.5)
else if (sim->pv[y/CELL][x/CELL] < -2.5)
{
parts[i].tmp -= 2;
sim->pv[y/CELL][x/CELL]++;
@ -83,8 +83,9 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
//Release sparks before explode
if (parts[i].life < 300)
{
rx = rand()%3-1;
ry = rand()%3-1;
int randstore = rand();
rx = randstore%3-1;
ry = (randstore>>2)%3-1;
r = pmap[y+ry][x+rx];
if ((r&0xFF) && (r&0xFF) != PT_BREC && (sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && !parts[r>>8].life)
{
@ -112,27 +113,36 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
//Explosion code
if (parts[i].life == 1)
{
int random = rand(), index;
sim->create_part(i, x, y, PT_EXOT);
parts[i].tmp2 = rand()%1000;
index = sim->create_part(-3,x+((random>>4)&3)-1,y+((random>>6)&3)-1,PT_ELEC);
if (index != -1)
parts[index].temp = 7000;
index = sim->create_part(-3,x+((random>>8)&3)-1,y+((random>>10)&3)-1,PT_PHOT);
if (index != -1)
parts[index].temp = 7000;
index = sim->create_part(-1,x+((random>>12)&3)-1,y+rand()%3-1,PT_BREC);
if (index != -1)
parts[index].temp = 7000;
parts[i].temp=9000;
sim->pv[y/CELL][x/CELL] += 50;
if (!parts[i].tmp2)
{
int random = rand(), index;
sim->create_part(i, x, y, PT_EXOT);
parts[i].tmp2 = rand()%1000;
index = sim->create_part(-3,x+((random>>4)&3)-1,y+((random>>6)&3)-1,PT_ELEC);
if (index != -1)
parts[index].temp = 7000;
index = sim->create_part(-3,x+((random>>8)&3)-1,y+((random>>10)&3)-1,PT_PHOT);
if (index != -1)
parts[index].temp = 7000;
index = sim->create_part(-1,x+((random>>12)&3)-1,y+rand()%3-1,PT_BREC);
if (index != -1)
parts[index].temp = 7000;
parts[i].temp=9000;
sim->pv[y/CELL][x/CELL] += 50;
return 1;
return 1;
}
else
{
parts[i].tmp2 = 0;
parts[i].temp = 273.15f;
parts[i].tmp = 0;
}
}
}
//Neighbor check loop
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];
@ -140,26 +150,45 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
r = sim->photons[y+ry][x+rx];
if (!r)
continue;
//Melts into EXOT
if ((r&0xFF) == PT_EXOT && !(rand()%250) && !parts[i].life)
if (parts[i].life)
{
sim->create_part(i, x, y, PT_EXOT);
//Makes EXOT around it get tmp to start exploding too
if (((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR))
{
if (!parts[r>>8].life)
parts[r>>8].tmp += 45;
else if (parts[i].tmp2 && rand()%2)
{
parts[r>>8].tmp2 = 1;
parts[i].tmp = 0;
}
}
else if ((r&0xFF)==PT_CFLM)
{
parts[i].tmp2 = 1;
parts[i].tmp = 0;
}
}
else if ((r&0xFF) == PT_ANAR)
else
{
//Melts into EXOT
if ((r&0xFF) == PT_EXOT && !(rand()%25))
{
sim->create_part(i, x, y, PT_EXOT);
}
//Absorbs energy particles
else if ((sim->elements[r&0xFF].Properties & TYPE_ENERGY))
{
parts[i].tmp += 20;
sim->kill_part(r>>8);
}
}
//VIBR+ANAR=BVBR
if (parts[i].type != PT_BVBR && (r&0xFF) == PT_ANAR)
{
sim->part_change_type(i,x,y,PT_BVBR);
sim->pv[y/CELL][x/CELL] -= 1;
}
else if (((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR) && parts[i].life && !parts[r>>8].life)
{
parts[r>>8].tmp += 10;
}
//Absorbs energy particles
else if ((sim->elements[r&0xFF].Properties & TYPE_ENERGY) && !parts[i].life)
{
parts[i].tmp += 20;
sim->kill_part(r>>8);
}
}
for (trade = 0; trade < 9; trade++)
{
@ -174,18 +203,9 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
if (parts[i].tmp > parts[r>>8].tmp)
{
transfer = parts[i].tmp - parts[r>>8].tmp;
if (transfer == 1)
{
parts[r>>8].tmp += 1;
parts[i].tmp -= 1;
trade = 9;
}
else if (transfer > 0)
{
parts[r>>8].tmp += transfer/2;
parts[i].tmp -= transfer/2;
trade = 9;
}
parts[r>>8].tmp += transfer/2;
parts[i].tmp -= transfer/2;
break;
}
}
}
@ -201,8 +221,14 @@ int Element_VIBR::graphics(GRAPHICS_FUNC_ARGS)
if (gradient >= 100 || cpart->life)
{
*colr = (int)(fabs(sin(exp((750.0f-cpart->life)/170)))*200.0f);
*colg = 255;
*colb = (int)(fabs(sin(exp((750.0f-cpart->life)/170)))*200.0f);
if (cpart->tmp2)
*colg = (int)(fabs(sin(exp((750.0f-cpart->life)/170)))*200.0f);
else
*colg = 255;
if (cpart->tmp2)
*colb = 255;
else
*colb = (int)(fabs(sin(exp((750.0f-cpart->life)/170)))*200.0f);
*firea = 90;
*firer = *colr;
*fireg = *colg;