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