Annotation of early-roguelike/srogue/armor.c, Revision 1.1.1.1
1.1 rubenllo 1: /*
2: * This file contains misc functions for dealing with armor
3: *
4: * @(#)armor.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: * wear:
22: * The player wants to wear something, so let the hero try
23: */
24: void
25: wear(void)
26: {
27: reg struct linked_list *item;
28: reg struct object *obj;
29:
30: if (cur_armor != NULL) {
31: msg("You are already wearing some.");
32: after = FALSE;
33: return;
34: }
35: if ((item = get_item("wear", ARMOR)) == NULL)
36: return;
37: obj = OBJPTR(item);
38: if (obj->o_type != ARMOR) {
39: msg("You can't wear that.");
40: return;
41: }
42: waste_time();
43: msg("Wearing %s.", a_magic[obj->o_which].mi_name);
44: cur_armor = obj;
45: setoflg(obj,ISKNOW);
46: nochange = FALSE;
47: }
48:
49:
50: /*
51: * take_off:
52: * Get the armor off of the players back
53: */
54: void
55: take_off(void)
56: {
57: reg struct object *obj;
58:
59: if ((obj = cur_armor) == NULL) {
60: msg("Not wearing any armor.");
61: return;
62: }
63: if (!dropcheck(cur_armor))
64: return;
65: cur_armor = NULL;
66: msg("Was wearing %c) %s",pack_char(obj),inv_name(obj,TRUE));
67: nochange = FALSE;
68: }
69:
70: /*
71: * initarmor:
72: * Initialize some armor.
73: */
74: void
75: initarmor(struct object *obj, int what)
76: {
77: struct init_armor *iwa;
78: struct magic_item *mi;
79:
80: obj->o_type = ARMOR;
81: obj->o_which = what;
82: iwa = &armors[what];
83: mi = &a_magic[what];
84: obj->o_vol = iwa->a_vol;
85: obj->o_ac = iwa->a_class;
86: obj->o_weight = iwa->a_wght;
87: obj->o_typname = things[TYP_ARMOR].mi_name;
88: }
89:
90: /*
91: * hurt_armor:
92: * Returns TRUE if armor is damaged
93: */
94: bool
95: hurt_armor(struct object *obj)
96: {
97: reg int type, ac;
98:
99: if (obj != NULL) {
100: if (o_on(obj, ISPROT) || (o_on(obj, ISBLESS) && rnd(100) < 10))
101: return FALSE;
102: ac = obj->o_ac;
103: type = obj->o_which;
104: if (type != PADDED && type != LEATHER)
105: if ((type == STUDDED && ac < 8) || (type != STUDDED && ac < 9))
106: return TRUE;
107: }
108: return FALSE;
109: }
CVSweb