Advertisement
Guest User

Untitled

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