dso4.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* ROBADV-- STEAL WINNER'S VALUABLES */
  2. /*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
  3. /* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
  4. /* WRITTEN BY R. M. SUPNIK */
  5. #include "funcs.h"
  6. #include "vars.h"
  7. integer robadv_(adv, nr, nc, na)
  8. integer adv;
  9. integer nr;
  10. integer nc;
  11. integer na;
  12. {
  13. /* System generated locals */
  14. integer ret_val, i__1;
  15. /* Local variables */
  16. integer i;
  17. ret_val = 0;
  18. /* !COUNT OBJECTS */
  19. i__1 = objcts_1.olnt;
  20. for (i = 1; i <= i__1; ++i) {
  21. if (objcts_1.oadv[i - 1] != adv || objcts_1.otval[i - 1] <= 0 || (
  22. objcts_1.oflag2[i - 1] & SCRDBT) != 0) {
  23. goto L100;
  24. }
  25. newsta_(i, 0, nr, nc, na);
  26. /* !STEAL OBJECT */
  27. ++ret_val;
  28. L100:
  29. ;
  30. }
  31. return ret_val;
  32. } /* robadv_ */
  33. /* ROBRM-- STEAL ROOM VALUABLES */
  34. /* DECLARATIONS */
  35. integer robrm_(rm, pr, nr, nc, na)
  36. integer rm;
  37. integer pr;
  38. integer nr;
  39. integer nc;
  40. integer na;
  41. {
  42. /* System generated locals */
  43. integer ret_val, i__1, i__2;
  44. /* Local variables */
  45. integer i;
  46. /* OBJECTS */
  47. ret_val = 0;
  48. /* !COUNT OBJECTS */
  49. i__1 = objcts_1.olnt;
  50. for (i = 1; i <= i__1; ++i) {
  51. /* !LOOP ON OBJECTS. */
  52. if (! qhere_(i, rm)) {
  53. goto L100;
  54. }
  55. if (objcts_1.otval[i - 1] <= 0 || (objcts_1.oflag2[i - 1] &
  56. SCRDBT) != 0 || (objcts_1.oflag1[i - 1] &
  57. VISIBT) == 0 || ! prob_(pr, pr)) {
  58. goto L50;
  59. }
  60. newsta_(i, 0, nr, nc, na);
  61. ++ret_val;
  62. objcts_1.oflag2[i - 1] |= TCHBT;
  63. goto L100;
  64. L50:
  65. if ((objcts_1.oflag2[i - 1] & ACTRBT) != 0) {
  66. i__2 = oactor_(i);
  67. ret_val += robadv_(i__2, nr, nc, na);
  68. }
  69. L100:
  70. ;
  71. }
  72. return ret_val;
  73. } /* robrm_ */
  74. /* WINNIN-- SEE IF VILLAIN IS WINNING */
  75. /* DECLARATIONS */
  76. logical winnin_(vl, hr)
  77. integer vl;
  78. integer hr;
  79. {
  80. /* System generated locals */
  81. logical ret_val;
  82. /* Local variables */
  83. integer ps, vs;
  84. /* OBJECTS */
  85. vs = objcts_1.ocapac[vl - 1];
  86. /* !VILLAIN STRENGTH */
  87. ps = vs - fights_(hr, 1);
  88. /* !HIS MARGIN OVER HERO */
  89. ret_val = prob_(90, 100);
  90. if (ps > 3) {
  91. return ret_val;
  92. }
  93. /* !+3... 90% WINNING */
  94. ret_val = prob_(75, 85);
  95. if (ps > 0) {
  96. return ret_val;
  97. }
  98. /* !>0... 75% WINNING */
  99. ret_val = prob_(50, 30);
  100. if (ps == 0) {
  101. return ret_val;
  102. }
  103. /* !=0... 50% WINNING */
  104. ret_val = prob_(25, 25);
  105. if (vs > 1) {
  106. return ret_val;
  107. }
  108. /* !ANY VILLAIN STRENGTH. */
  109. ret_val = prob_(10, 0);
  110. return ret_val;
  111. } /* winnin_ */
  112. /* FIGHTS-- COMPUTE FIGHT STRENGTH */
  113. /* DECLARATIONS */
  114. integer fights_(h, flg)
  115. integer h;
  116. logical flg;
  117. {
  118. /* Initialized data */
  119. const integer smin = 2;
  120. const integer smax = 7;
  121. /* System generated locals */
  122. integer ret_val;
  123. ret_val = smin + ((smax - smin) * advs_1.ascore[h - 1] + state_1.mxscor /
  124. 2) / state_1.mxscor;
  125. if (flg) {
  126. ret_val += advs_1.astren[h - 1];
  127. }
  128. return ret_val;
  129. } /* fights_ */
  130. /* VILSTR- COMPUTE VILLAIN STRENGTH */
  131. /* DECLARATIONS */
  132. integer vilstr_(v)
  133. integer v;
  134. {
  135. /* System generated locals */
  136. integer ret_val, i__1, i__2, i__3;
  137. /* Local variables */
  138. integer i;
  139. ret_val = objcts_1.ocapac[v - 1];
  140. if (ret_val <= 0) {
  141. return ret_val;
  142. }
  143. if (v != oindex_1.thief || ! findex_1.thfenf) {
  144. goto L100;
  145. }
  146. findex_1.thfenf = FALSE_;
  147. /* !THIEF UNENGROSSED. */
  148. ret_val = min(ret_val,2);
  149. /* !NO BETTER THAN 2. */
  150. L100:
  151. i__1 = vill_1.vlnt;
  152. for (i = 1; i <= i__1; ++i) {
  153. /* !SEE IF BEST WEAPON. */
  154. if (vill_1.villns[i - 1] == v && prsvec_1.prsi == vill_1.vbest[i - 1]
  155. ) {
  156. /* Computing MAX */
  157. i__2 = 1, i__3 = ret_val - 1;
  158. ret_val = max(i__2,i__3);
  159. }
  160. /* L200: */
  161. }
  162. return ret_val;
  163. } /* vilstr_ */