1 #include "simulation/ElementCommon.h"
2 
3 static int update(UPDATE_FUNC_ARGS);
4 
Element_SHLD3()5 void Element::Element_SHLD3()
6 {
7 	Identifier = "DEFAULT_PT_SHLD3";
8 	Name = "SHD3";
9 	Colour = PIXPACK(0x444444);
10 	MenuVisible = 0;
11 	MenuSection = SC_CRACKER2;
12 	Enabled = 1;
13 
14 	Advection = 0.0f;
15 	AirDrag = 0.00f * CFDS;
16 	AirLoss = 1.00f;
17 	Loss = 0.00f;
18 	Collision = 0.0f;
19 	Gravity = 0.0f;
20 	Diffusion = 0.00f;
21 	HotAir = 0.000f	* CFDS;
22 	Falldown = 0;
23 
24 	Flammable = 0;
25 	Explosive = 0;
26 	Meltable = 0;
27 	Hardness = 1;
28 
29 	Weight = 100;
30 
31 	HeatConduct = 0;
32 	Description = "Shield lvl 3.";
33 
34 	Properties = TYPE_SOLID|PROP_LIFE_DEC;
35 
36 	LowPressure = IPL;
37 	LowPressureTransition = NT;
38 	HighPressure = 25.0f;
39 	HighPressureTransition = PT_NONE;
40 	LowTemperature = ITL;
41 	LowTemperatureTransition = NT;
42 	HighTemperature = ITH;
43 	HighTemperatureTransition = NT;
44 
45 	Update = &update;
46 }
47 
update(UPDATE_FUNC_ARGS)48 static int update(UPDATE_FUNC_ARGS)
49 {
50 	int r, nnx, nny, rx, ry, np;
51 	for (rx=-1; rx<2; rx++)
52 		for (ry=-1; ry<2; ry++)
53 			if (BOUNDS_CHECK && (rx || ry))
54 			{
55 				r = pmap[y+ry][x+rx];
56 				if (!r)
57 				{
58 					if (RNG::Ref().chance(1, 2500))
59 					{
60 						np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
61 						if (np<0) continue;
62 						parts[np].life=7;
63 						sim->part_change_type(i,x,y,PT_SHLD2);
64 					}
65 					continue;
66 				}
67 				if (TYP(r)==PT_SHLD1 && parts[i].life>3)
68 				{
69 					sim->part_change_type(ID(r),x+rx,y+ry,PT_SHLD2);
70 					parts[ID(r)].life=7;
71 				}
72 				else if (TYP(r)==PT_SPRK&&parts[i].life==0)
73 				{
74 					if (RNG::Ref().chance(3, 500))
75 					{
76 						sim->part_change_type(i,x,y,PT_SHLD4);
77 						parts[i].life = 7;
78 					}
79 					for ( nnx=-1; nnx<2; nnx++)
80 						for ( nny=-1; nny<2; nny++)
81 						{
82 
83 							if (!pmap[y+ry+nny][x+rx+nnx])
84 							{
85 								np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1);
86 								if (np<0) continue;
87 								parts[np].life=7;
88 							}
89 						}
90 				}
91 			}
92 	return 0;
93 }
94