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