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