1 #include "simulation/ElementCommon.h"
2 
3 static int update(UPDATE_FUNC_ARGS);
4 
Element_DSTW()5 void Element::Element_DSTW()
6 {
7 	Identifier = "DEFAULT_PT_DSTW";
8 	Name = "DSTW";
9 	Colour = PIXPACK(0x1020C0);
10 	MenuVisible = 1;
11 	MenuSection = SC_LIQUID;
12 	Enabled = 1;
13 
14 	Advection = 0.6f;
15 	AirDrag = 0.01f * CFDS;
16 	AirLoss = 0.98f;
17 	Loss = 0.95f;
18 	Collision = 0.0f;
19 	Gravity = 0.1f;
20 	Diffusion = 0.00f;
21 	HotAir = 0.000f	* CFDS;
22 	Falldown = 2;
23 
24 	Flammable = 0;
25 	Explosive = 0;
26 	Meltable = 0;
27 	Hardness = 20;
28 
29 	Weight = 30;
30 
31 	DefaultProperties.temp = R_TEMP - 2.0f + 273.15f;
32 	HeatConduct = 23;
33 	Description = "Distilled water, does not conduct electricity.";
34 
35 	Properties = TYPE_LIQUID|PROP_NEUTPASS;
36 
37 	LowPressure = IPL;
38 	LowPressureTransition = NT;
39 	HighPressure = IPH;
40 	HighPressureTransition = NT;
41 	LowTemperature = 273.15f;
42 	LowTemperatureTransition = PT_ICEI;
43 	HighTemperature = 373.0f;
44 	HighTemperatureTransition = PT_WTRV;
45 
46 	Update = &update;
47 }
48 
update(UPDATE_FUNC_ARGS)49 static int update(UPDATE_FUNC_ARGS)
50 {
51 	int r, rx, ry;
52 	for (rx=-1; rx<2; rx++)
53 		for (ry=-1; ry<2; ry++)
54 			if (BOUNDS_CHECK && (rx || ry))
55 			{
56 				r = pmap[y+ry][x+rx];
57 				switch (TYP(r))
58 				{
59 				case PT_SALT:
60 					if (RNG::Ref().chance(1, 50))
61 					{
62 						sim->part_change_type(i,x,y,PT_SLTW);
63 						// on average, convert 3 DSTW to SLTW before SALT turns into SLTW
64 						if (RNG::Ref().chance(1, 3))
65 							sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
66 					}
67 					break;
68 				case PT_SLTW:
69 					if (RNG::Ref().chance(1, 2000))
70 					{
71 						sim->part_change_type(i,x,y,PT_SLTW);
72 						break;
73 					}
74 				case PT_WATR:
75 					if (RNG::Ref().chance(1, 100))
76 					{
77 						sim->part_change_type(i,x,y,PT_WATR);
78 					}
79 					break;
80 				case PT_RBDM:
81 				case PT_LRBD:
82 					if ((sim->legacy_enable||parts[i].temp>12.0f) && RNG::Ref().chance(1, 100))
83 					{
84 						sim->part_change_type(i,x,y,PT_FIRE);
85 						parts[i].life = 4;
86 					}
87 					break;
88 				case PT_FIRE:
89 					sim->kill_part(ID(r));
90 					if (RNG::Ref().chance(1, 30))
91 					{
92 						sim->kill_part(i);
93 						return 1;
94 					}
95 					break;
96 				default:
97 					continue;
98 				}
99 			}
100 	return 0;
101 }
102