annotate srogue/armor.c @ 317:aab761616489 default tip

Rearrange some Autoconf files. Autoconf was failing to detect install-sh at the top level and needed some explicit directions. It also wants config.guess and config.sub to be provided too. A few other macros have also been updated.
author John "Elwin" Edwards
date Tue, 05 Sep 2023 20:05:24 -0400
parents e52a8a7ad4c5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
1 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
2 * This file contains misc functions for dealing with armor
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
3 *
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
4 * @(#)armor.c 9.0 (rdk) 7/17/84
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
5 *
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
6 * Super-Rogue
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
7 * Copyright (C) 1984 Robert D. Kindelberger
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
8 * All rights reserved.
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
9 *
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
10 * Based on "Rogue: Exploring the Dungeons of Doom"
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
11 * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
12 * All rights reserved.
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
13 *
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
14 * See the file LICENSE.TXT for full copyright and licensing information.
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
15 */
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
16
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
17 #include "rogue.h"
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
18 #include "rogue.ext"
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
19
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
20 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
21 * wear:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
22 * The player wants to wear something, so let the hero try
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
23 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
24 void
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
25 wear(void)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
26 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
27 reg struct linked_list *item;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
28 reg struct object *obj;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
29
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
30 if (cur_armor != NULL) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
31 msg("You are already wearing some.");
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
32 after = FALSE;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
33 return;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
34 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
35 if ((item = get_item("wear", ARMOR)) == NULL)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
36 return;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
37 obj = OBJPTR(item);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
38 if (obj->o_type != ARMOR) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
39 msg("You can't wear that.");
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
40 return;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
41 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
42 waste_time();
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
43 msg("Wearing %s.", a_magic[obj->o_which].mi_name);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
44 cur_armor = obj;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
45 setoflg(obj,ISKNOW);
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
46 nochange = FALSE;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
47 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
48
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
49
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
50 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
51 * take_off:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
52 * Get the armor off of the players back
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
53 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
54 void
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
55 take_off(void)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
56 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
57 reg struct object *obj;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
58
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
59 if ((obj = cur_armor) == NULL) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
60 msg("Not wearing any armor.");
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
61 return;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
62 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
63 if (!dropcheck(cur_armor))
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
64 return;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
65 cur_armor = NULL;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
66 msg("Was wearing %c) %s",pack_char(obj),inv_name(obj,TRUE));
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
67 nochange = FALSE;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
68 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
69
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
70 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
71 * initarmor:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
72 * Initialize some armor.
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
73 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
74 void
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
75 initarmor(struct object *obj, int what)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
76 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
77 struct init_armor *iwa;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
78
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
79 obj->o_type = ARMOR;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
80 obj->o_which = what;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
81 iwa = &armors[what];
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
82 obj->o_vol = iwa->a_vol;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
83 obj->o_ac = iwa->a_class;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
84 obj->o_weight = iwa->a_wght;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
85 obj->o_typname = things[TYP_ARMOR].mi_name;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
86 }
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
87
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
88 /*
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
89 * hurt_armor:
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
90 * Returns TRUE if armor is damaged
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
91 */
217
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
92 bool
94a0d9dd5ce1 Super-Rogue: convert to ANSI-style function declarations.
John "Elwin" Edwards
parents: 36
diff changeset
93 hurt_armor(struct object *obj)
36
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
94 {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
95 reg int type, ac;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
96
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
97 if (obj != NULL) {
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
98 if (o_on(obj, ISPROT) || (o_on(obj, ISBLESS) && rnd(100) < 10))
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
99 return FALSE;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
100 ac = obj->o_ac;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
101 type = obj->o_which;
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
102 if (type != PADDED && type != LEATHER)
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
103 if ((type == STUDDED && ac < 8) || (type != STUDDED && ac < 9))
2128c7dc8a40 Import Super-Rogue 9.0 from the Roguelike Restoration Project (r1490)
elwin
parents:
diff changeset
104 return TRUE;