Skip to content

Commit 4aa0abe

Browse files
committed
Merge remote-tracking branch 'origin/alkali' into playtest-june2025
2 parents bf7f401 + b80c7c2 commit 4aa0abe

28 files changed

Lines changed: 284 additions & 25 deletions

src/simulation/elements/ANAR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void Element::Element_ANAR()
2525
Flammable = 0;
2626
Explosive = 0;
2727
Meltable = 0;
28-
Hardness = 30;
28+
Hardness = 29;
2929

3030
Weight = 85;
3131

src/simulation/elements/BASE.cpp

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
#include "simulation/ElementCommon.h"
2+
3+
static int update(UPDATE_FUNC_ARGS);
4+
static int graphics(GRAPHICS_FUNC_ARGS);
5+
6+
void Element::Element_BASE()
7+
{
8+
Identifier = "DEFAULT_PT_BASE";
9+
Name = "BASE";
10+
Colour = 0x90D5FF_rgb;
11+
MenuVisible = 1;
12+
MenuSection = SC_LIQUID;
13+
Enabled = 1;
14+
15+
Advection = 0.5f;
16+
AirDrag = 0.01f * CFDS;
17+
AirLoss = 0.97f;
18+
Loss = 0.96f;
19+
Collision = 0.0f;
20+
Gravity = 0.08f;
21+
Diffusion = 0.00f;
22+
HotAir = 0.000f * CFDS;
23+
Falldown = 2;
24+
25+
Flammable = 0;
26+
Explosive = 0;
27+
Meltable = 0;
28+
Hardness = 0;
29+
30+
Weight = 16;
31+
32+
HeatConduct = 31;
33+
Description = "Corrosive liquid. Rusts conductive solids, neutralizes acid.";
34+
35+
Properties = TYPE_LIQUID|PROP_DEADLY;
36+
37+
LowPressure = IPL;
38+
LowPressureTransition = NT;
39+
HighPressure = IPH;
40+
HighPressureTransition = NT;
41+
LowTemperature = ITL;
42+
LowTemperatureTransition = NT;
43+
HighTemperature = ITH;
44+
HighTemperatureTransition = NT;
45+
46+
DefaultProperties.life = 75;
47+
48+
Update = &update;
49+
Graphics = &graphics;
50+
}
51+
52+
static int update(UPDATE_FUNC_ARGS)
53+
{
54+
auto &sd = SimulationData::CRef();
55+
auto &elements = sd.elements;
56+
57+
//Reset spark effect
58+
parts[i].tmp = 0;
59+
60+
if (parts[i].life < 1)
61+
parts[i].life = 1;
62+
63+
if (parts[i].life > 100)
64+
parts[i].life = 100;
65+
66+
float pres = sim->pv[y/CELL][x/CELL];
67+
68+
//Base evaporates into BOYL or increases concentration
69+
if (parts[i].life < 100 && pres < 10.0f && parts[i].temp > (120.0f + 273.15f))
70+
{
71+
//Slow down boiling
72+
if (sim->rng.chance(1, 20))
73+
{
74+
//This way we preserve the total amount of concentrated BASE in the solution
75+
if (sim->rng.chance(1, parts[i].life+1))
76+
{
77+
auto temp = parts[i].temp;
78+
sim->create_part(i, x, y, PT_BOYL);
79+
parts[i].temp = temp;
80+
return 1;
81+
}
82+
else
83+
{
84+
parts[i].life++;
85+
//Enthalpy of vaporization
86+
parts[i].temp -= 20.0f / ((float)parts[i].life);
87+
}
88+
}
89+
}
90+
91+
//Base's freezing point lowers with its concentration
92+
if (parts[i].temp < (273.15f - ((float)parts[i].life)/4.0f))
93+
{
94+
//We don't save base's concentration, so ICEI(BASE) will unfreeze into life = 0
95+
sim->part_change_type(i, x, y, PT_ICEI);
96+
parts[i].ctype = PT_BASE;
97+
parts[i].life = 0;
98+
return 1;
99+
}
100+
101+
//Reactions
102+
for (auto rx = -1; rx <= 1; rx++)
103+
{
104+
for (auto ry = -1; ry <= 1; ry++)
105+
{
106+
if (rx || ry)
107+
{
108+
auto r = pmap[y+ry][x+rx];
109+
if (!r)
110+
continue;
111+
int rt = TYP(r);
112+
113+
if (rt != PT_BASE && rt != PT_SALT && rt != PT_SLTW && rt != PT_BOYL && rt != PT_MERC &&
114+
rt != PT_BMTL && rt != PT_BRMT && rt != PT_SOAP && rt != PT_CLNE && rt != PT_PCLN &&
115+
!(rt == PT_ICEI && parts[ID(r)].ctype == PT_BASE) && !(rt == PT_SNOW && parts[ID(r)].ctype == PT_BASE))
116+
{
117+
//Base is diluted by water
118+
if (parts[i].life > 1 && (rt == PT_WATR || rt == PT_DSTW || rt == PT_CBNW))
119+
{
120+
if (sim->rng.chance(1, 20))
121+
{
122+
int saturh = parts[i].life/2;
123+
124+
sim->part_change_type(ID(r), x+rx, y+ry, PT_BASE);
125+
parts[ID(r)].life = saturh;
126+
parts[ID(r)].temp += ((float)saturh)/10.0f;
127+
parts[i].life -= saturh;
128+
}
129+
} //Base neutralizes acid
130+
else if (rt == PT_ACID && parts[i].life >= parts[ID(r)].life)
131+
{
132+
sim->part_change_type(i, x, y, PT_SLTW);
133+
sim->part_change_type(ID(r), x+rx, y+ry, PT_SLTW);
134+
return 1;
135+
} //BASE + OIL = SOAP
136+
else if (parts[i].life >= 70 && rt == PT_OIL)
137+
{
138+
sim->part_change_type(i, x, y, PT_SOAP);
139+
parts[i].tmp = parts[i].tmp2 = parts[i].ctype = 0;
140+
sim->kill_part(ID(r));
141+
return 1;
142+
} //BASE + GOO = GEL
143+
else if (parts[i].life > 1 && rt == PT_GOO)
144+
{
145+
sim->create_part(ID(r), x+rx, y+ry, PT_GEL);
146+
parts[i].life--;
147+
} //BASE + BCOL = GUNP
148+
else if (parts[i].life > 1 && rt == PT_BCOL)
149+
{
150+
sim->create_part(ID(r), x+rx, y+ry, PT_GUNP);
151+
parts[i].life--;
152+
} //BASE + Molten ROCK = MERC
153+
else if (rt == PT_LAVA && parts[ID(r)].ctype == PT_ROCK && pres >= 10.0f && sim->rng.chance(1, 1000))
154+
{
155+
sim->part_change_type(i, x, y, PT_MERC);
156+
parts[i].life = 0;
157+
parts[i].tmp = 10;
158+
159+
sim->kill_part(ID(r));
160+
return 1;
161+
} //Base rusts conductive solids
162+
else if (parts[i].life >= 10 &&
163+
(elements[rt].Properties & (TYPE_SOLID|PROP_CONDUCTS)) == (TYPE_SOLID|PROP_CONDUCTS) && sim->rng.chance(1, 10))
164+
{
165+
sim->part_change_type(ID(r), x+rx, y+ry, PT_BMTL);
166+
parts[ID(r)].tmp = sim->rng.between(20, 29);
167+
parts[i].life--;
168+
//Draw a spark effect
169+
parts[i].tmp = 1;
170+
} //Base destroys a substance slower if acid destroys it faster
171+
else if (elements[rt].Hardness > 0 && elements[rt].Hardness < 50 &&
172+
parts[i].life >= (2*elements[rt].Hardness) && sim->rng.chance(50-elements[rt].Hardness, 1000))
173+
{
174+
sim->kill_part(ID(r));
175+
parts[i].life -= 2;
176+
//Draw a spark
177+
parts[i].tmp = 1;
178+
}
179+
}
180+
}
181+
}
182+
}
183+
184+
//Diffusion
185+
for (auto trade = 0; trade<2; trade++)
186+
{
187+
auto rx = sim->rng.between(-1, 1);
188+
auto ry = sim->rng.between(-1, 1);
189+
if (rx || ry)
190+
{
191+
auto r = pmap[y+ry][x+rx];
192+
if (!r)
193+
continue;
194+
if (TYP(r) == PT_BASE && (parts[i].life > parts[ID(r)].life) && parts[i].life>1)
195+
{
196+
int temp = parts[i].life - parts[ID(r)].life;
197+
if (temp == 1)
198+
{
199+
parts[ID(r)].life++;
200+
parts[i].life--;
201+
}
202+
else if (temp>0)
203+
{
204+
parts[ID(r)].life += temp/2;
205+
parts[i].life -= temp/2;
206+
}
207+
}
208+
}
209+
}
210+
return 0;
211+
}
212+
213+
static int graphics(GRAPHICS_FUNC_ARGS)
214+
{
215+
int s = cpart->life;
216+
217+
if (s < 25)
218+
{
219+
*colr = 0x33;
220+
*colg = 0x4C;
221+
*colb = 0xD8;
222+
}
223+
else if (s < 50)
224+
{
225+
*colr = 0x58;
226+
*colg = 0x83;
227+
*colb = 0xE8;
228+
}
229+
else if (s < 75)
230+
{
231+
*colr = 0x7D;
232+
*colg = 0xBA;
233+
*colb = 0xF7;
234+
}
235+
236+
*pixel_mode |= PMODE_BLUR;
237+
238+
if (cpart->tmp == 1)
239+
*pixel_mode |= PMODE_SPARK;
240+
241+
return 0;
242+
}

