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