author | unc0rr |
Sun, 28 Sep 2008 22:47:13 +0000 | |
changeset 1296 | d7fffad44b7e |
parent 1295 | 27bec661581c |
child 1297 | 78670b0c4a23 |
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; |
|
499 |
if Gear^.Y > _1024 then Gear^.Timer:= 1 |
|
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 |
|
1142
2c522c1ded31
Last try to get rope not to get stuck in the ground
unc0rr
parents:
1133
diff
changeset
|
652 |
nx:= hwAbs(cs) * hwSign(HHGear^.dX) * 7; // hedgehog direction normalized with length 7 |
2c522c1ded31
Last try to get rope not to get stuck in the ground
unc0rr
parents:
1133
diff
changeset
|
653 |
ny:= hwAbs(cc) * hwSign(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; |
|
1207
ceaab010269e
Some adjusting... it still doesn't solve problem fully
unc0rr
parents:
1206
diff
changeset
|
683 |
len:= len - _0_2 |
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 |
68 | 755 |
if TestCollisionYwithGear(HHGear, 1) then |
4 | 756 |
begin |
820
a26537586400
Fix fall without damage trick, which could be performed with not attached rope
unc0rr
parents:
819
diff
changeset
|
757 |
CheckHHDamage(HHGear); |
498 | 758 |
HHGear^.dY:= _0; |
542 | 759 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
4 | 760 |
end else |
761 |
begin |
|
351 | 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; |
|
498 | 769 |
tx:= _0; |
770 |
ty:= _0; |
|
771 |
while tt > _20 do |
|
4 | 772 |
begin |
517 | 773 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
774 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
4 | 775 |
begin |
351 | 776 |
Gear^.X:= Gear^.X + tx; |
777 |
Gear^.Y:= Gear^.Y + ty; |
|
778 |
Gear^.Elasticity:= tt; |
|
779 |
Gear^.doStep:= @doStepRopeWork; |
|
4 | 780 |
with HHGear^ do State:= State and not gstAttacking; |
498 | 781 |
tt:= _0 |
4 | 782 |
end; |
517 | 783 |
tx:= tx + Gear^.dX + Gear^.dX; |
784 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
498 | 785 |
tt:= tt - _2; |
4 | 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 |
4 | 804 |
begin |
351 | 805 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
4 | 806 |
begin |
807 |
State:= State and not gstAttacking; |
|
808 |
Message:= Message and not gm_Attack |
|
809 |
end; |
|
810 |
DeleteGear(Gear) |
|
811 |
end |
|
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; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
913 |
begin |
351 | 914 |
if (Gear^.Message and gm_Destroy) > 0 then |
1133 | 915 |
begin |
916 |
DeleteGear(Gear); |
|
917 |
FreeActionsList; |
|
918 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
|
919 |
with CurrentHedgehog^ do |
|
920 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
921 |
exit |
|
922 |
end; |
|
15 | 923 |
|
351 | 924 |
if Gear^.Damage > 0 then |
1133 | 925 |
begin |
926 |
x:= hwRound(Gear^.X); |
|
927 |
y:= hwRound(Gear^.Y); |
|
928 |
DeleteGear(Gear); |
|
929 |
if Gear^.Kind = gtCase then |
|
930 |
begin |
|
931 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
932 |
for i:= 0 to 63 do |
|
933 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
934 |
end; |
|
935 |
exit |
|
936 |
end; |
|
79 | 937 |
|
351 | 938 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
1133 | 939 |
begin |
940 |
AllInactive:= false; |
|
941 |
Gear^.dY:= Gear^.dY + cGravity; |
|
942 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
943 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
|
944 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
|
945 |
begin |
|
946 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
947 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
|
948 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false); |
|
949 |
end; |
|
950 |
CheckGearDrowning(Gear); |
|
951 |
end; |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
952 |
|
511 | 953 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1133 | 954 |
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
|
955 |
end; |
49 | 956 |
|
957 |
//////////////////////////////////////////////////////////////////////////////// |
|
557 | 958 |
const cSorterWorkTime = 640; |
959 |
var thexchar: array[0..cMaxTeams] of |
|
1133 | 960 |
record |
961 |
dy, ny, dw: LongInt; |
|
962 |
team: PTeam; |
|
963 |
SortFactor: QWord; |
|
964 |
end; |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
965 |
currsorter: PGear = nil; |
49 | 966 |
|
967 |
procedure doStepTeamHealthSorterWork(Gear: PGear); |
|
371 | 968 |
var i: LongInt; |
49 | 969 |
begin |
970 |
AllInactive:= false; |
|
351 | 971 |
dec(Gear^.Timer); |
972 |
if (Gear^.Timer and 15) = 0 then |
|
1133 | 973 |
for i:= 0 to Pred(TeamsCount) do |
974 |
with thexchar[i] do |
|
975 |
begin |
|
976 |
{$WARNINGS OFF} |
|
977 |
team^.DrawHealthY:= ny + dy * Gear^.Timer div 640; |
|
978 |
team^.TeamHealthBarWidth:= team^.NewTeamHealthBarWidth + dw * Gear^.Timer div cSorterWorkTime; |
|
979 |
{$WARNINGS ON} |
|
980 |
end; |
|
981 |
||
351 | 982 |
if (Gear^.Timer = 0) or (currsorter <> Gear) then |
1133 | 983 |
begin |
984 |
if currsorter = Gear then currsorter:= nil; |
|
985 |
DeleteGear(Gear) |
|
986 |
end |
|
49 | 987 |
end; |
988 |
||
989 |
procedure doStepTeamHealthSorter(Gear: PGear); |
|
1133 | 990 |
var i: Longword; |
991 |
b: boolean; |
|
992 |
t: LongInt; |
|
49 | 993 |
begin |
994 |
AllInactive:= false; |
|
557 | 995 |
|
547 | 996 |
for t:= 0 to Pred(TeamsCount) do |
1133 | 997 |
with thexchar[t] do |
998 |
begin |
|
999 |
dy:= TeamsArray[t]^.DrawHealthY; |
|
1000 |
dw:= TeamsArray[t]^.TeamHealthBarWidth - TeamsArray[t]^.NewTeamHealthBarWidth; |
|
1001 |
team:= TeamsArray[t]; |
|
1002 |
SortFactor:= TeamsArray[t]^.Clan^.ClanHealth; |
|
1003 |
SortFactor:= (SortFactor shl 3) + TeamsArray[t]^.Clan^.ClanIndex; |
|
1004 |
SortFactor:= (SortFactor shl 30) + TeamsArray[t]^.TeamHealth; |
|
1005 |
end; |
|
547 | 1006 |
|
601
78a68cc4d846
Special game mode allowing the only clan on map for training mode
unc0rr
parents:
590
diff
changeset
|
1007 |
if TeamsCount > 1 then |
1133 | 1008 |
repeat |
1009 |
b:= true; |
|
1010 |
for t:= 0 to TeamsCount - 2 do |
|
1011 |
if (thexchar[t].SortFactor > thexchar[Succ(t)].SortFactor) then |
|
1012 |
begin |
|
1013 |
thexchar[cMaxTeams]:= thexchar[t]; |
|
1014 |
thexchar[t]:= thexchar[Succ(t)]; |
|
1015 |
thexchar[Succ(t)]:= thexchar[cMaxTeams]; |
|
1016 |
b:= false |
|
1017 |
end |
|
1018 |
until b; |
|
557 | 1019 |
|
1120 | 1020 |
t:= - 4; |
557 | 1021 |
for i:= 0 to Pred(TeamsCount) do |
1133 | 1022 |
with thexchar[i] do |
1023 |
begin |
|
1024 |
dec(t, team^.HealthTex^.h + 2); |
|
1025 |
ny:= t; |
|
1026 |
dy:= dy - ny |
|
1027 |
end; |
|
764
7513452b1d51
Now game looks almost like it did before switching to OpenGL
unc0rr
parents:
762
diff
changeset
|
1028 |
|
557 | 1029 |
Gear^.Timer:= cSorterWorkTime; |
351 | 1030 |
Gear^.doStep:= @doStepTeamHealthSorterWork; |
143 | 1031 |
currsorter:= Gear |
49 | 1032 |
end; |
1033 |
||
79 | 1034 |
//////////////////////////////////////////////////////////////////////////////// |
854 | 1035 |
procedure doStepIdle(Gear: PGear); |
1036 |
begin |
|
1037 |
AllInactive:= false; |
|
925 | 1038 |
dec(Gear^.Timer); |
854 | 1039 |
if Gear^.Timer = 0 then |
1040 |
begin |
|
1041 |
DeleteGear(Gear); |
|
1042 |
AfterAttack |
|
1043 |
end |
|
1044 |
end; |
|
1045 |
||
79 | 1046 |
procedure doStepShover(Gear: PGear); |
1047 |
var HHGear: PGear; |
|
1048 |
begin |
|
351 | 1049 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1050 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1051 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1052 |
|
79 | 1053 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1054 |
|
351 | 1055 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 1056 |
Gear^.Timer:= 250; |
1057 |
Gear^.doStep:= @doStepIdle |
|
79 | 1058 |
end; |
1059 |
||
1060 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 1061 |
procedure doStepWhip(Gear: PGear); |
1062 |
var HHGear: PGear; |
|
1063 |
i: LongInt; |
|
1064 |
begin |
|
1065 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1066 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1067 |
DeleteCI(HHGear); |
925 | 1068 |
|
1069 |
for i:= 0 to 3 do |
|
1070 |
begin |
|
1071 |
AmmoShove(Gear, 30, 25); |
|
1072 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1073 |
end; |
|
1074 |
||
1075 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1076 |
Gear^.Timer:= 250; |
|
1077 |
Gear^.doStep:= @doStepIdle |
|
1078 |
end; |
|
1079 |
||
1080 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1081 |
procedure doStepFlame(Gear: PGear); |
1082 |
begin |
|
1083 |
AllInactive:= false; |
|
1084 |
if not TestCollisionYwithGear(Gear, 1) then |
|
1133 | 1085 |
begin |
1086 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
|
1087 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1088 |
if hwAbs(Gear^.dX) > _0_1 then Gear^.dX:= Gear^.dX * _0_5; |
|
1089 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
1090 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1091 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1092 |
if not (Gear^.Y < _1024) then |
|
1093 |
begin |
|
1094 |
DeleteGear(Gear); |
|
1095 |
exit |
|
1096 |
end |
|
1097 |
end else begin |
|
1098 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
|
1099 |
else begin |
|
1295 | 1100 |
AmmoShove(Gear, 5, 5); |
1101 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 3, 0); |
|
1133 | 1102 |
dec(Gear^.Health); |
1103 |
Gear^.Timer:= 1250 - Gear^.Angle * 12 |
|
1104 |
end |
|
1105 |
end; |
|
79 | 1106 |
|
1295 | 1107 |
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then |
1108 |
// AmmoFlameWork(Gear); |
|
79 | 1109 |
|
351 | 1110 |
if Gear^.Health = 0 then |
1133 | 1111 |
DeleteGear(Gear) |
79 | 1112 |
end; |
82 | 1113 |
|
1114 |
//////////////////////////////////////////////////////////////////////////////// |
|
1115 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1116 |
var HHGear: PGear; |
|
1117 |
begin |
|
1118 |
AllInactive:= false; |
|
351 | 1119 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
1133 | 1120 |
begin |
1121 |
DeleteGear(Gear); |
|
1122 |
AfterAttack; |
|
1123 |
exit |
|
1124 |
end; |
|
82 | 1125 |
|
351 | 1126 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1127 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
1133 | 1128 |
begin |
1129 |
Gear^.Tag:= hwRound(HHGear^.Y); |
|
1130 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
|
1131 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1132 |
Gear^.Y:= HHGear^.Y; |
|
1133 |
AmmoShove(Gear, 30, 40); |
|
1134 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
1135 |
end; |
|
351 | 1136 |
|
1137 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1138 |
if not (HHGear^.dY.isNegative) then |
|
1133 | 1139 |
begin |
1140 |
HHGear^.State:= HHGear^.State or gstMoving; |
|
1141 |
DeleteGear(Gear); |
|
1142 |
AfterAttack; |
|
1143 |
exit |
|
1144 |
end; |
|
351 | 1145 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1146 |
end; |
1147 |
||
1148 |
procedure doStepFirePunch(Gear: PGear); |
|
1149 |
var HHGear: PGear; |
|
1150 |
begin |
|
1151 |
AllInactive:= false; |
|
351 | 1152 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1153 |
DeleteCI(HHGear); |
498 | 1154 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1155 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1156 |
|
351 | 1157 |
HHGear^.dY:= - _0_3; |
82 | 1158 |
|
351 | 1159 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1160 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1161 |
Gear^.dY:= - _0_9; |
1162 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1163 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
1279 | 1164 |
|
1165 |
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false) |
|
82 | 1166 |
end; |
1167 |
||
263 | 1168 |
//////////////////////////////////////////////////////////////////////////////// |
1169 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1170 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1171 |
var HHGear: PGear; |
1172 |
begin |
|
351 | 1173 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1174 |
|
516 | 1175 |
inc(Gear^.Timer); |
1176 |
||
212 | 1177 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1178 |
or ((HHGear^.State and gstHHDriven) = 0) |
1179 |
or CheckGearDrowning(HHGear) |
|
1180 |
or ((Gear^.Message and gm_Attack) <> 0) then |
|
1181 |
begin |
|
1182 |
with HHGear^ do |
|
1183 |
begin |
|
1184 |
Message:= 0; |
|
1185 |
SetLittle(dX); |
|
1186 |
dY:= _0; |
|
1187 |
State:= State or gstMoving; |
|
1188 |
end; |
|
1189 |
DeleteGear(Gear); |
|
1190 |
exit |
|
1191 |
end; |
|
211 | 1192 |
|
351 | 1193 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1133 | 1194 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
211 | 1195 |
|
351 | 1196 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1197 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1198 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1199 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1200 |
|
351 | 1201 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1202 |
Gear^.X:= HHGear^.X; |
1203 |
Gear^.Y:= HHGear^.Y |
|
263 | 1204 |
end; |
211 | 1205 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1206 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1207 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1208 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1209 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1210 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1211 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1212 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1213 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1214 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1215 |
|
931 | 1216 |
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
|
1217 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1218 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1219 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1220 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1221 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1222 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1223 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1224 |
|
263 | 1225 |
//////////////////////////////////////////////////////////////////////////////// |
1226 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1227 |
begin |
|
1228 |
AllInactive:= false; |
|
498 | 1229 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
1124 | 1230 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1231 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
1124 | 1232 |
begin |
1233 |
dec(Gear^.Health); |
|
1234 |
case Gear^.State of |
|
1235 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1236 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1237 |
end; |
|
1238 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
|
1239 |
end; |
|
1240 |
||
1241 |
if (GameTicks and $3F) = 0 then |
|
1242 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1243 |
||
498 | 1244 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1245 |
end; |
1246 |
||
1247 |
procedure doStepAirAttack(Gear: PGear); |
|
1248 |
begin |
|
1249 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1250 |
|
408 | 1251 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1252 |
else Gear^.Tag:= -1; |
|
498 | 1253 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1124 | 1254 |
Gear^.Y:= -_300; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1255 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1256 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1257 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
1133 | 1258 |
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
|
1259 |
|
351 | 1260 |
Gear^.Health:= 6; |
801 | 1261 |
Gear^.doStep:= @doStepAirAttackWork; |
1262 |
PlaySound(sndIncoming, false) |
|
263 | 1263 |
end; |
1264 |
||
1265 |
//////////////////////////////////////////////////////////////////////////////// |
|
1266 |
||
1267 |
procedure doStepAirBomb(Gear: PGear); |
|
1268 |
begin |
|
1269 |
AllInactive:= false; |
|
1270 |
doStepFallingGear(Gear); |
|
351 | 1271 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 1272 |
begin |
1273 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1274 |
DeleteGear(Gear); |
|
1275 |
exit |
|
1276 |
end; |
|
263 | 1277 |
if (GameTicks and $3F) = 0 then |
1133 | 1278 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1279 |
end; |
409 | 1280 |
|
1281 |
//////////////////////////////////////////////////////////////////////////////// |
|
1282 |
||
1283 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1284 |
var HHGear: PGear; |
409 | 1285 |
begin |
1286 |
AllInactive:= false; |
|
415 | 1287 |
|
1288 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1289 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1290 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1291 |
sprAmGirder, Gear^.State, true) then |
1133 | 1292 |
begin |
1293 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1294 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1295 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1296 |
DeleteGear(Gear); |
|
1297 |
isCursorVisible:= true |
|
1298 |
end |
|
1299 |
else begin |
|
1300 |
DeleteGear(Gear); |
|
1301 |
AfterAttack |
|
1302 |
end; |
|
415 | 1303 |
TargetPoint.X:= NoPointX |
409 | 1304 |
end; |
520 | 1305 |
|
1306 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1307 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1308 |
var HHGear: PGear; |
1309 |
begin |
|
1310 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1311 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1312 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1313 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1314 |
or CheckGearDrowning(HHGear) then |
1315 |
begin |
|
1316 |
DeleteGear(Gear); |
|
1317 |
AfterAttack |
|
1318 |
end |
|
912 | 1319 |
end; |
1320 |
||
1321 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1322 |
begin |
853 | 1323 |
inc(Gear^.Timer); |
1324 |
if Gear^.Timer = 65 then |
|
1325 |
begin |
|
1326 |
Gear^.Timer:= 0; |
|
1327 |
inc(Gear^.Pos); |
|
1328 |
if Gear^.Pos = 11 then |
|
912 | 1329 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1330 |
end |
525 | 1331 |
end; |
520 | 1332 |
|
1333 |
procedure doStepTeleport(Gear: PGear); |
|
1334 |
var HHGear: PGear; |
|
1335 |
begin |
|
1336 |
AllInactive:= false; |
|
1337 |
||
1338 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1339 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1340 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1341 |
sprHHTelepMask, 0, false) then |
|
853 | 1342 |
begin |
1343 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1344 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1345 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1346 |
DeleteGear(Gear); |
|
1347 |
isCursorVisible:= true |
|
1348 |
end |
|
1349 |
else begin |
|
1350 |
DeleteCI(HHGear); |
|
1351 |
SetAllHHToActive; |
|
912 | 1352 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1353 |
Gear^.X:= HHGear^.X; |
1354 |
Gear^.Y:= HHGear^.Y; |
|
1355 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1356 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1357 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1358 |
end; |
|
520 | 1359 |
TargetPoint.X:= NoPointX |
1360 |
end; |
|
534 | 1361 |
|
1362 |
//////////////////////////////////////////////////////////////////////////////// |
|
1363 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1364 |
var HHGear: PGear; |
|
1365 |
Msg, State: Longword; |
|
1366 |
begin |
|
1367 |
AllInactive:= false; |
|
1368 |
||
540 | 1369 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1370 |
begin |
1371 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1372 |
Msg:= Gear^.Message and not gm_Switch; |
|
1373 |
DeleteGear(Gear); |
|
1374 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1375 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1376 |
|
1133 | 1377 |
HHGear:= CurrentHedgehog^.Gear; |
1378 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1379 |
HHGear^.Message:= Msg; |
|
1380 |
exit |
|
1381 |
end; |
|
534 | 1382 |
|
1383 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1384 |
begin |
1385 |
HHGear:= CurrentHedgehog^.Gear; |
|
1386 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1387 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1388 |
State:= HHGear^.State; |
|
1389 |
HHGear^.State:= 0; |
|
1390 |
HHGear^.Active:= false; |
|
1391 |
HHGear^.Z:= cHHZ; |
|
1392 |
RemoveGearFromList(HHGear); |
|
1393 |
InsertGearToList(HHGear); |
|
534 | 1394 |
|
1133 | 1395 |
repeat |
1396 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1397 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1398 |
|
1133 | 1399 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1400 |
|
1133 | 1401 |
HHGear:= CurrentHedgehog^.Gear; |
1402 |
HHGear^.State:= State; |
|
1403 |
HHGear^.Active:= true; |
|
1404 |
FollowGear:= HHGear; |
|
1405 |
HHGear^.Z:= cCurrHHZ; |
|
1406 |
RemoveGearFromList(HHGear); |
|
1407 |
InsertGearToList(HHGear); |
|
1408 |
Gear^.X:= HHGear^.X; |
|
1409 |
Gear^.Y:= HHGear^.Y |
|
1410 |
end; |
|
534 | 1411 |
end; |
1412 |
||
1413 |
procedure doStepSwitcher(Gear: PGear); |
|
1414 |
var HHGear: PGear; |
|
1415 |
begin |
|
1416 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1417 |
||
1418 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1419 |
with HHGear^ do |
|
1133 | 1420 |
begin |
1421 |
State:= State and not gstAttacking; |
|
1422 |
Message:= Message and not gm_Attack |
|
1423 |
end |
|
534 | 1424 |
end; |
924 | 1425 |
|
1426 |
//////////////////////////////////////////////////////////////////////////////// |
|
1427 |
procedure doStepMortar(Gear: PGear); |
|
1428 |
var dX, dY: hwFloat; |
|
1429 |
i: LongInt; |
|
963 | 1430 |
dxn, dyn: boolean; |
924 | 1431 |
begin |
1432 |
AllInactive:= false; |
|
963 | 1433 |
dxn:= Gear^.dX.isNegative; |
1434 |
dyn:= Gear^.dY.isNegative; |
|
1435 |
||
924 | 1436 |
doStepFallingGear(Gear); |
1437 |
if (Gear^.State and gstCollision) <> 0 then |
|
1438 |
begin |
|
1439 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1440 |
|
1441 |
Gear^.dX.isNegative:= not dxn; |
|
1442 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1443 |
for i:= 0 to 4 do |
1444 |
begin |
|
963 | 1445 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1446 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1447 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1448 |
end; |
1449 |
||
1450 |
DeleteGear(Gear); |
|
1451 |
exit |
|
1452 |
end; |
|
963 | 1453 |
|
924 | 1454 |
if (GameTicks and $3F) = 0 then |
1455 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1456 |
end; |
|
984 | 1457 |
|
1458 |
//////////////////////////////////////////////////////////////////////////////// |
|
1459 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1460 |
const upd: Longword = 0; |
|
987 | 1461 |
var i: LongWord; |
984 | 1462 |
HHGear: PGear; |
1463 |
begin |
|
1464 |
AllInactive:= false; |
|
1465 |
||
1466 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1467 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1468 |
DeleteCI(HHGear); |
|
1469 |
||
1470 |
i:= 2; |
|
1471 |
repeat |
|
1472 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1473 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1474 |
HHGear^.X:= Gear^.X; |
|
1475 |
HHGear^.Y:= Gear^.Y; |
|
1476 |
||
1477 |
inc(Gear^.Damage, 2); |
|
1478 |
||
1200 | 1479 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1480 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1481 |
|
1482 |
dec(i) |
|
1483 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1484 |
||
1485 |
inc(upd); |
|
1486 |
if upd > 3 then |
|
1487 |
begin |
|
987 | 1488 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1489 |
||
984 | 1490 |
AmmoShove(Gear, 30, 40); |
1491 |
||
1492 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1493 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1494 |
HHGear^.dX, |
1495 |
HHGear^.dY, |
|
1496 |
20 + cHHRadius * 2, |
|
1200 | 1497 |
cHHRadius * 2 + 6); |
984 | 1498 |
|
1499 |
upd:= 0 |
|
1500 |
end; |
|
1501 |
||
1502 |
if Gear^.Health < Gear^.Damage then |
|
1503 |
begin |
|
1504 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1505 |
AfterAttack; |
|
1506 |
DeleteGear(Gear); |
|
1507 |
DeleteGear(HHGear); |
|
1508 |
end else |
|
1509 |
begin |
|
1510 |
dec(Gear^.Health, Gear^.Damage); |
|
1511 |
Gear^.Damage:= 0 |
|
1512 |
end |
|
1513 |
end; |
|
1514 |
||
987 | 1515 |
procedure doStepKamikazeIdle(Gear: PGear); |
1516 |
begin |
|
1517 |
AllInactive:= false; |
|
1518 |
dec(Gear^.Timer); |
|
1519 |
if Gear^.Timer = 0 then |
|
1520 |
begin |
|
1521 |
Gear^.Pos:= 1; |
|
992 | 1522 |
PlaySound(sndKamikaze, false); |
987 | 1523 |
Gear^.doStep:= @doStepKamikazeWork |
1524 |
end |
|
1525 |
end; |
|
1526 |
||
984 | 1527 |
procedure doStepKamikaze(Gear: PGear); |
1528 |
var HHGear: PGear; |
|
1529 |
begin |
|
1530 |
AllInactive:= false; |
|
1531 |
||
1532 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1533 |
||
1534 |
HHGear^.dX:= Gear^.dX; |
|
1535 |
HHGear^.dY:= Gear^.dY; |
|
1536 |
||
1537 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1538 |
Gear^.dY:= - _0_9; |
|
1539 |
||
987 | 1540 |
Gear^.Timer:= 550; |
1541 |
||
1542 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1543 |
end; |
1544 |
||
1103 | 1545 |
//////////////////////////////////////////////////////////////////////////////// |
1546 |
const cakeh = 27; |
|
1110 | 1547 |
cakeDmg = 75; |
1103 | 1548 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1549 |
CakeI: Longword; |
|
1550 |
||
1110 | 1551 |
procedure doStepCakeExpl(Gear: PGear); |
1552 |
begin |
|
1553 |
inc(Gear^.Tag); |
|
1554 |
if Gear^.Tag < 2250 then exit; |
|
1555 |
||
1556 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1557 |
AfterAttack; |
|
1558 |
DeleteGear(Gear) |
|
1559 |
end; |
|
1560 |
||
1109 | 1561 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1562 |
var gi: PGear; |
1563 |
dmg: LongInt; |
|
1109 | 1564 |
begin |
1565 |
AllInactive:= false; |
|
1566 |
||
1567 |
inc(Gear^.Tag); |
|
1568 |
if Gear^.Tag < 100 then exit; |
|
1569 |
Gear^.Tag:= 0; |
|
1570 |
||
1571 |
if Gear^.Pos = 0 then |
|
1572 |
begin |
|
1110 | 1573 |
gi:= GearsList; |
1574 |
while gi <> nil do |
|
1575 |
begin |
|
1576 |
dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); |
|
1577 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
|
1578 |
gi^.State:= gi^.State or gstWinner; |
|
1579 |
gi:= gi^.NextGear |
|
1580 |
end; |
|
1581 |
Gear^.doStep:= @doStepCakeExpl; |
|
1111 | 1582 |
PlaySound(sndCake, false) |
1109 | 1583 |
end else dec(Gear^.Pos) |
1584 |
end; |
|
1585 |
||
1586 |
||
1089 | 1587 |
procedure doStepCakeWork(Gear: PGear); |
1588 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1589 |
var xx, yy, xxn, yyn: LongInt; |
|
1590 |
da: LongInt; |
|
1103 | 1591 |
tdx, tdy: hwFloat; |
1089 | 1592 |
|
1593 |
procedure PrevAngle; |
|
1594 |
begin |
|
1133 | 1595 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1596 |
end; |
1597 |
||
1598 |
procedure NextAngle; |
|
1599 |
begin |
|
1133 | 1600 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1601 |
end; |
1602 |
||
1088 | 1603 |
begin |
1089 | 1604 |
inc(Gear^.Tag); |
1108 | 1605 |
if Gear^.Tag < 7 then exit; |
1089 | 1606 |
|
1607 |
dA:= hwSign(Gear^.dX); |
|
1608 |
xx:= dirs[Gear^.Angle].x; |
|
1609 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1610 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1611 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1612 |
|
1613 |
||
1614 |
if (xx = 0) then |
|
1615 |
if TestCollisionYwithGear(Gear, yy) then |
|
1616 |
PrevAngle |
|
1617 |
else begin |
|
1618 |
Gear^.Tag:= 0; |
|
1619 |
Gear^.Y:= Gear^.Y + int2hwFloat(yy); |
|
1620 |
if not TestCollisionXwithGear(Gear, xxn) then NextAngle |
|
1621 |
end; |
|
1622 |
||
1623 |
if (yy = 0) then |
|
1624 |
if TestCollisionXwithGear(Gear, xx) then |
|
1625 |
PrevAngle |
|
1626 |
else begin |
|
1627 |
Gear^.Tag:= 0; |
|
1628 |
Gear^.X:= Gear^.X + int2hwFloat(xx); |
|
1629 |
if not TestCollisionYwithGear(Gear, yyn) then NextAngle |
|
1630 |
end; |
|
1631 |
||
1103 | 1632 |
if Gear^.Tag = 0 then |
1633 |
begin |
|
1634 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1635 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1636 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1637 |
CakePoints[CakeI].x:= Gear^.X; |
|
1638 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1639 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1640 |
end; |
|
1641 |
||
1089 | 1642 |
dec(Gear^.Health); |
1090 | 1643 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1644 |
begin |
1109 | 1645 |
FollowGear:= Gear; |
1646 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1647 |
end |
1088 | 1648 |
end; |
1089 | 1649 |
|
1103 | 1650 |
procedure doStepCakeUp(Gear: PGear); |
1651 |
var i: Longword; |
|
1652 |
begin |
|
1653 |
AllInactive:= false; |
|
1654 |
||
1108 | 1655 |
inc(Gear^.Tag); |
1109 | 1656 |
if Gear^.Tag < 100 then exit; |
1108 | 1657 |
Gear^.Tag:= 0; |
1658 |
||
1109 | 1659 |
if Gear^.Pos = 6 then |
1103 | 1660 |
begin |
1661 |
for i:= 0 to Pred(cakeh) do |
|
1662 |
begin |
|
1663 |
CakePoints[i].x:= Gear^.X; |
|
1664 |
CakePoints[i].y:= Gear^.Y |
|
1665 |
end; |
|
1666 |
CakeI:= 0; |
|
1667 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1668 |
end else inc(Gear^.Pos) |
1103 | 1669 |
end; |
1670 |
||
1089 | 1671 |
procedure doStepCakeFall(Gear: PGear); |
1672 |
begin |
|
1673 |
AllInactive:= false; |
|
1674 |
||
1675 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1676 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1677 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1678 |
else |
1679 |
begin |
|
1680 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1681 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1682 |
end |
|
1683 |
end; |
|
1684 |
||
1685 |
procedure doStepCake(Gear: PGear); |
|
1686 |
var HHGear: PGear; |
|
1687 |
begin |
|
1688 |
AllInactive:= false; |
|
1689 |
||
1690 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1691 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1692 |
DeleteCI(HHGear); |
1693 |
||
1106 | 1694 |
FollowGear:= Gear; |
1695 |
||
1089 | 1696 |
Gear^.doStep:= @doStepCakeFall |
1697 |
end; |
|
1698 |
||
1259 | 1699 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1700 |
procedure doStepSeductionWork(Gear: PGear); |
1701 |
var x, y: LongInt; |
|
1259 | 1702 |
begin |
1703 |
AllInactive:= false; |
|
1284 | 1704 |
|
1705 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1706 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1707 |
x:= hwRound(Gear^.X); |
|
1708 |
y:= hwRound(Gear^.Y); |
|
1259 | 1709 |
|
1284 | 1710 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) then |
1711 |
if (Land[y, x] <> 0) then |
|
1712 |
begin |
|
1713 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1714 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1715 |
Gear^.dX:= Gear^.dX * _1_5; |
1716 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1717 |
AmmoShove(Gear, 0, 40); |
1286 | 1718 |
AfterAttack; |
1284 | 1719 |
DeleteGear(Gear) |
1720 |
end |
|
1721 |
else |
|
1722 |
else |
|
1286 | 1723 |
begin |
1724 |
AfterAttack; |
|
1284 | 1725 |
DeleteGear(Gear) |
1286 | 1726 |
end |
1727 |
end; |
|
1728 |
||
1729 |
procedure doStepSeductionWear(Gear: PGear); |
|
1730 |
begin |
|
1731 |
AllInactive:= false; |
|
1732 |
inc(Gear^.Timer); |
|
1733 |
if Gear^.Timer > 250 then |
|
1734 |
begin |
|
1735 |
Gear^.Timer:= 0; |
|
1736 |
inc(Gear^.Pos) |
|
1737 |
end; |
|
1738 |
||
1739 |
if Gear^.Pos = 8 then |
|
1740 |
Gear^.doStep:= @doStepSeductionWork |
|
1259 | 1741 |
end; |
1284 | 1742 |
|
1743 |
procedure doStepSeduction(Gear: PGear); |
|
1744 |
begin |
|
1745 |
AllInactive:= false; |
|
1746 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1747 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1748 |
end; |