* Copyright (c) 1988 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)inventory.c 5.4 (Berkeley) 6/1/90";
* This source herein may be modified and/or distributed by anybody who
* so desires, with the following restrictions:
* 1.) No portion of this notice shall be removed.
* 2.) Credit shall not be taken for the creation of this source.
* 3.) This code is not to be traded, sold, or used for personal
char *press_space
= " --press space to continue--";
char *wand_materials
[WAND_MATERIALS
] = {
char *syllables
[MAXSYLLABLES
] = {
struct id_com_s com_id_tab
[COMS
] = {
'/', "/ identify object",
NULL
, "<SHIFT><dir>: run that way",
')', ") print current weapon",
NULL
, "<CTRL><dir>: run till adjacent",
']', "] print current armor",
'f', "f<dir> fight till death or near death",
'=', "= print current rings",
't', "t<dir> throw something",
'\001', "^A print Hp-raise average",
'm', "m<dir> move onto without picking up",
'z', "z<dir> zap a wand in a direction",
'o', "o examine/set options",
'^', "^<dir> identify trap type",
'\022', "^R redraw screen",
'&', "& save screen into 'rogue.screen'",
's', "s search for trap/secret door",
'\020', "^P repeat last message",
'>', "> go down a staircase",
'\033', "^[ cancel command",
'<', "< go up a staircase",
'.', ". rest for a turn",
',', ", pick something up",
'F', "F<dir> fight till either of you dies",
'I', "I inventory single item",
'v', "v print version number",
extern char *m_names
[], *more
;
short i
= 0, j
, maxlen
= 0, n
;
char descs
[MAX_PACK_COUNT
+1][DCOLS
];
message("your pack is empty", 0);
if (obj
->what_is
& mask
) {
descs
[i
][1] = obj
->ichar
;
descs
[i
][2] = ((obj
->what_is
& ARMOR
) && obj
->is_protected
)
get_desc(obj
, descs
[i
]+4);
if ((n
= strlen(descs
[i
])) > maxlen
) {
(void) strcpy(descs
[i
++], press_space
);
if (maxlen
< 27) maxlen
= 27;
col
= DCOLS
- (maxlen
+ 2);
for (row
= 0; ((row
< i
) && (row
< DROWS
)); row
++) {
for (j
= col
; j
< DCOLS
; j
++) {
descs
[row
-1][j
-col
] = mvinch(row
, j
);
mvaddstr(row
, col
, descs
[row
]);
for (j
= 1; ((j
< i
) && (j
< DROWS
)); j
++) {
mvaddstr(j
, col
, descs
[j
-1]);
message("Character you want help for (* for all):", 0);
char save
[(((COMS
/ 2) + (COMS
% 2)) + 1)][DCOLS
];
short rows
= (((COMS
/ 2) + (COMS
% 2)) + 1);
boolean need_two_screens
;
for (i
= 0; i
< rows
; i
++) {
for (j
= 0; j
< DCOLS
; j
++) {
save
[i
][j
] = mvinch(i
, j
);
for (i
= 0; i
< rows
; i
++) {
for (i
= 0; i
< (rows
-1); i
++) {
if (((i
+ i
) < COMS
) && ((i
+i
+k
) < COMS
)) {
mvaddstr(i
, 0, com_id_tab
[i
+i
+k
].com_desc
);
if (((i
+ i
+ 1) < COMS
) && ((i
+i
+k
+1) < COMS
)) {
com_id_tab
[i
+i
+k
+1].com_desc
);
mvaddstr(rows
- 1, 0, need_two_screens
? more
: press_space
);
for (i
= 0; i
< rows
; i
++) {
for (j
= 0; j
< DCOLS
; j
++) {
if (!pr_motion_char(ch
)) {
message("unknown character", 0);
if (!get_com_id(&i
, ch
)) {
message(com_id_tab
[i
].com_desc
, 0);
for (i
= 0; i
< COMS
; i
++) {
if (com_id_tab
[i
].com_char
== ch
) {
char until
[18], buf
[DCOLS
];
(void) strcpy(until
, "until adjascent");
(void) get_com_id(&n
, ch
);
sprintf(buf
, "run %s %s", com_id_tab
[n
].com_desc
+ 8, until
);
for (i
= 0; i
<= 32; i
++) {
j
= get_rand(0, (POTIONS
- 1));
k
= get_rand(0, (POTIONS
- 1));
id_potions
[j
].title
= id_potions
[k
].title
;
for (i
= 0; i
< SCROLS
; i
++) {
(void) strcpy(id_scrolls
[i
].title
, "'");
for (j
= 0; j
< sylls
; j
++) {
s
= get_rand(1, (MAXSYLLABLES
-1));
(void) strcat(id_scrolls
[i
].title
, syllables
[s
]);
n
= strlen(id_scrolls
[i
].title
);
(void) strcpy(id_scrolls
[i
].title
+(n
-1), "' ");
if (obj
->what_is
== AMULET
) {
(void) strcpy(desc
, "the amulet of Yendor ");
item_name
= name_of(obj
);
if (obj
->what_is
== GOLD
) {
sprintf(desc
, "%d pieces of gold", obj
->quantity
);
if (obj
->what_is
!= ARMOR
) {
if (obj
->quantity
== 1) {
(void) strcpy(desc
, "a ");
sprintf(desc
, "%d ", obj
->quantity
);
if (obj
->what_is
== FOOD
) {
if (obj
->which_kind
== RATION
) {
sprintf(desc
, "%d rations of ", obj
->quantity
);
(void) strcpy(desc
, "some ");
(void) strcpy(desc
, "a ");
(void) strcat(desc
, item_name
);
id_table
= get_id_table(obj
);
if (obj
->what_is
& (WEAPON
| ARMOR
| WAND
| RING
)) {
switch(id_table
[obj
->which_kind
].id_status
) {
(void) strcat(desc
, item_name
);
(void) strcat(desc
, "entitled: ");
(void) strcat(desc
, id_table
[obj
->which_kind
].title
);
(void) strcat(desc
, id_table
[obj
->which_kind
].title
);
(void) strcat(desc
, item_name
);
(id_table
[obj
->which_kind
].id_status
== IDENTIFIED
)) {
if (id_table
[obj
->which_kind
].id_status
== CALLED
) {
(void) strcat(desc
, id_table
[obj
->which_kind
].title
);
(void) strcat(desc
, item_name
);
(void) strcpy(desc
, id_table
[obj
->which_kind
].title
);
(void) strcat(desc
, name_of(obj
));
CALL
: switch(obj
->what_is
) {
(void) strcat(desc
, item_name
);
(void) strcat(desc
, "called ");
(void) strcat(desc
, id_table
[obj
->which_kind
].title
);
ID
: switch(obj
->what_is
) {
(void) strcat(desc
, item_name
);
(void) strcat(desc
, id_table
[obj
->which_kind
].real
);
if (wizard
|| obj
->identified
) {
if ((obj
->which_kind
== DEXTERITY
) ||
(obj
->which_kind
== ADD_STRENGTH
)) {
sprintf(more_info
, "%s%d ", ((obj
->class > 0) ? "+" : ""),
(void) strcat(desc
, more_info
);
(void) strcat(desc
, item_name
);
(void) strcat(desc
, id_table
[obj
->which_kind
].real
);
(void) strcat(desc
, item_name
);
(void) strcat(desc
, id_table
[obj
->which_kind
].real
);
if (wizard
|| obj
->identified
) {
sprintf(more_info
, "[%d]", obj
->class);
(void) strcat(desc
, more_info
);
sprintf(desc
, "%s%d ", ((obj
->d_enchant
>= 0) ? "+" : ""),
(void) strcat(desc
, id_table
[obj
->which_kind
].title
);
sprintf(more_info
, "[%d] ", get_armor_class(obj
));
(void) strcat(desc
, more_info
);
sprintf(desc
+strlen(desc
), "%s%d,%s%d ",
((obj
->hit_enchant
>= 0) ? "+" : ""), obj
->hit_enchant
,
((obj
->d_enchant
>= 0) ? "+" : ""), obj
->d_enchant
);
(void) strcat(desc
, name_of(obj
));
if (!strncmp(desc
, "a ", 2)) {
for (i
= strlen(desc
) + 1; i
> 1; i
--) {
if (obj
->in_use_flags
& BEING_WIELDED
) {
(void) strcat(desc
, "in hand");
} else if (obj
->in_use_flags
& BEING_WORN
) {
(void) strcat(desc
, "being worn");
} else if (obj
->in_use_flags
& ON_LEFT_HAND
) {
(void) strcat(desc
, "on left hand");
} else if (obj
->in_use_flags
& ON_RIGHT_HAND
) {
(void) strcat(desc
, "on right hand");
get_wand_and_ring_materials()
boolean used
[WAND_MATERIALS
];
for (i
= 0; i
< WAND_MATERIALS
; i
++) {
for (i
= 0; i
< WANDS
; i
++) {
j
= get_rand(0, WAND_MATERIALS
-1);
(void) strcpy(id_wands
[i
].title
, wand_materials
[j
]);
is_wood
[i
] = (j
> MAX_METAL
);
for (i
= 0; i
< GEMS
; i
++) {
for (i
= 0; i
< RINGS
; i
++) {
(void) strcpy(id_rings
[i
].title
, gems
[j
]);
ch
= ichar
? ichar
: pack_letter("inventory what?", ALL_OBJECTS
);
if (!(obj
= get_letter_object(ch
))) {
message("no such item.", 0);
desc
[1] = ((obj
->what_is
& ARMOR
) && obj
->is_protected
) ? '}' : ')';
inv_armor_weapon(is_weapon
)
single_inv(rogue
.weapon
->ichar
);
message("not wielding anything", 0);
single_inv(rogue
.armor
->ichar
);
message("not wearing anything", 0);
message("what do you want identified?", 0);
if ((ch
>= 'A') && (ch
<= 'Z')) {
id
= "the Amulet of Yendor";
id
= "unknown character";
sprintf(buf
, "'%c': %s", ch
, id
);