Merge branch 'resist'

This commit is contained in:
Saveliy Skresanov 2024-01-13 13:47:37 +07:00
commit e314e99c4c
21 changed files with 273 additions and 17 deletions

View File

@ -194,7 +194,7 @@ void SimulationData::init_can_move()
|| destinationType == PT_CLNE || destinationType == PT_PCLN || destinationType == PT_BCLN || destinationType == PT_PBCN
|| destinationType == PT_WATR || destinationType == PT_DSTW || destinationType == PT_SLTW || destinationType == PT_GLOW
|| destinationType == PT_ISOZ || destinationType == PT_ISZS || destinationType == PT_QRTZ || destinationType == PT_PQRT
|| destinationType == PT_H2 || destinationType == PT_BGLA || destinationType == PT_C5)
|| destinationType == PT_H2 || destinationType == PT_BGLA || destinationType == PT_C5 || destinationType == PT_RSST)
can_move[PT_PHOT][destinationType] = 2;
if (destinationType != PT_DMND && destinationType != PT_INSL && destinationType != PT_VOID && destinationType != PT_PVOD && destinationType != PT_VIBR && destinationType != PT_BVBR && destinationType != PT_PRTI && destinationType != PT_PRTO)
{
@ -233,6 +233,8 @@ void SimulationData::init_can_move()
can_move[PT_THDR][PT_THDR] = 2;
can_move[PT_EMBR][PT_EMBR] = 2;
can_move[PT_TRON][PT_SWCH] = 3;
can_move[PT_ELEC][PT_RSST] = 2;
can_move[PT_ELEC][PT_RSSS] = 2;
}
const CustomGOLData *SimulationData::GetCustomGOLByRule(int rule) const

View File

