author | Wuzzy <Wuzzy2@mail.ru> |
Sun, 19 Jul 2020 11:32:30 +0200 | |
changeset 15751 | 34138bf36c5c |
parent 15608 | 19c85b010144 |
child 15795 | da1bb21e6fbf |
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; |
|
14605
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
36 |
VisualGearLayersStart: array[0..6] of PVisualGear; |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
37 |
VisualGearLayersEnd: array[0..6] of PVisualGear; |
9287 | 38 |
|
39 |
implementation |
|
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11857
diff
changeset
|
40 |
uses uCollisions, uFloat, uVariables, uConsts, uTextures, uVisualGearsHandlers, uScript; |
9287 | 41 |
|
42 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType): PVisualGear; inline; |
|
43 |
begin |
|
10352 | 44 |
// adjust some visual gear types if underwater |
10354 | 45 |
if CheckCoordInWater(X, Y) and ((Kind = vgtBeeTrace) or (Kind = vgtSmokeTrace) or (Kind = vgtEvilTrace)) then |
10352 | 46 |
Kind:= vgtBubble; |
47 |
||
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
|
48 |
AddVisualGear:= AddVisualGear(X, Y, Kind, 0, false, -1); |
9287 | 49 |
end; |
50 |
||
51 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord): PVisualGear; inline; |
|
52 |
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
|
53 |
AddVisualGear:= AddVisualGear(X, Y, Kind, State, false, -1); |
9287 | 54 |
end; |
55 |
||
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
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
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
|
60 |
|
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
|
61 |
function AddVisualGear(X, Y: LongInt; Kind: TVisualGearType; State: LongWord; Critical: Boolean; Layer: LongInt): PVisualGear; |
9287 | 62 |
var gear: PVisualGear; |
63 |
t: Longword; |
|
64 |
sp: real; |
|
65 |
begin |
|
66 |
AddVisualGear:= nil; |
|
13040
a87d3119c962
VideoRec: Fix many effects not being recorded
Wuzzy <Wuzzy2@mail.ru>
parents:
12110
diff
changeset
|
67 |
if (GameType <> gmtRecord) and |
a87d3119c962
VideoRec: Fix many effects not being recorded
Wuzzy <Wuzzy2@mail.ru>
parents:
12110
diff
changeset
|
68 |
(((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
|
69 |
(not Critical)) then |
9287 | 70 |
exit; |
71 |
||
72 |
if ((cReducedQuality and rqAntiBoom) <> 0) and |
|
73 |
(not Critical) and |
|
74 |
(not (Kind in |
|
75 |
[vgtTeamHealthSorter, |
|
76 |
vgtSmallDamageTag, |
|
77 |
vgtSpeechBubble, |
|
78 |
vgtHealthTag, |
|
79 |
vgtExplosion, |
|
15118
260e96addf92
Allow vgtBigExplosion in low quality mode
Wuzzy <Wuzzy2@mail.ru>
parents:
14678
diff
changeset
|
80 |
vgtBigExplosion, |
9287 | 81 |
vgtSmokeTrace, |
82 |
vgtEvilTrace, |
|
83 |
vgtNote, |
|
10876 | 84 |
vgtFeather, |
9287 | 85 |
vgtSmoothWindBar])) then |
10015 | 86 |
|
9287 | 87 |
exit; |
88 |
||
89 |
inc(VGCounter); |
|
90 |
New(gear); |
|
91 |
FillChar(gear^, sizeof(TVisualGear), 0); |
|
92 |
gear^.X:= real(X); |
|
93 |
gear^.Y:= real(Y); |
|
94 |
gear^.Kind := Kind; |
|
9960 | 95 |
gear^.doStep:= doStepVGHandlers[Kind]; |
9287 | 96 |
gear^.Tint:= $FFFFFFFF; |
97 |
gear^.uid:= VGCounter; |
|
98 |
||
99 |
with gear^ do |
|
100 |
case Kind of |
|
101 |
vgtFlake: |
|
102 |
begin |
|
15608
19c85b010144
Add fade-in effect when flake appears at top
Wuzzy <Wuzzy2@mail.ru>
parents:
15118
diff
changeset
|
103 |
State:= 0; |
9287 | 104 |
Timer:= 0; |
105 |
tdX:= 0; |
|
106 |
tdY:= 0; |
|
107 |
Scale:= 1.0; |
|
108 |
if SuddenDeathDmg then |
|
109 |
begin |
|
10625
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10354
diff
changeset
|
110 |
if vobSDFrameTicks > 0 then |
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10354
diff
changeset
|
111 |
FrameTicks:= random(vobSDFrameTicks); |
9287 | 112 |
Frame:= random(vobSDFramesCount); |
113 |
end |
|
114 |
else |
|
115 |
begin |
|
10625
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10354
diff
changeset
|
116 |
if vobFrameTicks > 0 then |
125e120165aa
flake FrameTicks value of 0 now indicades that the frame should not be changed
sheepluva
parents:
10354
diff
changeset
|
117 |
FrameTicks:= random(vobFrameTicks); |
9287 | 118 |
Frame:= random(vobFramesCount); |
119 |
end; |
|
120 |
Angle:= random(360); |
|
121 |
dx:= 0.0000038654705 * random(10000); |
|
122 |
dy:= 0.000003506096 * random(7000); |
|
123 |
if random(2) = 0 then |
|
124 |
dx := -dx; |
|
125 |
if SuddenDeathDmg then |
|
126 |
dAngle:= (random(2) * 2 - 1) * (vobSDVelocity + random(vobSDVelocity)) / 1000 |
|
127 |
else |
|
128 |
dAngle:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) / 1000 |
|
129 |
end; |
|
130 |
vgtCloud: |
|
131 |
begin |
|
132 |
Frame:= random(4); |
|
133 |
dx:= 0.5 + 0.1 * random(5); // how much the cloud will be affected by wind |
|
134 |
timer:= random(4096); |
|
135 |
Scale:= 1.0 |
|
136 |
end; |
|
137 |
vgtExplPart, |
|
138 |
vgtExplPart2: |
|
139 |
begin |
|
140 |
t:= random(1024); |
|
141 |
sp:= 0.001 * (random(95) + 70); |
|
142 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
143 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
144 |
if random(2) = 0 then |
|
145 |
dx := -dx; |
|
146 |
if random(2) = 0 then |
|
147 |
dy := -dy; |
|
148 |
Frame:= 7 - random(3); |
|
149 |
FrameTicks:= cExplFrameTicks |
|
150 |
end; |
|
151 |
vgtFire: |
|
152 |
begin |
|
153 |
t:= random(1024); |
|
154 |
sp:= 0.001 * (random(85) + 95); |
|
155 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
156 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
157 |
if random(2) = 0 then |
|
158 |
dx := -dx; |
|
159 |
if random(2) = 0 then |
|
160 |
dy := -dy; |
|
161 |
FrameTicks:= 650 + random(250); |
|
162 |
Frame:= random(8) |
|
163 |
end; |
|
164 |
vgtEgg: |
|
165 |
begin |
|
166 |
t:= random(1024); |
|
167 |
sp:= 0.001 * (random(85) + 95); |
|
168 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
169 |
dy:= hwFloat2Float(AngleCos(t)) * sp; |
|
170 |
if random(2) = 0 then |
|
171 |
dx := -dx; |
|
172 |
if random(2) = 0 then |
|
173 |
dy := -dy; |
|
174 |
FrameTicks:= 650 + random(250); |
|
175 |
Frame:= 1 |
|
176 |
end; |
|
177 |
vgtShell: FrameTicks:= 500; |
|
178 |
vgtSmallDamageTag: |
|
179 |
begin |
|
180 |
gear^.FrameTicks:= 1100 |
|
181 |
end; |
|
182 |
vgtBubble: |
|
183 |
begin |
|
184 |
dx:= 0.0000038654705 * random(10000); |
|
185 |
dy:= 0; |
|
186 |
if random(2) = 0 then |
|
187 |
dx := -dx; |
|
188 |
FrameTicks:= 250 + random(1751); |
|
189 |
Frame:= random(5) |
|
190 |
end; |
|
191 |
vgtSteam: |
|
192 |
begin |
|
193 |
dx:= 0.0000038654705 * random(10000); |
|
194 |
dy:= 0.001 * (random(85) + 95); |
|
195 |
if random(2) = 0 then |
|
196 |
dx := -dx; |
|
197 |
Frame:= 7 - random(3); |
|
198 |
FrameTicks:= cExplFrameTicks * 2; |
|
199 |
end; |
|
200 |
vgtAmmo: |
|
201 |
begin |
|
202 |
alpha:= 1.0; |
|
203 |
scale:= 1.0 |
|
204 |
end; |
|
205 |
vgtSmokeWhite, |
|
206 |
vgtSmoke: |
|
207 |
begin |
|
208 |
Scale:= 1.0; |
|
209 |
dx:= 0.0002 * (random(45) + 10); |
|
210 |
dy:= 0.0002 * (random(45) + 10); |
|
211 |
if random(2) = 0 then |
|
212 |
dx := -dx; |
|
213 |
Frame:= 7 - random(2); |
|
214 |
FrameTicks:= cExplFrameTicks * 2; |
|
215 |
end; |
|
216 |
vgtDust: |
|
217 |
begin |
|
218 |
dx:= 0.005 * (random(15) + 10); |
|
219 |
dy:= 0.001 * (random(40) + 20); |
|
220 |
if random(2) = 0 then dx := -dx; |
|
221 |
if random(2) = 0 then Tag:= 1 |
|
222 |
else Tag:= -1; |
|
223 |
Frame:= 7 - random(2); |
|
224 |
FrameTicks:= random(20) + 15; |
|
225 |
end; |
|
226 |
vgtSplash: |
|
227 |
begin |
|
228 |
dx:= 0; |
|
229 |
dy:= 0; |
|
230 |
FrameTicks:= 740; |
|
231 |
Frame:= 19; |
|
232 |
Scale:= 0.75; |
|
233 |
Timer:= 1; |
|
234 |
end; |
|
235 |
vgtDroplet: |
|
236 |
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
|
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; |
|
14678
b390479f24c1
vgtHealthTag now supports setting FrameTicks <> 0 to disable automatic water handling
Wuzzy <Wuzzy2@mail.ru>
parents:
14605
diff
changeset
|
279 |
FrameTicks:= 0; |
9287 | 280 |
Timer:= 1500; |
281 |
dY:= -0.08; |
|
282 |
dX:= 0; |
|
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 |
end; |
|
291 |
vgtBigExplosion: |
|
292 |
begin |
|
293 |
gear^.Angle:= random(360); |
|
294 |
end; |
|
295 |
vgtChunk: |
|
296 |
begin |
|
297 |
gear^.Frame:= random(4); |
|
298 |
t:= random(1024); |
|
299 |
sp:= 0.001 * (random(85) + 47); |
|
300 |
dx:= hwFloat2Float(AngleSin(t)) * sp; |
|
301 |
dy:= hwFloat2Float(AngleCos(t)) * sp * -2; |
|
302 |
if random(2) = 0 then |
|
303 |
dx := -dx; |
|
304 |
end; |
|
10015 | 305 |
vgtNote: |
9287 | 306 |
begin |
307 |
dx:= 0.005 * (random(15) + 10); |
|
308 |
dy:= -0.001 * (random(40) + 20); |
|
309 |
if random(2) = 0 then |
|
310 |
dx := -dx; |
|
311 |
Frame:= random(4); |
|
312 |
FrameTicks:= random(2000) + 1500; |
|
313 |
end; |
|
314 |
vgtBulletHit: |
|
315 |
begin |
|
316 |
dx:= 0; |
|
317 |
dy:= 0; |
|
318 |
FrameTicks:= 350; |
|
319 |
Frame:= 7; |
|
320 |
Angle:= 0; |
|
321 |
end; |
|
10015 | 322 |
vgtSmoothWindBar: |
9287 | 323 |
begin |
324 |
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 |
|
325 |
Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed); |
|
326 |
end; |
|
327 |
vgtStraightShot: |
|
328 |
begin |
|
329 |
Angle:= 0; |
|
330 |
Scale:= 1.0; |
|
331 |
dx:= 0.001 * random(45); |
|
332 |
dy:= 0.001 * (random(20) + 25); |
|
333 |
State:= ord(sprHealth); |
|
334 |
if random(2) = 0 then |
|
335 |
dx := -dx; |
|
336 |
Frame:= 0; |
|
337 |
FrameTicks:= random(750) + 1250; |
|
338 |
State:= ord(sprSnowDust); |
|
339 |
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
|
340 |
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
|
341 |
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
|
342 |
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
|
343 |
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
|
344 |
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
|
345 |
end; |
9287 | 346 |
end; |
347 |
||
348 |
if State <> 0 then |
|
349 |
gear^.State:= State; |
|
350 |
||
351 |
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
|
352 |
vgtFlake: |
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
353 |
if random(3) = 0 then |
9287 | 354 |
begin |
355 |
gear^.Scale:= 0.5; |
|
356 |
gear^.Layer:= 0 // 33% - far back |
|
357 |
end |
|
358 |
else if random(3) = 0 then |
|
359 |
begin |
|
360 |
gear^.Scale:= 0.8; |
|
361 |
gear^.Layer:= 4 // 22% - mid-distance |
|
362 |
end |
|
363 |
else if random(3) <> 0 then |
|
364 |
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
|
365 |
else if (not cFlattenFlakes) and (random(2) = 0) then |
9287 | 366 |
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
|
367 |
else if not cFlattenFlakes then |
9287 | 368 |
begin |
369 |
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
|
370 |
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
|
371 |
end |
f214d6315b71
requested by CopherNeue - make "flatten-flakes" only exclude the foreground layers. testing on eyes/halloween seems ok.
nemo
parents:
11880
diff
changeset
|
372 |
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
|
373 |
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
|
374 |
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
|
375 |
end; |
9287 | 376 |
|
377 |
vgtCloud: if cFlattenClouds then gear^.Layer:= 5 |
|
378 |
else if random(3) = 0 then |
|
379 |
begin |
|
380 |
gear^.Scale:= 0.25; |
|
381 |
gear^.Layer:= 0 |
|
382 |
end |
|
383 |
else if random(2) = 0 then |
|
384 |
gear^.Layer:= 5 |
|
385 |
else |
|
386 |
begin |
|
387 |
gear^.Scale:= 0.4; |
|
388 |
gear^.Layer:= 4 |
|
389 |
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
|
390 |
vgtNoPlaceWarn: gear^.Layer:= 6; |
9287 | 391 |
|
392 |
// 0: this layer is very distant in the background when in stereo |
|
393 |
vgtTeamHealthSorter, |
|
394 |
vgtSmoothWindBar: gear^.Layer:= 0; |
|
395 |
||
396 |
||
397 |
// 1: this layer is on the land level (which is close but behind the screen plane) when stereo |
|
398 |
vgtSmokeTrace, |
|
399 |
vgtEvilTrace, |
|
400 |
vgtLineTrail, |
|
401 |
vgtSmoke, |
|
402 |
vgtSmokeWhite, |
|
403 |
vgtDust, |
|
404 |
vgtFire, |
|
405 |
vgtSplash, |
|
406 |
vgtDroplet, |
|
407 |
vgtBubble: gear^.Layer:= 1; |
|
408 |
||
409 |
// 3: this layer is on the screen plane (depth = 0) when stereo |
|
410 |
vgtSpeechBubble, |
|
411 |
vgtSmallDamageTag, |
|
412 |
vgtHealthTag, |
|
413 |
vgtStraightShot, |
|
10876 | 414 |
vgtFeather, |
9287 | 415 |
vgtChunk: gear^.Layer:= 3; |
416 |
||
417 |
// 2: this layer is outside the screen when stereo |
|
418 |
vgtExplosion, |
|
419 |
vgtBigExplosion, |
|
420 |
vgtExplPart, |
|
421 |
vgtExplPart2, |
|
422 |
vgtSteam, |
|
423 |
vgtAmmo, |
|
424 |
vgtShell, |
|
425 |
vgtEgg, |
|
426 |
vgtBeeTrace, |
|
427 |
vgtSmokeRing, |
|
428 |
vgtNote, |
|
429 |
vgtBulletHit, |
|
430 |
vgtCircle: gear^.Layer:= 2 |
|
431 |
end; |
|
432 |
||
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
|
433 |
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
|
434 |
|
14605
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
435 |
if VisualGearLayersStart[gear^.Layer] = nil then |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
436 |
VisualGearLayersStart[gear^.Layer]:= gear; |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
437 |
|
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
438 |
if VisualGearLayersEnd[gear^.Layer] <> nil then |
9287 | 439 |
begin |
14605
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
440 |
VisualGearLayersEnd[gear^.Layer]^.NextGear:= gear; |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
441 |
gear^.PrevGear:= VisualGearLayersEnd[gear^.Layer] |
9287 | 442 |
end; |
14605
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
443 |
VisualGearLayersEnd[gear^.Layer]:= gear; |
9287 | 444 |
|
445 |
AddVisualGear:= gear; |
|
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11857
diff
changeset
|
446 |
ScriptCall('onVisualGearAdd', gear^.uid); |
9287 | 447 |
end; |
448 |
||
449 |
procedure DeleteVisualGear(Gear: PVisualGear); |
|
450 |
begin |
|
11880
2eac7a96b342
Lua API: Add GetVisualGearType, onVisualGearAdd, onVisualGearDelete
Wuzzy <almikes@aol.com>
parents:
11857
diff
changeset
|
451 |
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
|
452 |
FreeAndNilTexture(Gear^.Tex); |
9287 | 453 |
|
14605
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
454 |
if (Gear^.NextGear = nil) and (Gear^.PrevGear = nil) then |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
455 |
begin |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
456 |
VisualGearLayersStart[Gear^.Layer]:= nil; |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
457 |
VisualGearLayersEnd[Gear^.Layer]:= nil; |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
458 |
end; |
9287 | 459 |
if Gear^.PrevGear <> nil then |
460 |
Gear^.PrevGear^.NextGear:= Gear^.NextGear |
|
14605
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
461 |
else if Gear^.NextGear <> nil then |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
462 |
VisualGearLayersStart[Gear^.Layer]:= Gear^.NextGear; |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
463 |
if Gear^.NextGear <> nil then |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
464 |
Gear^.NextGear^.PrevGear:= Gear^.PrevGear |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
465 |
else if Gear^.PrevGear <> nil then |
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
466 |
VisualGearLayersEnd[Gear^.Layer]:= Gear^.PrevGear; |
9287 | 467 |
|
468 |
if lastVisualGearByUID = Gear then |
|
469 |
lastVisualGearByUID:= nil; |
|
470 |
||
471 |
Dispose(Gear); |
|
472 |
end; |
|
473 |
||
474 |
function VisualGearByUID(uid : Longword) : PVisualGear; |
|
475 |
var vg: PVisualGear; |
|
476 |
i: LongWord; |
|
477 |
begin |
|
478 |
VisualGearByUID:= nil; |
|
479 |
if uid = 0 then |
|
480 |
exit; |
|
481 |
if (lastVisualGearByUID <> nil) and (lastVisualGearByUID^.uid = uid) then |
|
482 |
begin |
|
483 |
VisualGearByUID:= lastVisualGearByUID; |
|
484 |
exit |
|
485 |
end; |
|
486 |
// 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 |
|
487 |
for i:= 2 to 5 do |
|
488 |
begin |
|
14605
ab79cd4a7382
Reverse order of visual gears linked list
Wuzzy <Wuzzy2@mail.ru>
parents:
14593
diff
changeset
|
489 |
vg:= VisualGearLayersStart[i mod 4]; |
9287 | 490 |
while vg <> nil do |
491 |
begin |
|
492 |
if vg^.uid = uid then |
|
493 |
begin |
|
494 |
lastVisualGearByUID:= vg; |
|
495 |
VisualGearByUID:= vg; |
|
496 |
exit |
|
497 |
end; |
|
498 |
vg:= vg^.NextGear |
|
499 |
end |
|
500 |
end |
|
501 |
end; |
|
502 |
||
503 |
||
504 |
end. |