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