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