/
NEUT.cpp
221 lines (204 loc) · 5.27 KB
/
NEUT.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#include "simulation/Elements.h"
//#TPT-Directive ElementClass Element_NEUT PT_NEUT 18
Element_NEUT::Element_NEUT()
{
Identifier = "DEFAULT_PT_NEUT";
Name = "NEUT";
Colour = PIXPACK(0x20E0FF);
MenuVisible = 1;
MenuSection = SC_NUCLEAR;
Enabled = 1;
Advection = 0.0f;
AirDrag = 0.00f * CFDS;
AirLoss = 1.00f;
Loss = 1.00f;
Collision = -0.99f;
Gravity = 0.0f;
Diffusion = 0.01f;
HotAir = 0.002f * CFDS;
Falldown = 0;
Flammable = 0;
Explosive = 0;
Meltable = 0;
Hardness = 0;
Weight = -1;
Temperature = R_TEMP+4.0f +273.15f;
HeatConduct = 60;
Description = "Neutrons. Interact with matter in odd ways.";
Properties = TYPE_ENERGY|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC;
LowPressure = IPL;
LowPressureTransition = NT;
HighPressure = IPH;
HighPressureTransition = NT;
LowTemperature = ITL;
LowTemperatureTransition = NT;
HighTemperature = ITH;
HighTemperatureTransition = NT;
Update = &Element_NEUT::update;
Graphics = &Element_NEUT::graphics;
}
//#TPT-Directive ElementHeader Element_NEUT static int update(UPDATE_FUNC_ARGS)
int Element_NEUT::update(UPDATE_FUNC_ARGS)
{
int r, rx, ry;
int pressureFactor = 3 + (int)sim->pv[y/CELL][x/CELL];
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (BOUNDS_CHECK)
{
r = pmap[y+ry][x+rx];
switch (r&0xFF)
{
case PT_WATR:
if (3>(rand()%20))
sim->part_change_type(r>>8,x+rx,y+ry,PT_DSTW);
case PT_ICEI:
case PT_SNOW:
parts[i].vx *= 0.995;
parts[i].vy *= 0.995;
break;
case PT_PLUT:
if (pressureFactor>(rand()%1000))
{
if (!(rand()%3))
{
sim->create_part(r>>8, x+rx, y+ry, rand()%3 ? PT_LAVA : PT_URAN);
parts[r>>8].temp = MAX_TEMP;
if (parts[r>>8].type==PT_LAVA) {
parts[r>>8].tmp = 100;
parts[r>>8].ctype = PT_PLUT;
}
}
else
{
sim->create_part(r>>8, x+rx, y+ry, PT_NEUT);
parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
}
sim->pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough
Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS);
}
break;
#ifdef SDEUT
case PT_DEUT:
if ((pressureFactor+1+(parts[r>>8].life/100))>(rand()%1000))
{
DeutExplosion(sim, parts[r>>8].life, x+rx, y+ry, restrict_flt(parts[r>>8].temp + parts[r>>8].life*500.0f, MIN_TEMP, MAX_TEMP), PT_NEUT);
sim->kill_part(r>>8);
}
break;
#else
case PT_DEUT:
if ((pressureFactor+1)>(rand()%1000))
{
create_part(r>>8, x+rx, y+ry, PT_NEUT);
parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
parts[r>>8].life --;
parts[r>>8].temp = restrict_flt(parts[r>>8].temp + parts[r>>8].life*17.0f, MIN_TEMP, MAX_TEMP);
pv[y/CELL][x/CELL] += 6.0f * CFDS;
}
break;
#endif
case PT_GUNP:
if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_DUST);
break;
case PT_DYST:
if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_YEST);
break;
case PT_YEST:
sim->part_change_type(r>>8,x+rx,y+ry,PT_DYST);
break;
case PT_PLEX:
if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_GOO);
break;
case PT_NITR:
if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_DESL);
break;
case PT_PLNT:
if (!(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_WOOD);
break;
case PT_DESL:
case PT_OIL:
if (3>(rand()%200))
sim->part_change_type(r>>8,x+rx,y+ry,PT_GAS);
break;
case PT_COAL:
if (!(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_WOOD);
break;
case PT_BCOL:
if (!(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_SAWD);
break;
case PT_DUST:
if (!(rand()%20))
sim->part_change_type(r>>8, x+rx, y+ry, PT_FWRK);
break;
case PT_FWRK:
if (!(rand()%20))
parts[r>>8].ctype = PT_DUST;
break;
case PT_ACID:
if (!(rand()%20))
sim->create_part(r>>8, x+rx, y+ry, PT_ISOZ);
break;
case PT_TTAN:
if (!(rand()%20))
{
sim->kill_part(i);
return 1;
}
break;
case PT_EXOT:
if (!(rand()%20))
parts[r>>8].life = 1500;
break;
case PT_RFRG:
if (rand()%2)
sim->create_part(r>>8, x+rx, y+ry, PT_GAS);
else
sim->create_part(r>>8, x+rx, y+ry, PT_CAUS);
break;
default:
break;
}
}
return 0;
}
//#TPT-Directive ElementHeader Element_NEUT static int graphics(GRAPHICS_FUNC_ARGS)
int Element_NEUT::graphics(GRAPHICS_FUNC_ARGS)
{
*firea = 120;
*firer = 10;
*fireg = 80;
*fireb = 120;
*pixel_mode |= FIRE_ADD;
return 1;
}
//#TPT-Directive ElementHeader Element_NEUT static int DeutExplosion(Simulation * sim, int n, int x, int y, float temp, int t)
int Element_NEUT::DeutExplosion(Simulation * sim, int n, int x, int y, float temp, int t)//testing a new deut create part
{
int i;
n = (n/50);
if (n < 1)
n = 1;
else if (n > 340)
n = 340;
for (int c = 0; c < n; c++)
{
i = sim->create_part(-3, x, y, t);
if (i >= 0)
sim->parts[i].temp = temp;
else if (sim->pfree < 0)
break;
}
sim->pv[y/CELL][x/CELL] += (6.0f * CFDS)*n;
return 0;
}
Element_NEUT::~Element_NEUT() {}