author | nemo |
Mon, 01 Jun 2009 17:04:36 +0000 | |
changeset 2140 | 75e5c4fcae2a |
parent 2139 | 5a083e71a71d |
child 2141 | 3b06505dbd5d |
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 |
|
1713 |
inc(Gear^.Tag); |
|
1714 |
if Gear^.Tag < 2250 then exit; |
|
1715 |
||
1716 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound); |
|
1717 |
AfterAttack; |
|
1718 |
DeleteGear(Gear) |
|
1719 |
end; |
|
1720 |
||
1109 | 1721 |
procedure doStepCakeDown(Gear: PGear); |
1133 | 1722 |
var gi: PGear; |
1723 |
dmg: LongInt; |
|
1109 | 1724 |
begin |
1725 |
AllInactive:= false; |
|
1726 |
||
1727 |
inc(Gear^.Tag); |
|
1728 |
if Gear^.Tag < 100 then exit; |
|
1729 |
Gear^.Tag:= 0; |
|
1730 |
||
1731 |
if Gear^.Pos = 0 then |
|
1732 |
begin |
|
1110 | 1733 |
gi:= GearsList; |
1734 |
while gi <> nil do |
|
1735 |
begin |
|
1736 |
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
|
1737 |
if (dmg > 1) and (gi^.Kind = gtHedgehog) then |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1738 |
if (CurrentHedgehog^.Gear = gi) and (not gi^.Invulnerable) then |
1867 | 1739 |
gi^.State:= gi^.State or gstLoser |
1865
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1740 |
else |
ebc6dfca60d4
- nemo's patch: some animations, zero probability for infinite weapons
unc0rr
parents:
1861
diff
changeset
|
1741 |
gi^.State:= gi^.State or gstWinner; |
1110 | 1742 |
gi:= gi^.NextGear |
1743 |
end; |
|
1744 |
Gear^.doStep:= @doStepCakeExpl; |
|
1669 | 1745 |
PlaySound(sndCake, false, nil) |
1109 | 1746 |
end else dec(Gear^.Pos) |
1747 |
end; |
|
1748 |
||
1749 |
||
1089 | 1750 |
procedure doStepCakeWork(Gear: PGear); |
1751 |
const dirs: array[0..3] of TPoint = ((x: 0; y: -1), (x: 1; y: 0),(x: 0; y: 1),(x: -1; y: 0)); |
|
1752 |
var xx, yy, xxn, yyn: LongInt; |
|
1753 |
da: LongInt; |
|
1103 | 1754 |
tdx, tdy: hwFloat; |
1089 | 1755 |
|
1756 |
procedure PrevAngle; |
|
1757 |
begin |
|
1133 | 1758 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 - dA) mod 4 |
1089 | 1759 |
end; |
1760 |
||
1761 |
procedure NextAngle; |
|
1762 |
begin |
|
1133 | 1763 |
Gear^.Angle:= (LongInt(Gear^.Angle) + 4 + dA) mod 4 |
1089 | 1764 |
end; |
1765 |
||
1088 | 1766 |
begin |
1089 | 1767 |
inc(Gear^.Tag); |
1108 | 1768 |
if Gear^.Tag < 7 then exit; |
1089 | 1769 |
|
1770 |
dA:= hwSign(Gear^.dX); |
|
1771 |
xx:= dirs[Gear^.Angle].x; |
|
1772 |
yy:= dirs[Gear^.Angle].y; |
|
1133 | 1773 |
xxn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].x; |
1774 |
yyn:= dirs[(LongInt(Gear^.Angle) + 4 + dA) mod 4].y; |
|
1089 | 1775 |
|
1776 |
if (xx = 0) then |
|
1777 |
if TestCollisionYwithGear(Gear, yy) then |
|
1778 |
PrevAngle |
|
1779 |
else begin |
|
1780 |
Gear^.Tag:= 0; |
|
1781 |
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
|
1782 |
if not TestCollisionXwithGear(Gear, xxn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1783 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1784 |
Gear^.X:= Gear^.X + int2hwFloat(xxn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1785 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1786 |
end; |
1089 | 1787 |
end; |
1788 |
||
1789 |
if (yy = 0) then |
|
1790 |
if TestCollisionXwithGear(Gear, xx) then |
|
1791 |
PrevAngle |
|
1792 |
else begin |
|
1793 |
Gear^.Tag:= 0; |
|
1794 |
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
|
1795 |
if not TestCollisionYwithGear(Gear, yyn) then |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1796 |
begin |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1797 |
Gear^.Y:= Gear^.Y + int2hwFloat(yyn); |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1798 |
NextAngle |
cc5976f292f9
Cake makes a step after turn. This fixes cake stucking in air
unc0rr
parents:
1634
diff
changeset
|
1799 |
end; |
1089 | 1800 |
end; |
1801 |
||
1103 | 1802 |
if Gear^.Tag = 0 then |
1803 |
begin |
|
1804 |
CakeI:= (CakeI + 1) mod cakeh; |
|
1805 |
tdx:= CakePoints[CakeI].x - Gear^.X; |
|
1806 |
tdy:= - CakePoints[CakeI].y + Gear^.Y; |
|
1807 |
CakePoints[CakeI].x:= Gear^.X; |
|
1808 |
CakePoints[CakeI].y:= Gear^.Y; |
|
1809 |
Gear^.DirAngle:= DxDy2Angle(tdx, tdy); |
|
1810 |
end; |
|
1811 |
||
1089 | 1812 |
dec(Gear^.Health); |
1090 | 1813 |
if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then |
1089 | 1814 |
begin |
1109 | 1815 |
FollowGear:= Gear; |
1816 |
Gear^.doStep:= @doStepCakeDown |
|
1089 | 1817 |
end |
1088 | 1818 |
end; |
1089 | 1819 |
|
1103 | 1820 |
procedure doStepCakeUp(Gear: PGear); |
1821 |
var i: Longword; |
|
1822 |
begin |
|
1823 |
AllInactive:= false; |
|
1824 |
||
1108 | 1825 |
inc(Gear^.Tag); |
1109 | 1826 |
if Gear^.Tag < 100 then exit; |
1108 | 1827 |
Gear^.Tag:= 0; |
1828 |
||
1109 | 1829 |
if Gear^.Pos = 6 then |
1103 | 1830 |
begin |
1831 |
for i:= 0 to Pred(cakeh) do |
|
1832 |
begin |
|
1833 |
CakePoints[i].x:= Gear^.X; |
|
1834 |
CakePoints[i].y:= Gear^.Y |
|
1835 |
end; |
|
1836 |
CakeI:= 0; |
|
1837 |
Gear^.doStep:= @doStepCakeWork |
|
1109 | 1838 |
end else inc(Gear^.Pos) |
1103 | 1839 |
end; |
1840 |
||
1089 | 1841 |
procedure doStepCakeFall(Gear: PGear); |
1842 |
begin |
|
1843 |
AllInactive:= false; |
|
1844 |
||
1845 |
Gear^.dY:= Gear^.dY + cGravity; |
|
1846 |
if TestCollisionYwithGear(Gear, 1) then |
|
1103 | 1847 |
Gear^.doStep:= @doStepCakeUp |
1089 | 1848 |
else |
1849 |
begin |
|
1850 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1851 |
if CheckGearDrowning(Gear) then AfterAttack |
|
1852 |
end |
|
1853 |
end; |
|
1854 |
||
1855 |
procedure doStepCake(Gear: PGear); |
|
1856 |
var HHGear: PGear; |
|
1857 |
begin |
|
1858 |
AllInactive:= false; |
|
1859 |
||
1860 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
1103 | 1861 |
HHGear^.Message:= HHGear^.Message and (not gm_Attack); |
1089 | 1862 |
DeleteCI(HHGear); |
1863 |
||
1106 | 1864 |
FollowGear:= Gear; |
1865 |
||
1089 | 1866 |
Gear^.doStep:= @doStepCakeFall |
1867 |
end; |
|
1868 |
||
1259 | 1869 |
//////////////////////////////////////////////////////////////////////////////// |
1284 | 1870 |
procedure doStepSeductionWork(Gear: PGear); |
1871 |
var x, y: LongInt; |
|
1259 | 1872 |
begin |
1873 |
AllInactive:= false; |
|
1284 | 1874 |
|
1875 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1876 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1877 |
x:= hwRound(Gear^.X); |
|
1878 |
y:= hwRound(Gear^.Y); |
|
1259 | 1879 |
|
1753 | 1880 |
if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then |
1284 | 1881 |
if (Land[y, x] <> 0) then |
1882 |
begin |
|
1883 |
Gear^.dX.isNegative:= not Gear^.dX.isNegative; |
|
1884 |
Gear^.dY.isNegative:= not Gear^.dY.isNegative; |
|
1286 | 1885 |
Gear^.dX:= Gear^.dX * _1_5; |
1886 |
Gear^.dY:= Gear^.dY * _1_5 - _0_3; |
|
1284 | 1887 |
AmmoShove(Gear, 0, 40); |
1286 | 1888 |
AfterAttack; |
1284 | 1889 |
DeleteGear(Gear) |
1890 |
end |
|
1891 |
else |
|
1892 |
else |
|
1286 | 1893 |
begin |
1894 |
AfterAttack; |
|
1284 | 1895 |
DeleteGear(Gear) |
1286 | 1896 |
end |
1897 |
end; |
|
1898 |
||
1899 |
procedure doStepSeductionWear(Gear: PGear); |
|
1900 |
begin |
|
1901 |
AllInactive:= false; |
|
1902 |
inc(Gear^.Timer); |
|
1903 |
if Gear^.Timer > 250 then |
|
1904 |
begin |
|
1905 |
Gear^.Timer:= 0; |
|
1388 | 1906 |
inc(Gear^.Pos); |
1907 |
if Gear^.Pos = 5 then |
|
1669 | 1908 |
PlaySound(sndYoohoo, false, PHedgehog(Gear^.Hedgehog)^.Team^.voicepack) |
1286 | 1909 |
end; |
1367 | 1910 |
|
1911 |
if Gear^.Pos = 14 then |
|
1286 | 1912 |
Gear^.doStep:= @doStepSeductionWork |
1259 | 1913 |
end; |
1284 | 1914 |
|
1915 |
procedure doStepSeduction(Gear: PGear); |
|
1916 |
begin |
|
1917 |
AllInactive:= false; |
|
1918 |
DeleteCI(PHedgehog(Gear^.Hedgehog)^.Gear); |
|
1286 | 1919 |
Gear^.doStep:= @doStepSeductionWear |
1284 | 1920 |
end; |
1298 | 1921 |
|
1922 |
//////////////////////////////////////////////////////////////////////////////// |
|
1923 |
procedure doStepWaterUp(Gear: PGear); |
|
1924 |
var i: LongWord; |
|
1925 |
begin |
|
1926 |
AllInactive:= false; |
|
1927 |
||
1928 |
inc(Gear^.Timer); |
|
1929 |
if Gear^.Timer = 17 then |
|
1930 |
Gear^.Timer:= 0 |
|
1931 |
else |
|
1932 |
exit; |
|
1933 |
||
1934 |
if cWaterLine > 0 then |
|
1935 |
begin |
|
1936 |
dec(cWaterLine); |
|
1760 | 1937 |
for i:= 0 to LAND_WIDTH - 1 do |
1298 | 1938 |
Land[cWaterLine, i]:= 0; |
1939 |
SetAllToActive |
|
1940 |
end; |
|
1941 |
||
1942 |
inc(Gear^.Tag); |
|
1343 | 1943 |
if (Gear^.Tag = 47) or (cWaterLine = 0) then |
1298 | 1944 |
DeleteGear(Gear) |
1945 |
end; |
|
1573 | 1946 |
|
1947 |
//////////////////////////////////////////////////////////////////////////////// |
|
1590 | 1948 |
procedure doStepDrillDrilling(Gear: PGear); |
1633 | 1949 |
var t: PGearArray; |
1950 |
ox, oy: hwFloat; |
|
1573 | 1951 |
begin |
1590 | 1952 |
AllInactive:= false; |
1953 |
||
1633 | 1954 |
if (Gear^.Timer > 0) and ((Gear^.Timer mod 10) = 0) then |
1590 | 1955 |
begin |
1573 | 1956 |
ox:= Gear^.X; |
1957 |
oy:= Gear^.Y; |
|
1958 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
1959 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
1960 |
DrawTunnel(oX, oY, Gear^.dX, Gear^.dY, 2, 6); |
|
1961 |
CheckGearDrowning(Gear); |
|
1590 | 1962 |
end; |
1963 |
||
1633 | 1964 |
t:= CheckGearsCollision(Gear); //fixes drill not exploding when touching HH bug |
1590 | 1965 |
if (Gear^.Timer = 0) |
1633 | 1966 |
or (t^.Count <> 0) |
1590 | 1967 |
or (not TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) |
1784 | 1968 |
and not TestCollisionXWithGear(Gear, hwSign(Gear^.dX))) |
1969 |
or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] = COLOR_INDESTRUCTIBLE) then |
|
1590 | 1970 |
begin //out of time or exited ground |
1971 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
1972 |
DeleteGear(Gear); |
|
1973 |
exit |
|
1974 |
end; |
|
1975 |
||
1976 |
dec(Gear^.Timer); |
|
1573 | 1977 |
end; |
1978 |
||
1979 |
procedure doStepDrill(Gear: PGear); |
|
1590 | 1980 |
var t: PGearArray; |
1633 | 1981 |
oldDx, oldDy: hwFloat; |
1982 |
t2: hwFloat; |
|
1573 | 1983 |
begin |
1590 | 1984 |
AllInactive:= false; |
1573 | 1985 |
|
1590 | 1986 |
Gear^.dX:= Gear^.dX + cWindSpeed; |
1987 |
oldDx:= Gear^.dX; |
|
1988 |
oldDy:= Gear^.dY; |
|
1989 |
||
1990 |
doStepFallingGear(Gear); |
|
1991 |
||
1992 |
if (GameTicks and $3F) = 0 then |
|
1993 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1573 | 1994 |
|
1633 | 1995 |
if ((Gear^.State and gstCollision) <> 0) then begin //hit |
1590 | 1996 |
Gear^.dX:= oldDx; |
1997 |
Gear^.dY:= oldDy; |
|
1633 | 1998 |
|
1590 | 1999 |
t:= CheckGearsCollision(Gear); |
1633 | 2000 |
if (t^.Count = 0) then begin //hit the ground not the HH |
2001 |
t2 := _0_5 / Distance(Gear^.dX, Gear^.dY); |
|
2002 |
Gear^.dX:= Gear^.dX * t2; |
|
2003 |
Gear^.dY:= Gear^.dY * t2; |
|
2004 |
end else begin //explode right on contact with HH |
|
2005 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound); |
|
2006 |
DeleteGear(Gear); |
|
2007 |
exit; |
|
2008 |
end; |
|
2009 |
||
1590 | 2010 |
Gear^.doStep:= @doStepDrillDrilling; |
1633 | 2011 |
dec(Gear^.Timer) |
1590 | 2012 |
end |
2013 |
end; |
|
1601 | 2014 |
|
1633 | 2015 |
//////////////////////////////////////////////////////////////////////////////// |
1601 | 2016 |
procedure doStepBallgunWork(Gear: PGear); |
2017 |
var HHGear: PGear; |
|
1630 | 2018 |
rx, ry: hwFloat; |
1601 | 2019 |
begin |
2020 |
AllInactive:= false; |
|
2021 |
dec(Gear^.Timer); |
|
2022 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2023 |
HedgehogChAngle(HHGear); |
|
2024 |
if (Gear^.Timer mod 100) = 0 then |
|
2025 |
begin |
|
1630 | 2026 |
rx:= rndSign(getRandom * _0_1); |
2027 |
ry:= rndSign(getRandom * _0_1); |
|
1631
6e313b3818ef
Remove debug stuff, ballgun 64but incompatibility fixed in previous revision
unc0rr
parents:
1630
diff
changeset
|
2028 |
|
1630 | 2029 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBall, 0, |
2030 |
SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, |
|
2031 |
AngleCos(HHGear^.Angle) * ( - _0_8) + ry, |
|
2032 |
0); |
|
1601 | 2033 |
|
1669 | 2034 |
PlaySound(sndGun, false, nil); |
1601 | 2035 |
end; |
2036 |
||
1643 | 2037 |
if (Gear^.Timer = 0) or (HHGear^.Damage <> 0) then |
1601 | 2038 |
begin |
2039 |
DeleteGear(Gear); |
|
1643 | 2040 |
AfterAttack |
2041 |
end |
|
1601 | 2042 |
end; |
2043 |
||
2044 |
procedure doStepBallgun(Gear: PGear); |
|
2045 |
var HHGear: PGear; |
|
2046 |
begin |
|
2047 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2048 |
HHGear^.Message:= HHGear^.Message and not (gm_Up or gm_Down); |
|
2049 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2050 |
Gear^.doStep:= @doStepBallgunWork |
|
1633 | 2051 |
end; |
1689 | 2052 |
|
1696 | 2053 |
//////////////////////////////////////////////////////////////////////////////// |
1689 | 2054 |
procedure doStepRCPlaneWork(Gear: PGear); |
2055 |
const cAngleSpeed = 3; |
|
2056 |
var HHGear: PGear; |
|
2057 |
i: LongInt; |
|
2058 |
dX, dY: hwFloat; |
|
2059 |
fChanged: boolean; |
|
2060 |
trueAngle: Longword; |
|
2061 |
t: PGear; |
|
2062 |
begin |
|
2063 |
AllInactive:= false; |
|
2064 |
||
1696 | 2065 |
if Gear^.Timer > 0 then dec(Gear^.Timer); |
1689 | 2066 |
|
2067 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2068 |
FollowGear:= Gear; |
|
2069 |
||
2070 |
fChanged:= false; |
|
1696 | 2071 |
if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then |
1689 | 2072 |
begin |
2073 |
fChanged:= true; |
|
1696 | 2074 |
if Gear^.Angle > 2048 then dec(Gear^.Angle) else |
2075 |
if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false |
|
2076 |
end |
|
2077 |
else |
|
2078 |
begin |
|
2079 |
if ((Gear^.Message and gm_Left) <> 0) then |
|
2080 |
begin |
|
2081 |
fChanged:= true; |
|
2082 |
Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096 |
|
2083 |
end; |
|
1689 | 2084 |
|
1696 | 2085 |
if ((Gear^.Message and gm_Right) <> 0) then |
2086 |
begin |
|
2087 |
fChanged:= true; |
|
2088 |
Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096 |
|
2089 |
end |
|
1689 | 2090 |
end; |
2091 |
||
2092 |
if fChanged then |
|
2093 |
begin |
|
2094 |
Gear^.dX.isNegative:= (Gear^.Angle > 2048); |
|
2095 |
if Gear^.dX.isNegative then |
|
2096 |
trueAngle:= 4096 - Gear^.Angle |
|
2097 |
else |
|
2098 |
trueAngle:= Gear^.Angle; |
|
2099 |
||
2100 |
Gear^.dX:= SignAs(AngleSin(trueAngle), Gear^.dX) * _0_25; |
|
2101 |
Gear^.dY:= AngleCos(trueAngle) * -_0_25; |
|
2102 |
end; |
|
2103 |
||
2104 |
Gear^.X:= Gear^.X + Gear^.dX; |
|
2105 |
Gear^.Y:= Gear^.Y + Gear^.dY; |
|
2106 |
||
2107 |
if (GameTicks and $FF) = 0 then |
|
1698 | 2108 |
if Gear^.Timer < 3500 then |
1696 | 2109 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0) |
2110 |
else |
|
2111 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0); |
|
1689 | 2112 |
|
1696 | 2113 |
if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then |
1689 | 2114 |
begin |
2115 |
HHGear^.Message := HHGear^.Message and not gm_Attack; |
|
1708 | 2116 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0); |
1689 | 2117 |
dec(Gear^.Health) |
1712 | 2118 |
end; |
2119 |
||
2120 |
if ((HHGear^.Message and gm_LJump) <> 0) |
|
2121 |
and ((Gear^.State and gsttmpFlag) = 0) then |
|
2122 |
begin |
|
2123 |
Gear^.State:= Gear^.State or gsttmpFlag; |
|
2124 |
PauseMusic; |
|
2125 |
playSound(sndRideOfTheValkyries, false, nil); |
|
2126 |
end; |
|
1689 | 2127 |
|
2128 |
// pickup bonuses |
|
2129 |
t:= CheckGearNear(Gear, gtCase, 36, 36); |
|
2130 |
if t <> nil then |
|
2131 |
PickUp(HHGear, t); |
|
2132 |
||
2133 |
CheckCollision(Gear); |
|
2134 |
||
1712 | 2135 |
if ((Gear^.State and gstCollision) <> 0) |
2136 |
or CheckGearDrowning(Gear) then |
|
1689 | 2137 |
begin |
1712 | 2138 |
StopSound(sndRCPlane); |
2139 |
StopSound(sndRideOfTheValkyries); |
|
2140 |
ResumeMusic; |
|
2141 |
||
2142 |
if ((Gear^.State and gstCollision) <> 0) then |
|
1689 | 2143 |
begin |
1712 | 2144 |
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound); |
1714 | 2145 |
for i:= 0 to 32 do |
1712 | 2146 |
begin |
1714 | 2147 |
dX:= AngleCos(i * 64) * _0_5 * (GetRandom + _1); |
2148 |
dY:= AngleSin(i * 64) * _0_5 * (GetRandom + _1); |
|
1712 | 2149 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0); |
2150 |
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0); |
|
2151 |
end; |
|
2152 |
DeleteGear(Gear) |
|
1689 | 2153 |
end; |
1713 | 2154 |
|
1689 | 2155 |
AfterAttack; |
1713 | 2156 |
CurAmmoGear:= nil; |
1697 | 2157 |
TurnTimeLeft:= 14 * 125; |
1712 | 2158 |
HHGear^.Message:= 0; |
1697 | 2159 |
ParseCommand('/taunt '#1, true) |
2160 |
end |
|
1689 | 2161 |
end; |
2162 |
||
2163 |
procedure doStepRCPlane(Gear: PGear); |
|
2164 |
var HHGear: PGear; |
|
2165 |
begin |
|
2166 |
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear; |
|
2167 |
HHGear^.Message:= 0; |
|
2168 |
HHGear^.State:= HHGear^.State or gstNotKickable; |
|
2169 |
Gear^.Angle:= HHGear^.Angle; |
|
1696 | 2170 |
Gear^.Tag:= hwSign(HHGear^.dX); |
1689 | 2171 |
if HHGear^.dX.isNegative then Gear^.Angle:= 4096 - Gear^.Angle; |
2172 |
Gear^.doStep:= @doStepRCPlaneWork |
|
1712 | 2173 |
end; |