682 end; |
682 end; |
683 |
683 |
684 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
684 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
685 var Vx, Vy, x, y, t: real; |
685 var Vx, Vy, x, y, t: real; |
686 d: Longword; |
686 d: Longword; |
687 {fallDmg, }valueResult: LongInt; |
687 ix, iy, valueResult: LongInt; |
688 begin |
688 begin |
689 if (Level > 4) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn); |
689 if (Level > 4) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn); |
690 Level:= Level; // avoid compiler hint |
690 Level:= Level; // avoid compiler hint |
691 ap.ExplR:= 1; |
691 ap.ExplR:= 1; |
692 ap.Time:= 0; |
692 ap.Time:= 0; |
702 Vx:= (Targ.Point.X - x) * t; |
702 Vx:= (Targ.Point.X - x) * t; |
703 Vy:= (Targ.Point.Y - y) * t; |
703 Vy:= (Targ.Point.Y - y) * t; |
704 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy); |
704 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy); |
705 d:= 0; |
705 d:= 0; |
706 |
706 |
707 repeat |
707 ix:= trunc(x); |
708 x:= x + vX; |
708 iy:= trunc(y); |
709 y:= y + vY; |
709 |
710 if ((trunc(x) and LAND_WIDTH_MASK) = 0)and((trunc(y) and LAND_HEIGHT_MASK) = 0) |
710 if ((ix and LAND_WIDTH_MASK) = 0) and ((iy and LAND_HEIGHT_MASK) = 0) then |
711 and (Land[trunc(y), trunc(x)] <> 0) then |
711 repeat |
712 inc(d); |
712 if Land[iy, ix] <> 0 then |
713 until (Abs(Targ.Point.X - trunc(x)) + Abs(Targ.Point.Y - trunc(y)) < 5) |
713 inc(d); |
714 or (x < 0) |
714 x:= x + vX; |
715 or (y < 0) |
715 y:= y + vY; |
716 or (trunc(x) > LAND_WIDTH) |
716 ix:= trunc(x); |
717 or (trunc(y) > LAND_HEIGHT) |
717 iy:= trunc(y); |
718 or (d > 48); |
718 until (Abs(Targ.Point.X - ix) + Abs(Targ.Point.Y - iy) < 5) |
719 |
719 or (x < 0) |
720 if Abs(Targ.Point.X - trunc(x)) + Abs(Targ.Point.Y - trunc(y)) < 5 then |
720 or (y < 0) |
|
721 or (ix >= LAND_WIDTH) |
|
722 or (iy >= LAND_HEIGHT) |
|
723 or (d > 48); |
|
724 |
|
725 if Abs(Targ.Point.X - ix) + Abs(Targ.Point.Y - iy) < 5 then |
721 begin |
726 begin |
722 ap.AttacksNum:= 1 + (d + 8) div 12; |
727 ap.AttacksNum:= 1 + (d + 8) div 12; |
723 valueResult:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, 7, 20, vX*0.125, vY*0.125, afTrackFall) - ap.AttacksNum |
728 valueResult:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, 7, 20, vX*0.125, vY*0.125, afTrackFall) - ap.AttacksNum |
724 end |
729 end |
725 else |
730 else |