equal
deleted
inserted
replaced
637 end; |
637 end; |
638 |
638 |
639 |
639 |
640 function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
640 function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
641 var |
641 var |
642 i: longword; |
642 i, failNum: longword; |
643 begin |
643 begin |
644 FillBonuses(true, [gtCase]); |
644 FillBonuses(true, [gtCase]); |
645 if bonuses.Count = 0 then |
645 if bonuses.Count = 0 then |
646 TestTeleport := BadTurn |
646 TestTeleport := BadTurn |
647 else begin |
647 else begin |
648 i := random(bonuses.Count); |
648 failNum := 0; |
649 ap.AttackPutX := bonuses.ar[i].X; |
649 repeat |
650 ap.AttackPutY := bonuses.ar[i].Y - 50; |
650 i := random(bonuses.Count); |
651 TestTeleport := 0; |
651 inc(failNum); |
|
652 until(not TestColl(bonuses.ar[i].X, bonuses.ar[i].Y - cHHRadius - bonuses.ar[i].Radius, cHHRadius) or (failNum = bonuses.Count*2)); |
|
653 if failNum < bonuses.Count*2 then begin |
|
654 ap.AttackPutX := bonuses.ar[i].X; |
|
655 ap.AttackPutY := bonuses.ar[i].Y - cHHRadius - bonuses.ar[i].Radius; |
|
656 TestTeleport := 0; |
|
657 end |
|
658 else |
|
659 TestTeleport := BadTurn; |
652 end; |
660 end; |
653 end; |
661 end; |
654 |
662 |
655 end. |
663 end. |