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 | 1370 |
end; |
1371 |
Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag) |
|
1372 |
end; |
|
1373 |
||
1374 |
if (GameTicks and $3F) = 0 then |
|
1375 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1376 |
||
1753 | 1377 |
if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear) |
263 | 1378 |
end; |
1379 |
||
1380 |
procedure doStepAirAttack(Gear: PGear); |
|
1381 |
begin |
|
1382 |
AllInactive:= false; |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1383 |
|
1507 | 1384 |
if Gear^.X.QWordValue = 0 then |
1771 | 1385 |
begin |
1386 |
Gear^.Tag:= 1; |
|
1387 |
Gear^.X:= -_1024; |
|
1388 |
end |
|
1507 | 1389 |
else |
1771 | 1390 |
begin |
1507 | 1391 |
Gear^.Tag:= -1; |
1771 | 1392 |
Gear^.X:= int2hwFloat(LAND_WIDTH + 1024); |
1393 |
end; |
|
1507 | 1394 |
|
1784 | 1395 |
Gear^.Y:= int2hwFloat(topY-300); |
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1396 |
Gear^.dX:= int2hwFloat(TargetPoint.X - 5 * Gear^.Tag * 15); |
357 | 1397 |
|
543
465e2ec8f05f
- Better randomness of placing hedgehogs on the land
unc0rr
parents:
542
diff
changeset
|
1398 |
if int2hwFloat(TargetPoint.Y) - Gear^.Y > _0 then |
1133 | 1399 |
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
|
1400 |
|
351 | 1401 |
Gear^.Health:= 6; |
801 | 1402 |
Gear^.doStep:= @doStepAirAttackWork; |
1669 | 1403 |
PlaySound(sndIncoming, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
263 | 1404 |
end; |
1405 |
||
1406 |
//////////////////////////////////////////////////////////////////////////////// |
|
1407 |
||
1408 |
procedure doStepAirBomb(Gear: PGear); |
|
1409 |
begin |
|
1410 |
AllInactive:= false; |
|
1411 |
doStepFallingGear(Gear); |
|
351 | 1412 |
if (Gear^.State and gstCollision) <> 0 then |
1133 | 1413 |
begin |
1414 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1415 |
DeleteGear(Gear); |
|
1416 |
exit |
|
1417 |
end; |
|
263 | 1418 |
if (GameTicks and $3F) = 0 then |
1133 | 1419 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
211 | 1420 |
end; |
409 | 1421 |
|
1422 |
//////////////////////////////////////////////////////////////////////////////// |
|
1423 |
||
1424 |
procedure doStepGirder(Gear: PGear); |
|
415 | 1425 |
var HHGear: PGear; |
1915 | 1426 |
x, y, tx, ty: hwFloat; |
409 | 1427 |
begin |
1428 |
AllInactive:= false; |
|
415 | 1429 |
|
1430 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1915 | 1431 |
tx:= int2hwFloat(TargetPoint.X); |
1432 |
ty:= int2hwFloat(TargetPoint.Y); |
|
1433 |
x:= HHGear^.X; |
|
1434 |
y:= HHGear^.Y; |
|
1909 | 1435 |
|
1915 | 1436 |
if (Distance(tx - x, ty - y) > _256) or |
1437 |
not TryPlaceOnLand(TargetPoint.X - SpritesData[sprAmGirder].Width div 2, |
|
1438 |
TargetPoint.Y - SpritesData[sprAmGirder].Height div 2, |
|
520 | 1439 |
sprAmGirder, Gear^.State, true) then |
1133 | 1440 |
begin |
1914 | 1441 |
PlaySound(sndDenied, false, nil); |
1442 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1443 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1133 | 1444 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
1914 | 1445 |
isCursorVisible:= true; |
1446 |
DeleteGear(Gear) |
|
1133 | 1447 |
end |
1448 |
else begin |
|
1914 | 1449 |
PlaySound(sndPlaced, false, nil); |
1133 | 1450 |
DeleteGear(Gear); |
1909 | 1451 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
1914 | 1452 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^) |
1453 |
end; |
|
1454 |
||
1909 | 1455 |
HHGear^.State:= HHGear^.State and not (gstAttacking or gstAttacked); |
1456 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
415 | 1457 |
TargetPoint.X:= NoPointX |
409 | 1458 |
end; |
520 | 1459 |
|
1460 |
//////////////////////////////////////////////////////////////////////////////// |
|
525 | 1461 |
procedure doStepTeleportAfter(Gear: PGear); |
912 | 1462 |
var HHGear: PGear; |
1463 |
begin |
|
1464 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1465 |
HHGear^.Y:= HHGear^.Y + HHGear^.dY; // hedgehog falling to collect cases |
|
1466 |
HHGear^.dY:= HHGear^.dY + cGravity; |
|
945
4ead9cde4e14
- Start chat implementation: chat strings are on the screen
unc0rr
parents:
940
diff
changeset
|
1467 |
if TestCollisionYwithGear(HHGear, 1) |
1133 | 1468 |
or CheckGearDrowning(HHGear) then |
1469 |
begin |
|
1470 |
DeleteGear(Gear); |
|
1471 |
AfterAttack |
|
1472 |
end |
|
912 | 1473 |
end; |
1474 |
||
1475 |
procedure doStepTeleportAnim(Gear: PGear); |
|
525 | 1476 |
begin |
853 | 1477 |
inc(Gear^.Timer); |
1478 |
if Gear^.Timer = 65 then |
|
1479 |
begin |
|
1480 |
Gear^.Timer:= 0; |
|
1481 |
inc(Gear^.Pos); |
|
1482 |
if Gear^.Pos = 11 then |
|
912 | 1483 |
Gear^.doStep:= @doStepTeleportAfter |
853 | 1484 |
end |
525 | 1485 |
end; |
520 | 1486 |
|
1487 |
procedure doStepTeleport(Gear: PGear); |
|
1488 |
var HHGear: PGear; |
|
1489 |
begin |
|
1490 |
AllInactive:= false; |
|
1491 |
||
1492 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1493 |
if not TryPlaceOnLand(TargetPoint.X - SpritesData[sprHHTelepMask].Width div 2, |
|
1494 |
TargetPoint.Y - SpritesData[sprHHTelepMask].Height div 2, |
|
1495 |
sprHHTelepMask, 0, false) then |
|
853 | 1496 |
begin |
1497 |
HHGear^.Message:= HHGear^.Message and not gm_Attack; |
|
1498 |
HHGear^.State:= HHGear^.State and not gstAttacking; |
|
1499 |
HHGear^.State:= HHGear^.State or gstHHChooseTarget; |
|
1500 |
DeleteGear(Gear); |
|
1501 |
isCursorVisible:= true |
|
1502 |
end |
|
1503 |
else begin |
|
1504 |
DeleteCI(HHGear); |
|
1505 |
SetAllHHToActive; |
|
912 | 1506 |
Gear^.doStep:= @doStepTeleportAnim; |
853 | 1507 |
Gear^.X:= HHGear^.X; |
1508 |
Gear^.Y:= HHGear^.Y; |
|
1509 |
HHGear^.X:= int2hwFloat(TargetPoint.X); |
|
1510 |
HHGear^.Y:= int2hwFloat(TargetPoint.Y); |
|
1511 |
HHGear^.State:= HHGear^.State or gstMoving |
|
1512 |
end; |
|
520 | 1513 |
TargetPoint.X:= NoPointX |
1514 |
end; |
|
534 | 1515 |
|
1516 |
//////////////////////////////////////////////////////////////////////////////// |
|
1517 |
procedure doStepSwitcherWork(Gear: PGear); |
|
1518 |
var HHGear: PGear; |
|
1519 |
Msg, State: Longword; |
|
1520 |
begin |
|
1521 |
AllInactive:= false; |
|
1522 |
||
540 | 1523 |
if ((Gear^.Message and not gm_Switch) <> 0) or (TurnTimeLeft = 0) then |
1133 | 1524 |
begin |
1525 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1526 |
Msg:= Gear^.Message and not gm_Switch; |
|
1527 |
DeleteGear(Gear); |
|
1528 |
OnUsedAmmo(PHedgehog(HHGear^.Hedgehog)^); |
|
1529 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
534 | 1530 |
|
1133 | 1531 |
HHGear:= CurrentHedgehog^.Gear; |
1532 |
ApplyAmmoChanges(PHedgehog(HHGear^.Hedgehog)^); |
|
1533 |
HHGear^.Message:= Msg; |
|
1534 |
exit |
|
1535 |
end; |
|
534 | 1536 |
|
1537 |
if (Gear^.Message and gm_Switch) <> 0 then |
|
1133 | 1538 |
begin |
1539 |
HHGear:= CurrentHedgehog^.Gear; |
|
1540 |
HHGear^.Message:= HHGear^.Message and not gm_Switch; |
|
1541 |
Gear^.Message:= Gear^.Message and not gm_Switch; |
|
1542 |
State:= HHGear^.State; |
|
1543 |
HHGear^.State:= 0; |
|
1544 |
HHGear^.Active:= false; |
|
1545 |
HHGear^.Z:= cHHZ; |
|
1546 |
RemoveGearFromList(HHGear); |
|
1547 |
InsertGearToList(HHGear); |
|
534 | 1548 |
|
1133 | 1549 |
repeat |
1550 |
CurrentTeam^.CurrHedgehog:= Succ(CurrentTeam^.CurrHedgehog) mod (CurrentTeam^.HedgehogsNumber); |
|
1551 |
until (CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog].Gear <> nil); |
|
652 | 1552 |
|
1133 | 1553 |
CurrentHedgehog:= @CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]; |
534 | 1554 |
|
1133 | 1555 |
HHGear:= CurrentHedgehog^.Gear; |
1556 |
HHGear^.State:= State; |
|
1557 |
HHGear^.Active:= true; |
|
1558 |
FollowGear:= HHGear; |
|
1559 |
HHGear^.Z:= cCurrHHZ; |
|
1560 |
RemoveGearFromList(HHGear); |
|
1561 |
InsertGearToList(HHGear); |
|
1562 |
Gear^.X:= HHGear^.X; |
|
1563 |
Gear^.Y:= HHGear^.Y |
|
1564 |
end; |
|
534 | 1565 |
end; |
1566 |
||
1567 |
procedure doStepSwitcher(Gear: PGear); |
|
1568 |
var HHGear: PGear; |
|
1569 |
begin |
|
1570 |
Gear^.doStep:= @doStepSwitcherWork; |
|
1571 |
||
1572 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1573 |
with HHGear^ do |
|
1133 | 1574 |
begin |
1575 |
State:= State and not gstAttacking; |
|
1576 |
Message:= Message and not gm_Attack |
|
1577 |
end |
|
534 | 1578 |
end; |
924 | 1579 |
|
1580 |
//////////////////////////////////////////////////////////////////////////////// |
|
1581 |
procedure doStepMortar(Gear: PGear); |
|
1582 |
var dX, dY: hwFloat; |
|
1583 |
i: LongInt; |
|
963 | 1584 |
dxn, dyn: boolean; |
924 | 1585 |
begin |
1586 |
AllInactive:= false; |
|
963 | 1587 |
dxn:= Gear^.dX.isNegative; |
1588 |
dyn:= Gear^.dY.isNegative; |
|
1589 |
||
924 | 1590 |
doStepFallingGear(Gear); |
1591 |
if (Gear^.State and gstCollision) <> 0 then |
|
1592 |
begin |
|
1593 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, EXPLAutoSound); |
|
963 | 1594 |
|
1595 |
Gear^.dX.isNegative:= not dxn; |
|
1596 |
Gear^.dY.isNegative:= not dyn; |
|
924 | 1597 |
for i:= 0 to 4 do |
1598 |
begin |
|
963 | 1599 |
dX:= Gear^.dX + (GetRandom - _0_5) * _0_03; |
1600 |
dY:= Gear^.dY + (GetRandom - _0_5) * _0_03; |
|
1273 | 1601 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, dX, dY, 25); |
924 | 1602 |
end; |
1603 |
||
1604 |
DeleteGear(Gear); |
|
1605 |
exit |
|
1606 |
end; |
|
963 | 1607 |
|
924 | 1608 |
if (GameTicks and $3F) = 0 then |
1609 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0) |
|
1610 |
end; |
|
984 | 1611 |
|
1612 |
//////////////////////////////////////////////////////////////////////////////// |
|
1613 |
procedure doStepKamikazeWork(Gear: PGear); |
|
1614 |
const upd: Longword = 0; |
|
987 | 1615 |
var i: LongWord; |
984 | 1616 |
HHGear: PGear; |
1617 |
begin |
|
1618 |
AllInactive:= false; |
|
1619 |
||
1620 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1621 |
HHGear^.State:= HHGear^.State or gstNoDamage; |
|
1622 |
DeleteCI(HHGear); |
|
1623 |
||
1624 |
i:= 2; |
|
1625 |
repeat |
|
1626 |
Gear^.X:= Gear^.X + HHGear^.dX; |
|
1627 |
Gear^.Y:= Gear^.Y + HHGear^.dY; |
|
1628 |
HHGear^.X:= Gear^.X; |
|
1629 |
HHGear^.Y:= Gear^.Y; |
|
1630 |
||
1631 |
inc(Gear^.Damage, 2); |
|
1632 |
||
1200 | 1633 |
// if TestCollisionXwithGear(HHGear, hwSign(Gear^.dX)) |
1634 |
// or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY)) then inc(Gear^.Damage, 3); |
|
984 | 1635 |
|
1636 |
dec(i) |
|
1637 |
until (i = 0) or (Gear^.Damage > Gear^.Health); |
|
1638 |
||
1639 |
inc(upd); |
|
1640 |
if upd > 3 then |
|
1641 |
begin |
|
987 | 1642 |
if Gear^.Health < 1500 then Gear^.Pos:= 2; |
1643 |
||
984 | 1644 |
AmmoShove(Gear, 30, 40); |
1645 |
||
1646 |
DrawTunnel(HHGear^.X - HHGear^.dX * 10, |
|
1200 | 1647 |
HHGear^.Y - _2 - HHGear^.dY * 10 + hwAbs(HHGear^.dY) * 2, |
984 | 1648 |
HHGear^.dX, |
1649 |
HHGear^.dY, |
|
1650 |
20 + cHHRadius * 2, |
|
1200 | 1651 |
cHHRadius * 2 + 6); |
984 | 1652 |
|
1653 |
upd:= 0 |
|
1654 |
end; |
|
1655 |
||
1656 |
if Gear^.Health < Gear^.Damage then |
|
1657 |
begin |
|
1658 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound); |
|
1659 |
AfterAttack; |
|
1660 |
DeleteGear(Gear); |
|
1661 |
DeleteGear(HHGear); |
|
1662 |
end else |
|
1663 |
begin |
|
1664 |
dec(Gear^.Health, Gear^.Damage); |
|
1665 |
Gear^.Damage:= 0 |
|
1666 |
end |
|
1667 |
end; |
|
1668 |
||
987 | 1669 |
procedure doStepKamikazeIdle(Gear: PGear); |
1670 |
begin |
|
1671 |
AllInactive:= false; |
|
1672 |
dec(Gear^.Timer); |
|
1673 |
if Gear^.Timer = 0 then |
|
1674 |
begin |
|
1675 |
Gear^.Pos:= 1; |
|
1669 | 1676 |
PlaySound(sndKamikaze, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack); |
987 | 1677 |
Gear^.doStep:= @doStepKamikazeWork |
1678 |
end |
|
1679 |
end; |
|
1680 |
||
984 | 1681 |
procedure doStepKamikaze(Gear: PGear); |
1682 |
var HHGear: PGear; |
|
1683 |
begin |
|
1684 |
AllInactive:= false; |
|
1685 |
||
1686 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1687 |
||
1688 |
HHGear^.dX:= Gear^.dX; |
|
1689 |
HHGear^.dY:= Gear^.dY; |
|
1690 |
||
1691 |
Gear^.dX:= SignAs(_0_45, Gear^.dX); |
|
1692 |
Gear^.dY:= - _0_9; |
|
1693 |
||
987 | 1694 |
Gear^.Timer:= 550; |
1695 |
||
1696 |
Gear^.doStep:= @doStepKamikazeIdle |
|
984 | 1697 |
end; |
1698 |
||
1103 | 1699 |
//////////////////////////////////////////////////////////////////////////////// |
1700 |
const cakeh = 27; |
|
1110 | 1701 |
cakeDmg = 75; |
1103 | 1702 |
var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end; |
1703 |
CakeI: Longword; |
|
1704 |
||
1110 | 1705 |
procedure doStepCakeExpl(Gear: PGear); |
1706 |
begin |
|
1707 |
inc(Gear^.Tag); |
|
1708 |
if Gear^.Tag < 2250 then exit; |
|
1709 |
||
1710 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1711 |
AfterAttack; |
|
1712 |
DeleteGear(Gear) |
|
1713 |
end; |
|
1714 |
||
1109 | 1715 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1716 |
var gi: PGear; |
1717 |
dmg: LongInt; |
|
1109 | 1718 |
begin |
1719 |
AllInactive:= false; |
|
1720 |
||
1721 |
inc(Gear^.Tag); |
|
1722 |
if Gear^.Tag < 100 then exit; |
|
1723 |
Gear^.Tag:= 0; |
|
1724 |
||
1725 |
if Gear^.Pos = 0 then |
|
1726 |
begin |
|
1110 | 1727 |
gi:= GearsList; |
1728 |
while gi <> nil do |
|
1729 |
begin |
|
1730 |
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
|
1731 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1732 |
if (CurrentHedgehog^.Gear = gi) and (not gi^.Invulnerable) then |
1867 | 1733 |
gi^.State:= gi^.State or gstLoser |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1734 |
else |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1735 |
gi^.State:= gi^.State or gstWinner; |
1110 | 1736 |
gi:= gi^.NextGear |
1737 |
end; |
|
1738 |
Gear^.doStep:= @doStepCakeExpl; |
|
1669 | 1739 |
PlaySound(sndCake, false, nil) |
1109 | 1740 |
end else dec(Gear^.Pos) |
1741 |
end; |
|
1742 |
||
1743 |
||
1089 | 1744 |
procedure doStepCakeWork(Gear: PGear); |
1745 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1746 |
var xx, yy, xxn, yyn: LongInt; |
|
1747 |
da: LongInt; |
|
1103 | 1748 |
tdx, tdy: hwFloat; |
1089 | 1749 |
|
1750 |
procedure PrevAngle; |
|
1751 |
begin |
|
1133 | 1752 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1753 |
end; |
1754 |
||
1755 |
procedure NextAngle; |
|
1756 |
begin |
|
1133 | 1757 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1758 |
end; |
1759 |
||
1088 | 1760 |
begin |
1089 | 1761 |
inc(Gear^.Tag); |
1108 | 1762 |
if Gear^.Tag < 7 then exit; |
1089 | 1763 |
|
1764 |
dA:= hwSign(Gear^.dX); |
|
1765 |
xx:= dirs[Gear^.Angle].x; |
|
1766 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1767 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1768 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1769 |
|
1770 |
if (xx = 0) then |
|
1771 |
if TestCollisionYwithGear(Gear, yy) then |
|
1772 |
PrevAngle |
|
1773 |
else begin |
|
1774 |
Gear^.Tag:= 0; |
|
1775 |
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
|
1776 |
if not TestCollisionXwithGear(Gear, xxn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1777 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1778 |
Gear^.X:= Gear^.X + int2hwFloat(xxn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1779 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1780 |
end; |
1089 | 1781 |
end; |
1782 |
||
1783 |
if (yy = 0) then |
|
1784 |
if TestCollisionXwithGear(Gear, xx) then |
|
1785 |
PrevAngle |
|
1786 |
else begin |
|
1787 |
Gear^.Tag:= 0; |
|
1788 |
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
|
1789 |
if not TestCollisionYwithGear(Gear, yyn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1790 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1791 |
Gear^.Y:= Gear^.Y + int2hwFloat(yyn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1792 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1793 |
end; |
1089 | 1794 |
end; |
1795 |
||
1103 | 1796 |
if Gear^.Tag = 0 then |
1797 |
begin |
|
1798 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1799 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1800 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1801 |
CakePoints[CakeI].x:= Gear^.X; |
|
1802 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1803 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1804 |
end; |
|
1805 |
||
1089 | 1806 |
dec(Gear^.Health); |
1090 | 1807 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1808 |
begin |
1109 | 1809 |
FollowGear:= Gear; |
1810 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1811 |
end |
1088 | 1812 |
end; |
1089 | 1813 |
|
1103 | 1814 |
procedure doStepCakeUp(Gear: PGear); |
1815 |
var i: Longword; |
|
1816 |
begin |
|
1817 |
AllInactive:= false; |
|
1818 |
||
1108 | 1819 |
inc(Gear^.Tag); |
1109 | 1820 |
if Gear^.Tag < 100 then exit; |
1108 | 1821 |
Gear^.Tag:= 0; |
1822 |
||
1109 | 1823 |
if Gear^.Pos = 6 then |
1103 | 1824 |
begin |
1825 |
for i:= 0 to Pred(cakeh) do |
|
1826 |
begin |
|
1827 |
CakePoints[i].x:= Gear^.X; |
|
1828 |
CakePoints[i].y:= Gear^.Y |
|
1829 |
end; |
|
1830 |
CakeI:= 0; |
|
1831 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1832 |
end else inc(Gear^.Pos) |
1103 | 1833 |
end; |
1834 |
||
1089 | 1835 |
procedure doStepCakeFall(Gear: PGear); |
1836 |
begin |
|
1837 |
AllInactive:= false; |
|
1838 |
||
1839 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1840 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1841 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1842 |
else |
1843 |
begin |
|
1844 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1845 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1846 |
end |
|
1847 |
end; |
|
1848 |
||
1849 |
procedure doStepCake(Gear: PGear); |
|
1850 |
var HHGear: PGear; |
|
1851 |
begin |
|
1852 |
AllInactive:= false; |
|
1853 |
||
1854 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1855 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1856 |
DeleteCI(HHGear); |
1857 |
||
1106 | 1858 |
FollowGear:= Gear; |
1859 |
||
1089 | 1860 |
Gear^.doStep:= @doStepCakeFall |
1861 |
end; |
|
1862 |
||
1259 | 1863 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1864 |
procedure doStepSeductionWork(Gear: PGear); |
1865 |
var x, y: LongInt; |
|
1259 | 1866 |
begin |
1867 |
AllInactive:= false; |
|
1284 | 1868 |
|
1869 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1870 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1871 |
x:= hwRound(Gear^.X); |
|
1872 |
y:= hwRound(Gear^.Y); |
|
1259 | 1873 |
|
1753 | 1874 |
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then |
1284 | 1875 |
if (Land[y, x] <> 0) then |
1876 |
begin |
|
1877 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1878 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1879 |
Gear^.dX:= Gear^.dX * _1_5; |
1880 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1881 |
AmmoShove(Gear, 0, 40); |
1286 | 1882 |
AfterAttack; |
1284 | 1883 |
DeleteGear(Gear) |
1884 |
end |
|
1885 |
else |
|
1886 |
else |
|
1286 | 1887 |
begin |
1888 |
AfterAttack; |
|
1284 | 1889 |
DeleteGear(Gear) |
1286 | 1890 |
end |
1891 |
end; |
|
1892 |
||
1893 |
procedure doStepSeductionWear(Gear: PGear); |
|
1894 |
begin |
|
1895 |
AllInactive:= false; |
|
1896 |
inc(Gear^.Timer); |
|
1897 |
if Gear^.Timer > 250 then |
|
1898 |
begin |
|
1899 |
Gear^.Timer:= 0; |
|
1388 | 1900 |
inc(Gear^.Pos); |
1901 |
if Gear^.Pos = 5 then |
|
1669 | 1902 |
PlaySound(sndYoohoo, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1286 | 1903 |
end; |
1367 | 1904 |
|
1905 |
if Gear^.Pos = 14 then |
|
1286 | 1906 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1907 |
end; |
1284 | 1908 |
|
1909 |
procedure doStepSeduction(Gear: PGear); |
|
1910 |
begin |
|
1911 |
AllInactive:= false; |
|
1912 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1913 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1914 |
end; |
1298 | 1915 |
|
1916 |
//////////////////////////////////////////////////////////////////////////////// |
|
1917 |
procedure doStepWaterUp(Gear: PGear); |
|
1918 |
var i: LongWord; |
|
1919 |
begin |
|
1920 |
AllInactive:= false; |
|
1921 |
||
1922 |
inc(Gear^.Timer); |
|
1923 |
if Gear^.Timer = 17 then |
|
1924 |
Gear^.Timer:= 0 |
|
1925 |
else |
|
1926 |
exit; |
|
1927 |
||
1928 |
if cWaterLine > 0 then |
|
1929 |
begin |
|
1930 |
dec(cWaterLine); |
|
1760 | 1931 |
for i:= 0 to LAND_WIDTH - 1 do |
1298 | 1932 |
Land[cWaterLine, i]:= 0; |
1933 |
SetAllToActive |
|
1934 |
end; |
|
1935 |
||
1936 |
inc(Gear^.Tag); |
|
1343 | 1937 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1938 |
DeleteGear(Gear) |
1939 |
end; |
|
1573 | 1940 |
|
1941 |
//////////////////////////////////////////////////////////////////////////////// |
|
1590 | 1942 |
procedure doStepDrillDrilling(Gear: PGear); |
1633 | 1943 |
var t: PGearArray; |
1944 |
ox, oy: hwFloat; |
|
1573 | 1945 |
begin |
1590 | 1946 |
AllInactive:= false; |
1947 |
||
1633 | 1948 |
if (Gear^.Timer > 0) and ((Gear^.Timer mod 10) = 0) then |
1590 | 1949 |
begin |
1573 | 1950 |
ox:= Gear^.X; |
1951 |
oy:= Gear^.Y; |
|
1952 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1953 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1954 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); |
|
1955 |
CheckGearDrowning(Gear); |
|
1590 | 1956 |
end; |
1957 |
||
1633 | 1958 |
t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug |
1590 | 1959 |
if (Gear^.Timer = 0) |
1633 | 1960 |
or (t^.Count <> 0) |
1590 | 1961 |
or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) |
1784 | 1962 |
and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) |
1963 |
or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] = COLOR_INDESTRUCTIBLE) then |
|
1590 | 1964 |
begin //out of time or exited ground |
1965 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1966 |
DeleteGear(Gear); |
|
1967 |
exit |
|
1968 |
end; |
|
1969 |
||
1970 |
dec(Gear^.Timer); |
|
1573 | 1971 |
end; |
1972 |
||
1973 |
procedure doStepDrill(Gear: PGear); |
|
1590 | 1974 |
var t: PGearArray; |
1633 | 1975 |
oldDx, oldDy: hwFloat; |
1976 |
t2: hwFloat; |
|
1573 | 1977 |
begin |
1590 | 1978 |
AllInactive:= false; |
1573 | 1979 |
|
1590 | 1980 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1981 |
oldDx:= Gear^.dX; |
|
1982 |
oldDy:= Gear^.dY; |
|
1983 |
||
1984 |
doStepFallingGear(Gear); |
|
1985 |
||
1986 |
if (GameTicks and $3F) = 0 then |
|
1987 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1573 | 1988 |
|
1633 | 1989 |
if ((Gear^.State and gstCollision) <> 0) then begin //hit |
1590 | 1990 |
Gear^.dX:= oldDx; |
1991 |
Gear^.dY:= oldDy; |
|
1633 | 1992 |
|
1590 | 1993 |
t:= CheckGearsCollision(Gear); |
1633 | 1994 |
if (t^.Count = 0) then begin //hit the ground not the HH |
1995 |
t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); |
|
1996 |
Gear^.dX:= Gear^.dX * t2; |
|
1997 |
Gear^.dY:= Gear^.dY * t2; |
|
1998 |
end else begin //explode right on contact with HH |
|
1999 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
2000 |
DeleteGear(Gear); |
|
2001 |
exit; |
|
2002 |
end; |
|
2003 |
||
1590 | 2004 |
Gear^.doStep:= @doStepDrillDrilling; |
1633 | 2005 |
dec(Gear^.Timer) |
1590 | 2006 |
end |
2007 |
end; |
|
1601 | 2008 |
|
1633 | 2009 |
//////////////////////////////////////////////////////////////////////////////// |
1601 | 2010 |
procedure doStepBallgunWork(Gear: PGear); |
2011 |
var HHGear: PGear; |
|
1630 | 2012 |
rx, ry: hwFloat; |
1601 | 2013 |
begin |
2014 |
AllInactive:= false; |
|
2015 |
dec(Gear^.Timer); |
|
2016 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2017 |
HedgehogChAngle(HHGear); |
|
2018 |
if (Gear^.Timer mod 100) = 0 then |
|
2019 |
begin |
|
1630 | 2020 |
rx:= rndSign(getRandom * _0_1); |
2021 |
ry:= rndSign(getRandom * _0_1); |
|
1631
6e313b3818ef
Remove debug stuff, ballgun 64but incompatibility fixed in previous revision
unc0rr
parents:
1630
diff
changeset
|
2022 |
|
1630 | 2023 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0, |
2024 |
SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, |
|
2025 |
AngleCos(HHGear^.Angle) * ( - _0_8) + ry, |
|
2026 |
0); |
|
1601 | 2027 |
|
1669 | 2028 |
PlaySound(sndGun, false, nil); |
1601 | 2029 |
end; |
2030 |
||
1643 | 2031 |
if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then |
1601 | 2032 |
begin |
2033 |
DeleteGear(Gear); |
|
1643 | 2034 |
AfterAttack |
2035 |
end |
|
1601 | 2036 |
end; |
2037 |
||
2038 |
procedure doStepBallgun(Gear: PGear); |
|
2039 |
var HHGear: PGear; |
|
2040 |
begin |
|
2041 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2042 |
HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Down); |
|
2043 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2044 |
Gear^.doStep:= @doStepBallgunWork |
|
1633 | 2045 |
end; |
1689 | 2046 |
|
1696 | 2047 |
//////////////////////////////////////////////////////////////////////////////// |
1689 | 2048 |
procedure doStepRCPlaneWork(Gear: PGear); |
2049 |
const cAngleSpeed = 3; |
|
2050 |
var HHGear: PGear; |
|
2051 |
i: LongInt; |
|
2052 |
dX, dY: hwFloat; |
|
2053 |
fChanged: boolean; |
|
2054 |
trueAngle: Longword; |
|
2055 |
t: PGear; |
|
2056 |
begin |
|
2057 |
AllInactive:= false; |
|
2058 |
||
1696 | 2059 |
if Gear^.Timer > 0 then dec(Gear^.Timer); |
1689 | 2060 |
|
2061 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2062 |
FollowGear:= Gear; |
|
2063 |
||
2064 |
fChanged:= false; |
|
1696 | 2065 |
if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then |
1689 | 2066 |
begin |
2067 |
fChanged:= true; |
|
1696 | 2068 |
if Gear^.Angle > 2048 then dec(Gear^.Angle) else |
2069 |
if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false |
|
2070 |
end |
|
2071 |
else |
|
2072 |
begin |
|
2073 |
if ((Gear^.Message and gm_Left) <> 0) then |
|
2074 |
begin |
|
2075 |
fChanged:= true; |
|
2076 |
Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 |
|
2077 |
end; |
|
1689 | 2078 |
|
1696 | 2079 |
if ((Gear^.Message and gm_Right) <> 0) then |
2080 |
begin |
|
2081 |
fChanged:= true; |
|
2082 |
Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096 |
|
2083 |
end |
|
1689 | 2084 |
end; |
2085 |
||
2086 |
if fChanged then |
|
2087 |
begin |
|
2088 |
Gear^.dX.isNegative:= (Gear^.Angle > 2048); |
|
2089 |
if Gear^.dX.isNegative then |
|
2090 |
trueAngle:= 4096 - Gear^.Angle |
|
2091 |
else |
|
2092 |
trueAngle:= Gear^.Angle; |
|
2093 |
||
2094 |
Gear^.dX:= SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; |
|
2095 |
Gear^.dY:= AngleCos(trueAngle) * -_0_25; |
|
2096 |
end; |
|
2097 |
||
2098 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
2099 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
2100 |
||
2101 |
if (GameTicks and $FF) = 0 then |
|
1698 | 2102 |
if Gear^.Timer < 3500 then |
1696 | 2103 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0) |
2104 |
else |
|
2105 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1689 | 2106 |
|
1696 | 2107 |
if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then |
1689 | 2108 |
begin |
2109 |
HHGear^.Message := HHGear^.Message and not gm_Attack; |
|
1708 | 2110 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); |
1689 | 2111 |
dec(Gear^.Health) |
1712 | 2112 |
end; |
2113 |
||
2114 |
if ((HHGear^.Message and gm_LJump) <> 0) |
|
2115 |
and ((Gear^.State and gsttmpFlag) = 0) then |
|
2116 |
begin |
|
2117 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
2118 |
PauseMusic; |
|
2119 |
playSound(sndRideOfTheValkyries, false, nil); |
|
2120 |
end; |
|
1689 | 2121 |
|
2122 |
// pickup bonuses |
|
2123 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
2124 |
if t <> nil then |
|
2125 |
PickUp(HHGear, t); |
|
2126 |
||
2127 |
CheckCollision(Gear); |
|
2128 |
||
1712 | 2129 |
if ((Gear^.State and gstCollision) <> 0) |
2130 |
or CheckGearDrowning(Gear) then |
|
1689 | 2131 |
begin |
1712 | 2132 |
StopSound(sndRCPlane); |
2133 |
StopSound(sndRideOfTheValkyries); |
|
2134 |
ResumeMusic; |
|
2135 |
||
2136 |
if ((Gear^.State and gstCollision) <> 0) then |
|
1689 | 2137 |
begin |
1712 | 2138 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); |
1714 | 2139 |
for i:= 0 to 32 do |
1712 | 2140 |
begin |
1714 | 2141 |
dX:= AngleCos(i * 64) * _0_5 * (GetRandom + _1); |
2142 |
dY:= AngleSin(i * 64) * _0_5 * (GetRandom + _1); |
|
1712 | 2143 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); |
2144 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); |
|
2145 |
end; |
|
2146 |
DeleteGear(Gear) |
|
1689 | 2147 |
end; |
1713 | 2148 |
|
1689 | 2149 |
AfterAttack; |
1713 | 2150 |
CurAmmoGear:= nil; |
1697 | 2151 |
TurnTimeLeft:= 14 * 125; |
1712 | 2152 |
HHGear^.Message:= 0; |
1697 | 2153 |
ParseCommand('/taunt '#1, true) |
2154 |
end |
|
1689 | 2155 |
end; |
2156 |
||
2157 |
procedure doStepRCPlane(Gear: PGear); |
|
2158 |
var HHGear: PGear; |
|
2159 |
begin |
|
2160 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2161 |
HHGear^.Message:= 0; |
|
2162 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2163 |
Gear^.Angle:= HHGear^.Angle; |
|
1696 | 2164 |
Gear^.Tag:= hwSign(HHGear^.dX); |
1689 | 2165 |
if HHGear^.dX.isNegative then Gear^.Angle:= 4096 - Gear^.Angle; |
2166 |
Gear^.doStep:= @doStepRCPlaneWork |
|
1712 | 2167 |
end; |