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