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