Mercurial > hg > early-roguelike
comparison rogue3/misc.c @ 0:527e2150eaf0
Import Rogue 3.6 from the Roguelike Restoration Project (r1490)
| author | edwarj4 |
|---|---|
| date | Tue, 13 Oct 2009 13:33:34 +0000 |
| parents | |
| children | e7862a021609 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:527e2150eaf0 |
|---|---|
| 1 /* | |
| 2 * all sorts of miscellaneous routines | |
| 3 * | |
| 4 * @(#)misc.c 3.13 (Berkeley) 6/15/81 | |
| 5 * | |
| 6 * Rogue: Exploring the Dungeons of Doom | |
| 7 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
| 8 * All rights reserved. | |
| 9 * | |
| 10 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 11 */ | |
| 12 | |
| 13 #include "curses.h" | |
| 14 #include "rogue.h" | |
| 15 #include <ctype.h> | |
| 16 | |
| 17 /* | |
| 18 * tr_name: | |
| 19 * print the name of a trap | |
| 20 */ | |
| 21 | |
| 22 char * | |
| 23 tr_name(int ch) | |
| 24 { | |
| 25 char *s = ""; | |
| 26 | |
| 27 switch (ch) | |
| 28 { | |
| 29 case TRAPDOOR: | |
| 30 s = terse ? "A trapdoor." : "You found a trapdoor."; | |
| 31 when BEARTRAP: | |
| 32 s = terse ? "A beartrap." : "You found a beartrap."; | |
| 33 when SLEEPTRAP: | |
| 34 s = terse ? "A sleeping gas trap.":"You found a sleeping gas trap."; | |
| 35 when ARROWTRAP: | |
| 36 s = terse ? "An arrow trap." : "You found an arrow trap."; | |
| 37 when TELTRAP: | |
| 38 s = terse ? "A teleport trap." : "You found a teleport trap."; | |
| 39 when DARTTRAP: | |
| 40 s = terse ? "A dart trap." : "You found a poison dart trap."; | |
| 41 } | |
| 42 return s; | |
| 43 } | |
| 44 | |
| 45 /* | |
| 46 * Look: | |
| 47 * A quick glance all around the player | |
| 48 */ | |
| 49 | |
| 50 void | |
| 51 look(int wakeup) | |
| 52 { | |
| 53 int x, y; | |
| 54 int ch; | |
| 55 int oldx, oldy; | |
| 56 int inpass; | |
| 57 int passcount = 0; | |
| 58 struct room *rp; | |
| 59 int ey, ex; | |
| 60 | |
| 61 getyx(cw, oldy, oldx); | |
| 62 if (oldrp != NULL && (oldrp->r_flags & ISDARK) && off(player, ISBLIND)) | |
| 63 { | |
| 64 for (x = oldpos.x - 1; x <= oldpos.x + 1; x++) | |
| 65 for (y = oldpos.y - 1; y <= oldpos.y + 1; y++) | |
| 66 if ((y != hero.y || x != hero.x) && show(y, x) == FLOOR) | |
| 67 mvwaddch(cw, y, x, ' '); | |
| 68 } | |
| 69 inpass = ((rp = roomin(&hero)) == NULL); | |
| 70 ey = hero.y + 1; | |
| 71 ex = hero.x + 1; | |
| 72 for (x = hero.x - 1; x <= ex; x++) | |
| 73 if (x >= 0 && x < COLS) for (y = hero.y - 1; y <= ey; y++) | |
| 74 { | |
| 75 if (y <= 0 || y >= LINES - 1) | |
| 76 continue; | |
| 77 if (isupper(mvwinch(mw, y, x))) | |
| 78 { | |
| 79 struct linked_list *it; | |
| 80 struct thing *tp; | |
| 81 | |
| 82 if (wakeup) | |
| 83 it = wake_monster(y, x); | |
| 84 else | |
| 85 it = find_mons(y, x); | |
| 86 tp = (struct thing *) ldata(it); | |
| 87 if ((tp->t_oldch = mvinch(y, x)) == TRAP) | |
| 88 tp->t_oldch = | |
| 89 (trap_at(y,x)->tr_flags&ISFOUND) ? TRAP : FLOOR; | |
| 90 if (tp->t_oldch == FLOOR && (rp != NULL) && (rp->r_flags & ISDARK) | |
| 91 && off(player, ISBLIND)) | |
| 92 tp->t_oldch = ' '; | |
| 93 } | |
| 94 /* | |
| 95 * Secret doors show as walls | |
| 96 */ | |
| 97 if ((ch = show(y, x)) == SECRETDOOR) | |
| 98 ch = secretdoor(y, x); | |
| 99 /* | |
| 100 * Don't show room walls if he is in a passage | |
| 101 */ | |
| 102 if (off(player, ISBLIND)) | |
| 103 { | |
| 104 if (y == hero.y && x == hero.x | |
| 105 || (inpass && (ch == '-' || ch == '|'))) | |
| 106 continue; | |
| 107 } | |
| 108 else if (y != hero.y || x != hero.x) | |
| 109 continue; | |
| 110 wmove(cw, y, x); | |
| 111 waddch(cw, ch); | |
| 112 if (door_stop && !firstmove && running) | |
| 113 { | |
| 114 switch (runch) | |
| 115 { | |
| 116 case 'h': | |
| 117 if (x == ex) | |
| 118 continue; | |
| 119 when 'j': | |
| 120 if (y == hero.y - 1) | |
| 121 continue; | |
| 122 when 'k': | |
| 123 if (y == ey) | |
| 124 continue; | |
| 125 when 'l': | |
| 126 if (x == hero.x - 1) | |
| 127 continue; | |
| 128 when 'y': | |
| 129 if ((x + y) - (hero.x + hero.y) >= 1) | |
| 130 continue; | |
| 131 when 'u': | |
| 132 if ((y - x) - (hero.y - hero.x) >= 1) | |
| 133 continue; | |
| 134 when 'n': | |
| 135 if ((x + y) - (hero.x + hero.y) <= -1) | |
| 136 continue; | |
| 137 when 'b': | |
| 138 if ((y - x) - (hero.y - hero.x) <= -1) | |
| 139 continue; | |
| 140 } | |
| 141 switch (ch) | |
| 142 { | |
| 143 case DOOR: | |
| 144 if (x == hero.x || y == hero.y) | |
| 145 running = FALSE; | |
| 146 break; | |
| 147 case PASSAGE: | |
| 148 if (x == hero.x || y == hero.y) | |
| 149 passcount++; | |
| 150 break; | |
| 151 case FLOOR: | |
| 152 case '|': | |
| 153 case '-': | |
| 154 case ' ': | |
| 155 break; | |
| 156 default: | |
| 157 running = FALSE; | |
| 158 break; | |
| 159 } | |
| 160 } | |
| 161 } | |
| 162 if (door_stop && !firstmove && passcount > 1) | |
| 163 running = FALSE; | |
| 164 mvwaddch(cw, hero.y, hero.x, PLAYER); | |
| 165 wmove(cw, oldy, oldx); | |
| 166 oldpos = hero; | |
| 167 oldrp = rp; | |
| 168 } | |
| 169 | |
| 170 /* | |
| 171 * secret_door: | |
| 172 * Figure out what a secret door looks like. | |
| 173 */ | |
| 174 | |
| 175 int | |
| 176 secretdoor(int y, int x) | |
| 177 { | |
| 178 int i; | |
| 179 struct room *rp; | |
