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