261 begin |
261 begin |
262 AllInactive := false; |
262 AllInactive := false; |
263 Gear^.Y := Gear^.Y + cDrownSpeed; |
263 Gear^.Y := Gear^.Y + cDrownSpeed; |
264 Gear^.X := Gear^.X + Gear^.dX * cDrownSpeed; |
264 Gear^.X := Gear^.X + Gear^.dX * cDrownSpeed; |
265 // Create some bubbles (0.5% might be better but causes too few bubbles sometimes) |
265 // Create some bubbles (0.5% might be better but causes too few bubbles sometimes) |
266 if (((not SuddenDeathDmg) and (WaterOpacity < $FF)) |
266 if ((not SuddenDeathDmg and (WaterOpacity < $FF)) |
267 or (SuddenDeathDmg and (SDWaterOpacity < $FF))) and ((GameTicks and $1F) = 0) then |
267 or (SuddenDeathDmg and (SDWaterOpacity < $FF))) and ((GameTicks and $1F) = 0) then |
268 if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then |
268 if (Gear^.Kind = gtHedgehog) and (Random(4) = 0) then |
269 AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble) |
269 AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble) |
270 else if Random(12) = 0 then |
270 else if Random(12) = 0 then |
271 AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble); |
271 AddVisualGear(hwRound(Gear^.X) - Gear^.Radius, hwRound(Gear^.Y) - Gear^.Radius, vgtBubble); |
272 if ((not SuddenDeathDmg) and (WaterOpacity > $FE)) |
272 if (not SuddenDeathDmg and (WaterOpacity > $FE)) |
273 or (SuddenDeathDmg and (SDWaterOpacity > $FE)) |
273 or (SuddenDeathDmg and (SDWaterOpacity > $FE)) |
274 or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then |
274 or (hwRound(Gear^.Y) > Gear^.Radius + cWaterLine + cVisibleWater) then |
275 DeleteGear(Gear); |
275 DeleteGear(Gear); |
276 end; |
276 end; |
277 |
277 |
278 //////////////////////////////////////////////////////////////////////////////// |
278 //////////////////////////////////////////////////////////////////////////////// |
279 procedure doStepFallingGear(Gear: PGear); |
279 procedure doStepFallingGear(Gear: PGear); |
280 var |
280 var |
281 isFalling: boolean; |
281 isFalling: boolean; |
282 //tmp: QWord; |
282 //tmp: QWord; |
283 tdX, tdY: hwFloat; |
283 tX, tdX, tdY: hwFloat; |
284 collV, collH: LongInt; |
284 collV, collH, gX, gY: LongInt; |
285 land: word; |
285 land, xland: word; |
286 begin |
286 boing: PVisualGear; |
287 WorldWrap(Gear); |
287 begin |
|
288 tX:= Gear^.X; |
|
289 gX:= hwRound(Gear^.X); |
|
290 gY:= hwRound(Gear^.Y); |
|
291 if (Gear^.Kind <> gtGenericFaller) and WorldWrap(Gear) and (WorldEdge = weWrap) and (Gear^.AdvBounce <> 0) and |
|
292 ((TestCollisionXwithGear(Gear, 1) <> 0) or (TestCollisionXwithGear(Gear, -1) <> 0)) then |
|
293 begin |
|
294 Gear^.X:= tX; |
|
295 Gear^.dX.isNegative:= (gX > LongInt(leftX) + Gear^.Radius*2) |
|
296 end; |
288 |
297 |
289 // clip velocity at 2 - over 1 per pixel, but really shouldn't cause many actual problems. |
298 // clip velocity at 2 - over 1 per pixel, but really shouldn't cause many actual problems. |
290 {$IFNDEF WEBGL} |
|
291 if Gear^.dX.Round > 2 then |
299 if Gear^.dX.Round > 2 then |
292 Gear^.dX.QWordValue:= 8589934592; |
300 Gear^.dX.QWordValue:= 8589934592; |
293 if Gear^.dY.Round > 2 then |
301 if Gear^.dY.Round > 2 then |
294 Gear^.dY.QWordValue:= 8589934592; |
302 Gear^.dY.QWordValue:= 8589934592; |
295 {$ELSE} |
303 |
296 if Gear^.dX.Round > 2 then |
304 if (Gear^.State and gstSubmersible <> 0) and (gY > cWaterLine) then |
297 begin |
305 begin |
298 Gear^.dX.Round:= 2; |
306 Gear^.dX:= Gear^.dX * _0_999; |
299 Gear^.dX.Frac:= 0 |
307 Gear^.dY:= Gear^.dY * _0_999 |
300 end; |
308 end; |
301 if Gear^.dY.QWordValue > 2 then |
309 |
302 begin |
|
303 Gear^.dY.Round:= 2; |
|
304 Gear^.dY.Frac:= 0 |
|
305 end; |
|
306 {$ENDIF} |
|
307 Gear^.State := Gear^.State and (not gstCollision); |
310 Gear^.State := Gear^.State and (not gstCollision); |
308 collV := 0; |
311 collV := 0; |
309 collH := 0; |
312 collH := 0; |
310 tdX := Gear^.dX; |
313 tdX := Gear^.dX; |
311 tdY := Gear^.dY; |
314 tdY := Gear^.dY; |
312 |
315 |
313 // might need some testing/adjustments - just to avoid projectiles to fly forever (accelerated by wind/skips) |
316 // might need some testing/adjustments - just to avoid projectiles to fly forever (accelerated by wind/skips) |
314 if (hwRound(Gear^.X) < min(LAND_WIDTH div -2, -2048)) |
317 if (gX < min(LAND_WIDTH div -2, -2048)) |
315 or (hwRound(Gear^.X) > max(LAND_WIDTH * 3 div 2, 6144)) then |
318 or (gX > max(LAND_WIDTH * 3 div 2, 6144)) then |
316 Gear^.State := Gear^.State or gstCollision; |
319 Gear^.State := Gear^.State or gstCollision; |
317 |
320 |
318 if Gear^.dY.isNegative then |
321 if Gear^.dY.isNegative then |
319 begin |
322 begin |
320 isFalling := true; |
|
321 land:= TestCollisionYwithGear(Gear, -1); |
323 land:= TestCollisionYwithGear(Gear, -1); |
|
324 isFalling := land = 0; |
322 if land <> 0 then |
325 if land <> 0 then |
323 begin |
326 begin |
324 collV := -1; |
327 collV := -1; |
325 if land and lfIce <> 0 then |
328 if land and lfIce <> 0 then |
326 Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) |
329 Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) |
327 else |
330 else Gear^.dX := Gear^.dX * Gear^.Friction; |
328 Gear^.dX := Gear^.dX * Gear^.Friction; |
331 if (Gear^.AdvBounce = 0) or (land and lfBouncy = 0) then |
329 |
332 begin |
330 Gear^.dY := - Gear^.dY * Gear^.Elasticity; |
333 Gear^.dY := - Gear^.dY * Gear^.Elasticity; |
331 Gear^.State := Gear^.State or gstCollision |
334 Gear^.State := Gear^.State or gstCollision |
|
335 end |
|
336 else Gear^.dY := - Gear^.dY * cElastic |
332 end |
337 end |
333 else if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, 1) <> 0) then |
338 else if Gear^.AdvBounce = 1 then |
334 collV := 1; |
339 begin |
|
340 land:= TestCollisionYwithGear(Gear, 1); |
|
341 if land <> 0 then collV := 1 |
|
342 end |
335 end |
343 end |
336 else |
344 else |
337 begin // Gear^.dY.isNegative is false |
345 begin // Gear^.dY.isNegative is false |
338 land:= TestCollisionYwithGear(Gear, 1); |
346 land:= TestCollisionYwithGear(Gear, 1); |
339 if land <> 0 then |
347 if land <> 0 then |
343 if land and lfIce <> 0 then |
351 if land and lfIce <> 0 then |
344 Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) |
352 Gear^.dX := Gear^.dX * (_0_9 + Gear^.Friction * _0_1) |
345 else |
353 else |
346 Gear^.dX := Gear^.dX * Gear^.Friction; |
354 Gear^.dX := Gear^.dX * Gear^.Friction; |
347 |
355 |
348 Gear^.dY := - Gear^.dY * Gear^.Elasticity; |
356 if (Gear^.AdvBounce = 0) or (land and lfBouncy = 0) then |
|
357 begin |
|
358 Gear^.dY := - Gear^.dY * Gear^.Elasticity; |
|
359 Gear^.State := Gear^.State or gstCollision |
|
360 end |
|
361 else Gear^.dY := - Gear^.dY * cElastic |
|
362 end |
|
363 else |
|
364 begin |
|
365 isFalling := true; |
|
366 if Gear^.AdvBounce = 1 then |
|
367 begin |
|
368 land:= TestCollisionYwithGear(Gear, -1); |
|
369 if land <> 0 then collV := -1 |
|
370 end |
|
371 end |
|
372 end; |
|
373 |
|
374 |
|
375 xland:= TestCollisionXwithGear(Gear, hwSign(Gear^.dX)); |
|
376 if xland <> 0 then |
|
377 begin |
|
378 collH := hwSign(Gear^.dX); |
|
379 if (Gear^.AdvBounce = 0) or (xland and lfBouncy = 0) then |
|
380 begin |
|
381 Gear^.dX := - Gear^.dX * Gear^.Elasticity; |
|
382 Gear^.dY := Gear^.dY * Gear^.Elasticity; |
349 Gear^.State := Gear^.State or gstCollision |
383 Gear^.State := Gear^.State or gstCollision |
350 end |
384 end |
351 else |
385 else |
352 begin |
386 begin |
353 isFalling := true; |
387 Gear^.dX := - Gear^.dX * cElastic; |
354 if (Gear^.AdvBounce=1) and (TestCollisionYwithGear(Gear, -1) <> 0) then |
388 Gear^.dY := Gear^.dY * cElastic |
355 collV := -1 |
|
356 end |
389 end |
357 end; |
390 end |
358 |
391 else if Gear^.AdvBounce = 1 then |
359 |
392 begin |
360 if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
393 xland:= TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)); |
361 begin |
394 if xland <> 0 then collH := -hwSign(Gear^.dX) |
362 collH := hwSign(Gear^.dX); |
395 end; |
363 Gear^.dX := - Gear^.dX * Gear^.Elasticity; |
|
364 Gear^.dY := Gear^.dY * Gear^.Elasticity; |
|
365 Gear^.State := Gear^.State or gstCollision |
|
366 end |
|
367 else if (Gear^.AdvBounce=1) and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then |
|
368 collH := -hwSign(Gear^.dX); |
|
369 //if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then |
396 //if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then |
370 if (Gear^.AdvBounce=1) and (collV <>0) and (collH <> 0) and ((collV=-1) |
397 if (collV <> 0) and (collH <> 0) and |
371 or ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue)) then |
398 (((Gear^.AdvBounce=1) and ((collV=-1) or ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue)))) then |
372 begin |
399 //or ((xland or land) and lfBouncy <> 0)) then |
373 Gear^.dX := tdY*Gear^.Elasticity*Gear^.Friction; |
400 begin |
374 Gear^.dY := tdX*Gear^.Elasticity; |
401 if (xland or land) and lfBouncy = 0 then |
375 //*Gear^.Friction; |
402 begin |
376 Gear^.dY.isNegative := (not tdY.isNegative); |
403 Gear^.dX := tdY*Gear^.Elasticity*Gear^.Friction; |
|
404 Gear^.dY := tdX*Gear^.Elasticity; |
|
405 Gear^.State := Gear^.State or gstCollision |
|
406 end |
|
407 else |
|
408 begin |
|
409 Gear^.dX := tdY*cElastic*Gear^.Friction; |
|
410 Gear^.dY := tdX*cElastic |
|
411 end; |
|
412 |
|
413 Gear^.dY.isNegative := not tdY.isNegative; |
377 isFalling := false; |
414 isFalling := false; |
378 Gear^.AdvBounce := 10; |
415 Gear^.AdvBounce := 10; |
379 end; |
416 end; |
380 |
417 |
381 if Gear^.AdvBounce > 1 then |
418 if Gear^.AdvBounce > 1 then |
384 if isFalling then |
421 if isFalling then |
385 begin |
422 begin |
386 Gear^.dY := Gear^.dY + cGravity; |
423 Gear^.dY := Gear^.dY + cGravity; |
387 if (GameFlags and gfMoreWind) <> 0 then |
424 if (GameFlags and gfMoreWind) <> 0 then |
388 Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density |
425 Gear^.dX := Gear^.dX + cWindSpeed / Gear^.Density |
389 end; |
426 end; |
390 |
427 |
391 Gear^.X := Gear^.X + Gear^.dX; |
428 Gear^.X := Gear^.X + Gear^.dX; |
392 Gear^.Y := Gear^.Y + Gear^.dY; |
429 Gear^.Y := Gear^.Y + Gear^.dY; |
393 CheckGearDrowning(Gear); |
430 CheckGearDrowning(Gear); |
394 //if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
431 //if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
395 if (not isFalling) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) then |
432 if (not isFalling) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) then |
396 Gear^.State := Gear^.State and (not gstMoving) |
433 Gear^.State := Gear^.State and (not gstMoving) |
397 else |
434 else |
398 Gear^.State := Gear^.State or gstMoving; |
435 Gear^.State := Gear^.State or gstMoving; |
399 |
436 |
400 if (Gear^.nImpactSounds > 0) and |
437 if ((xland or land) and lfBouncy <> 0) and (Gear^.dX.QWordValue < _0_15.QWordValue) and (Gear^.dY.QWordValue < _0_15.QWordValue) then |
|
438 Gear^.State := Gear^.State or gstCollision; |
|
439 |
|
440 if ((xland or land) and lfBouncy <> 0) and (Gear^.Radius >= 3) and |
|
441 ((Gear^.dX.QWordValue > _0_15.QWordValue) or (Gear^.dY.QWordValue > _0_15.QWordValue)) then |
|
442 begin |
|
443 boing:= AddVisualGear(gX, gY, vgtStraightShot, 0, false, 1); |
|
444 if boing <> nil then |
|
445 with boing^ do |
|
446 begin |
|
447 Angle:= random(360); |
|
448 dx:= 0; |
|
449 dy:= 0; |
|
450 FrameTicks:= 200; |
|
451 tX:= _0; |
|
452 tX.QWordValue:= Gear^.dY.QWordValue + Gear^.dX.QWordValue; |
|
453 Scale:= hwFloat2Float(Gear^.Density * tX) / 1.5; |
|
454 State:= ord(sprBoing) |
|
455 end; |
|
456 PlaySound(sndMelonImpact, true) |
|
457 end |
|
458 else if (Gear^.nImpactSounds > 0) and |
401 (Gear^.State and gstCollision <> 0) and |
459 (Gear^.State and gstCollision <> 0) and |
402 (((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or (Gear^.State and gstMoving <> 0)) and |
460 (((Gear^.Kind <> gtMine) and (Gear^.Damage <> 0)) or (Gear^.State and gstMoving <> 0)) and |
403 (((Gear^.Radius < 3) and (Gear^.dY < -_0_1)) or |
461 (((Gear^.Radius < 3) and (Gear^.dY < -_0_1)) or |
404 ((Gear^.Radius >= 3) and |
462 ((Gear^.Radius >= 3) and |
405 ((Gear^.dX.QWordValue > _0_1.QWordValue) or (Gear^.dY.QWordValue > _0_1.QWordValue)))) then |
463 ((Gear^.dX.QWordValue > _0_1.QWordValue) or (Gear^.dY.QWordValue > _0_1.QWordValue)))) then |
862 end; |
927 end; |
863 |
928 |
864 AllInactive := false; |
929 AllInactive := false; |
865 |
930 |
866 if Gear^.dY.isNegative then |
931 if Gear^.dY.isNegative then |
867 if TestCollisionY(Gear, -1) then |
932 if TestCollisionY(Gear, -1) <> 0 then |
868 Gear^.dY := _0; |
933 Gear^.dY := _0; |
869 |
934 |
870 if (not Gear^.dY.isNegative) then |
935 if not Gear^.dY.isNegative then |
871 if TestCollisionY(Gear, 1) then |
936 if TestCollisionY(Gear, 1) <> 0 then |
872 begin |
937 begin |
873 Gear^.dY := - Gear^.dY * Gear^.Elasticity; |
938 Gear^.dY := - Gear^.dY * Gear^.Elasticity; |
874 if Gear^.dY > - _1div1024 then |
939 if Gear^.dY > - _1div1024 then |
875 begin |
940 begin |
876 Gear^.Active := false; |
941 Gear^.Active := false; |
877 exit |
942 exit |
878 end |
943 end |
879 else if Gear^.dY < - _0_03 then |
944 else if Gear^.dY < - _0_03 then |
880 PlaySound(Gear^.ImpactSound) |
945 PlaySound(Gear^.ImpactSound) |
881 end; |
946 end; |
882 |
947 |
883 Gear^.Y := Gear^.Y + Gear^.dY; |
948 Gear^.Y := Gear^.Y + Gear^.dY; |
884 CheckGearDrowning(Gear); |
949 CheckGearDrowning(Gear); |
885 Gear^.dY := Gear^.dY + cGravity |
950 Gear^.dY := Gear^.dY + cGravity |
886 end; |
951 end; |
922 end; |
987 end; |
923 end; |
988 end; |
924 |
989 |
925 |
990 |
926 if Gear^.Timer = 0 then |
991 if Gear^.Timer = 0 then |
927 Gear^.RenderTimer:= false |
992 begin |
|
993 // no "fuel"? just fall |
|
994 doStepFallingGear(Gear); |
|
995 // if drowning, stop bee sound |
|
996 if (Gear^.State and gstDrowning) <> 0 then |
|
997 StopSoundChan(Gear^.SoundChannel); |
|
998 end |
928 else |
999 else |
929 begin |
1000 begin |
930 if (GameTicks and $F) = 0 then |
1001 if (GameTicks and $F) = 0 then |
931 begin |
1002 begin |
932 if (GameTicks and $30) = 0 then |
1003 if (GameTicks and $30) = 0 then |
933 AddVisualGear(gX, gY, vgtBeeTrace); |
1004 begin |
|
1005 if nuw then |
|
1006 AddVisualGear(gX, gY, vgtBubble) |
|
1007 else |
|
1008 AddVisualGear(gX, gY, vgtBeeTrace); |
|
1009 end; |
934 Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X - gX)); |
1010 Gear^.dX := Gear^.Elasticity * (Gear^.dX + _0_000064 * (Gear^.Target.X - gX)); |
935 Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.Target.Y - gY)); |
1011 Gear^.dY := Gear^.Elasticity * (Gear^.dY + _0_000064 * (Gear^.Target.Y - gY)); |
936 // make sure new speed isn't higher than original one (which we stored in Friction variable) |
1012 // make sure new speed isn't higher than original one (which we stored in Friction variable) |
937 t := Gear^.Friction / Distance(Gear^.dX, Gear^.dY); |
1013 t := Gear^.Friction / Distance(Gear^.dX, Gear^.dY); |
938 Gear^.dX := Gear^.dX * t; |
1014 Gear^.dX := Gear^.dX * t; |
1647 Gear^.State := Gear^.State or gsttmpFlag; |
1721 Gear^.State := Gear^.State or gsttmpFlag; |
1648 end; |
1722 end; |
1649 |
1723 |
1650 //////////////////////////////////////////////////////////////////////////////// |
1724 //////////////////////////////////////////////////////////////////////////////// |
1651 procedure doStepSMine(Gear: PGear); |
1725 procedure doStepSMine(Gear: PGear); |
|
1726 var land: Word; |
1652 begin |
1727 begin |
1653 // TODO: do real calculation? |
1728 // TODO: do real calculation? |
1654 if TestCollisionXwithGear(Gear, 2) |
1729 land:= TestCollisionXwithGear(Gear, 2); |
1655 or (TestCollisionYwithGear(Gear, -2) <> 0) |
1730 if land = 0 then land:= TestCollisionYwithGear(Gear,-2); |
1656 or TestCollisionXwithGear(Gear, -2) |
1731 if land = 0 then land:= TestCollisionXwithGear(Gear,-2); |
1657 or (TestCollisionYwithGear(Gear, 2) <> 0) then |
1732 if land = 0 then land:= TestCollisionYwithGear(Gear, 2); |
|
1733 if (land <> 0) and (land and lfBouncy = 0) then |
1658 begin |
1734 begin |
1659 if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then |
1735 if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then |
1660 begin |
1736 begin |
1661 PlaySound(sndRopeAttach); |
1737 PlaySound(sndRopeAttach); |
1662 Gear^.dX:= _0; |
1738 Gear^.dX:= _0; |
1679 if ((GameTicks and $1F) = 0) then |
1755 if ((GameTicks and $1F) = 0) then |
1680 if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then |
1756 if CheckGearNear(Gear, gtHedgehog, 46, 32) <> nil then |
1681 Gear^.State := Gear^.State or gstAttacking |
1757 Gear^.State := Gear^.State or gstAttacking |
1682 end |
1758 end |
1683 else // gstAttacking <> 0 |
1759 else // gstAttacking <> 0 |
1684 begin |
1760 begin |
1685 AllInactive := false; |
1761 AllInactive := false; |
1686 if Gear^.Timer = 0 then |
1762 if Gear^.Timer = 0 then |
1687 begin |
1763 begin |
1688 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); |
1764 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); |
1689 DeleteGear(Gear); |
1765 DeleteGear(Gear); |
1690 exit |
1766 exit |
1691 end else |
1767 end |
|
1768 else |
1692 if (Gear^.Timer and $FF) = 0 then |
1769 if (Gear^.Timer and $FF) = 0 then |
1693 PlaySound(sndMineTick); |
1770 PlaySound(sndMineTick); |
1694 |
1771 dec(Gear^.Timer); |
1695 dec(Gear^.Timer); |
|
1696 end |
1772 end |
1697 end |
1773 end |
1698 else // gsttmpFlag = 0 |
1774 else // gsttmpFlag = 0 |
1699 if (TurnTimeLeft = 0) |
1775 if ((GameFlags and gfInfAttack = 0) and ((TurnTimeLeft = 0) or (Gear^.Hedgehog^.Gear = nil))) |
1700 or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) |
1776 or ((GameFlags and gfInfAttack <> 0) and (GameTicks > Gear^.FlightTime)) then |
1701 or (Gear^.Hedgehog^.Gear = nil) then |
|
1702 Gear^.State := Gear^.State or gsttmpFlag; |
1777 Gear^.State := Gear^.State or gsttmpFlag; |
1703 end; |
1778 end; |
1704 |
1779 |
1705 //////////////////////////////////////////////////////////////////////////////// |
1780 //////////////////////////////////////////////////////////////////////////////// |
1706 procedure doStepDynamite(Gear: PGear); |
1781 procedure doStepDynamite(Gear: PGear); |
2162 for i:= Random(3) downto 0 do |
2242 for i:= Random(3) downto 0 do |
2163 AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); |
2243 AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); |
2164 end; |
2244 end; |
2165 |
2245 |
2166 // This one is interesting. I think I understand the purpose, but I wonder if a bit more fuzzy of kicking could be done with getrandom. |
2246 // This one is interesting. I think I understand the purpose, but I wonder if a bit more fuzzy of kicking could be done with getrandom. |
2167 Gear^.Timer := 100 - Gear^.Tag * 3 + GetRandom(2); |
2247 Gear^.Timer := 100 - Gear^.Tag * 3 + LongInt(GetRandom(2)); |
2168 if (Gear^.Damage > 3000+Gear^.Tag*1500) then |
2248 if (Gear^.Damage > 3000+Gear^.Tag*1500) then |
2169 Gear^.Health := 0 |
2249 Gear^.Health := 0 |
2170 end |
2250 end |
2171 end |
2251 end |
2172 end; |
2252 end; |
2173 if Gear^.Health = 0 then |
2253 if Gear^.Health = 0 then |
2174 begin |
2254 begin |
2175 gX := hwRound(Gear^.X); |
2255 gX := hwRound(Gear^.X); |
2176 gY := hwRound(Gear^.Y); |
2256 gY := hwRound(Gear^.Y); |
2177 if (not sticky) then |
2257 if not sticky then |
2178 begin |
2258 begin |
2179 if ((GameTicks and $3) = 0) and (Random(1) = 0) then |
2259 if ((GameTicks and $3) = 0) and (Random(1) = 0) then |
2180 for i:= Random(2) downto 0 do |
2260 for i:= Random(2) downto 0 do |
2181 AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); |
2261 AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke); |
2182 end |
2262 end |
2320 procedure doStepAirAttackWork(Gear: PGear); |
2401 procedure doStepAirAttackWork(Gear: PGear); |
2321 begin |
2402 begin |
2322 AllInactive := false; |
2403 AllInactive := false; |
2323 Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
2404 Gear^.X := Gear^.X + cAirPlaneSpeed * Gear^.Tag; |
2324 |
2405 |
2325 if (Gear^.Health > 0) and (not (Gear^.X < Gear^.dX)) and (Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
2406 if (Gear^.Health > 0)and(not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then |
2326 begin |
2407 begin |
2327 dec(Gear^.Health); |
2408 dec(Gear^.Health); |
2328 case Gear^.State of |
2409 case Gear^.State of |
2329 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
2410 0: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
2330 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
2411 1: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0); |
2388 doStepFallingGear(Gear); |
2469 doStepFallingGear(Gear); |
2389 if (Gear^.State and gstCollision) <> 0 then |
2470 if (Gear^.State and gstCollision) <> 0 then |
2390 begin |
2471 begin |
2391 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); |
2472 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound); |
2392 DeleteGear(Gear); |
2473 DeleteGear(Gear); |
2393 {$IFNDEF PAS2C} |
|
2394 with mobileRecord do |
2474 with mobileRecord do |
2395 if (performRumble <> nil) and (not fastUntilLag) then |
2475 if (performRumble <> nil) and (not fastUntilLag) then |
2396 performRumble(kSystemSoundID_Vibrate); |
2476 performRumble(kSystemSoundID_Vibrate); |
2397 {$ENDIF} |
|
2398 exit |
2477 exit |
2399 end; |
2478 end; |
2400 if (GameTicks and $3F) = 0 then |
2479 if (GameTicks and $3F) = 0 then |
2401 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace) |
2480 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace) |
2402 end; |
2481 end; |
2406 procedure doStepGirder(Gear: PGear); |
2485 procedure doStepGirder(Gear: PGear); |
2407 var |
2486 var |
2408 HHGear: PGear; |
2487 HHGear: PGear; |
2409 x, y, tx, ty: hwFloat; |
2488 x, y, tx, ty: hwFloat; |
2410 rx: LongInt; |
2489 rx: LongInt; |
|
2490 LandFlags: Word; |
2411 begin |
2491 begin |
2412 AllInactive := false; |
2492 AllInactive := false; |
2413 |
2493 |
2414 HHGear := Gear^.Hedgehog^.Gear; |
2494 HHGear := Gear^.Hedgehog^.Gear; |
2415 tx := int2hwFloat(Gear^.Target.X); |
2495 tx := int2hwFloat(Gear^.Target.X); |
2416 ty := int2hwFloat(Gear^.Target.Y); |
2496 ty := int2hwFloat(Gear^.Target.Y); |
2417 x := HHGear^.X; |
2497 x := HHGear^.X; |
2418 y := HHGear^.Y; |
2498 y := HHGear^.Y; |
2419 rx:= hwRound(x); |
2499 rx:= hwRound(x); |
2420 |
2500 |
|
2501 LandFlags:= 0; |
|
2502 if Gear^.AmmoType = amRubber then LandFlags:= lfBouncy |
|
2503 else if cIce then LandFlags:= lfIce; |
|
2504 |
2421 if ((Distance(tx - x, ty - y) > _256) and ((WorldEdge <> weWrap) or |
2505 if ((Distance(tx - x, ty - y) > _256) and ((WorldEdge <> weWrap) or |
2422 ( |
2506 ( |
2423 (Distance(tx - int2hwFloat(rightX+(rx-leftX)), ty - y) > _256) and |
2507 (Distance(tx - int2hwFloat(rightX+(rx-leftX)), ty - y) > _256) and |
2424 (Distance(tx - int2hwFloat(leftX-(rightX-rx)), ty - y) > _256) |
2508 (Distance(tx - int2hwFloat(leftX-(rightX-rx)), ty - y) > _256) |
2425 ))) |
2509 ))) |
2426 or (not TryPlaceOnLand(Gear^.Target.X - SpritesData[sprAmGirder].Width div 2, Gear^.Target.Y - SpritesData[sprAmGirder].Height div 2, sprAmGirder, Gear^.State, true, false)) then |
2510 or (not TryPlaceOnLand(Gear^.Target.X - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Width div 2, Gear^.Target.Y - SpritesData[Ammoz[Gear^.AmmoType].PosSprite].Height div 2, Ammoz[Gear^.AmmoType].PosSprite, Gear^.State, true, false, LandFlags)) then |
2427 begin |
2511 begin |
2428 PlaySound(sndDenied); |
2512 PlaySound(sndDenied); |
2429 HHGear^.Message := HHGear^.Message and (not gmAttack); |
2513 HHGear^.Message := HHGear^.Message and (not gmAttack); |
2430 HHGear^.State := HHGear^.State and (not gstAttacking); |
2514 HHGear^.State := HHGear^.State and (not gstAttacking); |
2431 HHGear^.State := HHGear^.State or gstHHChooseTarget; |
2515 HHGear^.State := HHGear^.State or gstHHChooseTarget; |
3070 exit |
3154 exit |
3071 end; |
3155 end; |
3072 |
3156 |
3073 tempColl:= Gear^.CollisionMask; |
3157 tempColl:= Gear^.CollisionMask; |
3074 Gear^.CollisionMask:= $007F; |
3158 Gear^.CollisionMask:= $007F; |
3075 if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) <> 0) or TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) or (GameTicks > Gear^.FlightTime) then |
3159 if (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) <> 0) or (TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) <> 0) or (GameTicks > Gear^.FlightTime) then |
3076 t := CheckGearsCollision(Gear) |
3160 t := CheckGearsCollision(Gear) |
3077 else t := nil; |
3161 else t := nil; |
3078 Gear^.CollisionMask:= tempColl; |
3162 Gear^.CollisionMask:= tempColl; |
3079 //fixes drill not exploding when touching HH bug |
3163 //fixes drill not exploding when touching HH bug |
3080 |
3164 |
3081 if (Gear^.Timer = 0) or ((t <> nil) and (t^.Count <> 0)) |
3165 if (Gear^.Timer = 0) or ((t <> nil) and (t^.Count <> 0)) |
3082 or ( ((Gear^.State and gsttmpFlag) = 0) and (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (not TestCollisionXWithGear(Gear, hwSign(Gear^.dX)))) |
3166 or ( ((Gear^.State and gsttmpFlag) = 0) and (TestCollisionYWithGear(Gear, hwSign(Gear^.dY)) = 0) and (TestCollisionXWithGear(Gear, hwSign(Gear^.dX)) = 0)) |
3083 // CheckLandValue returns true if the type isn't matched |
3167 // CheckLandValue returns true if the type isn't matched |
3084 or (not (CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y), lfIndestructible))) then |
3168 or (not CheckLandValue(hwRound(Gear^.X), hwRound(Gear^.Y), lfIndestructible)) then |
3085 begin |
3169 begin |
3086 //out of time or exited ground |
3170 //out of time or exited ground |
3087 StopSoundChan(Gear^.SoundChannel); |
3171 StopSoundChan(Gear^.SoundChannel); |
3088 if (Gear^.State and gsttmpFlag) <> 0 then |
3172 if (Gear^.State and gsttmpFlag) <> 0 then |
3089 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound) |
3173 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, Gear^.Hedgehog, EXPLAutoSound) |
3294 if Gear^.Timer < 3500 then |
3378 if Gear^.Timer < 3500 then |
3295 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEvilTrace) |
3379 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEvilTrace) |
3296 else |
3380 else |
3297 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); |
3381 AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace); |
3298 |
3382 |
3299 if ((HHGear^.Message and gmAttack) <> 0) and (Gear^.Health <> 0) then |
3383 if (HHGear <> nil) and ((HHGear^.Message and gmAttack) <> 0) and (Gear^.Health <> 0) then |
3300 begin |
3384 begin |
3301 HHGear^.Message := HHGear^.Message and (not gmAttack); |
3385 HHGear^.Message := HHGear^.Message and (not gmAttack); |
3302 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * |
3386 AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * |
3303 _0_5, 0); |
3387 _0_5, 0); |
3304 dec(Gear^.Health) |
3388 dec(Gear^.Health) |
3305 end; |
3389 end; |
3306 |
3390 |
3307 if ((HHGear^.Message and gmLJump) <> 0) and ((Gear^.State and gsttmpFlag) = 0) then |
3391 if (HHGear <> nil) and ((HHGear^.Message and gmLJump) <> 0) and ((Gear^.State and gsttmpFlag) = 0) then |
3308 begin |
3392 begin |
3309 Gear^.State := Gear^.State or gsttmpFlag; |
3393 Gear^.State := Gear^.State or gsttmpFlag; |
3310 PauseMusic; |
3394 PauseMusic; |
3311 playSound(sndRideOfTheValkyries); |
3395 playSound(sndRideOfTheValkyries); |
3312 end; |
3396 end; |
3865 iscake:= (iterator^.Kind = gtCake); |
3960 iscake:= (iterator^.Kind = gtCake); |
3866 |
3961 |
3867 // won't port stuff that does not move towards the front/portal entrance |
3962 // won't port stuff that does not move towards the front/portal entrance |
3868 if iscake then |
3963 if iscake then |
3869 begin |
3964 begin |
3870 if (not (((iterator^.X - Gear^.X)*ox + (iterator^.Y - Gear^.Y)*oy).isNegative)) then |
3965 if not (((iterator^.X - Gear^.X)*ox + (iterator^.Y - Gear^.Y)*oy).isNegative) then |
3871 continue; |
3966 continue; |
3872 end |
3967 end |
3873 else |
3968 else |
3874 if (not ((Gear^.dX*ox + Gear^.dY*oy).isNegative)) then |
3969 if not ((Gear^.dX*ox + Gear^.dY*oy).isNegative) then |
3875 continue; |
3970 continue; |
3876 |
3971 |
3877 isbullet:= (iterator^.Kind in [gtShotgunShot, gtDEagleShot, gtSniperRifleShot, gtSineGunShot]); |
3972 isbullet:= (iterator^.Kind in [gtShotgunShot, gtDEagleShot, gtSniperRifleShot, gtSineGunShot]); |
3878 |
3973 |
3879 r:= int2hwFloat(iterator^.Radius); |
3974 r:= int2hwFloat(iterator^.Radius); |
3880 |
3975 |
3881 if (not (isbullet or iscake)) then |
3976 if not (isbullet or iscake) then |
3882 begin |
3977 begin |
3883 // wow! good candidate there, let's see if the distance and direction is okay! |
3978 // wow! good candidate there, let's see if the distance and direction is okay! |
3884 if hasdxy then |
3979 if hasdxy then |
3885 begin |
3980 begin |
3886 s := Distance(iterator^.dX, iterator^.dY); |
3981 s := Distance(iterator^.dX, iterator^.dY); |
3935 ny := Gear^.dX; |
4030 ny := Gear^.dX; |
3936 // ... decide where the top is based on the hog's direction when firing the portal |
4031 // ... decide where the top is based on the hog's direction when firing the portal |
3937 if Gear^.Elasticity.isNegative then |
4032 if Gear^.Elasticity.isNegative then |
3938 nx.isNegative := (not nx.isNegative) |
4033 nx.isNegative := (not nx.isNegative) |
3939 else |
4034 else |
3940 ny.isNegative := (not ny.isNegative); |
4035 ny.isNegative := not ny.isNegative; |
3941 |
4036 |
3942 // calc gear offset in portal normal vector direction |
4037 // calc gear offset in portal normal vector direction |
3943 noffs:= (nx * ox + ny * oy); |
4038 noffs:= (nx * ox + ny * oy); |
3944 |
4039 |
3945 if isBullet and (noffs.Round >= Longword(Gear^.Radius)) then |
4040 if isBullet and (noffs.Round >= Longword(Gear^.Radius)) then |
3946 continue; |
4041 continue; |
3947 |
4042 |
3948 // avoid gravity related loops of not really moving gear |
4043 // avoid gravity related loops of not really moving gear |
3949 if (not (iscake or isbullet)) |
4044 if not (iscake or isbullet) |
3950 and (Gear^.dY.isNegative) |
4045 and (Gear^.dY.isNegative) |
3951 and (conPortal^.dY.isNegative) |
4046 and (conPortal^.dY.isNegative) |
3952 and ((iterator^.dX.QWordValue + iterator^.dY.QWordValue) < _0_08.QWordValue) |
4047 and ((iterator^.dX.QWordValue + iterator^.dY.QWordValue) < _0_08.QWordValue) |
3953 and (iterator^.PortalCounter > 0) then |
4048 and (iterator^.PortalCounter > 0) then |
3954 continue; |
4049 continue; |
4025 |
4120 |
4026 if iterator^.Radius > 1 then |
4121 if iterator^.Radius > 1 then |
4027 iterator^.Radius := iterator^.Radius - 1; |
4122 iterator^.Radius := iterator^.Radius - 1; |
4028 |
4123 |
4029 // check front |
4124 // check front |
4030 isCollision := TestCollisionY(iterator, sy) |
4125 isCollision := (TestCollisionY(iterator, sy) <> 0) or (TestCollisionX(iterator, sx) <> 0); |
4031 or TestCollisionX(iterator, sx); |
4126 |
4032 |
4127 if not isCollision then |
4033 if (not isCollision) then |
|
4034 begin |
4128 begin |
4035 // check center area (with half the radius so that the |
4129 // check center area (with half the radius so that the |
4036 // the square check won't check more pixels than we want to) |
4130 // the square check won't check more pixels than we want to) |
4037 iterator^.Radius := 1 + resetr div 2; |
4131 iterator^.Radius := 1 + resetr div 2; |
4038 rh := resetr div 4; |
4132 rh := resetr div 4; |
4039 isCollision := TestCollisionYwithXYShift(iterator, 0, -sy * rh, sy, false) |
4133 isCollision := (TestCollisionYwithXYShift(iterator, 0, -sy * rh, sy, false) <> 0) |
4040 or TestCollisionXwithXYShift(iterator, ox * rh, 0, sx, false); |
4134 or (TestCollisionXwithXYShift(iterator, ox * rh, 0, sx, false) <> 0); |
4041 end; |
4135 end; |
4042 |
4136 |
4043 iterator^.Radius := resetr; |
4137 iterator^.Radius := resetr; |
4044 |
4138 |
4045 if isCollision then |
4139 if isCollision then |
4080 resetdx.QWordValue:= 4294967296 * 1152; |
4174 resetdx.QWordValue:= 4294967296 * 1152; |
4081 |
4175 |
4082 resetdy:=hwAbs(iterator^.dX*4); |
4176 resetdy:=hwAbs(iterator^.dX*4); |
4083 resetdy:= resetdy + hwPow(resetdy,3)/_6 + _3 * hwPow(resetdy,5) / _40 + _5 * hwPow(resetdy,7) / resety + resetx * hwPow(resetdy,9) / resetdx; |
4177 resetdy:= resetdy + hwPow(resetdy,3)/_6 + _3 * hwPow(resetdy,5) / _40 + _5 * hwPow(resetdy,7) / resety + resetx * hwPow(resetdy,9) / resetdx; |
4084 iterator^.Angle:= hwRound(resetdy*_2048 / _PI); |
4178 iterator^.Angle:= hwRound(resetdy*_2048 / _PI); |
4085 if (not iterator^.dY.isNegative) then iterator^.Angle:= 2048-iterator^.Angle; |
4179 if not iterator^.dY.isNegative then iterator^.Angle:= 2048-iterator^.Angle; |
4086 if iterator^.dX.isNegative then iterator^.Angle:= 4096-iterator^.Angle; |
4180 if iterator^.dX.isNegative then iterator^.Angle:= 4096-iterator^.Angle; |
4087 end |
4181 end |
4088 // VISUAL USE OF ANGLE ONLY |
4182 // VISUAL USE OF ANGLE ONLY |
4089 else if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtKamikaze) and (CurAmmoGear^.Hedgehog = iterator^.Hedgehog) then |
4183 else if (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtKamikaze) and (CurAmmoGear^.Hedgehog = iterator^.Hedgehog) then |
4090 begin |
4184 begin |
4703 Gear^.Y:= Gear^.Y + Gear^.dY; |
4796 Gear^.Y:= Gear^.Y + Gear^.dY; |
4704 Gear^.dX := Gear^.dX + cWindSpeed / 4; |
4797 Gear^.dX := Gear^.dX + cWindSpeed / 4; |
4705 Gear^.dY := Gear^.dY + cGravity / 100; |
4798 Gear^.dY := Gear^.dY + cGravity / 100; |
4706 if (GameTicks and $FF) = 0 then |
4799 if (GameTicks and $FF) = 0 then |
4707 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned); |
4800 doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 20, Gear^.Hedgehog, EXPLDontDraw or EXPLNoGfx or EXPLNoDamage or EXPLDoNotTouchAny or EXPLPoisoned); |
4708 AllInactive:= false; |
4801 if Gear^.State and gstTmpFlag = 0 then |
|
4802 AllInactive:= false; |
4709 end; |
4803 end; |
4710 |
4804 |
4711 //////////////////////////////////////////////////////////////////////////////// |
4805 //////////////////////////////////////////////////////////////////////////////// |
4712 procedure doStepHammer(Gear: PGear); |
4806 procedure doStepHammer(Gear: PGear); |
4713 var HHGear, tmp, tmp2: PGear; |
4807 var HHGear, tmp, tmp2: PGear; |
4730 tmp:= t^.ar[i]; |
4824 tmp:= t^.ar[i]; |
4731 if (tmp^.State and gstNoDamage) = 0 then |
4825 if (tmp^.State and gstNoDamage) = 0 then |
4732 if (tmp^.Kind = gtHedgehog) or (tmp^.Kind = gtMine) or (tmp^.Kind = gtExplosives) then |
4826 if (tmp^.Kind = gtHedgehog) or (tmp^.Kind = gtMine) or (tmp^.Kind = gtExplosives) then |
4733 begin |
4827 begin |
4734 //tmp^.State:= tmp^.State or gstFlatened; |
4828 //tmp^.State:= tmp^.State or gstFlatened; |
4735 if not tmp^.Invulnerable then |
4829 if (tmp^.Hedgehog^.Effects[heInvulnerable] = 0) then |
4736 ApplyDamage(tmp, CurrentHedgehog, tmp^.Health div 3, dsUnknown); |
4830 ApplyDamage(tmp, CurrentHedgehog, tmp^.Health div 3, dsUnknown); |
4737 //DrawTunnel(tmp^.X, tmp^.Y - _1, _0, _0_5, cHHRadius * 6, cHHRadius * 3); |
4831 //DrawTunnel(tmp^.X, tmp^.Y - _1, _0, _0_5, cHHRadius * 6, cHHRadius * 3); |
4738 tmp2:= AddGear(hwRound(tmp^.X), hwRound(tmp^.Y), gtHammerHit, 0, _0, _0, 0); |
4832 tmp2:= AddGear(hwRound(tmp^.X), hwRound(tmp^.Y), gtHammerHit, 0, _0, _0, 0); |
4739 tmp2^.LinkedGear:= tmp; |
4833 tmp2^.LinkedGear:= tmp; |
4740 SetAllToActive |
4834 SetAllToActive |
5385 Y:= HHGear^.Y |
5479 Y:= HHGear^.Y |
5386 end; |
5480 end; |
5387 |
5481 |
5388 if (Timer = iceCollideWithGround) and ((GameTicks - Power) > groundFreezingTime) then |
5482 if (Timer = iceCollideWithGround) and ((GameTicks - Power) > groundFreezingTime) then |
5389 begin |
5483 begin |
5390 FillRoundInLand2(target.x, target.y, iceRadius, icePixel); |
5484 FillRoundInLandFT(target.x, target.y, iceRadius, icePixel); |
5391 landRect.x := min(max(target.x - iceRadius, 0), LAND_WIDTH - 1); |
5485 landRect.x := min(max(target.x - iceRadius, 0), LAND_WIDTH - 1); |
5392 landRect.y := min(max(target.y - iceRadius, 0), LAND_HEIGHT - 1); |
5486 landRect.y := min(max(target.y - iceRadius, 0), LAND_HEIGHT - 1); |
5393 landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1); |
5487 landRect.w := min(2*iceRadius, LAND_WIDTH - landRect.x - 1); |
5394 landRect.h := min(2*iceRadius, LAND_HEIGHT - landRect.y - 1); |
5488 landRect.h := min(2*iceRadius, LAND_HEIGHT - landRect.y - 1); |
5395 UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true); |
5489 UpdateLandTexture(landRect.x, landRect.w, landRect.y, landRect.h, true); |
5440 end; |
5534 end; |
5441 iter:= iter^.NextGear |
5535 iter:= iter^.NextGear |
5442 end; |
5536 end; |
5443 |
5537 |
5444 // FillRoundInLandWithIce(Target.X, Target.Y, iceRadius); |
5538 // FillRoundInLandWithIce(Target.X, Target.Y, iceRadius); |
5445 SetAllHHToActive(true); |
5539 SetAllHHToActive; |
5446 Timer := iceWaitCollision; |
5540 Timer := iceWaitCollision; |
5447 end; |
5541 end; |
5448 |
5542 |
5449 if (Timer = iceCollideWithWater) and ((GameTicks - Power) > groundFreezingTime) then |
5543 if (Timer = iceCollideWithWater) and ((GameTicks - Power) > groundFreezingTime) then |
5450 begin |
5544 begin |
5451 PlaySound(sndHogFreeze); |
5545 PlaySound(sndHogFreeze); |
5452 DrawIceBreak(Target.X, cWaterLine - iceHeight, iceRadius, iceHeight); |
5546 DrawIceBreak(Target.X, cWaterLine - iceHeight, iceRadius, iceHeight); |
5453 SetAllHHToActive(true); |
5547 SetAllHHToActive; |
5454 Timer := iceWaitCollision; |
5548 Timer := iceWaitCollision; |
5455 end; |
5549 end; |
5456 (* |
5550 (* |
5457 Any ideas for something that would look good here? |
5551 Any ideas for something that would look good here? |
5458 if (Target.X <> NoPointX) and ((Timer = iceCollideWithGround) or (Timer = iceCollideWithWater)) and (GameTicks mod max((groundFreezingTime-((GameTicks - Power)*2)),2) = 0) then //and CheckLandValue(Target.X, Target.Y, lfIce) then |
5552 if (Target.X <> NoPointX) and ((Timer = iceCollideWithGround) or (Timer = iceCollideWithWater)) and (GameTicks mod max((groundFreezingTime-((GameTicks - Power)*2)),2) = 0) then //and CheckLandValue(Target.X, Target.Y, lfIce) then |
5591 exit |
5685 exit |
5592 end; |
5686 end; |
5593 |
5687 |
5594 // Search out a new target, as target seek time has expired, target is dead, target is out of range, or we did not have a target |
5688 // Search out a new target, as target seek time has expired, target is dead, target is out of range, or we did not have a target |
5595 if (HHGear = nil) or (Gear^.Timer = 0) or |
5689 if (HHGear = nil) or (Gear^.Timer = 0) or |
5596 (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) > int2hwFloat(Gear^.Angle)) |
5690 (((abs(HHGear^.X.Round-Gear^.X.Round) + abs(HHGear^.Y.Round-Gear^.Y.Round) + 2) > Gear^.Angle) and |
|
5691 (Distance(HHGear^.X-Gear^.X,HHGear^.Y-Gear^.Y) > int2hwFloat(Gear^.Angle))) |
5597 then |
5692 then |
5598 begin |
5693 begin |
5599 hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Angle); |
5694 hogs := GearsNear(Gear^.X, Gear^.Y, gtHedgehog, Gear^.Angle); |
5600 if hogs.size > 1 then |
5695 if hogs.size > 1 then |
5601 Gear^.Hedgehog:= hogs.ar^[GetRandom(hogs.size)]^.Hedgehog |
5696 Gear^.Hedgehog:= hogs.ar^[GetRandom(hogs.size)]^.Hedgehog |