@ -59,7 +59,8 @@ static int update(UPDATE_FUNC_ARGS)
if (!r)
continue;
auto rt = TYP(r);
if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL)
auto pavg = sim->parts_avg(i,ID(r),PT_INSL);
if (pavg!=PT_INSL && pavg!=PT_RSSS)
{
if ((elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0)
{

View File

@ -62,7 +62,8 @@ static int update(UPDATE_FUNC_ARGS)
if (rx || ry)
{
auto r = pmap[y+ry][x+rx];
if (!r || sim->parts_avg(ID(r), i,PT_INSL)==PT_INSL)
auto pavg = sim->parts_avg(ID(r), i, PT_INSL);
if (!r || pavg==PT_INSL || pavg==PT_RSSS)
continue;
if (TYP(r)==PT_SPRK && parts[i].life==0 && parts[ID(r)].life>0 && parts[ID(r)].life<4 && parts[ID(r)].ctype==PT_PSCN)
{

View File

@ -68,7 +68,8 @@ static int update(UPDATE_FUNC_ARGS)
if (!r)
continue;
auto rt = TYP(r);
if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL)
auto pavg = sim->parts_avg(i,ID(r),PT_INSL);
if (pavg != PT_INSL && pavg != PT_RSSS)
{
if ((elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0)
{

View File

@ -117,6 +117,15 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].tmp2 += 5;
parts[ID(r)].life = 1000;
break;
case PT_RSST: //Destroy RSST
if(!rx && !ry)
{
sim->kill_part(ID(r));
sim->kill_part(i);
return 1;
}
break;
case PT_NONE: //seems to speed up ELEC even if it isn't used
break;
default:

View File

@ -66,6 +66,12 @@ static int update(UPDATE_FUNC_ARGS)
parts[ID(r)].life = 10;
return 1;
}
else if (TYP(r) == PT_GEL) //GLOW + GEL = RSST
{
sim->kill_part(i);
sim->part_change_type(ID(r),x+rx,y+ry,PT_RSST);
return 1;
}
}
}
}

View File

@ -59,6 +59,16 @@ static int update(UPDATE_FUNC_ARGS)
if (parts[i].tmp <= -100)
parts[i].tmp = -100;
int under = pmap[y][x];
int utype = TYP(under);
//Randomly kill GRVT inside RSSS
if((utype == PT_RSSS) && sim->rng.chance(1, 5))
{
sim->kill_part(i);
return 1;
}
sim->gravmap[(y/CELL)*XCELLS+(x/CELL)] = 0.2f*parts[i].tmp;
return 0;
}

View File

@ -93,6 +93,8 @@ static int update(UPDATE_FUNC_ARGS)
}
Particle &neighbor = parts[ID(neighborData)];
auto pavg = sim->parts_avg(i, ID(neighborData), PT_INSL);
switch (TYP(neighborData))
{
case PT_SLTW:
@ -134,7 +136,7 @@ static int update(UPDATE_FUNC_ARGS)
break;
case PT_SPRK:
if (sim->parts_avg(i, ID(neighborData), PT_INSL) == PT_INSL)
if (pavg == PT_INSL || pavg == PT_RSSS)
{
break;
}
@ -149,7 +151,7 @@ static int update(UPDATE_FUNC_ARGS)
break;
case PT_NSCN:
if (sim->parts_avg(i, ID(neighborData), PT_INSL) == PT_INSL)
if (pavg == PT_INSL || pavg == PT_RSSS)
{
break;
}

View File

@ -69,7 +69,8 @@ static int update(UPDATE_FUNC_ARGS)
if (!r)
continue;
int rt = TYP(r);
if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL)
auto pavg = sim->parts_avg(i, ID(r), PT_INSL);
if (pavg != PT_INSL && pavg != PT_RSSS)
{
if ((elements[rt].Properties&PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[ID(r)].life == 0)
{

View File

@ -164,6 +164,31 @@ static int update(UPDATE_FUNC_ARGS)
else
sim->create_part(ID(r), x+rx, y+ry, PT_CAUS);
break;
case PT_RSSS:
if(!rx && !ry)
{
int ct_under, tmp_under;
ct_under = parts[ID(r)].ctype;
tmp_under = parts[ID(r)].tmp;
//If there's a correct ctype set, liquefy into it
if(ct_under > 0 && ct_under < PT_NUM)
{
sim->create_part(ID(r), x, y, ct_under);
//If there's a correct tmp set, use it for ctype
if(tmp_under > 0 && ct_under < PT_NUM)
parts[ID(r)].ctype = tmp_under;
}
else
sim->part_change_type(ID(r), x, y, PT_RSST); //Default to RSST if no ctype
sim->kill_part(i);
return 1;
}
break;
default:
break;
}

View File

@ -108,6 +108,29 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].vx = vx;
parts[i].vy = vy;
}
else if(TYP(r) == PT_RSST && !ry && !rx)//if on RSST, make it solid
{
int ct_under, tmp_under;
ct_under = parts[ID(r)].ctype;
tmp_under = parts[ID(r)].tmp;
//If there's a correct ctype set, solidify RSST into it
if(ct_under > 0 && ct_under < PT_NUM)
{
sim->create_part(ID(r), x, y, ct_under);
//If there's a correct tmp set, use it for ctype
if(tmp_under > 0 && ct_under < PT_NUM)
parts[ID(r)].ctype = tmp_under;
}
else
sim->part_change_type(ID(r), x, y, PT_RSSS); //Default to RSSS if no ctype
sim->kill_part(i);
return 1;
}
else if (TYP(r) == PT_FILT && parts[ID(r)].tmp==9)
{
parts[i].vx += ((float)sim->rng.between(-500, 500))/1000.0f;

View File

@ -103,6 +103,13 @@ static int update(UPDATE_FUNC_ARGS)
else change = 0.0f;
parts[uID].temp = restrict_flt(parts[uID].temp + change, MIN_TEMP, MAX_TEMP);
break;
case PT_RSSS: //Destroy RSSS
{
sim->kill_part(uID);
sim->kill_part(i);
return 1;
}
break;
case PT_NONE:
//slowly kill if it's not inside an element
if (parts[i].life)

View File

@ -61,7 +61,8 @@ static int update(UPDATE_FUNC_ARGS)
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL)
auto pavg = sim->parts_avg(i,ID(r),PT_INSL);
if (pavg != PT_INSL && pavg != PT_RSSS)
{
auto rt = TYP(r);
if ((elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0)

View File

@ -236,6 +236,10 @@ static int update(UPDATE_FUNC_ARGS)
case PT_SMKE: // SMKE -> CO2
sim->part_change_type(ID(r), x + rx, y + ry, PT_CO2);
break;
case PT_RSST: // RSST -> BIZR
sim->part_change_type(ID(r), x + rx, y + ry, PT_BIZR);
break;
}
}
}

