Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. procedure CanShootEnemy2
- 2. ;
- 3. returns Weapon tShootWeaponry;
- 4.
- 5. dcl
- 6. Dist, ii Integer,
- 7. mindist Integer,
- 8. ClsShipClass Integer,
- 9. tcrds2 tCoordinates,
- 10. mashcoords tCoordinates,
- 11. mashdist Integer,
- 12. mincoords tCoordinates,
- 13. minship Integer,
- 14. cos1, cos2 Real;
- 15.
- 16. ClsShipClass := 5;
- 17. ii := 1;
- 18. minship := 1;
- 19. mincoords := EnemyShips(ii)!Coordinates;
- 20. mindist := call
- 21. getDistance(ShCurrSt!Coordinates!x,ShCurrSt!Coordinates!y,
- 22. EnemyShips(ii)!Coordinates!x,EnemyShips(ii)!Coordinates!y);
- 23. for (ii:=1, ii<=NumVisibleShips, ii+1) {
- 24. Dist:= call
- 25. getDistance(ShCurrSt!Coordinates!x,ShCurrSt!Coordinates!y,
- 26. EnemyShips(ii)!Coordinates!x,EnemyShips(ii)!Coordinates!y);
- 27. if(ns2i(EnemyShips(ii)!TypeShip) = ClsShipClass) {
- 28. if (mashdist = Dist)
- 29. {
- 30. tcrds2 := call NextPosition2(ShCurrSt!Coordinates,
- 31. ShCurrSt!Heading,
- 32. ShCurrSt!Speed,
- 33. ShCurrSt!TypeShip);
- 34. cos1 := call CosBetweenVectorsCopy2(ShCurrSt!Coordinates,
- 35. tcrds2, EnemyShips(ii)!Coordinates);
- 36. cos2 := call CosBetweenVectorsCopy2(ShCurrSt!Coordinates,
- 37. tcrds2, mashcoords);
- 38. if (cos1 > cos2) {
- 39. ClsShipClass := ns2i(EnemyShips(ii)!TypeShip);
- 40. mashcoords := EnemyShips(ii)!Coordinates;
- 41. mashdist := Dist;
- 42. }
- 43. }
- 44. if (mashdist > Dist)
- 45. {
- 46. ClsShipClass := ns2i(EnemyShips(ii)!TypeShip);
- 47. mashcoords := EnemyShips(ii)!Coordinates;
- 48. mashdist := Dist;
- 49. }
- 50. }
- 51. if (ns2i(EnemyShips(ii)!TypeShip) < ClsShipClass)
- 52. {
- 53. ClsShipClass := ns2i(EnemyShips(ii)!TypeShip);
- 54. mashcoords := EnemyShips(ii)!Coordinates;
- 55. mashdist := Dist;
- 56. }
- 57. if (mindist = Dist) {
- 58. tcrds2 := call NextPosition2(ShCurrSt!Coordinates,
- 59. ShCurrSt!Heading,
- 60. ShCurrSt!Speed,
- 61. ShCurrSt!TypeShip);
- 62. cos1 := call CosBetweenVectorsCopy2(ShCurrSt!Coordinates,
- 63. tcrds2, EnemyShips(ii)!Coordinates);
- 64. cos2 := call CosBetweenVectorsCopy2(ShCurrSt!Coordinates,
- 65. tcrds2, mincoords);
- 66. if (cos1 > cos2) {
- 67. mincoords := EnemyShips(ii)!Coordinates;
- 68. minship := ii;
- 69. }
- 70. }
- 71. if (mindist > Dist) {
- 72. mincoords := EnemyShips(ii)!Coordinates;
- 73. mindist := Dist;
- 74. minship := ii;
- 75. }
- 76. }
- 77.
- 78. ii := 1;
- 79. Weapon!mashPoint := mashcoords;
- 80. tcrds2 := mincoords;
- 81. for (ii; ii <= 6; ii := ii + 1) {
- 82. if ((ii > 3) and (Longshot(ShCurrSt!ShipId) = 0)) break;
- 83. mincoords := tcrds2;
- 84. tcrds2 := call NextPosition2(mincoords, EnemyShips(minship)!Heading, EnemyShips(minship)!Speed, EnemyShips(minship)!TypeShip);
- 85. Dist := call getDistance(ShCurrSt!Coordinates!x, ShCurrSt!Coordinates!y, tcrds2!x,tcrds2!y);
- 86. if ((ShCurrSt!Ammunition(TORPEDO) /= 0) AND (WeaponryCharacter(TORPEDO)!Range >= Dist)) {
- 87. Weapon!TypeWeaponry := TORPEDO;
- 88. Weapon!isWeaponry := true;
- 89. Weapon!shootPoint := tcrds2;
- 90.
- 91. if (ii >3) {Longshot
- 92. (ShCurrSt!ShipId) := 0;}
- 93. return;
- 94. }
- 95. else if ((ShCurrSt!Ammunition(SHELL) /= 0 AND (WeaponryCharacter(SHELL)!Range >= Dist))
- 96. {
- 97. Weapon!TypeWeaponry := SHELL;
- 98. Weapon!isWeaponry := true;
- 99. Weapon!shootPoint := tcrds2;
- 100. if (ii > 3) {Longshot
- 101. (ShCurrSt!ShipId) := 0;}
- 102. return;
- 103. }
- 104. else if ((ShCurrSt!Ammunition(MISSILE) /= 0) AND (WeaponryCharacter(MISSILE)!Range >= Dist))
- 105. {
- 106. Weapon!TypeWeaponry := MISSILE;
- 107. Weapon!isWeaponry := true;
- 108. Weapon!shootPoint := tcrds2;
- 109. if (ii >3) {Longshot
- 110. (ShCurrSt!ShipId) := 0;}
- 111. return;
- 112. }
- 113. }
- 114. Weapon!isWeaponry := false;
- 115. Longshot(ShCurrSt!ShipId) := 1;
- 116. return;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement