diff --git a/src/simulation/elements/ANAR.cpp b/src/simulation/elements/ANAR.cpp index 7ed584c0e..53c46b9f9 100644 --- a/src/simulation/elements/ANAR.cpp +++ b/src/simulation/elements/ANAR.cpp @@ -25,7 +25,7 @@ void Element::Element_ANAR() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 30; + Hardness = 29; Weight = 85; diff --git a/src/simulation/elements/BASE.cpp b/src/simulation/elements/BASE.cpp new file mode 100644 index 000000000..98d72cc5a --- /dev/null +++ b/src/simulation/elements/BASE.cpp @@ -0,0 +1,244 @@ +#include "simulation/ElementCommon.h" + +static int update(UPDATE_FUNC_ARGS); +static int graphics(GRAPHICS_FUNC_ARGS); + +void Element::Element_BASE() +{ + Identifier = "DEFAULT_PT_BASE"; + Name = "BASE"; + Colour = 0x90D5FF_rgb; + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.5f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.97f; + Loss = 0.96f; + Collision = 0.0f; + Gravity = 0.08f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 16; + + HeatConduct = 31; + Description = "Corrosive liquid. Rusts conductive solids, neutralizes acid."; + + Properties = TYPE_LIQUID|PROP_DEADLY; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + DefaultProperties.life = 76; + + Update = &update; + Graphics = &graphics; +} + +static int update(UPDATE_FUNC_ARGS) +{ + auto &sd = SimulationData::CRef(); + auto &elements = sd.elements; + + //Reset spark effect + parts[i].tmp = 0; + + if (parts[i].life < 1) + parts[i].life = 1; + + if (parts[i].life > 100) + parts[i].life = 100; + + float pres = sim->pv[y/CELL][x/CELL]; + + //Base evaporates into BOYL or increases concentration + if (parts[i].life < 100 && pres < 10.0f && parts[i].temp > (120.0f + 273.15f)) + { + //Slow down boiling + if (sim->rng.chance(1, 20)) + { + //This way we preserve the total amount of concentrated BASE in the solution + if (sim->rng.chance(1, parts[i].life+1)) + { + auto temp = parts[i].temp; + sim->create_part(i, x, y, PT_BOYL); + parts[i].temp = temp; + return 1; + } + else + { + parts[i].life++; + //Enthalpy of vaporization + parts[i].temp -= 20.0f / ((float)parts[i].life); + } + } + } + + //Base's freezing point lowers with its concentration + if (parts[i].temp < (273.15f - ((float)parts[i].life)/4.0f)) + { + //We don't save base's concentration, so ICEI(BASE) will unfreeze into life = 0 + sim->part_change_type(i, x, y, PT_ICEI); + parts[i].ctype = PT_BASE; + parts[i].life = 0; + return 1; + } + + //Reactions + for (auto rx = -1; rx <= 1; rx++) + { + for (auto ry = -1; ry <= 1; ry++) + { + if (rx || ry) + { + auto r = pmap[y+ry][x+rx]; + if (!r) + continue; + int rt = TYP(r); + + //Don't react with some elements + if (rt != PT_BASE && rt != PT_SALT && rt != PT_SLTW && rt != PT_BOYL && rt != PT_MERC && + rt != PT_BMTL && rt != PT_BRMT && rt != PT_SOAP && rt != PT_CLNE && rt != PT_PCLN && + !(rt == PT_ICEI && parts[ID(r)].ctype == PT_BASE) && !(rt == PT_SNOW && parts[ID(r)].ctype == PT_BASE) && + !(rt == PT_SPRK && parts[ID(r)].ctype == PT_BMTL) && !(rt == PT_SPRK && parts[ID(r)].ctype == PT_BRMT)) + { + //Base is diluted by water + if (parts[i].life > 1 && (rt == PT_WATR || rt == PT_DSTW || rt == PT_CBNW)) + { + if (sim->rng.chance(1, 20)) + { + int saturh = parts[i].life/2; + + sim->part_change_type(ID(r), x+rx, y+ry, PT_BASE); + parts[ID(r)].life = saturh; + parts[ID(r)].temp += ((float)saturh)/10.0f; + parts[i].life -= saturh; + } + } //Base neutralizes acid + else if (rt == PT_ACID && parts[i].life >= parts[ID(r)].life) + { + sim->part_change_type(i, x, y, PT_SLTW); + sim->part_change_type(ID(r), x+rx, y+ry, PT_SLTW); + return 1; + } //BASE + OIL = SOAP + else if (parts[i].life >= 70 && rt == PT_OIL) + { + sim->part_change_type(i, x, y, PT_SOAP); + parts[i].tmp = parts[i].tmp2 = parts[i].ctype = 0; + sim->kill_part(ID(r)); + return 1; + } //BASE + GOO = GEL + else if (parts[i].life > 1 && rt == PT_GOO) + { + sim->create_part(ID(r), x+rx, y+ry, PT_GEL); + parts[i].life--; + } //BASE + BCOL = GUNP + else if (parts[i].life > 1 && rt == PT_BCOL) + { + sim->create_part(ID(r), x+rx, y+ry, PT_GUNP); + parts[i].life--; + } //BASE + Molten ROCK = MERC + else if (rt == PT_LAVA && parts[ID(r)].ctype == PT_ROCK && pres >= 10.0f && sim->rng.chance(1, 1000)) + { + sim->part_change_type(i, x, y, PT_MERC); + parts[i].life = 0; + parts[i].tmp = 10; + + sim->kill_part(ID(r)); + return 1; + } //Base rusts conductive solids + else if (parts[i].life >= 10 && + (elements[rt].Properties & (TYPE_SOLID|PROP_CONDUCTS)) == (TYPE_SOLID|PROP_CONDUCTS) && sim->rng.chance(1, 10)) + { + sim->part_change_type(ID(r), x+rx, y+ry, PT_BMTL); + parts[ID(r)].tmp = sim->rng.between(20, 29); + parts[i].life--; + //Draw a spark effect + parts[i].tmp = 1; + } //Base destroys a substance slower if acid destroys it faster + else if (elements[rt].Hardness > 0 && elements[rt].Hardness < 50 && + parts[i].life >= (2*elements[rt].Hardness) && sim->rng.chance(50-elements[rt].Hardness, 1000)) + { + sim->kill_part(ID(r)); + parts[i].life -= 2; + //Draw a spark + parts[i].tmp = 1; + } + } + } + } + } + + //Diffusion + for (auto trade = 0; trade<2; trade++) + { + auto rx = sim->rng.between(-1, 1); + auto ry = sim->rng.between(-1, 1); + if (rx || ry) + { + auto r = pmap[y+ry][x+rx]; + if (!r) + continue; + if (TYP(r) == PT_BASE && (parts[i].life > parts[ID(r)].life) && parts[i].life>1) + { + int temp = parts[i].life - parts[ID(r)].life; + if (temp == 1) + { + parts[ID(r)].life++; + parts[i].life--; + } + else if (temp>0) + { + parts[ID(r)].life += temp/2; + parts[i].life -= temp/2; + } + } + } + } + return 0; +} + +static int graphics(GRAPHICS_FUNC_ARGS) +{ + int s = cpart->life; + + if (s <= 25) + { + *colr = 0x33; + *colg = 0x4C; + *colb = 0xD8; + } + else if (s <= 50) + { + *colr = 0x58; + *colg = 0x83; + *colb = 0xE8; + } + else if (s <= 75) + { + *colr = 0x7D; + *colg = 0xBA; + *colb = 0xF7; + } + + *pixel_mode |= PMODE_BLUR; + + if (cpart->tmp == 1) + *pixel_mode |= PMODE_SPARK; + + return 0; +} diff --git a/src/simulation/elements/COAL.cpp b/src/simulation/elements/COAL.cpp index ba35673ea..cd34b6bca 100644 --- a/src/simulation/elements/COAL.cpp +++ b/src/simulation/elements/COAL.cpp @@ -23,7 +23,7 @@ void Element::Element_COAL() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 18; PhotonReflectWavelengths = 0x00000000; Weight = 100; diff --git a/src/simulation/elements/DEUT.cpp b/src/simulation/elements/DEUT.cpp index ad3cc36c7..6be72d5a4 100644 --- a/src/simulation/elements/DEUT.cpp +++ b/src/simulation/elements/DEUT.cpp @@ -26,7 +26,7 @@ void Element::Element_DEUT() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 19; Weight = 31; diff --git a/src/simulation/elements/DSTW.cpp b/src/simulation/elements/DSTW.cpp index 7d04bc3df..d0ca09c3e 100644 --- a/src/simulation/elements/DSTW.cpp +++ b/src/simulation/elements/DSTW.cpp @@ -95,6 +95,18 @@ static int update(UPDATE_FUNC_ARGS) return 1; } break; + case PT_SMKE: //DSTW + SMKE = BASE + if (parts[ID(r)].temp > (40 + 273.15f) && parts[ID(r)].temp < (60 + 273.15f) && + parts[i].temp > (40 + 273.15f) && parts[i].temp < (60 + 273.15f)) + { + if (sim->rng.chance(1, 100)) + { + sim->part_change_type(i,x,y,PT_BASE); + parts[i].life = 1; + sim->kill_part(ID(r)); + } + } + break; default: continue; } diff --git a/src/simulation/elements/EMBR.cpp b/src/simulation/elements/EMBR.cpp index a193b0245..4cff652a7 100644 --- a/src/simulation/elements/EMBR.cpp +++ b/src/simulation/elements/EMBR.cpp @@ -25,7 +25,7 @@ void Element::Element_EMBR() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 21; Weight = 30; diff --git a/src/simulation/elements/FIRW.cpp b/src/simulation/elements/FIRW.cpp index c09f67c7f..b15d5c83c 100644 --- a/src/simulation/elements/FIRW.cpp +++ b/src/simulation/elements/FIRW.cpp @@ -25,7 +25,7 @@ void Element::Element_FIRW() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 30; + Hardness = 28; Weight = 55; diff --git a/src/simulation/elements/FSEP.cpp b/src/simulation/elements/FSEP.cpp index 79798713b..4062476d5 100644 --- a/src/simulation/elements/FSEP.cpp +++ b/src/simulation/elements/FSEP.cpp @@ -24,7 +24,7 @@ void Element::Element_FSEP() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 30; + Hardness = 27; Weight = 70; diff --git a/src/simulation/elements/FUSE.cpp b/src/simulation/elements/FUSE.cpp index 2f95ca9e3..4421084db 100644 --- a/src/simulation/elements/FUSE.cpp +++ b/src/simulation/elements/FUSE.cpp @@ -24,7 +24,7 @@ void Element::Element_FUSE() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 19; Weight = 100; diff --git a/src/simulation/elements/GEL.cpp b/src/simulation/elements/GEL.cpp index e4a7f26f9..26b6c005e 100644 --- a/src/simulation/elements/GEL.cpp +++ b/src/simulation/elements/GEL.cpp @@ -25,7 +25,7 @@ void Element::Element_GEL() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 19; Weight = 35; diff --git a/src/simulation/elements/IRON.cpp b/src/simulation/elements/IRON.cpp index 3d01e022f..fe3b911ea 100644 --- a/src/simulation/elements/IRON.cpp +++ b/src/simulation/elements/IRON.cpp @@ -24,7 +24,7 @@ void Element::Element_IRON() Flammable = 0; Explosive = 0; Meltable = 1; - Hardness = 50; + Hardness = 49; Weight = 100; diff --git a/src/simulation/elements/LITH.cpp b/src/simulation/elements/LITH.cpp index 3b433fe19..e95602d44 100644 --- a/src/simulation/elements/LITH.cpp +++ b/src/simulation/elements/LITH.cpp @@ -25,7 +25,7 @@ void Element::Element_LITH() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 15; + Hardness = 14; Weight = 17; diff --git a/src/simulation/elements/MERC.cpp b/src/simulation/elements/MERC.cpp index 756bca1cf..e383a448c 100644 --- a/src/simulation/elements/MERC.cpp +++ b/src/simulation/elements/MERC.cpp @@ -24,7 +24,7 @@ void Element::Element_MERC() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 18; Weight = 91; diff --git a/src/simulation/elements/NEUT.cpp b/src/simulation/elements/NEUT.cpp index 1e317961c..d6c08a429 100644 --- a/src/simulation/elements/NEUT.cpp +++ b/src/simulation/elements/NEUT.cpp @@ -191,6 +191,10 @@ static int update(UPDATE_FUNC_ARGS) return 1; } break; + case PT_BASE: + if (parts[ID(r)].temp > (50 + 273.15) && sim->rng.chance(1, 35)) + sim->create_part(ID(r), x+rx, y+ry, PT_LRBD); + break; default: break; } diff --git a/src/simulation/elements/PSTE.cpp b/src/simulation/elements/PSTE.cpp index 11d01268a..2b148b26b 100644 --- a/src/simulation/elements/PSTE.cpp +++ b/src/simulation/elements/PSTE.cpp @@ -22,7 +22,7 @@ void Element::Element_PSTE() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 18; Weight = 31; diff --git a/src/simulation/elements/PSTS.cpp b/src/simulation/elements/PSTS.cpp index 2eee65875..d3584a152 100644 --- a/src/simulation/elements/PSTS.cpp +++ b/src/simulation/elements/PSTS.cpp @@ -22,7 +22,7 @@ void Element::Element_PSTS() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 18; Weight = 100; diff --git a/src/simulation/elements/PUMP.cpp b/src/simulation/elements/PUMP.cpp index a885970af..750b2c9b5 100644 --- a/src/simulation/elements/PUMP.cpp +++ b/src/simulation/elements/PUMP.cpp @@ -25,7 +25,7 @@ void Element::Element_PUMP() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 10; + Hardness = 9; Weight = 100; diff --git a/src/simulation/elements/RFGL.cpp b/src/simulation/elements/RFGL.cpp index 16536c204..0cca181d0 100644 --- a/src/simulation/elements/RFGL.cpp +++ b/src/simulation/elements/RFGL.cpp @@ -23,7 +23,7 @@ void Element::Element_RFGL() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 21; Weight = 10; diff --git a/src/simulation/elements/RFRG.cpp b/src/simulation/elements/RFRG.cpp index 50936fbff..e477c3946 100644 --- a/src/simulation/elements/RFRG.cpp +++ b/src/simulation/elements/RFRG.cpp @@ -23,7 +23,7 @@ void Element::Element_RFRG() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 21; Weight = 1; diff --git a/src/simulation/elements/RIME.cpp b/src/simulation/elements/RIME.cpp index 71f50e488..186f0ba41 100644 --- a/src/simulation/elements/RIME.cpp +++ b/src/simulation/elements/RIME.cpp @@ -24,7 +24,7 @@ void Element::Element_RIME() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 30; + Hardness = 32; Weight = 100; diff --git a/src/simulation/elements/SAWD.cpp b/src/simulation/elements/SAWD.cpp index 3e0bd05ff..cebdddcf3 100644 --- a/src/simulation/elements/SAWD.cpp +++ b/src/simulation/elements/SAWD.cpp @@ -22,7 +22,7 @@ void Element::Element_SAWD() Flammable = 10; Explosive = 0; Meltable = 0; - Hardness = 30; + Hardness = 29; Weight = 18; diff --git a/src/simulation/elements/SOAP.cpp b/src/simulation/elements/SOAP.cpp index 5726e8845..2e038ab06 100644 --- a/src/simulation/elements/SOAP.cpp +++ b/src/simulation/elements/SOAP.cpp @@ -27,7 +27,7 @@ void Element::Element_SOAP() Flammable = 0; Explosive = 0; Meltable = 0; - Hardness = 20; + Hardness = 19; Weight = 35; diff --git a/src/simulation/elements/SPNG.cpp b/src/simulation/elements/SPNG.cpp index 6523dc60d..a7cee3515 100644 --- a/src/simulation/elements/SPNG.cpp +++ b/src/simulation/elements/SPNG.cpp @@ -25,7 +25,7 @@ void Element::Element_SPNG() Flammable = 20; Explosive = 0; Meltable = 0; - Hardness = 30; + Hardness = 31; Weight = 100; diff --git a/src/simulation/elements/TTAN.cpp b/src/simulation/elements/TTAN.cpp index e1892d6ca..7efd104cf 100644 --- a/src/simulation/elements/TTAN.cpp +++ b/src/simulation/elements/TTAN.cpp @@ -25,7 +25,7 @@ void Element::Element_TTAN() Flammable = 0; Explosive = 0; Meltable = 1; - Hardness = 50; + Hardness = 48; Weight = 100; diff --git a/src/simulation/elements/VIRS.cpp b/src/simulation/elements/VIRS.cpp index 3940b77bd..4f2674140 100644 --- a/src/simulation/elements/VIRS.cpp +++ b/src/simulation/elements/VIRS.cpp @@ -114,7 +114,7 @@ int Element_VIRS_update(UPDATE_FUNC_ARGS) } } //transforms things into virus here - else if (TYP(r) != PT_VIRS && TYP(r) != PT_VRSS && TYP(r) != PT_VRSG && TYP(r) != PT_DMND) + else if (TYP(r) != PT_VIRS && TYP(r) != PT_VRSS && TYP(r) != PT_VRSG && TYP(r) != PT_DMND && TYP(r) != PT_BASE) { if (!(rndstore & 0x7)) { diff --git a/src/simulation/elements/WOOD.cpp b/src/simulation/elements/WOOD.cpp index e0b92da73..22facc48b 100644 --- a/src/simulation/elements/WOOD.cpp +++ b/src/simulation/elements/WOOD.cpp @@ -26,7 +26,7 @@ void Element::Element_WOOD() Flammable = 20; Explosive = 0; Meltable = 0; - Hardness = 15; + Hardness = 16; Weight = 100; diff --git a/src/simulation/elements/YEST.cpp b/src/simulation/elements/YEST.cpp index 662fd3e82..c16ae4268 100644 --- a/src/simulation/elements/YEST.cpp +++ b/src/simulation/elements/YEST.cpp @@ -24,7 +24,7 @@ void Element::Element_YEST() Flammable = 15; Explosive = 0; Meltable = 0; - Hardness = 30; + Hardness = 31; Weight = 80; diff --git a/src/simulation/elements/meson.build b/src/simulation/elements/meson.build index 4f1dc9c64..ac6459d58 100644 --- a/src/simulation/elements/meson.build +++ b/src/simulation/elements/meson.build @@ -192,7 +192,8 @@ simulation_elem_names = [ 'ROCK', 'LITH', 'RSST', - 'RSSS' + 'RSSS', + 'BASE', ] simulation_elem_src = []