471 range: integer; |
489 range: integer; |
472 begin |
490 begin |
473 ap.ExplR:= 0; |
491 ap.ExplR:= 0; |
474 ap.Time:= 0; |
492 ap.Time:= 0; |
475 ap.Power:= 1; |
493 ap.Power:= 1; |
476 range:= Metric(hwRound(Me^.X), hwRound(Me^.Y), Targ.X, Targ.Y); |
494 with PHedgehog(Me^.Hedgehog)^ do |
|
495 begin |
|
496 x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle))); |
|
497 y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle))) |
|
498 end; |
|
499 range:= Metric(hwRound(x), hwRound(y), Targ.X, Targ.Y); |
477 if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then exit(BadTurn); |
500 if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then exit(BadTurn); |
478 Vx:= (int2hwFloat(Targ.X) - Me^.X) * _1div1024; |
501 Vx:= (int2hwFloat(Targ.X) - x) * _1div1024; |
479 Vy:= (int2hwFloat(Targ.Y) - Me^.Y) * _1div1024; |
502 Vy:= (int2hwFloat(Targ.Y) - y) * _1div1024; |
480 x:= Me^.X; |
|
481 y:= Me^.Y; |
|
482 ap.Angle:= DxDy2AttackAngle(Vx, -Vy); |
503 ap.Angle:= DxDy2AttackAngle(Vx, -Vy); |
483 repeat |
504 repeat |
484 x:= x + vX; |
505 x:= x + vX; |
485 y:= y + vY; |
506 y:= y + vY; |
486 rx:= hwRound(x); |
507 rx:= hwRound(x); |
505 begin |
526 begin |
506 Level:= Level; // avoid compiler hint |
527 Level:= Level; // avoid compiler hint |
507 ap.ExplR:= 0; |
528 ap.ExplR:= 0; |
508 ap.Time:= 0; |
529 ap.Time:= 0; |
509 ap.Power:= 1; |
530 ap.Power:= 1; |
|
531 with PHedgehog(Me^.Hedgehog)^ do |
|
532 begin |
|
533 x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle))); |
|
534 y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle))) |
|
535 end; |
510 if Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) < 80 then |
536 if Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) < 80 then |
511 exit(BadTurn); |
537 exit(BadTurn); |
512 t:= _0_5 / Distance(int2hwFloat(Targ.X) - Me^.X, int2hwFloat(Targ.Y) - Me^.Y); |
538 t:= _0_5 / Distance(int2hwFloat(Targ.X) - x, int2hwFloat(Targ.Y) - y); |
513 Vx:= (int2hwFloat(Targ.X) - Me^.X) * t; |
539 Vx:= (int2hwFloat(Targ.X) - x) * t; |
514 Vy:= (int2hwFloat(Targ.Y) - Me^.Y) * t; |
540 Vy:= (int2hwFloat(Targ.Y) - y) * t; |
515 x:= Me^.X; |
|
516 y:= Me^.Y; |
|
517 ap.Angle:= DxDy2AttackAngle(Vx, -Vy); |
541 ap.Angle:= DxDy2AttackAngle(Vx, -Vy); |
518 d:= 0; |
542 d:= 0; |
519 |
543 |
520 repeat |
544 repeat |
521 x:= x + vX; |
545 x:= x + vX; |
529 TestDesertEagle:= valueResult |
553 TestDesertEagle:= valueResult |
530 end; |
554 end; |
531 |
555 |
532 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
556 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
533 var valueResult: LongInt; |
557 var valueResult: LongInt; |
|
558 x, y: hwFloat; |
534 begin |
559 begin |
535 Level:= Level; // avoid compiler hint |
560 Level:= Level; // avoid compiler hint |
536 ap.ExplR:= 0; |
561 ap.ExplR:= 0; |
537 if (Level > 2) or (Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) > 25) then |
562 if (Level > 2) or (Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) > 25) then |
538 exit(BadTurn); |
563 exit(BadTurn); |
539 |
564 |
540 ap.Time:= 0; |
565 ap.Time:= 0; |
541 ap.Power:= 1; |
566 ap.Power:= 1; |
542 if (Targ.X) - hwRound(Me^.X) >= 0 then ap.Angle:= cMaxAngle div 4 |
567 with PHedgehog(Me^.Hedgehog)^ do |
|
568 begin |
|
569 x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle))); |
|
570 y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle))) |
|
571 end; |
|
572 if (Targ.X) - hwRound(x) >= 0 then ap.Angle:= cMaxAngle div 4 |
543 else ap.Angle:= - cMaxAngle div 4; |
573 else ap.Angle:= - cMaxAngle div 4; |
544 valueResult:= RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X), hwRound(Me^.Y), 15, 30); |
574 valueResult:= RateShove(Me, hwRound(x) + 10 * hwSign(int2hwFloat(Targ.X) - x), hwRound(y), 15, 30); |
545 if valueResult <= 0 then valueResult:= BadTurn else inc(valueResult); |
575 if valueResult <= 0 then valueResult:= BadTurn else inc(valueResult); |
546 TestBaseballBat:= valueResult; |
576 TestBaseballBat:= valueResult; |
547 end; |
577 end; |
548 |
578 |
549 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
579 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
550 var i, valueResult: LongInt; |
580 var i, valueResult: LongInt; |
|
581 x, y: hwFloat; |
551 begin |
582 begin |
552 Level:= Level; // avoid compiler hint |
583 Level:= Level; // avoid compiler hint |
553 ap.ExplR:= 0; |
584 ap.ExplR:= 0; |
554 ap.Time:= 0; |
585 ap.Time:= 0; |
555 ap.Power:= 1; |
586 ap.Power:= 1; |
556 ap.Angle:= 0; |
587 ap.Angle:= 0; |
557 if (Abs(hwRound(Me^.X) - Targ.X) > 25) |
588 with PHedgehog(Me^.Hedgehog)^ do |
558 or (Abs(hwRound(Me^.Y) - 50 - Targ.Y) > 50) then |
589 begin |
559 begin |
590 x:= Me^.X + int2hwfloat(round(GetLaunchX(Ammo^[CurSlot, CurAmmo].AmmoType, hwSign(Me^.dX), Me^.Angle))); |
560 if TestColl(hwRound(Me^.Y), hwRound(Me^.Y) - 16, 6) |
591 y:= Me^.Y + int2hwfloat(round(GetLaunchY(Ammo^[CurSlot, CurAmmo].AmmoType, Me^.Angle))) |
561 and (RateShove(Me, hwRound(Me^.X) + 10 * hwSign(Me^.dX), hwRound(Me^.Y) - 40, 30, 30) = 0) then |
592 end; |
|
593 if (Abs(hwRound(x) - Targ.X) > 25) |
|
594 or (Abs(hwRound(y) - 50 - Targ.Y) > 50) then |
|
595 begin |
|
596 if TestColl(hwRound(x), hwRound(y) - 16, 6) |
|
597 and (RateShove(Me, hwRound(x) + 10 * hwSign(Me^.dX), hwRound(y) - 40, 30, 30) = 0) then |
562 valueResult:= Succ(BadTurn) |
598 valueResult:= Succ(BadTurn) |
563 else |
599 else |
564 valueResult:= BadTurn; |
600 valueResult:= BadTurn; |
565 exit(valueResult) |
601 exit(valueResult) |
566 end; |
602 end; |
567 |
603 |
568 valueResult:= 0; |
604 valueResult:= 0; |
569 for i:= 0 to 4 do |
605 for i:= 0 to 4 do |
570 valueResult:= valueResult + RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X), |
606 valueResult:= valueResult + RateShove(Me, hwRound(x) + 10 * hwSign(int2hwFloat(Targ.X) - x), |
571 hwRound(Me^.Y) - 20 * i - 5, 10, 30); |
607 hwRound(y) - 20 * i - 5, 10, 30); |
572 if valueResult <= 0 then |
608 if valueResult <= 0 then |
573 valueResult:= BadTurn |
609 valueResult:= BadTurn |
574 else |
610 else |
575 inc(valueResult); |
611 inc(valueResult); |
576 |
612 |