1 #include "simulation/ElementCommon.h"
2 
3 static int update(UPDATE_FUNC_ARGS);
4 
Element_FRZZ()5 void Element::Element_FRZZ()
6 {
7 	Identifier = "DEFAULT_PT_FRZZ";
8 	Name = "FRZZ";
9 	Colour = PIXPACK(0xC0E0FF);
10 	MenuVisible = 1;
11 	MenuSection = SC_POWDERS;
12 	Enabled = 1;
13 
14 	Advection = 0.7f;
15 	AirDrag = 0.01f * CFDS;
16 	AirLoss = 0.96f;
17 	Loss = 0.90f;
18 	Collision = -0.1f;
19 	Gravity = 0.05f;
20 	Diffusion = 0.01f;
21 	HotAir = -0.00005f* CFDS;
22 	Falldown = 1;
23 
24 	Flammable = 0;
25 	Explosive = 0;
26 	Meltable = 0;
27 	Hardness = 20;
28 
29 	Weight = 50;
30 
31 	DefaultProperties.temp = 253.15f;
32 	HeatConduct = 46;
33 	Description = "Freeze powder. When melted, forms ice that always cools. Spreads with regular water.";
34 
35 	Properties = TYPE_PART;
36 
37 	LowPressure = IPL;
38 	LowPressureTransition = NT;
39 	HighPressure = 1.8f;
40 	HighPressureTransition = PT_SNOW;
41 	LowTemperature = 50.0f;
42 	LowTemperatureTransition = PT_ICEI;
43 	HighTemperature = 273.15;
44 	HighTemperatureTransition = PT_FRZW;
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_WATR && RNG::Ref().chance(1, 20))
60 				{
61 					sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
62 					parts[ID(r)].life = 100;
63 					sim->kill_part(i);
64 					return 1;
65 				}
66 			}
67 	return 0;
68 }
69