Added BOOM and INDE

This commit is contained in:
Jakav-N 2022-11-28 16:15:35 -07:00
parent a6d73dec48
commit 3ea3f2f348
7 changed files with 268 additions and 6 deletions

View File

@ -2312,6 +2312,8 @@ bool Simulation::IsWallBlocking(int x, int y, int type)
int wall = bmap[y/CELL][x/CELL];
if (wall == WL_ALLOWGAS && !(elements[type].Properties&TYPE_GAS))
return true;
else if (type == PT_BOOM)
return false;
else if (wall == WL_ALLOWENERGY && !(elements[type].Properties&TYPE_ENERGY))
return true;
else if (wall == WL_ALLOWLIQUID && !(elements[type].Properties&TYPE_LIQUID))
@ -2424,7 +2426,7 @@ void Simulation::init_can_move()
|| destinationType == PT_ISOZ || destinationType == PT_ISZS || destinationType == PT_QRTZ || destinationType == PT_PQRT
|| destinationType == PT_H2 || destinationType == PT_BGLA || destinationType == PT_C5)
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)
if (destinationType != PT_INDE2 && destinationType != PT_INDE && destinationType != PT_DMND && destinationType != PT_INSL && destinationType != PT_VOID && destinationType != PT_PVOD && destinationType != PT_VIBR && destinationType != PT_BVBR && destinationType != PT_PRTI && destinationType != PT_PRTO)
{
can_move[PT_PROT][destinationType] = 2;
can_move[PT_GRVT][destinationType] = 2;
@ -2438,6 +2440,11 @@ void Simulation::init_can_move()
can_move[PT_DEST][PT_BCLN] = 0;
can_move[PT_DEST][PT_PBCN] = 0;
can_move[PT_DEST][PT_ROCK] = 0;
can_move[PT_DEST][PT_INDE2] = 0;
can_move[PT_DEST][PT_INDE] = 0;
can_move[PT_BOOM][PT_INDE] = 0;
can_move[PT_BOOM][PT_INDE2] = 0;
can_move[PT_NEUT][PT_INVIS] = 2;
can_move[PT_ELEC][PT_LCRY] = 2;
@ -3489,6 +3496,9 @@ void Simulation::UpdateParticles(int start, int end)
kill_part(i);
continue;
}
// Kill every wall which BOOM is in:
if (t == PT_BOOM) { bmap[y/CELL][x/CELL] = 0; }
// Kill a particle in a wall where it isn't supposed to go
if (bmap[y/CELL][x/CELL] &&
@ -3560,9 +3570,9 @@ void Simulation::UpdateParticles(int start, int end)
parts[i].vx *= elements[t].Loss;
parts[i].vy *= elements[t].Loss;
}
//particle gets velocity from the vx and vy maps
parts[i].vx += elements[t].Advection*vx[y/CELL][x/CELL] + pGravX;
parts[i].vy += elements[t].Advection*vy[y/CELL][x/CELL] + pGravY;
//particle gets velocity from the vx and vy maps, and BOOM isn't affected by gravity
parts[i].vx += elements[t].Advection*vx[y/CELL][x/CELL] + ((t != PT_BOOM) ? pGravX : 0);
parts[i].vy += elements[t].Advection*vy[y/CELL][x/CELL] + ((t != PT_BOOM) ? pGravY : 0);
if (elements[t].Diffusion)//the random diffusion that gasses have

View File

