annotate rogue4/weapons.c @ 300:0250220d8cdd

Fix an assortment of compiler warnings. A few potential bugs were removed in the process. Much code cleanup remains to be done.
author John "Elwin" Edwards
date Fri, 22 Nov 2019 21:18:27 -0500
parents 1b73a8641b37
children e52a8a7ad4c5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
1 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
2 * Functions for dealing with problems brought about by weapons
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
3 *
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
4 * @(#)weapons.c 4.14 (Berkeley) 4/6/82
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
5 *
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
6 * Rogue: Exploring the Dungeons of Doom
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
7 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
8 * All rights reserved.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
9 *
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
10 * See the file LICENSE.TXT for full copyright and licensing information.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
11 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
13 #include <curses.h>
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
14 #include <ctype.h>
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
15 #include <string.h>
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
16 #include "rogue.h"
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
17
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
18 #define NONE 100
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
19
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
20 static struct init_weps {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
21 char *iw_dam; /* Damage when wielded */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
22 char *iw_hrl; /* Damage when thrown */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
23 char iw_launch; /* Launching weapon */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
24 int iw_flags; /* Miscellaneous flags */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
25 } init_dam[MAXWEAPONS] = {
300
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
26 { "2d4", "1d3", NONE, 0 }, /* Mace */
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
27 { "3d4", "1d2", NONE, 0 }, /* Long sword */
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
28 { "1d1", "1d1", NONE, 0 }, /* Bow */
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
29 { "1d1", "2d3", BOW, ISMANY|ISMISL },/* Arrow */
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
30 { "1d6", "1d4", NONE, ISMISL }, /* Dagger */
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
31 { "4d4", "1d2", NONE, 0 }, /* 2h sword */
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
32 { "1d1", "1d3", NONE, ISMANY|ISMISL },/* Dart */
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
33 { "1d1", "1d1", NONE, 0 }, /* Crossbow */
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
34 { "1d2", "2d5", CROSSBOW, ISMANY|ISMISL },/* Crossbow bolt */
0250220d8cdd Fix an assortment of compiler warnings.
John "Elwin" Edwards
parents: 215
diff changeset
35 { "2d3", "1d6", NONE, ISMISL } /* Spear */
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
36 };
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
37
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
38 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
39 * missile:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
40 * Fire a missile in a given direction
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
41 */
215
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
42 void
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
43 missile(int ydelta, int xdelta)
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
44 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
45 register THING *obj, *nitem;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
46
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
47 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
48 * Get which thing we are hurling
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
49 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
50 if ((obj = get_item("throw", WEAPON)) == NULL)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
51 return;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
52 if (!dropcheck(obj) || is_current(obj))
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
53 return;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
54 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
55 * Get rid of the thing. If it is a non-multiple item object, or
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
56 * if it is the last thing, just drop it. Otherwise, create a new
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
57 * item with a count of one.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
58 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
59 if (obj->o_count < 2)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
60 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
61 detach(pack, obj);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
62 inpack--;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
63 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
64 else
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
65 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
66 obj->o_count--;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
67 if (obj->o_group == 0)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
68 inpack--;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
69 nitem = new_item();
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
70 *nitem = *obj;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
71 nitem->o_count = 1;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
72 obj = nitem;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
73 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
74 do_motion(obj, ydelta, xdelta);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
75 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
76 * AHA! Here it has hit something. If it is a wall or a door,
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
77 * or if it misses (combat) the monster, put it on the floor
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
78 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
79 if (moat(obj->o_pos.y, obj->o_pos.x) == NULL
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
80 || !hit_monster(unc(obj->o_pos), obj))
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
81 fall(obj, TRUE);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
82 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
83
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
84 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
85 * do_motion:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
86 * Do the actual motion on the screen done by an object traveling
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
87 * across the room
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
88 */
215
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
89 void
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
90 do_motion(THING *obj, int ydelta, int xdelta)
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
91 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
92 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
93 * Come fly with us ...
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
94 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
95 obj->o_pos = hero;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
96 for (;;)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
97 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
98 register int ch;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
99
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
100 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
101 * Erase the old one
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
102 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
103 if (!ce(obj->o_pos, hero) && cansee(unc(obj->o_pos)))
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
104 mvaddch(obj->o_pos.y, obj->o_pos.x, chat(obj->o_pos.y, obj->o_pos.x));
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
105 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
106 * Get the new position
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
107 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
108 obj->o_pos.y += ydelta;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
109 obj->o_pos.x += xdelta;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
110 if (step_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
111 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
112 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
113 * It hasn't hit anything yet, so display it
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
114 * If it alright.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
115 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
116 if (cansee(unc(obj->o_pos)))
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
117 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
118 mvaddch(obj->o_pos.y, obj->o_pos.x, obj->o_type);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
119 refresh();
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
120 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
121 continue;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
122 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
123 break;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
124 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
125 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
126
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
127 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
128 * fall:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
129 * Drop an item someplace around here.
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
130 */
215
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
131 void
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
132 fall(THING *obj, bool pr)
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
133 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
134 static coord fpos;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
135 register int index;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
136
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
137 if (fallpos(&obj->o_pos, &fpos, TRUE))
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
138 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
139 index = INDEX(fpos.y, fpos.x);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
140 _level[index] = obj->o_type;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
141 obj->o_pos = fpos;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
142 if (cansee(fpos.y, fpos.x))
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
143 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
144 mvaddch(fpos.y, fpos.x, obj->o_type);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
145 if (_monst[index] != NULL)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
146 _monst[index]->t_oldch = obj->o_type;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
147 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
148 attach(lvl_obj, obj);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
149 return;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
150 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
151
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
152 if (pr)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
153 msg("the %s vanishes as it hits the ground",
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
154 /* BUGFIX: Identification trick */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
155 (obj->o_type==WEAPON) ? w_names[obj->o_which] : inv_name(obj,TRUE));
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
156
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
157 discard(obj);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
158 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
159
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
160 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
161 * init_weapon:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
162 * Set up the initial goodies for a weapon
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
163 */
215
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
164 void
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
165 init_weapon(THING *weap, char type)
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
166 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
167 register struct init_weps *iwp;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
168
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
169 iwp = &init_dam[type];
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
170 strncpy(weap->o_damage, iwp->iw_dam, 8);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
171 strncpy(weap->o_hurldmg, iwp->iw_hrl, 8);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
172 weap->o_launch = iwp->iw_launch;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
173 weap->o_flags = iwp->iw_flags;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
174 if (weap->o_flags & ISMANY)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
175 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
176 weap->o_count = rnd(8) + 8;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
177 weap->o_group = group++;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
178 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
179 else
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
180 weap->o_count = 1;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
181 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
182
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
183 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
184 * hit_monster:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
185 * Does the missile hit the monster?
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
186 */
215
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
187 bool
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
188 hit_monster(int y, int x, THING *obj)
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
189 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
190 static coord mp;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
191
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
192 mp.y = y;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
193 mp.x = x;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
194 return fight(&mp, moat(y, x)->t_type, obj, TRUE);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
195 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
196
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
197 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
198 * num:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
199 * Figure out the plus number for armor/weapons
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
200 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
201 char *
215
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
202 num(int n1, int n2, char type)
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
203 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
204 static char numbuf[10];
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
205
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
206 sprintf(numbuf, "%s%d", n1 < 0 ? "" : "+", n1);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
207 if (type == WEAPON)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
208 sprintf(&numbuf[strlen(numbuf)], ",%s%d", n2 < 0 ? "" : "+", n2);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
209 return numbuf;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
210 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
211
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
212 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
213 * wield:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
214 * Pull out a certain weapon
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
215 */
215
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
216 void
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
217 wield(void)
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
218 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
219 register THING *obj, *oweapon;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
220 register char *sp;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
221
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
222 oweapon = cur_weapon;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
223 if (!dropcheck(cur_weapon))
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
224 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
225 cur_weapon = oweapon;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
226 return;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
227 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
228 cur_weapon = oweapon;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
229 if ((obj = get_item("wield", WEAPON)) == NULL)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
230 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
231 bad:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
232 after = FALSE;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
233 return;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
234 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
235
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
236 if (obj->o_type == ARMOR)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
237 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
238 msg("you can't wield armor");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
239 goto bad;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
240 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
241 if (is_current(obj))
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
242 goto bad;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
243
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
244 sp = inv_name(obj, TRUE);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
245 cur_weapon = obj;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
246 if (!terse)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
247 addmsg("you are now ");
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
248 msg("wielding %s (%c)", sp, pack_char(obj));
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
249 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
250
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
251 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
252 * fallpos:
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
253 * Pick a random position around the give (y, x) coordinates
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
254 */
215
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
255 bool
1b73a8641b37 rogue4: fix most GCC5 warnings.
John "Elwin" Edwards
parents: 12
diff changeset
256 fallpos(coord *pos, coord *newpos, bool pass)
12
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
257 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
258 register int y, x, cnt, ch;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
259
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
260 cnt = 0;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
261 for (y = pos->y - 1; y <= pos->y + 1; y++)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
262 for (x = pos->x - 1; x <= pos->x + 1; x++)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
263 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
264 /*
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
265 * check to make certain the spot is empty, if it is,
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
266 * put the object there, set it in the level list
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
267 * and re-draw the room if he can see it
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
268 */
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
269 if (y == hero.y && x == hero.x)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
270 continue;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
271 if (((ch = chat(y, x)) == FLOOR || (pass && ch == PASSAGE))
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
272 && rnd(++cnt) == 0)
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
273 {
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
274 newpos->y = y;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
275 newpos->x = x;
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
276 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
277 }
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
278 return (cnt != 0);
9535a08ddc39 Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
edwarj4
parents:
diff changeset
279 }