author | unc0rr |
Mon, 03 Nov 2008 14:24:54 +0000 | |
changeset 1467 | b288aea6b3d2 |
parent 1437 | 9f370351e859 |
child 1495 | 2b2b89bdb5f3 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2004-2008 Andrey Korotaev <unC0Rr@gmail.com> |
4 | 4 |
* |
183 | 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 |
|
4 | 8 |
* |
183 | 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. |
|
4 | 13 |
* |
183 | 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 |
|
4 | 17 |
*) |
18 |
||
19 |
procedure doStepDrowningGear(Gear: PGear); forward; |
|
20 |
||
21 |
function CheckGearDrowning(Gear: PGear): boolean; |
|
22 |
begin |
|
498 | 23 |
if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then |
1133 | 24 |
begin |
25 |
CheckGearDrowning:= true; |
|
26 |
Gear^.State:= gstDrowning; |
|
27 |
Gear^.doStep:= @doStepDrowningGear; |
|
28 |
PlaySound(sndSplash, false) |
|
29 |
end else |
|
30 |
CheckGearDrowning:= false |
|
4 | 31 |
end; |
32 |
||
33 |
procedure CheckCollision(Gear: PGear); |
|
34 |
begin |
|
351 | 35 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y)) |
1133 | 36 |
then Gear^.State:= Gear^.State or gstCollision |
37 |
else Gear^.State:= Gear^.State and not gstCollision |
|
4 | 38 |
end; |
39 |
||
40 |
procedure CheckHHDamage(Gear: PGear); |
|
522 | 41 |
var dmg: Longword; |
4 | 42 |
begin |
522 | 43 |
if _0_4 < Gear^.dY then |
1123 | 44 |
begin |
45 |
if _0_6 < Gear^.dY then |
|
1132 | 46 |
PlaySound(sndOw4, false) |
1123 | 47 |
else |
1132 | 48 |
PlaySound(sndOw1, false); |
1123 | 49 |
|
50 |
dmg:= 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70); |
|
51 |
inc(Gear^.Damage, dmg); |
|
52 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, Gear); |
|
53 |
end |
|
4 | 54 |
end; |
55 |
||
56 |
//////////////////////////////////////////////////////////////////////////////// |
|
57 |
//////////////////////////////////////////////////////////////////////////////// |
|
58 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
59 |
var dAngle: real; |
4 | 60 |
begin |
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
61 |
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000; |
1133 | 62 |
if not Gear^.dX.isNegative then |
63 |
Gear^.DirAngle:= Gear^.DirAngle + dAngle |
|
64 |
else |
|
65 |
Gear^.DirAngle:= Gear^.DirAngle - dAngle; |
|
66 |
||
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
67 |
if Gear^.DirAngle < 0 then Gear^.DirAngle:= Gear^.DirAngle + 360 |
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
68 |
else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 360 |
4 | 69 |
end; |
70 |
||
71 |
//////////////////////////////////////////////////////////////////////////////// |
|
72 |
procedure doStepDrowningGear(Gear: PGear); |
|
73 |
begin |
|
74 |
AllInactive:= false; |
|
351 | 75 |
Gear^.Y:= Gear^.Y + cDrownSpeed; |
76 |
if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
|
4 | 77 |
end; |
78 |
||
79 |
//////////////////////////////////////////////////////////////////////////////// |
|
80 |
procedure doStepFallingGear(Gear: PGear); |
|
542 | 81 |
var isFalling: boolean; |
4 | 82 |
begin |
503 | 83 |
Gear^.State:= Gear^.State and not gstCollision; |
84 |
||
85 |
if Gear^.dY.isNegative then |
|
1133 | 86 |
begin |
87 |
isFalling:= true; |
|
88 |
if TestCollisionYwithGear(Gear, -1) then |
|
89 |
begin |
|
90 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
91 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
92 |
Gear^.State:= Gear^.State or gstCollision |
|
93 |
end |
|
94 |
end else |
|
95 |
if TestCollisionYwithGear(Gear, 1) then |
|
96 |
begin |
|
97 |
isFalling:= false; |
|
98 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
99 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
100 |
Gear^.State:= Gear^.State or gstCollision |
|
101 |
end else isFalling:= true; |
|
503 | 102 |
|
351 | 103 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
1133 | 104 |
begin |
105 |
Gear^.dX:= - Gear^.dX * Gear^.Elasticity; |
|
106 |
Gear^.dY:= Gear^.dY * Gear^.Elasticity; |
|
107 |
Gear^.State:= Gear^.State or gstCollision |
|
108 |
end; |
|
503 | 109 |
|
542 | 110 |
if isFalling then Gear^.dY:= Gear^.dY + cGravity; |
503 | 111 |
|
351 | 112 |
Gear^.X:= Gear^.X + Gear^.dX; |
113 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 114 |
CheckGearDrowning(Gear); |
503 | 115 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
1133 | 116 |
(not isFalling) then |
117 |
Gear^.State:= Gear^.State and not gstMoving |
|
118 |
else |
|
119 |
Gear^.State:= Gear^.State or gstMoving |
|
4 | 120 |
end; |
121 |
||
122 |
//////////////////////////////////////////////////////////////////////////////// |
|
123 |
procedure doStepBomb(Gear: PGear); |
|
371 | 124 |
var i: LongInt; |
919 | 125 |
dX, dY: hwFloat; |
4 | 126 |
begin |
127 |
AllInactive:= false; |
|
1263 | 128 |
|
4 | 129 |
doStepFallingGear(Gear); |
1263 | 130 |
|
351 | 131 |
dec(Gear^.Timer); |
132 |
if Gear^.Timer = 0 then |
|
1133 | 133 |
begin |
134 |
case Gear^.Kind of |
|
135 |
gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
136 |
gtClusterBomb: begin |
|
137 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
138 |
for i:= 0 to 4 do |
|
139 |
begin |
|
140 |
dX:= rndSign(GetRandom * _0_1); |
|
141 |
dY:= (GetRandom - _3) * _0_08; |
|
1261 | 142 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
143 |
end |
|
144 |
end; |
|
145 |
gtWatermelon: begin |
|
146 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
147 |
for i:= 0 to 5 do |
|
148 |
begin |
|
149 |
dX:= rndSign(GetRandom * _0_1); |
|
1262 | 150 |
dY:= (GetRandom - _2) * _0_2; |
151 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMelonPiece, 0, dX, dY, 75)^.DirAngle:= i * 60; |
|
1133 | 152 |
end |
1263 | 153 |
end; |
154 |
gtHellishBomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 90, EXPLAutoSound); |
|
1133 | 155 |
end; |
156 |
DeleteGear(Gear); |
|
157 |
exit |
|
158 |
end; |
|
1263 | 159 |
|
4 | 160 |
CalcRotationDirAngle(Gear); |
1263 | 161 |
|
162 |
if Gear^.Kind = gtHellishBomb then |
|
1279 | 163 |
begin |
164 |
if Gear^.Timer = 3000 then PlaySound(sndHellish, false); |
|
165 |
||
1263 | 166 |
if (GameTicks and $3F) = 0 then |
167 |
if (Gear^.State and gstCollision) = 0 then |
|
168 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0); |
|
1279 | 169 |
end; |
1263 | 170 |
|
1158 | 171 |
if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then |
172 |
if (hwAbs(Gear^.dX) > _0_1) or |
|
173 |
(hwAbs(Gear^.dY) > _0_1) then |
|
174 |
PlaySound(sndGrenadeImpact, false) |
|
4 | 175 |
end; |
176 |
||
1279 | 177 |
procedure doStepWatermelon(Gear: PGear); |
178 |
begin |
|
179 |
AllInactive:= false; |
|
180 |
PlaySound(sndMelon, false); |
|
181 |
Gear^.doStep:= @doStepBomb |
|
182 |
end; |
|
183 |
||
78 | 184 |
procedure doStepCluster(Gear: PGear); |
185 |
begin |
|
186 |
AllInactive:= false; |
|
187 |
doStepFallingGear(Gear); |
|
351 | 188 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 189 |
begin |
1261 | 190 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, EXPLAutoSound); |
1133 | 191 |
DeleteGear(Gear); |
192 |
exit |
|
193 |
end; |
|
1262 | 194 |
|
195 |
if Gear^.Kind = gtMelonPiece then |
|
196 |
CalcRotationDirAngle(Gear) |
|
197 |
else |
|
198 |
if (GameTicks and $1F) = 0 then |
|
199 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
78 | 200 |
end; |
201 |
||
4 | 202 |
//////////////////////////////////////////////////////////////////////////////// |
203 |
procedure doStepGrenade(Gear: PGear); |
|
204 |
begin |
|
205 |
AllInactive:= false; |
|
351 | 206 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
4 | 207 |
doStepFallingGear(Gear); |
351 | 208 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 209 |
begin |
210 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
211 |
DeleteGear(Gear); |
|
212 |
exit |
|
213 |
end; |
|
4 | 214 |
if (GameTicks and $3F) = 0 then |
1133 | 215 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
4 | 216 |
end; |
217 |
||
218 |
//////////////////////////////////////////////////////////////////////////////// |
|
95 | 219 |
procedure doStepHealthTagWork(Gear: PGear); |
4 | 220 |
begin |
522 | 221 |
if Gear^.Kind = gtHealthTag then |
222 |
AllInactive:= false; |
|
351 | 223 |
dec(Gear^.Timer); |
522 | 224 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
351 | 225 |
if Gear^.Timer = 0 then |
1133 | 226 |
begin |
227 |
if Gear^.Kind = gtHealthTag then |
|
228 |
PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die |
|
229 |
DeleteGear(Gear) |
|
230 |
end |
|
4 | 231 |
end; |
232 |
||
263 | 233 |
procedure doStepHealthTagWorkUnderWater(Gear: PGear); |
234 |
begin |
|
235 |
AllInactive:= false; |
|
351 | 236 |
Gear^.Y:= Gear^.Y - _0_08; |
498 | 237 |
if hwRound(Gear^.Y) < cWaterLine + 10 then |
263 | 238 |
DeleteGear(Gear) |
239 |
end; |
|
240 |
||
95 | 241 |
procedure doStepHealthTag(Gear: PGear); |
242 |
var s: shortstring; |
|
522 | 243 |
font: THWFont; |
95 | 244 |
begin |
522 | 245 |
if Gear^.Kind = gtHealthTag then |
246 |
begin |
|
813 | 247 |
AllInactive:= false; |
522 | 248 |
font:= fnt16; |
249 |
Gear^.dY:= -_0_08 |
|
250 |
end else |
|
251 |
begin |
|
252 |
font:= fntSmall; |
|
253 |
Gear^.dY:= -_0_02 |
|
254 |
end; |
|
255 |
||
351 | 256 |
str(Gear^.State, s); |
762 | 257 |
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, font); |
498 | 258 |
if hwRound(Gear^.Y) < cWaterLine then Gear^.doStep:= @doStepHealthTagWork |
522 | 259 |
else Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
762 | 260 |
Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h) |
95 | 261 |
end; |
262 |
||
4 | 263 |
//////////////////////////////////////////////////////////////////////////////// |
264 |
procedure doStepGrave(Gear: PGear); |
|
265 |
begin |
|
266 |
AllInactive:= false; |
|
498 | 267 |
if Gear^.dY.isNegative then |
268 |
if TestCollisionY(Gear, -1) then Gear^.dY:= _0; |
|
4 | 269 |
|
351 | 270 |
if not Gear^.dY.isNegative then |
68 | 271 |
if TestCollisionY(Gear, 1) then |
4 | 272 |
begin |
351 | 273 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
274 |
if Gear^.dY > - _1div1024 then |
|
4 | 275 |
begin |
351 | 276 |
Gear^.Active:= false; |
4 | 277 |
exit |
351 | 278 |
end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false) |
4 | 279 |
end; |
351 | 280 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
4 | 281 |
CheckGearDrowning(Gear); |
351 | 282 |
Gear^.dY:= Gear^.dY + cGravity |
4 | 283 |
end; |
284 |
||
285 |
//////////////////////////////////////////////////////////////////////////////// |
|
286 |
procedure doStepUFOWork(Gear: PGear); |
|
351 | 287 |
var t: hwFloat; |
374 | 288 |
y: LongInt; |
4 | 289 |
begin |
290 |
AllInactive:= false; |
|
351 | 291 |
t:= Distance(Gear^.dX, Gear^.dY); |
292 |
Gear^.dX:= Gear^.Elasticity * (Gear^.dX + _0_000004 * (TargetPoint.X - hwRound(Gear^.X))); |
|
293 |
Gear^.dY:= Gear^.Elasticity * (Gear^.dY + _0_000004 * (TargetPoint.Y - hwRound(Gear^.Y))); |
|
294 |
t:= t / Distance(Gear^.dX, Gear^.dY); |
|
295 |
Gear^.dX:= Gear^.dX * t; |
|
296 |
Gear^.dY:= Gear^.dY * t; |
|
297 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
298 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
374 | 299 |
|
300 |
if (GameTicks and $3F) = 0 then |
|
301 |
begin |
|
302 |
y:= hwRound(Gear^.Y); |
|
303 |
if y + Gear^.Radius < cWaterLine then |
|
498 | 304 |
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); |
374 | 305 |
end; |
306 |
||
4 | 307 |
CheckCollision(Gear); |
351 | 308 |
dec(Gear^.Timer); |
309 |
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then |
|
4 | 310 |
begin |
560 | 311 |
StopSound(sndUFO); |
351 | 312 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 313 |
DeleteGear(Gear); |
314 |
end; |
|
315 |
end; |
|
316 |
||
317 |
procedure doStepUFO(Gear: PGear); |
|
318 |
begin |
|
319 |
AllInactive:= false; |
|
351 | 320 |
Gear^.X:= Gear^.X + Gear^.dX; |
321 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
322 |
Gear^.dY:= Gear^.dY + cGravity; |
|
4 | 323 |
CheckCollision(Gear); |
351 | 324 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 325 |
begin |
351 | 326 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 327 |
DeleteGear(Gear); |
328 |
exit |
|
329 |
end; |
|
351 | 330 |
dec(Gear^.Timer); |
331 |
if Gear^.Timer = 0 then |
|
4 | 332 |
begin |
560 | 333 |
PlaySound(sndUFO, true); |
351 | 334 |
Gear^.Timer:= 5000; |
335 |
Gear^.doStep:= @doStepUFOWork |
|
4 | 336 |
end; |
337 |
end; |
|
338 |
||
339 |
//////////////////////////////////////////////////////////////////////////////// |
|
876 | 340 |
procedure doStepShotIdle(Gear: PGear); |
341 |
begin |
|
342 |
AllInactive:= false; |
|
343 |
inc(Gear^.Timer); |
|
344 |
if Gear^.Timer > 75 then |
|
345 |
begin |
|
346 |
DeleteGear(Gear); |
|
347 |
AfterAttack |
|
348 |
end |
|
349 |
end; |
|
350 |
||
4 | 351 |
procedure doStepShotgunShot(Gear: PGear); |
352 |
var i: LongWord; |
|
353 |
begin |
|
354 |
AllInactive:= false; |
|
876 | 355 |
|
356 |
if ((Gear^.State and gstAnimation) = 0) then |
|
357 |
begin |
|
358 |
dec(Gear^.Timer); |
|
359 |
if Gear^.Timer = 0 then |
|
360 |
begin |
|
361 |
PlaySound(sndShotgunFire, false); |
|
362 |
Gear^.State:= Gear^.State or gstAnimation |
|
363 |
end; |
|
364 |
exit |
|
365 |
end |
|
366 |
else inc(Gear^.Timer); |
|
367 |
||
4 | 368 |
i:= 200; |
369 |
repeat |
|
351 | 370 |
Gear^.X:= Gear^.X + Gear^.dX; |
371 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 372 |
CheckCollision(Gear); |
351 | 373 |
if (Gear^.State and gstCollision) <> 0 then |
876 | 374 |
begin |
375 |
Gear^.X:= Gear^.X + Gear^.dX * 8; |
|
376 |
Gear^.Y:= Gear^.Y + Gear^.dY * 8; |
|
377 |
ShotgunShot(Gear); |
|
378 |
Gear^.doStep:= @doStepShotIdle; |
|
379 |
exit |
|
380 |
end; |
|
4 | 381 |
dec(i) |
382 |
until i = 0; |
|
498 | 383 |
if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then |
876 | 384 |
Gear^.doStep:= @doStepShotIdle |
4 | 385 |
end; |
386 |
||
387 |
//////////////////////////////////////////////////////////////////////////////// |
|
559 | 388 |
procedure doStepDEagleShotWork(Gear: PGear); |
38 | 389 |
var i, x, y: LongWord; |
351 | 390 |
oX, oY: hwFloat; |
38 | 391 |
begin |
392 |
AllInactive:= false; |
|
876 | 393 |
inc(Gear^.Timer); |
37 | 394 |
i:= 80; |
351 | 395 |
oX:= Gear^.X; |
396 |
oY:= Gear^.Y; |
|
37 | 397 |
repeat |
351 | 398 |
Gear^.X:= Gear^.X + Gear^.dX; |
399 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
400 |
x:= hwRound(Gear^.X); |
|
401 |
y:= hwRound(Gear^.Y); |
|
38 | 402 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) |
351 | 403 |
and (Land[y, x] <> 0) then inc(Gear^.Damage); |
519 | 404 |
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); |
38 | 405 |
dec(i) |
351 | 406 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
407 |
if Gear^.Damage > 0 then |
|
37 | 408 |
begin |
351 | 409 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1); |
410 |
dec(Gear^.Health, Gear^.Damage); |
|
411 |
Gear^.Damage:= 0 |
|
37 | 412 |
end; |
498 | 413 |
if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then |
876 | 414 |
Gear^.doStep:= @doStepShotIdle |
37 | 415 |
end; |
416 |
||
559 | 417 |
procedure doStepDEagleShot(Gear: PGear); |
418 |
begin |
|
419 |
PlaySound(sndGun, false); |
|
420 |
Gear^.doStep:= @doStepDEagleShotWork |
|
421 |
end; |
|
422 |
||
37 | 423 |
//////////////////////////////////////////////////////////////////////////////// |
4 | 424 |
procedure doStepActionTimer(Gear: PGear); |
425 |
begin |
|
351 | 426 |
dec(Gear^.Timer); |
427 |
case Gear^.Kind of |
|
83 | 428 |
gtATStartGame: begin |
4 | 429 |
AllInactive:= false; |
351 | 430 |
if Gear^.Timer = 0 then |
83 | 431 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
4 | 432 |
end; |
83 | 433 |
gtATSmoothWindCh: begin |
351 | 434 |
if Gear^.Timer = 0 then |
6 | 435 |
begin |
351 | 436 |
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) |
437 |
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); |
|
438 |
if WindBarWidth <> Gear^.Tag then Gear^.Timer:= 10; |
|
83 | 439 |
end |
440 |
end; |
|
441 |
gtATFinishGame: begin |
|
442 |
AllInactive:= false; |
|
351 | 443 |
if Gear^.Timer = 0 then |
113 | 444 |
begin |
445 |
SendIPC('N'); |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
446 |
SendIPC('q'); |
83 | 447 |
GameState:= gsExit |
113 | 448 |
end |
6 | 449 |
end; |
4 | 450 |
end; |
351 | 451 |
if Gear^.Timer = 0 then DeleteGear(Gear) |
4 | 452 |
end; |
453 |
||
454 |
//////////////////////////////////////////////////////////////////////////////// |
|
455 |
procedure doStepPickHammerWork(Gear: PGear); |
|
371 | 456 |
var i, ei: LongInt; |
4 | 457 |
HHGear: PGear; |
458 |
begin |
|
70 | 459 |
AllInactive:= false; |
351 | 460 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
461 |
dec(Gear^.Timer); |
|
462 |
if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then |
|
1200 | 463 |
begin |
464 |
StopSound(sndPickhammer); |
|
465 |
DeleteGear(Gear); |
|
466 |
AfterAttack; |
|
467 |
exit |
|
468 |
end; |
|
845 | 469 |
|
422 | 470 |
if (Gear^.Timer mod 33) = 0 then |
1200 | 471 |
begin |
472 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
473 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 7, 6, EXPLDontDraw); |
|
474 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
475 |
end; |
|
422 | 476 |
|
477 |
if (Gear^.Timer mod 47) = 0 then |
|
1200 | 478 |
begin |
479 |
i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
|
480 |
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
481 |
while i <= ei do |
|
482 |
begin |
|
483 |
DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); |
|
484 |
inc(i, 1) |
|
485 |
end; |
|
486 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
487 |
Gear^.Y:= Gear^.Y + _1_9; |
|
488 |
SetAllHHToActive; |
|
489 |
end; |
|
4 | 490 |
if TestCollisionYwithGear(Gear, 1) then |
1200 | 491 |
begin |
492 |
Gear^.dY:= _0; |
|
493 |
SetLittle(HHGear^.dX); |
|
494 |
HHGear^.dY:= _0; |
|
495 |
end else |
|
496 |
begin |
|
497 |
Gear^.dY:= Gear^.dY + cGravity; |
|
498 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1417 | 499 |
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 |
1200 | 500 |
end; |
4 | 501 |
|
351 | 502 |
Gear^.X:= Gear^.X + HHGear^.dX; |
503 |
HHGear^.X:= Gear^.X; |
|
498 | 504 |
HHGear^.Y:= Gear^.Y - int2hwFloat(cHHRadius); |
4 | 505 |
|
351 | 506 |
if (Gear^.Message and gm_Attack) <> 0 then |
507 |
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else |
|
508 |
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
509 |
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else |
|
510 |
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3 |
|
498 | 511 |
else Gear^.dX:= _0; |
4 | 512 |
end; |
513 |
||
514 |
procedure doStepPickHammer(Gear: PGear); |
|
371 | 515 |
var i, y: LongInt; |
4 | 516 |
ar: TRangeArray; |
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
517 |
HHGear: PGear; |
4 | 518 |
begin |
519 |
i:= 0; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
520 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
521 |
|
498 | 522 |
y:= hwRound(Gear^.Y) - cHHRadius * 2; |
351 | 523 |
while y < hwRound(Gear^.Y) do |
4 | 524 |
begin |
371 | 525 |
ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
526 |
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 527 |
inc(y, 2); |
528 |
inc(i) |
|
529 |
end; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
530 |
|
498 | 531 |
DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i)); |
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
532 |
Gear^.dY:= HHGear^.dY; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
533 |
DeleteCI(HHGear); |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
534 |
|
282 | 535 |
PlaySound(sndPickhammer, true); |
4 | 536 |
doStepPickHammerWork(Gear); |
351 | 537 |
Gear^.doStep:= @doStepPickHammerWork |
4 | 538 |
end; |
539 |
||
540 |
//////////////////////////////////////////////////////////////////////////////// |
|
371 | 541 |
var BTPrevAngle, BTSteps: LongInt; |
302 | 542 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
543 |
procedure doStepBlowTorchWork(Gear: PGear); |
302 | 544 |
var HHGear: PGear; |
305 | 545 |
b: boolean; |
302 | 546 |
begin |
547 |
AllInactive:= false; |
|
351 | 548 |
dec(Gear^.Timer); |
549 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
550 |
|
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
551 |
HedgehogChAngle(HHGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
552 |
|
305 | 553 |
b:= false; |
554 |
||
371 | 555 |
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
305 | 556 |
begin |
498 | 557 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); |
355 | 558 |
Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); |
351 | 559 |
BTPrevAngle:= HHGear^.Angle; |
358 | 560 |
b:= true |
305 | 561 |
end; |
562 |
||
351 | 563 |
if Gear^.Timer mod cHHStepTicks = 0 then |
302 | 564 |
begin |
305 | 565 |
b:= true; |
498 | 566 |
if Gear^.dX.isNegative then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right |
567 |
else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left; |
|
357 | 568 |
|
569 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
302 | 570 |
HedgehogStep(HHGear); |
357 | 571 |
HHGear^.State:= HHGear^.State or gstAttacking; |
305 | 572 |
|
573 |
inc(BTSteps); |
|
511 | 574 |
if BTSteps = 7 then |
305 | 575 |
begin |
576 |
BTSteps:= 0; |
|
511 | 577 |
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); |
578 |
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); |
|
351 | 579 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
511 | 580 |
AmmoShove(Gear, 2, 14); |
351 | 581 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
305 | 582 |
end; |
583 |
||
542 | 584 |
if (HHGear^.State and gstMoving) <> 0 then Gear^.Timer:= 0 |
302 | 585 |
end; |
305 | 586 |
|
587 |
if b then |
|
498 | 588 |
DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
351 | 589 |
Gear^.dX, Gear^.dY, |
306 | 590 |
cHHRadius * 5, cHHRadius * 2 + 6); |
305 | 591 |
|
351 | 592 |
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) then |
302 | 593 |
begin |
351 | 594 |
HHGear^.Message:= 0; |
302 | 595 |
DeleteGear(Gear); |
596 |
AfterAttack |
|
597 |
end |
|
598 |
end; |
|
599 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
600 |
procedure doStepBlowTorch(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
601 |
var HHGear: PGear; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
602 |
begin |
371 | 603 |
BTPrevAngle:= High(LongInt); |
305 | 604 |
BTSteps:= 0; |
351 | 605 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
606 |
HHGear^.Message:= 0; |
|
607 |
Gear^.doStep:= @doStepBlowTorchWork |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
608 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
609 |
|
302 | 610 |
//////////////////////////////////////////////////////////////////////////////// |
611 |
||
4 | 612 |
procedure doStepRopeWork(Gear: PGear); |
70 | 613 |
const flCheck: boolean = false; |
4 | 614 |
var HHGear: PGear; |
789 | 615 |
len, cs, cc, tx, ty, nx, ny: hwFloat; |
108 | 616 |
lx, ly: LongInt; |
4 | 617 |
|
618 |
procedure DeleteMe; |
|
619 |
begin |
|
620 |
with HHGear^ do |
|
621 |
begin |
|
622 |
Message:= Message and not gm_Attack; |
|
542 | 623 |
State:= State or gstMoving; |
4 | 624 |
end; |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
625 |
DeleteGear(Gear) |
4 | 626 |
end; |
627 |
||
628 |
begin |
|
351 | 629 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 630 |
|
351 | 631 |
if ((HHGear^.State and gstHHDriven) = 0) |
80 | 632 |
or (CheckGearDrowning(HHGear)) then |
4 | 633 |
begin |
634 |
DeleteMe; |
|
635 |
exit |
|
636 |
end; |
|
928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
925
diff
changeset
|
637 |
|
351 | 638 |
Gear^.dX:= HHGear^.X - Gear^.X; |
639 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
4 | 640 |
|
351 | 641 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
642 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 643 |
|
351 | 644 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 645 |
|
351 | 646 |
cs:= Gear^.dY + HHGear^.dY; |
647 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 648 |
len:= _1 / Distance(cc, cs); |
789 | 649 |
cc:= cc * len; // rope vector plus hedgehog direction vector normalized |
108 | 650 |
cs:= cs * len; |
4 | 651 |
|
1361 | 652 |
nx:= SignAs(cs, HHGear^.dX) * 7; // hedgehog direction normalized with length 7 |
653 |
ny:= SignAs(cc, HHGear^.dY) * 7; |
|
789 | 654 |
|
4 | 655 |
flCheck:= not flCheck; |
656 |
if flCheck then // check whether rope needs dividing |
|
657 |
begin |
|
498 | 658 |
len:= Gear^.Elasticity - _20; |
659 |
while len > _5 do |
|
4 | 660 |
begin |
661 |
tx:= cc*len; |
|
662 |
ty:= cs*len; |
|
789 | 663 |
lx:= hwRound(Gear^.X + tx + nx); |
664 |
ly:= hwRound(Gear^.Y + ty + ny); |
|
652 | 665 |
if ((ly and $FFFFFC00) = 0) and ((lx and $FFFFF800) = 0) and (Land[ly, lx] <> 0) then |
4 | 666 |
begin |
667 |
with RopePoints.ar[RopePoints.Count] do |
|
668 |
begin |
|
351 | 669 |
X:= Gear^.X; |
670 |
Y:= Gear^.Y; |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
671 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); |
351 | 672 |
b:= (cc * HHGear^.dY) > (cs * HHGear^.dX); |
4 | 673 |
dLen:= len |
674 |
end; |
|
351 | 675 |
Gear^.X:= Gear^.X + tx; |
676 |
Gear^.Y:= Gear^.Y + ty; |
|
4 | 677 |
inc(RopePoints.Count); |
789 | 678 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
351 | 679 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
680 |
Gear^.Friction:= Gear^.Friction - len; |
|
4 | 681 |
break |
682 |
end; |
|
1361 | 683 |
len:= len - _0_5 |
4 | 684 |
end; |
685 |
end else |
|
686 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
|
687 |
begin |
|
688 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
689 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
351 | 690 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
4 | 691 |
begin |
692 |
dec(RopePoints.Count); |
|
351 | 693 |
Gear^.X:=RopePoints.ar[RopePoints.Count].X; |
694 |
Gear^.Y:=RopePoints.ar[RopePoints.Count].Y; |
|
695 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
|
696 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
4 | 697 |
end |
698 |
end; |
|
699 |
||
351 | 700 |
Gear^.dX:= HHGear^.X - Gear^.X; |
701 |
Gear^.dY:= HHGear^.Y - Gear^.Y; |
|
108 | 702 |
|
351 | 703 |
cs:= Gear^.dY + HHGear^.dY; |
704 |
cc:= Gear^.dX + HHGear^.dX; |
|
498 | 705 |
len:= _1 / Distance(cc, cs); |
108 | 706 |
cc:= cc * len; |
707 |
cs:= cs * len; |
|
4 | 708 |
|
351 | 709 |
HHGear^.dX:= HHGear^.X; |
710 |
HHGear^.dY:= HHGear^.Y; |
|
4 | 711 |
|
351 | 712 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
713 |
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
|
714 |
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
4 | 715 |
|
498 | 716 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
351 | 717 |
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear^.dX)) |
718 |
or TestCollisionYwithGear(HHGear, -hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
4 | 719 |
|
351 | 720 |
HHGear^.X:= Gear^.X + cc*Gear^.Elasticity; |
721 |
HHGear^.Y:= Gear^.Y + cs*Gear^.Elasticity; |
|
4 | 722 |
|
351 | 723 |
HHGear^.dX:= HHGear^.X - HHGear^.dX; |
724 |
HHGear^.dY:= HHGear^.Y - HHGear^.dY; |
|
4 | 725 |
|
351 | 726 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
727 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
|
728 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
|
729 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
|
4 | 730 |
|
789 | 731 |
len:= Distance(HHGear^.dX, HHGear^.dY); |
940 | 732 |
if len > _0_8 then |
789 | 733 |
begin |
940 | 734 |
len:= _0_8 / len; |
789 | 735 |
HHGear^.dX:= HHGear^.dX * len; |
736 |
HHGear^.dY:= HHGear^.dY * len; |
|
737 |
end; |
|
738 |
||
351 | 739 |
if (Gear^.Message and gm_Attack) <> 0 then |
740 |
if (Gear^.State and gsttmpFlag) <> 0 then DeleteMe else |
|
741 |
else if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 742 |
end; |
743 |
||
744 |
||
745 |
procedure doStepRopeAttach(Gear: PGear); |
|
746 |
var HHGear: PGear; |
|
351 | 747 |
tx, ty, tt: hwFloat; |
4 | 748 |
begin |
351 | 749 |
Gear^.X:= Gear^.X - Gear^.dX; |
750 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 751 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 752 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 753 |
DeleteCI(HHGear); |
542 | 754 |
if (HHGear^.State and gstMoving) <> 0 then |
1433 | 755 |
if TestCollisionYwithGear(HHGear, 1) then |
756 |
begin |
|
757 |
CheckHHDamage(HHGear); |
|
758 |
HHGear^.dY:= _0; |
|
759 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
|
760 |
end else |
|
761 |
begin |
|
762 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
|
763 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
764 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
765 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
766 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
767 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
768 |
tt:= Gear^.Elasticity; |
|
769 |
tx:= _0; |
|
770 |
ty:= _0; |
|
771 |
while tt > _20 do |
|
772 |
begin |
|
773 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
|
774 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
775 |
begin |
|
776 |
Gear^.X:= Gear^.X + tx; |
|
777 |
Gear^.Y:= Gear^.Y + ty; |
|
778 |
Gear^.Elasticity:= tt; |
|
779 |
Gear^.doStep:= @doStepRopeWork; |
|
780 |
with HHGear^ do State:= State and not gstAttacking; |
|
781 |
tt:= _0 |
|
782 |
end; |
|
783 |
tx:= tx + Gear^.dX + Gear^.dX; |
|
784 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
785 |
tt:= tt - _2; |
|
786 |
end; |
|
787 |
end; |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
788 |
|
4 | 789 |
CheckCollision(Gear); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
790 |
|
351 | 791 |
if (Gear^.State and gstCollision) <> 0 then |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
792 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
793 |
Gear^.doStep:= @doStepRopeWork; |
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset
|
794 |
with HHGear^ do State:= State and not (gstAttacking or gstHHHJump); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
795 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
796 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
797 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
798 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
799 |
if Gear^.Elasticity < _10 then |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
800 |
Gear^.Elasticity:= _10000; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
801 |
end; |
4 | 802 |
|
351 | 803 |
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then |
1433 | 804 |
begin |
805 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
|
806 |
begin |
|
807 |
State:= State and not gstAttacking; |
|
808 |
Message:= Message and not gm_Attack |
|
809 |
end; |
|
810 |
DeleteGear(Gear) |
|
811 |
end |
|
4 | 812 |
end; |
813 |
||
814 |
procedure doStepRope(Gear: PGear); |
|
815 |
begin |
|
351 | 816 |
Gear^.dX:= - Gear^.dX; |
817 |
Gear^.dY:= - Gear^.dY; |
|
818 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 819 |
end; |
820 |
||
821 |
//////////////////////////////////////////////////////////////////////////////// |
|
822 |
procedure doStepSmokeTrace(Gear: PGear); |
|
823 |
begin |
|
351 | 824 |
inc(Gear^.Timer); |
825 |
if Gear^.Timer > 64 then |
|
1133 | 826 |
begin |
827 |
Gear^.Timer:= 0; |
|
828 |
dec(Gear^.State) |
|
829 |
end; |
|
351 | 830 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
831 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
832 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 833 |
end; |
9 | 834 |
|
835 |
//////////////////////////////////////////////////////////////////////////////// |
|
1045 | 836 |
procedure doStepExplosionWork(Gear: PGear); |
9 | 837 |
begin |
351 | 838 |
inc(Gear^.Timer); |
839 |
if Gear^.Timer > 75 then |
|
1133 | 840 |
begin |
841 |
inc(Gear^.State); |
|
842 |
Gear^.Timer:= 0; |
|
843 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
844 |
end; |
|
9 | 845 |
end; |
10 | 846 |
|
1045 | 847 |
procedure doStepExplosion(Gear: PGear); |
848 |
var i: LongWord; |
|
849 |
begin |
|
1047 | 850 |
for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire); |
851 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart); |
|
852 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2); |
|
1045 | 853 |
Gear^.doStep:= @doStepExplosionWork |
854 |
end; |
|
855 |
||
10 | 856 |
//////////////////////////////////////////////////////////////////////////////// |
857 |
procedure doStepMine(Gear: PGear); |
|
858 |
begin |
|
542 | 859 |
if (Gear^.State and gstMoving) <> 0 then |
914 | 860 |
begin |
861 |
DeleteCI(Gear); |
|
862 |
doStepFallingGear(Gear); |
|
863 |
if (Gear^.State and gstMoving) = 0 then |
|
864 |
begin |
|
865 |
AddGearCI(Gear); |
|
866 |
Gear^.dX:= _0; |
|
867 |
Gear^.dY:= _0 |
|
868 |
end; |
|
869 |
CalcRotationDirAngle(Gear); |
|
870 |
AllInactive:= false |
|
871 |
end else |
|
872 |
if ((GameTicks and $3F) = 25) then |
|
873 |
doStepFallingGear(Gear); |
|
351 | 874 |
|
875 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
1133 | 876 |
if ((Gear^.State and gstAttacking) = 0) then |
877 |
begin |
|
878 |
if ((GameTicks and $1F) = 0) then |
|
879 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking |
|
880 |
end else // gstAttacking <> 0 |
|
881 |
begin |
|
882 |
AllInactive:= false; |
|
883 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false); |
|
884 |
if Gear^.Timer = 0 then |
|
885 |
begin |
|
886 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
887 |
DeleteGear(Gear); |
|
888 |
exit |
|
889 |
end; |
|
890 |
dec(Gear^.Timer); |
|
891 |
end else // gsttmpFlag = 0 |
|
892 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
10 | 893 |
end; |
57 | 894 |
|
39 | 895 |
//////////////////////////////////////////////////////////////////////////////// |
896 |
procedure doStepDynamite(Gear: PGear); |
|
897 |
begin |
|
43 | 898 |
doStepFallingGear(Gear); |
899 |
AllInactive:= false; |
|
351 | 900 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
901 |
if Gear^.Timer = 0 then |
|
1133 | 902 |
begin |
903 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
904 |
DeleteGear(Gear); |
|
905 |
exit |
|
906 |
end; |
|
351 | 907 |
dec(Gear^.Timer); |
39 | 908 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
909 |
|
351 | 910 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
911 |
procedure doStepCase(Gear: PGear); |
371 | 912 |
var i, x, y: LongInt; |
1436 | 913 |
k: TGearType; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
914 |
begin |
351 | 915 |
if (Gear^.Message and gm_Destroy) > 0 then |
1133 | 916 |
begin |
917 |
DeleteGear(Gear); |
|
918 |
FreeActionsList; |
|
919 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
|
920 |
with CurrentHedgehog^ do |
|
921 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
922 |
exit |
|
923 |
end; |
|
15 | 924 |
|
351 | 925 |
if Gear^.Damage > 0 then |
1133 | 926 |
begin |
927 |
x:= hwRound(Gear^.X); |
|
928 |
y:= hwRound(Gear^.Y); |
|
1436 | 929 |
k:= Gear^.Kind; |
930 |
DeleteGear(Gear); // <-- delete gear! |
|
931 |
||
932 |
if k = gtCase then |
|
1133 | 933 |
begin |
934 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
935 |
for i:= 0 to 63 do |
|
936 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
937 |
end; |
|
938 |
exit |
|
939 |
end; |
|
79 | 940 |
|
351 | 941 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
1133 | 942 |
begin |
943 |
AllInactive:= false; |
|
944 |
Gear^.dY:= Gear^.dY + cGravity; |
|
945 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
946 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
|
947 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
|
948 |
begin |
|
949 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
950 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
|
951 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false); |
|
952 |
end; |
|
953 |
CheckGearDrowning(Gear); |
|
954 |
end; |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
955 |
|
511 | 956 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1133 | 957 |
else if (Gear^.dY.QWordValue <> 0) then DeleteCI(Gear) |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
958 |
end; |
49 | 959 |
|
960 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 961 |
const cSorterWorkTime = 640; |
962 |
var thexchar: array[0..cMaxTeams] of |
|
1133 | 963 |
record |
964 |
dy, ny, dw: LongInt; |
|
965 |
team: PTeam; |
|
966 |
SortFactor: QWord; |
|
967 |
end; |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
968 |
currsorter: PGear = nil; |
49 | 969 |
|
970 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 971 |
var i: LongInt; |
49 | 972 |
begin |
973 |
AllInactive:= false; |
|
351 | 974 |
dec(Gear^.Timer); |
975 |
if (Gear^.Timer and 15) = 0 then |
|
1133 | 976 |
for i:= 0 to Pred(TeamsCount) do |
977 |
with thexchar[i] do |
|
978 |
begin |
|
979 |
{$WARNINGS OFF} |
|
980 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
|
981 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
982 |
{$WARNINGS ON} |
|
983 |
end; |
|
984 |
||
351 | 985 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
1133 | 986 |
begin |
987 |
if currsorter = Gear then currsorter:= nil; |
|
988 |
DeleteGear(Gear) |
|
989 |
end |
|
49 | 990 |
end; |
991 |
||
992 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
1133 | 993 |
var i: Longword; |
994 |
b: boolean; |
|
995 |
t: LongInt; |
|
49 | 996 |
begin |
997 |
AllInactive:= false; |
|
557 | 998 |
|
547 | 999 |
for t:= 0 to Pred(TeamsCount) do |
1133 | 1000 |
with thexchar[t] do |
1001 |
begin |
|
1002 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
1003 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
1004 |
team:= TeamsArray[t]; |
|
1005 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
1006 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
1007 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
1008 |
end; |
|
547 | 1009 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
1010 |
if TeamsCount > 1 then |
1133 | 1011 |
repeat |
1012 |
b:= true; |
|
1013 |
for t:= 0 to TeamsCount - 2 do |
|
1014 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
1015 |
begin |
|
1016 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
1017 |
thexchar[t]:= thexchar[Succ(t)]; |
|
1018 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
1019 |
b:= false |
|
1020 |
end |
|
1021 |
until b; |
|
557 | 1022 |
|
1120 | 1023 |
t:= - 4; |
557 | 1024 |
for i:= 0 to Pred(TeamsCount) do |
1133 | 1025 |
with thexchar[i] do |
1026 |
begin |
|
1027 |
dec(t, team^.HealthTex^.h + 2); |
|
1028 |
ny:= t; |
|
1029 |
dy:= dy - ny |
|
1030 |
end; |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
1031 |
|
557 | 1032 |
Gear^.Timer:= cSorterWorkTime; |
351 | 1033 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 1034 |
currsorter:= Gear |
49 | 1035 |
end; |
1036 |
||
79 | 1037 |
//////////////////////////////////////////////////////////////////////////////// |
854 | 1038 |
procedure doStepIdle(Gear: PGear); |
1039 |
begin |
|
1040 |
AllInactive:= false; |
|
925 | 1041 |
dec(Gear^.Timer); |
854 | 1042 |
if Gear^.Timer = 0 then |
1043 |
begin |
|
1044 |
DeleteGear(Gear); |
|
1045 |
AfterAttack |
|
1046 |
end |
|
1047 |
end; |
|
1048 |
||
79 | 1049 |
procedure doStepShover(Gear: PGear); |
1050 |
var HHGear: PGear; |
|
1051 |
begin |
|
351 | 1052 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1053 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1054 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1055 |
|
79 | 1056 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1057 |
|
351 | 1058 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 1059 |
Gear^.Timer:= 250; |
1060 |
Gear^.doStep:= @doStepIdle |
|
79 | 1061 |
end; |
1062 |
||
1063 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 1064 |
procedure doStepWhip(Gear: PGear); |
1065 |
var HHGear: PGear; |
|
1066 |
i: LongInt; |
|
1067 |
begin |
|
1068 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1069 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1070 |
DeleteCI(HHGear); |
925 | 1071 |
|
1072 |
for i:= 0 to 3 do |
|
1073 |
begin |
|
1074 |
AmmoShove(Gear, 30, 25); |
|
1075 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1076 |
end; |
|
1077 |
||
1078 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1079 |
Gear^.Timer:= 250; |
|
1080 |
Gear^.doStep:= @doStepIdle |
|
1081 |
end; |
|
1082 |
||
1083 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1084 |
procedure doStepFlame(Gear: PGear); |
1433 | 1085 |
var cWindFactor: hwFloat; |
79 | 1086 |
begin |
1087 |
AllInactive:= false; |
|
1433 | 1088 |
|
79 | 1089 |
if not TestCollisionYwithGear(Gear, 1) then |
1133 | 1090 |
begin |
1433 | 1091 |
cWindFactor:= cWindSpeed * 270; |
1092 |
||
1093 |
if hwAbs(Gear^.dX - cWindFactor) > _0_01 then |
|
1437 | 1094 |
Gear^.dX:= (Gear^.dX - cWindFactor) * _0_995 + cWindFactor; |
1297 | 1095 |
|
1133 | 1096 |
Gear^.dY:= Gear^.dY + cGravity; |
1097 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
1297 | 1098 |
|
1133 | 1099 |
Gear^.X:= Gear^.X + Gear^.dX; |
1100 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1297 | 1101 |
|
1417 | 1102 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
1133 | 1103 |
begin |
1104 |
DeleteGear(Gear); |
|
1105 |
exit |
|
1106 |
end |
|
1107 |
end else begin |
|
1108 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
|
1109 |
else begin |
|
1297 | 1110 |
Gear^.Radius:= 5; |
1111 |
AmmoShove(Gear, 3, 100); |
|
1112 |
Gear^.Radius:= 1; |
|
1113 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); |
|
1133 | 1114 |
dec(Gear^.Health); |
1297 | 1115 |
Gear^.Timer:= 1250 - Gear^.Tag * 12 |
1133 | 1116 |
end |
1117 |
end; |
|
79 | 1118 |
|
1295 | 1119 |
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then |
1120 |
// AmmoFlameWork(Gear); |
|
79 | 1121 |
|
351 | 1122 |
if Gear^.Health = 0 then |
1133 | 1123 |
DeleteGear(Gear) |
79 | 1124 |
end; |
82 | 1125 |
|
1126 |
//////////////////////////////////////////////////////////////////////////////// |
|
1127 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1128 |
var HHGear: PGear; |
|
1129 |
begin |
|
1130 |
AllInactive:= false; |
|
351 | 1131 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
1133 | 1132 |
begin |
1133 |
DeleteGear(Gear); |
|
1134 |
AfterAttack; |
|
1135 |
exit |
|
1136 |
end; |
|
82 | 1137 |
|
351 | 1138 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1139 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
1133 | 1140 |
begin |
1141 |
Gear^.Tag:= hwRound(HHGear^.Y); |
|
1142 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
|
1143 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1144 |
Gear^.Y:= HHGear^.Y; |
|
1145 |
AmmoShove(Gear, 30, 40); |
|
1146 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
1147 |
end; |
|
351 | 1148 |
|
1149 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1150 |
if not (HHGear^.dY.isNegative) then |
|
1133 | 1151 |
begin |
1152 |
HHGear^.State:= HHGear^.State or gstMoving; |
|
1153 |
DeleteGear(Gear); |
|
1154 |
AfterAttack; |
|
1155 |
exit |
|
1156 |
end; |
|
351 | 1157 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1158 |
end; |
1159 |
||
1160 |
procedure doStepFirePunch(Gear: PGear); |
|
1161 |
var HHGear: PGear; |
|
1162 |
begin |
|
1163 |
AllInactive:= false; |
|
351 | 1164 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1165 |
DeleteCI(HHGear); |
498 | 1166 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1167 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1168 |
|
351 | 1169 |
HHGear^.dY:= - _0_3; |
82 | 1170 |
|
351 | 1171 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1172 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1173 |
Gear^.dY:= - _0_9; |
1174 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1175 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
1279 | 1176 |
|
1177 |
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false) |
|
82 | 1178 |
end; |
1179 |
||
263 | 1180 |
//////////////////////////////////////////////////////////////////////////////// |
1181 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1182 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1183 |
var HHGear: PGear; |
1184 |
begin |
|
351 | 1185 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1186 |
|
516 | 1187 |
inc(Gear^.Timer); |
1188 |
||
212 | 1189 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1190 |
or ((HHGear^.State and gstHHDriven) = 0) |
1191 |
or CheckGearDrowning(HHGear) |
|
1192 |
or ((Gear^.Message and gm_Attack) <> 0) then |
|
1193 |
begin |
|
1194 |
with HHGear^ do |
|
1195 |
begin |
|
1196 |
Message:= 0; |
|
1197 |
SetLittle(dX); |
|
1198 |
dY:= _0; |
|
1199 |
State:= State or gstMoving; |
|
1200 |
end; |
|
1201 |
DeleteGear(Gear); |
|
1202 |
exit |
|
1203 |
end; |
|
211 | 1204 |
|
351 | 1205 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1133 | 1206 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
211 | 1207 |
|
351 | 1208 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1209 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1210 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1211 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1212 |
|
351 | 1213 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1214 |
Gear^.X:= HHGear^.X; |
1215 |
Gear^.Y:= HHGear^.Y |
|
263 | 1216 |
end; |
211 | 1217 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1218 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1219 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1220 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1221 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1222 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1223 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1224 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1225 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1226 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1227 |
|
931 | 1228 |
HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked or gstMoving); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1229 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1230 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1231 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1232 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1233 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1234 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1235 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1236 |
|
263 | 1237 |
//////////////////////////////////////////////////////////////////////////////// |
1238 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1239 |
begin |
|
1240 |
AllInactive:= false; |
|
498 | 1241 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
1124 | 1242 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1243 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
1124 | 1244 |
begin |
1245 |
dec(Gear^.Health); |
|
1246 |
case Gear^.State of |
|
1247 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1248 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1249 |
end; |
|
1250 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
|
1251 |
end; |
|
1252 |
||
1253 |
if (GameTicks and $3F) = 0 then |
|
1254 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1255 |
||
498 | 1256 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1257 |
end; |
1258 |
||
1259 |
procedure doStepAirAttack(Gear: PGear); |
|
1260 |
begin |
|
1261 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1262 |
|
408 | 1263 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1264 |
else Gear^.Tag:= -1; |
|
498 | 1265 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1124 | 1266 |
Gear^.Y:= -_300; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1267 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1268 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1269 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
1133 | 1270 |
Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 / cGravity) * Gear^.Tag; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1271 |
|
351 | 1272 |
Gear^.Health:= 6; |
801 | 1273 |
Gear^.doStep:= @doStepAirAttackWork; |
1274 |
PlaySound(sndIncoming, false) |
|
263 | 1275 |
end; |
1276 |
||
1277 |
//////////////////////////////////////////////////////////////////////////////// |
|
1278 |
||
1279 |
procedure doStepAirBomb(Gear: PGear); |
|
1280 |
begin |
|
1281 |
AllInactive:= false; |
|
1282 |
doStepFallingGear(Gear); |
|
351 | 1283 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 1284 |
begin |
1285 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1286 |
DeleteGear(Gear); |
|
1287 |
exit |
|
1288 |
end; |
|
263 | 1289 |
if (GameTicks and $3F) = 0 then |
1133 | 1290 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1291 |
end; |
409 | 1292 |
|
1293 |
//////////////////////////////////////////////////////////////////////////////// |
|
1294 |
||
1295 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1296 |
var HHGear: PGear; |
409 | 1297 |
begin |
1298 |
AllInactive:= false; |
|
415 | 1299 |
|
1300 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1301 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1302 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1303 |
sprAmGirder, Gear^.State, true) then |
1133 | 1304 |
begin |
1305 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1306 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1307 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1308 |
DeleteGear(Gear); |
|
1309 |
isCursorVisible:= true |
|
1310 |
end |
|
1311 |
else begin |
|
1312 |
DeleteGear(Gear); |
|
1313 |
AfterAttack |
|
1314 |
end; |
|
415 | 1315 |
TargetPoint.X:= NoPointX |
409 | 1316 |
end; |
520 | 1317 |
|
1318 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1319 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1320 |
var HHGear: PGear; |
1321 |
begin |
|
1322 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1323 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1324 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1325 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1326 |
or CheckGearDrowning(HHGear) then |
1327 |
begin |
|
1328 |
DeleteGear(Gear); |
|
1329 |
AfterAttack |
|
1330 |
end |
|
912 | 1331 |
end; |
1332 |
||
1333 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1334 |
begin |
853 | 1335 |
inc(Gear^.Timer); |
1336 |
if Gear^.Timer = 65 then |
|
1337 |
begin |
|
1338 |
Gear^.Timer:= 0; |
|
1339 |
inc(Gear^.Pos); |
|
1340 |
if Gear^.Pos = 11 then |
|
912 | 1341 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1342 |
end |
525 | 1343 |
end; |
520 | 1344 |
|
1345 |
procedure doStepTeleport(Gear: PGear); |
|
1346 |
var HHGear: PGear; |
|
1347 |
begin |
|
1348 |
AllInactive:= false; |
|
1349 |
||
1350 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1351 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1352 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1353 |
sprHHTelepMask, 0, false) then |
|
853 | 1354 |
begin |
1355 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1356 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1357 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1358 |
DeleteGear(Gear); |
|
1359 |
isCursorVisible:= true |
|
1360 |
end |
|
1361 |
else begin |
|
1362 |
DeleteCI(HHGear); |
|
1363 |
SetAllHHToActive; |
|
912 | 1364 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1365 |
Gear^.X:= HHGear^.X; |
1366 |
Gear^.Y:= HHGear^.Y; |
|
1367 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1368 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1369 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1370 |
end; |
|
520 | 1371 |
TargetPoint.X:= NoPointX |
1372 |
end; |
|
534 | 1373 |
|
1374 |
//////////////////////////////////////////////////////////////////////////////// |
|
1375 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1376 |
var HHGear: PGear; |
|
1377 |
Msg, State: Longword; |
|
1378 |
begin |
|
1379 |
AllInactive:= false; |
|
1380 |
||
540 | 1381 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1382 |
begin |
1383 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1384 |
Msg:= Gear^.Message and not gm_Switch; |
|
1385 |
DeleteGear(Gear); |
|
1386 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1387 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1388 |
|
1133 | 1389 |
HHGear:= CurrentHedgehog^.Gear; |
1390 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1391 |
HHGear^.Message:= Msg; |
|
1392 |
exit |
|
1393 |
end; |
|
534 | 1394 |
|
1395 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1396 |
begin |
1397 |
HHGear:= CurrentHedgehog^.Gear; |
|
1398 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1399 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1400 |
State:= HHGear^.State; |
|
1401 |
HHGear^.State:= 0; |
|
1402 |
HHGear^.Active:= false; |
|
1403 |
HHGear^.Z:= cHHZ; |
|
1404 |
RemoveGearFromList(HHGear); |
|
1405 |
InsertGearToList(HHGear); |
|
534 | 1406 |
|
1133 | 1407 |
repeat |
1408 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1409 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1410 |
|
1133 | 1411 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1412 |
|
1133 | 1413 |
HHGear:= CurrentHedgehog^.Gear; |
1414 |
HHGear^.State:= State; |
|
1415 |
HHGear^.Active:= true; |
|
1416 |
FollowGear:= HHGear; |
|
1417 |
HHGear^.Z:= cCurrHHZ; |
|
1418 |
RemoveGearFromList(HHGear); |
|
1419 |
InsertGearToList(HHGear); |
|
1420 |
Gear^.X:= HHGear^.X; |
|
1421 |
Gear^.Y:= HHGear^.Y |
|
1422 |
end; |
|
534 | 1423 |
end; |
1424 |
||
1425 |
procedure doStepSwitcher(Gear: PGear); |
|
1426 |
var HHGear: PGear; |
|
1427 |
begin |
|
1428 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1429 |
||
1430 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1431 |
with HHGear^ do |
|
1133 | 1432 |
begin |
1433 |
State:= State and not gstAttacking; |
|
1434 |
Message:= Message and not gm_Attack |
|
1435 |
end |
|
534 | 1436 |
end; |
924 | 1437 |
|
1438 |
//////////////////////////////////////////////////////////////////////////////// |
|
1439 |
procedure doStepMortar(Gear: PGear); |
|
1440 |
var dX, dY: hwFloat; |
|
1441 |
i: LongInt; |
|
963 | 1442 |
dxn, dyn: boolean; |
924 | 1443 |
begin |
1444 |
AllInactive:= false; |
|
963 | 1445 |
dxn:= Gear^.dX.isNegative; |
1446 |
dyn:= Gear^.dY.isNegative; |
|
1447 |
||
924 | 1448 |
doStepFallingGear(Gear); |
1449 |
if (Gear^.State and gstCollision) <> 0 then |
|
1450 |
begin |
|
1451 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1452 |
|
1453 |
Gear^.dX.isNegative:= not dxn; |
|
1454 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1455 |
for i:= 0 to 4 do |
1456 |
begin |
|
963 | 1457 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1458 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1459 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1460 |
end; |
1461 |
||
1462 |
DeleteGear(Gear); |
|
1463 |
exit |
|
1464 |
end; |
|
963 | 1465 |
|
924 | 1466 |
if (GameTicks and $3F) = 0 then |
1467 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1468 |
end; |
|
984 | 1469 |
|
1470 |
//////////////////////////////////////////////////////////////////////////////// |
|
1471 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1472 |
const upd: Longword = 0; |
|
987 | 1473 |
var i: LongWord; |
984 | 1474 |
HHGear: PGear; |
1475 |
begin |
|
1476 |
AllInactive:= false; |
|
1477 |
||
1478 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1479 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1480 |
DeleteCI(HHGear); |
|
1481 |
||
1482 |
i:= 2; |
|
1483 |
repeat |
|
1484 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1485 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1486 |
HHGear^.X:= Gear^.X; |
|
1487 |
HHGear^.Y:= Gear^.Y; |
|
1488 |
||
1489 |
inc(Gear^.Damage, 2); |
|
1490 |
||
1200 | 1491 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1492 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1493 |
|
1494 |
dec(i) |
|
1495 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1496 |
||
1497 |
inc(upd); |
|
1498 |
if upd > 3 then |
|
1499 |
begin |
|
987 | 1500 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1501 |
||
984 | 1502 |
AmmoShove(Gear, 30, 40); |
1503 |
||
1504 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1505 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1506 |
HHGear^.dX, |
1507 |
HHGear^.dY, |
|
1508 |
20 + cHHRadius * 2, |
|
1200 | 1509 |
cHHRadius * 2 + 6); |
984 | 1510 |
|
1511 |
upd:= 0 |
|
1512 |
end; |
|
1513 |
||
1514 |
if Gear^.Health < Gear^.Damage then |
|
1515 |
begin |
|
1516 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1517 |
AfterAttack; |
|
1518 |
DeleteGear(Gear); |
|
1519 |
DeleteGear(HHGear); |
|
1520 |
end else |
|
1521 |
begin |
|
1522 |
dec(Gear^.Health, Gear^.Damage); |
|
1523 |
Gear^.Damage:= 0 |
|
1524 |
end |
|
1525 |
end; |
|
1526 |
||
987 | 1527 |
procedure doStepKamikazeIdle(Gear: PGear); |
1528 |
begin |
|
1529 |
AllInactive:= false; |
|
1530 |
dec(Gear^.Timer); |
|
1531 |
if Gear^.Timer = 0 then |
|
1532 |
begin |
|
1533 |
Gear^.Pos:= 1; |
|
992 | 1534 |
PlaySound(sndKamikaze, false); |
987 | 1535 |
Gear^.doStep:= @doStepKamikazeWork |
1536 |
end |
|
1537 |
end; |
|
1538 |
||
984 | 1539 |
procedure doStepKamikaze(Gear: PGear); |
1540 |
var HHGear: PGear; |
|
1541 |
begin |
|
1542 |
AllInactive:= false; |
|
1543 |
||
1544 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1545 |
||
1546 |
HHGear^.dX:= Gear^.dX; |
|
1547 |
HHGear^.dY:= Gear^.dY; |
|
1548 |
||
1549 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1550 |
Gear^.dY:= - _0_9; |
|
1551 |
||
987 | 1552 |
Gear^.Timer:= 550; |
1553 |
||
1554 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1555 |
end; |
1556 |
||
1103 | 1557 |
//////////////////////////////////////////////////////////////////////////////// |
1558 |
const cakeh = 27; |
|
1110 | 1559 |
cakeDmg = 75; |
1103 | 1560 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1561 |
CakeI: Longword; |
|
1562 |
||
1110 | 1563 |
procedure doStepCakeExpl(Gear: PGear); |
1564 |
begin |
|
1565 |
inc(Gear^.Tag); |
|
1566 |
if Gear^.Tag < 2250 then exit; |
|
1567 |
||
1568 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1569 |
AfterAttack; |
|
1570 |
DeleteGear(Gear) |
|
1571 |
end; |
|
1572 |
||
1109 | 1573 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1574 |
var gi: PGear; |
1575 |
dmg: LongInt; |
|
1109 | 1576 |
begin |
1577 |
AllInactive:= false; |
|
1578 |
||
1579 |
inc(Gear^.Tag); |
|
1580 |
if Gear^.Tag < 100 then exit; |
|
1581 |
Gear^.Tag:= 0; |
|
1582 |
||
1583 |
if Gear^.Pos = 0 then |
|
1584 |
begin |
|
1110 | 1585 |
gi:= GearsList; |
1586 |
while gi <> nil do |
|
1587 |
begin |
|
1588 |
dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); |
|
1589 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
|
1590 |
gi^.State:= gi^.State or gstWinner; |
|
1591 |
gi:= gi^.NextGear |
|
1592 |
end; |
|
1593 |
Gear^.doStep:= @doStepCakeExpl; |
|
1111 | 1594 |
PlaySound(sndCake, false) |
1109 | 1595 |
end else dec(Gear^.Pos) |
1596 |
end; |
|
1597 |
||
1598 |
||
1089 | 1599 |
procedure doStepCakeWork(Gear: PGear); |
1600 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1601 |
var xx, yy, xxn, yyn: LongInt; |
|
1602 |
da: LongInt; |
|
1103 | 1603 |
tdx, tdy: hwFloat; |
1089 | 1604 |
|
1605 |
procedure PrevAngle; |
|
1606 |
begin |
|
1133 | 1607 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1608 |
end; |
1609 |
||
1610 |
procedure NextAngle; |
|
1611 |
begin |
|
1133 | 1612 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1613 |
end; |
1614 |
||
1088 | 1615 |
begin |
1089 | 1616 |
inc(Gear^.Tag); |
1108 | 1617 |
if Gear^.Tag < 7 then exit; |
1089 | 1618 |
|
1619 |
dA:= hwSign(Gear^.dX); |
|
1620 |
xx:= dirs[Gear^.Angle].x; |
|
1621 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1622 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1623 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1624 |
|
1625 |
||
1626 |
if (xx = 0) then |
|
1627 |
if TestCollisionYwithGear(Gear, yy) then |
|
1628 |
PrevAngle |
|
1629 |
else begin |
|
1630 |
Gear^.Tag:= 0; |
|
1631 |
Gear^.Y:= Gear^.Y + int2hwFloat(yy); |
|
1632 |
if not TestCollisionXwithGear(Gear, xxn) then NextAngle |
|
1633 |
end; |
|
1634 |
||
1635 |
if (yy = 0) then |
|
1636 |
if TestCollisionXwithGear(Gear, xx) then |
|
1637 |
PrevAngle |
|
1638 |
else begin |
|
1639 |
Gear^.Tag:= 0; |
|
1640 |
Gear^.X:= Gear^.X + int2hwFloat(xx); |
|
1641 |
if not TestCollisionYwithGear(Gear, yyn) then NextAngle |
|
1642 |
end; |
|
1643 |
||
1103 | 1644 |
if Gear^.Tag = 0 then |
1645 |
begin |
|
1646 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1647 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1648 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1649 |
CakePoints[CakeI].x:= Gear^.X; |
|
1650 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1651 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1652 |
end; |
|
1653 |
||
1089 | 1654 |
dec(Gear^.Health); |
1090 | 1655 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1656 |
begin |
1109 | 1657 |
FollowGear:= Gear; |
1658 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1659 |
end |
1088 | 1660 |
end; |
1089 | 1661 |
|
1103 | 1662 |
procedure doStepCakeUp(Gear: PGear); |
1663 |
var i: Longword; |
|
1664 |
begin |
|
1665 |
AllInactive:= false; |
|
1666 |
||
1108 | 1667 |
inc(Gear^.Tag); |
1109 | 1668 |
if Gear^.Tag < 100 then exit; |
1108 | 1669 |
Gear^.Tag:= 0; |
1670 |
||
1109 | 1671 |
if Gear^.Pos = 6 then |
1103 | 1672 |
begin |
1673 |
for i:= 0 to Pred(cakeh) do |
|
1674 |
begin |
|
1675 |
CakePoints[i].x:= Gear^.X; |
|
1676 |
CakePoints[i].y:= Gear^.Y |
|
1677 |
end; |
|
1678 |
CakeI:= 0; |
|
1679 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1680 |
end else inc(Gear^.Pos) |
1103 | 1681 |
end; |
1682 |
||
1089 | 1683 |
procedure doStepCakeFall(Gear: PGear); |
1684 |
begin |
|
1685 |
AllInactive:= false; |
|
1686 |
||
1687 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1688 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1689 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1690 |
else |
1691 |
begin |
|
1692 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1693 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1694 |
end |
|
1695 |
end; |
|
1696 |
||
1697 |
procedure doStepCake(Gear: PGear); |
|
1698 |
var HHGear: PGear; |
|
1699 |
begin |
|
1700 |
AllInactive:= false; |
|
1701 |
||
1702 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1703 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1704 |
DeleteCI(HHGear); |
1705 |
||
1106 | 1706 |
FollowGear:= Gear; |
1707 |
||
1089 | 1708 |
Gear^.doStep:= @doStepCakeFall |
1709 |
end; |
|
1710 |
||
1259 | 1711 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1712 |
procedure doStepSeductionWork(Gear: PGear); |
1713 |
var x, y: LongInt; |
|
1259 | 1714 |
begin |
1715 |
AllInactive:= false; |
|
1284 | 1716 |
|
1717 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1718 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1719 |
x:= hwRound(Gear^.X); |
|
1720 |
y:= hwRound(Gear^.Y); |
|
1259 | 1721 |
|
1284 | 1722 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) then |
1723 |
if (Land[y, x] <> 0) then |
|
1724 |
begin |
|
1725 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1726 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1727 |
Gear^.dX:= Gear^.dX * _1_5; |
1728 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1729 |
AmmoShove(Gear, 0, 40); |
1286 | 1730 |
AfterAttack; |
1284 | 1731 |
DeleteGear(Gear) |
1732 |
end |
|
1733 |
else |
|
1734 |
else |
|
1286 | 1735 |
begin |
1736 |
AfterAttack; |
|
1284 | 1737 |
DeleteGear(Gear) |
1286 | 1738 |
end |
1739 |
end; |
|
1740 |
||
1741 |
procedure doStepSeductionWear(Gear: PGear); |
|
1742 |
begin |
|
1743 |
AllInactive:= false; |
|
1744 |
inc(Gear^.Timer); |
|
1745 |
if Gear^.Timer > 250 then |
|
1746 |
begin |
|
1747 |
Gear^.Timer:= 0; |
|
1388 | 1748 |
inc(Gear^.Pos); |
1749 |
if Gear^.Pos = 5 then |
|
1750 |
PlaySound(sndYoohoo, false) |
|
1286 | 1751 |
end; |
1367 | 1752 |
|
1753 |
if Gear^.Pos = 14 then |
|
1286 | 1754 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1755 |
end; |
1284 | 1756 |
|
1757 |
procedure doStepSeduction(Gear: PGear); |
|
1758 |
begin |
|
1759 |
AllInactive:= false; |
|
1760 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1761 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1762 |
end; |
1298 | 1763 |
|
1764 |
//////////////////////////////////////////////////////////////////////////////// |
|
1765 |
procedure doStepWaterUp(Gear: PGear); |
|
1766 |
var i: LongWord; |
|
1767 |
begin |
|
1768 |
AllInactive:= false; |
|
1769 |
||
1770 |
inc(Gear^.Timer); |
|
1771 |
if Gear^.Timer = 17 then |
|
1772 |
Gear^.Timer:= 0 |
|
1773 |
else |
|
1774 |
exit; |
|
1775 |
||
1776 |
if cWaterLine > 0 then |
|
1777 |
begin |
|
1778 |
dec(cWaterLine); |
|
1779 |
for i:= 0 to 2047 do |
|
1780 |
Land[cWaterLine, i]:= 0; |
|
1781 |
SetAllToActive |
|
1782 |
end; |
|
1783 |
||
1784 |
inc(Gear^.Tag); |
|
1343 | 1785 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1786 |
DeleteGear(Gear) |
1787 |
end; |