1 #include "simulation/ElementCommon.h"
2 
3 static int update(UPDATE_FUNC_ARGS);
4 
Element_CAUS()5 void Element::Element_CAUS()
6 {
7 	Identifier = "DEFAULT_PT_CAUS";
8 	Name = "CAUS";
9 	Colour = PIXPACK(0x80FFA0);
10 	MenuVisible = 1;
11 	MenuSection = SC_GAS;
12 	Enabled = 1;
13 
14 	Advection = 2.0f;
15 	AirDrag = 0.00f * CFDS;
16 	AirLoss = 0.99f;
17 	Loss = 0.30f;
18 	Collision = -0.1f;
19 	Gravity = 0.0f;
20 	Diffusion = 1.50f;
21 	HotAir = 0.000f	* CFDS;
22 	Falldown = 0;
23 
24 	Flammable = 0;
25 	Explosive = 0;
26 	Meltable = 0;
27 	Hardness = 0;
28 
29 	Weight = 1;
30 
31 	HeatConduct = 70;
32 	Description = "Caustic Gas, acts like ACID.";
33 
34 	Properties = TYPE_GAS|PROP_DEADLY;
35 
36 	LowPressure = IPL;
37 	LowPressureTransition = NT;
38 	HighPressure = IPH;
39 	HighPressureTransition = NT;
40 	LowTemperature = ITL;
41 	LowTemperatureTransition = NT;
42 	HighTemperature = ITH;
43 	HighTemperatureTransition = NT;
44 
45 	DefaultProperties.life = 75;
46 
47 	Update = &update;
48 }
49 
update(UPDATE_FUNC_ARGS)50 static int update(UPDATE_FUNC_ARGS)
51 {
52 	for (int rx = -2; rx <= 2; rx++)
53 		for (int ry = -2; ry <= 2; ry++)
54 			if (BOUNDS_CHECK && (rx || ry))
55 			{
56 				int r = pmap[y+ry][x+rx];
57 				if (!r)
58 					continue;
59 				if (TYP(r) == PT_GAS)
60 				{
61 					if (sim->pv[(y+ry)/CELL][(x+rx)/CELL] > 3)
62 					{
63 						sim->part_change_type(ID(r), x+rx, y+ry, PT_RFRG);
64 						sim->part_change_type(i, x, y, PT_RFRG);
65 					}
66 				}
67 				else if (TYP(r) != PT_ACID && TYP(r) != PT_CAUS && TYP(r) != PT_RFRG && TYP(r) != PT_RFGL)
68 				{
69 					if ((TYP(r) != PT_CLNE && TYP(r) != PT_PCLN && RNG::Ref().chance(sim->elements[TYP(r)].Hardness, 1000)) && parts[i].life >= 50)
70 					{
71 						// GLAS protects stuff from acid
72 						if (sim->parts_avg(i, ID(r),PT_GLAS) != PT_GLAS)
73 						{
74 							float newtemp = ((60.0f - (float)sim->elements[TYP(r)].Hardness)) * 7.0f;
75 							if (newtemp < 0)
76 								newtemp = 0;
77 							parts[i].temp += newtemp;
78 							parts[i].life--;
79 							sim->kill_part(ID(r));
80 						}
81 					}
82 					else if (parts[i].life <= 50)
83 					{
84 						sim->kill_part(i);
85 						return 1;
86 					}
87 				}
88 			}
89 	return 0;
90 }
91