Mercurial > hg > early-roguelike
comparison srogue/rings.c @ 36:2128c7dc8a40
Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
| author | elwin |
|---|---|
| date | Thu, 25 Nov 2010 12:21:41 +0000 |
| parents | |
| children | 3aa87373c908 |
comparison
equal
deleted
inserted
replaced
| 35:05018c63a721 | 36:2128c7dc8a40 |
|---|---|
| 1 /* | |
| 2 * routines dealing specifically with rings | |
| 3 * | |
| 4 * @(#)rings.c 9.0 (rdk) 7/17/84 | |
| 5 * | |
| 6 * Super-Rogue | |
| 7 * Copyright (C) 1984 Robert D. Kindelberger | |
| 8 * All rights reserved. | |
| 9 * | |
| 10 * Based on "Rogue: Exploring the Dungeons of Doom" | |
| 11 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
| 12 * All rights reserved. | |
| 13 * | |
| 14 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 15 */ | |
| 16 | |
| 17 #include "rogue.h" | |
| 18 #include "rogue.ext" | |
| 19 | |
| 20 /* | |
| 21 * ring_on: | |
| 22 * Put on a ring | |
| 23 */ | |
| 24 ring_on() | |
| 25 { | |
| 26 reg struct object *obj; | |
| 27 reg struct linked_list *item; | |
| 28 reg int ring, wh; | |
| 29 char buf[LINLEN]; | |
| 30 bool okring; | |
| 31 | |
| 32 if (cur_ring[LEFT] != NULL && cur_ring[RIGHT] != NULL) { | |
| 33 msg("Already wearing two rings."); | |
| 34 after = FALSE; | |
| 35 return; | |
| 36 } | |
| 37 /* | |
| 38 * Make certain that it is somethings that we want to wear | |
| 39 */ | |
| 40 if ((item = get_item("put on", RING)) == NULL) | |
| 41 return; | |
| 42 obj = OBJPTR(item); | |
| 43 if (obj->o_type != RING) { | |
| 44 msg("That won't fit on your finger."); | |
| 45 return; | |
| 46 } | |
| 47 /* | |
| 48 * find out which hand to put it on | |
| 49 */ | |
| 50 if (is_current(obj)) | |
| 51 return; | |
| 52 if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) { | |
| 53 if ((ring = gethand(FALSE)) < 0) | |
| 54 return; | |
| 55 } | |
| 56 else if (cur_ring[LEFT] == NULL) | |
| 57 ring = LEFT; | |
| 58 else | |
| 59 ring = RIGHT; | |
| 60 cur_ring[ring] = obj; | |
| 61 wh = obj->o_which; | |
| 62 /* | |
| 63 * okring = FALSE when: | |
| 64 * 1) ring is cursed and benefit = plus | |
| 65 * 2) ring is blessed and benefit = minus | |
| 66 */ | |
| 67 okring = !((obj->o_ac > 0 && o_on(obj, ISCURSED)) || | |
| 68 (obj->o_ac < 0 && o_on(obj, ISBLESS))); | |
| 69 /* | |
| 70 * Calculate the effect it has on the poor guy (if possible). | |
| 71 */ | |
| 72 if (okring) { | |
| 73 switch (wh) { | |
| 74 case R_SPEED: | |
| 75 if (--obj->o_ac < 0) { | |
| 76 obj->o_ac = 0; | |
| 77 setoflg(obj,ISCURSED); | |
| 78 } | |
| 79 else { | |
| 80 add_haste(FALSE); | |
| 81 msg("You find yourself moving must faster."); | |
| 82 } | |
| 83 when R_GIANT: /* to 24 */ | |
| 84 him->s_ef.a_str = MAXSTR; | |
| 85 when R_ADDSTR: | |
| 86 chg_abil(STR,obj->o_ac,FROMRING); | |
| 87 when R_KNOW: | |
| 88 chg_abil(WIS,obj->o_ac,FROMRING); | |
| 89 when R_DEX: | |
| 90 chg_abil(DEX,obj->o_ac,FROMRING); | |
| 91 when R_CONST: | |
| 92 chg_abil(CON,obj->o_ac,FROMRING); | |
| 93 when R_SEEINVIS: | |
| 94 player.t_flags |= CANSEE; | |
| 95 light(&hero); | |
| 96 mvwaddch(cw, hero.y, hero.x, PLAYER); | |
| 97 when R_AGGR: | |
| 98 aggravate(); | |
| 99 when R_HEAVY: | |
| 100 updpack(); /* new pack weight */ | |
| 101 when R_BLIND: | |
| 102 r_know[R_BLIND] = TRUE; | |
| 103 player.t_flags |= ISBLIND; | |
| 104 look(FALSE); | |
| 105 when R_SLOW: | |
| 106 player.t_flags |= ISSLOW; | |
| 107 when R_SAPEM: | |
| 108 fuse(sapem,TRUE,150); | |
| 109 when R_LIGHT: { | |
| 110 struct room *rop; | |
| 111 | |
| 112 r_know[R_LIGHT] = TRUE; | |
| 113 if ((rop = player.t_room) != NULL) { | |
| 114 rop->r_flags &= ~ISDARK; | |
| 115 light(&hero); | |
| 116 mvwaddch(cw, hero.y, hero.x, PLAYER); | |
| 117 } | |
| 118 } | |
| 119 } | |
| 120 } | |
| 121 if (r_know[wh] && r_guess[wh]) { | |
| 122 free(r_guess[wh]); | |
| 123 r_guess[wh] = NULL; | |
| 124 } | |
| 125 else if(!r_know[wh] && r_guess[wh] == NULL) { | |
| 126 mpos = 0; | |
| 127 strcpy(buf, r_stones[wh]); | |
| 128 msg(callit); | |
| 129 if (get_str(buf, cw) == NORM) { | |
| 130 r_guess[wh] = new(strlen(buf) + 1); | |
| 131 strcpy(r_guess[wh], buf); | |
| 132 } | |
| 133 } | |
| 134 mpos = 0; | |
| 135 msg("Now wearing %s",inv_name(obj,TRUE)); | |
| 136 ringfood = ring_eat(); | |
| 137 nochange = FALSE; | |
| 138 } | |
| 139 | |
| 140 | |
| 141 /* | |
| 142 * ring_off: | |
| 143 * Take off some ring | |
| 144 */ | |
| 145 ring_off() | |
| 146 { | |
| 147 reg int ring; | |
| 148 reg struct object *obj; | |
| 149 | |
| 150 if (cur_ring[LEFT] == NULL && cur_ring[RIGHT] == NULL) { | |
| 151 msg("You're not wearing any rings."); | |
| 152 return; | |
| 153 } | |
| 154 else if (cur_ring[LEFT] == NULL) | |
| 155 ring = RIGHT; | |
| 156 else if (cur_ring[RIGHT] == NULL) | |
| 157 ring = LEFT; | |
| 158 else | |
| 159 if ((ring = gethand(TRUE)) < 0) | |
| 160 return; | |
| 161 mpos = 0; | |
| 162 obj = cur_ring[ring]; | |
| 163 if (obj == NULL) { | |
| 164 msg("Not wearing such a ring."); | |
| 165 return; | |
| 166 } | |
| 167 if (dropcheck(obj)) { | |
| 168 msg("Was wearing %s", inv_name(obj, TRUE)); | |
| 169 nochange = FALSE; | |
| 170 ringfood = ring_eat(); | |
| 171 } | |
| 172 } | |
| 173 | |
| 174 | |
| 175 /* | |
| 176 * toss_ring: | |
| 177 * Remove a ring and stop its effects | |
| 178 */ | |
| 179 toss_ring(what) | |
| 180 struct object *what; | |
| 181 { |
