forked from RoguelikeRestorationProject/urogue1.03
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharmor.c
183 lines (163 loc) · 3.99 KB
/
armor.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
armor.c - This file contains misc functions for dealing with armor
UltraRogue
Copyright (C) 1984, 1985, 1986, 1987, 1990, 1991 Herb Chong
All rights reserved.
Based on "Advanced Rogue"
Copyright (C) 1983, 1984 Michael Morgan, Ken Dalka and AT&T
All rights reserved.
Based on "Super-Rogue"
Copyright (C) 1982, 1983 Robert D. Kindelberger
All rights reserved.
Based on "Rogue: Exploring the Dungeons of Doom"
Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
All rights reserved.
See the file LICENSE.TXT for full copyright and licensing information.
*/
#include "rogue.h"
/*
wear()
The player wants to wear something, so let him/her put it on.
*/
void
wear()
{
struct object *obj;
if (cur_armor != NULL) {
addmsg("You are already wearing some");
if (!terse)
addmsg(". You'll have to take it off first");
addmsg(".");
endmsg();
after = FALSE;
return;
}
/* What does player want to wear? */
if ((obj = get_object(pack, "wear", ARMOR, NULL)) == NULL)
return;
wear_ok(&player, obj, MESSAGE);
waste_time();
addmsg(terse ? "W" : "You are now w");
msg("earing %s.", armors[obj->o_which].a_name);
cur_armor = obj;
obj->o_flags |= ISKNOW;
}
/*
* take_off: Get the armor off of the players back
*/
void
take_off()
{
struct object *obj;
extern char print_letters[];
if ((obj = cur_armor) == NULL) {
msg("%s wearing armor!", terse ? "Not" : "You aren't");
return;
}
if (!dropcheck(cur_armor))
return;
addmsg(terse ? "Was" : "You used to be");
msg(" wearing %c%c) %s.", ARMOR, print_letters[get_ident(obj)],
inv_name(obj, LOWERCASE));
cur_armor = NULL;
if (on(player, STUMBLER)) {
msg("Your foot feels a lot better now.");
turn_off(player, STUMBLER);
}
}
/*
* wear_ok: enforce player class armor restrictions
*/
int
wear_ok(struct thing *wearee, struct object *obj, bool print_message)
{
int which = obj->o_which;
bool ret_val = TRUE;
int class_type = wearee->t_ctype;
if (obj->o_type != ARMOR) {
ret_val = FALSE;
return (ret_val);
}
else
switch (class_type) {
when C_MAGICIAN: /* cannot wear metal */
case C_ILLUSION:
switch (which) {
case RING_MAIL:
case SCALE_MAIL:
case PADDED_ARMOR:
case CHAIN_MAIL:
case BRIGANDINE:
case SPLINT_MAIL:
case GOOD_CHAIN:
case PLATE_MAIL:
case PLATE_ARMOR:
ret_val = FALSE;
otherwise:
break;
}
when C_THIEF: /* cannot clank around */
case C_ASSASIN:
case C_NINJA:
switch (which) {
case CHAIN_MAIL:
case BRIGANDINE:
case SPLINT_MAIL:
case GOOD_CHAIN:
case PLATE_MAIL:
case PLATE_ARMOR:
ret_val = FALSE;
otherwise:
break;
}
when C_CLERIC: /* cannot wear plate */
case C_DRUID:
switch (which) {
case PLATE_MAIL:
case PLATE_ARMOR:
case MITHRIL:
ret_val = FALSE;
otherwise:
break;
}
case C_FIGHTER: /* wear anything */
case C_RANGER:
break;
when C_PALADIN: /* cannot wear common stuff */
switch (which) {
case SOFT_LEATHER:
case CUIRBOLILLI:
case HEAVY_LEATHER:
case STUDDED_LEATHER:
case PADDED_ARMOR:
case BRIGANDINE:
ret_val = FALSE;
otherwise:
break;
}
case C_MONSTER:
break;
otherwise: /* Unknown class */
debug("Unknown class %d.", class_type);
break;
}
if (ret_val == FALSE && print_message == MESSAGE)
switch (class_type) {
when C_MAGICIAN:
case C_ILLUSION:
msg("You cannot regenerate spell points while wearing that!");
when C_THIEF:
case C_ASSASIN:
case C_NINJA:
msg("Don't expect to be stealty while wearing that!");
when C_CLERIC:
case C_DRUID:
case C_PALADIN:
msg("Your god strongly disapproves of your wearing that!");
case C_FIGHTER:
case C_RANGER:
case C_MONSTER:
break;
}
return (ret_val);
}