Add element ROCK (#724)

This commit is contained in:
RCAProduction 2020-10-07 16:27:25 -07:00 committed by GitHub
parent 99c99132bd
commit 1f7e9095da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 143 additions and 2 deletions

View File

@ -198,5 +198,6 @@ ELEMENT_DEFINE(LDTC, 186);
ELEMENT_DEFINE(SLCN, 187);
ELEMENT_DEFINE(PTNM, 188);
ELEMENT_DEFINE(VSNS, 189);
ELEMENT_DEFINE(ROCK, 190);
#undef ELEMENT_DEFINE

View File

@ -2370,8 +2370,9 @@ void Simulation::init_can_move()
can_move[movingType][PT_FIGH] = 0;
//INVS behaviour varies with pressure
can_move[movingType][PT_INVIS] = 3;
//stop CNCT from being displaced by other particles
//stop CNCT and ROCK from being displaced by other particles
can_move[movingType][PT_CNCT] = 0;
can_move[movingType][PT_ROCK] = 0;
//VOID and PVOD behaviour varies with powered state and ctype
can_move[movingType][PT_PVOD] = 3;
can_move[movingType][PT_VOID] = 3;
@ -2772,7 +2773,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny)
}
break;
case PT_CNCT:
if (y < ny && TYP(pmap[y+1][x]) == PT_CNCT) //check below CNCT for another CNCT
if (y < ny && (TYP(pmap[y+1][x]) == PT_CNCT || TYP(pmap[y+1][x]) == PT_ROCK)) //check below CNCT for another CNCT or ROCK
return 0;
break;
case PT_GBMB:

View File

@ -192,6 +192,65 @@ int Element_FIRE_update(UPDATE_FUNC_ARGS)
parts[ID(r)].ctype = PT_HEAC;
}
}
else if (parts[i].ctype == PT_ROCK)
{
float pres = sim->pv[y / CELL][x / CELL];
if (pres <= -9)
{
parts[i].ctype = PT_STNE;
break;
}
if (pres >= 25 && RNG::Ref().chance(1, 100000))
{
if (pres <= 50)
{
if (RNG::Ref().chance(1, 2))
parts[i].ctype = PT_BRMT;
else
parts[i].ctype = PT_CNCT;
break;
}
else if (pres <= 75)
{
if (pres >= 73 || RNG::Ref().chance(1, 8))
parts[i].ctype = PT_GOLD;
else
parts[i].ctype = PT_QRTZ;
break;
}
else if (pres <= 100 && parts[i].temp >= 5000)
{
if (RNG::Ref().chance(1, 5)) // 1 in 5 chance IRON to TTAN
parts[i].ctype = PT_TTAN;
else
parts[i].ctype = PT_IRON;
break;
}
else if (pres <= 255 && parts[i].temp >= 5000 && RNG::Ref().chance(1, 5))
{
if (RNG::Ref().chance(1, 5))
parts[i].ctype = PT_URAN;
else if (RNG::Ref().chance(1, 5))
parts[i].ctype = PT_PLUT;
else
parts[i].ctype = PT_TUNG;
break;
}
}
if (parts[ID(r)].ctype == PT_GOLD && parts[i].tmp == 0 && pres >= 50 && RNG::Ref().chance(1, 10000)) // Produce GOLD veins/clusters
{
parts[i].ctype = PT_GOLD;
if (rx) // Trend veins vertical
parts[i].tmp = 1;
}
}
else if (parts[i].ctype == PT_STNE && sim->pv[y / CELL][x / CELL] >= 2.0f) // Form ROCK with pressure
{
parts[i].tmp2 = RNG::Ref().between(0, 10); // Provide tmp2 for color noise
parts[i].ctype = PT_ROCK;
}
}
if ((surround_space || sim->elements[rt].Explosive) &&

View File

@ -0,0 +1,73 @@
#include "simulation/ElementCommon.h"
static int graphics(GRAPHICS_FUNC_ARGS);
static void create(ELEMENT_CREATE_FUNC_ARGS);
void Element::Element_ROCK()
{
Identifier = "DEFAULT_PT_ROCK";
Name = "ROCK";
Colour = PIXPACK(0x727272);
MenuVisible = 1;
MenuSection = SC_SOLIDS;
Enabled = 1;
Advection = 0.0f;
AirDrag = 0.00f * CFDS;
AirLoss = 0.94f;
Loss = 0.00f;
Collision = -0.0f;
Gravity = 0.0f;
Diffusion = 0.00f;
HotAir = 0.000f * CFDS;
Falldown = 0;
Flammable = 0;
Explosive = 0;
Meltable = 5;
Hardness = 70;
Weight = 120;
HeatConduct = 200;
Description = "Rock. Solid material, CNCT can stack on top of it.";
Properties = TYPE_SOLID | PROP_HOT_GLOW;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = 120;
HighPressureTransition = PT_STNE;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = 1943.15f;
HighTemperatureTransition = PT_LAVA;
Graphics = &graphics;
Create = &create;
}
static int graphics(GRAPHICS_FUNC_ARGS)
{
int z = (cpart->tmp2 - 7) * 6; // Randomized color noise based on tmp2
*colr += z;
*colg += z;
*colb += z;
if (cpart->temp >= 810.15) // Glows when hot, right before melting becomes bright
{
*pixel_mode |= FIRE_ADD;
*firea = ((cpart->temp)-810.15)/45;
*firer = *colr;
*fireg = *colg;
*fireb = *colb;
}
return 0;
}
static void create(ELEMENT_CREATE_FUNC_ARGS)
{
sim->parts[i].tmp2 = RNG::Ref().between(0, 10);
}

View File

@ -82,6 +82,13 @@ static int update(UPDATE_FUNC_ARGS)
{
sim->part_change_type(i,x,y,PT_SLTW);
}
else if (TYP(r)==PT_ROCK && fabs(parts[i].vx)+fabs(parts[i].vy) >= 0.5 && RNG::Ref().chance(1, 1000)) // ROCK erosion
{
if (RNG::Ref().chance(1,3))
sim->part_change_type(ID(r),x+rx,y+ry,PT_SAND);
else
sim->part_change_type(ID(r),x+rx,y+ry,PT_STNE);
}
}
return 0;
}