Mercurial > hg > early-roguelike
comparison srogue/encumb.c @ 36:2128c7dc8a40
Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
author | elwin |
---|---|
date | Thu, 25 Nov 2010 12:21:41 +0000 |
parents | |
children | 94a0d9dd5ce1 |
comparison
equal
deleted
inserted
replaced
35:05018c63a721 | 36:2128c7dc8a40 |
---|---|
1 /* | |
2 * Stuff to do with encumberence | |
3 * | |
4 * @(#)encumb.c 9.0 (rdk) 7/17/84 | |
5 * | |
6 * Super-Rogue | |
7 * Copyright (C) 1984 Robert D. Kindelberger | |
8 * All rights reserved. | |
9 * | |
10 * See the file LICENSE.TXT for full copyright and licensing information. | |
11 */ | |
12 | |
13 #include "rogue.h" | |
14 #include "rogue.ext" | |
15 | |
16 /* | |
17 * updpack: | |
18 * Update his pack weight and adjust fooduse accordingly | |
19 */ | |
20 updpack() | |
21 { | |
22 reg int topcarry, curcarry; | |
23 | |
24 him->s_carry = totalenc(); /* get total encumb */ | |
25 curcarry = packweight(); /* get pack weight */ | |
26 topcarry = him->s_carry / 5; /* 20% of total carry */ | |
27 if (curcarry > 4 * topcarry) { | |
28 if (rnd(100) < 80) | |
29 foodlev = 3; /* > 80% of pack */ | |
30 } | |
31 else if (curcarry > 3 * topcarry) { | |
32 if (rnd(100) < 60) | |
33 foodlev = 2; /* > 60% of pack */ | |
34 } | |
35 else | |
36 foodlev = 1; /* <= 60% of pack */ | |
37 him->s_pack = curcarry; /* update pack weight */ | |
38 packvol = pack_vol(); /* update pack volume */ | |
39 nochange = FALSE; /* also change display */ | |
40 } | |
41 | |
42 | |
43 /* | |
44 * packweight: | |
45 * Get the total weight of the hero's pack | |
46 */ | |
47 packweight() | |
48 { | |
49 reg struct object *obj; | |
50 reg struct linked_list *pc; | |
51 reg int weight, i; | |
52 | |
53 weight = 0; | |
54 for (pc = pack ; pc != NULL ; pc = next(pc)) { | |
55 obj = OBJPTR(pc); | |
56 weight += itemweight(obj) * obj->o_count; | |
57 } | |
58 if (weight < 0) /* in case of amulet */ | |
59 weight = 0; | |
60 for (i = LEFT; i <= RIGHT; i += 1) { | |
61 obj = cur_ring[i]; | |
62 if (obj != NULL) { | |
63 if (obj->o_type == R_HEAVY && o_off(obj, ISBLESS)) | |
64 weight += weight / 4; | |
65 } | |
66 } | |
67 return weight; | |
68 } | |
69 | |
70 | |
71 /* | |
72 * itemweight: | |
73 * Get the weight of an object | |
74 */ | |
75 itemweight(wh) | |
76 struct object *wh; | |
77 { | |
78 reg int weight; | |
79 | |
80 weight = wh->o_weight; /* get base weight */ | |
81 switch (wh->o_type) { | |
82 case ARMOR: | |
83 if ((armors[wh->o_which].a_class - wh->o_ac) > 0) | |
84 weight /= 2; | |
85 when WEAPON: | |
86 if ((wh->o_hplus + wh->o_dplus) > 0) | |
87 weight /= 2; | |
88 } | |
89 if (o_on(wh,ISCURSED)) | |
90 weight += weight / 5; /* 20% more for cursed */ | |
91 if (o_on(wh, ISBLESS)) | |
92 weight -= weight / 5; /* 20% less for blessed */ | |
93 return weight; | |
94 } | |
95 | |
96 /* | |
97 * pack_vol: | |
98 * Get the total volume of the hero's pack | |
99 */ | |
100 pack_vol() | |
101 { | |
102 reg struct object *obj; | |
103 reg struct linked_list *pc; | |
104 reg int volume; | |
105 | |
106 volume = 0; | |
107 for (pc = pack ; pc != NULL ; pc = next(pc)) { | |
108 obj = OBJPTR(pc); | |
109 volume += itemvol(obj); | |
110 } | |
111 return volume; | |
112 } | |
113 | |
114 /* | |
115 * itemvol: | |
116 * Get the volume of an object | |
117 */ | |
118 itemvol(wh) | |
119 struct object *wh; | |
120 { | |
121 reg int volume, what, extra; | |
122 | |
123 extra = 0; | |
124 what = getindex(wh->o_type); | |
125 switch (wh->o_type) { | |
126 case ARMOR: extra = armors[wh->o_which].a_vol; | |
127 when WEAPON: extra = weaps[wh->o_which].w_vol; | |
128 when STICK: if (strcmp(ws_stuff[wh->o_which].ws_type,"staff") == 0) | |
129 extra = V_WS_STAFF; | |
130 else | |
131 extra = V_WS_WAND; | |
132 } | |
133 volume = thnginfo[what].mf_vol + extra; | |
134 volume *= wh->o_count; | |
135 return volume; | |
136 } | |
137 | |
138 /* | |
139 * playenc: | |
140 * Get hero's carrying ability above norm | |
141 */ | |
142 playenc() | |
143 { | |
144 reg estr = him->s_ef.a_str; | |
145 if (estr >= 24) | |
146 return 3000; | |
147 switch(him->s_ef.a_str) { | |
148 case 23: return 2000; | |
149 case 22: return 1500; | |
150 case 21: return 1250; | |
151 case 20: return 1100; | |
152 case 19: return 1000; | |
153 case 18: return 700; | |
154 case 17: return 500; | |
155 case 16: return 350; | |
156 case 15: | |
157 case 14: return 200; | |
158 case 13: | |
159 case 12: return 100; | |
160 case 11: | |
161 case 10: | |
162 case 9: | |
163 case 8: return 0; | |
164 case 7: | |
165 case 6: return -150; | |
166 case 5: | |
167 case 4: return -250; | |
168 } | |
169 return -350; | |
170 } | |
171 | |
172 | |
173 /* | |
174 * totalenc: | |
175 * Get total weight that the hero can carry | |
176 */ | |
177 totalenc() | |
178 { | |
179 reg int wtotal; | |
180 | |
181 wtotal = NORMENCB + playenc(); | |
182 switch(hungry_state) { | |
183 case F_OKAY: | |
184 case F_HUNGRY: ; /* no change */ | |
185 when F_WEAK: wtotal -= wtotal / 10; /* 10% off weak */ | |
186 when F_FAINT: wtotal /= 2; /* 50% off faint */ | |
187 } | |
188 return wtotal; | |
189 } | |
190 | |
191 /* | |
192 * whgtchk: | |
193 * See if the hero can carry his pack | |
194 */ | |
195 wghtchk(fromfuse) | |
196 int fromfuse; | |
197 { | |
198 reg int dropchk, err = TRUE; | |
199 reg char ch; | |
200 | |
201 inwhgt = TRUE; | |
202 if (him->s_pack > him->s_carry) { | |
203 ch = player.t_oldch; | |
204 extinguish(wghtchk); | |
205 if ((ch != FLOOR && ch != PASSAGE) || isfight) { | |
206 fuse(wghtchk, TRUE, 1); | |
207 inwhgt = FALSE; | |
208 return; | |
209 } | |
210 msg("Your pack is too heavy for you."); | |
211 do { | |
212 dropchk = drop(NULL); | |
213 if (dropchk == SOMTHERE) | |
214 err = FALSE; | |
215 else if (dropchk == FALSE) { | |
216 mpos = 0; | |
217 msg("You must drop something"); | |
218 } | |
219 if (dropchk == TRUE) | |
220 err = FALSE; | |
221 } while(err); | |
222 } | |
223 inwhgt = FALSE; | |
224 } | |
225 | |
226 | |
227 /* | |
228 * hitweight: | |
229 * Gets the fighting ability according to current weight | |
230 * This returns a +1 hit for light pack weight | |
231 * 0 hit for medium pack weight | |
232 * -1 hit for heavy pack weight | |
233 */ | |
234 hitweight() | |
235 { | |
236 return(2 - foodlev); | |
237 } |