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