Mercurial > hg > early-roguelike
comparison arogue5/wear.c @ 63:0ed67132cf10
Import Advanced Rogue 5.8 from the Roguelike Restoration Project (r1490)
| author | elwin |
|---|---|
| date | Thu, 09 Aug 2012 22:58:48 +0000 |
| parents | |
| children | c49f7927b0fa |
comparison
equal
deleted
inserted
replaced
| 62:0ef99244acb8 | 63:0ed67132cf10 |
|---|---|
| 1 /* | |
| 2 * This file contains misc functions for dealing with armor | |
| 3 * | |
| 4 * Advanced Rogue | |
| 5 * Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T | |
| 6 * All rights reserved. | |
| 7 * | |
| 8 * Based on "Rogue: Exploring the Dungeons of Doom" | |
| 9 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * See the file LICENSE.TXT for full copyright and licensing information. | |
| 13 */ | |
| 14 | |
| 15 #include "curses.h" | |
| 16 #include "rogue.h" | |
| 17 | |
| 18 | |
| 19 /* | |
| 20 * take_off: | |
| 21 * Get the armor off of the players back | |
| 22 */ | |
| 23 | |
| 24 take_off() | |
| 25 { | |
| 26 register struct object *obj; | |
| 27 register struct linked_list *item; | |
| 28 | |
| 29 /* What does player want to take off? */ | |
| 30 if ((item = get_item(pack, "take off", REMOVABLE)) == NULL) | |
| 31 return; | |
| 32 | |
| 33 obj = OBJPTR(item); | |
| 34 if (!is_current(obj)) { | |
| 35 sprintf(outstring,"Not wearing %c) %s", pack_char(pack, obj),inv_name(obj, TRUE)); | |
| 36 msg(outstring); | |
| 37 return; | |
| 38 } | |
| 39 | |
| 40 /* Can the player remove the item? */ | |
| 41 if (!dropcheck(obj)) return; | |
| 42 updpack(TRUE); | |
| 43 | |
| 44 sprintf(outstring,"Was wearing %c) %s", pack_char(pack, obj),inv_name(obj,TRUE)); | |
| 45 msg(outstring); | |
| 46 } | |
| 47 | |
| 48 /* | |
| 49 * wear: | |
| 50 * The player wants to wear something, so let him/her put it on. | |
| 51 */ | |
| 52 | |
| 53 wear() | |
| 54 { | |
| 55 register struct linked_list *item; | |
| 56 register struct object *obj; | |
| 57 register int i; | |
| 58 char buf[LINELEN]; | |
| 59 | |
| 60 | |
| 61 /* What does player want to wear? */ | |
| 62 if ((item = get_item(pack, "wear", WEARABLE)) == NULL) | |
| 63 return; | |
| 64 | |
| 65 obj = OBJPTR(item); | |
| 66 | |
| 67 switch (obj->o_type) { | |
| 68 case ARMOR: | |
| 69 if (cur_armor != NULL) { | |
| 70 addmsg("You are already wearing armor"); | |
| 71 if (!terse) addmsg(". You'll have to take it off first."); | |
| 72 endmsg(); | |
| 73 after = FALSE; | |
| 74 return; | |
| 75 } | |
| 76 if (cur_misc[WEAR_BRACERS] != NULL) { | |
| 77 msg("You can't wear armor with bracers of defense."); | |
| 78 return; | |
| 79 } | |
| 80 if (cur_misc[WEAR_CLOAK] != NULL || cur_relic[EMORI_CLOAK]) { | |
| 81 msg("You can't wear armor with a cloak."); | |
| 82 return; | |
| 83 } | |
| 84 if (player.t_ctype == C_THIEF && | |
| 85 (obj->o_which != LEATHER && obj->o_which != STUDDED_LEATHER)) { | |
| 86 if (terse) msg("Thieves can't wear that type of armor"); | |
| 87 else | |
| 88 msg("Thieves can only wear leather or studded leather armor"); | |
| 89 return; | |
| 90 } | |
| 91 waste_time(); | |
| 92 obj->o_flags |= ISKNOW; | |
| 93 cur_armor = obj; | |
| 94 addmsg(terse ? "W" : "You are now w"); | |
| 95 msg("earing %s.", armors[obj->o_which].a_name); | |
| 96 | |
| 97 when MM: | |
| 98 switch (obj->o_which) { | |
| 99 /* | |
| 100 * when wearing the boots of elvenkind the player will not | |
| 101 * set off any traps | |
| 102 */ | |
| 103 case MM_ELF_BOOTS: | |
| 104 if (cur_misc[WEAR_BOOTS] != NULL) | |
| 105 msg("already wearing a pair of boots"); | |
| 106 else { | |
| 107 msg("wearing %s",inv_name(obj,TRUE)); | |
| 108 cur_misc[WEAR_BOOTS] = obj; | |
| 109 } | |
| 110 /* | |
| 111 * when wearing the boots of dancing the player will dance | |
| 112 * uncontrollably | |
| 113 */ | |
| 114 when MM_DANCE: | |
| 115 if (cur_misc[WEAR_BOOTS] != NULL) | |
| 116 msg("already wearing a pair of boots"); | |
| 117 else { | |
| 118 msg("wearing %s",inv_name(obj,TRUE)); | |
| 119 cur_misc[WEAR_BOOTS] = obj; | |
| 120 msg("You begin to dance uncontrollably!"); | |
| 121 turn_on(player, ISDANCE); | |
| 122 } | |
| 123 /* | |
| 124 * bracers give the hero protection in he same way armor does. | |
| 125 * they cannot be used with armor but can be used with cloaks | |
| 126 */ | |
| 127 when MM_BRACERS: | |
| 128 if (cur_misc[WEAR_BRACERS] != NULL) | |
| 129 msg("already wearing bracers"); | |
| 130 else { | |
| 131 if (cur_armor != NULL) { | |
| 132 msg("You can't wear bracers of defense with armor."); | |
| 133 } | |
| 134 else { | |
| 135 msg("wearing %s",inv_name(obj,TRUE)); | |
| 136 cur_misc[WEAR_BRACERS] = obj; | |
| 137 } | |
| 138 } | |
| 139 | |
| 140 /* | |
| 141 * The robe (cloak) of powerlessness disallows any spell casting | |
| 142 */ | |
| 143 when MM_R_POWERLESS: | |
| 144 /* | |
| 145 * the cloak of displacement gives the hero an extra +2 on AC | |
| 146 * and saving throws. Cloaks cannot be used with armor. | |
| 147 */ | |
| 148 case MM_DISP: | |
| 149 /* | |
| 150 * the cloak of protection gives the hero +n on AC and saving | |
| 151 * throws with a max of +3 on saves | |
| 152 */ | |
| 153 case MM_PROTECT: | |
| 154 if (cur_misc[WEAR_CLOAK] != NULL || cur_relic[EMORI_CLOAK]) | |
| 155 msg("%slready wearing a cloak.", terse ? "A" | |
| 156 : "You are a"); | |
| 157 else { | |
| 158 if (cur_armor != NULL) { | |
| 159 msg("You can't wear a cloak with armor."); | |
| 160 } | |
| 161 else { | |
| 162 msg("wearing %s",inv_name(obj,TRUE)); | |
| 163 cur_misc[WEAR_CLOAK] = obj; | |
| 164 } | |
| 165 } | |
| 166 /* | |
| 167 * the gauntlets of dexterity give the hero a dexterity of 18 | |
| 168 * the gauntlets of ogre power give the hero a strength of 18 | |
| 169 * the gauntlets of fumbling cause the hero to drop his weapon | |
| 170 */ | |
| 171 when MM_G_DEXTERITY: | |
| 172 case MM_G_OGRE: | |
| 173 case MM_FUMBLE: | |
| 174 if (cur_misc[WEAR_GAUNTLET] != NULL) | |
| 175 msg("Already wearing a pair of gauntlets."); | |
| 176 else { | |
| 177 msg("wearing %s",inv_name(obj,TRUE)); | |
| 178 cur_misc[WEAR_GAUNTLET] = obj; | |
| 179 if (obj->o_which == MM_FUMBLE) | |
| 180 daemon(fumble, 0, AFTER); | |
| 181 } | |
| 182 /* | |
| 183 * the jewel of attacks does an aggavate monster | |
| 184 */ | |
| 185 when MM_JEWEL: | |
| 186 if (cur_misc[WEAR_JEWEL] != NULL || cur_relic[YENDOR_AMULET]) | |
| 187 msg("Already wearing an amulet."); | |
| 188 else { | |
| 189 msg("wearing %s",inv_name(obj,TRUE)); | |
| 190 cur_misc[WEAR_JEWEL] = obj; | |
| 191 aggravate(); | |
| 192 } | |
| 193 /* | |
| 194 * the necklace of adaption makes the hero immune to | |
| 195 * chlorine gas | |
| 196 */ | |
| 197 when MM_ADAPTION: | |
| 198 if (cur_misc[WEAR_NECKLACE] != NULL) | |
| 199 msg("already wearing a necklace"); | |
| 200 else { | |
| 201 msg("wearing %s",inv_name(obj,TRUE)); | |
| 202 cur_misc[WEAR_NECKLACE] = obj; | |
| 203 turn_on(player, NOGAS); | |
| 204 } | |
| 205 /* | |
| 206 * the necklace of stragulation will try to strangle the | |
| 207 * hero to death | |
| 208 */ | |
| 209 when MM_STRANGLE: | |
| 210 if (cur_misc[WEAR_NECKLACE] != NULL) | |
| 211 msg("already wearing a necklace"); | |
| 212 else { | |
| 213 msg("wearing %s",inv_name(obj,TRUE)); | |
| 214 cur_misc[WEAR_NECKLACE] = obj; | |
| 215 msg("The necklace is beginning to strangle you!"); | |
| 216 daemon(strangle, 0, AFTER); | |
| 217 } | |
| 218 otherwise: | |
| 219 msg("what a strange item you have!"); | |
| 220 } | |
| 221 status(FALSE); | |
| 222 if (m_know[obj->o_which] && m_guess[obj->o_which]) { | |
| 223 free(m_guess[obj->o_which]); | |
| 224 m_guess[obj->o_which] = NULL; | |
| 225 } | |
| 226 else if (!m_know[obj->o_which] && | |
| 227 askme && | |
| 228 (obj->o_flags & ISKNOW) == 0 && | |
| 229 m_guess[obj->o_which] == NULL) { | |
| 230 msg(terse ? "Call it: " : "What do you want to call it? "); | |
| 231 if (get_str(buf, cw) == NORM) { | |
| 232 m_guess[obj->o_which] = new((unsigned int) strlen(buf) + 1); | |
| 233 strcpy(m_guess[obj->o_which], buf); | |
| 234 } | |
| 235 } | |
| 236 | |
| 237 when RING: | |
| 238 if (cur_misc[WEAR_GAUNTLET] != NULL) { | |
| 239 msg ("You have to remove your gauntlets first!"); | |
| 240 return; | |
| 241 } | |
| 242 | |
| 243 /* If there is room, put on the ring */ | |
| 244 for (i=0; i<NUM_FINGERS; i++) | |
| 245 if (cur_ring[i] == NULL) { | |
| 246 cur_ring[i] = obj; | |
| 247 break; | |
| 248 } | |
| 249 if (i == NUM_FINGERS) { /* No room */ | |
| 250 if (terse) msg("Wearing enough rings"); | |
| 251 else msg("You already have on eight rings"); | |
| 252 return; | |
| 253 } | |
| 254 | |
| 255 /* Calculate the effect of the ring */ | |
| 256 ring_on(obj); | |
| 257 } | |
| 258 updpack(TRUE); | |
| 259 } |
