author | nemo |
Sun, 03 May 2009 17:35:10 +0000 | |
changeset 2023 | 41d3afaa20c7 |
parent 2017 | 7845c77c8d31 |
child 2024 | 2985f3bd18b7 |
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 |
//////////////////////////////////////////////////////////////////////////////// |
|
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
454 |
procedure doStepBulletWork(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); |
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
470 |
if Gear^.Damage > 5 then |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
471 |
if Gear^.Ammo^.AmmoType = amDEagle then |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
472 |
AmmoShove(Gear, 7, 20) |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
473 |
else |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
474 |
AmmoShove(Gear, Gear^.Timer*2, 20); |
38 | 475 |
dec(i) |
351 | 476 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
477 |
if Gear^.Damage > 0 then |
|
37 | 478 |
begin |
351 | 479 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 82 - i, 1); |
480 |
dec(Gear^.Health, Gear^.Damage); |
|
481 |
Gear^.Damage:= 0 |
|
37 | 482 |
end; |
1760 | 483 |
|
484 |
if (Gear^.Health <= 0) |
|
485 |
or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0) |
|
486 |
or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then |
|
876 | 487 |
Gear^.doStep:= @doStepShotIdle |
37 | 488 |
end; |
489 |
||
559 | 490 |
procedure doStepDEagleShot(Gear: PGear); |
491 |
begin |
|
1669 | 492 |
PlaySound(sndGun, false, nil); |
2023
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
493 |
Gear^.doStep:= @doStepBulletWork |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
494 |
end; |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
495 |
|
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
496 |
procedure doStepSniperRifleShot(Gear: PGear); |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
497 |
begin |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
498 |
if not cLaserSighting then // game doesn't have default laser sight. turn it on and give them a chance to aim |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
499 |
begin |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
500 |
cLaserSighting:= true; |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
501 |
cArtillery:= true; |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
502 |
DeleteGear(Gear); |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
503 |
AfterAttack; |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
504 |
dec(CurrentHedgehog^.AttacksNum); |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
505 |
exit |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
506 |
end; |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
507 |
|
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
508 |
if (PHedgehog(Gear^.Hedgehog)^.Gear^.Message and gm_Attack) <> 0 then |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
509 |
begin |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
510 |
Gear^.State:= Gear^.State or gstAnimation; |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
511 |
PlaySound(sndGun, false, nil); |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
512 |
Gear^.doStep:= @doStepBulletWork |
41d3afaa20c7
Artillery mode, sniper rifle, speech bubble tweaks, fix of rope bug introduced by enabling hats in jump
nemo
parents:
2017
diff
changeset
|
513 |
end |
559 | 514 |
end; |
515 |
||
37 | 516 |
//////////////////////////////////////////////////////////////////////////////// |
4 | 517 |
procedure doStepActionTimer(Gear: PGear); |
518 |
begin |
|
351 | 519 |
dec(Gear^.Timer); |
520 |
case Gear^.Kind of |
|
83 | 521 |
gtATStartGame: begin |
4 | 522 |
AllInactive:= false; |
351 | 523 |
if Gear^.Timer = 0 then |
83 | 524 |
AddCaption(trmsg[sidStartFight], $FFFFFF, capgrpGameState); |
4 | 525 |
end; |
83 | 526 |
gtATSmoothWindCh: begin |
351 | 527 |
if Gear^.Timer = 0 then |
6 | 528 |
begin |
351 | 529 |
if WindBarWidth < Gear^.Tag then inc(WindBarWidth) |
530 |
else if WindBarWidth > Gear^.Tag then dec(WindBarWidth); |
|
531 |
if WindBarWidth <> Gear^.Tag then Gear^.Timer:= 10; |
|
83 | 532 |
end |
533 |
end; |
|
534 |
gtATFinishGame: begin |
|
535 |
AllInactive:= false; |
|
351 | 536 |
if Gear^.Timer = 0 then |
113 | 537 |
begin |
538 |
SendIPC('N'); |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
306
diff
changeset
|
539 |
SendIPC('q'); |
83 | 540 |
GameState:= gsExit |
113 | 541 |
end |
6 | 542 |
end; |
4 | 543 |
end; |
351 | 544 |
if Gear^.Timer = 0 then DeleteGear(Gear) |
4 | 545 |
end; |
546 |
||
547 |
//////////////////////////////////////////////////////////////////////////////// |
|
548 |
procedure doStepPickHammerWork(Gear: PGear); |
|
371 | 549 |
var i, ei: LongInt; |
4 | 550 |
HHGear: PGear; |
551 |
begin |
|
70 | 552 |
AllInactive:= false; |
351 | 553 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
554 |
dec(Gear^.Timer); |
|
555 |
if (Gear^.Timer = 0)or((Gear^.Message and gm_Destroy) <> 0)or((HHGear^.State and gstHHDriven) = 0) then |
|
1200 | 556 |
begin |
557 |
StopSound(sndPickhammer); |
|
558 |
DeleteGear(Gear); |
|
559 |
AfterAttack; |
|
560 |
exit |
|
561 |
end; |
|
845 | 562 |
|
422 | 563 |
if (Gear^.Timer mod 33) = 0 then |
1200 | 564 |
begin |
565 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
566 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y) + 7, 6, EXPLDontDraw); |
|
567 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
568 |
end; |
|
422 | 569 |
|
570 |
if (Gear^.Timer mod 47) = 0 then |
|
1200 | 571 |
begin |
572 |
i:= hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
|
573 |
ei:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
574 |
while i <= ei do |
|
575 |
begin |
|
576 |
DrawExplosion(i, hwRound(Gear^.Y) + 3, 3); |
|
577 |
inc(i, 1) |
|
578 |
end; |
|
579 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
580 |
Gear^.Y:= Gear^.Y + _1_9; |
|
581 |
SetAllHHToActive; |
|
582 |
end; |
|
4 | 583 |
if TestCollisionYwithGear(Gear, 1) then |
1200 | 584 |
begin |
585 |
Gear^.dY:= _0; |
|
586 |
SetLittle(HHGear^.dX); |
|
587 |
HHGear^.dY:= _0; |
|
588 |
end else |
|
589 |
begin |
|
590 |
Gear^.dY:= Gear^.dY + cGravity; |
|
591 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1417 | 592 |
if hwRound(Gear^.Y) > cWaterLine then Gear^.Timer:= 1 |
1200 | 593 |
end; |
4 | 594 |
|
351 | 595 |
Gear^.X:= Gear^.X + HHGear^.dX; |
596 |
HHGear^.X:= Gear^.X; |
|
498 | 597 |
HHGear^.Y:= Gear^.Y - int2hwFloat(cHHRadius); |
4 | 598 |
|
351 | 599 |
if (Gear^.Message and gm_Attack) <> 0 then |
600 |
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else |
|
601 |
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
602 |
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else |
|
603 |
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3 |
|
498 | 604 |
else Gear^.dX:= _0; |
4 | 605 |
end; |
606 |
||
607 |
procedure doStepPickHammer(Gear: PGear); |
|
371 | 608 |
var i, y: LongInt; |
4 | 609 |
ar: TRangeArray; |
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
610 |
HHGear: PGear; |
4 | 611 |
begin |
612 |
i:= 0; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
613 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
614 |
|
498 | 615 |
y:= hwRound(Gear^.Y) - cHHRadius * 2; |
351 | 616 |
while y < hwRound(Gear^.Y) do |
4 | 617 |
begin |
371 | 618 |
ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2)); |
619 |
ar[i].Right:= hwRound(Gear^.X) + Gear^.Radius + LongInt(GetRandom(2)); |
|
4 | 620 |
inc(y, 2); |
621 |
inc(i) |
|
622 |
end; |
|
911
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
623 |
|
498 | 624 |
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
|
625 |
Gear^.dY:= HHGear^.dY; |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
626 |
DeleteCI(HHGear); |
b709fe13ed69
Fix issue with hedgehog on top of the hedgehog with pickhammer
unc0rr
parents:
883
diff
changeset
|
627 |
|
1669 | 628 |
PlaySound(sndPickhammer, true, nil); |
4 | 629 |
doStepPickHammerWork(Gear); |
351 | 630 |
Gear^.doStep:= @doStepPickHammerWork |
4 | 631 |
end; |
632 |
||
633 |
//////////////////////////////////////////////////////////////////////////////// |
|
371 | 634 |
var BTPrevAngle, BTSteps: LongInt; |
302 | 635 |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
636 |
procedure doStepBlowTorchWork(Gear: PGear); |
302 | 637 |
var HHGear: PGear; |
1528 | 638 |
b: boolean; |
639 |
prevX: LongInt; |
|
302 | 640 |
begin |
641 |
AllInactive:= false; |
|
351 | 642 |
dec(Gear^.Timer); |
643 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
644 |
|
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
645 |
HedgehogChAngle(HHGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
646 |
|
305 | 647 |
b:= false; |
648 |
||
371 | 649 |
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then |
1528 | 650 |
begin |
651 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX); |
|
652 |
Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5); |
|
653 |
BTPrevAngle:= HHGear^.Angle; |
|
654 |
b:= true |
|
655 |
end; |
|
656 |
||
657 |
if ((HHGear^.State and gstMoving) <> 0) then |
|
658 |
begin |
|
659 |
doStepHedgehogMoving(HHGear); |
|
1736 | 660 |
if (HHGear^.State and gstHHDriven) = 0 then Gear^.Timer:= 0 |
1528 | 661 |
end; |
305 | 662 |
|
351 | 663 |
if Gear^.Timer mod cHHStepTicks = 0 then |
1528 | 664 |
begin |
665 |
b:= true; |
|
666 |
if Gear^.dX.isNegative then |
|
1547 | 667 |
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Left |
1528 | 668 |
else |
1547 | 669 |
HHGear^.Message:= (HHGear^.Message and (gm_Attack or gm_Up or gm_Down)) or gm_Right; |
305 | 670 |
|
1528 | 671 |
if ((HHGear^.State and gstMoving) = 0) then |
672 |
begin |
|
673 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
674 |
prevX:= hwRound(HHGear^.X); |
|
675 |
||
676 |
HedgehogStep(HHGear); |
|
677 |
||
678 |
if (prevX = hwRound(HHGear^.X)) then HHGear^.X:= HHGear^.X + SignAs(_1, HHGear^.dX); |
|
679 |
HHGear^.State:= HHGear^.State or gstAttacking |
|
680 |
end; |
|
305 | 681 |
|
1528 | 682 |
inc(BTSteps); |
683 |
if BTSteps = 7 then |
|
684 |
begin |
|
685 |
BTSteps:= 0; |
|
686 |
Gear^.X:= HHGear^.X + Gear^.dX * (cHHRadius + cBlowTorchC); |
|
687 |
Gear^.Y:= HHGear^.Y + Gear^.dY * (cHHRadius + cBlowTorchC); |
|
688 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1643 | 689 |
AmmoShove(Gear, 2, 15); |
1528 | 690 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
691 |
end; |
|
692 |
end; |
|
305 | 693 |
|
694 |
if b then |
|
498 | 695 |
DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7, |
351 | 696 |
Gear^.dX, Gear^.dY, |
1501 | 697 |
cHHRadius * 5, cHHRadius * 2 + 7); |
305 | 698 |
|
1784 | 699 |
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 | 700 |
begin |
701 |
HHGear^.Message:= 0; |
|
702 |
HHGear^.State:= HHGear^.State and (not gstNotKickable); |
|
703 |
DeleteGear(Gear); |
|
704 |
AfterAttack |
|
705 |
end |
|
302 | 706 |
end; |
707 |
||
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
708 |
procedure doStepBlowTorch(Gear: PGear); |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
709 |
var HHGear: PGear; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
710 |
begin |
371 | 711 |
BTPrevAngle:= High(LongInt); |
305 | 712 |
BTSteps:= 0; |
351 | 713 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
714 |
HHGear^.Message:= 0; |
|
1528 | 715 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
351 | 716 |
Gear^.doStep:= @doStepBlowTorchWork |
303
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
717 |
end; |
1659c4aad5ab
Now blow torch angle can be changed during blowing :)
unc0rr
parents:
302
diff
changeset
|
718 |
|
302 | 719 |
//////////////////////////////////////////////////////////////////////////////// |
720 |
||
1781 | 721 |
procedure doStepRope(Gear: PGear); forward; |
722 |
||
723 |
procedure doStepRopeAfterAttack(Gear: PGear); |
|
724 |
var HHGear: PGear; |
|
725 |
begin |
|
726 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
727 |
if ((HHGear^.State and gstHHDriven) = 0) |
|
728 |
or (CheckGearDrowning(HHGear)) |
|
729 |
or TestCollisionYwithGear(HHGear, 1) then |
|
730 |
begin |
|
731 |
DeleteGear(Gear); |
|
732 |
exit |
|
733 |
end; |
|
734 |
||
1785 | 735 |
HedgehogChAngle(HHGear); |
736 |
||
1781 | 737 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
738 |
if HHGear^.dY.isNegative and TestCollisionYwithGear(HHGear, -1) then HHGear^.dY:= _0; |
|
739 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
740 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
741 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
742 |
||
743 |
if (Gear^.Message and gm_Attack) <> 0 then |
|
744 |
begin |
|
745 |
Gear^.X:= HHGear^.X; |
|
746 |
Gear^.Y:= HHGear^.Y; |
|
1964 | 747 |
|
748 |
ApplyAngleBounds(PHedgehog(Gear^.Hedgehog)^, amRope); |
|
749 |
||
1781 | 750 |
Gear^.dX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX); |
751 |
Gear^.dY:= -AngleCos(HHGear^.Angle); |
|
752 |
Gear^.Friction:= _450; |
|
753 |
Gear^.Elasticity:= _0; |
|
754 |
Gear^.State:= Gear^.State and not gsttmpflag; |
|
755 |
Gear^.doStep:= @doStepRope |
|
756 |
end |
|
757 |
end; |
|
758 |
||
4 | 759 |
procedure doStepRopeWork(Gear: PGear); |
760 |
var HHGear: PGear; |
|
1669 | 761 |
len, tx, ty, nx, ny, ropeDx, ropeDy, mdX, mdY: hwFloat; |
1504 | 762 |
lx, ly: LongInt; |
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
763 |
haveCollision, |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
764 |
haveDivided: boolean; |
4 | 765 |
|
1504 | 766 |
procedure DeleteMe; |
767 |
begin |
|
768 |
with HHGear^ do |
|
769 |
begin |
|
770 |
Message:= Message and not gm_Attack; |
|
771 |
State:= State or gstMoving; |
|
1892 | 772 |
State:= State and not gstWinner; |
1504 | 773 |
end; |
774 |
DeleteGear(Gear) |
|
775 |
end; |
|
4 | 776 |
|
1781 | 777 |
procedure WaitCollision; |
778 |
begin |
|
779 |
with HHGear^ do |
|
780 |
begin |
|
781 |
Message:= Message and not gm_Attack; |
|
782 |
State:= State or gstMoving; |
|
783 |
end; |
|
784 |
RopePoints.Count:= 0; |
|
785 |
Gear^.Elasticity:= _0; |
|
786 |
Gear^.doStep:= @doStepRopeAfterAttack |
|
787 |
end; |
|
788 |
||
4 | 789 |
begin |
351 | 790 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
108 | 791 |
|
351 | 792 |
if ((HHGear^.State and gstHHDriven) = 0) |
1504 | 793 |
or (CheckGearDrowning(HHGear)) then |
794 |
begin |
|
795 |
DeleteMe; |
|
796 |
exit |
|
797 |
end; |
|
928
b9064b48b001
Some preparation work for attacking from rope, parachute and etc.
unc0rr
parents:
925
diff
changeset
|
798 |
|
351 | 799 |
if (Gear^.Message and gm_Left <> 0) then HHGear^.dX:= HHGear^.dX - _0_0002 else |
800 |
if (Gear^.Message and gm_Right <> 0) then HHGear^.dX:= HHGear^.dX + _0_0002; |
|
4 | 801 |
|
351 | 802 |
if not TestCollisionYwithGear(HHGear, 1) then HHGear^.dY:= HHGear^.dY + cGravity; |
4 | 803 |
|
1652 | 804 |
ropeDx:= HHGear^.X - Gear^.X; // vector between hedgehog and rope attaching point |
805 |
ropeDy:= HHGear^.Y - Gear^.Y; |
|
806 |
||
807 |
mdX:= ropeDx + HHGear^.dX; |
|
808 |
mdY:= ropeDy + HHGear^.dY; |
|
809 |
len:= _1 / Distance(mdX, mdY); |
|
810 |
mdX:= mdX * len; // rope vector plus hedgehog direction vector normalized |
|
811 |
mdY:= mdY * len; |
|
812 |
||
813 |
Gear^.dX:= mdX; // for visual purposes only |
|
814 |
Gear^.dY:= mdY; |
|
815 |
||
816 |
///// |
|
817 |
tx:= HHGear^.X; |
|
818 |
ty:= HHGear^.Y; |
|
4 | 819 |
|
1652 | 820 |
if ((Gear^.Message and gm_Down) <> 0) and (Gear^.Elasticity < Gear^.Friction) then |
821 |
if not (TestCollisionXwithGear(HHGear, hwSign(ropeDx)) |
|
822 |
or TestCollisionYwithGear(HHGear, hwSign(ropeDy))) then |
|
823 |
Gear^.Elasticity:= Gear^.Elasticity + _0_3; |
|
824 |
||
825 |
if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then |
|
826 |
if not (TestCollisionXwithGear(HHGear, -hwSign(ropeDx)) |
|
827 |
or TestCollisionYwithGear(HHGear, -hwSign(ropeDy))) then |
|
828 |
Gear^.Elasticity:= Gear^.Elasticity - _0_3; |
|
829 |
||
830 |
HHGear^.X:= Gear^.X + mdX * Gear^.Elasticity; |
|
831 |
HHGear^.Y:= Gear^.Y + mdY * Gear^.Elasticity; |
|
832 |
||
833 |
HHGear^.dX:= HHGear^.X - tx; |
|
834 |
HHGear^.dY:= HHGear^.Y - ty; |
|
835 |
//// |
|
836 |
||
1554 | 837 |
|
1922 | 838 |
haveDivided:= false; |
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
839 |
// check whether rope needs dividing |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
840 |
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
|
841 |
nx:= ropeDx * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
842 |
ny:= ropeDy * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
843 |
|
1652 | 844 |
len:= Gear^.Elasticity - _0_3x70; |
845 |
while len > _0_3 do |
|
1504 | 846 |
begin |
1652 | 847 |
lx:= hwRound(Gear^.X + mdX * len); |
848 |
ly:= hwRound(Gear^.Y + mdY * len); |
|
1753 | 849 |
if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0) then |
1504 | 850 |
begin |
851 |
with RopePoints.ar[RopePoints.Count] do |
|
852 |
begin |
|
853 |
X:= Gear^.X; |
|
854 |
Y:= Gear^.Y; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
855 |
if RopePoints.Count = 0 then RopePoints.HookAngle:= DxDy2Angle(Gear^.dY, Gear^.dX); |
1652 | 856 |
b:= (nx * HHGear^.dY) > (ny * HHGear^.dX); |
1504 | 857 |
dLen:= len |
858 |
end; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
859 |
Gear^.X:= Gear^.X + nx * len; |
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
860 |
Gear^.Y:= Gear^.Y + ny * len; |
1504 | 861 |
inc(RopePoints.Count); |
862 |
TryDo(RopePoints.Count <= MAXROPEPOINTS, 'Rope points overflow', true); |
|
863 |
Gear^.Elasticity:= Gear^.Elasticity - len; |
|
864 |
Gear^.Friction:= Gear^.Friction - len; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
865 |
haveDivided:= true; |
1504 | 866 |
break |
867 |
end; |
|
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
868 |
len:= len - _0_3 // should be the same as increase step |
1504 | 869 |
end; |
1553
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
870 |
|
77f326c7f0ef
The best final fix for rope stucking in the ground bug
unc0rr
parents:
1552
diff
changeset
|
871 |
if not haveDivided then |
1504 | 872 |
if RopePoints.Count > 0 then // check whether the last dividing point could be removed |
873 |
begin |
|
874 |
tx:= RopePoints.ar[Pred(RopePoints.Count)].X; |
|
875 |
ty:= RopePoints.ar[Pred(RopePoints.Count)].Y; |
|
876 |
if RopePoints.ar[Pred(RopePoints.Count)].b xor ((tx - Gear^.X) * (ty - HHGear^.Y) > (tx - HHGear^.X) * (ty - Gear^.Y)) then |
|
877 |
begin |
|
878 |
dec(RopePoints.Count); |
|
1652 | 879 |
Gear^.X:= RopePoints.ar[RopePoints.Count].X; |
880 |
Gear^.Y:= RopePoints.ar[RopePoints.Count].Y; |
|
1504 | 881 |
Gear^.Elasticity:= Gear^.Elasticity + RopePoints.ar[RopePoints.Count].dLen; |
882 |
Gear^.Friction:= Gear^.Friction + RopePoints.ar[RopePoints.Count].dLen |
|
883 |
end |
|
884 |
end; |
|
4 | 885 |
|
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
|
886 |
haveCollision:= false; |
351 | 887 |
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
|
888 |
begin |
1504 | 889 |
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
|
890 |
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
|
891 |
end; |
351 | 892 |
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
|
893 |
begin |
1504 | 894 |
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
|
895 |
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
|
896 |
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
|
897 |
|
1579
2f581b1f289e
More bouncy rope, but you need to press vertical arrow and horizontal keys at once to bounce
unc0rr
parents:
1573
diff
changeset
|
898 |
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
|
899 |
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
|
900 |
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
|
901 |
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
|
902 |
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
|
903 |
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
|
904 |
end; |
4 | 905 |
|
789 | 906 |
len:= Distance(HHGear^.dX, HHGear^.dY); |
940 | 907 |
if len > _0_8 then |
1504 | 908 |
begin |
909 |
len:= _0_8 / len; |
|
910 |
HHGear^.dX:= HHGear^.dX * len; |
|
911 |
HHGear^.dY:= HHGear^.dY * len; |
|
912 |
end; |
|
789 | 913 |
|
351 | 914 |
if (Gear^.Message and gm_Attack) <> 0 then |
1504 | 915 |
if (Gear^.State and gsttmpFlag) <> 0 then |
1922 | 916 |
with PHedgehog(Gear^.Hedgehog)^ do |
1964 | 917 |
if Ammo^[CurSlot, CurAmmo].AmmoType <> amParachute then |
1922 | 918 |
WaitCollision |
919 |
else |
|
920 |
DeleteMe |
|
1504 | 921 |
else |
922 |
else |
|
923 |
if (Gear^.State and gsttmpFlag) = 0 then |
|
924 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
4 | 925 |
end; |
926 |
||
927 |
procedure doStepRopeAttach(Gear: PGear); |
|
928 |
var HHGear: PGear; |
|
1781 | 929 |
tx, ty, tt: hwFloat; |
930 |
||
931 |
procedure RemoveFromAmmo; |
|
932 |
begin |
|
933 |
if (Gear^.State and gstAttacked) = 0 then |
|
934 |
begin |
|
935 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
936 |
Gear^.State:= Gear^.State or gstAttacked |
|
1964 | 937 |
end; |
938 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
|
1781 | 939 |
end; |
940 |
||
4 | 941 |
begin |
351 | 942 |
Gear^.X:= Gear^.X - Gear^.dX; |
943 |
Gear^.Y:= Gear^.Y - Gear^.dY; |
|
498 | 944 |
Gear^.Elasticity:= Gear^.Elasticity + _1; |
351 | 945 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
517 | 946 |
DeleteCI(HHGear); |
542 | 947 |
if (HHGear^.State and gstMoving) <> 0 then |
1433 | 948 |
if TestCollisionYwithGear(HHGear, 1) then |
949 |
begin |
|
950 |
CheckHHDamage(HHGear); |
|
951 |
HHGear^.dY:= _0; |
|
952 |
HHGear^.State:= HHGear^.State and not (gstMoving or gstHHJumping); |
|
953 |
end else |
|
954 |
begin |
|
955 |
if TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then SetLittle(HHGear^.dX); |
|
956 |
HHGear^.X:= HHGear^.X + HHGear^.dX; |
|
957 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; |
|
958 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
959 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
960 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
961 |
tt:= Gear^.Elasticity; |
|
962 |
tx:= _0; |
|
963 |
ty:= _0; |
|
964 |
while tt > _20 do |
|
965 |
begin |
|
966 |
if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), -hwSign(Gear^.dX)) |
|
967 |
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), -hwSign(Gear^.dY)) then |
|
968 |
begin |
|
969 |
Gear^.X:= Gear^.X + tx; |
|
970 |
Gear^.Y:= Gear^.Y + ty; |
|
971 |
Gear^.Elasticity:= tt; |
|
972 |
Gear^.doStep:= @doStepRopeWork; |
|
1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
973 |
with HHGear^ do State:= State and not (gstAttacking or gstMoving or gstHHHJump); |
1781 | 974 |
|
975 |
RemoveFromAmmo; |
|
976 |
||
1752
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
977 |
tt:= _0; |
769986d39202
Fix accidental rope removinf from ammo in some cases
unc0rr
parents:
1736
diff
changeset
|
978 |
exit |
1433 | 979 |
end; |
980 |
tx:= tx + Gear^.dX + Gear^.dX; |
|
981 |
ty:= ty + Gear^.dY + Gear^.dY; |
|
982 |
tt:= tt - _2; |
|
983 |
end; |
|
984 |
end; |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
985 |
|
4 | 986 |
CheckCollision(Gear); |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
987 |
|
351 | 988 |
if (Gear^.State and gstCollision) <> 0 then |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
989 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
990 |
Gear^.doStep:= @doStepRopeWork; |
974
fc16141a0128
Prevent wrong aim direction when using rope after high jump
unc0rr
parents:
963
diff
changeset
|
991 |
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
|
992 |
|
1781 | 993 |
RemoveFromAmmo; |
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
994 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
995 |
if Gear^.Elasticity < _10 then |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
996 |
Gear^.Elasticity:= _10000; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
997 |
end; |
4 | 998 |
|
1634
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
999 |
if (Gear^.Elasticity > Gear^.Friction) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
1000 |
or ((Gear^.Message and gm_Attack) = 0) |
486a89f0e843
Fix rope bug which allowed hedgehog to go into land
unc0rr
parents:
1633
diff
changeset
|
1001 |
or (HHGear^.Damage > 0) then |
1433 | 1002 |
begin |
1003 |
with PHedgehog(Gear^.Hedgehog)^.Gear^ do |
|
1004 |
begin |
|
1005 |
State:= State and not gstAttacking; |
|
1006 |
Message:= Message and not gm_Attack |
|
1007 |
end; |
|
1008 |
DeleteGear(Gear) |
|
1009 |
end |
|
4 | 1010 |
end; |
1011 |
||
1012 |
procedure doStepRope(Gear: PGear); |
|
1013 |
begin |
|
351 | 1014 |
Gear^.dX:= - Gear^.dX; |
1015 |
Gear^.dY:= - Gear^.dY; |
|
1016 |
Gear^.doStep:= @doStepRopeAttach |
|
4 | 1017 |
end; |
1018 |
||
1019 |
//////////////////////////////////////////////////////////////////////////////// |
|
1020 |
procedure doStepSmokeTrace(Gear: PGear); |
|
1021 |
begin |
|
351 | 1022 |
inc(Gear^.Timer); |
1023 |
if Gear^.Timer > 64 then |
|
1133 | 1024 |
begin |
1025 |
Gear^.Timer:= 0; |
|
1026 |
dec(Gear^.State) |
|
1027 |
end; |
|
351 | 1028 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1029 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1030 |
if Gear^.State = 0 then DeleteGear(Gear) |
|
4 | 1031 |
end; |
9 | 1032 |
|
1033 |
//////////////////////////////////////////////////////////////////////////////// |
|
1045 | 1034 |
procedure doStepExplosionWork(Gear: PGear); |
9 | 1035 |
begin |
351 | 1036 |
inc(Gear^.Timer); |
1037 |
if Gear^.Timer > 75 then |
|
1133 | 1038 |
begin |
1039 |
inc(Gear^.State); |
|
1040 |
Gear^.Timer:= 0; |
|
1041 |
if Gear^.State > 5 then DeleteGear(Gear) |
|
1042 |
end; |
|
9 | 1043 |
end; |
10 | 1044 |
|
1045 | 1045 |
procedure doStepExplosion(Gear: PGear); |
1046 |
var i: LongWord; |
|
1047 |
begin |
|
1047 | 1048 |
for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire); |
1049 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart); |
|
1050 |
for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2); |
|
1045 | 1051 |
Gear^.doStep:= @doStepExplosionWork |
1052 |
end; |
|
1053 |
||
10 | 1054 |
//////////////////////////////////////////////////////////////////////////////// |
1055 |
procedure doStepMine(Gear: PGear); |
|
1056 |
begin |
|
542 | 1057 |
if (Gear^.State and gstMoving) <> 0 then |
914 | 1058 |
begin |
1059 |
DeleteCI(Gear); |
|
1060 |
doStepFallingGear(Gear); |
|
1061 |
if (Gear^.State and gstMoving) = 0 then |
|
1062 |
begin |
|
1063 |
AddGearCI(Gear); |
|
1064 |
Gear^.dX:= _0; |
|
1065 |
Gear^.dY:= _0 |
|
1066 |
end; |
|
1067 |
CalcRotationDirAngle(Gear); |
|
1068 |
AllInactive:= false |
|
1069 |
end else |
|
1070 |
if ((GameTicks and $3F) = 25) then |
|
1071 |
doStepFallingGear(Gear); |
|
351 | 1072 |
|
1073 |
if ((Gear^.State and gsttmpFlag) <> 0) then |
|
1133 | 1074 |
if ((Gear^.State and gstAttacking) = 0) then |
1075 |
begin |
|
1076 |
if ((GameTicks and $1F) = 0) then |
|
1077 |
if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then Gear^.State:= Gear^.State or gstAttacking |
|
1078 |
end else // gstAttacking <> 0 |
|
1079 |
begin |
|
1080 |
AllInactive:= false; |
|
1669 | 1081 |
if (Gear^.Timer and $FF) = 0 then PlaySound(sndMineTick, false, nil); |
1133 | 1082 |
if Gear^.Timer = 0 then |
1083 |
begin |
|
1084 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1085 |
DeleteGear(Gear); |
|
1086 |
exit |
|
1087 |
end; |
|
1088 |
dec(Gear^.Timer); |
|
1089 |
end else // gsttmpFlag = 0 |
|
1090 |
if TurnTimeLeft = 0 then Gear^.State:= Gear^.State or gsttmpFlag; |
|
10 | 1091 |
end; |
57 | 1092 |
|
39 | 1093 |
//////////////////////////////////////////////////////////////////////////////// |
1094 |
procedure doStepDynamite(Gear: PGear); |
|
1095 |
begin |
|
43 | 1096 |
doStepFallingGear(Gear); |
1097 |
AllInactive:= false; |
|
351 | 1098 |
if Gear^.Timer mod 166 = 0 then inc(Gear^.Tag); |
1099 |
if Gear^.Timer = 0 then |
|
1133 | 1100 |
begin |
1101 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound); |
|
1102 |
DeleteGear(Gear); |
|
1103 |
exit |
|
1104 |
end; |
|
351 | 1105 |
dec(Gear^.Timer); |
39 | 1106 |
end; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1107 |
|
351 | 1108 |
/////////////////////////////////////////////////////////////////////////////// |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1109 |
procedure doStepCase(Gear: PGear); |
371 | 1110 |
var i, x, y: LongInt; |
1436 | 1111 |
k: TGearType; |
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1112 |
begin |
351 | 1113 |
if (Gear^.Message and gm_Destroy) > 0 then |
1133 | 1114 |
begin |
1115 |
DeleteGear(Gear); |
|
1116 |
FreeActionsList; |
|
1117 |
SetAllToActive; // something (hh, mine, etc...) could be on top of the case |
|
1118 |
with CurrentHedgehog^ do |
|
1119 |
if Gear <> nil then Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump); |
|
1120 |
exit |
|
1121 |
end; |
|
15 | 1122 |
|
351 | 1123 |
if Gear^.Damage > 0 then |
1133 | 1124 |
begin |
1125 |
x:= hwRound(Gear^.X); |
|
1126 |
y:= hwRound(Gear^.Y); |
|
1436 | 1127 |
k:= Gear^.Kind; |
1128 |
DeleteGear(Gear); // <-- delete gear! |
|
1129 |
||
1130 |
if k = gtCase then |
|
1133 | 1131 |
begin |
1132 |
doMakeExplosion(x, y, 25, EXPLAutoSound); |
|
1133 |
for i:= 0 to 63 do |
|
1134 |
AddGear(x, y, gtFlame, 0, _0, _0, 0); |
|
1135 |
end; |
|
1136 |
exit |
|
1137 |
end; |
|
79 | 1138 |
|
351 | 1139 |
if (Gear^.dY.QWordValue <> 0) or (not TestCollisionYwithGear(Gear, 1)) then |
1133 | 1140 |
begin |
1141 |
AllInactive:= false; |
|
1142 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1143 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1144 |
if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else |
|
1145 |
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then |
|
1146 |
begin |
|
1147 |
Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
|
1148 |
if Gear^.dY > - _0_001 then Gear^.dY:= _0 |
|
1669 | 1149 |
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false, nil); |
1133 | 1150 |
end; |
1151 |
CheckGearDrowning(Gear); |
|
1152 |
end; |
|
14
81f125629b25
- Mine checks whether a hedgehog is near less frequently
unc0rr
parents:
13
diff
changeset
|
1153 |
|
511 | 1154 |
if (Gear^.dY.QWordValue = 0) then AddGearCI(Gear) |
1133 | 1155 |
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
|
1156 |
end; |
49 | 1157 |
|
1158 |
//////////////////////////////////////////////////////////////////////////////// |
|
854 | 1159 |
procedure doStepIdle(Gear: PGear); |
1160 |
begin |
|
1161 |
AllInactive:= false; |
|
925 | 1162 |
dec(Gear^.Timer); |
854 | 1163 |
if Gear^.Timer = 0 then |
1164 |
begin |
|
1165 |
DeleteGear(Gear); |
|
1166 |
AfterAttack |
|
1167 |
end |
|
1168 |
end; |
|
1169 |
||
79 | 1170 |
procedure doStepShover(Gear: PGear); |
1171 |
var HHGear: PGear; |
|
1172 |
begin |
|
351 | 1173 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1174 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1175 |
DeleteCI(HHGear); |
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1176 |
|
79 | 1177 |
AmmoShove(Gear, 30, 115); |
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1178 |
|
351 | 1179 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
854 | 1180 |
Gear^.Timer:= 250; |
1181 |
Gear^.doStep:= @doStepIdle |
|
79 | 1182 |
end; |
1183 |
||
1184 |
//////////////////////////////////////////////////////////////////////////////// |
|
925 | 1185 |
procedure doStepWhip(Gear: PGear); |
1186 |
var HHGear: PGear; |
|
1187 |
i: LongInt; |
|
1188 |
begin |
|
1189 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1190 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
980
20128e98988b
Don't push attacking hedgehog when using whip or baseball
unc0rr
parents:
979
diff
changeset
|
1191 |
DeleteCI(HHGear); |
925 | 1192 |
|
1193 |
for i:= 0 to 3 do |
|
1194 |
begin |
|
1195 |
AmmoShove(Gear, 30, 25); |
|
1196 |
Gear^.X:= Gear^.X + Gear^.dX * 5 |
|
1197 |
end; |
|
1198 |
||
1199 |
HHGear^.State:= HHGear^.State and not gstNoDamage; |
|
1200 |
Gear^.Timer:= 250; |
|
1201 |
Gear^.doStep:= @doStepIdle |
|
1202 |
end; |
|
1203 |
||
1204 |
//////////////////////////////////////////////////////////////////////////////// |
|
79 | 1205 |
procedure doStepFlame(Gear: PGear); |
1206 |
begin |
|
1207 |
AllInactive:= false; |
|
1433 | 1208 |
|
79 | 1209 |
if not TestCollisionYwithGear(Gear, 1) then |
1133 | 1210 |
begin |
1586 | 1211 |
if hwAbs(Gear^.dX) > _0_01 then |
1212 |
Gear^.dX:= Gear^.dX * _0_995; |
|
1297 | 1213 |
|
1133 | 1214 |
Gear^.dY:= Gear^.dY + cGravity; |
1830 | 1215 |
if hwAbs(Gear^.dY) > _0_2 then Gear^.dY:= Gear^.dY * _0_995; |
1297 | 1216 |
|
1830 | 1217 |
Gear^.X:= Gear^.X + Gear^.dX + cWindSpeed * 640; |
1133 | 1218 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
1297 | 1219 |
|
1417 | 1220 |
if not (hwRound(Gear^.Y) < cWaterLine) then |
1133 | 1221 |
begin |
1222 |
DeleteGear(Gear); |
|
1223 |
exit |
|
1224 |
end |
|
1225 |
end else begin |
|
1226 |
if Gear^.Timer > 0 then dec(Gear^.Timer) |
|
1227 |
else begin |
|
1586 | 1228 |
Gear^.Radius:= 9; |
1229 |
AmmoShove(Gear, 4, 100); |
|
1297 | 1230 |
Gear^.Radius:= 1; |
1231 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 4, EXPLNoDamage); |
|
1133 | 1232 |
dec(Gear^.Health); |
1586 | 1233 |
Gear^.Timer:= 450 - Gear^.Tag * 8 |
1133 | 1234 |
end |
1235 |
end; |
|
79 | 1236 |
|
1295 | 1237 |
//if (((GameTicks div 8) mod 64) = Gear^.Tag) then |
1238 |
// AmmoFlameWork(Gear); |
|
79 | 1239 |
|
351 | 1240 |
if Gear^.Health = 0 then |
1133 | 1241 |
DeleteGear(Gear) |
79 | 1242 |
end; |
82 | 1243 |
|
1244 |
//////////////////////////////////////////////////////////////////////////////// |
|
1245 |
procedure doStepFirePunchWork(Gear: PGear); |
|
1246 |
var HHGear: PGear; |
|
1247 |
begin |
|
1248 |
AllInactive:= false; |
|
351 | 1249 |
if ((Gear^.Message and gm_Destroy) <> 0) then |
1133 | 1250 |
begin |
1251 |
DeleteGear(Gear); |
|
1252 |
AfterAttack; |
|
1253 |
exit |
|
1254 |
end; |
|
82 | 1255 |
|
351 | 1256 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
1257 |
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then |
|
1133 | 1258 |
begin |
1259 |
Gear^.Tag:= hwRound(HHGear^.Y); |
|
1260 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2); |
|
1261 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1262 |
Gear^.Y:= HHGear^.Y; |
|
1263 |
AmmoShove(Gear, 30, 40); |
|
1264 |
HHGear^.State:= HHGear^.State and not gstNoDamage |
|
1265 |
end; |
|
351 | 1266 |
|
1267 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
1268 |
if not (HHGear^.dY.isNegative) then |
|
1133 | 1269 |
begin |
1270 |
HHGear^.State:= HHGear^.State or gstMoving; |
|
1271 |
DeleteGear(Gear); |
|
1272 |
AfterAttack; |
|
1273 |
exit |
|
1274 |
end; |
|
351 | 1275 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY |
82 | 1276 |
end; |
1277 |
||
1278 |
procedure doStepFirePunch(Gear: PGear); |
|
1279 |
var HHGear: PGear; |
|
1280 |
begin |
|
1281 |
AllInactive:= false; |
|
351 | 1282 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
514 | 1283 |
DeleteCI(HHGear); |
498 | 1284 |
HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5; |
1014
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1285 |
HHGear^.dX:= SignAs(cLittle, Gear^.dX); |
3c7d4e7ccdff
- Fix firepunch sprite direction when use in high jump
unc0rr
parents:
992
diff
changeset
|
1286 |
|
351 | 1287 |
HHGear^.dY:= - _0_3; |
82 | 1288 |
|
351 | 1289 |
Gear^.X:= HHGear^.X; |
979
edb8f208c1d9
Fix firepunch direction when attacking from high jump
unc0rr
parents:
974
diff
changeset
|
1290 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
351 | 1291 |
Gear^.dY:= - _0_9; |
1292 |
Gear^.doStep:= @doStepFirePunchWork; |
|
498 | 1293 |
DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5); |
1279 | 1294 |
|
1669 | 1295 |
PlaySound(TSound(ord(sndFirePunch1) + GetRandom(6)), false, PHedgehog(HHGear^.Hedgehog)^.Team^.voicepack) |
82 | 1296 |
end; |
1297 |
||
263 | 1298 |
//////////////////////////////////////////////////////////////////////////////// |
1299 |
||
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1300 |
procedure doStepParachuteWork(Gear: PGear); |
211 | 1301 |
var HHGear: PGear; |
1302 |
begin |
|
351 | 1303 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
82 | 1304 |
|
516 | 1305 |
inc(Gear^.Timer); |
1306 |
||
212 | 1307 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1308 |
or ((HHGear^.State and gstHHDriven) = 0) |
1309 |
or CheckGearDrowning(HHGear) |
|
1310 |
or ((Gear^.Message and gm_Attack) <> 0) then |
|
1311 |
begin |
|
1312 |
with HHGear^ do |
|
1313 |
begin |
|
1314 |
Message:= 0; |
|
1315 |
SetLittle(dX); |
|
1316 |
dY:= _0; |
|
1317 |
State:= State or gstMoving; |
|
1318 |
end; |
|
1319 |
DeleteGear(Gear); |
|
1320 |
exit |
|
1321 |
end; |
|
211 | 1322 |
|
351 | 1323 |
if not TestCollisionXwithGear(HHGear, hwSign(HHGear^.dX)) then |
1133 | 1324 |
HHGear^.X:= HHGear^.X + cWindSpeed * 200; |
211 | 1325 |
|
351 | 1326 |
if (Gear^.Message and gm_Left) <> 0 then HHGear^.X:= HHGear^.X - cMaxWindSpeed * 40 |
1327 |
else if (Gear^.Message and gm_Right) <> 0 then HHGear^.X:= HHGear^.X + cMaxWindSpeed * 40; |
|
1328 |
if (Gear^.Message and gm_Up) <> 0 then HHGear^.Y:= HHGear^.Y - cGravity * 40 |
|
1329 |
else if (Gear^.Message and gm_Down) <> 0 then HHGear^.Y:= HHGear^.Y + cGravity * 40; |
|
211 | 1330 |
|
351 | 1331 |
HHGear^.Y:= HHGear^.Y + cGravity * 100; |
568 | 1332 |
Gear^.X:= HHGear^.X; |
1333 |
Gear^.Y:= HHGear^.Y |
|
263 | 1334 |
end; |
211 | 1335 |
|
929
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1336 |
procedure doStepParachute(Gear: PGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1337 |
var HHGear: PGear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1338 |
begin |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1339 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1340 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1341 |
DeleteCI(HHGear); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1342 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1343 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1344 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1345 |
|
931 | 1346 |
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
|
1347 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1348 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1349 |
Gear^.doStep:= @doStepParachuteWork; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1350 |
|
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1351 |
Gear^.Message:= HHGear^.Message; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1352 |
doStepParachuteWork(Gear) |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1353 |
end; |
9456e1e77369
- Continue preparation for implementing attack from rope and parachute
unc0rr
parents:
928
diff
changeset
|
1354 |
|
263 | 1355 |
//////////////////////////////////////////////////////////////////////////////// |
1356 |
procedure doStepAirAttackWork(Gear: PGear); |
|
1507 | 1357 |
var i: Longint; |
263 | 1358 |
begin |
1359 |
AllInactive:= false; |
|
498 | 1360 |
Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
1124 | 1361 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1362 |
if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
1124 | 1363 |
begin |
1364 |
dec(Gear^.Health); |
|
1365 |
case Gear^.State of |
|
1366 |
0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1367 |
1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
|
1586 | 1368 |
2: for i:= -19 to 19 do |
1369 |
FollowGear:= AddGear(hwRound(Gear^.X) + i div 3, hwRound(Gear^.Y), gtFlame, 0, _0_001 * i, _0, 0); |
|
1124
1636a3c7c061
- Airplane is higher
unc0& |