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