src/simulation/elements/COAL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void Element::Element_COAL()
2323
Flammable = 0;
2424
Explosive = 0;
2525
Meltable = 0;
26-
Hardness = 20;
26+
Hardness = 18;
2727
PhotonReflectWavelengths = 0x00000000;
2828

2929
Weight = 100;

src/simulation/elements/DEUT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void Element::Element_DEUT()
2626
Flammable = 0;
2727
Explosive = 0;
2828
Meltable = 0;
29-
Hardness = 20;
29+
Hardness = 19;
3030

3131
Weight = 31;
3232

src/simulation/elements/DSTW.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ static int update(UPDATE_FUNC_ARGS)
9595
return 1;
9696
}
9797
break;
98+
case PT_SMKE: //DSTW + SMKE = BASE
99+
if (parts[ID(r)].temp > (40 + 273.15f) && parts[ID(r)].temp < (60 + 273.15f) &&
100+
parts[i].temp > (40 + 273.15f) && parts[i].temp < (60 + 273.15f))
101+
{
102+
if (sim->rng.chance(1, 100))
103+
{
104+
sim->part_change_type(i,x,y,PT_BASE);
105+
parts[i].life = 1;
106+
sim->kill_part(ID(r));
107+
}
108+
}
109+
break;
98110
default:
99111
continue;
100112
}

