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