author | unc0rr |
Sat, 13 Nov 2010 16:47:40 +0300 | |
branch | 0.9.14 |
changeset 4271 | 3fa9eb4d25b9 |
parent 4172 | 03fe080d99d6 |
child 4279 | b697a26ed538 |
permissions | -rw-r--r-- |
3441 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2004-2010 Andrey Korotaev <unC0Rr@gmail.com> |
|
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*) |
|
18 |
procedure doStepFlake(Gear: PVisualGear; Steps: Longword); |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
19 |
var sign: float; |
3441 | 20 |
begin |
3641 | 21 |
if vobCount = 0 then exit; |
3611 | 22 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
23 |
sign:= 1; |
3441 | 24 |
with Gear^ do |
25 |
begin |
|
26 |
inc(FrameTicks, Steps); |
|
27 |
if FrameTicks > vobFrameTicks then |
|
28 |
begin |
|
29 |
dec(FrameTicks, vobFrameTicks); |
|
30 |
inc(Frame); |
|
31 |
if Frame = vobFramesCount then Frame:= 0 |
|
32 |
end; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
33 |
X:= X + (cWindSpeedf * 200 + dX + tdX) * Steps; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
34 |
Y:= Y + (dY + tdY + cGravityf * vobFallSpeed) * Steps; |
3441 | 35 |
Angle:= Angle + dAngle * Steps; |
4152
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
36 |
if Angle > 360 then |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
37 |
Angle:= Angle - 360 |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
38 |
else |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
39 |
if Angle < - 360 then |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
40 |
Angle:= Angle + 360; |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
41 |
|
3441 | 42 |
|
3764 | 43 |
if (round(X) >= cLeftScreenBorder) and |
44 |
(round(X) <= cRightScreenBorder) and |
|
4161 | 45 |
(round(Y) - 75 <= LAND_HEIGHT) and |
3441 | 46 |
(Timer > 0) and (Timer-Steps > 0) then |
47 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
48 |
if tdX > 0 then sign := 1 |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
49 |
else sign:= -1; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
50 |
tdX:= tdX - 0.005*Steps*sign; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
51 |
if ((sign < 0) and (tdX > 0)) or ((sign > 0) and (tdX < 0)) then tdX:= 0; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
52 |
if tdX > 0 then sign := 1 |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
53 |
else sign:= -1; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
54 |
tdY:= tdY - 0.005*Steps*sign; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
55 |
if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then tdY:= 0; |
3441 | 56 |
dec(Timer, Steps) |
57 |
end |
|
58 |
else |
|
59 |
begin |
|
3764 | 60 |
if round(X) < cLeftScreenBorder then X:= X + cScreenSpace else |
61 |
if round(X) > cRightScreenBorder then X:= X - cScreenSpace; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
62 |
// if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + float(25); // For if flag is set for flakes rising upwards? |
4161 | 63 |
if round(Y) - 75 > LAND_HEIGHT then Y:= Y - float(1024 + 150); // TODO - configure in theme (jellies for example could use limited range) |
3441 | 64 |
Timer:= 0; |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
65 |
tdX:= 0; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
66 |
tdY:= 0 |
3441 | 67 |
end; |
68 |
end; |
|
69 |
||
70 |
end; |
|
71 |
||
72 |
//////////////////////////////////////////////////////////////////////////////// |
|
73 |
procedure doStepBeeTrace(Gear: PVisualGear; Steps: Longword); |
|
74 |
begin |
|
75 |
if Gear^.FrameTicks > Steps then |
|
76 |
dec(Gear^.FrameTicks, Steps) |
|
77 |
else |
|
78 |
DeleteVisualGear(Gear); |
|
79 |
end; |
|
80 |
||
81 |
//////////////////////////////////////////////////////////////////////////////// |
|
82 |
procedure doStepCloud(Gear: PVisualGear; Steps: Longword); |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
83 |
var s: Longword; |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
84 |
t: float; |
3441 | 85 |
begin |
3994
486da687d76a
fix/tweak let clouds reflect wind speed and direction again + stronger
sheepluva
parents:
3976
diff
changeset
|
86 |
Gear^.X:= Gear^.X + (cWindSpeedf * 750 * Gear^.dX) * Steps; |
3441 | 87 |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
88 |
// up-and-down-bounce magic |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
89 |
s := (GameTicks + Gear^.Timer) mod 4096; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
90 |
t := 8 * AngleSin(s mod 2048).QWordValue / 4294967296; |
3597
978c30ef50fc
visual gears: fixing nemo's c-style assignment/multiplications
sheepluva
parents:
3593
diff
changeset
|
91 |
if (s < 2048) then t := -t; |
3441 | 92 |
|
4161 | 93 |
Gear^.Y := LAND_HEIGHT - 1184 + LongInt(Gear^.Timer mod 8) + t; |
3441 | 94 |
|
3764 | 95 |
if round(Gear^.X) < cLeftScreenBorder then Gear^.X:= Gear^.X + cScreenSpace else |
96 |
if round(Gear^.X) > cRightScreenBorder then Gear^.X:= Gear^.X - cScreenSpace |
|
3441 | 97 |
end; |
98 |
||
99 |
//////////////////////////////////////////////////////////////////////////////// |
|
100 |
procedure doStepExpl(Gear: PVisualGear; Steps: Longword); |
|
101 |
begin |
|
102 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
103 |
||
104 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
105 |
//Gear^.dY:= Gear^.dY + cGravityf; |
3441 | 106 |
|
107 |
if Gear^.FrameTicks <= Steps then |
|
108 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
109 |
else |
|
110 |
begin |
|
111 |
dec(Gear^.Frame); |
|
112 |
Gear^.FrameTicks:= cExplFrameTicks |
|
113 |
end |
|
114 |
else dec(Gear^.FrameTicks, Steps) |
|
115 |
end; |
|
116 |
||
117 |
//////////////////////////////////////////////////////////////////////////////// |
|
3704 | 118 |
procedure doStepNote(Gear: PVisualGear; Steps: Longword); |
119 |
begin |
|
120 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
121 |
||
122 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3706 | 123 |
Gear^.dY:= Gear^.dY + cGravityf * Steps / 2; |
3704 | 124 |
|
3706 | 125 |
Gear^.Angle:= Gear^.Angle + (Gear^.Frame + 1) * Steps / 10; |
126 |
while Gear^.Angle > cMaxAngle do |
|
127 |
Gear^.Angle:= Gear^.Angle - cMaxAngle; |
|
3704 | 128 |
|
129 |
if Gear^.FrameTicks <= Steps then |
|
130 |
DeleteVisualGear(Gear) |
|
131 |
else |
|
132 |
dec(Gear^.FrameTicks, Steps) |
|
133 |
end; |
|
134 |
||
135 |
//////////////////////////////////////////////////////////////////////////////// |
|
3441 | 136 |
procedure doStepEgg(Gear: PVisualGear; Steps: Longword); |
137 |
begin |
|
138 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
139 |
||
140 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
141 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 142 |
|
143 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
144 |
||
145 |
if Gear^.FrameTicks <= Steps then |
|
146 |
DeleteVisualGear(Gear) |
|
147 |
else |
|
148 |
dec(Gear^.FrameTicks, Steps) |
|
149 |
end; |
|
150 |
||
151 |
//////////////////////////////////////////////////////////////////////////////// |
|
152 |
procedure doStepFire(Gear: PVisualGear; Steps: Longword); |
|
3751 | 153 |
var vgt: PVisualGear; |
3441 | 154 |
begin |
155 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
156 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
157 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravityf * (Steps * Steps); |
3751 | 158 |
if (Gear^.State and gstTmpFlag) = 0 then |
159 |
begin |
|
160 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
|
3764 | 161 |
if ((GameTicks mod 200) < Steps + 1) then |
3751 | 162 |
begin |
163 |
vgt:= AddVisualGear(round(Gear^.X), round(Gear^.Y), vgtFire); |
|
164 |
if vgt <> nil then |
|
165 |
begin |
|
166 |
vgt^.dx:= 0; |
|
167 |
vgt^.dy:= 0; |
|
168 |
vgt^.State:= gstTmpFlag; |
|
169 |
end; |
|
170 |
end |
|
171 |
end |
|
172 |
else |
|
173 |
inc(Steps, Steps); |
|
3441 | 174 |
|
175 |
if Gear^.FrameTicks <= Steps then |
|
176 |
DeleteVisualGear(Gear) |
|
177 |
else |
|
178 |
dec(Gear^.FrameTicks, Steps) |
|
179 |
end; |
|
180 |
||
181 |
//////////////////////////////////////////////////////////////////////////////// |
|
182 |
procedure doStepShell(Gear: PVisualGear; Steps: Longword); |
|
183 |
begin |
|
184 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
185 |
||
186 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
187 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 188 |
|
189 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
190 |
||
191 |
if Gear^.FrameTicks <= Steps then |
|
192 |
DeleteVisualGear(Gear) |
|
193 |
else |
|
194 |
dec(Gear^.FrameTicks, Steps) |
|
195 |
end; |
|
196 |
||
197 |
procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword); |
|
198 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
199 |
Gear^.Y:= Gear^.Y - 0.02 * Steps; |
3441 | 200 |
|
201 |
if Gear^.FrameTicks <= Steps then |
|
202 |
DeleteVisualGear(Gear) |
|
203 |
else |
|
204 |
dec(Gear^.FrameTicks, Steps) |
|
205 |
end; |
|
206 |
||
207 |
//////////////////////////////////////////////////////////////////////////////// |
|
208 |
procedure doStepBubble(Gear: PVisualGear; Steps: Longword); |
|
209 |
begin |
|
3909
4ba25a3d15af
remove windspeed from bubbles, remove initial dY from bubbles, apply dY/dX to bubbles, correct offsets on flying saucer flame graphics, add bubbles when flying saucer thrusts underwater, make flying saucer sink more slowly underwater
nemo
parents:
3764
diff
changeset
|
210 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
4ba25a3d15af
remove windspeed from bubbles, remove initial dY from bubbles, apply dY/dX to bubbles, correct offsets on flying saucer flame graphics, add bubbles when flying saucer thrusts underwater, make flying saucer sink more slowly underwater
nemo
parents:
3764
diff
changeset
|
211 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
212 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 213 |
|
4172 | 214 |
Gear^.dX := Gear^.dX / (1.001 * Steps); |
215 |
Gear^.dY := Gear^.dY / (1.001 * Steps); |
|
3909
4ba25a3d15af
remove windspeed from bubbles, remove initial dY from bubbles, apply dY/dX to bubbles, correct offsets on flying saucer flame graphics, add bubbles when flying saucer thrusts underwater, make flying saucer sink more slowly underwater
nemo
parents:
3764
diff
changeset
|
216 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
217 |
if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then |
3441 | 218 |
DeleteVisualGear(Gear) |
219 |
else |
|
220 |
dec(Gear^.FrameTicks, Steps) |
|
221 |
end; |
|
222 |
||
223 |
//////////////////////////////////////////////////////////////////////////////// |
|
224 |
procedure doStepHealth(Gear: PVisualGear; Steps: Longword); |
|
225 |
begin |
|
226 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
227 |
Gear^.Y:= Gear^.Y - Gear^.dY * Steps; |
|
228 |
||
229 |
if Gear^.FrameTicks <= Steps then |
|
230 |
DeleteVisualGear(Gear) |
|
231 |
else |
|
232 |
dec(Gear^.FrameTicks, Steps); |
|
233 |
end; |
|
234 |
||
235 |
//////////////////////////////////////////////////////////////////////////////// |
|
236 |
procedure doStepSteam(Gear: PVisualGear; Steps: Longword); |
|
237 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
238 |
Gear^.X:= Gear^.X + (cWindSpeedf * 100 + Gear^.dX) * Steps; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
239 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 240 |
|
241 |
if Gear^.FrameTicks <= Steps then |
|
242 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
243 |
else |
|
244 |
begin |
|
245 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
246 |
Gear^.FrameTicks:= cExplFrameTicks |
|
247 |
end |
|
248 |
else dec(Gear^.FrameTicks, Steps) |
|
249 |
end; |
|
250 |
||
251 |
//////////////////////////////////////////////////////////////////////////////// |
|
252 |
procedure doStepAmmo(Gear: PVisualGear; Steps: Longword); |
|
253 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
254 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 255 |
|
256 |
Gear^.scale:= Gear^.scale + 0.0025 * Steps; |
|
257 |
Gear^.alpha:= Gear^.alpha - 0.0015 * Steps; |
|
258 |
||
259 |
if Gear^.alpha < 0 then DeleteVisualGear(Gear) |
|
260 |
end; |
|
261 |
||
262 |
//////////////////////////////////////////////////////////////////////////////// |
|
263 |
procedure doStepSmoke(Gear: PVisualGear; Steps: Longword); |
|
264 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
265 |
Gear^.X:= Gear^.X + (cWindSpeedf + Gear^.dX) * Steps; |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
266 |
Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps; |
3441 | 267 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
268 |
Gear^.dX := Gear^.dX + (cWindSpeedf * 0.3 * Steps); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
269 |
//Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995); |
3441 | 270 |
|
271 |
if Gear^.FrameTicks <= Steps then |
|
272 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
273 |
else |
|
274 |
begin |
|
275 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
276 |
Gear^.FrameTicks:= cExplFrameTicks |
|
277 |
end |
|
278 |
else dec(Gear^.FrameTicks, Steps) |
|
279 |
end; |
|
280 |
||
281 |
//////////////////////////////////////////////////////////////////////////////// |
|
282 |
procedure doStepDust(Gear: PVisualGear; Steps: Longword); |
|
283 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
284 |
Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps; |
3441 | 285 |
Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; |
286 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
287 |
Gear^.dX := Gear^.dX - (Gear^.dX * 0.005 * Steps); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
288 |
Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps); |
3441 | 289 |
|
290 |
if Gear^.FrameTicks <= Steps then |
|
291 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
292 |
else |
|
293 |
begin |
|
294 |
dec(Gear^.Frame); |
|
295 |
Gear^.FrameTicks:= cExplFrameTicks |
|
296 |
end |
|
297 |
else dec(Gear^.FrameTicks, Steps) |
|
298 |
end; |
|
299 |
||
300 |
//////////////////////////////////////////////////////////////////////////////// |
|
301 |
procedure doStepSplash(Gear: PVisualGear; Steps: Longword); |
|
302 |
begin |
|
303 |
if Gear^.FrameTicks <= Steps then |
|
304 |
DeleteVisualGear(Gear) |
|
305 |
else |
|
306 |
dec(Gear^.FrameTicks, Steps); |
|
307 |
end; |
|
308 |
||
309 |
//////////////////////////////////////////////////////////////////////////////// |
|
310 |
procedure doStepDroplet(Gear: PVisualGear; Steps: Longword); |
|
311 |
begin |
|
312 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
313 |
||
314 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
315 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 316 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
317 |
if round(Gear^.Y) > cWaterLine then begin |
3441 | 318 |
DeleteVisualGear(Gear); |
319 |
PlaySound(TSound(ord(sndDroplet1) + Random(3))); |
|
320 |
end; |
|
321 |
end; |
|
322 |
||
323 |
//////////////////////////////////////////////////////////////////////////////// |
|
324 |
procedure doStepSmokeRing(Gear: PVisualGear; Steps: Longword); |
|
325 |
begin |
|
326 |
inc(Gear^.Timer, Steps); |
|
327 |
if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear) |
|
328 |
else |
|
329 |
begin |
|
330 |
Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4; |
|
331 |
Gear^.alpha := 1 - power(Gear^.Timer / 350, 4); |
|
332 |
if Gear^.alpha < 0 then Gear^.alpha:= 0; |
|
333 |
end; |
|
334 |
end; |
|
335 |
||
336 |
//////////////////////////////////////////////////////////////////////////////// |
|
337 |
procedure doStepFeather(Gear: PVisualGear; Steps: Longword); |
|
338 |
begin |
|
339 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
340 |
||
341 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
342 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 343 |
|
344 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
345 |
||
346 |
if Gear^.FrameTicks <= Steps then |
|
347 |
DeleteVisualGear(Gear) |
|
348 |
else |
|
349 |
dec(Gear^.FrameTicks, Steps) |
|
350 |
end; |
|
351 |
||
352 |
//////////////////////////////////////////////////////////////////////////////// |
|
353 |
const cSorterWorkTime = 640; |
|
354 |
var thexchar: array[0..cMaxTeams] of |
|
355 |
record |
|
356 |
dy, ny, dw: LongInt; |
|
357 |
team: PTeam; |
|
358 |
SortFactor: QWord; |
|
359 |
end; |
|
360 |
currsorter: PVisualGear = nil; |
|
361 |
||
362 |
procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword); |
|
363 |
var i, t: LongInt; |
|
364 |
begin |
|
365 |
for t:= 1 to Steps do |
|
366 |
begin |
|
367 |
dec(Gear^.Timer); |
|
368 |
if (Gear^.Timer and 15) = 0 then |
|
369 |
for i:= 0 to Pred(TeamsCount) do |
|
370 |
with thexchar[i] do |
|
371 |
begin |
|
372 |
{$WARNINGS OFF} |
|
373 |
team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div 640; |
|
374 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime; |
|
375 |
{$WARNINGS ON} |
|
376 |
end; |
|
377 |
||
378 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
|
379 |
begin |
|
380 |
if currsorter = Gear then currsorter:= nil; |
|
381 |
DeleteVisualGear(Gear); |
|
382 |
exit |
|
383 |
end |
|
384 |
end |
|
385 |
end; |
|
386 |
||
387 |
procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword); |
|
388 |
var i: Longword; |
|
389 |
b: boolean; |
|
390 |
t: LongInt; |
|
391 |
begin |
|
392 |
Steps:= Steps; // avoid compiler hint |
|
393 |
for t:= 0 to Pred(TeamsCount) do |
|
394 |
with thexchar[t] do |
|
395 |
begin |
|
396 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
397 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
398 |
team:= TeamsArray[t]; |
|
399 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
400 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
401 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
402 |
end; |
|
403 |
||
404 |
if TeamsCount > 1 then |
|
405 |
repeat |
|
406 |
b:= true; |
|
407 |
for t:= 0 to TeamsCount - 2 do |
|
408 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
409 |
begin |
|
410 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
411 |
thexchar[t]:= thexchar[Succ(t)]; |
|
412 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
413 |
b:= false |
|
414 |
end |
|
415 |
until b; |
|
416 |
||
417 |
t:= - 4; |
|
418 |
for i:= 0 to Pred(TeamsCount) do |
|
419 |
with thexchar[i] do |
|
420 |
begin |
|
421 |
dec(t, team^.HealthTex^.h + 2); |
|
422 |
ny:= t; |
|
423 |
dy:= dy - ny |
|
424 |
end; |
|
425 |
||
426 |
Gear^.Timer:= cSorterWorkTime; |
|
427 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
428 |
currsorter:= Gear; |
|
429 |
//doStepTeamHealthSorterWork(Gear, Steps) |
|
430 |
end; |
|
431 |
||
432 |
//////////////////////////////////////////////////////////////////////////////// |
|
433 |
procedure doStepSpeechBubbleWork(Gear: PVisualGear; Steps: Longword); |
|
434 |
begin |
|
435 |
if Gear^.Timer > Steps then dec(Gear^.Timer, Steps) else Gear^.Timer:= 0; |
|
436 |
||
437 |
if (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then |
|
438 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
439 |
Gear^.X:= PHedgehog(Gear^.Hedgehog)^.Gear^.X.QWordValue/4294967296 + (Gear^.Tex^.w div 2 - Gear^.FrameTicks); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
440 |
Gear^.Y:= PHedgehog(Gear^.Hedgehog)^.Gear^.Y.QWordValue/4294967296 - (16 + Gear^.Tex^.h); |
3441 | 441 |
end; |
442 |
||
443 |
if Gear^.Timer = 0 then |
|
444 |
begin |
|
445 |
if PHedgehog(Gear^.Hedgehog)^.SpeechGear = Gear then |
|
446 |
PHedgehog(Gear^.Hedgehog)^.SpeechGear:= nil; |
|
447 |
DeleteVisualGear(Gear) |
|
448 |
end; |
|
449 |
end; |
|
450 |
||
451 |
procedure doStepSpeechBubble(Gear: PVisualGear; Steps: Longword); |
|
452 |
begin |
|
453 |
Steps:= Steps; // avoid compiler hint |
|
454 |
||
455 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
456 |
if SpeechGear <> nil then SpeechGear^.Timer:= 0; |
|
457 |
||
458 |
PHedgehog(Gear^.Hedgehog)^.SpeechGear:= Gear; |
|
459 |
||
460 |
Gear^.Timer:= max(Length(Gear^.Text) * 150, 3000); |
|
461 |
||
462 |
Gear^.Tex:= RenderSpeechBubbleTex(Gear^.Text, Gear^.FrameTicks, fnt16); |
|
463 |
||
464 |
case Gear^.FrameTicks of |
|
465 |
1: Gear^.FrameTicks:= SpritesData[sprSpeechTail].Width-28; |
|
466 |
2: Gear^.FrameTicks:= SpritesData[sprThoughtTail].Width-20; |
|
467 |
3: Gear^.FrameTicks:= SpritesData[sprShoutTail].Width-10; |
|
468 |
end; |
|
469 |
||
470 |
Gear^.doStep:= @doStepSpeechBubbleWork; |
|
471 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
472 |
Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h) |
3441 | 473 |
end; |
474 |
||
475 |
//////////////////////////////////////////////////////////////////////////////// |
|
476 |
procedure doStepHealthTagWork(Gear: PVisualGear; Steps: Longword); |
|
477 |
begin |
|
478 |
if Steps > Gear^.Timer then |
|
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
479 |
DeleteVisualGear(Gear) |
3441 | 480 |
else |
481 |
begin |
|
482 |
dec(Gear^.Timer, Steps); |
|
483 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
484 |
end; |
|
485 |
end; |
|
486 |
||
487 |
procedure doStepHealthTagWorkUnderWater(Gear: PVisualGear; Steps: Longword); |
|
488 |
begin |
|
4161 | 489 |
if round(Gear^.Y) - 10 < cWaterLine then |
3441 | 490 |
DeleteVisualGear(Gear) |
491 |
else |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
492 |
Gear^.Y:= Gear^.Y - 0.08 * Steps; |
3441 | 493 |
|
494 |
end; |
|
495 |
||
496 |
procedure doStepHealthTag(Gear: PVisualGear; Steps: Longword); |
|
497 |
var s: shortstring; |
|
498 |
begin |
|
499 |
s:= ''; |
|
500 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
501 |
Gear^.dY:= -0.08; |
3441 | 502 |
|
503 |
str(Gear^.State, s); |
|
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
504 |
if Gear^.Hedgehog <> nil then |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
505 |
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16) |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
506 |
else |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
507 |
Gear^.Tex:= RenderStringTex(s, cWhiteColor, fnt16); |
3441 | 508 |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
509 |
if round(Gear^.Y) < cWaterLine then |
3441 | 510 |
Gear^.doStep:= @doStepHealthTagWork |
511 |
else |
|
512 |
Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
|
513 |
||
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
514 |
Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h); |
3441 | 515 |
|
516 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
517 |
end; |
|
518 |
||
519 |
//////////////////////////////////////////////////////////////////////////////// |
|
520 |
procedure doStepSmokeTrace(Gear: PVisualGear; Steps: Longword); |
|
521 |
begin |
|
522 |
inc(Gear^.Timer, Steps ); |
|
523 |
if Gear^.Timer > 64 then |
|
524 |
begin |
|
3995
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
525 |
if Gear^.State = 0 then |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
526 |
begin |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
527 |
DeleteVisualGear(Gear); |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
528 |
exit; |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
529 |
end; |
3441 | 530 |
dec(Gear^.State, Gear^.Timer div 65); |
531 |
Gear^.Timer:= Gear^.Timer mod 65; |
|
532 |
end; |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
533 |
Gear^.dX:= Gear^.dX + cWindSpeedf * Steps; |
3587 | 534 |
Gear^.X:= Gear^.X + Gear^.dX; |
3441 | 535 |
end; |
536 |
||
537 |
//////////////////////////////////////////////////////////////////////////////// |
|
538 |
procedure doStepExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
539 |
begin |
|
540 |
inc(Gear^.Timer, Steps); |
|
541 |
if Gear^.Timer > 75 then |
|
542 |
begin |
|
543 |
inc(Gear^.State, Gear^.Timer div 76); |
|
544 |
Gear^.Timer:= Gear^.Timer mod 76; |
|
545 |
if Gear^.State > 5 then DeleteVisualGear(Gear); |
|
546 |
end; |
|
547 |
end; |
|
548 |
||
549 |
procedure doStepExplosion(Gear: PVisualGear; Steps: Longword); |
|
550 |
var i: LongWord; |
|
3590 | 551 |
gX,gY: LongInt; |
3441 | 552 |
begin |
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
553 |
gX:= round(Gear^.X); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
554 |
gY:= round(Gear^.Y); |
3590 | 555 |
for i:= 0 to 31 do AddVisualGear(gX, gY, vgtFire); |
556 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart); |
|
557 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart2); |
|
3441 | 558 |
Gear^.doStep:= @doStepExplosionWork; |
559 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
560 |
end; |
|
561 |
||
562 |
||
563 |
//////////////////////////////////////////////////////////////////////////////// |
|
564 |
procedure doStepBigExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
3587 | 565 |
//var maxMovement: LongInt; |
3441 | 566 |
begin |
567 |
||
568 |
inc(Gear^.Timer, Steps); |
|
3466
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
569 |
(* |
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
570 |
FIXME - This block desyncs due to the way WorldDx is important for various things network related. |
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
571 |
One possible solution is, instead of using WorldDx, to use straight gl/SDL calls to jitter the screen a bit. |
3441 | 572 |
if (Gear^.Timer and 5) = 0 then |
573 |
begin |
|
574 |
maxMovement := max(1, 13 - ((Gear^.Timer * 15) div 250)); |
|
575 |
ShakeCamera(maxMovement); |
|
576 |
end; |
|
3466
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
577 |
*) |
3441 | 578 |
if Gear^.Timer > 250 then DeleteVisualGear(Gear); |
579 |
end; |
|
580 |
||
581 |
procedure doStepBigExplosion(Gear: PVisualGear; Steps: Longword); |
|
582 |
var i: LongWord; |
|
583 |
gX,gY: LongInt; |
|
584 |
begin |
|
3593
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
585 |
gX:= round(Gear^.X); |
ae50f63e4fa9
Remove hwFloat from VisualGears - they don't need the precision for syncing purposes, and it saves a whole lot of operations.
nemo
parents:
3592
diff
changeset
|
586 |
gY:= round(Gear^.Y); |
3441 | 587 |
AddVisualGear(gX, gY, vgtSmokeRing); |
588 |
for i:= 0 to 46 do AddVisualGear(gX, gY, vgtFire); |
|
589 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart); |
|
590 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart2); |
|
591 |
Gear^.doStep:= @doStepBigExplosionWork; |
|
592 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
4034
634a8c8682de
add some phone rumbling to big explosions, airbomb and sinegun
koda
parents:
3995
diff
changeset
|
593 |
performRumble(); |
3441 | 594 |
end; |
3689 | 595 |
|
596 |
procedure doStepChunk(Gear: PVisualGear; Steps: Longword); |
|
597 |
begin |
|
598 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
599 |
||
600 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
601 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
|
602 |
||
603 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
604 |
||
605 |
if round(Gear^.Y) > cWaterLine then |
|
606 |
begin |
|
3699 | 607 |
AddVisualGear(round(Gear^.X), round(Gear^.Y), vgtDroplet); |
3689 | 608 |
DeleteVisualGear(Gear); |
609 |
end |
|
610 |
end; |