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