* 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
static char sccsid
[] = "@(#)object.c 5.1 (Berkeley) %G%";
unsigned short dungeon
[DROWS
][DCOLS
];
object
*free_list
= (object
*) 0;
char *fruit
= (char *) 0;
INIT_AW
, /* armor, weapon */
INIT_HP
, /* Hp current,max */
INIT_STR
, /* Str current,max */
INIT_EXP
, /* exp level,points */
struct id id_potions
[POTIONS
] = {
{100, "blue \0 ", "of increase strength ", 0},
{250, "red \0 ", "of restore strength ", 0},
{100, "green \0 ", "of healing ", 0},
{200, "grey \0 ", "of extra healing ", 0},
{10, "brown \0 ", "of poison ", 0},
{300, "clear \0 ", "of raise level ", 0},
{10, "pink \0 ", "of blindness ", 0},
{25, "white \0 ", "of hallucination ", 0},
{100, "purple \0 ", "of detect monster ", 0},
{100, "black \0 ", "of detect things ", 0},
{10, "yellow \0 ", "of confusion ", 0},
{80, "plaid \0 ", "of levitation ", 0},
{150, "burgundy \0 ", "of haste self ", 0},
{145, "beige \0 ", "of see invisible ", 0}
struct id id_scrolls
[SCROLS
] = {
{505, " ", "of protect armor ", 0},
{200, " ", "of hold monster ", 0},
{235, " ", "of enchant weapon ", 0},
{235, " ", "of enchant armor ", 0},
{175, " ", "of identify ", 0},
{190, " ", "of teleportation ", 0},
{25, " ", "of sleep ", 0},
{610, " ", "of scare monster ", 0},
{210, " ", "of remove curse ", 0},
{80, " ", "of create monster ",0},
{25, " ", "of aggravate monster ",0},
{180, " ", "of magic mapping ", 0},
{90, " ", "of confuse monster ", 0}
struct id id_weapons
[WEAPONS
] = {
{150, "short bow ", "", 0},
{35, "shurikens ", "", 0},
{470, "long sword ", "", 0},
{580, "two-handed sword ", "", 0}
struct id id_armors
[ARMORS
] = {
{300, "leather armor ", "", (UNIDENTIFIED
)},
{300, "ring mail ", "", (UNIDENTIFIED
)},
{400, "scale mail ", "", (UNIDENTIFIED
)},
{500, "chain mail ", "", (UNIDENTIFIED
)},
{600, "banded mail ", "", (UNIDENTIFIED
)},
{600, "splint mail ", "", (UNIDENTIFIED
)},
{700, "plate mail ", "", (UNIDENTIFIED
)}
struct id id_wands
[WANDS
] = {
{25, " ", "of teleport away ",0},
{50, " ", "of slow monster ", 0},
{8, " ", "of invisibility ",0},
{55, " ", "of polymorph ",0},
{2, " ", "of haste monster ",0},
{20, " ", "of magic missile ",0},
{20, " ", "of cancellation ",0},
{0, " ", "of do nothing ",0},
{35, " ", "of drain life ",0},
struct id id_rings
[RINGS
] = {
{250, " ", "of stealth ",0},
{100, " ", "of teleportation ", 0},
{255, " ", "of regeneration ",0},
{295, " ", "of slow digestion ",0},
{200, " ", "of add strength ",0},
{250, " ", "of sustain strength ",0},
{250, " ", "of dexterity ",0},
{25, " ", "of adornment ",0},
{300, " ", "of see invisible ",0},
{290, " ", "of maintain armor ",0},
{270, " ", "of searching ",0},
extern short cur_level
, max_level
;
extern boolean is_wood
[];
if (cur_level
< max_level
) {
n
= coin_toss() ? get_rand(2, 4) : get_rand(3, 5);
while (rand_percent(33)) {
if (party_room
!= NO_ROOM
) {
for (i
= 0; i
< n
; i
++) {
boolean is_maze
, is_room
;
for (i
= 0; i
< MAXROOMS
; i
++) {
is_maze
= (rooms
[i
].is_room
& R_MAZE
) ? 1 : 0;
is_room
= (rooms
[i
].is_room
& R_ROOM
) ? 1 : 0;
if (!(is_room
|| is_maze
)) {
if (is_maze
|| rand_percent(GOLD_PERCENT
)) {
for (j
= 0; j
< 50; j
++) {
row
= get_rand(rooms
[i
].top_row
+1,
col
= get_rand(rooms
[i
].left_col
+1,
if ((dungeon
[row
][col
] == FLOOR
) ||
(dungeon
[row
][col
] == TUNNEL
)) {
plant_gold(row
, col
, is_maze
);
plant_gold(row
, col
, is_maze
)
obj
->row
= row
; obj
->col
= col
;
obj
->quantity
= get_rand((2 * cur_level
), (16 * cur_level
));
obj
->quantity
+= obj
->quantity
/ 2;
dungeon
[row
][col
] |= OBJECT
;
(void) add_to_pack(obj
, &level_objects
, 0);
dungeon
[row
][col
] |= OBJECT
;
(void) add_to_pack(obj
, &level_objects
, 0);
object_at(pack
, row
, col
)
object
*obj
= (object
*) 0;
if (dungeon
[row
][col
] & (MONSTER
| OBJECT
)) {
while (obj
&& ((obj
->row
!= row
) || (obj
->col
!= col
))) {
message("object_at(): inconsistent", 1);
obj
= rogue
.pack
.next_object
;
while (obj
&& (obj
->ichar
!= ch
)) {
while (objlist
->next_object
) {
obj
= objlist
->next_object
;
objlist
->next_object
->next_object
;
retstring
= obj
->quantity
> 1 ? "scrolls " : "scroll ";
retstring
= obj
->quantity
> 1 ? "potions " : "potion ";
if (obj
->which_kind
== RATION
) {
retstring
= is_wood
[obj
->which_kind
] ? "staff " : "wand ";
switch(obj
->which_kind
) {
retstring
=obj
->quantity
> 1 ? "darts " : "dart ";
retstring
=obj
->quantity
> 1 ? "arrows " : "arrow ";
retstring
=obj
->quantity
> 1 ? "daggers " : "dagger ";
retstring
=obj
->quantity
> 1?"shurikens ":"shuriken ";
retstring
= id_weapons
[obj
->which_kind
].title
;
if (foods
< (cur_level
/ 3)) {
obj
->what_is
= gr_what_is();
percent
= get_rand(1, 91);
} else if (percent
<= 60) {
} else if (percent
<= 64) {
} else if (percent
<= 74) {
} else if (percent
<= 83) {
} else if (percent
<= 88) {
percent
= get_rand(0, 91);
obj
->which_kind
= PROTECT_ARMOR
;
} else if (percent
<= 10) {
obj
->which_kind
= HOLD_MONSTER
;
} else if (percent
<= 20) {
obj
->which_kind
= CREATE_MONSTER
;
} else if (percent
<= 35) {
obj
->which_kind
= IDENTIFY
;
} else if (percent
<= 43) {
obj
->which_kind
= TELEPORT
;
} else if (percent
<= 50) {
} else if (percent
<= 55) {
obj
->which_kind
= SCARE_MONSTER
;
} else if (percent
<= 64) {
obj
->which_kind
= REMOVE_CURSE
;
} else if (percent
<= 69) {
obj
->which_kind
= ENCH_ARMOR
;
} else if (percent
<= 74) {
obj
->which_kind
= ENCH_WEAPON
;
} else if (percent
<= 80) {
obj
->which_kind
= AGGRAVATE_MONSTER
;
} else if (percent
<= 86) {
obj
->which_kind
= CON_MON
;
obj
->which_kind
= MAGIC_MAPPING
;
percent
= get_rand(1, 118);
obj
->which_kind
= RAISE_LEVEL
;
} else if (percent
<= 15) {
obj
->which_kind
= DETECT_OBJECTS
;
} else if (percent
<= 25) {
obj
->which_kind
= DETECT_MONSTER
;
} else if (percent
<= 35) {
obj
->which_kind
= INCREASE_STRENGTH
;
} else if (percent
<= 45) {
obj
->which_kind
= RESTORE_STRENGTH
;
} else if (percent
<= 55) {
obj
->which_kind
= HEALING
;
} else if (percent
<= 65) {
obj
->which_kind
= EXTRA_HEALING
;
} else if (percent
<= 75) {
obj
->which_kind
= BLINDNESS
;
} else if (percent
<= 85) {
obj
->which_kind
= HALLUCINATION
;
} else if (percent
<= 95) {
obj
->which_kind
= CONFUSION
;
} else if (percent
<= 105) {
obj
->which_kind
= POISON
;
} else if (percent
<= 110) {
obj
->which_kind
= LEVITATION
;
} else if (percent
<= 114) {
obj
->which_kind
= HASTE_SELF
;
obj
->which_kind
= SEE_INVISIBLE
;
gr_weapon(obj
, assign_wk
)
short blessing
, increment
;
obj
->which_kind
= get_rand(0, (WEAPONS
- 1));
if ((obj
->which_kind
== ARROW
) || (obj
->which_kind
== DAGGER
) ||
(obj
->which_kind
== SHURIKEN
) | (obj
->which_kind
== DART
)) {
obj
->quantity
= get_rand(3, 15);
obj
->quiver
= get_rand(0, 126);
obj
->hit_enchant
= obj
->d_enchant
= 0;
percent
= get_rand(1, 96);
blessing
= get_rand(1, 3);
} else if (percent
<= 32) {
for (i
= 0; i
< blessing
; i
++) {
obj
->hit_enchant
+= increment
;
obj
->d_enchant
+= increment
;
switch(obj
->which_kind
) {
obj
->which_kind
= get_rand(0, (ARMORS
- 1));
obj
->class = obj
->which_kind
+ 2;
if ((obj
->which_kind
== PLATE
) || (obj
->which_kind
== SPLINT
)) {
percent
= get_rand(1, 100);
blessing
= get_rand(1, 3);
obj
->d_enchant
-= blessing
;
} else if (percent
<= 33) {
obj
->d_enchant
+= blessing
;
obj
->which_kind
= get_rand(0, (WANDS
- 1));
obj
->class = get_rand(3, 7);
get_food(obj
, force_ration
)
if (force_ration
|| rand_percent(80)) {
obj
->which_kind
= RATION
;
gr_row_col(&row
, &col
, (FLOOR
| TUNNEL
));
dungeon
[row
][col
] |= STAIRS
;
return(obj
->class + obj
->d_enchant
);
free_list
= free_list
->next_object
;
} else if (!(obj
= (object
*) md_malloc(sizeof(object
)))) {
message("cannot allocate object, saving game", 0);
save_into_file(error_file
);
obj
->picked_up
= obj
->is_cursed
= 0;
obj
->in_use_flags
= NOT_USED
;
obj
->identified
= UNIDENTIFIED
;
obj
->next_object
= free_list
;
n
= rand_percent(99) ? party_objects(party_room
) : 11;
party_monsters(party_room
, n
);
obj
= level_objects
.next_object
;
rc
= get_mask_char(obj
->what_is
);
if (dungeon
[row
][col
] & MONSTER
) {
if (monster
= object_at(&level_monsters
, row
, col
)) {
monster
->trail_char
= rc
;
if (((mc
< 'A') || (mc
> 'Z')) &&
((row
!= rogue
.row
) || (col
!= rogue
.col
))) {
monster
= level_monsters
.next_object
;
if (monster
->m_flags
& IMITATES
) {
mvaddch(monster
->row
, monster
->col
, (int) monster
->disguise
);
monster
= monster
->next_monster
;
gr_row_col(&row
, &col
, (FLOOR
| TUNNEL
));
if (pack_count((object
*) 0) >= MAX_PACK_COUNT
) {
message("type of object?", 0);
while (r_index("!?:)]=/,\033", (ch
= rgetchar()), 0) == -1) {
if ((ch
!= ',') && (ch
!= ':')) {
if (get_input_line("which kind?", "", buf
, "", 0, 1)) {
if ((wk
>= 0) && (wk
<= max
)) {
obj
->which_kind
= (unsigned short) wk
;
if (obj
->what_is
== RING
) {
(void) add_to_pack(obj
, &rogue
.pack
, 1);