643 |
643 |
644 |
644 |
645 function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
645 function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
646 var |
646 var |
647 i, failNum: longword; |
647 i, failNum: longword; |
648 begin |
648 maxTop: longword; |
|
649 begin |
|
650 TestTeleport := BadTurn; |
649 Level:= Level; // avoid compiler hint |
651 Level:= Level; // avoid compiler hint |
650 FillBonuses(true, [gtCase]); |
652 FillBonuses(true, [gtCase]); |
651 if bonuses.Count = 0 then begin |
653 if bonuses.Count = 0 then begin |
652 if Me^.Health <= 100 then begin |
654 if Me^.Health <= 100 then begin |
653 ap.AttackPutX := Targ.X; |
655 maxTop := Targ.Y - cHHRadius * 2; |
654 ap.AttackPutY := topY + cHHRadius*2; |
656 while(not TestColl(Targ.X, maxTop, cHHRadius) and (maxTop > topY)) do |
655 TestTeleport := Targ.Y - topY; |
657 dec(maxTop, cHHRadius*2); |
|
658 if(not TestColl(Targ.X, maxTop + cHHRadius, cHHRadius)) then begin |
|
659 ap.AttackPutX := Targ.X; |
|
660 ap.AttackPutY := maxTop + cHHRadius; |
|
661 TestTeleport := Targ.Y - maxTop; |
|
662 end; |
656 end |
663 end |
657 else |
|
658 TestTeleport := BadTurn; |
|
659 end |
664 end |
660 else begin |
665 else begin |
661 failNum := 0; |
666 failNum := 0; |
662 repeat |
667 repeat |
663 i := random(bonuses.Count); |
668 i := random(bonuses.Count); |