src/simulation/elements/EMBR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void Element::Element_EMBR()
2525
Flammable = 0;
2626
Explosive = 0;
2727
Meltable = 0;
28-
Hardness = 20;
28+
Hardness = 21;
2929

3030
Weight = 30;
3131

src/simulation/elements/FIRW.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void Element::Element_FIRW()
2525
Flammable = 0;
2626
Explosive = 0;
2727
Meltable = 0;
28-
Hardness = 30;
28+
Hardness = 28;
2929

3030
Weight = 55;
3131

src/simulation/elements/FSEP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void Element::Element_FSEP()
2424
Flammable = 0;
2525
Explosive = 0;
2626
Meltable = 0;
27-
Hardness = 30;
27+
Hardness = 27;
2828

2929
Weight = 70;
3030

src/simulation/elements/FUSE.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void Element::Element_FUSE()
2424
Flammable = 0;
2525
Explosive = 0;
2626
Meltable = 0;
27-
Hardness = 20;
27+
Hardness = 19;
2828

2929
Weight = 100;
3030

src/simulation/elements/GEL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void Element::Element_GEL()
2525
Flammable = 0;
2626
Explosive = 0;
2727
Meltable = 0;
28-
Hardness = 20;
28+
Hardness = 19;
2929

3030
Weight = 35;
3131

0 commit comments

Comments
 (0)