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