author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 26 Nov 2018 17:59:27 +0100 | |
changeset 14320 | 5cff42e1dd92 |
parent 13568 | 470982c05f7e |
child 14593 | 34e810295d08 |
permissions | -rw-r--r-- |
9287 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
11046 | 3 |
* Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com> |
9287 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
10015
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
9287 | 17 |
*) |
18 |
||
19 |
{$INCLUDE "options.inc"} |
|
20 |
||
21 |
unit uVisualGearsList; |
|
22 |
interface |
|
23 |
uses uTypes; |
|
24 |
||
25 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline; |
|
26 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord): PVisualGear; inline; |
|
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
27 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear; inline; |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
28 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean; Layer: LongInt): PVisualGear; |
9287 | 29 |
procedure DeleteVisualGear(Gear: PVisualGear); |
30 |
function VisualGearByUID(uid : Longword) : PVisualGear; |
|
31 |
||
10015 | 32 |
const |
9287 | 33 |
cExplFrameTicks = 110; |
34 |
||
35 |
var VGCounter: LongWord; |
|
36 |
VisualGearLayers: array[0..6] of PVisualGear; |
|
37 |
||
38 |
implementation |
|
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11857
diff
changeset
|
39 |
uses uCollisions, uFloat, uVariables, uConsts, uTextures, uVisualGearsHandlers, uScript; |
9287 | 40 |
|
41 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline; |
|
42 |
begin |
|
10352 | 43 |
// adjust some visual gear types if underwater |
10354 | 44 |
if CheckCoordInWater(X, Y) and ((Kind = vgtBeeTrace) or (Kind = vgtSmokeTrace) or (Kind = vgtEvilTrace)) then |
10352 | 45 |
Kind:= vgtBubble; |
46 |
||
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
47 |
AddVisualGear:= AddVisualGear(X, Y, Kind, 0, false, -1); |
9287 | 48 |
end; |
49 |
||
50 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord): PVisualGear; inline; |
|
51 |
begin |
|
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
52 |
AddVisualGear:= AddVisualGear(X, Y, Kind, State, false, -1); |
9287 | 53 |
end; |
54 |
||
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
55 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean): PVisualGear; inline; |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
56 |
begin |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
57 |
AddVisualGear:= AddVisualGear(X, Y, Kind, State, Critical, -1); |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
58 |
end; |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
59 |
|
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
60 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean; Layer: LongInt): PVisualGear; |
9287 | 61 |
var gear: PVisualGear; |
62 |
t: Longword; |
|
63 |
sp: real; |
|
64 |
begin |
|
65 |
AddVisualGear:= nil; |
|
13040
a87d3119c962
VideoRec: Fix many effects not being recorded
Wuzzy <Wuzzy2@mail.ru>
parents:
12110
diff
changeset
|
66 |
if (GameType <> gmtRecord) and |
a87d3119c962
VideoRec: Fix many effects not being recorded
Wuzzy <Wuzzy2@mail.ru>
parents:
12110
diff
changeset
|
67 |
(((GameType = gmtSave) or (fastUntilLag and (GameType = gmtNet)) or fastScrolling) and // we are scrolling now |
13329
e8801220c13f
minor simplification of conditions for not spawning a visual gear - also allows lua to spawn clouds critically or non-critically. We probably shouldn't even exempt clouds from this, and just spawn them once synced, but, eh, probably isn't a significant hit since sheepluva made the motion more efficient.
nemo
parents:
13040
diff
changeset
|
68 |
(not Critical)) then |
9287 | 69 |
exit; |
70 |
||
71 |
if ((cReducedQuality and rqAntiBoom) <> 0) and |
|
72 |
(not Critical) and |
|
73 |
(not (Kind in |
|
74 |
[vgtTeamHealthSorter, |
|
75 |
vgtSmallDamageTag, |
|
76 |
vgtSpeechBubble, |
|
77 |
vgtHealthTag, |
|
78 |
vgtExplosion, |
|
79 |
vgtSmokeTrace, |
|
80 |
vgtEvilTrace, |
|
81 |
vgtNote, |
|
10876 | 82 |
vgtFeather, |
9287 | 83 |
vgtSmoothWindBar])) then |
10015 | 84 |
|
9287 | 85 |
exit; |
86 |
||
87 |
inc(VGCounter); |
|
88 |
New(gear); |
|
89 |
FillChar(gear^, sizeof(TVisualGear), 0); |
|
90 |
gear^.X:= real(X); |
|
91 |
gear^.Y:= real(Y); |
|
92 |
gear^.Kind := Kind; |
|
9960 | 93 |
gear^.doStep:= doStepVGHandlers[Kind]; |
9287 | 94 |
gear^.Tint:= $FFFFFFFF; |
95 |
gear^.uid:= VGCounter; |
|
96 |
||
97 |
with gear^ do |
|
98 |
case Kind of |
|
99 |
vgtFlake: |
|
100 |
begin |
|
101 |
Timer:= 0; |
|
102 |
tdX:= 0; |
|
103 |
tdY:= 0; |
|
104 |
Scale:= 1.0; |
|
105 |
if SuddenDeathDmg then |
|
106 |
begin |
|
10625
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10354
diff
changeset
|
107 |
if vobSDFrameTicks > 0 then |
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10354
diff
changeset
|
108 |
FrameTicks:= random(vobSDFrameTicks); |
9287 | 109 |
Frame:= random(vobSDFramesCount); |
110 |
end |
|
111 |
else |
|
112 |
begin |
|
10625
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10354
diff
changeset
|
113 |
if vobFrameTicks > 0 then |
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10354
diff
changeset
|
114 |
FrameTicks:= random(vobFrameTicks); |
9287 | 115 |
Frame:= random(vobFramesCount); |
116 |
end; |
|
117 |
Angle:= random(360); |
|
118 |
dx:= 0.0000038654705 * random(10000); |
|
119 |
dy:= 0.000003506096 * random(7000); |
|
120 |
if random(2) = 0 then |
|
121 |
dx := -dx; |
|
122 |
if SuddenDeathDmg then |
|
123 |
dAngle:= (random(2) * 2 - 1) * (vobSDVelocity + random(vobSDVelocity)) / 1000 |
|
124 |
else |
|
125 |
dAngle:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) / 1000 |
|
126 |
end; |
|
127 |
vgtCloud: |
|
128 |
begin |
|
129 |
Frame:= random(4); |
|
130 |
dx:= 0.5 + 0.1 * random(5); // how much the cloud will be affected by wind |
|
131 |
timer:= random(4096); |
|
132 |
Scale:= 1.0 |
|
133 |
end; |
|
134 |
vgtExplPart, |
|
135 |
vgtExplPart2: |
|
136 |
begin |
|
137 |
t:= random(1024); |
|
138 |
sp:= 0.001 * (random(95) + 70); |
|
139 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
140 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
141 |
if random(2) = 0 then |
|
142 |
dx := -dx; |
|
143 |
if random(2) = 0 then |
|
144 |
dy := -dy; |
|
145 |
Frame:= 7 - random(3); |
|
146 |
FrameTicks:= cExplFrameTicks |
|
147 |
end; |
|
148 |
vgtFire: |
|
149 |
begin |
|
150 |
t:= random(1024); |
|
151 |
sp:= 0.001 * (random(85) + 95); |
|
152 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
153 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
154 |
if random(2) = 0 then |
|
155 |
dx := -dx; |
|
156 |
if random(2) = 0 then |
|
157 |
dy := -dy; |
|
158 |
FrameTicks:= 650 + random(250); |
|
159 |
Frame:= random(8) |
|
160 |
end; |
|
161 |
vgtEgg: |
|
162 |
begin |
|
163 |
t:= random(1024); |
|
164 |
sp:= 0.001 * (random(85) + 95); |
|
165 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
166 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
167 |
if random(2) = 0 then |
|
168 |
dx := -dx; |
|
169 |
if random(2) = 0 then |
|
170 |
dy := -dy; |
|
171 |
FrameTicks:= 650 + random(250); |
|
172 |
Frame:= 1 |
|
173 |
end; |
|
174 |
vgtShell: FrameTicks:= 500; |
|
175 |
vgtSmallDamageTag: |
|
176 |
begin |
|
177 |
gear^.FrameTicks:= 1100 |
|
178 |
end; |
|
179 |
vgtBubble: |
|
180 |
begin |
|
181 |
dx:= 0.0000038654705 * random(10000); |
|
182 |
dy:= 0; |
|
183 |
if random(2) = 0 then |
|
184 |
dx := -dx; |
|
185 |
FrameTicks:= 250 + random(1751); |
|
186 |
Frame:= random(5) |
|
187 |
end; |
|
188 |
vgtSteam: |
|
189 |
begin |
|
190 |
dx:= 0.0000038654705 * random(10000); |
|
191 |
dy:= 0.001 * (random(85) + 95); |
|
192 |
if random(2) = 0 then |
|
193 |
dx := -dx; |
|
194 |
Frame:= 7 - random(3); |
|
195 |
FrameTicks:= cExplFrameTicks * 2; |
|
196 |
end; |
|
197 |
vgtAmmo: |
|
198 |
begin |
|
199 |
alpha:= 1.0; |
|
200 |
scale:= 1.0 |
|
201 |
end; |
|
202 |
vgtSmokeWhite, |
|
203 |
vgtSmoke: |
|
204 |
begin |
|
205 |
Scale:= 1.0; |
|
206 |
dx:= 0.0002 * (random(45) + 10); |
|
207 |
dy:= 0.0002 * (random(45) + 10); |
|
208 |
if random(2) = 0 then |
|
209 |
dx := -dx; |
|
210 |
Frame:= 7 - random(2); |
|
211 |
FrameTicks:= cExplFrameTicks * 2; |
|
212 |
end; |
|
213 |
vgtDust: |
|
214 |
begin |
|
215 |
dx:= 0.005 * (random(15) + 10); |
|
216 |
dy:= 0.001 * (random(40) + 20); |
|
217 |
if random(2) = 0 then dx := -dx; |
|
218 |
if random(2) = 0 then Tag:= 1 |
|
219 |
else Tag:= -1; |
|
220 |
Frame:= 7 - random(2); |
|
221 |
FrameTicks:= random(20) + 15; |
|
222 |
end; |
|
223 |
vgtSplash: |
|
224 |
begin |
|
225 |
dx:= 0; |
|
226 |
dy:= 0; |
|
227 |
FrameTicks:= 740; |
|
228 |
Frame:= 19; |
|
229 |
Scale:= 0.75; |
|
230 |
Timer:= 1; |
|
231 |
end; |
|
232 |
vgtDroplet: |
|
233 |
begin |
|
11857
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
234 |
// old dx & dy calcs |
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
235 |
// dx:= 0.001 * (random(180) - 90); |
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
236 |
// dy:= -0.001 * (random(160) + 40); |
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
237 |
// => min speed ~ 0.098, max speed ~ 0.218, speed range ~ 0.120 |
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
238 |
// => min angle(4096) ~ 129, max angle ~ 1919, angle range ~ 1790 |
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
239 |
dx:= 0.001 * (98 + random(121)); // speed |
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
240 |
Frame:= 129 + random(1791); // angle |
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
241 |
dy:= -dx * hwFloat2Float(AngleSin(Frame)); |
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
242 |
// divide by 2 to create an eliptic shape |
cb137eb71556
pimp up random droplet movement vector init to create half-elliptic rather than square patterns - makes using piano less painful to the eyes
sheepluva
parents:
11046
diff
changeset
|
243 |
dx:= dx * hwFloat2Float(AngleCos(Frame)) / 2; |
9287 | 244 |
FrameTicks:= 250 + random(1751); |
245 |
Frame:= random(3) |
|
246 |
end; |
|
247 |
vgtBeeTrace: |
|
248 |
begin |
|
249 |
FrameTicks:= 1000; |
|
250 |
Frame:= random(16); |
|
251 |
end; |
|
252 |
vgtSmokeRing: |
|
253 |
begin |
|
254 |
dx:= 0; |
|
255 |
dy:= 0; |
|
256 |
FrameTicks:= 600; |
|
257 |
Timer:= 0; |
|
258 |
Frame:= 0; |
|
259 |
scale:= 0.6; |
|
260 |
alpha:= 1; |
|
261 |
angle:= random(360); |
|
262 |
end; |
|
263 |
vgtFeather: |
|
264 |
begin |
|
265 |
t:= random(1024); |
|
266 |
sp:= 0.001 * (random(85) + 95); |
|
267 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
268 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
269 |
if random(2) = 0 then |
|
270 |
dx := -dx; |
|
271 |
if random(2) = 0 then |
|
272 |
dy := -dy; |
|
273 |
FrameTicks:= 650 + random(250); |
|
274 |
Frame:= 1 |
|
275 |
end; |
|
276 |
vgtHealthTag: |
|
277 |
begin |
|
278 |
Frame:= 0; |
|
279 |
Timer:= 1500; |
|
280 |
dY:= -0.08; |
|
281 |
dX:= 0; |
|
282 |
//gear^.Z:= 2002; |
|
283 |
end; |
|
284 |
vgtSmokeTrace, |
|
285 |
vgtEvilTrace: |
|
286 |
begin |
|
287 |
gear^.X:= gear^.X - 16; |
|
288 |
gear^.Y:= gear^.Y - 16; |
|
289 |
gear^.State:= 8; |
|
290 |
//gear^.Z:= cSmokeZ |
|
291 |
end; |
|
292 |
vgtBigExplosion: |
|
293 |
begin |
|
294 |
gear^.Angle:= random(360); |
|
295 |
end; |
|
296 |
vgtChunk: |
|
297 |
begin |
|
298 |
gear^.Frame:= random(4); |
|
299 |
t:= random(1024); |
|
300 |
sp:= 0.001 * (random(85) + 47); |
|
301 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
302 |
dy:= hwFloat2Float(AngleCos(t)) * sp * -2; |
|
303 |
if random(2) = 0 then |
|
304 |
dx := -dx; |
|
305 |
end; |
|
10015 | 306 |
vgtNote: |
9287 | 307 |
begin |
308 |
dx:= 0.005 * (random(15) + 10); |
|
309 |
dy:= -0.001 * (random(40) + 20); |
|
310 |
if random(2) = 0 then |
|
311 |
dx := -dx; |
|
312 |
Frame:= random(4); |
|
313 |
FrameTicks:= random(2000) + 1500; |
|
314 |
end; |
|
315 |
vgtBulletHit: |
|
316 |
begin |
|
317 |
dx:= 0; |
|
318 |
dy:= 0; |
|
319 |
FrameTicks:= 350; |
|
320 |
Frame:= 7; |
|
321 |
Angle:= 0; |
|
322 |
end; |
|
10015 | 323 |
vgtSmoothWindBar: |
9287 | 324 |
begin |
325 |
Angle:= hwFloat2Float(cMaxWindSpeed)*2 / 1440; // seems rate below is supposed to change wind bar at 1px per 10ms. Max time, 1440ms. This tries to match the rate of change |
|
326 |
Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
|
327 |
end; |
|
328 |
vgtStraightShot: |
|
329 |
begin |
|
330 |
Angle:= 0; |
|
331 |
Scale:= 1.0; |
|
332 |
dx:= 0.001 * random(45); |
|
333 |
dy:= 0.001 * (random(20) + 25); |
|
334 |
State:= ord(sprHealth); |
|
335 |
if random(2) = 0 then |
|
336 |
dx := -dx; |
|
337 |
Frame:= 0; |
|
338 |
FrameTicks:= random(750) + 1250; |
|
339 |
State:= ord(sprSnowDust); |
|
340 |
end; |
|
10251
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
341 |
vgtNoPlaceWarn: |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
342 |
begin |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
343 |
FrameTicks:= 2000; |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
344 |
Tint:= $FF0000FF; |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
345 |
Scale:= 1.0; |
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
346 |
end; |
9287 | 347 |
end; |
348 |
||
349 |
if State <> 0 then |
|
350 |
gear^.State:= State; |
|
351 |
||
352 |
case Gear^.Kind of |
|
12110
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
353 |
vgtFlake: |
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
354 |
if random(3) = 0 then |
9287 | 355 |
begin |
356 |
gear^.Scale:= 0.5; |
|
357 |
gear^.Layer:= 0 // 33% - far back |
|
358 |
end |
|
359 |
else if random(3) = 0 then |
|
360 |
begin |
|
361 |
gear^.Scale:= 0.8; |
|
362 |
gear^.Layer:= 4 // 22% - mid-distance |
|
363 |
end |
|
364 |
else if random(3) <> 0 then |
|
365 |
gear^.Layer:= 5 // 30% - just behind land |
|
12110
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
366 |
else if (not cFlattenFlakes) and (random(2) = 0) then |
9287 | 367 |
gear^.Layer:= 6 // 7% - just in front of land |
12110
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
368 |
else if not cFlattenFlakes then |
9287 | 369 |
begin |
370 |
gear^.Scale:= 1.5; |
|
12110
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
371 |
gear^.Layer:= 2 // 7% - close up |
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
372 |
end |
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
373 |
else begin |
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
374 |
gear^.Layer:= 0; |
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
375 |
gear^.Scale:= 0.5 |
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
376 |
end; |
9287 | 377 |
|
378 |
vgtCloud: if cFlattenClouds then gear^.Layer:= 5 |
|
379 |
else if random(3) = 0 then |
|
380 |
begin |
|
381 |
gear^.Scale:= 0.25; |
|
382 |
gear^.Layer:= 0 |
|
383 |
end |
|
384 |
else if random(2) = 0 then |
|
385 |
gear^.Layer:= 5 |
|
386 |
else |
|
387 |
begin |
|
388 |
gear^.Scale:= 0.4; |
|
389 |
gear^.Layer:= 4 |
|
390 |
end; |
|
10251
a3b42e81803c
collision indicator on failed girder placement (especially useful with rubberband I guess). still needs some tweaks but I am going to bed now :P
sheepluva
parents:
10193
diff
changeset
|
391 |
vgtNoPlaceWarn: gear^.Layer:= 6; |
9287 | 392 |
|
393 |
// 0: this layer is very distant in the background when in stereo |
|
394 |
vgtTeamHealthSorter, |
|
395 |
vgtSmoothWindBar: gear^.Layer:= 0; |
|
396 |
||
397 |
||
398 |
// 1: this layer is on the land level (which is close but behind the screen plane) when stereo |
|
399 |
vgtSmokeTrace, |
|
400 |
vgtEvilTrace, |
|
401 |
vgtLineTrail, |
|
402 |
vgtSmoke, |
|
403 |
vgtSmokeWhite, |
|
404 |
vgtDust, |
|
405 |
vgtFire, |
|
406 |
vgtSplash, |
|
407 |
vgtDroplet, |
|
408 |
vgtBubble: gear^.Layer:= 1; |
|
409 |
||
410 |
// 3: this layer is on the screen plane (depth = 0) when stereo |
|
411 |
vgtSpeechBubble, |
|
412 |
vgtSmallDamageTag, |
|
413 |
vgtHealthTag, |
|
414 |
vgtStraightShot, |
|
10876 | 415 |
vgtFeather, |
9287 | 416 |
vgtChunk: gear^.Layer:= 3; |
417 |
||
418 |
// 2: this layer is outside the screen when stereo |
|
419 |
vgtExplosion, |
|
420 |
vgtBigExplosion, |
|
421 |
vgtExplPart, |
|
422 |
vgtExplPart2, |
|
423 |
vgtSteam, |
|
424 |
vgtAmmo, |
|
425 |
vgtShell, |
|
426 |
vgtEgg, |
|
427 |
vgtBeeTrace, |
|
428 |
vgtSmokeRing, |
|
429 |
vgtNote, |
|
430 |
vgtBulletHit, |
|
431 |
vgtCircle: gear^.Layer:= 2 |
|
432 |
end; |
|
433 |
||
9769
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
434 |
if Layer <> -1 then gear^.Layer:= Layer; |
5814e0c47c99
Experiment in adding a "boing" graphic for bouncing. It has no text right now (was thinking l10n) and colour is fixed.
nemo
parents:
9287
diff
changeset
|
435 |
|
9287 | 436 |
if VisualGearLayers[gear^.Layer] <> nil then |
437 |
begin |
|
438 |
VisualGearLayers[gear^.Layer]^.PrevGear:= gear; |
|
439 |
gear^.NextGear:= VisualGearLayers[gear^.Layer] |
|
440 |
end; |
|
441 |
VisualGearLayers[gear^.Layer]:= gear; |
|
442 |
||
443 |
AddVisualGear:= gear; |
|
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11857
diff
changeset
|
444 |
ScriptCall('onVisualGearAdd', gear^.uid); |
9287 | 445 |
end; |
446 |
||
447 |
procedure DeleteVisualGear(Gear: PVisualGear); |
|
448 |
begin |
|
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11857
diff
changeset
|
449 |
ScriptCall('onVisualGearDelete', Gear^.uid); |
10634
35d059bd0932
Use FreeAndNil across the board. Even if we are immediately assigning after, probably avoids accidental mistakes. Also free neglected owner tex on shutdown, and delete hog gears using the normal deletion procedure if for any reason they still exist (EndGame call?).
nemo
parents:
10625
diff
changeset
|
450 |
FreeAndNilTexture(Gear^.Tex); |
9287 | 451 |
|
452 |
if Gear^.NextGear <> nil then |
|
453 |
Gear^.NextGear^.PrevGear:= Gear^.PrevGear; |
|
454 |
if Gear^.PrevGear <> nil then |
|
455 |
Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
456 |
else |
|
457 |
VisualGearLayers[Gear^.Layer]:= Gear^.NextGear; |
|
458 |
||
459 |
if lastVisualGearByUID = Gear then |
|
460 |
lastVisualGearByUID:= nil; |
|
461 |
||
462 |
Dispose(Gear); |
|
463 |
end; |
|
464 |
||
465 |
function VisualGearByUID(uid : Longword) : PVisualGear; |
|
466 |
var vg: PVisualGear; |
|
467 |
i: LongWord; |
|
468 |
begin |
|
469 |
VisualGearByUID:= nil; |
|
470 |
if uid = 0 then |
|
471 |
exit; |
|
472 |
if (lastVisualGearByUID <> nil) and (lastVisualGearByUID^.uid = uid) then |
|
473 |
begin |
|
474 |
VisualGearByUID:= lastVisualGearByUID; |
|
475 |
exit |
|
476 |
end; |
|
477 |
// search in an order that is more likely to return layers they actually use. Could perhaps track statistically AddVisualGear in uScript, since that is most likely the ones they want |
|
478 |
for i:= 2 to 5 do |
|
479 |
begin |
|
480 |
vg:= VisualGearLayers[i mod 4]; |
|
481 |
while vg <> nil do |
|
482 |
begin |
|
483 |
if vg^.uid = uid then |
|
484 |
begin |
|
485 |
lastVisualGearByUID:= vg; |
|
486 |
VisualGearByUID:= vg; |
|
487 |
exit |
|
488 |
end; |
|
489 |
vg:= vg^.NextGear |
|
490 |
end |
|
491 |
end |
|
492 |
end; |
|
493 |
||
494 |
||
495 |
end. |