@ -0,0 +1,126 @@
#include "simulation/ElementCommon.h"
#include "simulation/Simulation.h"
static int update(UPDATE_FUNC_ARGS);
static int graphics(GRAPHICS_FUNC_ARGS);
void Element::Element_BOOM()
{
Identifier = "DEFAULT_PT_BOOM";
Name = "BOOM";
Colour = PIXPACK(0xFF3311);
MenuVisible = 1;
MenuSection = SC_EXPLOSIVE;
Enabled = 1;
Advection = -0.05f;
AirDrag = 0.00f * CFDS;
AirLoss = 0.95f;
Loss = 0.95f;
Collision = -0.1f;
//I think this controls how much it is affected by gravity. If so, making it zero should do the trick.
Gravity = 0.0f;
Diffusion = 0.00f;
HotAir = 0.000f * CFDS;
Falldown = 1;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 0;
Weight = 101;
HeatConduct = 150;
Description = "More destructive Bomb, can break through virtually anything.";
Properties = TYPE_ENERGY;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &update;
Graphics = &graphics;
}
static int update(UPDATE_FUNC_ARGS)
{
int r, rx, ry, rt, nb, proton;
int c = 0;
sim->pv[y/CELL][x/CELL]-=256.0f;
for (rx=-1; rx<=1; rx++) {
for (ry=-1; ry<=1; ry++) {
if (BOUNDS_CHECK && (rx || ry)) {
int r = pmap[y+ry][x+rx];
rt = TYP(r);
if (!r || rt == PT_INDE2)
continue;
if (rt == PT_VOID) {
int rx2, ry2;
for (rx2=-1; rx2<=1; rx2++) {
for (ry2=-1; ry2<=1; ry2++) {
sim->create_part(-1, x+rx2, y+ry2, PT_BOOM);
}
}
}
while (r && TYP(r) != PT_BOOM && c < 20) {
sim->kill_part(ID(r));
r = pmap[y + ry][x + rx];
c++;
}
rx = RNG::Ref().between(-3, 3);
ry = RNG::Ref().between(-3, 3);
sim->create_part(-1, x+rx, y+ry, PT_BOOM);
sim->pv[y/CELL][x/CELL]+=10000.0f;
parts[i].temp = 1000000.0f;
}
}
}
/*if (RNG::Ref().chance(1, 20)) {
rx = RNG::Ref().between(-3, 3);
ry = RNG::Ref().between(-3, 3);
sim->create_part(-1, x+rx, y+ry, PT_PLSM);
}*/
if (RNG::Ref().chance(1, 10)) {
rx = RNG::Ref().between(-3, 3);
ry = RNG::Ref().between(-3, 3);
proton = sim->create_part(-1, x+rx, y+ry, PT_PROT);
if (proton > -1)
sim->parts[proton].temp = MAX_TEMP;
}
return 0;
}
static int graphics(GRAPHICS_FUNC_ARGS)
{
*pixel_mode |= PMODE_FLARE;
return 1;
}

View File

@ -83,9 +83,18 @@ static int update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx];
if (!r || (restrictElement && ((TYP(r) == restrictElement) == (parts[i].tmp2 == 1))))
r = pmap[y+ry][x+rx];
if (TYP(r) == PT_BOOM) {
if (RNG::Ref().chance(1, 2)) {
sim->kill_part(i);
return 1;
} else {
parts[i].ctype = PT_BOOM;
}
}
if (!r || (restrictElement && ((TYP(r) == restrictElement) == (parts[i].tmp2 == 1))))
continue;
if (TYP(r) != PT_CONV && TYP(r) != PT_DMND && TYP(r) != ctype)
if (TYP(r) != PT_CONV && TYP(r) != PT_DMND && TYP(r) != PT_INDE2 && TYP(r) != ctype)
{
sim->create_part(ID(r), x+rx, y+ry, TYP(parts[i].ctype), ID(parts[i].ctype));
}

View File

@ -0,0 +1,72 @@
#include "simulation/ElementCommon.h"
static int update(UPDATE_FUNC_ARGS);
static void create(ELEMENT_CREATE_FUNC_ARGS);
void Element::Element_INDE()
{
Identifier = "DEFAULT_PT_INDE";
Name = "INDE";
Colour = PIXPACK(0xCCFFFF);
MenuVisible = 1;
MenuSection = SC_SPECIAL;
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 = 0;
Description = "Basically indestructible. It also insulates.";
Properties = TYPE_SOLID;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &update;
Create = &create;
}
static int update(UPDATE_FUNC_ARGS)
{
int r = pmap[y][x];
if (TYP(r) == PT_INDE2 && r != i) {
return 0;
}
if (TYP(r) != PT_INDE) {
sim->kill_part(ID(r));
}
if ((!pmap[y][x]) || TYP(r) == PT_INDE) {
sim->create_part(-3, x, y, PT_INDE2);
}
return 0;
}
static void create(ELEMENT_CREATE_FUNC_ARGS)
{
sim->create_part(-3, x, y, PT_INDE2);
}

View File

@ -0,0 +1,42 @@
#include "simulation/ElementCommon.h"
void Element::Element_INDE2()
{
Identifier = "DEFAULT_PT_INDE2";
Name = "IND2";
Colour = PIXPACK(0xCCFFFF);
MenuVisible = 1;
MenuSection = SC_CRACKER2;
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 = 0;
Description = "Indestructible. It also insulates.";
Properties = TYPE_SOLID;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
}

View File

@ -259,7 +259,7 @@ static int update(UPDATE_FUNC_ARGS)
continue;
}
if (pavg == PT_INSL) continue; //Insulation blocks everything past here
if (pavg == PT_INSL || pavg == PT_INDE || pavg == PT_INDE2) continue; //Insulation blocks everything past here
if (!((sim->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.

View File

@ -191,6 +191,9 @@ simulation_elem_ids = [
[ 'VSNS', 189 ],
[ 'ROCK', 190 ],
[ 'LITH', 191 ],
[ 'BOOM', 192 ],
[ 'INDE', 193 ],
[ 'INDE2', 194 ],
]
simulation_elem_src = []