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