View File

@ -0,0 +1,56 @@
#include "simulation/ElementCommon.h"
#include "simulation/Air.h"
static int update(UPDATE_FUNC_ARGS);
void Element::Element_RSSS()
{
Identifier = "DEFAULT_PT_RSSS";
Name = "RSSS";
Colour = 0xC43626_rgb;
MenuVisible = 1;
MenuSection = SC_SOLIDS;
Enabled = 1;
Advection = 0.0f;
AirDrag = 0.00f * CFDS;
AirLoss = 0.90f;
Loss = 0.00f;
Collision = 0.0f;
Gravity = 0.0f;
Diffusion = 0.00f;
HotAir = 0.000f * CFDS;
Falldown = 0;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 0;
Weight = 100;
HeatConduct = 130;
Description = "Solidified resist. Blocks pressure and insulates electricity. Liquefies on contact with neutrons.";
Properties = TYPE_SOLID|PROP_NEUTPASS;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &update;
}
static int update(UPDATE_FUNC_ARGS)
{
//Block air like TTAN
sim->air->bmap_blockair[y/CELL][x/CELL] = 1;
sim->air->bmap_blockairh[y/CELL][x/CELL] = 0x8;
return 0;
}

View File

@ -0,0 +1,87 @@
#include "simulation/ElementCommon.h"
int update(UPDATE_FUNC_ARGS);
void Element::Element_RSST()
{
Identifier = "DEFAULT_PT_RSST";
Name = "RSST";
Colour = 0xF95B49_rgb;
MenuVisible = 1;
MenuSection = SC_LIQUID;
Enabled = 1;
Advection = 0.3f;
AirDrag = 0.02f * CFDS;
AirLoss = 0.98f;
Loss = 0.80f;
Collision = 0.0f;
Gravity = 0.15f;
Diffusion = 0.00f;
HotAir = 0.000f * CFDS;
Falldown = 2;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 50;
Weight = 33;
DefaultProperties.temp = R_TEMP + 20.0f + 273.15f;
HeatConduct = 55;
Description = "Resist. Solidifies on contact with photons, is destroyed by electrons and spark.";
Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPASS;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &update;
}
int update(UPDATE_FUNC_ARGS)
{
for(int rx = -1; rx < 2; rx++)
{
for(int ry = -1; ry < 2; ry++)
{
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
// RSST + GUNP = FIRW
if(TYP(r) == PT_GUNP)
{
sim->part_change_type(i, x, y, PT_FIRW);
sim->kill_part(ID(r));
return 1;
}
// RSST + BCOL = FSEP
if(TYP(r) == PT_BCOL)
{
sim->part_change_type(i, x, y, PT_FSEP);
parts[i].life = 50;
sim->kill_part(ID(r));
return 1;
}
// Set RSST ctype from nearby clone
if((TYP(r) == PT_CLNE) || (TYP(r) == PT_PCLN))
{
if(parts[ID(r)].ctype != PT_RSST)
parts[i].ctype = parts[ID(r)].ctype;
}
}
}
return 0;
}

View File

