author | sheepluva |
Sun, 30 Oct 2011 17:31:53 +0100 | |
changeset 6242 | 27297c421bbc |
parent 6179 | b529f88d37d0 |
child 6291 | cfd2483b8c97 |
permissions | -rw-r--r-- |
3441 | 1 |
(* |
2 |
* Hedgewars, a free turn based strategy game |
|
4976 | 3 |
* Copyright (c) 2004-2011 Andrey Korotaev <unC0Rr@gmail.com> |
3441 | 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 |
*) |
|
5121
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
18 |
|
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
19 |
(* |
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
20 |
* This file contains the step handlers for visual gears. |
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
21 |
* |
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
22 |
* Since the effects of visual gears do not affect the course of the game, |
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
23 |
* no "synchronization" between players is required. |
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
24 |
* => The usage of safe functions or data types (e.g. GetRandom() or hwFloat) |
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
25 |
* is usually not necessary and therefore undesirable. |
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
26 |
*) |
2d34ec60992c
added some comments in order to confuse the GSoC students as much as possible ;D
sheepluva
parents:
4976
diff
changeset
|
27 |
|
3441 | 28 |
procedure doStepFlake(Gear: PVisualGear; Steps: Longword); |
4379
6cd6b77df8b8
No need for Extended data type just to draw some visual gears. It's a shame we have Math unit dependency
unC0Rr
parents:
4365
diff
changeset
|
29 |
var sign: real; |
3441 | 30 |
begin |
3641 | 31 |
if vobCount = 0 then exit; |
3611 | 32 |
|
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 |
sign:= 1; |
3441 | 34 |
with Gear^ do |
35 |
begin |
|
36 |
inc(FrameTicks, Steps); |
|
4806
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
37 |
if not SuddenDeathDmg and (FrameTicks > vobFrameTicks) then |
3441 | 38 |
begin |
39 |
dec(FrameTicks, vobFrameTicks); |
|
40 |
inc(Frame); |
|
41 |
if Frame = vobFramesCount then Frame:= 0 |
|
4806
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
42 |
end |
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
43 |
else if SuddenDeathDmg and (FrameTicks > vobSDFrameTicks) then |
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
44 |
begin |
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
45 |
dec(FrameTicks, vobSDFrameTicks); |
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
46 |
inc(Frame); |
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
47 |
if Frame = vobSDFramesCount then Frame:= 0 |
3441 | 48 |
end; |
5355 | 49 |
X:= X + (cWindSpeedf * 400 + dX + tdX) * Steps; |
4806
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
50 |
if SuddenDeathDmg then |
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
51 |
Y:= Y + (dY + tdY + cGravityf * vobSDFallSpeed) * Steps |
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
52 |
else |
48c1a395f0a7
added flake configuration also in sudden death and SDClouds for underwater
Henek
parents:
4475
diff
changeset
|
53 |
Y:= Y + (dY + tdY + cGravityf * vobFallSpeed) * Steps; |
3441 | 54 |
Angle:= Angle + dAngle * Steps; |
4152
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
55 |
if Angle > 360 then |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
56 |
Angle:= Angle - 360 |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
57 |
else |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
58 |
if Angle < - 360 then |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
59 |
Angle:= Angle + 360; |
07008cb354f9
Prevent vgtFlake's rotation angle to grow too high in its absolute value
unc0rr
parents:
4034
diff
changeset
|
60 |
|
3441 | 61 |
|
3764 | 62 |
if (round(X) >= cLeftScreenBorder) and |
63 |
(round(X) <= cRightScreenBorder) and |
|
4161 | 64 |
(round(Y) - 75 <= LAND_HEIGHT) and |
3441 | 65 |
(Timer > 0) and (Timer-Steps > 0) then |
66 |
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
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
if ((sign < 0) and (tdY > 0)) or ((sign > 0) and (tdY < 0)) then tdY:= 0; |
3441 | 75 |
dec(Timer, Steps) |
76 |
end |
|
77 |
else |
|
78 |
begin |
|
3764 | 79 |
if round(X) < cLeftScreenBorder then X:= X + cScreenSpace else |
80 |
if round(X) > cRightScreenBorder then X:= X - cScreenSpace; |
|
4379
6cd6b77df8b8
No need for Extended data type just to draw some visual gears. It's a shame we have Math unit dependency
unC0Rr
parents:
4365
diff
changeset
|
81 |
// if round(Y) < (LAND_HEIGHT - 1024 - 75) then Y:= Y + 25.0; // For if flag is set for flakes rising upwards? |
6179
b529f88d37d0
Bit of an experiment with giving flakes a bit more depth. Might need to be theme flagged, or theme flakes reworked on some themes. Looks neat in stereo. Also finally use an array for the layers
nemo
parents:
6128
diff
changeset
|
82 |
if round(Y) - 225 > LAND_HEIGHT then Y:= Y - (1024 + 300); // TODO - configure in theme (jellies for example could use limited range) |
3441 | 83 |
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
|
84 |
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
|
85 |
tdY:= 0 |
3441 | 86 |
end; |
87 |
end; |
|
88 |
||
89 |
end; |
|
90 |
||
91 |
//////////////////////////////////////////////////////////////////////////////// |
|
92 |
procedure doStepBeeTrace(Gear: PVisualGear; Steps: Longword); |
|
93 |
begin |
|
94 |
if Gear^.FrameTicks > Steps then |
|
95 |
dec(Gear^.FrameTicks, Steps) |
|
96 |
else |
|
97 |
DeleteVisualGear(Gear); |
|
98 |
end; |
|
99 |
||
100 |
//////////////////////////////////////////////////////////////////////////////// |
|
101 |
procedure doStepCloud(Gear: PVisualGear; Steps: Longword); |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
102 |
var s: Longword; |
4379
6cd6b77df8b8
No need for Extended data type just to draw some visual gears. It's a shame we have Math unit dependency
unC0Rr
parents:
4365
diff
changeset
|
103 |
t: real; |
3441 | 104 |
begin |
3994
486da687d76a
fix/tweak let clouds reflect wind speed and direction again + stronger
sheepluva
parents:
3976
diff
changeset
|
105 |
Gear^.X:= Gear^.X + (cWindSpeedf * 750 * Gear^.dX) * Steps; |
3441 | 106 |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
107 |
// 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
|
108 |
s := (GameTicks + Gear^.Timer) mod 4096; |
5151
cbadb9fa52fc
An experiment - make bazooka AI use float instead of hwFloat - should be as accurate, but faster.
nemo
parents:
5121
diff
changeset
|
109 |
t := 8 * hwFloat2Float(AngleSin(s mod 2048)); |
3597
978c30ef50fc
visual gears: fixing nemo's c-style assignment/multiplications
sheepluva
parents:
3593
diff
changeset
|
110 |
if (s < 2048) then t := -t; |
3441 | 111 |
|
4161 | 112 |
Gear^.Y := LAND_HEIGHT - 1184 + LongInt(Gear^.Timer mod 8) + t; |
3441 | 113 |
|
3764 | 114 |
if round(Gear^.X) < cLeftScreenBorder then Gear^.X:= Gear^.X + cScreenSpace else |
115 |
if round(Gear^.X) > cRightScreenBorder then Gear^.X:= Gear^.X - cScreenSpace |
|
3441 | 116 |
end; |
117 |
||
118 |
//////////////////////////////////////////////////////////////////////////////// |
|
119 |
procedure doStepExpl(Gear: PVisualGear; Steps: Longword); |
|
120 |
begin |
|
121 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
122 |
||
123 |
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
|
124 |
//Gear^.dY:= Gear^.dY + cGravityf; |
3441 | 125 |
|
126 |
if Gear^.FrameTicks <= Steps then |
|
127 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
128 |
else |
|
129 |
begin |
|
130 |
dec(Gear^.Frame); |
|
131 |
Gear^.FrameTicks:= cExplFrameTicks |
|
132 |
end |
|
133 |
else dec(Gear^.FrameTicks, Steps) |
|
134 |
end; |
|
135 |
||
136 |
//////////////////////////////////////////////////////////////////////////////// |
|
3704 | 137 |
procedure doStepNote(Gear: PVisualGear; Steps: Longword); |
138 |
begin |
|
139 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
140 |
||
141 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3706 | 142 |
Gear^.dY:= Gear^.dY + cGravityf * Steps / 2; |
3704 | 143 |
|
3706 | 144 |
Gear^.Angle:= Gear^.Angle + (Gear^.Frame + 1) * Steps / 10; |
145 |
while Gear^.Angle > cMaxAngle do |
|
146 |
Gear^.Angle:= Gear^.Angle - cMaxAngle; |
|
3704 | 147 |
|
148 |
if Gear^.FrameTicks <= Steps then |
|
149 |
DeleteVisualGear(Gear) |
|
150 |
else |
|
151 |
dec(Gear^.FrameTicks, Steps) |
|
152 |
end; |
|
153 |
||
154 |
//////////////////////////////////////////////////////////////////////////////// |
|
4279 | 155 |
procedure doStepLineTrail(Gear: PVisualGear; Steps: Longword); |
156 |
begin |
|
157 |
Steps := Steps; |
|
158 |
if Gear^.Timer <= Steps then |
|
159 |
DeleteVisualGear(Gear) |
|
160 |
else |
|
161 |
dec(Gear^.Timer, Steps) |
|
162 |
end; |
|
163 |
||
164 |
//////////////////////////////////////////////////////////////////////////////// |
|
3441 | 165 |
procedure doStepEgg(Gear: PVisualGear; Steps: Longword); |
166 |
begin |
|
167 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
168 |
||
169 |
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
|
170 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 171 |
|
172 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
173 |
||
174 |
if Gear^.FrameTicks <= Steps then |
|
6128 | 175 |
begin |
176 |
DeleteVisualGear(Gear); |
|
177 |
exit |
|
178 |
end |
|
3441 | 179 |
else |
5874
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5855
diff
changeset
|
180 |
dec(Gear^.FrameTicks, Steps); |
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5855
diff
changeset
|
181 |
|
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5855
diff
changeset
|
182 |
if Gear^.FrameTicks < $FF then |
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5855
diff
changeset
|
183 |
Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or Gear^.FrameTicks |
3441 | 184 |
end; |
185 |
||
186 |
//////////////////////////////////////////////////////////////////////////////// |
|
187 |
procedure doStepFire(Gear: PVisualGear; Steps: Longword); |
|
3751 | 188 |
var vgt: PVisualGear; |
3441 | 189 |
begin |
190 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
191 |
||
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
|
192 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravityf * (Steps * Steps); |
3751 | 193 |
if (Gear^.State and gstTmpFlag) = 0 then |
194 |
begin |
|
195 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
|
3764 | 196 |
if ((GameTicks mod 200) < Steps + 1) then |
3751 | 197 |
begin |
198 |
vgt:= AddVisualGear(round(Gear^.X), round(Gear^.Y), vgtFire); |
|
199 |
if vgt <> nil then |
|
200 |
begin |
|
201 |
vgt^.dx:= 0; |
|
202 |
vgt^.dy:= 0; |
|
203 |
vgt^.State:= gstTmpFlag; |
|
204 |
end; |
|
205 |
end |
|
206 |
end |
|
207 |
else |
|
208 |
inc(Steps, Steps); |
|
3441 | 209 |
|
210 |
if Gear^.FrameTicks <= Steps then |
|
211 |
DeleteVisualGear(Gear) |
|
212 |
else |
|
213 |
dec(Gear^.FrameTicks, Steps) |
|
214 |
end; |
|
215 |
||
216 |
//////////////////////////////////////////////////////////////////////////////// |
|
217 |
procedure doStepShell(Gear: PVisualGear; Steps: Longword); |
|
218 |
begin |
|
219 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
220 |
||
221 |
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
|
222 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 223 |
|
224 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
225 |
||
226 |
if Gear^.FrameTicks <= Steps then |
|
227 |
DeleteVisualGear(Gear) |
|
228 |
else |
|
229 |
dec(Gear^.FrameTicks, Steps) |
|
230 |
end; |
|
231 |
||
232 |
procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword); |
|
233 |
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
|
234 |
Gear^.Y:= Gear^.Y - 0.02 * Steps; |
3441 | 235 |
|
236 |
if Gear^.FrameTicks <= Steps then |
|
237 |
DeleteVisualGear(Gear) |
|
238 |
else |
|
239 |
dec(Gear^.FrameTicks, Steps) |
|
240 |
end; |
|
241 |
||
242 |
//////////////////////////////////////////////////////////////////////////////// |
|
243 |
procedure doStepBubble(Gear: PVisualGear; Steps: Longword); |
|
244 |
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
|
245 |
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
|
246 |
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
|
247 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 248 |
|
4172 | 249 |
Gear^.dX := Gear^.dX / (1.001 * Steps); |
250 |
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
|
251 |
|
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
|
252 |
if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then |
3441 | 253 |
DeleteVisualGear(Gear) |
254 |
else |
|
255 |
dec(Gear^.FrameTicks, Steps) |
|
256 |
end; |
|
257 |
||
258 |
//////////////////////////////////////////////////////////////////////////////// |
|
259 |
procedure doStepSteam(Gear: PVisualGear; Steps: Longword); |
|
260 |
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
|
261 |
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
|
262 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 263 |
|
264 |
if Gear^.FrameTicks <= Steps then |
|
265 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
266 |
else |
|
267 |
begin |
|
268 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
269 |
Gear^.FrameTicks:= cExplFrameTicks |
|
270 |
end |
|
271 |
else dec(Gear^.FrameTicks, Steps) |
|
272 |
end; |
|
273 |
||
274 |
//////////////////////////////////////////////////////////////////////////////// |
|
275 |
procedure doStepAmmo(Gear: PVisualGear; Steps: Longword); |
|
276 |
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
|
277 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 278 |
|
279 |
Gear^.scale:= Gear^.scale + 0.0025 * Steps; |
|
280 |
Gear^.alpha:= Gear^.alpha - 0.0015 * Steps; |
|
281 |
||
282 |
if Gear^.alpha < 0 then DeleteVisualGear(Gear) |
|
283 |
end; |
|
284 |
||
285 |
//////////////////////////////////////////////////////////////////////////////// |
|
286 |
procedure doStepSmoke(Gear: PVisualGear; Steps: Longword); |
|
287 |
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
|
288 |
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
|
289 |
Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps; |
3441 | 290 |
|
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
|
291 |
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
|
292 |
//Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995); |
3441 | 293 |
|
294 |
if Gear^.FrameTicks <= Steps then |
|
295 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
296 |
else |
|
297 |
begin |
|
298 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
299 |
Gear^.FrameTicks:= cExplFrameTicks |
|
300 |
end |
|
301 |
else dec(Gear^.FrameTicks, Steps) |
|
302 |
end; |
|
303 |
||
304 |
//////////////////////////////////////////////////////////////////////////////// |
|
305 |
procedure doStepDust(Gear: PVisualGear; Steps: Longword); |
|
306 |
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
|
307 |
Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps; |
3441 | 308 |
Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; |
309 |
||
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
|
310 |
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
|
311 |
Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps); |
3441 | 312 |
|
313 |
if Gear^.FrameTicks <= Steps then |
|
314 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
315 |
else |
|
316 |
begin |
|
317 |
dec(Gear^.Frame); |
|
318 |
Gear^.FrameTicks:= cExplFrameTicks |
|
319 |
end |
|
320 |
else dec(Gear^.FrameTicks, Steps) |
|
321 |
end; |
|
322 |
||
323 |
//////////////////////////////////////////////////////////////////////////////// |
|
324 |
procedure doStepSplash(Gear: PVisualGear; Steps: Longword); |
|
325 |
begin |
|
326 |
if Gear^.FrameTicks <= Steps then |
|
327 |
DeleteVisualGear(Gear) |
|
328 |
else |
|
329 |
dec(Gear^.FrameTicks, Steps); |
|
330 |
end; |
|
331 |
||
332 |
//////////////////////////////////////////////////////////////////////////////// |
|
333 |
procedure doStepDroplet(Gear: PVisualGear; Steps: Longword); |
|
334 |
begin |
|
335 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
336 |
||
337 |
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
|
338 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 339 |
|
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
|
340 |
if round(Gear^.Y) > cWaterLine then begin |
3441 | 341 |
DeleteVisualGear(Gear); |
342 |
PlaySound(TSound(ord(sndDroplet1) + Random(3))); |
|
343 |
end; |
|
344 |
end; |
|
345 |
||
346 |
//////////////////////////////////////////////////////////////////////////////// |
|
347 |
procedure doStepSmokeRing(Gear: PVisualGear; Steps: Longword); |
|
348 |
begin |
|
349 |
inc(Gear^.Timer, Steps); |
|
350 |
if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear) |
|
351 |
else |
|
352 |
begin |
|
353 |
Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4; |
|
354 |
Gear^.alpha := 1 - power(Gear^.Timer / 350, 4); |
|
355 |
if Gear^.alpha < 0 then Gear^.alpha:= 0; |
|
356 |
end; |
|
357 |
end; |
|
358 |
||
359 |
//////////////////////////////////////////////////////////////////////////////// |
|
360 |
procedure doStepFeather(Gear: PVisualGear; Steps: Longword); |
|
361 |
begin |
|
362 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
363 |
||
364 |
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
|
365 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 366 |
|
367 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
368 |
||
369 |
if Gear^.FrameTicks <= Steps then |
|
370 |
DeleteVisualGear(Gear) |
|
371 |
else |
|
372 |
dec(Gear^.FrameTicks, Steps) |
|
373 |
end; |
|
374 |
||
375 |
//////////////////////////////////////////////////////////////////////////////// |
|
376 |
const cSorterWorkTime = 640; |
|
377 |
var thexchar: array[0..cMaxTeams] of |
|
378 |
record |
|
379 |
dy, ny, dw: LongInt; |
|
380 |
team: PTeam; |
|
381 |
SortFactor: QWord; |
|
382 |
end; |
|
383 |
currsorter: PVisualGear = nil; |
|
384 |
||
385 |
procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword); |
|
386 |
var i, t: LongInt; |
|
387 |
begin |
|
388 |
for t:= 1 to Steps do |
|
389 |
begin |
|
390 |
dec(Gear^.Timer); |
|
391 |
if (Gear^.Timer and 15) = 0 then |
|
392 |
for i:= 0 to Pred(TeamsCount) do |
|
393 |
with thexchar[i] do |
|
394 |
begin |
|
395 |
{$WARNINGS OFF} |
|
396 |
team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div 640; |
|
397 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime; |
|
398 |
{$WARNINGS ON} |
|
399 |
end; |
|
400 |
||
401 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
|
402 |
begin |
|
403 |
if currsorter = Gear then currsorter:= nil; |
|
404 |
DeleteVisualGear(Gear); |
|
405 |
exit |
|
406 |
end |
|
407 |
end |
|
408 |
end; |
|
409 |
||
410 |
procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword); |
|
411 |
var i: Longword; |
|
412 |
b: boolean; |
|
413 |
t: LongInt; |
|
414 |
begin |
|
415 |
Steps:= Steps; // avoid compiler hint |
|
416 |
for t:= 0 to Pred(TeamsCount) do |
|
417 |
with thexchar[t] do |
|
418 |
begin |
|
419 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
420 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
421 |
team:= TeamsArray[t]; |
|
422 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
423 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
424 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
425 |
end; |
|
426 |
||
427 |
if TeamsCount > 1 then |
|
428 |
repeat |
|
429 |
b:= true; |
|
430 |
for t:= 0 to TeamsCount - 2 do |
|
431 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
432 |
begin |
|
433 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
434 |
thexchar[t]:= thexchar[Succ(t)]; |
|
435 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
436 |
b:= false |
|
437 |
end |
|
438 |
until b; |
|
439 |
||
440 |
t:= - 4; |
|
441 |
for i:= 0 to Pred(TeamsCount) do |
|
442 |
with thexchar[i] do |
|
443 |
begin |
|
444 |
dec(t, team^.HealthTex^.h + 2); |
|
445 |
ny:= t; |
|
446 |
dy:= dy - ny |
|
447 |
end; |
|
448 |
||
449 |
Gear^.Timer:= cSorterWorkTime; |
|
450 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
451 |
currsorter:= Gear; |
|
452 |
//doStepTeamHealthSorterWork(Gear, Steps) |
|
453 |
end; |
|
454 |
||
455 |
//////////////////////////////////////////////////////////////////////////////// |
|
456 |
procedure doStepSpeechBubbleWork(Gear: PVisualGear; Steps: Longword); |
|
457 |
begin |
|
458 |
if Gear^.Timer > Steps then dec(Gear^.Timer, Steps) else Gear^.Timer:= 0; |
|
459 |
||
4365 | 460 |
if (Gear^.Hedgehog^.Gear <> nil) then |
3441 | 461 |
begin |
5151
cbadb9fa52fc
An experiment - make bazooka AI use float instead of hwFloat - should be as accurate, but faster.
nemo
parents:
5121
diff
changeset
|
462 |
Gear^.X:= hwFloat2Float(Gear^.Hedgehog^.Gear^.X) + (Gear^.Tex^.w div 2 - Gear^.FrameTicks); |
cbadb9fa52fc
An experiment - make bazooka AI use float instead of hwFloat - should be as accurate, but faster.
nemo
parents:
5121
diff
changeset
|
463 |
Gear^.Y:= hwFloat2Float(Gear^.Hedgehog^.Gear^.Y) - (16 + Gear^.Tex^.h); |
3441 | 464 |
end; |
465 |
||
466 |
if Gear^.Timer = 0 then |
|
467 |
begin |
|
4365 | 468 |
if Gear^.Hedgehog^.SpeechGear = Gear then |
469 |
Gear^.Hedgehog^.SpeechGear:= nil; |
|
3441 | 470 |
DeleteVisualGear(Gear) |
471 |
end; |
|
472 |
end; |
|
473 |
||
474 |
procedure doStepSpeechBubble(Gear: PVisualGear; Steps: Longword); |
|
475 |
begin |
|
476 |
Steps:= Steps; // avoid compiler hint |
|
477 |
||
4365 | 478 |
with Gear^.Hedgehog^ do |
3441 | 479 |
if SpeechGear <> nil then SpeechGear^.Timer:= 0; |
480 |
||
4365 | 481 |
Gear^.Hedgehog^.SpeechGear:= Gear; |
3441 | 482 |
|
5186 | 483 |
Gear^.Timer:= max(LongInt(Length(Gear^.Text)) * 150, 3000); |
3441 | 484 |
|
485 |
Gear^.Tex:= RenderSpeechBubbleTex(Gear^.Text, Gear^.FrameTicks, fnt16); |
|
486 |
||
487 |
case Gear^.FrameTicks of |
|
488 |
1: Gear^.FrameTicks:= SpritesData[sprSpeechTail].Width-28; |
|
489 |
2: Gear^.FrameTicks:= SpritesData[sprThoughtTail].Width-20; |
|
490 |
3: Gear^.FrameTicks:= SpritesData[sprShoutTail].Width-10; |
|
491 |
end; |
|
492 |
||
493 |
Gear^.doStep:= @doStepSpeechBubbleWork; |
|
494 |
||
4379
6cd6b77df8b8
No need for Extended data type just to draw some visual gears. It's a shame we have Math unit dependency
unC0Rr
parents:
4365
diff
changeset
|
495 |
Gear^.Y:= Gear^.Y - Gear^.Tex^.h |
3441 | 496 |
end; |
497 |
||
498 |
//////////////////////////////////////////////////////////////////////////////// |
|
499 |
procedure doStepHealthTagWork(Gear: PVisualGear; Steps: Longword); |
|
500 |
begin |
|
501 |
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
|
502 |
DeleteVisualGear(Gear) |
3441 | 503 |
else |
504 |
begin |
|
505 |
dec(Gear^.Timer, Steps); |
|
506 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
5581 | 507 |
Gear^.X:= Gear^.X + Gear^.dX * Steps |
3441 | 508 |
end; |
509 |
end; |
|
510 |
||
511 |
procedure doStepHealthTagWorkUnderWater(Gear: PVisualGear; Steps: Longword); |
|
512 |
begin |
|
4161 | 513 |
if round(Gear^.Y) - 10 < cWaterLine then |
3441 | 514 |
DeleteVisualGear(Gear) |
515 |
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
|
516 |
Gear^.Y:= Gear^.Y - 0.08 * Steps; |
3441 | 517 |
|
518 |
end; |
|
519 |
||
520 |
procedure doStepHealthTag(Gear: PVisualGear; Steps: Longword); |
|
521 |
var s: shortstring; |
|
522 |
begin |
|
523 |
s:= ''; |
|
524 |
||
525 |
str(Gear^.State, s); |
|
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
526 |
if Gear^.Hedgehog <> nil then |
4365 | 527 |
Gear^.Tex:= RenderStringTex(s, Gear^.Hedgehog^.Team^.Clan^.Color, fnt16) |
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
528 |
else |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
529 |
Gear^.Tex:= RenderStringTex(s, cWhiteColor, fnt16); |
3441 | 530 |
|
5578 | 531 |
Gear^.doStep:= @doStepHealthTagWork; |
5576 | 532 |
|
5596 | 533 |
if (round(Gear^.Y) > cWaterLine) and (Gear^.Frame = 0) then |
3441 | 534 |
Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
535 |
||
4379
6cd6b77df8b8
No need for Extended data type just to draw some visual gears. It's a shame we have Math unit dependency
unC0Rr
parents:
4365
diff
changeset
|
536 |
Gear^.Y:= Gear^.Y - Gear^.Tex^.h; |
3441 | 537 |
|
538 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
539 |
end; |
|
540 |
||
541 |
//////////////////////////////////////////////////////////////////////////////// |
|
542 |
procedure doStepSmokeTrace(Gear: PVisualGear; Steps: Longword); |
|
543 |
begin |
|
544 |
inc(Gear^.Timer, Steps ); |
|
545 |
if Gear^.Timer > 64 then |
|
546 |
begin |
|
3995
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
547 |
if Gear^.State = 0 then |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
548 |
begin |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
549 |
DeleteVisualGear(Gear); |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
550 |
exit; |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
551 |
end; |
3441 | 552 |
dec(Gear^.State, Gear^.Timer div 65); |
553 |
Gear^.Timer:= Gear^.Timer mod 65; |
|
554 |
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
|
555 |
Gear^.dX:= Gear^.dX + cWindSpeedf * Steps; |
3587 | 556 |
Gear^.X:= Gear^.X + Gear^.dX; |
3441 | 557 |
end; |
558 |
||
559 |
//////////////////////////////////////////////////////////////////////////////// |
|
560 |
procedure doStepExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
561 |
begin |
|
562 |
inc(Gear^.Timer, Steps); |
|
563 |
if Gear^.Timer > 75 then |
|
564 |
begin |
|
565 |
inc(Gear^.State, Gear^.Timer div 76); |
|
566 |
Gear^.Timer:= Gear^.Timer mod 76; |
|
567 |
if Gear^.State > 5 then DeleteVisualGear(Gear); |
|
568 |
end; |
|
569 |
end; |
|
570 |
||
571 |
procedure doStepExplosion(Gear: PVisualGear; Steps: Longword); |
|
572 |
var i: LongWord; |
|
4473 | 573 |
gX,gY: LongInt; |
574 |
vg: PVisualGear; |
|
3441 | 575 |
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
|
576 |
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
|
577 |
gY:= round(Gear^.Y); |
4473 | 578 |
for i:= 0 to 31 do |
579 |
begin |
|
580 |
vg:= AddVisualGear(gX, gY, vgtFire); |
|
4475
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
581 |
if vg <> nil then |
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
582 |
begin |
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
583 |
vg^.State:= gstTmpFlag; |
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
584 |
inc(vg^.FrameTicks, vg^.FrameTicks) |
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
585 |
end |
4473 | 586 |
end; |
3590 | 587 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart); |
588 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart2); |
|
3441 | 589 |
Gear^.doStep:= @doStepExplosionWork; |
590 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
591 |
end; |
|
592 |
||
593 |
||
594 |
//////////////////////////////////////////////////////////////////////////////// |
|
595 |
procedure doStepBigExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
5855
74c621e12baa
I do believe the only thing that was *ever* wrong with camera shake was someone decided to use getRandom on something that had always been a visual effect anyway. Pretty sure WorldDx is in fact safe to modify.
nemo
parents:
5840
diff
changeset
|
596 |
var maxMovement: LongInt; |
3441 | 597 |
begin |
598 |
||
599 |
inc(Gear^.Timer, Steps); |
|
600 |
if (Gear^.Timer and 5) = 0 then |
|
601 |
begin |
|
602 |
maxMovement := max(1, 13 - ((Gear^.Timer * 15) div 250)); |
|
603 |
ShakeCamera(maxMovement); |
|
604 |
end; |
|
5804
98192121dc69
Since shakes are still proving unsafe until camera is reworked, try a mild flash instead
nemo
parents:
5803
diff
changeset
|
605 |
|
3441 | 606 |
if Gear^.Timer > 250 then DeleteVisualGear(Gear); |
607 |
end; |
|
608 |
||
609 |
procedure doStepBigExplosion(Gear: PVisualGear; Steps: Longword); |
|
610 |
var i: LongWord; |
|
4473 | 611 |
gX,gY: LongInt; |
612 |
vg: PVisualGear; |
|
3441 | 613 |
begin |
5855
74c621e12baa
I do believe the only thing that was *ever* wrong with camera shake was someone decided to use getRandom on something that had always been a visual effect anyway. Pretty sure WorldDx is in fact safe to modify.
nemo
parents:
5840
diff
changeset
|
614 |
//ScreenFade:= sfFromWhite; |
74c621e12baa
I do believe the only thing that was *ever* wrong with camera shake was someone decided to use getRandom on something that had always been a visual effect anyway. Pretty sure WorldDx is in fact safe to modify.
nemo
parents:
5840
diff
changeset
|
615 |
//ScreenFadeValue:= round(60 * zoom * zoom); |
74c621e12baa
I do believe the only thing that was *ever* wrong with camera shake was someone decided to use getRandom on something that had always been a visual effect anyway. Pretty sure WorldDx is in fact safe to modify.
nemo
parents:
5840
diff
changeset
|
616 |
//ScreenFadeSpeed:= 5; |
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
|
617 |
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
|
618 |
gY:= round(Gear^.Y); |
3441 | 619 |
AddVisualGear(gX, gY, vgtSmokeRing); |
4473 | 620 |
for i:= 0 to 46 do |
621 |
begin |
|
622 |
vg:= AddVisualGear(gX, gY, vgtFire); |
|
4475
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
623 |
if vg <> nil then |
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
624 |
begin |
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
625 |
vg^.State:= gstTmpFlag; |
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
626 |
inc(vg^.FrameTicks, vg^.FrameTicks) |
54e78c40970b
rendering optimisations. remove the recursive flames in explosions (might need more due to the gravity change in the new flames) but more usefully, eliminate a number of redundant Tint calls
nemo
parents:
4473
diff
changeset
|
627 |
end |
4473 | 628 |
end; |
3441 | 629 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart); |
630 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart2); |
|
631 |
Gear^.doStep:= @doStepBigExplosionWork; |
|
632 |
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
|
633 |
performRumble(); |
3441 | 634 |
end; |
3689 | 635 |
|
636 |
procedure doStepChunk(Gear: PVisualGear; Steps: Longword); |
|
637 |
begin |
|
638 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
639 |
||
640 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
641 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
|
642 |
||
643 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
644 |
||
5235
e30b06ffea3a
Skip droplets if plain splash is enabled, add a sanity check just in case.
nemo
parents:
5186
diff
changeset
|
645 |
if (round(Gear^.Y) > cWaterLine) and ((cReducedQuality and rqPlainSplash) = 0) then |
3689 | 646 |
begin |
3699 | 647 |
AddVisualGear(round(Gear^.X), round(Gear^.Y), vgtDroplet); |
3689 | 648 |
DeleteVisualGear(Gear); |
649 |
end |
|
650 |
end; |
|
4327 | 651 |
|
652 |
//////////////////////////////////////////////////////////////////////////////// |
|
653 |
procedure doStepBulletHit(Gear: PVisualGear; Steps: Longword); |
|
654 |
begin |
|
655 |
if Gear^.FrameTicks <= Steps then |
|
656 |
DeleteVisualGear(Gear) |
|
657 |
else |
|
658 |
dec(Gear^.FrameTicks, Steps); |
|
659 |
end; |
|
4420
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4379
diff
changeset
|
660 |
|
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4379
diff
changeset
|
661 |
//////////////////////////////////////////////////////////////////////////////// |
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4379
diff
changeset
|
662 |
procedure doStepCircle(Gear: PVisualGear; Steps: Longword); |
4452 | 663 |
var tmp: LongInt; |
4421 | 664 |
i: LongWord; |
4420
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4379
diff
changeset
|
665 |
begin |
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4379
diff
changeset
|
666 |
with Gear^ do |
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4379
diff
changeset
|
667 |
if Frame <> 0 then |
4421 | 668 |
for i:= 1 to Steps do |
4420
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4379
diff
changeset
|
669 |
begin |
4421 | 670 |
inc(FrameTicks); |
671 |
if (FrameTicks mod Frame) = 0 then |
|
672 |
begin |
|
673 |
tmp:= Gear^.Tint and $FF; |
|
674 |
if tdY >= 0 then inc(tmp) |
|
675 |
else dec(tmp); |
|
676 |
if tmp < round(dX) then tdY:= 1; |
|
677 |
if tmp > round(dY) then tdY:= -1; |
|
4838
6c2528fe925d
Force a bunch of images to RGBA that were either RGB or indexed, strip
nemo
parents:
4806
diff
changeset
|
678 |
if tmp > 255 then tmp := 255; |
6c2528fe925d
Force a bunch of images to RGBA that were either RGB or indexed, strip
nemo
parents:
4806
diff
changeset
|
679 |
if tmp < 0 then tmp := 0; |
5179
8d64dcb566ea
Fix "Mixing signed expressions and longwords gives a 64bit result" warnings
unc0rr
parents:
5151
diff
changeset
|
680 |
Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or Longword(tmp) |
4421 | 681 |
end |
4420
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4379
diff
changeset
|
682 |
end |
6be946bcd17a
Add a visual gear for drawing circles. Intent is to allow specifying areas on map for lua scripts (such as to indicate a location to go to). Could also be used to, say, circle a hog in CTF. Also add a "Critical" flag for visual gears so a gear flagges as such will always be created.
nemo
parents:
4379
diff
changeset
|
683 |
end; |
5357
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
684 |
|
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
685 |
//////////////////////////////////////////////////////////////////////////////// |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
686 |
procedure doStepSmoothWindBar(Gear: PVisualGear; Steps: Longword); |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
687 |
begin |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
688 |
inc(Gear^.Timer, Steps); |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
689 |
|
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
690 |
while Gear^.Timer >= 10 do |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
691 |
begin |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
692 |
dec(Gear^.Timer, 10); |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
693 |
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
694 |
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
695 |
end; |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
696 |
|
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
697 |
if WindBarWidth = Gear^.Tag then |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
698 |
DeleteVisualGear(Gear) |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
699 |
end; |
5562 | 700 |
//////////////////////////////////////////////////////////////////////////////// |
701 |
procedure doStepStraightShot(Gear: PVisualGear; Steps: Longword); |
|
702 |
begin |
|
703 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
704 |
Gear^.Y:= Gear^.Y - Gear^.dY * Steps; |
|
5357
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
705 |
|
5562 | 706 |
if Gear^.FrameTicks <= Steps then |
707 |
DeleteVisualGear(Gear) |
|
708 |
else |
|
709 |
begin |
|
710 |
dec(Gear^.FrameTicks, Steps); |
|
711 |
if (Gear^.FrameTicks < 501) and (Gear^.FrameTicks mod 5 = 0) then |
|
712 |
Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or (((Gear^.Tint and $000000FF) * Gear^.FrameTicks) div 500) |
|
713 |
end |
|
714 |
end; |
|
715 |