1 #include "simulation/ElementCommon.h"
2
3 static int update(UPDATE_FUNC_ARGS);
4 static int graphics(GRAPHICS_FUNC_ARGS);
5
Element_DMG()6 void Element::Element_DMG()
7 {
8 Identifier = "DEFAULT_PT_DMG";
9 Name = "DMG";
10 Colour = PIXPACK(0x88FF88);
11 MenuVisible = 1;
12 MenuSection = SC_FORCE;
13 Enabled = 1;
14
15 Advection = 0.0f;
16 AirDrag = 0.01f * CFDS;
17 AirLoss = 0.98f;
18 Loss = 0.95f;
19 Collision = 0.0f;
20 Gravity = 0.1f;
21 Diffusion = 0.00f;
22 HotAir = 0.000f * CFDS;
23 Falldown = 1;
24
25 Flammable = 0;
26 Explosive = 0;
27 Meltable = 0;
28 Hardness = 20;
29
30 Weight = 30;
31
32 DefaultProperties.temp = R_TEMP - 2.0f + 273.15f;
33 HeatConduct = 29;
34 Description = "Generates damaging pressure and breaks any elements it hits.";
35
36 Properties = TYPE_PART|PROP_SPARKSETTLE;
37
38 LowPressure = IPL;
39 LowPressureTransition = NT;
40 HighPressure = IPH;
41 HighPressureTransition = NT;
42 LowTemperature = ITL;
43 LowTemperatureTransition = NT;
44 HighTemperature = ITH;
45 HighTemperatureTransition = NT;
46
47 Update = &update;
48 Graphics = &graphics;
49 }
50
update(UPDATE_FUNC_ARGS)51 static int update(UPDATE_FUNC_ARGS)
52 {
53 int r, rr, rx, ry, nxi, nxj, t, dist;
54 int rad = 25;
55 float angle, fx, fy;
56
57 for (rx=-1; rx<2; rx++)
58 for (ry=-1; ry<2; ry++)
59 if (BOUNDS_CHECK && (rx || ry))
60 {
61 r = pmap[y+ry][x+rx];
62 if (!r)
63 continue;
64 if (TYP(r)!=PT_DMG && TYP(r)!=PT_EMBR && TYP(r)!=PT_DMND && TYP(r)!=PT_CLNE && TYP(r)!=PT_PCLN && TYP(r)!=PT_BCLN)
65 {
66 sim->kill_part(i);
67 for (nxj=-rad; nxj<=rad; nxj++)
68 for (nxi=-rad; nxi<=rad; nxi++)
69 if (x+nxi>=0 && y+nxj>=0 && x+nxi<XRES && y+nxj<YRES && (nxi || nxj))
70 {
71 dist = sqrt(pow(nxi, 2.0f)+pow(nxj, 2.0f));//;(pow((float)nxi,2))/(pow((float)rad,2))+(pow((float)nxj,2))/(pow((float)rad,2));
72 if (!dist || (dist <= rad))
73 {
74 rr = pmap[y+nxj][x+nxi];
75 if (rr)
76 {
77 angle = atan2((float)nxj, nxi);
78 fx = cos(angle) * 7.0f;
79 fy = sin(angle) * 7.0f;
80 parts[ID(rr)].vx += fx;
81 parts[ID(rr)].vy += fy;
82 sim->vx[(y+nxj)/CELL][(x+nxi)/CELL] += fx;
83 sim->vy[(y+nxj)/CELL][(x+nxi)/CELL] += fy;
84 sim->pv[(y+nxj)/CELL][(x+nxi)/CELL] += 1.0f;
85 t = TYP(rr);
86 if (t && sim->elements[t].HighPressureTransition>-1 && sim->elements[t].HighPressureTransition<PT_NUM)
87 sim->part_change_type(ID(rr), x+nxi, y+nxj, sim->elements[t].HighPressureTransition);
88 else if (t == PT_BMTL)
89 sim->part_change_type(ID(rr), x+nxi, y+nxj, PT_BRMT);
90 else if (t == PT_GLAS)
91 sim->part_change_type(ID(rr), x+nxi, y+nxj, PT_BGLA);
92 else if (t == PT_COAL)
93 sim->part_change_type(ID(rr), x+nxi, y+nxj, PT_BCOL);
94 else if (t == PT_QRTZ)
95 sim->part_change_type(ID(rr), x+nxi, y+nxj, PT_PQRT);
96 else if (t == PT_TUNG)
97 {
98 sim->part_change_type(ID(rr), x+nxi, y+nxj, PT_BRMT);
99 parts[ID(rr)].ctype = PT_TUNG;
100 }
101 else if (t == PT_WOOD)
102 sim->part_change_type(ID(rr), x+nxi, y+nxj, PT_SAWD);
103 }
104 }
105 }
106 return 1;
107 }
108 }
109 return 0;
110 }
111
graphics(GRAPHICS_FUNC_ARGS)112 static int graphics(GRAPHICS_FUNC_ARGS)
113 {
114 *pixel_mode |= PMODE_FLARE;
115 return 1;
116 }
117