author | unc0rr |
Sun, 19 Apr 2009 11:59:23 +0000 | |
changeset 2005 | aa79f631711b |
parent 1964 | dc9ea05c9d2f |
child 2017 | 7845c77c8d31 |
permissions | -rw-r--r-- |
4 | 1 |
(* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1689 | 3 |
* Copyright (c) 2004-2009 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; |
|
1918 | 22 |
var skipSpeed, skipAngle, skipDecay: hwFloat; |
4 | 23 |
begin |
1918 | 24 |
// probably needs tweaking. might need to be in a case statement based upon gear type |
25 |
//(not Gear^.dY.isNegative) and this should not be necessary |
|
498 | 26 |
if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then |
1918 | 27 |
begin |
28 |
skipSpeed:= _0_25; // was 0.36 - couldn't manage baseball bat. Tiy's build is 0.36... |
|
29 |
skipAngle:= _1 + _0_9; // these should perhaps also be constants, once work out what proper values are |
|
30 |
skipDecay:= _0_87; // this could perhaps be a tiny bit higher. |
|
1919 | 31 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > skipSpeed) and |
1920 | 32 |
(hwAbs(Gear^.dX) > skipAngle * hwAbs(Gear^.dY)) then |
1918 | 33 |
begin |
34 |
Gear^.dY.isNegative:= true; |
|
1919 | 35 |
Gear^.dY:= Gear^.dY * skipDecay; |
36 |
Gear^.dX:= Gear^.dX * skipDecay; |
|
1918 | 37 |
CheckGearDrowning:= false |
38 |
end |
|
39 |
else |
|
40 |
begin |
|
41 |
CheckGearDrowning:= true; |
|
42 |
Gear^.State:= gstDrowning; |
|
43 |
Gear^.doStep:= @doStepDrowningGear; |
|
44 |
end; |
|
45 |
PlaySound(sndSplash, false, nil) |
|
46 |
end |
|
47 |
else |
|
1133 | 48 |
CheckGearDrowning:= false |
4 | 49 |
end; |
50 |
||
51 |
procedure CheckCollision(Gear: PGear); |
|
52 |
begin |
|
351 | 53 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y)) |
1133 | 54 |
then Gear^.State:= Gear^.State or gstCollision |
55 |
else Gear^.State:= Gear^.State and not gstCollision |
|
4 | 56 |
end; |
57 |
||
58 |
procedure CheckHHDamage(Gear: PGear); |
|
522 | 59 |
var dmg: Longword; |
4 | 60 |
begin |
1849 | 61 |
if(Gear^.Invulnerable) then exit; |
522 | 62 |
if _0_4 < Gear^.dY then |
1123 | 63 |
begin |
64 |
if _0_6 < Gear^.dY then |
|
1669 | 65 |
PlaySound(sndOw4, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1123 | 66 |
else |
1669 | 67 |
PlaySound(sndOw1, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
1123 | 68 |
|
1861 | 69 |
dmg:= modifyDamage(1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70)); |
1123 | 70 |
inc(Gear^.Damage, dmg); |
1505 | 71 |
AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, dmg, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color); |
1123 | 72 |
end |
4 | 73 |
end; |
74 |
||
75 |
//////////////////////////////////////////////////////////////////////////////// |
|
76 |
//////////////////////////////////////////////////////////////////////////////// |
|
77 |
procedure CalcRotationDirAngle(Gear: PGear); |
|
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
78 |
var dAngle: real; |
4 | 79 |
begin |
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
80 |
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)).QWordValue / $80000000; |
1133 | 81 |
if not Gear^.dX.isNegative then |
82 |
Gear^.DirAngle:= Gear^.DirAngle + dAngle |
|
83 |
else |
|
84 |
Gear^.DirAngle:= Gear^.DirAngle - dAngle; |
|
85 |
||
776
8fc7e59d9cb4
Convert the rest of rotated sprites to be rotated by OpenGL
unc0rr
parents:
764
diff
changeset
|
86 |
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
|
87 |
else if 360 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 360 |
4 | 88 |
end; |
89 |
||
90 |
//////////////////////////////////////////////////////////////////////////////// |
|
91 |
procedure doStepDrowningGear(Gear: PGear); |
|
92 |
begin |
|
93 |
AllInactive:= false; |
|
351 | 94 |
Gear^.Y:= Gear^.Y + cDrownSpeed; |
95 |
if hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater then DeleteGear(Gear) |
|
4 | 96 |
end; |
97 |
||
98 |
//////////////////////////////////////////////////////////////////////////////// |
|
99 |
procedure doStepFallingGear(Gear: PGear); |
|
542 | 100 |
var isFalling: boolean; |
4 | 101 |
begin |
503 | 102 |
Gear^.State:= Gear^.State and not gstCollision; |
103 |
||
104 |
if Gear^.dY.isNegative then |
|
1133 | 105 |
begin |
106 |
isFalling:= true; |
|
107 |
if TestCollisionYwithGear(Gear, -1) then |
|
108 |
begin |
|
109 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
110 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
111 |
Gear^.State:= Gear^.State or gstCollision |
|
112 |
end |
|
113 |
end else |
|
114 |
if TestCollisionYwithGear(Gear, 1) then |
|
115 |
begin |
|
116 |
isFalling:= false; |
|
117 |
Gear^.dX:= Gear^.dX * Gear^.Friction; |
|
118 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
119 |
Gear^.State:= Gear^.State or gstCollision |
|
120 |
end else isFalling:= true; |
|
503 | 121 |
|
351 | 122 |
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
1133 | 123 |
begin |
124 |
Gear^.dX:= - Gear^.dX * Gear^.Elasticity; |
|
125 |
Gear^.dY:= Gear^.dY * Gear^.Elasticity; |
|
126 |
Gear^.State:= Gear^.State or gstCollision |
|
127 |
end; |
|
503 | 128 |
|
542 | 129 |
if isFalling then Gear^.dY:= Gear^.dY + cGravity; |
503 | 130 |
|
351 | 131 |
Gear^.X:= Gear^.X + Gear^.dX; |
132 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 133 |
CheckGearDrowning(Gear); |
503 | 134 |
if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
1133 | 135 |
(not isFalling) then |
136 |
Gear^.State:= Gear^.State and not gstMoving |
|
137 |
else |
|
138 |
Gear^.State:= Gear^.State or gstMoving |
|
4 | 139 |
end; |
140 |
||
141 |
//////////////////////////////////////////////////////////////////////////////// |
|
142 |
procedure doStepBomb(Gear: PGear); |
|
371 | 143 |
var i: LongInt; |
919 | 144 |
dX, dY: hwFloat; |
4 | 145 |
begin |
146 |
AllInactive:= false; |
|
1263 | 147 |
|
4 | 148 |
doStepFallingGear(Gear); |
1263 | 149 |
|
351 | 150 |
dec(Gear^.Timer); |
151 |
if Gear^.Timer = 0 then |
|
1133 | 152 |
begin |
153 |
case Gear^.Kind of |
|
154 |
gtAmmo_Bomb: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1603 | 155 |
gtBall: doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 40, EXPLAutoSound); |
1133 | 156 |
gtClusterBomb: begin |
157 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
158 |
for i:= 0 to 4 do |
|
159 |
begin |
|
160 |
dX:= rndSign(GetRandom * _0_1); |
|
161 |
dY:= (GetRandom - _3) * _0_08; |
|
1261 | 162 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
163 |
end |
|
164 |
end; |
|
165 |
gtWatermelon: begin |
|
166 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
167 |
for i:= 0 to 5 do |
|
168 |
begin |
|
169 |
dX:= rndSign(GetRandom * _0_1); |
|
1496 | 170 |
dY:= (GetRandom - _1_5) * _0_3; |
1262 | 171 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMelonPiece, 0, dX, dY, 75)^.DirAngle:= i * 60; |
1133 | 172 |
end |
1263 | 173 |
end; |
1555 | 174 |
gtHellishBomb: begin |
175 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 90, EXPLAutoSound); |
|
176 |
for i:= 0 to 127 do |
|
177 |
begin |
|
178 |
dX:= AngleCos(i * 16) * _0_5 * (GetRandom + _1); |
|
179 |
dY:= AngleSin(i * 16) * _0_5 * (GetRandom + _1); |
|
180 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); |
|
181 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); |
|
182 |
end |
|
183 |
end; |
|
1133 | 184 |
end; |
185 |
DeleteGear(Gear); |
|
186 |
exit |
|
187 |
end; |
|
1263 | 188 |
|
4 | 189 |
CalcRotationDirAngle(Gear); |
1263 | 190 |
|
191 |
if Gear^.Kind = gtHellishBomb then |
|
1279 | 192 |
begin |
1669 | 193 |
if Gear^.Timer = 3000 then PlaySound(sndHellish, false, nil); |
1279 | 194 |
|
1263 | 195 |
if (GameTicks and $3F) = 0 then |
196 |
if (Gear^.State and gstCollision) = 0 then |
|
197 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0); |
|
1279 | 198 |
end; |
1263 | 199 |
|
1158 | 200 |
if (Gear^.State and (gstCollision or gstMoving)) = (gstCollision or gstMoving) then |
201 |
if (hwAbs(Gear^.dX) > _0_1) or |
|
202 |
(hwAbs(Gear^.dY) > _0_1) then |
|
1669 | 203 |
PlaySound(sndGrenadeImpact, false, nil) |
4 | 204 |
end; |
205 |
||
1279 | 206 |
procedure doStepWatermelon(Gear: PGear); |
207 |
begin |
|
208 |
AllInactive:= false; |
|
1669 | 209 |
PlaySound(sndMelon, false, nil); |
1279 | 210 |
Gear^.doStep:= @doStepBomb |
211 |
end; |
|
212 |
||
78 | 213 |
procedure doStepCluster(Gear: PGear); |
214 |
begin |
|
215 |
AllInactive:= false; |
|
216 |
doStepFallingGear(Gear); |
|
351 | 217 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 218 |
begin |
1261 | 219 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), Gear^.Timer, EXPLAutoSound); |
1133 | 220 |
DeleteGear(Gear); |
221 |
exit |
|
222 |
end; |
|
1262 | 223 |
|
224 |
if Gear^.Kind = gtMelonPiece then |
|
225 |
CalcRotationDirAngle(Gear) |
|
226 |
else |
|
227 |
if (GameTicks and $1F) = 0 then |
|
228 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
78 | 229 |
end; |
230 |
||
4 | 231 |
//////////////////////////////////////////////////////////////////////////////// |
232 |
procedure doStepGrenade(Gear: PGear); |
|
233 |
begin |
|
234 |
AllInactive:= false; |
|
351 | 235 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
4 | 236 |
doStepFallingGear(Gear); |
351 | 237 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 238 |
begin |
239 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
240 |
DeleteGear(Gear); |
|
241 |
exit |
|
242 |
end; |
|
4 | 243 |
if (GameTicks and $3F) = 0 then |
1133 | 244 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
4 | 245 |
end; |
246 |
||
247 |
//////////////////////////////////////////////////////////////////////////////// |
|
95 | 248 |
procedure doStepHealthTagWork(Gear: PGear); |
4 | 249 |
begin |
522 | 250 |
if Gear^.Kind = gtHealthTag then |
1505 | 251 |
AllInactive:= false; |
252 |
||
351 | 253 |
dec(Gear^.Timer); |
522 | 254 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
1505 | 255 |
|
351 | 256 |
if Gear^.Timer = 0 then |
1133 | 257 |
begin |
258 |
if Gear^.Kind = gtHealthTag then |
|
259 |
PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die |
|
260 |
DeleteGear(Gear) |
|
261 |
end |
|
4 | 262 |
end; |
263 |
||
263 | 264 |
procedure doStepHealthTagWorkUnderWater(Gear: PGear); |
265 |
begin |
|
1505 | 266 |
AllInactive:= false; |
1495 | 267 |
|
351 | 268 |
Gear^.Y:= Gear^.Y - _0_08; |
1495 | 269 |
|
498 | 270 |
if hwRound(Gear^.Y) < cWaterLine + 10 then |
1505 | 271 |
DeleteGear(Gear) |
263 | 272 |
end; |
273 |
||
95 | 274 |
procedure doStepHealthTag(Gear: PGear); |
275 |
var s: shortstring; |
|
276 |
begin |
|
1505 | 277 |
AllInactive:= false; |
278 |
Gear^.dY:= -_0_08; |
|
522 | 279 |
|
351 | 280 |
str(Gear^.State, s); |
1505 | 281 |
Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16); |
282 |
||
283 |
if hwRound(Gear^.Y) < cWaterLine then |
|
284 |
Gear^.doStep:= @doStepHealthTagWork |
|
285 |
else |
|
286 |
Gear^.doStep:= @doStepHealthTagWorkUnderWater; |
|
287 |
||
762 | 288 |
Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h) |
95 | 289 |
end; |
290 |
||
4 | 291 |
//////////////////////////////////////////////////////////////////////////////// |
292 |
procedure doStepGrave(Gear: PGear); |
|
293 |
begin |
|
294 |
AllInactive:= false; |
|
498 | 295 |
if Gear^.dY.isNegative then |
296 |
if TestCollisionY(Gear, -1) then Gear^.dY:= _0; |
|
4 | 297 |
|
351 | 298 |
if not Gear^.dY.isNegative then |
68 | 299 |
if TestCollisionY(Gear, 1) then |
4 | 300 |
begin |
351 | 301 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
302 |
if Gear^.dY > - _1div1024 then |
|
4 | 303 |
begin |
351 | 304 |
Gear^.Active:= false; |
4 | 305 |
exit |
1669 | 306 |
end else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil) |
4 | 307 |
end; |
1505 | 308 |
|
351 | 309 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
4 | 310 |
CheckGearDrowning(Gear); |
351 | 311 |
Gear^.dY:= Gear^.dY + cGravity |
4 | 312 |
end; |
313 |
||
314 |
//////////////////////////////////////////////////////////////////////////////// |
|
315 |
procedure doStepUFOWork(Gear: PGear); |
|
351 | 316 |
var t: hwFloat; |
374 | 317 |
y: LongInt; |
4 | 318 |
begin |
319 |
AllInactive:= false; |
|
351 | 320 |
t:= Distance(Gear^.dX, Gear^.dY); |
321 |
Gear^.dX:= Gear^.Elasticity * (Gear^.dX + _0_000004 * (TargetPoint.X - hwRound(Gear^.X))); |
|
322 |
Gear^.dY:= Gear^.Elasticity * (Gear^.dY + _0_000004 * (TargetPoint.Y - hwRound(Gear^.Y))); |
|
323 |
t:= t / Distance(Gear^.dX, Gear^.dY); |
|
324 |
Gear^.dX:= Gear^.dX * t; |
|
325 |
Gear^.dY:= Gear^.dY * t; |
|
326 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
327 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
374 | 328 |
|
329 |
if (GameTicks and $3F) = 0 then |
|
330 |
begin |
|
331 |
y:= hwRound(Gear^.Y); |
|
332 |
if y + Gear^.Radius < cWaterLine then |
|
498 | 333 |
AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0); |
374 | 334 |
end; |
335 |
||
4 | 336 |
CheckCollision(Gear); |
351 | 337 |
dec(Gear^.Timer); |
338 |
if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then |
|
4 | 339 |
begin |
560 | 340 |
StopSound(sndUFO); |
351 | 341 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 342 |
DeleteGear(Gear); |
343 |
end; |
|
344 |
end; |
|
345 |
||
346 |
procedure doStepUFO(Gear: PGear); |
|
347 |
begin |
|
348 |
AllInactive:= false; |
|
351 | 349 |
Gear^.X:= Gear^.X + Gear^.dX; |
350 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
351 |
Gear^.dY:= Gear^.dY + cGravity; |
|
4 | 352 |
CheckCollision(Gear); |
351 | 353 |
if (Gear^.State and gstCollision) <> 0 then |
4 | 354 |
begin |
351 | 355 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
4 | 356 |
DeleteGear(Gear); |
357 |
exit |
|
358 |
end; |
|
351 | 359 |
dec(Gear^.Timer); |
360 |
if Gear^.Timer = 0 then |
|
4 | 361 |
begin |
1669 | 362 |
PlaySound(sndUFO, true, nil); |
351 | 363 |
Gear^.Timer:= 5000; |
364 |
Gear^.doStep:= @doStepUFOWork |
|
4 | 365 |
end; |
366 |
end; |
|
367 |
||
368 |
//////////////////////////////////////////////////////////////////////////////// |
|
876 | 369 |
procedure doStepShotIdle(Gear: PGear); |
370 |
begin |
|
371 |
AllInactive:= false; |
|
372 |
inc(Gear^.Timer); |
|
373 |
if Gear^.Timer > 75 then |
|
374 |
begin |
|
375 |
DeleteGear(Gear); |
|
376 |
AfterAttack |
|
377 |
end |
|
378 |
end; |
|
379 |
||
4 | 380 |
procedure doStepShotgunShot(Gear: PGear); |
381 |
var i: LongWord; |
|
382 |
begin |
|
383 |
AllInactive:= false; |
|
876 | 384 |
|
385 |
if ((Gear^.State and gstAnimation) = 0) then |
|
386 |
begin |
|
387 |
dec(Gear^.Timer); |
|
388 |
if Gear^.Timer = 0 then |
|
389 |
begin |
|
1669 | 390 |
PlaySound(sndShotgunFire, false, nil); |
876 | 391 |
Gear^.State:= Gear^.State or gstAnimation |
392 |
end; |
|
393 |
exit |
|
394 |
end |
|
395 |
else inc(Gear^.Timer); |
|
396 |
||
4 | 397 |
i:= 200; |
398 |
repeat |
|
351 | 399 |
Gear^.X:= Gear^.X + Gear^.dX; |
400 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
4 | 401 |
CheckCollision(Gear); |
351 | 402 |
if (Gear^.State and gstCollision) <> 0 then |
876 | 403 |
begin |
404 |
Gear^.X:= Gear^.X + Gear^.dX * 8; |
|
405 |
Gear^.Y:= Gear^.Y + Gear^.dY * 8; |
|
406 |
ShotgunShot(Gear); |
|
407 |
Gear^.doStep:= @doStepShotIdle; |
|
408 |
exit |
|
409 |
end; |
|
4 | 410 |
dec(i) |
411 |
until i = 0; |
|
1760 | 412 |
if (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then |
876 | 413 |
Gear^.doStep:= @doStepShotIdle |
4 | 414 |
end; |
415 |
||
416 |
//////////////////////////////////////////////////////////////////////////////// |
|
559 | 417 |
procedure doStepDEagleShotWork(Gear: PGear); |
38 | 418 |
var i, x, y: LongWord; |
351 | 419 |
oX, oY: hwFloat; |
38 | 420 |
begin |
421 |
AllInactive:= false; |
|
876 | 422 |
inc(Gear^.Timer); |
37 | 423 |
i:= 80; |
351 | 424 |
oX:= Gear^.X; |
425 |
oY:= Gear^.Y; |
|
37 | 426 |
repeat |
351 | 427 |
Gear^.X:= Gear^.X + Gear^.dX; |
428 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
429 |
x:= hwRound(Gear^.X); |
|
430 |
y:= hwRound(Gear^.Y); |
|
1753 | 431 |
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) |
351 | 432 |
and (Land[y, x] <> 0) then inc(Gear^.Damage); |
519 | 433 |
if Gear^.Damage > 5 then AmmoShove(Gear, 7, 20); |
38 | 434 |
dec(i) |
351 | 435 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
436 |
if Gear^.Damage > 0 then |
|
37 | 437 |
begin |
351 | 438 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1); |
439 |
dec(Gear^.Health, Gear^.Damage); |
|
440 |
Gear^.Damage:= 0 |
|
37 | 441 |
end; |
1760 | 442 |
|
443 |
if (Gear^.Health <= 0) |
|
444 |
or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) |
|
445 |
or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then |
|
876 | 446 |
Gear^.doStep:= @doStepShotIdle |
37 | 447 |
end; |
448 |
||
559 | 449 |
procedure doStepDEagleShot(Gear: PGear); |
450 |
begin |
|
1669 | 451 |
PlaySound(sndGun, false, nil); |
559 | 452 |
Gear^.doStep:= @doStepDEagleShotWork |
453 |
end; |
|
454 |
||
37 | 455 |
//////////////////////////////////////////////////////////////////////////////// |
4 | 456 |
procedure doStepActionTimer(Gear: PGear); |
457 |
begin |
|
351 | 458 |
dec(Gear^.Timer); |
459 |
case Gear^.Kind of |
|
83 | 460 |
gtATStartGame: begin |
4 | 461 |
AllInactive:= false; |
351 | 462 |
if Gear^.Timer = 0 then |
83 | 463 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
4 | 464 |
end; |
83 | 465 |
gtATSmoothWindCh: begin |
351 | 466 |
if Gear^.Timer = 0 then |
6 | 467 |
begin |
351 | 468 |
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) |
469 |
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); |
|
470 |
if WindBarWidth <> Gear^.Tag then Gear^.Timer:= 10; |
|
83 | 471 |
end |
472 |
end; |
|
473 |
gtATFinishGame: begin |
|
474 |
AllInactive:= false; |
|
351 | 475 |
if Gear^.Timer = 0 then |
113 | 476 |
begin |
477 |
SendIPC('N'); |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
478 |
SendIPC('q'); |
83 | 479 |
GameState:= gsExit |
113 | 480 |
end |
6 | 481 |
end; |
4 | 482 |
end; |
351 | 483 |
if Gear^.Timer = 0 then DeleteGear(Gear) |
4 | 484 |
end; |
485 |
||
486 |
//////////////////////////////////////////////////////////////////////////////// |
|
487 |
procedure doStepPickHammerWork(Gear: PGear); |
|
371 | 488 |
var i, ei: LongInt; |
4 | 489 |
HHGear: PGear; |
490 |
begin |
|
70 | 491 |
AllInactive:= false; |
351 | 492 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
493 |
dec(Gear^.Timer); |
|
494 |
if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then |
|
1200 | 495 |
begin |
496 |
StopSound(sndPickhammer); |
|
497 |
DeleteGear(Gear); |
|
498 |
AfterAttack; |
|
499 |
exit |
|
500 |
end; |
|
845 | 501 |
|
422 | 502 |
if (Gear^.Timer mod 33) = 0 then |
1200 | 503 |
begin |
504 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
505 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 7, 6, EXPLDontDraw); |
|
506 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
507 |
end; |
|
422 | 508 |
|
509 |
if (Gear^.Timer mod 47) = 0 then |
|
1200 | 510 |
begin |
511 |
i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
|
512 |
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
513 |
while i <= ei do |
|
514 |
begin |
|
515 |
DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); |
|
516 |
inc(i, 1) |
|
517 |
end; |
|
518 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
519 |
Gear^.Y:= Gear^.Y + _1_9; |
|
520 |
SetAllHHToActive; |
|
521 |
end; |
|
4 | 522 |
if TestCollisionYwithGear(Gear, 1) then |
1200 | 523 |
begin |
524 |
Gear^.dY:= _0; |
|
525 |
SetLittle(HHGear^.dX); |
|
526 |
HHGear^.dY:= _0; |
|
527 |
end else |
|
528 |
begin |
|
529 |
Gear^.dY:= Gear^.dY + cGravity; |
|
530 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1417 | 531 |
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 |
1200 | 532 |
end; |
4 | 533 |
|
351 | 534 |
Gear^.X:= Gear^.X + HHGear^.dX; |
535 |
HHGear^.X:= Gear^.X; |
|
498 | 536 |
HHGear^.Y:= Gear^.Y - int2hwFloat(cHHRadius); |
4 | 537 |
|
351 | 538 |
if (Gear^.Message and gm_Attack) <> 0 then |
539 |
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else |
|
540 |
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
541 |
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else |
|
542 |
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3 |
|
498 | 543 |
else Gear^.dX:= _0; |
4 | 544 |
end; |
545 |
||
546 |
procedure doStepPickHammer(Gear: PGear); |
|
371 | 547 |
var i, y: LongInt; |
4 | 548 |
ar: TRangeArray; |
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
549 |
HHGear: PGear; |
4 | 550 |
begin |
551 |
i:= 0; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
552 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
553 |
|
498 | 554 |
y:= hwRound(Gear^.Y) - cHHRadius * 2; |
351 | 555 |
while y < hwRound(Gear^.Y) do |
4 | 556 |
begin |
371 | 557 |
ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
558 |
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 559 |
inc(y, 2); |
560 |
inc(i) |
|
561 |
end; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
562 |
|
498 | 563 |
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
|
564 |
Gear^.dY:= HHGear^.dY; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
565 |
DeleteCI(HHGear); |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
566 |
|
1669 | 567 |
PlaySound(sndPickhammer, true, nil); |
4 | 568 |
doStepPickHammerWork(Gear); |
351 | 569 |
Gear^.doStep:= @doStepPickHammerWork |
4 | 570 |
end; |
571 |
||
572 |
//////////////////////////////////////////////////////////////////////////////// |
|
371 | 573 |
var BTPrevAngle, BTSteps: LongInt; |
302 | 574 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
575 |
procedure doStepBlowTorchWork(Gear: PGear); |
302 | 576 |
var HHGear: PGear; |
1528 | 577 |
b: boolean; |
578 |
prevX: LongInt; |
|
302 | 579 |
begin |
580 |
AllInactive:= false; |
|
351 | 581 |
dec(Gear^.Timer); |
582 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
583 |
|
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
584 |
HedgehogChAngle(HHGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
585 |
|
305 | 586 |
b:= false; |
587 |
||
371 | 588 |
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
1528 | 589 |
begin |
590 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); |
|
591 |
Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); |
|
592 |
BTPrevAngle:= HHGear^.Angle; |
|
593 |
b:= true |
|
594 |
end; |
|
595 |
||
596 |
if ((HHGear^.State and gstMoving) <> 0) then |
|
597 |
begin |
|
598 |
doStepHedgehogMoving(HHGear); |
|
1736 | 599 |
if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer:= 0 |
1528 | 600 |
end; |
305 | 601 |
|
351 | 602 |
if Gear^.Timer mod cHHStepTicks = 0 then |
1528 | 603 |
begin |
604 |
b:= true; |
|
605 |
if Gear^.dX.isNegative then |
|
1547 | 606 |
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left |
1528 | 607 |
else |
1547 | 608 |
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; |
305 | 609 |
|
1528 | 610 |
if ((HHGear^.State and gstMoving) = 0) then |
611 |
begin |
|
612 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
613 |
prevX:= hwRound(HHGear^.X); |
|
614 |
||
615 |
HedgehogStep(HHGear); |
|
616 |
||
617 |
if (prevX = hwRound(HHGear^.X)) then HHGear^.X:= HHGear^.X + SignAs(_1, HHGear^.dX); |
|
618 |
HHGear^.State:= HHGear^.State or gstAttacking |
|
619 |
end; |
|
305 | 620 |
|
1528 | 621 |
inc(BTSteps); |
622 |
if BTSteps = 7 then |
|
623 |
begin |
|
624 |
BTSteps:= 0; |
|
625 |
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); |
|
626 |
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); |
|
627 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1643 | 628 |
AmmoShove(Gear, 2, 15); |
1528 | 629 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
630 |
end; |
|
631 |
end; |
|
305 | 632 |
|
633 |
if b then |
|
498 | 634 |
DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
351 | 635 |
Gear^.dX, Gear^.dY, |
1501 | 636 |
cHHRadius * 5, cHHRadius * 2 + 7); |
305 | 637 |
|
1784 | 638 |
if (Gear^.Timer = 0) or ((HHGear^.Message and gm_Attack) <> 0) or (Land[hwRound(HHGear^.Y), hwRound(HHGear^.X + Gear^.dX * 32)] = COLOR_INDESTRUCTIBLE) then |
1528 | 639 |
begin |
640 |
HHGear^.Message:= 0; |
|
641 |
HHGear^.State:= HHGear^.State and (not gstNotKickable); |
|
642 |
DeleteGear(Gear); |
|
643 |
AfterAttack |
|
644 |
end |
|
302 | 645 |
end; |
646 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
647 |
procedure doStepBlowTorch(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
648 |
var HHGear: PGear; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
649 |
begin |
371 | 650 |
BTPrevAngle:= High(LongInt); |
305 | 651 |
BTSteps:= 0; |
351 | 652 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
653 |
HHGear^.Message:= 0; |
|
1528 | 654 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
351 | 655 |
Gear^.doStep:= @doStepBlowTorchWork |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
656 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
657 |
|
302 | 658 |
//////////////////////////////////////////////////////////////////////////////// |
659 |
||
1781 | 660 |
procedure doStepRope(Gear: PGear); forward; |
661 |
||
662 |
procedure doStepRopeAfterAttack(Gear: PGear); |
|
663 |
var HHGear: PGear; |
|
664 |
begin |
|
665 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
666 |
if ((HHGear^.State and gstHHDriven) = 0) |
|
667 |
or (CheckGearDrowning(HHGear)) |
|
668 |
or TestCollisionYwithGear(HHGear, 1) then |
|
669 |
begin |
|
670 |
DeleteGear(Gear); |
|
671 |
exit |
|
672 |
end; |
|
673 |
||
1785 | 674 |
HedgehogChAngle(HHGear); |
675 |
||
1781 | 676 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
677 |
if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY:= _0; |
|
678 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
679 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
680 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
681 |
||
682 |
if (Gear^.Message and gm_Attack) <> 0 then |
|
683 |
begin |
|
684 |
Gear^.X:= HHGear^.X; |
|
685 |
Gear^.Y:= HHGear^.Y; |
|
1964 | 686 |
|
687 |
ApplyAngleBounds(PHedgehog(Gear^.Hedgehog)^, amRope); |
|
688 |
||
1781 | 689 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); |
690 |
Gear^.dY:= -AngleCos(HHGear^.Angle); |
|
691 |
Gear^.Friction:= _450; |
|
692 |
Gear^.Elasticity:= _0; |
|
693 |
Gear^.State:= Gear^.State and not gsttmpflag; |
|
694 |
Gear^.doStep:= @doStepRope |
|
695 |
end |
|
696 |
end; |
|
697 |
||
4 | 698 |
procedure doStepRopeWork(Gear: PGear); |
699 |
var HHGear: PGear; |
|
1669 | 700 |
len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat; |
1504 | 701 |
lx, ly: LongInt; |
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
702 |
haveCollision, |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
703 |
haveDivided: boolean; |
4 | 704 |
|
1504 | 705 |
procedure DeleteMe; |
706 |
begin |
|
707 |
with HHGear^ do |
|
708 |
begin |
|
709 |
Message:= Message and not gm_Attack; |
|
710 |
State:= State or gstMoving; |
|
1892 | 711 |
State:= State and not gstWinner; |
1504 | 712 |
end; |
713 |
DeleteGear(Gear) |
|
714 |
end; |
|
4 | 715 |
|
1781 | 716 |
procedure WaitCollision; |
717 |
begin |
|
718 |
with HHGear^ do |
|
719 |
begin |
|
720 |
Message:= Message and not gm_Attack; |
|
721 |
State:= State or gstMoving; |
|
722 |
end; |
|
723 |
RopePoints.Count:= 0; |
|
724 |
Gear^.Elasticity:= _0; |
|
725 |
Gear^.doStep:= @doStepRopeAfterAttack |
|
726 |
end; |
|
727 |
||
4 | 728 |
begin |
351 | 729 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 730 |
|
351 | 731 |
if ((HHGear^.State and gstHHDriven) = 0) |
1504 | 732 |
or (CheckGearDrowning(HHGear)) then |
733 |
begin |
|
734 |
DeleteMe; |
|
735 |
exit |
|
736 |
end; |
|
928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
925
diff
changeset
|
737 |
|
351 | 738 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
739 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 740 |
|
351 | 741 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 742 |
|
1652 | 743 |
ropeDx:= HHGear^.X - Gear^.X; // vector between hedgehog and rope attaching point |
744 |
ropeDy:= HHGear^.Y - Gear^.Y; |
|
745 |
||
746 |
mdX:= ropeDx + HHGear^.dX; |
|
747 |
mdY:= ropeDy + HHGear^.dY; |
|
748 |
len:= _1 / Distance(mdX, mdY); |
|
749 |
mdX:= mdX * len; // rope vector plus hedgehog direction vector normalized |
|
750 |
mdY:= mdY * len; |
|
751 |
||
752 |
Gear^.dX:= mdX; // for visual purposes only |
|
753 |
Gear^.dY:= mdY; |
|
754 |
||
755 |
///// |
|
756 |
tx:= HHGear^.X; |
|
757 |
ty:= HHGear^.Y; |
|
4 | 758 |
|
1652 | 759 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
760 |
if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) |
|
761 |
or TestCollisionYwithGear(HHGear, hwSign(ropeDy))) then |
|
762 |
Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
763 |
||
764 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
|
765 |
if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) |
|
766 |
or TestCollisionYwithGear(HHGear, -hwSign(ropeDy))) then |
|
767 |
Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
768 |
||
769 |
HHGear^.X:= Gear^.X + mdX * Gear^.Elasticity; |
|
770 |
HHGear^.Y:= Gear^.Y + mdY * Gear^.Elasticity; |
|
771 |
||
772 |
HHGear^.dX:= HHGear^.X - tx; |
|
773 |
HHGear^.dY:= HHGear^.Y - ty; |
|
774 |
//// |
|
775 |
||
1554 | 776 |
|
1922 | 777 |
haveDivided:= false; |
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
778 |
// check whether rope needs dividing |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
779 |
len:= _1 / Distance(ropeDx, ropeDy); // old rope pos |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
780 |
nx:= ropeDx * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
781 |
ny:= ropeDy * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
782 |
|
1652 | 783 |
len:= Gear^.Elasticity - _0_3x70; |
784 |
while len > _0_3 do |
|
1504 | 785 |
begin |
1652 | 786 |
lx:= hwRound(Gear^.X + mdX * len); |
787 |
ly:= hwRound(Gear^.Y + mdY * len); |
|
1753 | 788 |
if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then |
1504 | 789 |
begin |
790 |
with RopePoints.ar[RopePoints.Count] do |
|
791 |
begin |
|
792 |
X:= Gear^.X; |
|
793 |
Y:= Gear^.Y; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
794 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); |
1652 | 795 |
b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); |
1504 | 796 |
dLen:= len |
797 |
end; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
798 |
Gear^.X:= Gear^.X + nx * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
799 |
Gear^.Y:= Gear^.Y + ny * len; |
1504 | 800 |
inc(RopePoints.Count); |
801 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
|
802 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
|
803 |
Gear^.Friction:= Gear^.Friction - len; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
804 |
haveDivided:= true; |
1504 | 805 |
break |
806 |
end; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
807 |
len:= len - _0_3 // should be the same as increase step |
1504 | 808 |
end; |
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
809 |
|
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
810 |
if not haveDivided then |
1504 | 811 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
812 |
begin |
|
813 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
814 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
815 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
|
816 |
begin |
|
817 |
dec(RopePoints.Count); |
|
1652 | 818 |
Gear^.X:= RopePoints.ar[RopePoints.Count].X; |
819 |
Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; |
|
1504 | 820 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
821 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
822 |
end |
|
823 |
end; |
|
4 | 824 |
|
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
825 |
haveCollision:= false; |
351 | 826 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
827 |
begin |
1504 | 828 |
HHGear^.dX:= -_0_6 * HHGear^.dX; |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
829 |
haveCollision:= true |
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
830 |
end; |
351 | 831 |
if TestCollisionYwithGear(HHGear, hwSign(HHGear^.dY)) then |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
832 |
begin |
1504 | 833 |
HHGear^.dY:= -_0_6 * HHGear^.dY; |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
834 |
haveCollision:= true |
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
835 |
end; |
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
836 |
|
1579
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
837 |
if haveCollision |
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
838 |
and (Gear^.Message and (gm_Left or gm_Right) <> 0) |
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
839 |
and (Gear^.Message and (gm_Up or gm_Down) <> 0) then |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
840 |
begin |
1579
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
841 |
HHGear^.dX:= SignAs(hwAbs(HHGear^.dX) + _0_2, HHGear^.dX); |
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
842 |
HHGear^.dY:= SignAs(hwAbs(HHGear^.dY) + _0_2, HHGear^.dY) |
1551
c747e69f98f3
Add some speed to hedgehog on rope when colliding with land and pressing left or right arrow key
unc0rr
parents:
1548
diff
changeset
|
843 |
end; |
4 | 844 |
|
789 | 845 |
len:= Distance(HHGear^.dX, HHGear^.dY); |
940 | 846 |
if len > _0_8 then |
1504 | 847 |
begin |
848 |
len:= _0_8 / len; |
|
849 |
HHGear^.dX:= HHGear^.dX * len; |
|
850 |
HHGear^.dY:= HHGear^.dY * len; |
|
851 |
end; |
|
789 | 852 |
|
351 | 853 |
if (Gear^.Message and gm_Attack) <> 0 then |
1504 | 854 |
if (Gear^.State and gsttmpFlag) <> 0 then |
1922 | 855 |
with PHedgehog(Gear^.Hedgehog)^ do |
1964 | 856 |
if Ammo^[CurSlot, CurAmmo].AmmoType <> amParachute then |
1922 | 857 |
WaitCollision |
858 |
else |
|
859 |
DeleteMe |
|
1504 | 860 |
else |
861 |
else |
|
862 |
if (Gear^.State and gsttmpFlag) = 0 then |
|
863 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 864 |
end; |
865 |
||
866 |
procedure doStepRopeAttach(Gear: PGear); |
|
867 |
var HHGear: PGear; |
|
1781 | 868 |
tx, ty, tt: hwFloat; |
869 |
||
870 |
procedure RemoveFromAmmo; |
|
871 |
begin |
|
872 |
if (Gear^.State and gstAttacked) = 0 then |
|
873 |
begin |
|
874 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
875 |
Gear^.State:= Gear^.State or gstAttacked |
|
1964 | 876 |
end; |
877 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
|
1781 | 878 |
end; |
879 |
||
4 | 880 |
begin |
351 | 881 |
Gear^.X:= Gear^.X - Gear^.dX; |
882 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 883 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 884 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 885 |
DeleteCI(HHGear); |
542 | 886 |
if (HHGear^.State and gstMoving) <> 0 then |
1433 | 887 |
if TestCollisionYwithGear(HHGear, 1) then |
888 |
begin |
|
889 |
CheckHHDamage(HHGear); |
|
890 |
HHGear^.dY:= _0; |
|
891 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
|
892 |
end else |
|
893 |
begin |
|
894 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
|
895 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
896 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
897 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
898 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
899 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
900 |
tt:= Gear^.Elasticity; |
|
901 |
tx:= _0; |
|
902 |
ty:= _0; |
|
903 |
while tt > _20 do |
|
904 |
begin |
|
905 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
|
906 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
907 |
begin |
|
908 |
Gear^.X:= Gear^.X + tx; |
|
909 |
Gear^.Y:= Gear^.Y + ty; |
|
910 |
Gear^.Elasticity:= tt; |
|
911 |
Gear^.doStep:= @doStepRopeWork; |
|
1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
912 |
with HHGear^ do State:= State and not (gstAttacking or gstMoving or gstHHHJump); |
1781 | 913 |
|
914 |
RemoveFromAmmo; |
|
915 |
||
1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
916 |
tt:= _0; |
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
917 |
exit |
1433 | 918 |
end; |
919 |
tx:= tx + Gear^.dX + Gear^.dX; |
|
920 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
921 |
tt:= tt - _2; |
|
922 |
end; |
|
923 |
end; |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
924 |
|
4 | 925 |
CheckCollision(Gear); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
926 |
|
351 | 927 |
if (Gear^.State and gstCollision) <> 0 then |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
928 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
929 |
Gear^.doStep:= @doStepRopeWork; |
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset
|
930 |
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
|
931 |
|
1781 | 932 |
RemoveFromAmmo; |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
933 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
934 |
if Gear^.Elasticity < _10 then |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
935 |
Gear^.Elasticity:= _10000; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
936 |
end; |
4 | 937 |
|
1634
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
938 |
if (Gear^.Elasticity > Gear^.Friction) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
939 |
or ((Gear^.Message and gm_Attack) = 0) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
940 |
or (HHGear^.Damage > 0) then |
1433 | 941 |
begin |
942 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
|
943 |
begin |
|
944 |
State:= State and not gstAttacking; |
|
945 |
Message:= Message and not gm_Attack |
|
946 |
end; |
|
947 |
DeleteGear(Gear) |
|
948 |
end |
|
4 | 949 |
end; |
950 |
||
951 |
procedure doStepRope(Gear: PGear); |
|
952 |
begin |
|
351 | 953 |
Gear^.dX:= - Gear^.dX; |
954 |
Gear^.dY:= - Gear^.dY; |
|
955 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 956 |
end; |
957 |
||
958 |
//////////////////////////////////////////////////////////////////////////////// |
|
959 |
procedure doStepSmokeTrace(Gear: PGear); |
|
960 |
begin |
|
351 | 961 |
inc(Gear^.Timer); |
962 |
if Gear^.Timer > 64 then |
|
1133 | 963 |
begin |
964 |
Gear^.Timer:= 0; |
|
965 |
dec(Gear^.State) |
|
966 |
end; |
|
351 | 967 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
968 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
969 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 970 |
end; |
9 | 971 |
|
972 |
//////////////////////////////////////////////////////////////////////////////// |
|
1045 | 973 |
procedure doStepExplosionWork(Gear: PGear); |
9 | 974 |
begin |
351 | 975 |
inc(Gear^.Timer); |
976 |
if Gear^.Timer > 75 then |
|
1133 | 977 |
begin |
978 |
inc(Gear^.State); |
|
979 |
Gear^.Timer:= 0; |
|
980 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
981 |
end; |
|
9 | 982 |
end; |
10 | 983 |
|
1045 | 984 |
procedure doStepExplosion(Gear: PGear); |
985 |
var i: LongWord; |
|
986 |
begin |
|
1047 | 987 |
for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire); |
988 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart); |
|
989 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2); |
|
1045 | 990 |
Gear^.doStep:= @doStepExplosionWork |
991 |
end; |
|
992 |
||
10 | 993 |
//////////////////////////////////////////////////////////////////////////////// |
994 |
procedure doStepMine(Gear: PGear); |
|
995 |
begin |
|
542 | 996 |
if (Gear^.State and gstMoving) <> 0 then |
914 | 997 |
begin |
998 |
DeleteCI(Gear); |
|
999 |
doStepFallingGear(Gear); |
|
1000 |
if (Gear^.State and gstMoving) = 0 then |
|
1001 |
begin |
|
1002 |
AddGearCI(Gear); |
|
1003 |
Gear^.dX:= _0; |
|
1004 |
Gear^.dY:= _0 |
|
1005 |
end; |
|
1006 |
CalcRotationDirAngle(Gear); |
|
1007 |
AllInactive:= false |
|
1008 |
end else |
|
1009 |
if ((GameTicks and $3F) = 25) then |
|
1010 |
doStepFallingGear(Gear); |
|
351 | 1011 |
|
1012 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
1133 | 1013 |
if ((Gear^.State and gstAttacking) = 0) then |
1014 |
begin |
|
1015 |
if ((GameTicks and $1F) = 0) then |
|
1016 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking |
|
1017 |
end else // gstAttacking <> 0 |
|
1018 |
begin |
|
1019 |
AllInactive:= false; |
|
1669 | 1020 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil); |
1133 | 1021 |
if Gear^.Timer = 0 then |
1022 |
begin |
|
1023 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1024 |
DeleteGear(Gear); |
|
1025 |
exit |
|
1026 |
end; |
|
1027 |
dec(Gear^.Timer); |
|
1028 |
end else // gsttmpFlag = 0 |
|
1029 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
10 | 1030 |
end; |
57 | 1031 |
|
39 | 1032 |
//////////////////////////////////////////////////////////////////////////////// |
1033 |
procedure doStepDynamite(Gear: PGear); |
|
1034 |
begin |
|
43 | 1035 |
doStepFallingGear(Gear); |
1036 |
AllInactive:= false; |
|
351 | 1037 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
1038 |
if Gear^.Timer = 0 then |
|
1133 | 1039 |
begin |
1040 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
1041 |
DeleteGear(Gear); |
|
1042 |
exit |
|
1043 |
end; |
|
351 | 1044 |
dec(Gear^.Timer); |
39 | 1045 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1046 |
|
351 | 1047 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1048 |
procedure doStepCase(Gear: PGear); |
371 | 1049 |
var i, x, y: LongInt; |
1436 | 1050 |
k: TGearType; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1051 |
begin |
351 | 1052 |
if (Gear^.Message and gm_Destroy) > 0 then |
1133 | 1053 |
begin |
1054 |
DeleteGear(Gear); |
|
1055 |
FreeActionsList; |
|
1056 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
|
1057 |
with CurrentHedgehog^ do |
|
1058 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
1059 |
exit |
|
1060 |
end; |
|
15 | 1061 |
|
351 | 1062 |
if Gear^.Damage > 0 then |
1133 | 1063 |
begin |
1064 |
x:= hwRound(Gear^.X); |
|
1065 |
y:= hwRound(Gear^.Y); |
|
1436 | 1066 |
k:= Gear^.Kind; |
1067 |
DeleteGear(Gear); // <-- delete gear! |
|
1068 |
||
1069 |
if k = gtCase then |
|
1133 | 1070 |
begin |
1071 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
1072 |
for i:= 0 to 63 do |
|
1073 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
1074 |
end; |
|
1075 |
exit |
|
1076 |
end; |
|
79 | 1077 |
|
351 | 1078 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
1133 | 1079 |
begin |
1080 |
AllInactive:= false; |
|
1081 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1082 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1083 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
|
1084 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
|
1085 |
begin |
|
1086 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
1087 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
|
1669 | 1088 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil); |
1133 | 1089 |
end; |
1090 |
CheckGearDrowning(Gear); |
|
1091 |
end; |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1092 |
|
511 | 1093 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1133 | 1094 |
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
|
1095 |
end; |
49 | 1096 |
|
1097 |
//////////////////////////////////////////////////////////////////////////////// |
|
854 | 1098 |
procedure doStepIdle(Gear: PGear); |
1099 |
begin |
|
1100 |
AllInactive:= false; |
|
925 | 1101 |
dec(Gear^.Timer); |
854 | 1102 |
if Gear^.Timer = 0 then |
1103 |
begin |
|
1104 |
DeleteGear(Gear); |
|
1105 |
AfterAttack |
|
1106 |
end |
|
1107 |
end; |
|
1108 |
||
79 | 1109 |
procedure doStepShover(Gear: PGear); |
1110 |
var HHGear: PGear; |
|
1111 |
begin |
|
351 | 1112 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1113 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1114 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1115 |
|
79 | 1116 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1117 |
|
351 | 1118 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 1119 |
Gear^.Timer:= 250; |
1120 |
Gear^.doStep:= @doStepIdle |
|
79 | 1121 |
end; |
1122 |
||
1123 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 1124 |
procedure doStepWhip(Gear: PGear); |
1125 |
var HHGear: PGear; |
|
1126 |
i: LongInt; |
|
1127 |
begin |
|
1128 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1129 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1130 |
DeleteCI(HHGear); |
925 | 1131 |
|
1132 |
for i:= 0 to 3 do |
|
1133 |
begin |
|
1134 |
AmmoShove(Gear, 30, 25); |
|
1135 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1136 |
end; |
|
1137 |
||
1138 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1139 |
Gear^.Timer:= 250; |
|
1140 |
Gear^.doStep:= @doStepIdle |
|
1141 |
end; |
|
1142 |
||
1143 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1144 |
procedure doStepFlame(Gear: PGear); |
1145 |
begin |
|
1146 |
AllInactive:= false; |
|
1433 | 1147 |
|
79 | 1148 |
if not TestCollisionYwithGear(Gear, 1) then |
1133 | 1149 |
begin |
1586 | 1150 |
if hwAbs(Gear^.dX) > _0_01 then |
1151 |
Gear^.dX:= Gear^.dX * _0_995; |
|
1297 | 1152 |
|
1133 | 1153 |
Gear^.dY:= Gear^.dY + cGravity; |
1830 | 1154 |
if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995; |
1297 | 1155 |
|
1830 | 1156 |
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640; |
1133 | 1157 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
1297 | 1158 |
|
1417 | 1159 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
1133 | 1160 |
begin |
1161 |
DeleteGear(Gear); |
|
1162 |
exit |
|
1163 |
end |
|
1164 |
end else begin |
|
1165 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
|
1166 |
else begin |
|
1586 | 1167 |
Gear^.Radius:= 9; |
1168 |
AmmoShove(Gear, 4, 100); |
|
1297 | 1169 |
Gear^.Radius:= 1; |
1170 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); |
|
1133 | 1171 |
dec(Gear^.Health); |
1586 | 1172 |
Gear^.Timer:= 450 - Gear^.Tag * 8 |
1133 | 1173 |
end |
1174 |
end; |
|
79 | 1175 |
|
1295 | 1176 |
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then |
1177 |
// AmmoFlameWork(Gear); |
|
79 | 1178 |
|
351 | 1179 |
if Gear^.Health = 0 then |
1133 | 1180 |
DeleteGear(Gear) |
79 | 1181 |
end; |
82 | 1182 |
|
1183 |
//////////////////////////////////////////////////////////////////////////////// |
|
1184 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1185 |
var HHGear: PGear; |
|
1186 |
begin |
|
1187 |
AllInactive:= false; |
|
351 | 1188 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
1133 | 1189 |
begin |
1190 |
DeleteGear(Gear); |
|
1191 |
AfterAttack; |
|
1192 |
exit |
|
1193 |
end; |
|
82 | 1194 |
|
351 | 1195 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1196 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
1133 | 1197 |
begin |
1198 |
Gear^.Tag:= hwRound(HHGear^.Y); |
|
1199 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
|
1200 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1201 |
Gear^.Y:= HHGear^.Y; |
|
1202 |
AmmoShove(Gear, 30, 40); |
|
1203 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
1204 |
end; |
|
351 | 1205 |
|
1206 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1207 |
if not (HHGear^.dY.isNegative) then |
|
1133 | 1208 |
begin |
1209 |
HHGear^.State:= HHGear^.State or gstMoving; |
|
1210 |
DeleteGear(Gear); |
|
1211 |
AfterAttack; |
|
1212 |
exit |
|
1213 |
end; |
|
351 | 1214 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1215 |
end; |
1216 |
||
1217 |
procedure doStepFirePunch(Gear: PGear); |
|
1218 |
var HHGear: PGear; |
|
1219 |
begin |
|
1220 |
AllInactive:= false; |
|
351 | 1221 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1222 |
DeleteCI(HHGear); |
498 | 1223 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1224 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1225 |
|
351 | 1226 |
HHGear^.dY:= - _0_3; |
82 | 1227 |
|
351 | 1228 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1229 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1230 |
Gear^.dY:= - _0_9; |
1231 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1232 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
1279 | 1233 |
|
1669 | 1234 |
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack) |
82 | 1235 |
end; |
1236 |
||
263 | 1237 |
//////////////////////////////////////////////////////////////////////////////// |
1238 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1239 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1240 |
var HHGear: PGear; |
1241 |
begin |
|
351 | 1242 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1243 |
|
516 | 1244 |
inc(Gear^.Timer); |
1245 |
||
212 | 1246 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1247 |
or ((HHGear^.State and gstHHDriven) = 0) |
1248 |
or CheckGearDrowning(HHGear) |
|
1249 |
or ((Gear^.Message and gm_Attack) <> 0) then |
|
1250 |
begin |
|
1251 |
with HHGear^ do |
|
1252 |
begin |
|
1253 |
Message:= 0; |
|
1254 |
SetLittle(dX); |
|
1255 |
dY:= _0; |
|
1256 |
State:= State or gstMoving; |
|
1257 |
end; |
|
1258 |
DeleteGear(Gear); |
|
1259 |
exit |
|
1260 |
end; |
|
211 | 1261 |
|
351 | 1262 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1133 | 1263 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
211 | 1264 |
|
351 | 1265 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1266 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1267 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1268 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1269 |
|
351 | 1270 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1271 |
Gear^.X:= HHGear^.X; |
1272 |
Gear^.Y:= HHGear^.Y |
|
263 | 1273 |
end; |
211 | 1274 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1275 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1276 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1277 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1278 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1279 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1280 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1281 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1282 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1283 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1284 |
|
931 | 1285 |
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
|
1286 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1287 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1288 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1289 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1290 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1291 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1292 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1293 |
|
263 | 1294 |
//////////////////////////////////////////////////////////////////////////////// |
1295 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1507 | 1296 |
var i: Longint; |
263 | 1297 |
begin |
1298 |
AllInactive:= false; |
|
498 | 1299 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
1124 | 1300 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1301 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
1124 | 1302 |
begin |
1303 |
dec(Gear^.Health); |
|
1304 |
case Gear^.State of |
|
1305 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1306 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1586 | 1307 |
2: for i:= -19 to 19 do |
1308 |
FollowGear:= AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0); |
|
1124 | 1309 |
end; |
1310 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
|
1311 |
end; |
|
1312 |
||
1313 |
if (GameTicks and $3F) = 0 then |
|
1314 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1315 |
||
1753 | 1316 |
if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1317 |
end; |
1318 |
||
1319 |
procedure doStepAirAttack(Gear: PGear); |
|
1320 |
begin |
|
1321 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1322 |
|
1507 | 1323 |
if Gear^.X.QWordValue = 0 then |
1771 | 1324 |
begin |
1325 |
Gear^.Tag:= 1; |
|
1326 |
Gear^.X:= -_1024; |
|
1327 |
end |
|
1507 | 1328 |
else |
1771 | 1329 |
begin |
1507 | 1330 |
Gear^.Tag:= -1; |
1771 | 1331 |
Gear^.X:= int2hwFloat(LAND_WIDTH + 1024); |
1332 |
end; |
|
1507 | 1333 |
|
1784 | 1334 |
Gear^.Y:= int2hwFloat(topY-300); |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1335 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1336 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1337 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
1133 | 1338 |
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
|
1339 |
|
351 | 1340 |
Gear^.Health:= 6; |
801 | 1341 |
Gear^.doStep:= @doStepAirAttackWork; |
1669 | 1342 |
PlaySound(sndIncoming, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
263 | 1343 |
end; |
1344 |
||
1345 |
//////////////////////////////////////////////////////////////////////////////// |
|
1346 |
||
1347 |
procedure doStepAirBomb(Gear: PGear); |
|
1348 |
begin |
|
1349 |
AllInactive:= false; |
|
1350 |
doStepFallingGear(Gear); |
|
351 | 1351 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 1352 |
begin |
1353 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1354 |
DeleteGear(Gear); |
|
1355 |
exit |
|
1356 |
end; |
|
263 | 1357 |
if (GameTicks and $3F) = 0 then |
1133 | 1358 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1359 |
end; |
409 | 1360 |
|
1361 |
//////////////////////////////////////////////////////////////////////////////// |
|
1362 |
||
1363 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1364 |
var HHGear: PGear; |
1915 | 1365 |
x, y, tx, ty: hwFloat; |
409 | 1366 |
begin |
1367 |
AllInactive:= false; |
|
415 | 1368 |
|
1369 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1915 | 1370 |
tx:= int2hwFloat(TargetPoint.X); |
1371 |
ty:= int2hwFloat(TargetPoint.Y); |
|
1372 |
x:= HHGear^.X; |
|
1373 |
y:= HHGear^.Y; |
|
1909 | 1374 |
|
1915 | 1375 |
if (Distance(tx - x, ty - y) > _256) or |
1376 |
not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
|
1377 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1378 |
sprAmGirder, Gear^.State, true) then |
1133 | 1379 |
begin |
1914 | 1380 |
PlaySound(sndDenied, false, nil); |
1381 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1382 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1133 | 1383 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
1914 | 1384 |
isCursorVisible:= true; |
1385 |
DeleteGear(Gear) |
|
1133 | 1386 |
end |
1387 |
else begin |
|
1914 | 1388 |
PlaySound(sndPlaced, false, nil); |
1133 | 1389 |
DeleteGear(Gear); |
1909 | 1390 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1914 | 1391 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
1392 |
end; |
|
1393 |
||
1909 | 1394 |
HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked); |
1395 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
415 | 1396 |
TargetPoint.X:= NoPointX |
409 | 1397 |
end; |
520 | 1398 |
|
1399 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1400 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1401 |
var HHGear: PGear; |
1402 |
begin |
|
1403 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1404 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1405 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1406 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1407 |
or CheckGearDrowning(HHGear) then |
1408 |
begin |
|
1409 |
DeleteGear(Gear); |
|
1410 |
AfterAttack |
|
1411 |
end |
|
912 | 1412 |
end; |
1413 |
||
1414 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1415 |
begin |
853 | 1416 |
inc(Gear^.Timer); |
1417 |
if Gear^.Timer = 65 then |
|
1418 |
begin |
|
1419 |
Gear^.Timer:= 0; |
|
1420 |
inc(Gear^.Pos); |
|
1421 |
if Gear^.Pos = 11 then |
|
912 | 1422 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1423 |
end |
525 | 1424 |
end; |
520 | 1425 |
|
1426 |
procedure doStepTeleport(Gear: PGear); |
|
1427 |
var HHGear: PGear; |
|
1428 |
begin |
|
1429 |
AllInactive:= false; |
|
1430 |
||
1431 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1432 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1433 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1434 |
sprHHTelepMask, 0, false) then |
|
853 | 1435 |
begin |
1436 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1437 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1438 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1439 |
DeleteGear(Gear); |
|
1440 |
isCursorVisible:= true |
|
1441 |
end |
|
1442 |
else begin |
|
1443 |
DeleteCI(HHGear); |
|
1444 |
SetAllHHToActive; |
|
912 | 1445 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1446 |
Gear^.X:= HHGear^.X; |
1447 |
Gear^.Y:= HHGear^.Y; |
|
1448 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1449 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1450 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1451 |
end; |
|
520 | 1452 |
TargetPoint.X:= NoPointX |
1453 |
end; |
|
534 | 1454 |
|
1455 |
//////////////////////////////////////////////////////////////////////////////// |
|
1456 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1457 |
var HHGear: PGear; |
|
1458 |
Msg, State: Longword; |
|
1459 |
begin |
|
1460 |
AllInactive:= false; |
|
1461 |
||
540 | 1462 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1463 |
begin |
1464 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1465 |
Msg:= Gear^.Message and not gm_Switch; |
|
1466 |
DeleteGear(Gear); |
|
1467 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1468 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1469 |
|
1133 | 1470 |
HHGear:= CurrentHedgehog^.Gear; |
1471 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1472 |
HHGear^.Message:= Msg; |
|
1473 |
exit |
|
1474 |
end; |
|
534 | 1475 |
|
1476 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1477 |
begin |
1478 |
HHGear:= CurrentHedgehog^.Gear; |
|
1479 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1480 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1481 |
State:= HHGear^.State; |
|
1482 |
HHGear^.State:= 0; |
|
1483 |
HHGear^.Active:= false; |
|
1484 |
HHGear^.Z:= cHHZ; |
|
1485 |
RemoveGearFromList(HHGear); |
|
1486 |
InsertGearToList(HHGear); |
|
534 | 1487 |
|
1133 | 1488 |
repeat |
1489 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1490 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1491 |
|
1133 | 1492 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1493 |
|
1133 | 1494 |
HHGear:= CurrentHedgehog^.Gear; |
1495 |
HHGear^.State:= State; |
|
1496 |
HHGear^.Active:= true; |
|
1497 |
FollowGear:= HHGear; |
|
1498 |
HHGear^.Z:= cCurrHHZ; |
|
1499 |
RemoveGearFromList(HHGear); |
|
1500 |
InsertGearToList(HHGear); |
|
1501 |
Gear^.X:= HHGear^.X; |
|
1502 |
Gear^.Y:= HHGear^.Y |
|
1503 |
end; |
|
534 | 1504 |
end; |
1505 |
||
1506 |
procedure doStepSwitcher(Gear: PGear); |
|
1507 |
var HHGear: PGear; |
|
1508 |
begin |
|
1509 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1510 |
||
1511 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1512 |
with HHGear^ do |
|
1133 | 1513 |
begin |
1514 |
State:= State and not gstAttacking; |
|
1515 |
Message:= Message and not gm_Attack |
|
1516 |
end |
|
534 | 1517 |
end; |
924 | 1518 |
|
1519 |
//////////////////////////////////////////////////////////////////////////////// |
|
1520 |
procedure doStepMortar(Gear: PGear); |
|
1521 |
var dX, dY: hwFloat; |
|
1522 |
i: LongInt; |
|
963 | 1523 |
dxn, dyn: boolean; |
924 | 1524 |
begin |
1525 |
AllInactive:= false; |
|
963 | 1526 |
dxn:= Gear^.dX.isNegative; |
1527 |
dyn:= Gear^.dY.isNegative; |
|
1528 |
||
924 | 1529 |
doStepFallingGear(Gear); |
1530 |
if (Gear^.State and gstCollision) <> 0 then |
|
1531 |
begin |
|
1532 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1533 |
|
1534 |
Gear^.dX.isNegative:= not dxn; |
|
1535 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1536 |
for i:= 0 to 4 do |
1537 |
begin |
|
963 | 1538 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1539 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1540 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1541 |
end; |
1542 |
||
1543 |
DeleteGear(Gear); |
|
1544 |
exit |
|
1545 |
end; |
|
963 | 1546 |
|
924 | 1547 |
if (GameTicks and $3F) = 0 then |
1548 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1549 |
end; |
|
984 | 1550 |
|
1551 |
//////////////////////////////////////////////////////////////////////////////// |
|
1552 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1553 |
const upd: Longword = 0; |
|
987 | 1554 |
var i: LongWord; |
984 | 1555 |
HHGear: PGear; |
1556 |
begin |
|
1557 |
AllInactive:= false; |
|
1558 |
||
1559 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1560 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1561 |
DeleteCI(HHGear); |
|
1562 |
||
1563 |
i:= 2; |
|
1564 |
repeat |
|
1565 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1566 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1567 |
HHGear^.X:= Gear^.X; |
|
1568 |
HHGear^.Y:= Gear^.Y; |
|
1569 |
||
1570 |
inc(Gear^.Damage, 2); |
|
1571 |
||
1200 | 1572 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1573 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1574 |
|
1575 |
dec(i) |
|
1576 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1577 |
||
1578 |
inc(upd); |
|
1579 |
if upd > 3 then |
|
1580 |
begin |
|
987 | 1581 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1582 |
||
984 | 1583 |
AmmoShove(Gear, 30, 40); |
1584 |
||
1585 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1586 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1587 |
HHGear^.dX, |
1588 |
HHGear^.dY, |
|
1589 |
20 + cHHRadius * 2, |
|
1200 | 1590 |
cHHRadius * 2 + 6); |
984 | 1591 |
|
1592 |
upd:= 0 |
|
1593 |
end; |
|
1594 |
||
1595 |
if Gear^.Health < Gear^.Damage then |
|
1596 |
begin |
|
1597 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1598 |
AfterAttack; |
|
1599 |
DeleteGear(Gear); |
|
1600 |
DeleteGear(HHGear); |
|
1601 |
end else |
|
1602 |
begin |
|
1603 |
dec(Gear^.Health, Gear^.Damage); |
|
1604 |
Gear^.Damage:= 0 |
|
1605 |
end |
|
1606 |
end; |
|
1607 |
||
987 | 1608 |
procedure doStepKamikazeIdle(Gear: PGear); |
1609 |
begin |
|
1610 |
AllInactive:= false; |
|
1611 |
dec(Gear^.Timer); |
|
1612 |
if Gear^.Timer = 0 then |
|
1613 |
begin |
|
1614 |
Gear^.Pos:= 1; |
|
1669 | 1615 |
PlaySound(sndKamikaze, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
987 | 1616 |
Gear^.doStep:= @doStepKamikazeWork |
1617 |
end |
|
1618 |
end; |
|
1619 |
||
984 | 1620 |
procedure doStepKamikaze(Gear: PGear); |
1621 |
var HHGear: PGear; |
|
1622 |
begin |
|
1623 |
AllInactive:= false; |
|
1624 |
||
1625 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1626 |
||
1627 |
HHGear^.dX:= Gear^.dX; |
|
1628 |
HHGear^.dY:= Gear^.dY; |
|
1629 |
||
1630 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1631 |
Gear^.dY:= - _0_9; |
|
1632 |
||
987 | 1633 |
Gear^.Timer:= 550; |
1634 |
||
1635 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1636 |
end; |
1637 |
||
1103 | 1638 |
//////////////////////////////////////////////////////////////////////////////// |
1639 |
const cakeh = 27; |
|
1110 | 1640 |
cakeDmg = 75; |
1103 | 1641 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1642 |
CakeI: Longword; |
|
1643 |
||
1110 | 1644 |
procedure doStepCakeExpl(Gear: PGear); |
1645 |
begin |
|
1646 |
inc(Gear^.Tag); |
|
1647 |
if Gear^.Tag < 2250 then exit; |
|
1648 |
||
1649 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1650 |
AfterAttack; |
|
1651 |
DeleteGear(Gear) |
|
1652 |
end; |
|
1653 |
||
1109 | 1654 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1655 |
var gi: PGear; |
1656 |
dmg: LongInt; |
|
1109 | 1657 |
begin |
1658 |
AllInactive:= false; |
|
1659 |
||
1660 |
inc(Gear^.Tag); |
|
1661 |
if Gear^.Tag < 100 then exit; |
|
1662 |
Gear^.Tag:= 0; |
|
1663 |
||
1664 |
if Gear^.Pos = 0 then |
|
1665 |
begin |
|
1110 | 1666 |
gi:= GearsList; |
1667 |
while gi <> nil do |
|
1668 |
begin |
|
1669 |
dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y)); |
|
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1670 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1671 |
if (CurrentHedgehog^.Gear = gi) and (not gi^.Invulnerable) then |
1867 | 1672 |
gi^.State:= gi^.State or gstLoser |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1673 |
else |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1674 |
gi^.State:= gi^.State or gstWinner; |
1110 | 1675 |
gi:= gi^.NextGear |
1676 |
end; |
|
1677 |
Gear^.doStep:= @doStepCakeExpl; |
|
1669 | 1678 |
PlaySound(sndCake, false, nil) |
1109 | 1679 |
end else dec(Gear^.Pos) |
1680 |
end; |
|
1681 |
||
1682 |
||
1089 | 1683 |
procedure doStepCakeWork(Gear: PGear); |
1684 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1685 |
var xx, yy, xxn, yyn: LongInt; |
|
1686 |
da: LongInt; |
|
1103 | 1687 |
tdx, tdy: hwFloat; |
1089 | 1688 |
|
1689 |
procedure PrevAngle; |
|
1690 |
begin |
|
1133 | 1691 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1692 |
end; |
1693 |
||
1694 |
procedure NextAngle; |
|
1695 |
begin |
|
1133 | 1696 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1697 |
end; |
1698 |
||
1088 | 1699 |
begin |
1089 | 1700 |
inc(Gear^.Tag); |
1108 | 1701 |
if Gear^.Tag < 7 then exit; |
1089 | 1702 |
|
1703 |
dA:= hwSign(Gear^.dX); |
|
1704 |
xx:= dirs[Gear^.Angle].x; |
|
1705 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1706 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1707 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1708 |
|
1709 |
if (xx = 0) then |
|
1710 |
if TestCollisionYwithGear(Gear, yy) then |
|
1711 |
PrevAngle |
|
1712 |
else begin |
|
1713 |
Gear^.Tag:= 0; |
|
1714 |
Gear^.Y:= Gear^.Y + int2hwFloat(yy); |
|
1635
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1715 |
if not TestCollisionXwithGear(Gear, xxn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1716 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1717 |
Gear^.X:= Gear^.X + int2hwFloat(xxn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1718 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1719 |
end; |
1089 | 1720 |
end; |
1721 |
||
1722 |
if (yy = 0) then |
|
1723 |
if TestCollisionXwithGear(Gear, xx) then |
|
1724 |
PrevAngle |
|
1725 |
else begin |
|
1726 |
Gear^.Tag:= 0; |
|
1727 |
Gear^.X:= Gear^.X + int2hwFloat(xx); |
|
1635
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1728 |
if not TestCollisionYwithGear(Gear, yyn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1729 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1730 |
Gear^.Y:= Gear^.Y + int2hwFloat(yyn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1731 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1732 |
end; |
1089 | 1733 |
end; |
1734 |
||
1103 | 1735 |
if Gear^.Tag = 0 then |
1736 |
begin |
|
1737 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1738 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1739 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1740 |
CakePoints[CakeI].x:= Gear^.X; |
|
1741 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1742 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1743 |
end; |
|
1744 |
||
1089 | 1745 |
dec(Gear^.Health); |
1090 | 1746 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1747 |
begin |
1109 | 1748 |
FollowGear:= Gear; |
1749 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1750 |
end |
1088 | 1751 |
end; |
1089 | 1752 |
|
1103 | 1753 |
procedure doStepCakeUp(Gear: PGear); |
1754 |
var i: Longword; |
|
1755 |
begin |
|
1756 |
AllInactive:= false; |
|
1757 |
||
1108 | 1758 |
inc(Gear^.Tag); |
1109 | 1759 |
if Gear^.Tag < 100 then exit; |
1108 | 1760 |
Gear^.Tag:= 0; |
1761 |
||
1109 | 1762 |
if Gear^.Pos = 6 then |
1103 | 1763 |
begin |
1764 |
for i:= 0 to Pred(cakeh) do |
|
1765 |
begin |
|
1766 |
CakePoints[i].x:= Gear^.X; |
|
1767 |
CakePoints[i].y:= Gear^.Y |
|
1768 |
end; |
|
1769 |
CakeI:= 0; |
|
1770 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1771 |
end else inc(Gear^.Pos) |
1103 | 1772 |
end; |
1773 |
||
1089 | 1774 |
procedure doStepCakeFall(Gear: PGear); |
1775 |
begin |
|
1776 |
AllInactive:= false; |
|
1777 |
||
1778 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1779 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1780 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1781 |
else |
1782 |
begin |
|
1783 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1784 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1785 |
end |
|
1786 |
end; |
|
1787 |
||
1788 |
procedure doStepCake(Gear: PGear); |
|
1789 |
var HHGear: PGear; |
|
1790 |
begin |
|
1791 |
AllInactive:= false; |
|
1792 |
||
1793 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1794 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1795 |
DeleteCI(HHGear); |
1796 |
||
1106 | 1797 |
FollowGear:= Gear; |
1798 |
||
1089 | 1799 |
Gear^.doStep:= @doStepCakeFall |
1800 |
end; |
|
1801 |
||
1259 | 1802 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1803 |
procedure doStepSeductionWork(Gear: PGear); |
1804 |
var x, y: LongInt; |
|
1259 | 1805 |
begin |
1806 |
AllInactive:= false; |
|
1284 | 1807 |
|
1808 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1809 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1810 |
x:= hwRound(Gear^.X); |
|
1811 |
y:= hwRound(Gear^.Y); |
|
1259 | 1812 |
|
1753 | 1813 |
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then |
1284 | 1814 |
if (Land[y, x] <> 0) then |
1815 |
begin |
|
1816 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1817 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1818 |
Gear^.dX:= Gear^.dX * _1_5; |
1819 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1820 |
AmmoShove(Gear, 0, 40); |
1286 | 1821 |
AfterAttack; |
1284 | 1822 |
DeleteGear(Gear) |
1823 |
end |
|
1824 |
else |
|
1825 |
else |
|
1286 | 1826 |
begin |
1827 |
AfterAttack; |
|
1284 | 1828 |
DeleteGear(Gear) |
1286 | 1829 |
end |
1830 |
end; |
|
1831 |
||
1832 |
procedure doStepSeductionWear(Gear: PGear); |
|
1833 |
begin |
|
1834 |
AllInactive:= false; |
|
1835 |
inc(Gear^.Timer); |
|
1836 |
if Gear^.Timer > 250 then |
|
1837 |
begin |
|
1838 |
Gear^.Timer:= 0; |
|
1388 | 1839 |
inc(Gear^.Pos); |
1840 |
if Gear^.Pos = 5 then |
|
1669 | 1841 |
PlaySound(sndYoohoo, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1286 | 1842 |
end; |
1367 | 1843 |
|
1844 |
if Gear^.Pos = 14 then |
|
1286 | 1845 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1846 |
end; |
1284 | 1847 |
|
1848 |
procedure doStepSeduction(Gear: PGear); |
|
1849 |
begin |
|
1850 |
AllInactive:= false; |
|
1851 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1852 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1853 |
end; |
1298 | 1854 |
|
1855 |
//////////////////////////////////////////////////////////////////////////////// |
|
1856 |
procedure doStepWaterUp(Gear: PGear); |
|
1857 |
var i: LongWord; |
|
1858 |
begin |
|
1859 |
AllInactive:= false; |
|
1860 |
||
1861 |
inc(Gear^.Timer); |
|
1862 |
if Gear^.Timer = 17 then |
|
1863 |
Gear^.Timer:= 0 |
|
1864 |
else |
|
1865 |
exit; |
|
1866 |
||
1867 |
if cWaterLine > 0 then |
|
1868 |
begin |
|
1869 |
dec(cWaterLine); |
|
1760 | 1870 |
for i:= 0 to LAND_WIDTH - 1 do |
1298 | 1871 |
Land[cWaterLine, i]:= 0; |
1872 |
SetAllToActive |
|
1873 |
end; |
|
1874 |
||
1875 |
inc(Gear^.Tag); |
|
1343 | 1876 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1877 |
DeleteGear(Gear) |
1878 |
end; |
|
1573 | 1879 |
|
1880 |
//////////////////////////////////////////////////////////////////////////////// |
|
1590 | 1881 |
procedure doStepDrillDrilling(Gear: PGear); |
1633 | 1882 |
var t: PGearArray; |
1883 |
ox, oy: hwFloat; |
|
1573 | 1884 |
begin |
1590 | 1885 |
AllInactive:= false; |
1886 |
||
1633 | 1887 |
if (Gear^.Timer > 0) and ((Gear^.Timer mod 10) = 0) then |
1590 | 1888 |
begin |
1573 | 1889 |
ox:= Gear^.X; |
1890 |
oy:= Gear^.Y; |
|
1891 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1892 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1893 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); |
|
1894 |
CheckGearDrowning(Gear); |
|
1590 | 1895 |
end; |
1896 |
||
1633 | 1897 |
t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug |
1590 | 1898 |
if (Gear^.Timer = 0) |
1633 | 1899 |
or (t^.Count <> 0) |
1590 | 1900 |
or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) |
1784 | 1901 |
and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) |
1902 |
or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] = COLOR_INDESTRUCTIBLE) then |
|
1590 | 1903 |
begin //out of time or exited ground |
1904 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1905 |
DeleteGear(Gear); |
|
1906 |
exit |
|
1907 |
end; |
|
1908 |
||
1909 |
dec(Gear^.Timer); |
|
1573 | 1910 |
end; |
1911 |
||
1912 |
procedure doStepDrill(Gear: PGear); |
|
1590 | 1913 |
var t: PGearArray; |
1633 | 1914 |
oldDx, oldDy: hwFloat; |
1915 |
t2: hwFloat; |
|
1573 | 1916 |
begin |
1590 | 1917 |
AllInactive:= false; |
1573 | 1918 |
|
1590 | 1919 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1920 |
oldDx:= Gear^.dX; |
|
1921 |
oldDy:= Gear^.dY; |
|
1922 |
||
1923 |
doStepFallingGear(Gear); |
|
1924 |
||
1925 |
if (GameTicks and $3F) = 0 then |
|
1926 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1573 | 1927 |
|
1633 | 1928 |
if ((Gear^.State and gstCollision) <> 0) then begin //hit |
1590 | 1929 |
Gear^.dX:= oldDx; |
1930 |
Gear^.dY:= oldDy; |
|
1633 | 1931 |
|
1590 | 1932 |
t:= CheckGearsCollision(Gear); |
1633 | 1933 |
if (t^.Count = 0) then begin //hit the ground not the HH |
1934 |
t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); |
|
1935 |
Gear^.dX:= Gear^.dX * t2; |
|
1936 |
Gear^.dY:= Gear^.dY * t2; |
|
1937 |
end else begin //explode right on contact with HH |
|
1938 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1939 |
DeleteGear(Gear); |
|
1940 |
exit; |
|
1941 |
end; |
|
1942 |
||
1590 | 1943 |
Gear^.doStep:= @doStepDrillDrilling; |
1633 | 1944 |
dec(Gear^.Timer) |
1590 | 1945 |
end |
1946 |
end; |
|
1601 | 1947 |
|
1633 | 1948 |
//////////////////////////////////////////////////////////////////////////////// |
1601 | 1949 |
procedure doStepBallgunWork(Gear: PGear); |
1950 |
var HHGear: PGear; |
|
1630 | 1951 |
rx, ry: hwFloat; |
1601 | 1952 |
begin |
1953 |
AllInactive:= false; |
|
1954 |
dec(Gear^.Timer); |
|
1955 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1956 |
HedgehogChAngle(HHGear); |
|
1957 |
if (Gear^.Timer mod 100) = 0 then |
|
1958 |
begin |
|
1630 | 1959 |
rx:= rndSign(getRandom * _0_1); |
1960 |
ry:= rndSign(getRandom * _0_1); |
|
1631
6e313b3818ef
Remove debug stuff, ballgun 64but incompatibility fixed in previous revision
unc0rr
parents:
1630
diff
changeset
|
1961 |
|
1630 | 1962 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0, |
1963 |
SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, |
|
1964 |
AngleCos(HHGear^.Angle) * ( - _0_8) + ry, |
|
1965 |
0); |
|
1601 | 1966 |
|
1669 | 1967 |
PlaySound(sndGun, false, nil); |
1601 | 1968 |
end; |
1969 |
||
1643 | 1970 |
if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then |
1601 | 1971 |
begin |
1972 |
DeleteGear(Gear); |
|
1643 | 1973 |
AfterAttack |
1974 |
end |
|
1601 | 1975 |
end; |
1976 |
||
1977 |
procedure doStepBallgun(Gear: PGear); |
|
1978 |
var HHGear: PGear; |
|
1979 |
begin |
|
1980 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1981 |
HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Down); |
|
1982 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
1983 |
Gear^.doStep:= @doStepBallgunWork |
|
1633 | 1984 |
end; |
1689 | 1985 |
|
1696 | 1986 |
//////////////////////////////////////////////////////////////////////////////// |
1689 | 1987 |
procedure doStepRCPlaneWork(Gear: PGear); |
1988 |
const cAngleSpeed = 3; |
|
1989 |
var HHGear: PGear; |
|
1990 |
i: LongInt; |
|
1991 |
dX, dY: hwFloat; |
|
1992 |
fChanged: boolean; |
|
1993 |
trueAngle: Longword; |
|
1994 |
t: PGear; |
|
1995 |
begin |
|
1996 |
AllInactive:= false; |
|
1997 |
||
1696 | 1998 |
if Gear^.Timer > 0 then dec(Gear^.Timer); |
1689 | 1999 |
|
2000 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2001 |
FollowGear:= Gear; |
|
2002 |
||
2003 |
fChanged:= false; |
|
1696 | 2004 |
if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then |
1689 | 2005 |
begin |
2006 |
fChanged:= true; |
|
1696 | 2007 |
if Gear^.Angle > 2048 then dec(Gear^.Angle) else |
2008 |
if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false |
|
2009 |
end |
|
2010 |
else |
|
2011 |
begin |
|
2012 |
if ((Gear^.Message and gm_Left) <> 0) then |
|
2013 |
begin |
|
2014 |
fChanged:= true; |
|
2015 |
Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 |
|
2016 |
end; |
|
1689 | 2017 |
|
1696 | 2018 |
if ((Gear^.Message and gm_Right) <> 0) then |
2019 |
begin |
|
2020 |
fChanged:= true; |
|
2021 |
Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096 |
|
2022 |
end |
|
1689 | 2023 |
end; |
2024 |
||
2025 |
if fChanged then |
|
2026 |
begin |
|
2027 |
Gear^.dX.isNegative:= (Gear^.Angle > 2048); |
|
2028 |
if Gear^.dX.isNegative then |
|
2029 |
trueAngle:= 4096 - Gear^.Angle |
|
2030 |
else |
|
2031 |
trueAngle:= Gear^.Angle; |
|
2032 |
||
2033 |
Gear^.dX:= SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; |
|
2034 |
Gear^.dY:= AngleCos(trueAngle) * -_0_25; |
|
2035 |
end; |
|
2036 |
||
2037 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
2038 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
2039 |
||
2040 |
if (GameTicks and $FF) = 0 then |
|
1698 | 2041 |
if Gear^.Timer < 3500 then |
1696 | 2042 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0) |
2043 |
else |
|
2044 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1689 | 2045 |
|
1696 | 2046 |
if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then |
1689 | 2047 |
begin |
2048 |
HHGear^.Message := HHGear^.Message and not gm_Attack; |
|
1708 | 2049 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); |
1689 | 2050 |
dec(Gear^.Health) |
1712 | 2051 |
end; |
2052 |
||
2053 |
if ((HHGear^.Message and gm_LJump) <> 0) |
|
2054 |
and ((Gear^.State and gsttmpFlag) = 0) then |
|
2055 |
begin |
|
2056 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
2057 |
PauseMusic; |
|
2058 |
playSound(sndRideOfTheValkyries, false, nil); |
|
2059 |
end; |
|
1689 | 2060 |
|
2061 |
// pickup bonuses |
|
2062 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
2063 |
if t <> nil then |
|
2064 |
PickUp(HHGear, t); |
|
2065 |
||
2066 |
CheckCollision(Gear); |
|
2067 |
||
1712 | 2068 |
if ((Gear^.State and gstCollision) <> 0) |
2069 |
or CheckGearDrowning(Gear) then |
|
1689 | 2070 |
begin |
1712 | 2071 |
StopSound(sndRCPlane); |
2072 |
StopSound(sndRideOfTheValkyries); |
|
2073 |
ResumeMusic; |
|
2074 |
||
2075 |
if ((Gear^.State and gstCollision) <> 0) then |
|
1689 | 2076 |
begin |
1712 | 2077 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); |
1714 | 2078 |
for i:= 0 to 32 do |
1712 | 2079 |
begin |
1714 | 2080 |
dX:= AngleCos(i * 64) * _0_5 * (GetRandom + _1); |
2081 |
dY:= AngleSin(i * 64) * _0_5 * (GetRandom + _1); |
|
1712 | 2082 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); |
2083 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); |
|
2084 |
end; |
|
2085 |
DeleteGear(Gear) |
|
1689 | 2086 |
end; |
1713 | 2087 |
|
1689 | 2088 |
AfterAttack; |
1713 | 2089 |
CurAmmoGear:= nil; |
1697 | 2090 |
TurnTimeLeft:= 14 * 125; |
1712 | 2091 |
HHGear^.Message:= 0; |
1697 | 2092 |
ParseCommand('/taunt '#1, true) |
2093 |
end |
|
1689 | 2094 |
end; |
2095 |
||
2096 |
procedure doStepRCPlane(Gear: PGear); |
|
2097 |
var HHGear: PGear; |
|
2098 |
begin |
|
2099 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2100 |
HHGear^.Message:= 0; |
|
2101 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2102 |
Gear^.Angle:= HHGear^.Angle; |
|
1696 | 2103 |
Gear^.Tag:= hwSign(HHGear^.dX); |
1689 | 2104 |
if HHGear^.dX.isNegative then Gear^.Angle:= 4096 - Gear^.Angle; |
2105 |
Gear^.doStep:= @doStepRCPlaneWork |
|
1712 | 2106 |
end; |