Mercurial > hg > early-roguelike
comparison rogue3/sticks.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 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:527e2150eaf0 |
|---|---|
| 1 /* | |
| 2 * Functions to implement the various sticks one might find | |
| 3 * while wandering around the dungeon. | |
| 4 * | |
| 5 * @(#)sticks.c 3.14 (Berkeley) 6/15/81 | |
| 6 * | |
| 7 * Rogue: Exploring the Dungeons of Doom | |
| 8 * Copyright (C) 1980, 1981 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 void | |
| 20 fix_stick(struct object *cur) | |
| 21 { | |
| 22 if (strcmp(ws_type[cur->o_which], "staff") == 0) | |
| 23 strcpy(cur->o_damage,"2d3"); | |
| 24 else | |
| 25 strcpy(cur->o_damage,"1d1"); | |
| 26 strcpy(cur->o_hurldmg,"1d1"); | |
| 27 | |
| 28 cur->o_charges = 3 + rnd(5); | |
| 29 switch (cur->o_which) | |
| 30 { | |
| 31 case WS_HIT: | |
| 32 cur->o_hplus = 3; | |
| 33 cur->o_dplus = 3; | |
| 34 strcpy(cur->o_damage,"1d8"); | |
| 35 when WS_LIGHT: | |
| 36 cur->o_charges = 10 + rnd(10); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 void | |
| 41 do_zap(int gotdir) | |
| 42 { | |
| 43 struct linked_list *item; | |
| 44 struct object *obj; | |
| 45 struct room *rp; | |
| 46 struct thing *tp; | |
| 47 int y, x; | |
| 48 | |
| 49 if ((item = get_item("zap with", STICK)) == NULL) | |
| 50 return; | |
| 51 obj = (struct object *) ldata(item); | |
| 52 if (obj->o_type != STICK) | |
| 53 { | |
| 54 msg("You can't zap with that!"); | |
| 55 after = FALSE; | |
| 56 return; | |
| 57 } | |
| 58 if (obj->o_charges == 0) | |
| 59 { | |
| 60 msg("Nothing happens."); | |
| 61 return; | |
| 62 } | |
| 63 if (!gotdir) | |
| 64 do { | |
| 65 delta.y = rnd(3) - 1; | |
| 66 delta.x = rnd(3) - 1; | |
| 67 } while (delta.y == 0 && delta.x == 0); | |
| 68 switch (obj->o_which) | |
| 69 { | |
| 70 case WS_LIGHT: | |
| 71 /* | |
| 72 * Reddy Kilowat wand. Light up the room | |
| 73 */ | |
| 74 ws_know[WS_LIGHT] = TRUE; | |
| 75 if ((rp = roomin(&hero)) == NULL) | |
| 76 msg("The corridor glows and then fades"); | |
| 77 else | |
| 78 { | |
| 79 addmsg("The room is lit"); | |
| 80 if (!terse) | |
| 81 addmsg(" by a shimmering blue light."); | |
| 82 endmsg(); | |
| 83 rp->r_flags &= ~ISDARK; | |
| 84 /* | |
| 85 * Light the room and put the player back up | |
| 86 */ | |
| 87 light(&hero); | |
| 88 mvwaddch(cw, hero.y, hero.x, PLAYER); | |
| 89 } | |
| 90 when WS_DRAIN: | |
| 91 /* | |
| 92 * Take away 1/2 of hero's hit points, then take it away | |
| 93 * evenly from the monsters in the room (or next to hero | |
| 94 * if he is in a passage) | |
| 95 */ | |
| 96 if (pstats.s_hpt < 2) | |
| 97 { | |
| 98 msg("You are too weak to use it."); | |
| 99 return; | |
| 100 } | |
| 101 else if ((rp = roomin(&hero)) == NULL) | |
| 102 drain(hero.y-1, hero.y+1, hero.x-1, hero.x+1); | |
| 103 else | |
| 104 drain(rp->r_pos.y, rp->r_pos.y+rp->r_max.y, | |
| 105 rp->r_pos.x, rp->r_pos.x+rp->r_max.x); | |
| 106 when WS_POLYMORPH: | |
| 107 case WS_TELAWAY: | |
| 108 case WS_TELTO: | |
| 109 case WS_CANCEL: | |
| 110 { | |
| 111 int monster; | |
| 112 int oldch; | |
| 113 int rm; | |
| 114 | |
| 115 y = hero.y; | |
| 116 x = hero.x; | |
| 117 while (step_ok(winat(y, x))) | |
| 118 { | |
| 119 y += delta.y; | |
| 120 x += delta.x; | |
| 121 } | |
| 122 if (isupper(monster = mvwinch(mw, y, x))) | |
| 123 { | |
| 124 int omonst = monster; | |
| 125 | |
| 126 if (monster == 'F') | |
| 127 player.t_flags &= ~ISHELD; | |
| 128 item = find_mons(y, x); | |
| 129 tp = (struct thing *) ldata(item); | |
| 130 if (obj->o_which == WS_POLYMORPH) | |
| 131 { | |
| 132 detach(mlist, item); | |
| 133 oldch = tp->t_oldch; | |
| 134 delta.y = y; | |
| 135 delta.x = x; | |
| 136 new_monster(item, monster = rnd(26) + 'A', &delta); | |
| 137 if (!(tp->t_flags & ISRUN)) | |
| 138 runto(&delta, &hero); | |
| 139 if (isupper(mvwinch(cw, y, x))) | |
| 140 mvwaddch(cw, y, x, monster); | |
| 141 tp->t_oldch = oldch; | |
| 142 ws_know[WS_POLYMORPH] |= (monster != omonst); | |
| 143 } | |
| 144 else if (obj->o_which == WS_CANCEL) | |
| 145 { | |
| 146 tp->t_flags |= ISCANC; | |
| 147 tp->t_flags &= ~ISINVIS; | |
| 148 } | |
| 149 else | |
| 150 { | |
| 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 } | |
| 159 else | |
| 160 { | |
| 161 tp->t_pos.y = hero.y + delta.y; | |
| 162 tp->t_pos.x = hero.x + delta.x; | |
| 163 } | |
| 164 if (isupper(mvwinch(cw, y, x))) | |
| 165 mvwaddch(cw, y, x, tp->t_oldch); | |
| 166 tp->t_dest = &hero; | |
| 167 tp->t_flags |= ISRUN; | |
| 168 mvwaddch(mw, y, x, ' '); | |
| 169 mvwaddch(mw, tp->t_pos.y, tp->t_pos.x, monster); | |
| 170 if (tp->t_pos.y != y || tp->t_pos.x != x) | |
| 171 tp->t_oldch = mvwinch(cw, tp->t_pos.y, tp->t_pos.x); | |
| 172 } | |
| 173 } | |
| 174 } | |
| 175 when WS_MISSILE: | |
| 176 { | |
| 177 static struct object bolt = | |
| 178 { | |
