author | koda |
Sat, 03 Jul 2010 15:31:36 +0200 | |
changeset 3620 | c28a86f379f6 |
parent 3611 | ed00aa2b339e |
child 3641 | 98319a621dc8 |
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 |
3611 | 21 |
if ((cReducedQuality and rqkillFlakes) <> 0) then exit; |
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; |
36 |
||
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
|
37 |
if (round(X) >= -cScreenWidth - 64) and |
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
|
38 |
(round(X) <= cScreenWidth + LAND_WIDTH) and |
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
|
39 |
(round(Y) <= (LAND_HEIGHT + 75)) and |
3441 | 40 |
(Timer > 0) and (Timer-Steps > 0) then |
41 |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then tdY:= 0; |
3441 | 50 |
dec(Timer, Steps) |
51 |
end |
|
52 |
else |
|
53 |
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
|
54 |
if round(X) < -cScreenWidth - 64 then X:= float(cScreenWidth + LAND_WIDTH) else |
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 round(X) > cScreenWidth + LAND_WIDTH then X:= float(-cScreenWidth - 64); |
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
|
56 |
// if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + float(25); // For if flag is set for flakes rising upwards? |
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
|
57 |
if round(Y) > (LAND_HEIGHT + 75) then Y:= Y - float(1024 + 150); // TODO - configure in theme (jellies for example could use limited range) |
3441 | 58 |
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
|
59 |
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
|
60 |
tdY:= 0 |
3441 | 61 |
end; |
62 |
end; |
|
63 |
||
64 |
end; |
|
65 |
||
66 |
//////////////////////////////////////////////////////////////////////////////// |
|
67 |
procedure doStepBeeTrace(Gear: PVisualGear; Steps: Longword); |
|
68 |
begin |
|
69 |
if Gear^.FrameTicks > Steps then |
|
70 |
dec(Gear^.FrameTicks, Steps) |
|
71 |
else |
|
72 |
DeleteVisualGear(Gear); |
|
73 |
end; |
|
74 |
||
75 |
//////////////////////////////////////////////////////////////////////////////// |
|
76 |
procedure doStepCloud(Gear: PVisualGear; Steps: Longword); |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
77 |
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
|
78 |
t: float; |
3441 | 79 |
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
|
80 |
Gear^.X:= Gear^.X + (cWindSpeedf * 200 + Gear^.dX) * Steps; |
3441 | 81 |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
82 |
// 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
|
83 |
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
|
84 |
t := 8 * AngleSin(s mod 2048).QWordValue / 4294967296; |
3597
978c30ef50fc
visual gears: fixing nemo's c-style assignment/multiplications
sheepluva
parents:
3593
diff
changeset
|
85 |
if (s < 2048) then t := -t; |
3441 | 86 |
|
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
|
87 |
Gear^.Y := LAND_HEIGHT-1184 + Gear^.Timer mod 8 + t; |
3441 | 88 |
|
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 |
if round(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= float(cScreenWidth + LAND_WIDTH) else |
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 |
if round(Gear^.X) > cScreenWidth + LAND_WIDTH then Gear^.X:= float(-cScreenWidth - 256) |
3441 | 91 |
end; |
92 |
||
93 |
//////////////////////////////////////////////////////////////////////////////// |
|
94 |
procedure doStepExpl(Gear: PVisualGear; Steps: Longword); |
|
95 |
begin |
|
96 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
97 |
||
98 |
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
|
99 |
//Gear^.dY:= Gear^.dY + cGravityf; |
3441 | 100 |
|
101 |
if Gear^.FrameTicks <= Steps then |
|
102 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
103 |
else |
|
104 |
begin |
|
105 |
dec(Gear^.Frame); |
|
106 |
Gear^.FrameTicks:= cExplFrameTicks |
|
107 |
end |
|
108 |
else dec(Gear^.FrameTicks, Steps) |
|
109 |
end; |
|
110 |
||
111 |
//////////////////////////////////////////////////////////////////////////////// |
|
112 |
procedure doStepEgg(Gear: PVisualGear; Steps: Longword); |
|
113 |
begin |
|
114 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
115 |
||
116 |
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
|
117 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 118 |
|
119 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
120 |
||
121 |
if Gear^.FrameTicks <= Steps then |
|
122 |
DeleteVisualGear(Gear) |
|
123 |
else |
|
124 |
dec(Gear^.FrameTicks, Steps) |
|
125 |
end; |
|
126 |
||
127 |
//////////////////////////////////////////////////////////////////////////////// |
|
128 |
procedure doStepFire(Gear: PVisualGear; Steps: Longword); |
|
129 |
begin |
|
130 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
131 |
||
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
|
132 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravityf * (Steps * 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
|
133 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 134 |
|
135 |
if Gear^.FrameTicks <= Steps then |
|
136 |
DeleteVisualGear(Gear) |
|
137 |
else |
|
138 |
dec(Gear^.FrameTicks, Steps) |
|
139 |
end; |
|
140 |
||
141 |
//////////////////////////////////////////////////////////////////////////////// |
|
142 |
procedure doStepShell(Gear: PVisualGear; Steps: Longword); |
|
143 |
begin |
|
144 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
145 |
||
146 |
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
|
147 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 148 |
|
149 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
150 |
||
151 |
if Gear^.FrameTicks <= Steps then |
|
152 |
DeleteVisualGear(Gear) |
|
153 |
else |
|
154 |
dec(Gear^.FrameTicks, Steps) |
|
155 |
end; |
|
156 |
||
157 |
procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword); |
|
158 |
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
|
159 |
Gear^.Y:= Gear^.Y - 0.02 * Steps; |
3441 | 160 |
|
161 |
if Gear^.FrameTicks <= Steps then |
|
162 |
DeleteVisualGear(Gear) |
|
163 |
else |
|
164 |
dec(Gear^.FrameTicks, Steps) |
|
165 |
end; |
|
166 |
||
167 |
//////////////////////////////////////////////////////////////////////////////// |
|
168 |
procedure doStepBubble(Gear: PVisualGear; Steps: Longword); |
|
169 |
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
|
170 |
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
|
171 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 172 |
|
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
|
173 |
if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then |
3441 | 174 |
DeleteVisualGear(Gear) |
175 |
else |
|
176 |
dec(Gear^.FrameTicks, Steps) |
|
177 |
end; |
|
178 |
||
179 |
//////////////////////////////////////////////////////////////////////////////// |
|
180 |
procedure doStepHealth(Gear: PVisualGear; Steps: Longword); |
|
181 |
begin |
|
182 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
183 |
Gear^.Y:= Gear^.Y - Gear^.dY * Steps; |
|
184 |
||
185 |
if Gear^.FrameTicks <= Steps then |
|
186 |
DeleteVisualGear(Gear) |
|
187 |
else |
|
188 |
dec(Gear^.FrameTicks, Steps); |
|
189 |
end; |
|
190 |
||
191 |
//////////////////////////////////////////////////////////////////////////////// |
|
192 |
procedure doStepSteam(Gear: PVisualGear; Steps: Longword); |
|
193 |
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
|
194 |
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
|
195 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 196 |
|
197 |
if Gear^.FrameTicks <= Steps then |
|
198 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
199 |
else |
|
200 |
begin |
|
201 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
202 |
Gear^.FrameTicks:= cExplFrameTicks |
|
203 |
end |
|
204 |
else dec(Gear^.FrameTicks, Steps) |
|
205 |
end; |
|
206 |
||
207 |
//////////////////////////////////////////////////////////////////////////////// |
|
208 |
procedure doStepAmmo(Gear: PVisualGear; Steps: Longword); |
|
209 |
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
|
210 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 211 |
|
212 |
Gear^.scale:= Gear^.scale + 0.0025 * Steps; |
|
213 |
Gear^.alpha:= Gear^.alpha - 0.0015 * Steps; |
|
214 |
||
215 |
if Gear^.alpha < 0 then DeleteVisualGear(Gear) |
|
216 |
end; |
|
217 |
||
218 |
//////////////////////////////////////////////////////////////////////////////// |
|
219 |
procedure doStepSmoke(Gear: PVisualGear; Steps: Longword); |
|
220 |
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
|
221 |
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
|
222 |
Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps; |
3441 | 223 |
|
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
|
224 |
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
|
225 |
//Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995); |
3441 | 226 |
|
227 |
if Gear^.FrameTicks <= Steps then |
|
228 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
229 |
else |
|
230 |
begin |
|
231 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
232 |
Gear^.FrameTicks:= cExplFrameTicks |
|
233 |
end |
|
234 |
else dec(Gear^.FrameTicks, Steps) |
|
235 |
end; |
|
236 |
||
237 |
//////////////////////////////////////////////////////////////////////////////// |
|
238 |
procedure doStepDust(Gear: PVisualGear; Steps: Longword); |
|
239 |
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
|
240 |
Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps; |
3441 | 241 |
Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; |
242 |
||
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
|
243 |
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
|
244 |
Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps); |
3441 | 245 |
|
246 |
if Gear^.FrameTicks <= Steps then |
|
247 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
248 |
else |
|
249 |
begin |
|
250 |
dec(Gear^.Frame); |
|
251 |
Gear^.FrameTicks:= cExplFrameTicks |
|
252 |
end |
|
253 |
else dec(Gear^.FrameTicks, Steps) |
|
254 |
end; |
|
255 |
||
256 |
//////////////////////////////////////////////////////////////////////////////// |
|
257 |
procedure doStepSplash(Gear: PVisualGear; Steps: Longword); |
|
258 |
begin |
|
259 |
if Gear^.FrameTicks <= Steps then |
|
260 |
DeleteVisualGear(Gear) |
|
261 |
else |
|
262 |
dec(Gear^.FrameTicks, Steps); |
|
263 |
end; |
|
264 |
||
265 |
//////////////////////////////////////////////////////////////////////////////// |
|
266 |
procedure doStepDroplet(Gear: PVisualGear; Steps: Longword); |
|
267 |
begin |
|
268 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
269 |
||
270 |
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
|
271 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 272 |
|
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
|
273 |
if round(Gear^.Y) > cWaterLine then begin |
3441 | 274 |
DeleteVisualGear(Gear); |
275 |
PlaySound(TSound(ord(sndDroplet1) + Random(3))); |
|
276 |
end; |
|
277 |
end; |
|
278 |
||
279 |
//////////////////////////////////////////////////////////////////////////////// |
|
280 |
procedure doStepSmokeRing(Gear: PVisualGear; Steps: Longword); |
|
281 |
begin |
|
282 |
inc(Gear^.Timer, Steps); |
|
283 |
if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear) |
|
284 |
else |
|
285 |
begin |
|
286 |
Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4; |
|
287 |
Gear^.alpha := 1 - power(Gear^.Timer / 350, 4); |
|
288 |
if Gear^.alpha < 0 then Gear^.alpha:= 0; |
|
289 |
end; |
|
290 |
end; |
|
291 |
||
292 |
//////////////////////////////////////////////////////////////////////////////// |
|
293 |
procedure doStepFeather(Gear: PVisualGear; Steps: Longword); |
|
294 |
begin |
|
295 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
296 |
||
297 |
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
|
298 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 299 |
|
300 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
301 |
||
302 |
if Gear^.FrameTicks <= Steps then |
|
303 |
DeleteVisualGear(Gear) |
|
304 |
else |
|
305 |
dec(Gear^.FrameTicks, Steps) |
|
306 |
end; |
|
307 |
||
308 |
//////////////////////////////////////////////////////////////////////////////// |
|
309 |
const cSorterWorkTime = 640; |
|
310 |
var thexchar: array[0..cMaxTeams] of |
|
311 |
record |
|
312 |
dy, ny, dw: LongInt; |
|
313 |
team: PTeam; |
|
314 |
SortFactor: QWord; |
|
315 |
end; |
|
316 |
currsorter: PVisualGear = nil; |
|
317 |
||
318 |
procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword); |
|
319 |
var i, t: LongInt; |
|
320 |
begin |
|
321 |
for t:= 1 to Steps do |
|
322 |
begin |
|
323 |
dec(Gear^.Timer); |
|
324 |
if (Gear^.Timer and 15) = 0 then |
|
325 |
for i:= 0 to Pred(TeamsCount) do |
|
326 |
with thexchar[i] do |
|
327 |
begin |
|
328 |
{$WARNINGS OFF} |
|
329 |
team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div 640; |
|
330 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime; |
|
331 |
{$WARNINGS ON} |
|
332 |
end; |
|
333 |
||
334 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
|
335 |
begin |
|
336 |
if currsorter = Gear then currsorter:= nil; |
|
337 |
DeleteVisualGear(Gear); |
|
338 |
exit |
|
339 |
end |
|
340 |
end |
|
341 |
end; |
|
342 |
||
343 |
procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword); |
|
344 |
var i: Longword; |
|
345 |
b: boolean; |
|
346 |
t: LongInt; |
|
347 |
begin |
|
348 |
Steps:= Steps; // avoid compiler hint |
|
349 |
for t:= 0 to Pred(TeamsCount) do |
|
350 |
with thexchar[t] do |
|
351 |
begin |
|
352 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
353 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
354 |
team:= TeamsArray[t]; |
|
355 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
356 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
357 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
358 |
end; |
|
359 |
||
360 |
if TeamsCount > 1 then |
|
361 |
repeat |
|
362 |
b:= true; |
|
363 |
for t:= 0 to TeamsCount - 2 do |
|
364 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
365 |
begin |
|
366 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
367 |
thexchar[t]:= thexchar[Succ(t)]; |
|
368 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
369 |
b:= false |
|
370 |
end |
|
371 |
until b; |
|
372 |
||
373 |
t:= - 4; |
|
374 |
for i:= 0 to Pred(TeamsCount) do |
|
375 |
with thexchar[i] do |
|
376 |
begin |
|
377 |
dec(t, team^.HealthTex^.h + 2); |
|
378 |
ny:= t; |
|
379 |
dy:= dy - ny |
|
380 |
end; |
|
381 |
||
382 |
Gear^.Timer:= cSorterWorkTime; |
|
383 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
384 |
currsorter:= Gear; |
|
385 |
//doStepTeamHealthSorterWork(Gear, Steps) |
|
386 |
end; |
|
387 |
||
388 |
//////////////////////////////////////////////////////////////////////////////// |
|
389 |
procedure doStepSpeechBubbleWork(Gear: PVisualGear; Steps: Longword); |
|
390 |
begin |
|
391 |
if Gear^.Timer > Steps then dec(Gear^.Timer, Steps) else Gear^.Timer:= 0; |
|
392 |
||
393 |
if (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then |
|
394 |
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
|
395 |
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
|
396 |
Gear^.Y:= PHedgehog(Gear^.Hedgehog)^.Gear^.Y.QWordValue/4294967296 - (16 + Gear^.Tex^.h); |
3441 | 397 |
end; |
398 |
||
399 |
if Gear^.Timer = 0 then |
|
400 |
begin |
|
401 |
if PHedgehog(Gear^.Hedgehog)^.SpeechGear = Gear then |
|
402 |
PHedgehog(Gear^.Hedgehog)^.SpeechGear:= nil; |
|
403 |
DeleteVisualGear(Gear) |
|
404 |
end; |
|
405 |
end; |
|
406 |
||
407 |
procedure doStepSpeechBubble(Gear: PVisualGear; Steps: Longword); |
|
408 |
begin |
|
409 |
Steps:= Steps; // avoid compiler hint |
|
410 |
||
411 |
with PHedgehog(Gear^.Hedgehog)^ do |
|
412 |
if SpeechGear <> nil then SpeechGear^.Timer:= 0; |
|
413 |
||
414 |
PHedgehog(Gear^.Hedgehog)^.SpeechGear:= Gear; |
|
415 |
||
416 |
Gear^.Timer:= max(Length(Gear^.Text) * 150, 3000); |
|
417 |
||
418 |
Gear^.Tex:= RenderSpeechBubbleTex(Gear^.Text, Gear^.FrameTicks, fnt16); |
|
419 |
||
420 |
case Gear^.FrameTicks of |
|
421 |
1: Gear^.FrameTicks:= SpritesData[sprSpeechTail].Width-28; |
|
422 |
2: Gear^.FrameTicks:= SpritesData[sprThoughtTail].Width-20; |
|
423 |
3: Gear^.FrameTicks:= SpritesData[sprShoutTail].Width-10; |
|
424 |
end; |
|
425 |
||
426 |
Gear^.doStep:= @doStepSpeechBubbleWork; |
|
427 |
||
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
|
428 |
Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h) |
3441 | 429 |
end; |
430 |
||
431 |
//////////////////////////////////////////////////////////////////////////////// |
|
432 |
procedure doStepHealthTagWork(Gear: PVisualGear; Steps: Longword); |
|
433 |
begin |
|
434 |
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
|
435 |
DeleteVisualGear(Gear) |
3441 | 436 |
else |
437 |
begin |
|
438 |
dec(Gear^.Timer, Steps); |
|
439 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
440 |
end; |
|
441 |
end; |
|
442 |
||
443 |
procedure doStepHealthTagWorkUnderWater(Gear: PVisualGear; Steps: Longword); |
|
444 |
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
|
445 |
if round(Gear^.Y) < cWaterLine + 10 then |
3441 | 446 |
DeleteVisualGear(Gear) |
447 |
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
|
448 |
Gear^.Y:= Gear^.Y - 0.08 * Steps; |
3441 | 449 |
|
450 |
end; |
|
451 |
||
452 |
procedure doStepHealthTag(Gear: PVisualGear; Steps: Longword); |
|
453 |
var s: shortstring; |
|
454 |
begin |
|
455 |
s:= ''; |
|
456 |
||
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
|
457 |
Gear^.dY:= -0.08; |
3441 | 458 |
|
459 |
str(Gear^.State, s); |
|
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
460 |
if Gear^.Hedgehog <> nil then |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
461 |
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
|
462 |
else |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
463 |
Gear^.Tex:= RenderStringTex(s, cWhiteColor, fnt16); |
3441 | 464 |
|
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
|
465 |
if round(Gear^.Y) < cWaterLine then |
3441 | 466 |
Gear^.doStep:= @doStepHealthTagWork |
467 |
else |
|
468 |
Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
|
469 |
||
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
|
470 |
Gear^.Y:= Gear^.Y - float(Gear^.Tex^.h); |
3441 | 471 |
|
472 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
473 |
end; |
|
474 |
||
475 |
//////////////////////////////////////////////////////////////////////////////// |
|
476 |
procedure doStepSmokeTrace(Gear: PVisualGear; Steps: Longword); |
|
477 |
begin |
|
478 |
inc(Gear^.Timer, Steps ); |
|
479 |
if Gear^.Timer > 64 then |
|
480 |
begin |
|
481 |
dec(Gear^.State, Gear^.Timer div 65); |
|
482 |
Gear^.Timer:= Gear^.Timer mod 65; |
|
483 |
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
|
484 |
Gear^.dX:= Gear^.dX + cWindSpeedf * Steps; |
3587 | 485 |
Gear^.X:= Gear^.X + Gear^.dX; |
3441 | 486 |
if Gear^.State = 0 then DeleteVisualGear(Gear); |
487 |
end; |
|
488 |
||
489 |
//////////////////////////////////////////////////////////////////////////////// |
|
490 |
procedure doStepExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
491 |
begin |
|
492 |
inc(Gear^.Timer, Steps); |
|
493 |
if Gear^.Timer > 75 then |
|
494 |
begin |
|
495 |
inc(Gear^.State, Gear^.Timer div 76); |
|
496 |
Gear^.Timer:= Gear^.Timer mod 76; |
|
497 |
if Gear^.State > 5 then DeleteVisualGear(Gear); |
|
498 |
end; |
|
499 |
end; |
|
500 |
||
501 |
procedure doStepExplosion(Gear: PVisualGear; Steps: Longword); |
|
502 |
var i: LongWord; |
|
3590 | 503 |
gX,gY: LongInt; |
3441 | 504 |
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
|
505 |
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
|
506 |
gY:= round(Gear^.Y); |
3590 | 507 |
for i:= 0 to 31 do AddVisualGear(gX, gY, vgtFire); |
508 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart); |
|
509 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart2); |
|
3441 | 510 |
Gear^.doStep:= @doStepExplosionWork; |
511 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
512 |
end; |
|
513 |
||
514 |
||
515 |
//////////////////////////////////////////////////////////////////////////////// |
|
516 |
procedure doStepBigExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
3587 | 517 |
//var maxMovement: LongInt; |
3441 | 518 |
begin |
519 |
||
520 |
inc(Gear^.Timer, Steps); |
|
3466
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
521 |
(* |
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
522 |
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
|
523 |
One possible solution is, instead of using WorldDx, to use straight gl/SDL calls to jitter the screen a bit. |
3441 | 524 |
if (Gear^.Timer and 5) = 0 then |
525 |
begin |
|
526 |
maxMovement := max(1, 13 - ((Gear^.Timer * 15) div 250)); |
|
527 |
ShakeCamera(maxMovement); |
|
528 |
end; |
|
3466
78d9fa9a700e
Comment out the desyncing block, with a suggestion for possible fix
nemo
parents:
3459
diff
changeset
|
529 |
*) |
3441 | 530 |
if Gear^.Timer > 250 then DeleteVisualGear(Gear); |
531 |
end; |
|
532 |
||
533 |
procedure doStepBigExplosion(Gear: PVisualGear; Steps: Longword); |
|
534 |
var i: LongWord; |
|
535 |
gX,gY: LongInt; |
|
536 |
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
|
537 |
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
|
538 |
gY:= round(Gear^.Y); |
3441 | 539 |
AddVisualGear(gX, gY, vgtSmokeRing); |
540 |
for i:= 0 to 46 do AddVisualGear(gX, gY, vgtFire); |
|
541 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart); |
|
542 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart2); |
|
543 |
Gear^.doStep:= @doStepBigExplosionWork; |
|
544 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
545 |
end; |