1 /* SCCS Id: @(#)botl.c 3.4 1996/07/15 */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
8 extern const char *hu_stat[]; /* defined in eat.c */
10 const char * const enc_stat[] = {
19 STATIC_DCL void NDECL(bot1);
20 STATIC_DCL void NDECL(bot2);
23 /* MAXCO must hold longest uncompressed status line, and must be larger
26 * longest practical second status line at the moment is
27 * Astral Plane $:12345 HP:700(700) Pw:111(111) AC:-127 Xp:30/123456789
28 * T:123456 Satiated Conf FoodPois Ill Blind Stun Hallu Overloaded
29 * -- or somewhat over 130 characters
34 #define MAXCO (COLNO+20)
38 STATIC_DCL int mrank_sz;
40 STATIC_OVL NEARDATA int mrank_sz = 0; /* loaded by max_rank_sz (from u_init) */
43 STATIC_DCL const char *NDECL(rank);
47 /* convert experience level (1..30) to rank index (0..8) */
52 return (xlev <= 2) ? 0 : (xlev <= 30) ? ((xlev + 2) / 4) : 8;
55 #if 0 /* not currently needed */
56 /* convert rank index (0..8) to experience level (1..30) */
61 return (rank <= 0) ? 1 : (rank <= 8) ? ((rank * 4) - 2) : 30;
66 rank_of(lev, monnum, female)
71 register struct Role *role;
76 for (role = (struct Role *) roles; role->name.m; role++)
77 if (monnum == role->malenum || monnum == role->femalenum)
83 for (i = xlev_to_rank((int)lev); i >= 0; i--) {
84 if (female && role->rank[i].f) return (role->rank[i].f);
85 if (role->rank[i].m) return (role->rank[i].m);
88 /* Try the role name, instead */
89 if (female && role->name.f) return (role->name.f);
90 else if (role->name.m) return (role->name.m);
95 STATIC_OVL const char *
98 return(rank_of(u.ulevel, Role_switch, flags.female));
102 title_to_mon(str, rank_indx, title_length)
104 int *rank_indx, *title_length;
109 /* Loop through each of the roles */
110 for (i = 0; roles[i].name.m; i++)
111 for (j = 0; j < 9; j++) {
112 if (roles[i].rank[j].m && !strncmpi(str,
113 roles[i].rank[j].m, strlen(roles[i].rank[j].m))) {
114 if (rank_indx) *rank_indx = j;
115 if (title_length) *title_length = strlen(roles[i].rank[j].m);
116 return roles[i].malenum;
118 if (roles[i].rank[j].f && !strncmpi(str,
119 roles[i].rank[j].f, strlen(roles[i].rank[j].f))) {
120 if (rank_indx) *rank_indx = j;
121 if (title_length) *title_length = strlen(roles[i].rank[j].f);
122 return ((roles[i].femalenum != NON_PM) ?
123 roles[i].femalenum : roles[i].malenum);
135 register int i, r, maxr = 0;
136 for (i = 0; i < 9; i++) {
137 if (urole.rank[i].m && (r = strlen(urole.rank[i].m)) > maxr) maxr = r;
138 if (urole.rank[i].f && (r = strlen(urole.rank[i].f)) > maxr) maxr = r;
151 int deepest = deepest_lev_reached(FALSE);
153 long ugold = u.ugold + hidden_gold();
155 if ((ugold -= u.ugold0) < 0L) ugold = 0L;
156 return ugold + u.urexp + (long)(50 * (deepest - 1))
158 long umoney = money_cnt(invent) + hidden_gold();
160 if ((umoney -= u.umoney0) < 0L) umoney = 0L;
161 return umoney + u.urexp + (long)(50 * (deepest - 1))
163 + (long)(deepest > 30 ? 10000 :
164 deepest > 20 ? 1000*(deepest - 20) : 0);
175 Strcpy(newbot1, plname);
176 if('a' <= newbot1[0] && newbot1[0] <= 'z') newbot1[0] += 'A'-'a';
178 Sprintf(nb = eos(newbot1)," the ");
184 Strcpy(mbot, mons[u.umonnum].mname);
185 while(mbot[k] != 0) {
186 if ((k == 0 || (k > 0 && mbot[k-1] == ' ')) &&
187 'a' <= mbot[k] && mbot[k] <= 'z')
188 mbot[k] += 'A' - 'a';
191 Sprintf(nb = eos(nb), mbot);
193 Sprintf(nb = eos(nb), rank());
195 Sprintf(nb = eos(nb)," ");
197 j = (nb + 2) - newbot1; /* aka strlen(newbot1) but less computation */
199 Sprintf(nb = eos(nb),"%*s", i-j, " "); /* pad with spaces */
200 if (ACURR(A_STR) > 18) {
201 if (ACURR(A_STR) > STR18(100))
202 Sprintf(nb = eos(nb),"St:%2d ",ACURR(A_STR)-100);
203 else if (ACURR(A_STR) < STR18(100))
204 Sprintf(nb = eos(nb), "St:18/%02d ",ACURR(A_STR)-18);
206 Sprintf(nb = eos(nb),"St:18/** ");
208 Sprintf(nb = eos(nb), "St:%-1d ",ACURR(A_STR));
209 Sprintf(nb = eos(nb),
210 "Dx:%-1d Co:%-1d In:%-1d Wi:%-1d Ch:%-1d",
211 ACURR(A_DEX), ACURR(A_CON), ACURR(A_INT), ACURR(A_WIS), ACURR(A_CHA));
212 Sprintf(nb = eos(nb), (u.ualign.type == A_CHAOTIC) ? " Chaotic" :
213 (u.ualign.type == A_NEUTRAL) ? " Neutral" : " Lawful");
216 Sprintf(nb = eos(nb), " S:%ld", botl_score());
218 curs(WIN_STATUS, 1, 0);
219 putstr(WIN_STATUS, 0, newbot1);
222 /* provide the name of the current level for display by various ports */
229 /* TODO: Add in dungeon name */
231 Sprintf(buf, "%s ", dungeons[u.uz.dnum].dname);
232 else if (In_quest(&u.uz))
233 Sprintf(buf, "Home %d ", dunlev(&u.uz));
234 else if (In_endgame(&u.uz))
236 Is_astralevel(&u.uz) ? "Astral Plane " : "End Game ");
238 /* ports with more room may expand this one */
239 Sprintf(buf, "Dlvl:%-2d ", depth(&u.uz));
251 int cap = near_capacity();
253 hp = Upolyd ? u.mh : u.uhp;
254 hpmax = Upolyd ? u.mhmax : u.uhpmax;
257 (void) describe_level(newbot2);
258 Sprintf(nb = eos(newbot2),
259 "%c:%-2ld HP:%d(%d) Pw:%d(%d) AC:%-2d", oc_syms[COIN_CLASS],
265 hp, hpmax, u.uen, u.uenmax, u.uac);
268 Sprintf(nb = eos(nb), " HD:%d", mons[u.umonnum].mlevel);
270 else if(flags.showexp)
271 Sprintf(nb = eos(nb), " Xp:%u/%-1ld", u.ulevel,u.uexp);
274 Sprintf(nb = eos(nb), " Exp:%u", u.ulevel);
277 Sprintf(nb = eos(nb), " T:%ld", moves);
278 if(strcmp(hu_stat[u.uhs], " ")) {
279 Sprintf(nb = eos(nb), " ");
280 Strcat(newbot2, hu_stat[u.uhs]);
282 if(Confusion) Sprintf(nb = eos(nb), " Conf");
284 if (u.usick_type & SICK_VOMITABLE)
285 Sprintf(nb = eos(nb), " FoodPois");
286 if (u.usick_type & SICK_NONVOMITABLE)
287 Sprintf(nb = eos(nb), " Ill");
289 if(Blind) Sprintf(nb = eos(nb), " Blind");
290 if(Stunned) Sprintf(nb = eos(nb), " Stun");
291 if(Hallucination) Sprintf(nb = eos(nb), " Hallu");
292 if(Slimed) Sprintf(nb = eos(nb), " Slime");
293 if(cap > UNENCUMBERED)
294 Sprintf(nb = eos(nb), " %s", enc_stat[cap]);
295 curs(WIN_STATUS, 1, 1);
296 putstr(WIN_STATUS, 0, newbot2);
304 flags.botl = flags.botlx = 0;