author | nemo |
Thu, 15 Dec 2011 11:06:36 -0500 | |
changeset 6530 | dc6ce7eb556b |
parent 6302 | db8bdbb34e03 |
child 6553 | 91365db8b82c |
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? |
6302
db8bdbb34e03
Spread flakes out over 5 layers now (far back, mid distance, just behind land, just in front of lands and hog, near distance). Spread clouds out over 3 layers (far back, mid distance, just behind land). Add a flatten clouds option, use
nemo
parents:
6291
diff
changeset
|
82 |
if (Gear^.Layer = 2) and (round(Y) - 225 > LAND_HEIGHT) then Y:= Y - (1024 + 300) // TODO - configure in theme (jellies for example could use limited range) |
db8bdbb34e03
Spread flakes out over 5 layers now (far back, mid distance, just behind land, just in front of lands and hog, near distance). Spread clouds out over 3 layers (far back, mid distance, just behind land). Add a flatten clouds option, use
nemo
parents:
6291
diff
changeset
|
83 |
else if (Gear^.Layer <> 2) and (round(Y) + 50 > LAND_HEIGHT) then Y:= Y - (1024 + 25); |
3441 | 84 |
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
|
85 |
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
|
86 |
tdY:= 0 |
3441 | 87 |
end; |
88 |
end; |
|
89 |
||
90 |
end; |
|
91 |
||
92 |
//////////////////////////////////////////////////////////////////////////////// |
|
93 |
procedure doStepBeeTrace(Gear: PVisualGear; Steps: Longword); |
|
94 |
begin |
|
95 |
if Gear^.FrameTicks > Steps then |
|
96 |
dec(Gear^.FrameTicks, Steps) |
|
97 |
else |
|
98 |
DeleteVisualGear(Gear); |
|
99 |
end; |
|
100 |
||
101 |
//////////////////////////////////////////////////////////////////////////////// |
|
102 |
procedure doStepCloud(Gear: PVisualGear; Steps: Longword); |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
103 |
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
|
104 |
t: real; |
3441 | 105 |
begin |
3994
486da687d76a
fix/tweak let clouds reflect wind speed and direction again + stronger
sheepluva
parents:
3976
diff
changeset
|
106 |
Gear^.X:= Gear^.X + (cWindSpeedf * 750 * Gear^.dX) * Steps; |
3441 | 107 |
|
3592
0bcad5c38c9e
clouds: up-and-down-bouncing now without evil loop
sheepluva
parents:
3590
diff
changeset
|
108 |
// 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
|
109 |
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
|
110 |
t := 8 * hwFloat2Float(AngleSin(s mod 2048)); |
3597
978c30ef50fc
visual gears: fixing nemo's c-style assignment/multiplications
sheepluva
parents:
3593
diff
changeset
|
111 |
if (s < 2048) then t := -t; |
3441 | 112 |
|
4161 | 113 |
Gear^.Y := LAND_HEIGHT - 1184 + LongInt(Gear^.Timer mod 8) + t; |
3441 | 114 |
|
3764 | 115 |
if round(Gear^.X) < cLeftScreenBorder then Gear^.X:= Gear^.X + cScreenSpace else |
116 |
if round(Gear^.X) > cRightScreenBorder then Gear^.X:= Gear^.X - cScreenSpace |
|
3441 | 117 |
end; |
118 |
||
119 |
//////////////////////////////////////////////////////////////////////////////// |
|
120 |
procedure doStepExpl(Gear: PVisualGear; Steps: Longword); |
|
121 |
begin |
|
122 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
123 |
||
124 |
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
|
125 |
//Gear^.dY:= Gear^.dY + cGravityf; |
3441 | 126 |
|
127 |
if Gear^.FrameTicks <= Steps then |
|
128 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
129 |
else |
|
130 |
begin |
|
131 |
dec(Gear^.Frame); |
|
132 |
Gear^.FrameTicks:= cExplFrameTicks |
|
133 |
end |
|
134 |
else dec(Gear^.FrameTicks, Steps) |
|
135 |
end; |
|
136 |
||
137 |
//////////////////////////////////////////////////////////////////////////////// |
|
3704 | 138 |
procedure doStepNote(Gear: PVisualGear; Steps: Longword); |
139 |
begin |
|
140 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
141 |
||
142 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
3706 | 143 |
Gear^.dY:= Gear^.dY + cGravityf * Steps / 2; |
3704 | 144 |
|
3706 | 145 |
Gear^.Angle:= Gear^.Angle + (Gear^.Frame + 1) * Steps / 10; |
146 |
while Gear^.Angle > cMaxAngle do |
|
147 |
Gear^.Angle:= Gear^.Angle - cMaxAngle; |
|
3704 | 148 |
|
149 |
if Gear^.FrameTicks <= Steps then |
|
150 |
DeleteVisualGear(Gear) |
|
151 |
else |
|
152 |
dec(Gear^.FrameTicks, Steps) |
|
153 |
end; |
|
154 |
||
155 |
//////////////////////////////////////////////////////////////////////////////// |
|
4279 | 156 |
procedure doStepLineTrail(Gear: PVisualGear; Steps: Longword); |
157 |
begin |
|
158 |
Steps := Steps; |
|
159 |
if Gear^.Timer <= Steps then |
|
160 |
DeleteVisualGear(Gear) |
|
161 |
else |
|
162 |
dec(Gear^.Timer, Steps) |
|
163 |
end; |
|
164 |
||
165 |
//////////////////////////////////////////////////////////////////////////////// |
|
3441 | 166 |
procedure doStepEgg(Gear: PVisualGear; Steps: Longword); |
167 |
begin |
|
168 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
169 |
||
170 |
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
|
171 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 172 |
|
173 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
174 |
||
175 |
if Gear^.FrameTicks <= Steps then |
|
6128 | 176 |
begin |
177 |
DeleteVisualGear(Gear); |
|
178 |
exit |
|
179 |
end |
|
3441 | 180 |
else |
5874
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5855
diff
changeset
|
181 |
dec(Gear^.FrameTicks, Steps); |
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5855
diff
changeset
|
182 |
|
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5855
diff
changeset
|
183 |
if Gear^.FrameTicks < $FF then |
5cd329cf2460
nemo's molotov burst effect; with a slight color modification added
sheepluva
parents:
5855
diff
changeset
|
184 |
Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or Gear^.FrameTicks |
3441 | 185 |
end; |
186 |
||
187 |
//////////////////////////////////////////////////////////////////////////////// |
|
188 |
procedure doStepFire(Gear: PVisualGear; Steps: Longword); |
|
3751 | 189 |
var vgt: PVisualGear; |
3441 | 190 |
begin |
191 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
192 |
||
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
|
193 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps;// + cGravityf * (Steps * Steps); |
3751 | 194 |
if (Gear^.State and gstTmpFlag) = 0 then |
195 |
begin |
|
196 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
|
3764 | 197 |
if ((GameTicks mod 200) < Steps + 1) then |
3751 | 198 |
begin |
199 |
vgt:= AddVisualGear(round(Gear^.X), round(Gear^.Y), vgtFire); |
|
200 |
if vgt <> nil then |
|
201 |
begin |
|
202 |
vgt^.dx:= 0; |
|
203 |
vgt^.dy:= 0; |
|
204 |
vgt^.State:= gstTmpFlag; |
|
205 |
end; |
|
206 |
end |
|
207 |
end |
|
208 |
else |
|
209 |
inc(Steps, Steps); |
|
3441 | 210 |
|
211 |
if Gear^.FrameTicks <= Steps then |
|
212 |
DeleteVisualGear(Gear) |
|
213 |
else |
|
214 |
dec(Gear^.FrameTicks, Steps) |
|
215 |
end; |
|
216 |
||
217 |
//////////////////////////////////////////////////////////////////////////////// |
|
218 |
procedure doStepShell(Gear: PVisualGear; Steps: Longword); |
|
219 |
begin |
|
220 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
221 |
||
222 |
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
|
223 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 224 |
|
225 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
226 |
||
227 |
if Gear^.FrameTicks <= Steps then |
|
228 |
DeleteVisualGear(Gear) |
|
229 |
else |
|
230 |
dec(Gear^.FrameTicks, Steps) |
|
231 |
end; |
|
232 |
||
233 |
procedure doStepSmallDamage(Gear: PVisualGear; Steps: Longword); |
|
234 |
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
|
235 |
Gear^.Y:= Gear^.Y - 0.02 * Steps; |
3441 | 236 |
|
237 |
if Gear^.FrameTicks <= Steps then |
|
238 |
DeleteVisualGear(Gear) |
|
239 |
else |
|
240 |
dec(Gear^.FrameTicks, Steps) |
|
241 |
end; |
|
242 |
||
243 |
//////////////////////////////////////////////////////////////////////////////// |
|
244 |
procedure doStepBubble(Gear: PVisualGear; Steps: Longword); |
|
245 |
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
|
246 |
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
|
247 |
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
|
248 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 249 |
|
4172 | 250 |
Gear^.dX := Gear^.dX / (1.001 * Steps); |
251 |
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
|
252 |
|
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
|
253 |
if (Gear^.FrameTicks <= Steps) or (round(Gear^.Y) < cWaterLine) then |
3441 | 254 |
DeleteVisualGear(Gear) |
255 |
else |
|
256 |
dec(Gear^.FrameTicks, Steps) |
|
257 |
end; |
|
258 |
||
259 |
//////////////////////////////////////////////////////////////////////////////// |
|
260 |
procedure doStepSteam(Gear: PVisualGear; Steps: Longword); |
|
261 |
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
|
262 |
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
|
263 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 264 |
|
265 |
if Gear^.FrameTicks <= Steps then |
|
266 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
267 |
else |
|
268 |
begin |
|
269 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
270 |
Gear^.FrameTicks:= cExplFrameTicks |
|
271 |
end |
|
272 |
else dec(Gear^.FrameTicks, Steps) |
|
273 |
end; |
|
274 |
||
275 |
//////////////////////////////////////////////////////////////////////////////// |
|
276 |
procedure doStepAmmo(Gear: PVisualGear; Steps: Longword); |
|
277 |
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
|
278 |
Gear^.Y:= Gear^.Y - cDrownSpeedf * Steps; |
3441 | 279 |
|
280 |
Gear^.scale:= Gear^.scale + 0.0025 * Steps; |
|
281 |
Gear^.alpha:= Gear^.alpha - 0.0015 * Steps; |
|
282 |
||
283 |
if Gear^.alpha < 0 then DeleteVisualGear(Gear) |
|
284 |
end; |
|
285 |
||
286 |
//////////////////////////////////////////////////////////////////////////////// |
|
287 |
procedure doStepSmoke(Gear: PVisualGear; Steps: Longword); |
|
288 |
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
|
289 |
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
|
290 |
Gear^.Y:= Gear^.Y - (cDrownSpeedf + Gear^.dY) * Steps; |
3441 | 291 |
|
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
|
292 |
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
|
293 |
//Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.995); |
3441 | 294 |
|
295 |
if Gear^.FrameTicks <= Steps then |
|
296 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
297 |
else |
|
298 |
begin |
|
299 |
if Random(2) = 0 then dec(Gear^.Frame); |
|
300 |
Gear^.FrameTicks:= cExplFrameTicks |
|
301 |
end |
|
302 |
else dec(Gear^.FrameTicks, Steps) |
|
303 |
end; |
|
304 |
||
305 |
//////////////////////////////////////////////////////////////////////////////// |
|
306 |
procedure doStepDust(Gear: PVisualGear; Steps: Longword); |
|
307 |
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
|
308 |
Gear^.X:= Gear^.X + (cWindSpeedf + (cWindSpeedf * 0.03 * Steps) + Gear^.dX) * Steps; |
3441 | 309 |
Gear^.Y:= Gear^.Y - (Gear^.dY) * Steps; |
310 |
||
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
|
311 |
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
|
312 |
Gear^.dY := Gear^.dY - (cDrownSpeedf * 0.001 * Steps); |
3441 | 313 |
|
314 |
if Gear^.FrameTicks <= Steps then |
|
315 |
if Gear^.Frame = 0 then DeleteVisualGear(Gear) |
|
316 |
else |
|
317 |
begin |
|
318 |
dec(Gear^.Frame); |
|
319 |
Gear^.FrameTicks:= cExplFrameTicks |
|
320 |
end |
|
321 |
else dec(Gear^.FrameTicks, Steps) |
|
322 |
end; |
|
323 |
||
324 |
//////////////////////////////////////////////////////////////////////////////// |
|
325 |
procedure doStepSplash(Gear: PVisualGear; Steps: Longword); |
|
326 |
begin |
|
327 |
if Gear^.FrameTicks <= Steps then |
|
328 |
DeleteVisualGear(Gear) |
|
329 |
else |
|
330 |
dec(Gear^.FrameTicks, Steps); |
|
331 |
end; |
|
332 |
||
333 |
//////////////////////////////////////////////////////////////////////////////// |
|
334 |
procedure doStepDroplet(Gear: PVisualGear; Steps: Longword); |
|
335 |
begin |
|
336 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
337 |
||
338 |
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
|
339 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 340 |
|
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
|
341 |
if round(Gear^.Y) > cWaterLine then begin |
3441 | 342 |
DeleteVisualGear(Gear); |
343 |
PlaySound(TSound(ord(sndDroplet1) + Random(3))); |
|
344 |
end; |
|
345 |
end; |
|
346 |
||
347 |
//////////////////////////////////////////////////////////////////////////////// |
|
348 |
procedure doStepSmokeRing(Gear: PVisualGear; Steps: Longword); |
|
349 |
begin |
|
350 |
inc(Gear^.Timer, Steps); |
|
351 |
if Gear^.Timer >= Gear^.FrameTicks then DeleteVisualGear(Gear) |
|
352 |
else |
|
353 |
begin |
|
354 |
Gear^.scale := 1.25 * (-power(2, -10 * Int(Gear^.Timer)/Gear^.FrameTicks) + 1) + 0.4; |
|
355 |
Gear^.alpha := 1 - power(Gear^.Timer / 350, 4); |
|
356 |
if Gear^.alpha < 0 then Gear^.alpha:= 0; |
|
357 |
end; |
|
358 |
end; |
|
359 |
||
360 |
//////////////////////////////////////////////////////////////////////////////// |
|
361 |
procedure doStepFeather(Gear: PVisualGear; Steps: Longword); |
|
362 |
begin |
|
363 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
364 |
||
365 |
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
|
366 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
3441 | 367 |
|
368 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
369 |
||
370 |
if Gear^.FrameTicks <= Steps then |
|
371 |
DeleteVisualGear(Gear) |
|
372 |
else |
|
373 |
dec(Gear^.FrameTicks, Steps) |
|
374 |
end; |
|
375 |
||
376 |
//////////////////////////////////////////////////////////////////////////////// |
|
377 |
const cSorterWorkTime = 640; |
|
378 |
var thexchar: array[0..cMaxTeams] of |
|
379 |
record |
|
380 |
dy, ny, dw: LongInt; |
|
381 |
team: PTeam; |
|
382 |
SortFactor: QWord; |
|
383 |
end; |
|
384 |
currsorter: PVisualGear = nil; |
|
385 |
||
386 |
procedure doStepTeamHealthSorterWork(Gear: PVisualGear; Steps: Longword); |
|
387 |
var i, t: LongInt; |
|
388 |
begin |
|
389 |
for t:= 1 to Steps do |
|
390 |
begin |
|
391 |
dec(Gear^.Timer); |
|
392 |
if (Gear^.Timer and 15) = 0 then |
|
393 |
for i:= 0 to Pred(TeamsCount) do |
|
394 |
with thexchar[i] do |
|
395 |
begin |
|
396 |
{$WARNINGS OFF} |
|
397 |
team^.DrawHealthY:= ny + dy * LongInt(Gear^.Timer) div 640; |
|
398 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * LongInt(Gear^.Timer) div cSorterWorkTime; |
|
399 |
{$WARNINGS ON} |
|
400 |
end; |
|
401 |
||
402 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
|
403 |
begin |
|
404 |
if currsorter = Gear then currsorter:= nil; |
|
405 |
DeleteVisualGear(Gear); |
|
406 |
exit |
|
407 |
end |
|
408 |
end |
|
409 |
end; |
|
410 |
||
411 |
procedure doStepTeamHealthSorter(Gear: PVisualGear; Steps: Longword); |
|
412 |
var i: Longword; |
|
413 |
b: boolean; |
|
414 |
t: LongInt; |
|
415 |
begin |
|
416 |
Steps:= Steps; // avoid compiler hint |
|
417 |
for t:= 0 to Pred(TeamsCount) do |
|
418 |
with thexchar[t] do |
|
419 |
begin |
|
420 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
421 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
422 |
team:= TeamsArray[t]; |
|
423 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
424 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
425 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
426 |
end; |
|
427 |
||
428 |
if TeamsCount > 1 then |
|
429 |
repeat |
|
430 |
b:= true; |
|
431 |
for t:= 0 to TeamsCount - 2 do |
|
432 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
433 |
begin |
|
434 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
435 |
thexchar[t]:= thexchar[Succ(t)]; |
|
436 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
437 |
b:= false |
|
438 |
end |
|
439 |
until b; |
|
440 |
||
441 |
t:= - 4; |
|
442 |
for i:= 0 to Pred(TeamsCount) do |
|
443 |
with thexchar[i] do |
|
444 |
begin |
|
445 |
dec(t, team^.HealthTex^.h + 2); |
|
446 |
ny:= t; |
|
447 |
dy:= dy - ny |
|
448 |
end; |
|
449 |
||
450 |
Gear^.Timer:= cSorterWorkTime; |
|
451 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
|
452 |
currsorter:= Gear; |
|
453 |
//doStepTeamHealthSorterWork(Gear, Steps) |
|
454 |
end; |
|
455 |
||
456 |
//////////////////////////////////////////////////////////////////////////////// |
|
457 |
procedure doStepSpeechBubbleWork(Gear: PVisualGear; Steps: Longword); |
|
458 |
begin |
|
459 |
if Gear^.Timer > Steps then dec(Gear^.Timer, Steps) else Gear^.Timer:= 0; |
|
460 |
||
4365 | 461 |
if (Gear^.Hedgehog^.Gear <> nil) then |
3441 | 462 |
begin |
5151
cbadb9fa52fc
An experiment - make bazooka AI use float instead of hwFloat - should be as accurate, but faster.
nemo
parents:
5121
diff
changeset
|
463 |
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
|
464 |
Gear^.Y:= hwFloat2Float(Gear^.Hedgehog^.Gear^.Y) - (16 + Gear^.Tex^.h); |
3441 | 465 |
end; |
466 |
||
467 |
if Gear^.Timer = 0 then |
|
468 |
begin |
|
4365 | 469 |
if Gear^.Hedgehog^.SpeechGear = Gear then |
470 |
Gear^.Hedgehog^.SpeechGear:= nil; |
|
3441 | 471 |
DeleteVisualGear(Gear) |
472 |
end; |
|
473 |
end; |
|
474 |
||
475 |
procedure doStepSpeechBubble(Gear: PVisualGear; Steps: Longword); |
|
476 |
begin |
|
477 |
Steps:= Steps; // avoid compiler hint |
|
478 |
||
4365 | 479 |
with Gear^.Hedgehog^ do |
3441 | 480 |
if SpeechGear <> nil then SpeechGear^.Timer:= 0; |
481 |
||
4365 | 482 |
Gear^.Hedgehog^.SpeechGear:= Gear; |
3441 | 483 |
|
5186 | 484 |
Gear^.Timer:= max(LongInt(Length(Gear^.Text)) * 150, 3000); |
3441 | 485 |
|
486 |
Gear^.Tex:= RenderSpeechBubbleTex(Gear^.Text, Gear^.FrameTicks, fnt16); |
|
487 |
||
488 |
case Gear^.FrameTicks of |
|
489 |
1: Gear^.FrameTicks:= SpritesData[sprSpeechTail].Width-28; |
|
490 |
2: Gear^.FrameTicks:= SpritesData[sprThoughtTail].Width-20; |
|
491 |
3: Gear^.FrameTicks:= SpritesData[sprShoutTail].Width-10; |
|
492 |
end; |
|
493 |
||
494 |
Gear^.doStep:= @doStepSpeechBubbleWork; |
|
495 |
||
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
|
496 |
Gear^.Y:= Gear^.Y - Gear^.Tex^.h |
3441 | 497 |
end; |
498 |
||
499 |
//////////////////////////////////////////////////////////////////////////////// |
|
500 |
procedure doStepHealthTagWork(Gear: PVisualGear; Steps: Longword); |
|
501 |
begin |
|
502 |
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
|
503 |
DeleteVisualGear(Gear) |
3441 | 504 |
else |
505 |
begin |
|
506 |
dec(Gear^.Timer, Steps); |
|
507 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
5581 | 508 |
Gear^.X:= Gear^.X + Gear^.dX * Steps |
3441 | 509 |
end; |
510 |
end; |
|
511 |
||
512 |
procedure doStepHealthTagWorkUnderWater(Gear: PVisualGear; Steps: Longword); |
|
513 |
begin |
|
4161 | 514 |
if round(Gear^.Y) - 10 < cWaterLine then |
3441 | 515 |
DeleteVisualGear(Gear) |
516 |
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
|
517 |
Gear^.Y:= Gear^.Y - 0.08 * Steps; |
3441 | 518 |
|
519 |
end; |
|
520 |
||
521 |
procedure doStepHealthTag(Gear: PVisualGear; Steps: Longword); |
|
522 |
var s: shortstring; |
|
523 |
begin |
|
524 |
s:= ''; |
|
525 |
||
526 |
str(Gear^.State, s); |
|
3459
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
527 |
if Gear^.Hedgehog <> nil then |
4365 | 528 |
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
|
529 |
else |
c552aa44108d
hey sheepluva, how about just this? lets you have an anonymous one too.
nemo
parents:
3443
diff
changeset
|
530 |
Gear^.Tex:= RenderStringTex(s, cWhiteColor, fnt16); |
3441 | 531 |
|
5578 | 532 |
Gear^.doStep:= @doStepHealthTagWork; |
5576 | 533 |
|
5596 | 534 |
if (round(Gear^.Y) > cWaterLine) and (Gear^.Frame = 0) then |
3441 | 535 |
Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
536 |
||
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
|
537 |
Gear^.Y:= Gear^.Y - Gear^.Tex^.h; |
3441 | 538 |
|
539 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
540 |
end; |
|
541 |
||
542 |
//////////////////////////////////////////////////////////////////////////////// |
|
543 |
procedure doStepSmokeTrace(Gear: PVisualGear; Steps: Longword); |
|
544 |
begin |
|
545 |
inc(Gear^.Timer, Steps ); |
|
546 |
if Gear^.Timer > 64 then |
|
547 |
begin |
|
3995
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
548 |
if Gear^.State = 0 then |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
549 |
begin |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
550 |
DeleteVisualGear(Gear); |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
551 |
exit; |
360332f8785f
SmokeTrace: animation got aborted before last animation frame was displayed
sheepluva
parents:
3994
diff
changeset
|
552 |
end; |
3441 | 553 |
dec(Gear^.State, Gear^.Timer div 65); |
554 |
Gear^.Timer:= Gear^.Timer mod 65; |
|
555 |
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
|
556 |
Gear^.dX:= Gear^.dX + cWindSpeedf * Steps; |
3587 | 557 |
Gear^.X:= Gear^.X + Gear^.dX; |
3441 | 558 |
end; |
559 |
||
560 |
//////////////////////////////////////////////////////////////////////////////// |
|
561 |
procedure doStepExplosionWork(Gear: PVisualGear; Steps: Longword); |
|
562 |
begin |
|
563 |
inc(Gear^.Timer, Steps); |
|
564 |
if Gear^.Timer > 75 then |
|
565 |
begin |
|
566 |
inc(Gear^.State, Gear^.Timer div 76); |
|
567 |
Gear^.Timer:= Gear^.Timer mod 76; |
|
568 |
if Gear^.State > 5 then DeleteVisualGear(Gear); |
|
569 |
end; |
|
570 |
end; |
|
571 |
||
572 |
procedure doStepExplosion(Gear: PVisualGear; Steps: Longword); |
|
573 |
var i: LongWord; |
|
4473 | 574 |
gX,gY: LongInt; |
575 |
vg: PVisualGear; |
|
3441 | 576 |
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
|
577 |
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
|
578 |
gY:= round(Gear^.Y); |
4473 | 579 |
for i:= 0 to 31 do |
580 |
begin |
|
581 |
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
|
582 |
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
|
583 |
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
|
584 |
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
|
585 |
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
|
586 |
end |
4473 | 587 |
end; |
3590 | 588 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart); |
589 |
for i:= 0 to 8 do AddVisualGear(gX, gY, vgtExplPart2); |
|
3441 | 590 |
Gear^.doStep:= @doStepExplosionWork; |
591 |
if Steps > 1 then Gear^.doStep(Gear, Steps-1); |
|
592 |
end; |
|
593 |
||
594 |
||
595 |
//////////////////////////////////////////////////////////////////////////////// |
|
596 |
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
|
597 |
var maxMovement: LongInt; |
3441 | 598 |
begin |
599 |
||
600 |
inc(Gear^.Timer, Steps); |
|
601 |
if (Gear^.Timer and 5) = 0 then |
|
602 |
begin |
|
603 |
maxMovement := max(1, 13 - ((Gear^.Timer * 15) div 250)); |
|
604 |
ShakeCamera(maxMovement); |
|
605 |
end; |
|
5804
98192121dc69
Since shakes are still proving unsafe until camera is reworked, try a mild flash instead
nemo
parents:
5803
diff
changeset
|
606 |
|
3441 | 607 |
if Gear^.Timer > 250 then DeleteVisualGear(Gear); |
608 |
end; |
|
609 |
||
610 |
procedure doStepBigExplosion(Gear: PVisualGear; Steps: Longword); |
|
611 |
var i: LongWord; |
|
4473 | 612 |
gX,gY: LongInt; |
613 |
vg: PVisualGear; |
|
3441 | 614 |
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
|
615 |
//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
|
616 |
//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
|
617 |
//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
|
618 |
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
|
619 |
gY:= round(Gear^.Y); |
3441 | 620 |
AddVisualGear(gX, gY, vgtSmokeRing); |
4473 | 621 |
for i:= 0 to 46 do |
622 |
begin |
|
623 |
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
|
624 |
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
|
625 |
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
|
626 |
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
|
627 |
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
|
628 |
end |
4473 | 629 |
end; |
3441 | 630 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart); |
631 |
for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart2); |
|
632 |
Gear^.doStep:= @doStepBigExplosionWork; |
|
633 |
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
|
634 |
performRumble(); |
3441 | 635 |
end; |
3689 | 636 |
|
637 |
procedure doStepChunk(Gear: PVisualGear; Steps: Longword); |
|
638 |
begin |
|
639 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
640 |
||
641 |
Gear^.Y:= Gear^.Y + Gear^.dY * Steps; |
|
642 |
Gear^.dY:= Gear^.dY + cGravityf * Steps; |
|
643 |
||
644 |
Gear^.Angle:= round(Gear^.Angle + Steps) mod cMaxAngle; |
|
645 |
||
5235
e30b06ffea3a
Skip droplets if plain splash is enabled, add a sanity check just in case.
nemo
parents:
5186
diff
changeset
|
646 |
if (round(Gear^.Y) > cWaterLine) and ((cReducedQuality and rqPlainSplash) = 0) then |
3689 | 647 |
begin |
3699 | 648 |
AddVisualGear(round(Gear^.X), round(Gear^.Y), vgtDroplet); |
3689 | 649 |
DeleteVisualGear(Gear); |
650 |
end |
|
651 |
end; |
|
4327 | 652 |
|
653 |
//////////////////////////////////////////////////////////////////////////////// |
|
654 |
procedure doStepBulletHit(Gear: PVisualGear; Steps: Longword); |
|
655 |
begin |
|
656 |
if Gear^.FrameTicks <= Steps then |
|
657 |
DeleteVisualGear(Gear) |
|
658 |
else |
|
659 |
dec(Gear^.FrameTicks, Steps); |
|
660 |
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
|
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 |
//////////////////////////////////////////////////////////////////////////////// |
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
|
663 |
procedure doStepCircle(Gear: PVisualGear; Steps: Longword); |
4452 | 664 |
var tmp: LongInt; |
4421 | 665 |
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
|
666 |
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
|
667 |
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
|
668 |
if Frame <> 0 then |
4421 | 669 |
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
|
670 |
begin |
4421 | 671 |
inc(FrameTicks); |
672 |
if (FrameTicks mod Frame) = 0 then |
|
673 |
begin |
|
674 |
tmp:= Gear^.Tint and $FF; |
|
675 |
if tdY >= 0 then inc(tmp) |
|
676 |
else dec(tmp); |
|
677 |
if tmp < round(dX) then tdY:= 1; |
|
678 |
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
|
679 |
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
|
680 |
if tmp < 0 then tmp := 0; |
5179
8d64dcb566ea
Fix "Mixing signed expressions and longwords gives a 64bit result" warnings
unc0rr
parents:
5151
diff
changeset
|
681 |
Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or Longword(tmp) |
4421 | 682 |
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
|
683 |
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
|
684 |
end; |
5357
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 |
//////////////////////////////////////////////////////////////////////////////// |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
687 |
procedure doStepSmoothWindBar(Gear: PVisualGear; Steps: Longword); |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
688 |
begin |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
689 |
inc(Gear^.Timer, Steps); |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
690 |
|
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
691 |
while Gear^.Timer >= 10 do |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
692 |
begin |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
693 |
dec(Gear^.Timer, 10); |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
694 |
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
695 |
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
|
696 |
end; |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
697 |
|
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
698 |
if WindBarWidth = Gear^.Tag then |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
699 |
DeleteVisualGear(Gear) |
ec36f3d53f3c
Tiny optimization: convert smooth wind indicator change gear into visual gear
unc0rr
parents:
5236
diff
changeset
|
700 |
end; |
5562 | 701 |
//////////////////////////////////////////////////////////////////////////////// |
702 |
procedure doStepStraightShot(Gear: PVisualGear; Steps: Longword); |
|
703 |
begin |
|
704 |
Gear^.X:= Gear^.X + Gear^.dX * Steps; |
|
705 |
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
|
706 |
|
5562 | 707 |
if Gear^.FrameTicks <= Steps then |
708 |
DeleteVisualGear(Gear) |
|
709 |
else |
|
710 |
begin |
|
711 |
dec(Gear^.FrameTicks, Steps); |
|
712 |
if (Gear^.FrameTicks < 501) and (Gear^.FrameTicks mod 5 = 0) then |
|
713 |
Gear^.Tint:= (Gear^.Tint and $FFFFFF00) or (((Gear^.Tint and $000000FF) * Gear^.FrameTicks) div 500) |
|
714 |
end |
|
715 |
end; |
|
716 |