Mercurial > hg > early-roguelike
comparison rogue4/sticks.c @ 12:9535a08ddc39
Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
| author | edwarj4 |
|---|---|
| date | Sat, 24 Oct 2009 16:52:52 +0000 |
| parents | |
| children | 1b73a8641b37 |
comparison
equal
deleted
inserted
replaced
| 11:949d558c2162 | 12:9535a08ddc39 |
|---|---|
| 1 /* | |
| 2 * Functions to implement the various sticks one might find | |
| 3 * while wandering around the dungeon. | |
| 4 * | |
| 5 * @(#)sticks.c 4.22 (Berkeley) 5/19/82 | |
| 6 * | |
| 7 * Rogue: Exploring the Dungeons of Doom | |
| 8 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman | |
| 9 * All rights reserved. | |
| 10 * | |
| 11 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 12 */ | |
| 13 | |
| 14 #include <curses.h> | |
| 15 #include <ctype.h> | |
| 16 #include <string.h> | |
| 17 #include "rogue.h" | |
| 18 | |
| 19 /* | |
| 20 * fix_stick: | |
| 21 * Set up a new stick | |
| 22 */ | |
| 23 fix_stick(cur) | |
| 24 register THING *cur; | |
| 25 { | |
| 26 if (strcmp(ws_type[cur->o_which], "staff") == 0) | |
| 27 strcpy(cur->o_damage,"2d3"); | |
| 28 else | |
| 29 strcpy(cur->o_damage,"1d1"); | |
| 30 strcpy(cur->o_hurldmg,"1d1"); | |
| 31 | |
| 32 cur->o_charges = 3 + rnd(5); | |
| 33 switch (cur->o_which) | |
| 34 { | |
| 35 case WS_HIT: | |
| 36 cur->o_hplus = 100; | |
| 37 cur->o_dplus = 3; | |
| 38 strcpy(cur->o_damage,"1d8"); | |
| 39 when WS_LIGHT: | |
| 40 cur->o_charges = 10 + rnd(10); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 /* | |
| 45 * do_zap: | |
| 46 * Perform a zap with a wand | |
| 47 */ | |
| 48 do_zap() | |
| 49 { | |
| 50 register THING *obj, *tp; | |
| 51 register int y, x; | |
| 52 register char *name; | |
| 53 | |
| 54 if ((obj = get_item("zap with", STICK)) == NULL) | |
| 55 return; | |
| 56 if (obj->o_type != STICK) | |
| 57 { | |
| 58 after = FALSE; | |
| 59 msg("you can't zap with that!"); | |
| 60 return; | |
| 61 } | |
| 62 if (obj->o_charges == 0) | |
| 63 { | |
| 64 msg("nothing happens"); | |
| 65 return; | |
| 66 } | |
| 67 switch (obj->o_which) | |
| 68 { | |
| 69 case WS_LIGHT: | |
| 70 /* | |
| 71 * Reddy Kilowat wand. Light up the room | |
| 72 */ | |
| 73 ws_know[WS_LIGHT] = TRUE; | |
| 74 if (proom->r_flags & ISGONE) | |
| 75 msg("the corridor glows and then fades"); | |
| 76 else | |
| 77 { | |
| 78 proom->r_flags &= ~ISDARK; | |
| 79 /* | |
| 80 * Light the room and put the player back up | |
| 81 */ | |
| 82 enter_room(&hero); | |
| 83 addmsg("the room is lit"); | |
| 84 if (!terse) | |
| 85 addmsg(" by a shimmering blue light"); | |
| 86 endmsg(); | |
| 87 } | |
| 88 when WS_DRAIN: | |
| 89 /* | |
| 90 * Take away 1/2 of hero's hit points, then take it away | |
| 91 * evenly from the monsters in the room (or next to hero | |
| 92 * if he is in a passage) | |
| 93 */ | |
| 94 if (pstats.s_hpt < 2) | |
| 95 { | |
| 96 msg("you are too weak to use it"); | |
| 97 return; | |
| 98 } | |
| 99 else | |
| 100 drain(); | |
| 101 when WS_POLYMORPH: | |
| 102 case WS_TELAWAY: | |
| 103 case WS_TELTO: | |
| 104 case WS_CANCEL: | |
| 105 { | |
| 106 register char monster, oldch; | |
| 107 register int rm; | |
| 108 | |
| 109 y = hero.y; | |
| 110 x = hero.x; | |
| 111 while (step_ok(winat(y, x))) | |
| 112 { | |
| 113 y += delta.y; | |
| 114 x += delta.x; | |
| 115 } | |
| 116 if ((tp = moat(y, x)) != NULL) | |
| 117 { | |
| 118 register char omonst; | |
| 119 | |
| 120 omonst = monster = tp->t_type; | |
| 121 if (monster == 'F') | |
| 122 player.t_flags &= ~ISHELD; | |
| 123 if (obj->o_which == WS_POLYMORPH) | |
| 124 { | |
| 125 register THING *pp; | |
| 126 | |
| 127 pp = tp->t_pack; | |
| 128 detach(mlist, tp); | |
| 129 if (see_monst(tp)) | |
| 130 mvaddch(y, x, chat(y, x)); | |
| 131 oldch = tp->t_oldch; | |
| 132 delta.y = y; | |
| 133 delta.x = x; | |
| 134 new_monster(tp, monster = rnd(26) + 'A', &delta); | |
| 135 if (see_monst(tp)) | |
| 136 mvaddch(y, x, monster); | |
| 137 tp->t_oldch = oldch; | |
| 138 tp->t_pack = pp; | |
| 139 ws_know[WS_POLYMORPH] |= (monster != omonst); | |
| 140 } | |
| 141 else if (obj->o_which == WS_CANCEL) | |
| 142 { | |
| 143 tp->t_flags |= ISCANC; | |
| 144 tp->t_flags &= ~(ISINVIS|CANHUH); | |
| 145 tp->t_disguise = tp->t_type; | |
| 146 } | |
| 147 else | |
| 148 { | |
| 149 if (isupper(toascii(mvinch(y,x)))) | |
| 150 mvaddch(y, x, tp->t_oldch); | |
| 151 if (obj->o_which == WS_TELAWAY) | |
| 152 { | |
| 153 do | |
| 154 { | |
| 155 rm = rnd_room(); | |
| 156 rnd_pos(&rooms[rm], &tp->t_pos); | |
| 157 } until (winat(tp->t_pos.y, tp->t_pos.x) == FLOOR); | |
| 158 tp->t_room = roomin(&tp->t_pos); | |
| 159 tp->t_oldch = mvinch(tp->t_pos.y, tp->t_pos.x); | |
| 160 if (see_monst(tp)) | |
| 161 mvaddch(tp->t_pos.y, tp->t_pos.x, tp->t_disguise); | |
| 162 else if (on(player, SEEMONST)) | |
| 163 { | |
| 164 standout(); | |
| 165 mvaddch(tp->t_pos.y, tp->t_pos.x, tp->t_disguise); | |
| 166 standend(); | |
| 167 } | |
| 168 } | |
| 169 else | |
| 170 { | |
| 171 tp->t_pos.y = hero.y + delta.y; | |
| 172 tp->t_pos.x = hero.x + delta.x; | |
| 173 | |
| 174 if (tp->t_pos.y != y || tp->t_pos.x != x) | |
| 175 tp->t_oldch = mvinch(tp->t_pos.y, tp->t_pos.x); | |
| 176 } | |
| 177 moat(y, x) = NULL; | |
| 178 moat(tp->t_pos.y, tp->t_pos.x) = tp; | |
| 179 if (tp->t_type == 'F') |
