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) std::string LuaScriptInterface::FormatCommand(std::string command)
{ {
if(command[0] == '!') if(command != "" && command[0] == '!')
{ {
return "!"+legacy->FormatCommand(command.substr(1)); return "!"+legacy->FormatCommand(command.substr(1));
} }

View File

@@ -58,7 +58,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
parts[i].tmp++; parts[i].tmp++;
parts[i].temp -= 3; parts[i].temp -= 3;
} }
if (parts[i].temp < 271.65f) else if (parts[i].temp < 271.65f)
{ {
parts[i].tmp--; parts[i].tmp--;
parts[i].temp += 3; parts[i].temp += 3;
@@ -69,7 +69,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
parts[i].tmp += 7; parts[i].tmp += 7;
sim->pv[y/CELL][x/CELL]--; 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; parts[i].tmp -= 2;
sim->pv[y/CELL][x/CELL]++; sim->pv[y/CELL][x/CELL]++;
@@ -83,8 +83,9 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
//Release sparks before explode //Release sparks before explode
if (parts[i].life < 300) if (parts[i].life < 300)
{ {
rx = rand()%3-1; int randstore = rand();
ry = rand()%3-1; rx = randstore%3-1;
ry = (randstore>>2)%3-1;
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if ((r&0xFF) && (r&0xFF) != PT_BREC && (sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && !parts[r>>8].life) if ((r&0xFF) && (r&0xFF) != PT_BREC && (sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && !parts[r>>8].life)
{ {
@@ -111,6 +112,8 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
} }
//Explosion code //Explosion code
if (parts[i].life == 1) if (parts[i].life == 1)
{
if (!parts[i].tmp2)
{ {
int random = rand(), index; int random = rand(), index;
sim->create_part(i, x, y, PT_EXOT); sim->create_part(i, x, y, PT_EXOT);
@@ -129,10 +132,17 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
return 1; return 1;
} }
else
{
parts[i].tmp2 = 0;
parts[i].temp = 273.15f;
parts[i].tmp = 0;
}
}
} }
//Neighbor check loop //Neighbor check loop
for (rx=-2; rx<3; rx++) for (rx=-1; rx<2; rx++)
for (ry=-2; ry<3; ry++) for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
@@ -140,27 +150,46 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
r = sim->photons[y+ry][x+rx]; r = sim->photons[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if (parts[i].life)
{
//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
{
//Melts into EXOT //Melts into EXOT
if ((r&0xFF) == PT_EXOT && !(rand()%250) && !parts[i].life) if ((r&0xFF) == PT_EXOT && !(rand()%25))
{ {
sim->create_part(i, x, y, PT_EXOT); sim->create_part(i, x, y, PT_EXOT);
} }
else if ((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 //Absorbs energy particles
else if ((sim->elements[r&0xFF].Properties & TYPE_ENERGY) && !parts[i].life) else if ((sim->elements[r&0xFF].Properties & TYPE_ENERGY))
{ {
parts[i].tmp += 20; parts[i].tmp += 20;
sim->kill_part(r>>8); 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;
}
}
for (trade = 0; trade < 9; trade++) for (trade = 0; trade < 9; trade++)
{ {
int random = rand(); int random = rand();
@@ -174,18 +203,9 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
if (parts[i].tmp > parts[r>>8].tmp) if (parts[i].tmp > parts[r>>8].tmp)
{ {
transfer = 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[r>>8].tmp += transfer/2;
parts[i].tmp -= transfer/2; parts[i].tmp -= transfer/2;
trade = 9; break;
}
} }
} }
} }
@@ -201,7 +221,13 @@ int Element_VIBR::graphics(GRAPHICS_FUNC_ARGS)
if (gradient >= 100 || cpart->life) if (gradient >= 100 || cpart->life)
{ {
*colr = (int)(fabs(sin(exp((750.0f-cpart->life)/170)))*200.0f); *colr = (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; *colg = 255;
if (cpart->tmp2)
*colb = 255;
else
*colb = (int)(fabs(sin(exp((750.0f-cpart->life)/170)))*200.0f); *colb = (int)(fabs(sin(exp((750.0f-cpart->life)/170)))*200.0f);
*firea = 90; *firea = 90;
*firer = *colr; *firer = *colr;