1 #include "simulation/ElementCommon.h"
2 
3 static int update(UPDATE_FUNC_ARGS);
4 
Element_WATR()5 void Element::Element_WATR()
6 {
7 	Identifier = "DEFAULT_PT_WATR";
8 	Name = "WATR";
9 	Colour = PIXPACK(0x2030D0);
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 = 29;
33 	Description = "Water. Conducts electricity, freezes, and extinguishes fires.";
34 
35 	Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|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 				if (!r)
58 					continue;
59 				if (TYP(r)==PT_SALT && RNG::Ref().chance(1, 50))
60 				{
61 					sim->part_change_type(i,x,y,PT_SLTW);
62 					// on average, convert 3 WATR to SLTW before SALT turns into SLTW
63 					if (RNG::Ref().chance(1, 3))
64 						sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);
65 				}
66 				else if ((TYP(r)==PT_RBDM||TYP(r)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && RNG::Ref().chance(1, 100))
67 				{
68 					sim->part_change_type(i,x,y,PT_FIRE);
69 					parts[i].life = 4;
70 					parts[i].ctype = PT_WATR;
71 				}
72 				else if (TYP(r)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR)
73 				{
74 					sim->kill_part(ID(r));
75 					if (RNG::Ref().chance(1, 30))
76 					{
77 						sim->kill_part(i);
78 						return 1;
79 					}
80 				}
81 				else if (TYP(r)==PT_SLTW && RNG::Ref().chance(1, 2000))
82 				{
83 					sim->part_change_type(i,x,y,PT_SLTW);
84 				}
85 			}
86 	return 0;
87 }
88