]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - rogue/inventory.c
2 * Copyright (c) 1988 The Regents of the University of California.
5 * This code is derived from software contributed to Berkeley by
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 /*static char sccsid[] = "from: @(#)inventory.c 5.4 (Berkeley) 6/1/90";*/
39 static char rcsid
[] = "$Id: inventory.c,v 1.2 1993/08/01 18:52:29 mycroft Exp $";
45 * This source herein may be modified and/or distributed by anybody who
46 * so desires, with the following restrictions:
47 * 1.) No portion of this notice shall be removed.
48 * 2.) Credit shall not be taken for the creation of this source.
49 * 3.) This code is not to be traded, sold, or used for personal
56 boolean is_wood
[WANDS
];
57 char *press_space
= " --press space to continue--";
59 char *wand_materials
[WAND_MATERIALS
] = {
110 char *syllables
[MAXSYLLABLES
] = {
160 struct id_com_s com_id_tab
[COMS
] = {
161 '?', "? prints help",
162 'r', "r read scroll",
163 '/', "/ identify object",
166 'w', "w wield a weapon",
170 'T', "T take armor off",
172 'P', "P put on ring",
174 'R', "R remove ring",
176 'd', "d drop object",
177 'b', "b down & left",
178 'c', "c call object",
179 'n', "n down & right",
180 NULL
, "<SHIFT><dir>: run that way",
181 ')', ") print current weapon",
182 NULL
, "<CTRL><dir>: run till adjacent",
183 ']', "] print current armor",
184 'f', "f<dir> fight till death or near death",
185 '=', "= print current rings",
186 't', "t<dir> throw something",
187 '\001', "^A print Hp-raise average",
188 'm', "m<dir> move onto without picking up",
189 'z', "z<dir> zap a wand in a direction",
190 'o', "o examine/set options",
191 '^', "^<dir> identify trap type",
192 '\022', "^R redraw screen",
193 '&', "& save screen into 'rogue.screen'",
194 's', "s search for trap/secret door",
195 '\020', "^P repeat last message",
196 '>', "> go down a staircase",
197 '\033', "^[ cancel command",
198 '<', "< go up a staircase",
200 '.', ". rest for a turn",
202 ',', ", pick something up",
203 '!', "! shell escape",
205 'F', "F<dir> fight till either of you dies",
206 'I', "I inventory single item",
207 'v', "v print version number",
208 'q', "q quaff potion"
211 extern boolean wizard
;
212 extern char *m_names
[], *more
;
214 inventory(pack
, mask
)
219 short i
= 0, j
, maxlen
= 0, n
;
220 char descs
[MAX_PACK_COUNT
+1][DCOLS
];
223 obj
= pack
->next_object
;
226 message("your pack is empty", 0);
230 if (obj
->what_is
& mask
) {
232 descs
[i
][1] = obj
->ichar
;
233 descs
[i
][2] = ((obj
->what_is
& ARMOR
) && obj
->is_protected
)
236 get_desc(obj
, descs
[i
]+4);
237 if ((n
= strlen(descs
[i
])) > maxlen
) {
242 obj
= obj
->next_object
;
244 (void) strcpy(descs
[i
++], press_space
);
245 if (maxlen
< 27) maxlen
= 27;
246 col
= DCOLS
- (maxlen
+ 2);
248 for (row
= 0; ((row
< i
) && (row
< DROWS
)); row
++) {
250 for (j
= col
; j
< DCOLS
; j
++) {
251 descs
[row
-1][j
-col
] = mvinch(row
, j
);
253 descs
[row
-1][j
-col
] = 0;
255 mvaddstr(row
, col
, descs
[row
]);
264 for (j
= 1; ((j
< i
) && (j
< DROWS
)); j
++) {
265 mvaddstr(j
, col
, descs
[j
-1]);
274 while (ch
!= CANCEL
) {
276 message("Character you want help for (* for all):", 0);
284 char save
[(((COMS
/ 2) + (COMS
% 2)) + 1)][DCOLS
];
285 short rows
= (((COMS
/ 2) + (COMS
% 2)) + 1);
286 boolean need_two_screens
;
289 need_two_screens
= 1;
294 for (i
= 0; i
< rows
; i
++) {
295 for (j
= 0; j
< DCOLS
; j
++) {
296 save
[i
][j
] = mvinch(i
, j
);
300 for (i
= 0; i
< rows
; i
++) {
304 for (i
= 0; i
< (rows
-1); i
++) {
306 if (((i
+ i
) < COMS
) && ((i
+i
+k
) < COMS
)) {
307 mvaddstr(i
, 0, com_id_tab
[i
+i
+k
].com_desc
);
309 if (((i
+ i
+ 1) < COMS
) && ((i
+i
+k
+1) < COMS
)) {
310 mvaddstr(i
, (DCOLS
/2),
311 com_id_tab
[i
+i
+k
+1].com_desc
);
315 mvaddstr(rows
- 1, 0, need_two_screens
? more
: press_space
);
319 if (need_two_screens
) {
321 need_two_screens
= 0;
324 for (i
= 0; i
< rows
; i
++) {
326 for (j
= 0; j
< DCOLS
; j
++) {
333 if (!pr_com_id(ch
)) {
334 if (!pr_motion_char(ch
)) {
336 message("unknown character", 0);
350 if (!get_com_id(&i
, ch
)) {
354 message(com_id_tab
[i
].com_desc
, 0);
358 get_com_id(index
, ch
)
364 for (i
= 0; i
< COMS
; i
++) {
365 if (com_id_tab
[i
].com_char
== ch
) {
392 char until
[18], buf
[DCOLS
];
397 (void) strcpy(until
, "until adjascent");
402 (void) get_com_id(&n
, ch
);
403 sprintf(buf
, "run %s %s", com_id_tab
[n
].com_desc
+ 8, until
);
417 for (i
= 0; i
<= 32; i
++) {
418 j
= get_rand(0, (POTIONS
- 1));
419 k
= get_rand(0, (POTIONS
- 1));
420 t
= id_potions
[j
].title
;
421 id_potions
[j
].title
= id_potions
[k
].title
;
422 id_potions
[k
].title
= t
;
431 for (i
= 0; i
< SCROLS
; i
++) {
432 sylls
= get_rand(2, 5);
433 (void) strcpy(id_scrolls
[i
].title
, "'");
435 for (j
= 0; j
< sylls
; j
++) {
436 s
= get_rand(1, (MAXSYLLABLES
-1));
437 (void) strcat(id_scrolls
[i
].title
, syllables
[s
]);
439 n
= strlen(id_scrolls
[i
].title
);
440 (void) strcpy(id_scrolls
[i
].title
+(n
-1), "' ");
453 if (obj
->what_is
== AMULET
) {
454 (void) strcpy(desc
, "the amulet of Yendor ");
457 item_name
= name_of(obj
);
459 if (obj
->what_is
== GOLD
) {
460 sprintf(desc
, "%d pieces of gold", obj
->quantity
);
464 if (obj
->what_is
!= ARMOR
) {
465 if (obj
->quantity
== 1) {
466 (void) strcpy(desc
, "a ");
468 sprintf(desc
, "%d ", obj
->quantity
);
471 if (obj
->what_is
== FOOD
) {
472 if (obj
->which_kind
== RATION
) {
473 if (obj
->quantity
> 1) {
474 sprintf(desc
, "%d rations of ", obj
->quantity
);
476 (void) strcpy(desc
, "some ");
479 (void) strcpy(desc
, "a ");
481 (void) strcat(desc
, item_name
);
484 id_table
= get_id_table(obj
);
489 if (obj
->what_is
& (WEAPON
| ARMOR
| WAND
| RING
)) {
493 switch(id_table
[obj
->which_kind
].id_status
) {
496 switch(obj
->what_is
) {
498 (void) strcat(desc
, item_name
);
499 (void) strcat(desc
, "entitled: ");
500 (void) strcat(desc
, id_table
[obj
->which_kind
].title
);
503 (void) strcat(desc
, id_table
[obj
->which_kind
].title
);
504 (void) strcat(desc
, item_name
);
508 if (obj
->identified
||
509 (id_table
[obj
->which_kind
].id_status
== IDENTIFIED
)) {
512 if (id_table
[obj
->which_kind
].id_status
== CALLED
) {
515 (void) strcat(desc
, id_table
[obj
->which_kind
].title
);
516 (void) strcat(desc
, item_name
);
519 if (obj
->identified
) {
522 (void) strcpy(desc
, id_table
[obj
->which_kind
].title
);
525 if (obj
->identified
) {
528 (void) strcat(desc
, name_of(obj
));
533 CALL
: switch(obj
->what_is
) {
538 (void) strcat(desc
, item_name
);
539 (void) strcat(desc
, "called ");
540 (void) strcat(desc
, id_table
[obj
->which_kind
].title
);
545 ID
: switch(obj
->what_is
) {
548 (void) strcat(desc
, item_name
);
549 (void) strcat(desc
, id_table
[obj
->which_kind
].real
);
552 if (wizard
|| obj
->identified
) {
553 if ((obj
->which_kind
== DEXTERITY
) ||
554 (obj
->which_kind
== ADD_STRENGTH
)) {
555 sprintf(more_info
, "%s%d ", ((obj
->class > 0) ? "+" : ""),
557 (void) strcat(desc
, more_info
);
560 (void) strcat(desc
, item_name
);
561 (void) strcat(desc
, id_table
[obj
->which_kind
].real
);
564 (void) strcat(desc
, item_name
);
565 (void) strcat(desc
, id_table
[obj
->which_kind
].real
);
566 if (wizard
|| obj
->identified
) {
567 sprintf(more_info
, "[%d]", obj
->class);
568 (void) strcat(desc
, more_info
);
572 sprintf(desc
, "%s%d ", ((obj
->d_enchant
>= 0) ? "+" : ""),
574 (void) strcat(desc
, id_table
[obj
->which_kind
].title
);
575 sprintf(more_info
, "[%d] ", get_armor_class(obj
));
576 (void) strcat(desc
, more_info
);
579 sprintf(desc
+strlen(desc
), "%s%d,%s%d ",
580 ((obj
->hit_enchant
>= 0) ? "+" : ""), obj
->hit_enchant
,
581 ((obj
->d_enchant
>= 0) ? "+" : ""), obj
->d_enchant
);
582 (void) strcat(desc
, name_of(obj
));
588 if (!strncmp(desc
, "a ", 2)) {
589 if (is_vowel(desc
[2])) {
590 for (i
= strlen(desc
) + 1; i
> 1; i
--) {
596 if (obj
->in_use_flags
& BEING_WIELDED
) {
597 (void) strcat(desc
, "in hand");
598 } else if (obj
->in_use_flags
& BEING_WORN
) {
599 (void) strcat(desc
, "being worn");
600 } else if (obj
->in_use_flags
& ON_LEFT_HAND
) {
601 (void) strcat(desc
, "on left hand");
602 } else if (obj
->in_use_flags
& ON_RIGHT_HAND
) {
603 (void) strcat(desc
, "on right hand");
607 get_wand_and_ring_materials()
610 boolean used
[WAND_MATERIALS
];
612 for (i
= 0; i
< WAND_MATERIALS
; i
++) {
615 for (i
= 0; i
< WANDS
; i
++) {
617 j
= get_rand(0, WAND_MATERIALS
-1);
620 (void) strcpy(id_wands
[i
].title
, wand_materials
[j
]);
621 is_wood
[i
] = (j
> MAX_METAL
);
623 for (i
= 0; i
< GEMS
; i
++) {
626 for (i
= 0; i
< RINGS
; i
++) {
628 j
= get_rand(0, GEMS
-1);
631 (void) strcpy(id_rings
[i
].title
, gems
[j
]);
642 ch
= ichar
? ichar
: pack_letter("inventory what?", ALL_OBJECTS
);
647 if (!(obj
= get_letter_object(ch
))) {
648 message("no such item.", 0);
652 desc
[1] = ((obj
->what_is
& ARMOR
) && obj
->is_protected
) ? '}' : ')';
655 get_desc(obj
, desc
+3);
663 switch(obj
->what_is
) {
677 return((struct id
*) 0);
680 inv_armor_weapon(is_weapon
)
685 single_inv(rogue
.weapon
->ichar
);
687 message("not wielding anything", 0);
691 single_inv(rogue
.armor
->ichar
);
693 message("not wearing anything", 0);
704 message("what do you want identified?", 0);
708 if ((ch
>= 'A') && (ch
<= 'Z')) {
709 id
= m_names
[ch
-'A'];
710 } else if (ch
< 32) {
729 id
= "wall of a room";
750 id
= "wand or staff";
765 id
= "the Amulet of Yendor";
768 id
= "unknown character";
773 sprintf(buf
, "'%c': %s", ch
, id
);