author | unc0rr |
Fri, 24 Oct 2008 13:03:06 +0000 | |
changeset 1406 | 08b9c28419f1 |
parent 1388 | 5e7920f2e2aa |
child 1417 | 210cb6b1b275 |
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 |
|
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 |
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 |
1297 | 1086 |
if hwAbs(Gear^.dX - cWindSpeed) > _0_1 then |
1087 |
Gear^.dX:= (Gear^.dX - cWindSpeed) * _0_5 + cWindSpeed; |
|
1088 |
||
1133 | 1089 |
Gear^.dY:= Gear^.dY + cGravity; |
1090 |
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995; |
|
1297 | 1091 |
|
1133 | 1092 |
Gear^.X:= Gear^.X + Gear^.dX; |
1093 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1297 | 1094 |
|
1133 | 1095 |
if not (Gear^.Y < _1024) then |
1096 |
begin |
|
1097 |
DeleteGear(Gear); |
|
1098 |
exit |
|
1099 |
end |
|
1100 |
end else begin |
|
1101 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
|
1102 |
else begin |
|
1297 | 1103 |
Gear^.Radius:= 5; |
1104 |
AmmoShove(Gear, 3, 100); |
|
1105 |
Gear^.Radius:= 1; |
|
1106 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); |
|
1133 | 1107 |
dec(Gear^.Health); |
1297 | 1108 |
Gear^.Timer:= 1250 - Gear^.Tag * 12 |
1133 | 1109 |
end |
1110 |
end; |
|
79 | 1111 |
|
1295 | 1112 |
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then |
1113 |
// AmmoFlameWork(Gear); |
|
79 | 1114 |
|
351 | 1115 |
if Gear^.Health = 0 then |
1133 | 1116 |
DeleteGear(Gear) |
79 | 1117 |
end; |
82 | 1118 |
|
1119 |
//////////////////////////////////////////////////////////////////////////////// |
|
1120 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1121 |
var HHGear: PGear; |
|
1122 |
begin |
|
1123 |
AllInactive:= false; |
|
351 | 1124 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
1133 | 1125 |
begin |
1126 |
DeleteGear(Gear); |
|
1127 |
AfterAttack; |
|
1128 |
exit |
|
1129 |
end; |
|
82 | 1130 |
|
351 | 1131 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1132 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
1133 | 1133 |
begin |
1134 |
Gear^.Tag:= hwRound(HHGear^.Y); |
|
1135 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
|
1136 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1137 |
Gear^.Y:= HHGear^.Y; |
|
1138 |
AmmoShove(Gear, 30, 40); |
|
1139 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
1140 |
end; |
|
351 | 1141 |
|
1142 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1143 |
if not (HHGear^.dY.isNegative) then |
|
1133 | 1144 |
begin |
1145 |
HHGear^.State:= HHGear^.State or gstMoving; |
|
1146 |
DeleteGear(Gear); |
|
1147 |
AfterAttack; |
|
1148 |
exit |
|
1149 |
end; |
|
351 | 1150 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1151 |
end; |
1152 |
||
1153 |
procedure doStepFirePunch(Gear: PGear); |
|
1154 |
var HHGear: PGear; |
|
1155 |
begin |
|
1156 |
AllInactive:= false; |
|
351 | 1157 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1158 |
DeleteCI(HHGear); |
498 | 1159 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1160 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1161 |
|
351 | 1162 |
HHGear^.dY:= - _0_3; |
82 | 1163 |
|
351 | 1164 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1165 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1166 |
Gear^.dY:= - _0_9; |
1167 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1168 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
1279 | 1169 |
|
1170 |
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false) |
|
82 | 1171 |
end; |
1172 |
||
263 | 1173 |
//////////////////////////////////////////////////////////////////////////////// |
1174 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1175 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1176 |
var HHGear: PGear; |
1177 |
begin |
|
351 | 1178 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1179 |
|
516 | 1180 |
inc(Gear^.Timer); |
1181 |
||
212 | 1182 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1183 |
or ((HHGear^.State and gstHHDriven) = 0) |
1184 |
or CheckGearDrowning(HHGear) |
|
1185 |
or ((Gear^.Message and gm_Attack) <> 0) then |
|
1186 |
begin |
|
1187 |
with HHGear^ do |
|
1188 |
begin |
|
1189 |
Message:= 0; |
|
1190 |
SetLittle(dX); |
|
1191 |
dY:= _0; |
|
1192 |
State:= State or gstMoving; |
|
1193 |
end; |
|
1194 |
DeleteGear(Gear); |
|
1195 |
exit |
|
1196 |
end; |
|
211 | 1197 |
|
351 | 1198 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1133 | 1199 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
211 | 1200 |
|
351 | 1201 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1202 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1203 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1204 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1205 |
|
351 | 1206 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1207 |
Gear^.X:= HHGear^.X; |
1208 |
Gear^.Y:= HHGear^.Y |
|
263 | 1209 |
end; |
211 | 1210 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1211 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1212 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1213 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1214 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1215 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1216 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1217 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1218 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1219 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1220 |
|
931 | 1221 |
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
|
1222 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1223 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1224 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1225 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1226 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1227 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1228 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1229 |
|
263 | 1230 |
//////////////////////////////////////////////////////////////////////////////// |
1231 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1232 |
begin |
|
1233 |
AllInactive:= false; |
|
498 | 1234 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
1124 | 1235 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1236 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
1124 | 1237 |
begin |
1238 |
dec(Gear^.Health); |
|
1239 |
case Gear^.State of |
|
1240 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1241 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1242 |
end; |
|
1243 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
|
1244 |
end; |
|
1245 |
||
1246 |
if (GameTicks and $3F) = 0 then |
|
1247 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1248 |
||
498 | 1249 |
if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1250 |
end; |
1251 |
||
1252 |
procedure doStepAirAttack(Gear: PGear); |
|
1253 |
begin |
|
1254 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1255 |
|
408 | 1256 |
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1 |
1257 |
else Gear^.Tag:= -1; |
|
498 | 1258 |
Gear^.X:= _1024 - _2048 * Gear^.Tag; |
1124 | 1259 |
Gear^.Y:= -_300; |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1260 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1261 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1262 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
1133 | 1263 |
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
|
1264 |
|
351 | 1265 |
Gear^.Health:= 6; |
801 | 1266 |
Gear^.doStep:= @doStepAirAttackWork; |
1267 |
PlaySound(sndIncoming, false) |
|
263 | 1268 |
end; |
1269 |
||
1270 |
//////////////////////////////////////////////////////////////////////////////// |
|
1271 |
||
1272 |
procedure doStepAirBomb(Gear: PGear); |
|
1273 |
begin |
|
1274 |
AllInactive:= false; |
|
1275 |
doStepFallingGear(Gear); |
|
351 | 1276 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 1277 |
begin |
1278 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1279 |
DeleteGear(Gear); |
|
1280 |
exit |
|
1281 |
end; |
|
263 | 1282 |
if (GameTicks and $3F) = 0 then |
1133 | 1283 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1284 |
end; |
409 | 1285 |
|
1286 |
//////////////////////////////////////////////////////////////////////////////// |
|
1287 |
||
1288 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1289 |
var HHGear: PGear; |
409 | 1290 |
begin |
1291 |
AllInactive:= false; |
|
415 | 1292 |
|
1293 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
409 | 1294 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
1295 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1296 |
sprAmGirder, Gear^.State, true) then |
1133 | 1297 |
begin |
1298 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1299 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1300 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1301 |
DeleteGear(Gear); |
|
1302 |
isCursorVisible:= true |
|
1303 |
end |
|
1304 |
else begin |
|
1305 |
DeleteGear(Gear); |
|
1306 |
AfterAttack |
|
1307 |
end; |
|
415 | 1308 |
TargetPoint.X:= NoPointX |
409 | 1309 |
end; |
520 | 1310 |
|
1311 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1312 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1313 |
var HHGear: PGear; |
1314 |
begin |
|
1315 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1316 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1317 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1318 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1319 |
or CheckGearDrowning(HHGear) then |
1320 |
begin |
|
1321 |
DeleteGear(Gear); |
|
1322 |
AfterAttack |
|
1323 |
end |
|
912 | 1324 |
end; |
1325 |
||
1326 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1327 |
begin |
853 | 1328 |
inc(Gear^.Timer); |
1329 |
if Gear^.Timer = 65 then |
|
1330 |
begin |
|
1331 |
Gear^.Timer:= 0; |
|
1332 |
inc(Gear^.Pos); |
|
1333 |
if Gear^.Pos = 11 then |
|
912 | 1334 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1335 |
end |
525 | 1336 |
end; |
520 | 1337 |
|
1338 |
procedure doStepTeleport(Gear: PGear); |
|
1339 |
var HHGear: PGear; |
|
1340 |
begin |
|
1341 |
AllInactive:= false; |
|
1342 |
||
1343 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1344 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1345 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1346 |
sprHHTelepMask, 0, false) then |
|
853 | 1347 |
begin |
1348 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1349 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1350 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1351 |
DeleteGear(Gear); |
|
1352 |
isCursorVisible:= true |
|
1353 |
end |
|
1354 |
else begin |
|
1355 |
DeleteCI(HHGear); |
|
1356 |
SetAllHHToActive; |
|
912 | 1357 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1358 |
Gear^.X:= HHGear^.X; |
1359 |
Gear^.Y:= HHGear^.Y; |
|
1360 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1361 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1362 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1363 |
end; |
|
520 | 1364 |
TargetPoint.X:= NoPointX |
1365 |
end; |
|
534 | 1366 |
|
1367 |
//////////////////////////////////////////////////////////////////////////////// |
|
1368 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1369 |
var HHGear: PGear; |
|
1370 |
Msg, State: Longword; |
|
1371 |
begin |
|
1372 |
AllInactive:= false; |
|
1373 |
||
540 | 1374 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1375 |
begin |
1376 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1377 |
Msg:= Gear^.Message and not gm_Switch; |
|
1378 |
DeleteGear(Gear); |
|
1379 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1380 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1381 |
|
1133 | 1382 |
HHGear:= CurrentHedgehog^.Gear; |
1383 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1384 |
HHGear^.Message:= Msg; |
|
1385 |
exit |
|
1386 |
end; |
|
534 | 1387 |
|
1388 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1389 |
begin |
1390 |
HHGear:= CurrentHedgehog^.Gear; |
|
1391 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1392 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1393 |
State:= HHGear^.State; |
|
1394 |
HHGear^.State:= 0; |
|
1395 |
HHGear^.Active:= false; |
|
1396 |
HHGear^.Z:= cHHZ; |
|
1397 |
RemoveGearFromList(HHGear); |
|
1398 |
InsertGearToList(HHGear); |
|
534 | 1399 |
|
1133 | 1400 |
repeat |
1401 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1402 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1403 |
|
1133 | 1404 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1405 |
|
1133 | 1406 |
HHGear:= CurrentHedgehog^.Gear; |
1407 |
HHGear^.State:= State; |
|
1408 |
HHGear^.Active:= true; |
|
1409 |
FollowGear:= HHGear; |
|
1410 |
HHGear^.Z:= cCurrHHZ; |
|
1411 |
RemoveGearFromList(HHGear); |
|
1412 |
InsertGearToList(HHGear); |
|
1413 |
Gear^.X:= HHGear^.X; |
|
1414 |
Gear^.Y:= HHGear^.Y |
|
1415 |
end; |
|
534 | 1416 |
end; |
1417 |
||
1418 |
procedure doStepSwitcher(Gear: PGear); |
|
1419 |
var HHGear: PGear; |
|
1420 |
begin |
|
1421 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1422 |
||
1423 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1424 |
with HHGear^ do |
|
1133 | 1425 |
begin |
1426 |
State:= State and not gstAttacking; |
|
1427 |
Message:= Message and not gm_Attack |
|
1428 |
end |
|
534 | 1429 |
end; |
924 | 1430 |
|
1431 |
//////////////////////////////////////////////////////////////////////////////// |
|
1432 |
procedure doStepMortar(Gear: PGear); |
|
1433 |
var dX, dY: hwFloat; |
|
1434 |
i: LongInt; |
|
963 | 1435 |
dxn, dyn: boolean; |
924 | 1436 |
begin |
1437 |
AllInactive:= false; |
|
963 | 1438 |
dxn:= Gear^.dX.isNegative; |
1439 |
dyn:= Gear^.dY.isNegative; |
|
1440 |
||
924 | 1441 |
doStepFallingGear(Gear); |
1442 |
if (Gear^.State and gstCollision) <> 0 then |
|
1443 |
begin |
|
1444 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1445 |
|
1446 |
Gear^.dX.isNegative:= not dxn; |
|
1447 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1448 |
for i:= 0 to 4 do |
1449 |
begin |
|
963 | 1450 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1451 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1452 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1453 |
end; |
1454 |
||
1455 |
DeleteGear(Gear); |
|
1456 |
exit |
|
1457 |
end; |
|
963 | 1458 |
|
924 | 1459 |
if (GameTicks and $3F) = 0 then |
1460 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1461 |
end; |
|
984 | 1462 |
|
1463 |
//////////////////////////////////////////////////////////////////////////////// |
|
1464 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1465 |
const upd: Longword = 0; |
|
987 | 1466 |
var i: LongWord; |
984 | 1467 |
HHGear: PGear; |
1468 |
begin |
|
1469 |
AllInactive:= false; |
|
1470 |
||
1471 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1472 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1473 |
DeleteCI(HHGear); |
|
1474 |
||
1475 |
i:= 2; |
|
1476 |
repeat |
|
1477 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1478 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1479 |
HHGear^.X:= Gear^.X; |
|
1480 |
HHGear^.Y:= Gear^.Y; |
|
1481 |
||
1482 |
inc(Gear^.Damage, 2); |
|
1483 |
||
1200 | 1484 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1485 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1486 |
|
1487 |
dec(i) |
|
1488 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1489 |
||
1490 |
inc(upd); |
|
1491 |
if upd > 3 then |
|
1492 |
begin |
|
987 | 1493 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1494 |
||
984 | 1495 |
AmmoShove(Gear, 30, 40); |
1496 |
||
1497 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1498 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1499 |
HHGear^.dX, |
1500 |
HHGear^.dY, |
|
1501 |
20 + cHHRadius * 2, |
|
1200 | 1502 |
cHHRadius * 2 + 6); |
984 | 1503 |
|
1504 |
upd:= 0 |
|
1505 |
end; |
|
1506 |
||
1507 |
if Gear^.Health < Gear^.Damage then |
|
1508 |
begin |
|
1509 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1510 |
AfterAttack; |
|
1511 |
DeleteGear(Gear); |
|
1512 |
DeleteGear(HHGear); |
|
1513 |
end else |
|
1514 |
begin |
|
1515 |
dec(Gear^.Health, Gear^.Damage); |
|
1516 |
Gear^.Damage:= 0 |
|
1517 |
end |
|
1518 |
end; |
|
1519 |
||
987 | 1520 |
procedure doStepKamikazeIdle(Gear: PGear); |
1521 |
begin |
|
1522 |
AllInactive:= false; |
|
1523 |
dec(Gear^.Timer); |
|
1524 |
if Gear^.Timer = 0 then |
|
1525 |
begin |
|
1526 |
Gear^.Pos:= 1; |
|
992 | 1527 |
PlaySound(sndKamikaze, false); |
987 | 1528 |
Gear^.doStep:= @doStepKamikazeWork |
1529 |
end |
|
1530 |
end; |
|
1531 |
||
984 | 1532 |
procedure doStepKamikaze(Gear: PGear); |
1533 |
var HHGear: PGear; |
|
1534 |
begin |
|
1535 |
AllInactive:= false; |
|
1536 |
||
1537 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1538 |
||
1539 |
HHGear^.dX:= Gear^.dX; |
|
1540 |
HHGear^.dY:= Gear^.dY; |
|
1541 |
||
1542 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1543 |
Gear^.dY:= - _0_9; |
|
1544 |
||
987 | 1545 |
Gear^.Timer:= 550; |
1546 |
||
1547 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1548 |
end; |
1549 |
||
1103 | 1550 |
//////////////////////////////////////////////////////////////////////////////// |
1551 |
const cakeh = 27; |
|
1110 | 1552 |
cakeDmg = 75; |
1103 | 1553 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1554 |
CakeI: Longword; |
|
1555 |
||
1110 | 1556 |
procedure doStepCakeExpl(Gear: PGear); |
1557 |
begin |
|
1558 |
inc(Gear^.Tag); |
|
1559 |
if Gear^.Tag < 2250 then exit; |
|
1560 |
||
1561 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1562 |
AfterAttack; |
|
1563 |
DeleteGear(Gear) |
|
1564 |
end; |
|
1565 |
||
1109 | 1566 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1567 |
var gi: PGear; |
1568 |
dmg: LongInt; |
|
1109 | 1569 |
begin |
1570 |
AllInactive:= false; |
|
1571 |
||
1572 |
inc(Gear^.Tag); |
|
1573 |
if Gear^.Tag < 100 then exit; |
|
1574 |
Gear^.Tag:= 0; |
|
1575 |
||
1576 |
if Gear^.Pos = 0 then |
|
1577 |
begin |
|
1110 | 1578 |
gi:= GearsList; |
1579 |
while gi <> nil do |
|
1580 |
begin |
|
1581 |
dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); |
|
1582 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
|
1583 |
gi^.State:= gi^.State or gstWinner; |
|
1584 |
gi:= gi^.NextGear |
|
1585 |
end; |
|
1586 |
Gear^.doStep:= @doStepCakeExpl; |
|
1111 | 1587 |
PlaySound(sndCake, false) |
1109 | 1588 |
end else dec(Gear^.Pos) |
1589 |
end; |
|
1590 |
||
1591 |
||
1089 | 1592 |
procedure doStepCakeWork(Gear: PGear); |
1593 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1594 |
var xx, yy, xxn, yyn: LongInt; |
|
1595 |
da: LongInt; |
|
1103 | 1596 |
tdx, tdy: hwFloat; |
1089 | 1597 |
|
1598 |
procedure PrevAngle; |
|
1599 |
begin |
|
1133 | 1600 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1601 |
end; |
1602 |
||
1603 |
procedure NextAngle; |
|
1604 |
begin |
|
1133 | 1605 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1606 |
end; |
1607 |
||
1088 | 1608 |
begin |
1089 | 1609 |
inc(Gear^.Tag); |
1108 | 1610 |
if Gear^.Tag < 7 then exit; |
1089 | 1611 |
|
1612 |
dA:= hwSign(Gear^.dX); |
|
1613 |
xx:= dirs[Gear^.Angle].x; |
|
1614 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1615 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1616 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1617 |
|
1618 |
||
1619 |
if (xx = 0) then |
|
1620 |
if TestCollisionYwithGear(Gear, yy) then |
|
1621 |
PrevAngle |
|
1622 |
else begin |
|
1623 |
Gear^.Tag:= 0; |
|
1624 |
Gear^.Y:= Gear^.Y + int2hwFloat(yy); |
|
1625 |
if not TestCollisionXwithGear(Gear, xxn) then NextAngle |
|
1626 |
end; |
|
1627 |
||
1628 |
if (yy = 0) then |
|
1629 |
if TestCollisionXwithGear(Gear, xx) then |
|
1630 |
PrevAngle |
|
1631 |
else begin |
|
1632 |
Gear^.Tag:= 0; |
|
1633 |
Gear^.X:= Gear^.X + int2hwFloat(xx); |
|
1634 |
if not TestCollisionYwithGear(Gear, yyn) then NextAngle |
|
1635 |
end; |
|
1636 |
||
1103 | 1637 |
if Gear^.Tag = 0 then |
1638 |
begin |
|
1639 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1640 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1641 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1642 |
CakePoints[CakeI].x:= Gear^.X; |
|
1643 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1644 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1645 |
end; |
|
1646 |
||
1089 | 1647 |
dec(Gear^.Health); |
1090 | 1648 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1649 |
begin |
1109 | 1650 |
FollowGear:= Gear; |
1651 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1652 |
end |
1088 | 1653 |
end; |
1089 | 1654 |
|
1103 | 1655 |
procedure doStepCakeUp(Gear: PGear); |
1656 |
var i: Longword; |
|
1657 |
begin |
|
1658 |
AllInactive:= false; |
|
1659 |
||
1108 | 1660 |
inc(Gear^.Tag); |
1109 | 1661 |
if Gear^.Tag < 100 then exit; |
1108 | 1662 |
Gear^.Tag:= 0; |
1663 |
||
1109 | 1664 |
if Gear^.Pos = 6 then |
1103 | 1665 |
begin |
1666 |
for i:= 0 to Pred(cakeh) do |
|
1667 |
begin |
|
1668 |
CakePoints[i].x:= Gear^.X; |
|
1669 |
CakePoints[i].y:= Gear^.Y |
|
1670 |
end; |
|
1671 |
CakeI:= 0; |
|
1672 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1673 |
end else inc(Gear^.Pos) |
1103 | 1674 |
end; |
1675 |
||
1089 | 1676 |
procedure doStepCakeFall(Gear: PGear); |
1677 |
begin |
|
1678 |
AllInactive:= false; |
|
1679 |
||
1680 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1681 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1682 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1683 |
else |
1684 |
begin |
|
1685 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1686 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1687 |
end |
|
1688 |
end; |
|
1689 |
||
1690 |
procedure doStepCake(Gear: PGear); |
|
1691 |
var HHGear: PGear; |
|
1692 |
begin |
|
1693 |
AllInactive:= false; |
|
1694 |
||
1695 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1696 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1697 |
DeleteCI(HHGear); |
1698 |
||
1106 | 1699 |
FollowGear:= Gear; |
1700 |
||
1089 | 1701 |
Gear^.doStep:= @doStepCakeFall |
1702 |
end; |
|
1703 |
||
1259 | 1704 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1705 |
procedure doStepSeductionWork(Gear: PGear); |
1706 |
var x, y: LongInt; |
|
1259 | 1707 |
begin |
1708 |
AllInactive:= false; |
|
1284 | 1709 |
|
1710 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1711 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1712 |
x:= hwRound(Gear^.X); |
|
1713 |
y:= hwRound(Gear^.Y); |
|
1259 | 1714 |
|
1284 | 1715 |
if ((y and $FFFFFC00) = 0) and ((x and $FFFFF800) = 0) then |
1716 |
if (Land[y, x] <> 0) then |
|
1717 |
begin |
|
1718 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1719 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1720 |
Gear^.dX:= Gear^.dX * _1_5; |
1721 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1722 |
AmmoShove(Gear, 0, 40); |
1286 | 1723 |
AfterAttack; |
1284 | 1724 |
DeleteGear(Gear) |
1725 |
end |
|
1726 |
else |
|
1727 |
else |
|
1286 | 1728 |
begin |
1729 |
AfterAttack; |
|
1284 | 1730 |
DeleteGear(Gear) |
1286 | 1731 |
end |
1732 |
end; |
|
1733 |
||
1734 |
procedure doStepSeductionWear(Gear: PGear); |
|
1735 |
begin |
|
1736 |
AllInactive:= false; |
|
1737 |
inc(Gear^.Timer); |
|
1738 |
if Gear^.Timer > 250 then |
|
1739 |
begin |
|
1740 |
Gear^.Timer:= 0; |
|
1388 | 1741 |
inc(Gear^.Pos); |
1742 |
if Gear^.Pos = 5 then |
|
1743 |
PlaySound(sndYoohoo, false) |
|
1286 | 1744 |
end; |
1367 | 1745 |
|
1746 |
if Gear^.Pos = 14 then |
|
1286 | 1747 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1748 |
end; |
1284 | 1749 |
|
1750 |
procedure doStepSeduction(Gear: PGear); |
|
1751 |
begin |
|
1752 |
AllInactive:= false; |
|
1753 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1754 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1755 |
end; |
1298 | 1756 |
|
1757 |
//////////////////////////////////////////////////////////////////////////////// |
|
1758 |
procedure doStepWaterUp(Gear: PGear); |
|
1759 |
var i: LongWord; |
|
1760 |
begin |
|
1761 |
AllInactive:= false; |
|
1762 |
||
1763 |
inc(Gear^.Timer); |
|
1764 |
if Gear^.Timer = 17 then |
|
1765 |
Gear^.Timer:= 0 |
|
1766 |
else |
|
1767 |
exit; |
|
1768 |
||
1769 |
if cWaterLine > 0 then |
|
1770 |
begin |
|
1771 |
dec(cWaterLine); |
|
1772 |
for i:= 0 to 2047 do |
|
1773 |
Land[cWaterLine, i]:= 0; |
|
1774 |
SetAllToActive |
|
1775 |
end; |
|
1776 |
||
1777 |
inc(Gear^.Tag); |
|
1343 | 1778 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1779 |
DeleteGear(Gear) |
1780 |
end; |