annotate arogue7/monsters.c @ 311:28e22fb35989

Fix one more batch of compiler warnings. A few of these were potential bugs.
author John "Elwin" Edwards
date Tue, 04 May 2021 21:03:47 -0400
parents e1cd27c5464f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2 * monsters.c - File with various monster functions in it
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3 *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
4 * Advanced Rogue
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
5 * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
6 * All rights reserved.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
7 *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
8 * Based on "Rogue: Exploring the Dungeons of Doom"
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
10 * All rights reserved.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
11 *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
12 * See the file LICENSE.TXT for full copyright and licensing information.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
13 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
14
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
15 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
16 * File with various monster functions in it
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
17 *
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
18 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
19
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
20 #include "curses.h"
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
21 #include "rogue.h"
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
22 #include <ctype.h>
126
b786053d2f37 arogue7: add missing header includes.
John "Elwin" Edwards
parents: 125
diff changeset
23 #include <string.h>
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
24 #include <stdlib.h>
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
25
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
26
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
27 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
28 * Check_residue takes care of any effect of the monster
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
29 */
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
30 void
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
31 check_residue(struct thing *tp)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
32 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
33 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
34 * Take care of special abilities
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
35 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
36 if (on(*tp, DIDHOLD) && (--hold_count == 0)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
37 turn_off(player, ISHELD);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
38 turn_off(*tp, DIDHOLD);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
39 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
40
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
41 /* If frightened of this monster, stop */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
42 if (on(player, ISFLEE) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
43 player.t_dest == &tp->t_pos) turn_off(player, ISFLEE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
44
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
45 /* If monster was suffocating player, stop it */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
46 if (on(*tp, DIDSUFFOCATE)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
47 extinguish(suffocate);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
48 turn_off(*tp, DIDSUFFOCATE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
49 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
50
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
51 /* If something with fire, may darken */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
52 if (on(*tp, HASFIRE)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
53 register struct room *rp=roomin(&tp->t_pos);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
54 register struct linked_list *fire_item;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
55
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
56 if (rp) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
57 for (fire_item = rp->r_fires; fire_item != NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
58 fire_item = next(fire_item)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
59 if (THINGPTR(fire_item) == tp) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
60 detach(rp->r_fires, fire_item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
61 destroy_item(fire_item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
62 if (rp->r_fires == NULL) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
63 rp->r_flags &= ~HASFIRE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
64 if (cansee(tp->t_pos.y, tp->t_pos.x)) light(&hero);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
65 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
66 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
67 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
68 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
69 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
70 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
71 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
72
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
73 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
74 * Creat_mons creates the specified monster -- any if 0
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
75 * person: Where to create next to
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
76 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
77
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
78 bool
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
79 creat_mons(struct thing *person, short monster, bool report)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
80 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
81 struct linked_list *nitem;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
82 register struct thing *tp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
83 struct room *rp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
84 coord *mp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
85
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
86 if (levtype == POSTLEV)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
87 return(FALSE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
88 if ((mp = fallpos(&(person->t_pos), FALSE, 2)) != NULL) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
89 nitem = new_item(sizeof (struct thing));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
90 new_monster(nitem,
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
91 monster == 0 ? randmonster(FALSE, FALSE)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
92 : monster,
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
93 mp,
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
94 TRUE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
95 tp = THINGPTR(nitem);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
96 runto(tp, &hero);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
97 carry_obj(tp, monsters[tp->t_index].m_carry/2); /* only half chance */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
98
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
99 /* since it just got here, it is disoriented */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
100 tp->t_no_move = 2 * movement(tp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
101
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
102 if (on(*tp, HASFIRE)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
103 rp = roomin(&tp->t_pos);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
104 if (rp) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
105 register struct linked_list *fire_item;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
106
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
107 /* Put the new fellow in the room list */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
108 fire_item = creat_item();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
109 ldata(fire_item) = (char *) tp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
110 attach(rp->r_fires, fire_item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
111
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
112 rp->r_flags |= HASFIRE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
113 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
114 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
115
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
116 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
117 * If we can see this monster, set oldch to ' ' to make light()
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
118 * think the creature used to be invisible (ie. not seen here)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
119 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
120 if (cansee(tp->t_pos.y, tp->t_pos.x)) tp->t_oldch = ' ';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
121 return(TRUE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
122 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
123 if (report) msg("You hear a faint cry of anguish in the distance.");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
124 return(FALSE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
125 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
126
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
127 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
128 * Genmonsters:
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
129 * Generate at least 'least' monsters for this single room level.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
130 * 'Treas' indicates whether this is a "treasure" level.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
131 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
132
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
133 void
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
134 genmonsters(int least, bool treas)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
135 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
136 reg int i;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
137 reg struct room *rp = &rooms[0];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
138 reg struct linked_list *item;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
139 reg struct thing *mp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
140 coord tp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
141
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
142 for (i = 0; i < level + least; i++) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
143 if (!treas && rnd(100) < 50) /* put in some little buggers */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
144 continue;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
145 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
146 * Put the monster in
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
147 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
148 item = new_item(sizeof *mp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
149 mp = THINGPTR(item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
150 do {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
151 rnd_pos(rp, &tp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
152 } until(mvwinch(stdscr, tp.y, tp.x) == FLOOR);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
153
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
154 new_monster(item, randmonster(FALSE, FALSE), &tp, FALSE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
155 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
156 * See if we want to give it a treasure to carry around.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
157 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
158 carry_obj(mp, monsters[mp->t_index].m_carry);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
159
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
160 /* Calculate a movement rate */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
161 mp->t_no_move = movement(mp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
162
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
163 /* Is it going to give us some light? */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
164 if (on(*mp, HASFIRE)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
165 register struct linked_list *fire_item;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
166
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
167 fire_item = creat_item();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
168 ldata(fire_item) = (char *) mp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
169 attach(rp->r_fires, fire_item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
170 rp->r_flags |= HASFIRE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
171 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
172 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
173 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
174
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
175 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
176 * id_monst returns the index of the monster given its letter
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
177 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
178
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
179 short
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
180 id_monst(char monster)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
181 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
182 register short result;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
183
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
184 result = NLEVMONS*vlevel;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
185 if (result > NUMMONST) result = NUMMONST;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
186
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
187 for(; result>0; result--)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
188 if (monsters[result].m_appear == monster) return(result);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
189 for (result=(NLEVMONS*vlevel)+1; result <= NUMMONST; result++)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
190 if (monsters[result].m_appear == monster) return(result);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
191 return(0);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
192 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
193
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
194
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
195 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
196 * new_monster:
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
197 * Pick a new monster and add it to the list
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
198 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
199
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
200 void
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
201 new_monster(struct linked_list *item, short type, coord *cp, bool max_monster)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
202 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
203 register struct thing *tp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
204 register struct monster *mp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
205 register char *ip, *hitp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
206 register int i, min_intel, max_intel;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
207 register int num_dice, num_sides=8, num_extra=0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
208
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
209 attach(mlist, item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
210 tp = THINGPTR(item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
211 tp->t_pack = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
212 tp->t_index = type;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
213 tp->t_wasshot = FALSE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
214 tp->t_type = monsters[type].m_appear;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
215 tp->t_ctype = C_MONSTER;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
216 tp->t_action = A_NIL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
217 tp->t_doorgoal = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
218 tp->t_quiet = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
219 tp->t_dest = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
220 tp->t_name = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
221 tp->t_pos = tp->t_oldpos = *cp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
222 tp->t_oldch = CCHAR( mvwinch(cw, cp->y, cp->x) );
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
223 mvwaddch(mw, cp->y, cp->x, tp->t_type);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
224 mp = &monsters[tp->t_index];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
225
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
226 /* Figure out monster's hit points */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
227 hitp = mp->m_stats.s_hpt;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
228 num_dice = atoi(hitp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
229 if ((hitp = strchr(hitp, 'd')) != NULL) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
230 num_sides = atoi(++hitp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
231 if ((hitp = strchr(hitp, '+')) != NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
232 num_extra = atoi(++hitp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
233 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
234
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
235 tp->t_stats.s_lvladj = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
236 tp->t_stats.s_lvl = mp->m_stats.s_lvl;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
237 tp->t_stats.s_arm = mp->m_stats.s_arm;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
238 strncpy(tp->t_stats.s_dmg, mp->m_stats.s_dmg, sizeof(tp->t_stats.s_dmg));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
239 tp->t_stats.s_str = mp->m_stats.s_str;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
240 tp->t_stats.s_dext = mp->m_stats.s_dex;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
241 tp->t_movement = mp->m_stats.s_move;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
242 if (vlevel > HARDER) { /* the deeper, the meaner we get */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
243 tp->t_stats.s_lvl += (vlevel - HARDER);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
244 num_dice += (vlevel - HARDER)/2;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
245 tp->t_stats.s_arm -= (vlevel - HARDER) / 4;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
246 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
247 if (max_monster)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
248 tp->t_stats.s_hpt = num_dice * num_sides + num_extra;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
249 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
250 tp->t_stats.s_hpt = roll(num_dice, num_sides) + num_extra;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
251 tp->t_stats.s_exp = mp->m_stats.s_exp + mp->m_add_exp*tp->t_stats.s_hpt;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
252
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
253 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
254 * just initailize others values to something reasonable for now
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
255 * maybe someday will *really* put these in monster table
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
256 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
257 tp->t_stats.s_wisdom = 8 + rnd(4);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
258 tp->t_stats.s_const = 8 + rnd(4);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
259 tp->t_stats.s_charisma = 8 + rnd(4);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
260
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
261 /* Set the initial flags */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
262 for (i=0; i<16; i++) tp->t_flags[i] = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
263 for (i=0; i<MAXFLAGS; i++)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
264 turn_on(*tp, mp->m_flags[i]);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
265
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
266 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
267 * these are the base chances that a creatures will do something
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
268 * assuming it can. These are(or can be) modified at runtime
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
269 * based on what the creature experiences
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
270 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
271 tp->t_breathe = 75; /* base chance of breathing */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
272 tp->t_artifact = 90; /* base chance of using artifact */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
273 tp->t_summon = 40; /* base chance of summoning */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
274 tp->t_cast = 75; /* base chance of casting a spell */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
275 tp->t_wand = on(*tp, ISUNIQUE) ? 35 : 50; /* base chance of using wands */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
276
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
277 /* suprising monsters don't always surprise you */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
278 if (!max_monster && on(*tp, CANSURPRISE) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
279 off(*tp, ISUNIQUE) && rnd(100) < 20)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
280 turn_off(*tp, CANSURPRISE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
281
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
282 /* If this monster is unique, gen it */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
283 if (on(*tp, ISUNIQUE)) mp->m_normal = FALSE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
284
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
285 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
286 * If it is the quartermaster, then compute his level and exp pts
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
287 * based on the level. This will make it fair when thieves try to
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
288 * steal and give them reasonable experience if they succeed.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
289 * Then fill his pack with his wares.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
290 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
291 if (on(*tp, CANSELL)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
292 tp->t_stats.s_exp = vlevel * 100;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
293 tp->t_stats.s_lvl = vlevel/2 + 1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
294 make_sell_pack(tp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
295 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
296
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
297 /* Normally scared monsters have a chance to not be scared */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
298 if (on(*tp, ISFLEE) && (rnd(4) == 0)) turn_off(*tp, ISFLEE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
299
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
300 /* Figure intelligence */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
301 min_intel = atoi(mp->m_intel);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
302 if ((ip = (char *) strchr(mp->m_intel, '-')) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
303 tp->t_stats.s_intel = min_intel;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
304 else {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
305 max_intel = atoi(++ip);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
306 if (max_monster)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
307 tp->t_stats.s_intel = max_intel;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
308 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
309 tp->t_stats.s_intel = min_intel + rnd(max_intel - min_intel);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
310 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
311 if (vlevel > HARDER)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
312 tp->t_stats.s_intel += ((vlevel - HARDER)/2);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
313 tp->maxstats = tp->t_stats;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
314
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
315 /* If the monster can shoot, it may have a weapon */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
316 if (on(*tp, CANSHOOT) && ((rnd(100) < (22 + vlevel)) || max_monster)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
317 struct linked_list *item1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
318 register struct object *cur, *cur1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
319
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
320 item = new_item(sizeof *cur);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
321 item1 = new_item(sizeof *cur1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
322 cur = OBJPTR(item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
323 cur1 = OBJPTR(item1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
324 cur->o_hplus = (rnd(4) < 3) ? 0
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
325 : (rnd(3) + 1) * ((rnd(3) < 2) ? 1 : -1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
326 cur->o_dplus = (rnd(4) < 3) ? 0
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
327 : (rnd(3) + 1) * ((rnd(3) < 2) ? 1 : -1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
328 cur1->o_hplus = (rnd(4) < 3) ? 0
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
329 : (rnd(3) + 1) * ((rnd(3) < 2) ? 1 : -1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
330 cur1->o_dplus = (rnd(4) < 3) ? 0
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
331 : (rnd(3) + 1) * ((rnd(3) < 2) ? 1 : -1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
332
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
333 strncpy(cur->o_damage, "0d0", sizeof(cur->o_damage));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
334 strncpy(cur->o_hurldmg, "0d0", sizeof(cur->o_hurldmg));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
335 strncpy(cur1->o_damage, "0d0", sizeof(cur1->o_damage));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
336 strncpy(cur1->o_hurldmg, "0d0", sizeof(cur1->o_hurldmg));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
337
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
338 cur->o_ac = cur1->o_ac = 11;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
339 cur->o_count = cur1->o_count = 1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
340 cur->o_group = cur1->o_group = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
341 cur->contents = cur1->contents = NULL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
342 if ((cur->o_hplus <= 0) && (cur->o_dplus <= 0)) cur->o_flags = ISCURSED;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
343 if ((cur1->o_hplus <= 0) && (cur1->o_dplus <= 0))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
344 cur1->o_flags = ISCURSED;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
345 cur->o_flags = cur1->o_flags = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
346 cur->o_type = cur1->o_type = WEAPON;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
347 cur->o_mark[0] = cur1->o_mark[0] = '\0';
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
348
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
349 /* The monster may use a crossbow, sling, or an arrow */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
350 i = rnd(100);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
351 if (i < 10) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
352 cur->o_which = CROSSBOW;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
353 cur1->o_which = BOLT;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
354 init_weapon(cur, CROSSBOW);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
355 init_weapon(cur1, BOLT);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
356 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
357 else if (i < 70) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
358 cur->o_which = BOW;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
359 cur1->o_which = ARROW;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
360 init_weapon(cur, BOW);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
361 init_weapon(cur1, ARROW);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
362 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
363 else {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
364 cur->o_which = SLING;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
365 cur1->o_which = ROCK;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
366 init_weapon(cur, SLING);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
367 init_weapon(cur1, ROCK);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
368 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
369
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
370 attach(tp->t_pack, item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
371 attach(tp->t_pack, item1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
372 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
373
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
374
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
375 /* Calculate the initial movement rate */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
376 updpack(TRUE, tp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
377 tp->t_no_move = movement(tp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
378
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
379 if (ISWEARING(R_AGGR))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
380 runto(tp, &hero);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
381 if (on(*tp, ISDISGUISE))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
382 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
383 char mch;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
384
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
385 if (tp->t_pack != NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
386 mch = (OBJPTR(tp->t_pack))->o_type;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
387 else
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
388 switch (rnd(10)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
389 case 0: mch = GOLD;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
390 when 1: mch = POTION;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
391 when 2: mch = SCROLL;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
392 when 3: mch = FOOD;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
393 when 4: mch = WEAPON;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
394 when 5: mch = ARMOR;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
395 when 6: mch = RING;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
396 when 7: mch = STICK;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
397 when 8: mch = monsters[randmonster(FALSE, FALSE)].m_appear;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
398 when 9: mch = MM;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
399 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
400 tp->t_disguise = mch;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
401 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
402 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
403
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
404 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
405 * randmonster:
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
406 * Pick a monster to show up. The lower the level,
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
407 * the meaner the monster.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
408 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
409
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
410 short
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
411 randmonster(bool wander, bool no_unique)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
412 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
413 register int d, cur_level, range, i;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
414
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
415 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
416 * Do we want a merchant? Merchant is always in place 'NUMMONST'
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
417 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
418 if (wander && monsters[NUMMONST].m_wander && rnd(100) < pstats.s_charisma/4)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
419 return NUMMONST;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
420
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
421 cur_level = vlevel;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
422 range = 4*NLEVMONS;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
423 i = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
424 do
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
425 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
426 if (i++ > range*10) { /* just in case all have be genocided */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
427 i = 0;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
428 if (--cur_level <= 0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
429 fatal("Rogue could not find a monster to make");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
430 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
431 d = NLEVMONS*(cur_level - 1) + (rnd(range) - (range - 1 - NLEVMONS));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
432 if (d < 1)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
433 d = rnd(NLEVMONS) + 1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
434 if (d > NUMMONST - NUMUNIQUE - 1) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
435 if (no_unique)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
436 d = rnd(range) + (NUMMONST - NUMUNIQUE - 1) - (range - 1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
437 else if (d > NUMMONST - 1)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
438 d = rnd(range+NUMUNIQUE) + (NUMMONST-1) - (range+NUMUNIQUE-1);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
439 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
440 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
441 while (wander ? !monsters[d].m_wander || !monsters[d].m_normal
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
442 : !monsters[d].m_normal);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
443 return d;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
444 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
445
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
446 /* Sell displays a menu of goods from which the player may choose
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
447 * to purchase something.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
448 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
449
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
450 void
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
451 sell(struct thing *tp)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
452 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
453 register struct linked_list *item, *seller;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
454 register struct linked_list *sellpack;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
455 register struct object *obj;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
456 register int worth, min_worth;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
457 char buffer[LINELEN];
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
458
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
459
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
460 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
461 * Get a linked_list pointer to the seller. We need this in case
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
462 * he disappears so we can set monst_dead.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
463 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
464 seller = find_mons(tp->t_pos.y, tp->t_pos.x);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
465
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
466 sellpack = tp->t_pack;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
467 if (sellpack == NULL) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
468 msg("%s looks puzzled and departs.", prname(monster_name(tp), TRUE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
469
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
470 /* Get rid of the monster */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
471 killed(seller, FALSE, FALSE, FALSE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
472 return;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
473 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
474
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
475 /* See how much the minimum pack item is worth */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
476 min_worth = 100000;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
477 for (item = sellpack; item != NULL; item = next(item)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
478 obj = OBJPTR(item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
479 obj->o_flags |= ISPOST; /* Force a long description of the item */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
480 worth = get_worth(obj);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
481 if (worth < min_worth) min_worth = worth;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
482 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
483
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
484 /* See if player can afford an item */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
485 if (min_worth > purse) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
486 msg("%s eyes your small purse and departs.",
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
487 prname(monster_name(tp), TRUE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
488
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
489 /* Get rid of the monster */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
490 killed(seller, FALSE, FALSE, FALSE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
491 return;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
492 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
493
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
494 /* Announce our intentions */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
495 msg("%s opens his pack.--More--", prname(monster_name(tp), TRUE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
496 wait_for(' ');
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
497
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
498 /* Try to sell something */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
499 sprintf(buffer, "You got %d gold pieces. Buy", purse);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
500 item = get_item(sellpack, buffer, ALL, TRUE, TRUE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
501
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
502 /* Get rid of the monster */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
503 if (item != NULL) detach(tp->t_pack, item); /* Take it out of the pack */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
504 killed(seller, FALSE, FALSE, FALSE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
505
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
506 if (item == NULL) return;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
507
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
508 /* Can he afford the selected item? */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
509 obj = OBJPTR(item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
510
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
511 worth = get_worth(obj);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
512 if (worth > purse) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
513 msg("You cannot afford it.");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
514 o_discard(item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
515 return;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
516 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
517
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
518 /* Charge him through the nose */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
519 purse -= worth;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
520
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
521 /* If a stick or ring, let player know the type */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
522 switch (obj->o_type) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
523 case RING: r_know[obj->o_which] = TRUE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
524 when POTION:p_know[obj->o_which] = TRUE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
525 when SCROLL:s_know[obj->o_which] = TRUE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
526 when STICK: ws_know[obj->o_which] = TRUE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
527 when MM: m_know[obj->o_which] = TRUE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
528
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
529 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
530
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
531 /* Remove the POST flag that we used for get_item() */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
532 obj->o_flags &= ~ISPOST;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
533
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
534 if (add_pack(item, FALSE, NULL) == FALSE) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
535 obj->o_pos = hero;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
536 fall(item, TRUE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
537 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
538 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
539
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
540
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
541
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
542 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
543 * what to do when the hero steps next to a monster
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
544 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
545 struct linked_list *
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
546 wake_monster(int y, int x)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
547 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
548 register struct thing *tp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
549 register struct linked_list *it;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
550 register struct room *trp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
551 register char *mname;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
552 bool nasty; /* Will the monster "attack"? */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
553
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
554 if ((it = find_mons(y, x)) == NULL) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
555 msg("Wake: can't find monster in show (%d, %d)", y, x);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
556 return (NULL);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
557 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
558 tp = THINGPTR(it);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
559 if (on(*tp, ISSTONE)) /* if stoned, don't do anything */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
560 return it;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
561
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
562 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
563 * For now, if we are a friendly monster, we won't do any of
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
564 * our special effects.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
565 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
566 if (on(*tp, ISFRIENDLY)) return it;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
567
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
568 trp = roomin(&tp->t_pos); /* Current room for monster */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
569
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
570 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
571 * Let greedy ones in a room guard gold
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
572 * (except in a maze where lots of creatures would all go for the
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
573 * same piece of gold)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
574 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
575 if (on(*tp, ISGREED) && off(*tp, ISRUN) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
576 levtype != MAZELEV && trp != NULL &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
577 lvl_obj != NULL) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
578 register struct linked_list *item;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
579 register struct object *cur;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
580
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
581 for (item = lvl_obj; item != NULL; item = next(item)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
582 cur = OBJPTR(item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
583 if ((cur->o_type == GOLD) && (roomin(&cur->o_pos) == trp)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
584 /* Run to the gold */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
585 runto(tp, &cur->o_pos);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
586
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
587 /* Make it worth protecting */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
588 cur->o_count += GOLDCALC + GOLDCALC;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
589 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
590 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
591 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
592 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
593
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
594 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
595 * Every time he sees mean monster, it might start chasing him
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
596 */
311
28e22fb35989 Fix one more batch of compiler warnings.
John "Elwin" Edwards
parents: 238
diff changeset
597 if ((on(*tp, ISMEAN) &&
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
598 off(*tp, ISHELD) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
599 off(*tp, ISRUN) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
600 rnd(100) > 33 &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
601 (!is_stealth(&player) || (on(*tp, ISUNIQUE) && rnd(100) > 50)) &&
311
28e22fb35989 Fix one more batch of compiler warnings.
John "Elwin" Edwards
parents: 238
diff changeset
602 (off(player, ISINVIS) || on(*tp, CANSEE))) ||
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
603 (trp != NULL && (trp->r_flags & ISTREAS))) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
604 runto(tp, &hero);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
605 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
606
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
607 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
608 * Get the name; we don't want to do it until here because we need to
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
609 * know whether the monster is still sleeping or not.
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
610 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
611 mname = monster_name(tp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
612
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
613 /* See if the monster will bother the player */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
614 nasty = (on(*tp, ISRUN) && cansee(tp->t_pos.y, tp->t_pos.x));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
615
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
616 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
617 * if the creature is awake and can see the player and the
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
618 * player has the dreaded "eye of vecna" then see if the
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
619 * creature is turned to stone
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
620 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
621 if (cur_relic[EYE_VECNA] && nasty && off(*tp, NOSTONE) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
622 (off(player, ISINVIS) || on(*tp, CANSEE))) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
623 turn_on(*tp, NOSTONE); /* only have to save once */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
624 if (!save(VS_PETRIFICATION, tp, -2)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
625 turn_on(*tp, ISSTONE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
626 turn_off(*tp, ISRUN);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
627 turn_off(*tp, ISINVIS);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
628 turn_off(*tp, CANSURPRISE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
629 turn_off(*tp, ISDISGUISE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
630 msg("%s is turned to stone!", prname(mname, TRUE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
631 return it;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
632 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
633 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
634
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
635 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
636 * Handle monsters that can gaze and do things while running
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
637 * Player must be able to see the monster and the monster must
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
638 * not be asleep
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
639 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
640 if (nasty && !invisible(tp)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
641 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
642 * Confusion
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
643 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
644 if (on(*tp, CANHUH) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
645 (off(*tp, ISINVIS) || on(player, CANSEE)) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
646 (off(*tp, CANSURPRISE) || ISWEARING(R_ALERT))) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
647 if (!save(VS_MAGIC, &player, 0)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
648 if (off(player, ISCLEAR)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
649 if (find_slot(unconfuse))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
650 lengthen(unconfuse, HUHDURATION);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
651 else {
238
e1cd27c5464f arogue7, xrogue: improve the handling of the arguments to fuses.
John "Elwin" Edwards
parents: 219
diff changeset
652 fuse(unconfuse, NULL, HUHDURATION, AFTER);
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
653 msg("%s's gaze has confused you.",prname(mname, TRUE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
654 turn_on(player, ISHUH);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
655 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
656 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
657 else msg("You feel dizzy for a moment, but it quickly passes.");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
658 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
659 else if (rnd(100) < 67)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
660 turn_off(*tp, CANHUH); /* Once you save, maybe that's it */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
661 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
662
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
663 /* Sleep */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
664 if(on(*tp, CANSNORE) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
665 player.t_action != A_FREEZE &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
666 !save(VS_PARALYZATION, &player, 0)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
667 if (ISWEARING(R_ALERT))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
668 msg("You feel slightly drowsy for a moment.");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
669 else {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
670 msg("%s's gaze puts you to sleep.", prname(mname, TRUE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
671 player.t_no_move += movement(&player) * SLEEPTIME;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
672 player.t_action = A_FREEZE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
673 if (rnd(100) < 50) turn_off(*tp, CANSNORE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
674 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
675 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
676
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
677 /* Fear */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
678 if (on(*tp, CANFRIGHTEN) && !on(player, ISFLEE)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
679 turn_off(*tp, CANFRIGHTEN);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
680 if (!ISWEARING(R_HEROISM) &&
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
681 !save(VS_WAND, &player, -(tp->t_stats.s_lvl/10))) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
682 turn_on(player, ISFLEE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
683 player.t_dest = &tp->t_pos;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
684 msg("The sight of %s terrifies you.", prname(mname, FALSE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
685 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
686 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
687
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
688 /* blinding creatures */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
689 if(on(*tp, CANBLIND) && !find_slot(sight)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
690 turn_off(*tp, CANBLIND);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
691 if (!save(VS_WAND, &player, 0)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
692 msg("The gaze of %s blinds you", prname(mname, FALSE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
693 turn_on(player, ISBLIND);
238
e1cd27c5464f arogue7, xrogue: improve the handling of the arguments to fuses.
John "Elwin" Edwards
parents: 219
diff changeset
694 fuse(sight, NULL, rnd(30)+20, AFTER);
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
695 light(&hero);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
696 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
697 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
698
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
699 /* the sight of the ghost can age you! */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
700 if (on(*tp, CANAGE)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
701 turn_off (*tp, CANAGE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
702 if (!save(VS_MAGIC, &player, 0)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
703 msg ("The sight of %s ages you!", prname(mname, FALSE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
704 pstats.s_const--;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
705 max_stats.s_const--;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
706 if (pstats.s_const < 0)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
707 death (D_CONSTITUTION);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
708 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
709 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
710
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
711
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
712 /* Turning to stone */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
713 if (on(*tp, LOOKSTONE)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
714 turn_off(*tp, LOOKSTONE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
715
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
716 if (on(player, CANINWALL))
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
717 msg("The gaze of %s has no effect.", prname(mname, FALSE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
718 else {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
719 if (!save(VS_PETRIFICATION, &player, 0) && rnd(100) < 5) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
720 pstats.s_hpt = -1;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
721 msg("The gaze of %s petrifies you.", prname(mname, FALSE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
722 msg("You are turned to stone !!! --More--");
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
723 wait_for(' ');
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
724 death(D_PETRIFY);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
725 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
726 else {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
727 msg("The gaze of %s stiffens your limbs.",
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
728 prname(mname, FALSE));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
729 player.t_no_move += movement(&player) * STONETIME;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
730 player.t_action = A_FREEZE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
731 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
732 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
733 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
734 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
735
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
736 return it;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
737 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
738 /*
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
739 * wanderer:
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
740 * A wandering monster has awakened and is headed for the player
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
741 */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
742
219
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
743 void
f9ef86cf22b2 Advanced Rogue 7: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 126
diff changeset
744 wanderer(void)
125
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
745 {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
746 register int i;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
747 register struct room *hr = roomin(&hero);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
748 register struct linked_list *item;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
749 register struct thing *tp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
750 register long *attr; /* Points to monsters' attributes */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
751 int carry; /* Chance of wanderer carrying anything */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
752 short rmonst; /* Our random wanderer */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
753 bool canteleport = FALSE, /* Can the monster teleport? */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
754 seehim; /* Is monster within sight? */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
755 coord cp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
756
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
757 rmonst = randmonster(TRUE, FALSE); /* Choose a random wanderer */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
758 attr = &monsters[rmonst].m_flags[0]; /* Start of attributes */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
759 for (i=0; i<MAXFLAGS; i++)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
760 if (*attr++ == CANTELEPORT) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
761 canteleport = TRUE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
762 break;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
763 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
764
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
765 /* Find a place for it -- avoid the player's room if can't teleport */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
766 do {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
767 do {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
768 i = rnd_room();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
769 } until (canteleport || hr != &rooms[i] || levtype == MAZELEV ||
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
770 levtype == OUTSIDE || levtype == POSTLEV);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
771
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
772 /* Make sure the monster does not teleport on top of the player */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
773 do {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
774 rnd_pos(&rooms[i], &cp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
775 } while (hr == &rooms[i] && ce(cp, hero));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
776 } until (step_ok(cp.y, cp.x, NOMONST, NULL));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
777
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
778 /* Create a new wandering monster */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
779 item = new_item(sizeof *tp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
780 new_monster(item, rmonst, &cp, FALSE);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
781 tp = THINGPTR(item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
782 runto(tp, &hero);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
783 tp->t_pos = cp; /* Assign the position to the monster */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
784 seehim = cansee(tp->t_pos.y, tp->t_pos.x);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
785 if (on(*tp, HASFIRE)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
786 register struct room *rp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
787
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
788 rp = roomin(&tp->t_pos);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
789 if (rp) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
790 register struct linked_list *fire_item;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
791
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
792 fire_item = creat_item();
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
793 ldata(fire_item) = (char *) tp;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
794 attach(rp->r_fires, fire_item);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
795
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
796 rp->r_flags |= HASFIRE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
797 if (seehim && next(rp->r_fires) == NULL)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
798 light(&hero);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
799 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
800 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
801
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
802 /* See if we give the monster anything */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
803 carry = monsters[tp->t_index].m_carry;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
804 if (off(*tp, ISUNIQUE)) carry /= 2; /* Non-unique has only a half chance */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
805 carry_obj(tp, carry);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
806
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
807 /* Calculate its movement rate */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
808 tp->t_no_move = movement(tp);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
809
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
810 /* Alert the player if a monster just teleported in */
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
811 if (hr == &rooms[i] && canteleport && seehim && !invisible(tp)) {
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
812 msg("A %s just teleported in", monster_name(tp));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
813 light(&hero);
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
814 running = FALSE;
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
815 }
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
816
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
817 if (wizard)
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
818 msg("Started a wandering %s", monster_name(tp));
adfa37e67084 Import Advanced Rogue 7.7 from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
819 }