annotate srogue/rooms.c @ 304:e52a8a7ad4c5

Fix many compiler warnings. There should only be two changes in behavior: arogue7/fight.c, arogue7/fight.c: a to-hit bonus is now correctly applied to characters who are not monks instead of monks who are not empty-handed. urogue/fight.c: fixed an interaction with the "debug" macro that could cause the wrong message to be displayed.
author John "Elwin" Edwards
date Wed, 14 Apr 2021 18:55:33 -0400
parents 94a0d9dd5ce1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
1 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
2 * Draw the nine rooms on the screen
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
3 *
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
4 * @(#)rooms.c 9.0 (rdk) 7/17/84
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
5 *
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
6 * Super-Rogue
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
7 * Copyright (C) 1984 Robert D. Kindelberger
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
8 * All rights reserved.
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
9 *
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
10 * Based on "Rogue: Exploring the Dungeons of Doom"
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
11 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
12 * All rights reserved.
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
13 *
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
14 * See the file LICENSE.TXT for full copyright and licensing information.
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
15 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
16
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
17 #include "rogue.h"
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
18 #include "rogue.ext"
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
19
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
20 void horiz(int cnt);
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
21 void vert(int cnt);
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
22
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
23 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
24 * do_rooms:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
25 * Place the rooms in the dungeon
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
26 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
27 void
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
28 do_rooms(void)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
29 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
30 int mloops, mchance, nummons, left_out, roomtries;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
31 bool treas = FALSE;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
32 reg int i;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
33 reg struct room *rp;
304
e52a8a7ad4c5 Fix many compiler warnings.
John "Elwin" Edwards
parents: 217
diff changeset
34 struct coord top, bsze;
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
35
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
36 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
37 * bsze is the maximum room size
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
38 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
39 bsze.x = COLS / 3;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
40 bsze.y = (LINES - 1) / 3;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
41 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
42 * Clear things for a new level
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
43 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
44 for (rp = rooms; rp < &rooms[MAXROOMS]; rp++)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
45 rp->r_goldval = rp->r_nexits = rp->r_flags = 0;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
46 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
47 * Put the gone rooms, if any, on the level
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
48 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
49 left_out = rnd(4);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
50 for (i = 0; i < left_out; i++)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
51 rooms[rnd_room()].r_flags |= ISGONE;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
52 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
53 * dig and populate all the rooms on the level
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
54 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
55 for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
56 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
57 * Find upper left corner of box that this room goes in
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
58 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
59 top.x = (i%3) * bsze.x + 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
60 top.y = i/3 * bsze.y;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
61 if (rf_on(rp,ISGONE)) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
62 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
63 * Place a gone room. Make certain that there is a
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
64 * blank line for passage drawing.
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
65 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
66 roomtries = 0;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
67 do {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
68 rp->r_pos.x = top.x + rnd(bsze.x-2) + 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
69 rp->r_pos.y = top.y + rnd(bsze.y-2) + 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
70 rp->r_max.x = -COLS;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
71 rp->r_max.x = -LINES;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
72 if (++roomtries > 250)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
73 fatal("failed to place a gone room");
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
74 } until(rp->r_pos.y > 0 && rp->r_pos.y < LINES-2);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
75 continue;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
76 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
77 if (rnd(10) < level-1)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
78 rp->r_flags |= ISDARK;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
79 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
80 * Find a place and size for a random room
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
81 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
82 roomtries = 0;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
83 do {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
84 rp->r_max.x = rnd(bsze.x - 4) + 4;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
85 rp->r_max.y = rnd(bsze.y - 4) + 4;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
86 rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
87 rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
88 if (++roomtries > 250) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
89 fatal("failed to place a good room");
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
90 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
91 } until (rp->r_pos.y != 0);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
92 if (level < max_level)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
93 mchance = 30; /* 30% when going up (all monsters) */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
94 else
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
95 mchance = 3; /* 3% when going down */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
96 treas = FALSE;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
97 if (rnd(100) < mchance && (rp->r_max.x * rp->r_max.y) >
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
98 ((bsze.x * bsze.y * 55) / 100)) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
99 treas = TRUE;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
100 rp->r_flags |= ISTREAS;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
101 rp->r_flags |= ISDARK;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
102 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
103 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
104 * Put the gold in
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
105 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
106 if ((rnd(100) < 50 || treas) && (!amulet || level >= max_level)) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
107 rp->r_goldval = GOLDCALC;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
108 if (treas)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
109 rp->r_goldval += 200 + (15 * (rnd(level) + 2));
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
110 rp->r_gold.y = rp->r_pos.y + rnd(rp->r_max.y - 2) + 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
111 rp->r_gold.x = rp->r_pos.x + rnd(rp->r_max.x - 2) + 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
112 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
113 draw_room(rp);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
114 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
115 * Put the monster in
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
116 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
117 if (treas) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
118 mloops = rnd(level / 3) + 6;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
119 mchance = 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
120 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
121 else {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
122 mloops = 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
123 mchance = 100;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
124 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
125 for (nummons = 0; nummons < mloops; nummons++) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
126 if (rnd(mchance) < (rp->r_goldval > 0 ? 80 : 25))
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
127 add_mon(rp, treas);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
128 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
129 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
130 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
131
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
132 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
133 * add_mon:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
134 * Add a monster to a room
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
135 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
136 void
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
137 add_mon(struct room *rm, bool treas)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
138 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
139 reg struct thing *tp;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
140 reg struct linked_list *item;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
141 struct coord mp;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
142 int chance;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
143
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
144 mp = *rnd_pos(rm);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
145 item = new_monster(rnd_mon(FALSE,FALSE), &mp, treas);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
146 tp = THINGPTR(item);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
147 chance = rnd(100);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
148 if (levtype == MAZELEV)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
149 chance = rnd(50);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
150 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
151 * See if monster has a treasure
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
152 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
153 if (levtype == MAZELEV && rnd(100) < 20) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
154 reg struct linked_list *fd;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
155
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
156 fd = new_thing(FALSE, FOOD, 0);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
157 attach(tp->t_pack, fd);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
158 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
159 else {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
160 if (chance < monsters[tp->t_indx].m_carry)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
161 attach(tp->t_pack, new_thing(FALSE, ANYTHING));
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
162 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
163 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
164
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
165 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
166 * draw_room:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
167 * Draw a box around a room
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
168 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
169 void
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
170 draw_room(struct room *rp)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
171 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
172 reg int j, k;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
173
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
174 move(rp->r_pos.y, rp->r_pos.x+1);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
175 vert(rp->r_max.y-2); /* Draw left side */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
176 move(rp->r_pos.y+rp->r_max.y-1, rp->r_pos.x);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
177 horiz(rp->r_max.x); /* Draw bottom */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
178 move(rp->r_pos.y, rp->r_pos.x);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
179 horiz(rp->r_max.x); /* Draw top */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
180 vert(rp->r_max.y-2); /* Draw right side */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
181 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
182 * Put the floor down
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
183 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
184 for (j = 1; j < rp->r_max.y - 1; j++) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
185 move(rp->r_pos.y + j, rp->r_pos.x + 1);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
186 for (k = 1; k < rp->r_max.x - 1; k++) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
187 addch(FLOOR);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
188 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
189 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
190 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
191 * Put the gold there
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
192 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
193 if (rp->r_goldval > 0)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
194 mvaddch(rp->r_gold.y, rp->r_gold.x, GOLD);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
195 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
196
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
197 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
198 * horiz:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
199 * draw a horizontal line
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
200 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
201 void
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
202 horiz(int cnt)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
203 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
204 while (cnt-- > 0)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
205 addch('-');
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
206 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
207
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
208
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
209 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
210 * vert:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
211 * draw a vertical line
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
212 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
213 void
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
214 vert(int cnt)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
215 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
216 reg int x, y;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
217
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
218 getyx(stdscr, y, x);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
219 x--;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
220 while (cnt-- > 0) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
221 move(++y, x);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
222 addch('|');
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
223 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
224 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
225
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
226
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
227 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
228 * rnd_pos:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
229 * pick a random spot in a room
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
230 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
231 struct coord *
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
232 rnd_pos(struct room *rp)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
233 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
234 reg int y, x, i;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
235 static struct coord spot;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
236
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
237 i = 0;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
238 do {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
239 x = rp->r_pos.x + rnd(rp->r_max.x - 2) + 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
240 y = rp->r_pos.y + rnd(rp->r_max.y - 2) + 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
241 i += 1;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
242 } while(winat(y, x) != FLOOR && i < 1000);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
243 spot.x = x;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
244 spot.y = y;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
245 return &spot;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
246 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
247
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
248 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
249 * rf_on:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
250 * Returns TRUE if flag is set for room stuff
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
251 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
252 bool
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
253 rf_on(struct room *rm, long bit)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
254 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
255 return (rm->r_flags & bit);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
256 }