1 #include "simulation/ElementCommon.h"
2 #include "simulation/Air.h"
3 
4 static int update(UPDATE_FUNC_ARGS);
5 static int graphics(GRAPHICS_FUNC_ARGS);
6 
Element_GOLD()7 void Element::Element_GOLD()
8 {
9 	Identifier = "DEFAULT_PT_GOLD";
10 	Name = "GOLD";
11 	Colour = PIXPACK(0xDCAD2C);
12 	MenuVisible = 1;
13 	MenuSection = SC_SOLIDS;
14 	Enabled = 1;
15 
16 	Advection = 0.0f;
17 	AirDrag = 0.00f * CFDS;
18 	AirLoss = 0.90f;
19 	Loss = 0.00f;
20 	Collision = 0.0f;
21 	Gravity = 0.0f;
22 	Diffusion = 0.00f;
23 	HotAir = 0.000f	* CFDS;
24 	Falldown = 0;
25 
26 	Flammable = 0;
27 	Explosive = 0;
28 	Meltable = 1;
29 	Hardness = 0;
30 	PhotonReflectWavelengths = 0x3C038100;
31 
32 	Weight = 100;
33 
34 	HeatConduct = 251;
35 	Description = "Corrosion resistant metal, will reverse corrosion of iron.";
36 
37 	Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW|PROP_LIFE_DEC|PROP_NEUTPASS;
38 
39 	LowPressure = IPL;
40 	LowPressureTransition = NT;
41 	HighPressure = IPH;
42 	HighPressureTransition = NT;
43 	LowTemperature = ITL;
44 	LowTemperatureTransition = NT;
45 	HighTemperature = 1337.0f;
46 	HighTemperatureTransition = PT_LAVA;
47 
48 	Update = &update;
49 	Graphics = &graphics;
50 }
51 
update(UPDATE_FUNC_ARGS)52 static int update(UPDATE_FUNC_ARGS)
53 {
54 	int rx, ry, r, rndstore;
55 	static int checkCoordsX[] = { -4, 4, 0, 0 };
56 	static int checkCoordsY[] = { 0, 0, -4, 4 };
57 	//Find nearby rusted iron (BMTL with tmp 1+)
58 	for(int j = 0; j < 8; j++){
59 		rndstore = RNG::Ref().gen();
60 		rx = (rndstore % 9)-4;
61 		rndstore >>= 4;
62 		ry = (rndstore % 9)-4;
63 		if ((!rx != !ry) && BOUNDS_CHECK) {
64 			r = pmap[y+ry][x+rx];
65 			if(!r) continue;
66 			if(TYP(r)==PT_BMTL && parts[ID(r)].tmp)
67 			{
68 				parts[ID(r)].tmp = 0;
69 				sim->part_change_type(ID(r), x+rx, y+ry, PT_IRON);
70 			}
71 		}
72 	}
73 	//Find sparks
74 	if(!parts[i].life)
75 	{
76 		for(int j = 0; j < 4; j++){
77 			rx = checkCoordsX[j];
78 			ry = checkCoordsY[j];
79 			if (BOUNDS_CHECK) {
80 				r = pmap[y+ry][x+rx];
81 				if(!r) continue;
82 				if(TYP(r)==PT_SPRK && parts[ID(r)].life && parts[ID(r)].life<4)
83 				{
84 					sim->part_change_type(i, x, y, PT_SPRK);
85 					parts[i].life = 4;
86 					parts[i].ctype = PT_GOLD;
87 				}
88 			}
89 		}
90 	}
91 	if (TYP(sim->photons[y][x]) == PT_NEUT)
92 	{
93 		if (RNG::Ref().chance(1, 7))
94 		{
95 			sim->kill_part(ID(sim->photons[y][x]));
96 		}
97 	}
98 	return 0;
99 }
100 
graphics(GRAPHICS_FUNC_ARGS)101 static int graphics(GRAPHICS_FUNC_ARGS)
102 {
103 	int rndstore = RNG::Ref().gen();
104 	*colr += (rndstore % 10) - 5;
105 	rndstore >>= 4;
106 	*colg += (rndstore % 10)- 5;
107 	rndstore >>= 4;
108 	*colb += (rndstore % 10) - 5;
109 	return 0;
110 }
111