@ -74,6 +74,12 @@ static int update(UPDATE_FUNC_ARGS)
parts[i].life = 54;
else if (ct == PT_SWCH)
parts[i].life = 14;
else if (ct == PT_RSST) //RSST disappears at the end of its spark cycle
{
sim->kill_part(i);
return 1;
}
if (sim->part_change_type(i,x,y,ct))
return 1;
return 0;
@ -92,7 +98,8 @@ static int update(UPDATE_FUNC_ARGS)
if (parts[i].life==1)
{
auto nearp = Element_ETRD_nearestSparkablePart(sim, i);
if (nearp!=-1 && sim->parts_avg(i, nearp, PT_INSL)!=PT_INSL)
auto pavg = sim->parts_avg(i, nearp, PT_INSL);
if (nearp!=-1 && pavg!=PT_INSL && pavg!=PT_RSSS)
{
sim->CreateLine(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), PT_PLSM);
parts[i].life = 20;
@ -200,7 +207,7 @@ static int update(UPDATE_FUNC_ARGS)
switch (receiver)
{
case PT_SWCH:
if (pavg!=PT_INSL && parts[i].life<4)
if (pavg!=PT_INSL && pavg!=PT_RSSS && parts[i].life<4)
{
if(sender==PT_PSCN && parts[ID(r)].life<10) {
parts[ID(r)].life = 10;
@ -213,7 +220,7 @@ static int update(UPDATE_FUNC_ARGS)
}
break;
case PT_SPRK:
if (pavg!=PT_INSL && parts[i].life<4)
if (pavg!=PT_INSL && pavg!=PT_RSSS && parts[i].life<4)
{
if (parts[ID(r)].ctype==PT_SWCH)
{
@ -246,14 +253,14 @@ static int update(UPDATE_FUNC_ARGS)
}
continue;
case PT_PPIP:
if (parts[i].life == 3 && pavg!=PT_INSL)
if (parts[i].life == 3 && pavg!=PT_INSL && pavg!=PT_RSSS)
{
if (sender == PT_NSCN || sender == PT_PSCN || sender == PT_INST)
Element_PPIP_flood_trigger(sim, x+rx, y+ry, sender);
}
continue;
case PT_NTCT: case PT_PTCT: case PT_INWR:
if (sender==PT_METL && pavg!=PT_INSL && parts[i].life<4)
if (sender==PT_METL && pavg!=PT_INSL && pavg!=PT_RSSS && parts[i].life<4)
{
parts[ID(r)].temp = 473.0f;
if (receiver==PT_NTCT||receiver==PT_PTCT)
@ -272,7 +279,7 @@ static int update(UPDATE_FUNC_ARGS)
continue;
}
if (pavg == PT_INSL) continue; //Insulation blocks everything past here
if ((pavg == PT_INSL) || (pavg == PT_RSSS)) continue; //Insulation blocks everything past here
if (!((elements[receiver].Properties&PROP_CONDUCTS)||receiver==PT_INST||receiver==PT_QRTZ)) continue; //Stop non-conducting receivers, allow INST and QRTZ as special cases
if (abs(rx)+abs(ry)>=4 &&sender!=PT_SWCH&&receiver!=PT_SWCH) continue; //Only switch conducts really far
if (receiver==sender && receiver!=PT_INST && receiver!=PT_QRTZ) goto conduct; //Everything conducts to itself, except INST.
@ -358,6 +365,14 @@ static int update(UPDATE_FUNC_ARGS)
sim->FloodINST(x+rx,y+ry);//spark the wire
}
}
else if (receiver==PT_RSST) {
if (parts[ID(r)].life==0 && parts[i].life<4)
{
sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
parts[ID(r)].life = 5;
parts[ID(r)].ctype = receiver;
}
}
else if (parts[ID(r)].life==0 && parts[i].life<4) {
parts[ID(r)].life = 4;
parts[ID(r)].ctype = receiver;

View File

@ -65,7 +65,8 @@ static int update(UPDATE_FUNC_ARGS)
auto r = pmap[y+ry][x+rx];
if (!r)
continue;
if (sim->parts_avg(i,ID(r),PT_INSL)!=PT_INSL)
auto pavg = sim->parts_avg(i,ID(r),PT_INSL);
if (pavg!=PT_INSL && pavg!=PT_RSSS)
{
auto rt = TYP(r);
if (rt==PT_SWCH)

View File

@ -69,7 +69,8 @@ static int update(UPDATE_FUNC_ARGS)
if (!r)
continue;
int rt = TYP(r);
if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL)
auto pavg = sim->parts_avg(i, ID(r), PT_INSL);
if (pavg != PT_INSL && pavg != PT_RSSS)
{
if ((elements[rt].Properties&PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[ID(r)].life == 0)
{

View File

@ -67,7 +67,8 @@ static int update(UPDATE_FUNC_ARGS)
if (!r)
continue;
int rt = TYP(r);
if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL)
auto pavg = sim->parts_avg(i, ID(r), PT_INSL);
if (pavg != PT_INSL && pavg != PT_RSSS)
{
if ((elements[rt].Properties &PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[ID(r)].life == 0)
{

View File

@ -191,6 +191,8 @@ simulation_elem_names = [
'VSNS',
'ROCK',
'LITH',
'RSST',
'RSSS'
]
simulation_elem_src = []