annotate urogue/weapons.c @ 264:778938a5c21d

UltraRogue: add location for character files. When using the -n option, UltraRogue will look for character files in a single location, similar to save files. The location is chosen by defining CHRDIR in getplay.c, at least until UltraRogue gets integrated with the build systems.
author John "Elwin" Edwards
date Sun, 19 Feb 2017 19:47:09 -0500
parents c495a4f288c6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
256
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
1 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
2 weapons.c - Functions for dealing with problems brought about by weapons
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
3
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
4 UltraRogue: The Ultimate Adventure in the Dungeons of Doom
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
5 Copyright (C) 1985, 1986, 1992, 1993, 1995 Herb Chong
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
6 All rights reserved.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
7
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
8 Based on "Advanced Rogue"
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
10 All rights reserved.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
11
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
12 Based on "Rogue: Exploring the Dungeons of Doom"
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
14 All rights reserved.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
15
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
16 See the file LICENSE.TXT for full copyright and licensing information.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
17 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
18
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
19 #include <ctype.h>
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
20 #include <string.h>
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
21 #include "rogue.h"
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
22
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
23 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
24 missile()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
25 Fire a missile in a given direction
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
26 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
27
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
28 void
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
29 missile(int ydelta, int xdelta, struct linked_list *item, struct thing *tp)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
30 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
31 struct object *obj;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
32 struct linked_list *nitem;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
33
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
34 if (item == NULL) /* Get which thing we are hurling */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
35 return;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
36
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
37 obj = OBJPTR(item);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
38
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
39 if (!dropcheck(obj) || is_current(obj))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
40 return;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
41
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
42 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
43 * Get rid of the thing. If it is a non-multiple item object, or if
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
44 * it is the last thing, just drop it. Otherwise, create a new item
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
45 * with a count of one.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
46 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
47
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
48 if (obj->o_count < 2)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
49 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
50 if (tp->t_pack == pack)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
51 rem_pack(obj);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
52 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
53 detach(tp->t_pack, item);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
54 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
55 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
56 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
57 obj->o_count--;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
58 nitem = (struct linked_list *) new_item(sizeof *obj);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
59 obj = OBJPTR(nitem);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
60 *obj = *(OBJPTR(item));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
61 obj->o_count = 1;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
62 item = nitem;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
63 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
64
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
65 switch (obj->o_type)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
66 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
67 case ARTIFACT:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
68 has_artifact &= ~(1 << obj->o_which);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
69 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
70
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
71 case SCROLL:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
72 if (obj->o_which == S_SCARE && obj->o_flags & ISBLESSED)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
73 obj->o_flags &= ~ISBLESSED;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
74 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
75 obj->o_flags |= ISCURSED;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
76 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
77
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
78 updpack();
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
79 obj->o_pos = do_motion(obj->o_type, ydelta, xdelta, tp);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
80
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
81 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
82 * AHA! Here it has hit something. If it is a wall or a door, or if
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
83 * it misses (combat) the monster, put it on the floor
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
84 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
85
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
86 if (!hit_monster(obj->o_pos.y, obj->o_pos.x, obj, tp))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
87 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
88 if (obj->o_type == WEAPON && obj->o_which == GRENADE)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
89 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
90 hearmsg("BOOOM!");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
91 aggravate();
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
92
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
93 if (ntraps + 1 < 2 * MAXTRAPS &&
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
94 fallpos(obj->o_pos, &traps[ntraps].tr_pos))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
95 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
96 mvaddch(traps[ntraps].tr_pos.y, traps[ntraps].tr_pos.x,
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
97 TRAPDOOR);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
98 traps[ntraps].tr_type = TRAPDOOR;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
99 traps[ntraps].tr_flags = ISFOUND;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
100 traps[ntraps].tr_show = TRAPDOOR;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
101 ntraps++;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
102 light(&hero);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
103 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
104 discard(item);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
105 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
106 else if (obj->o_flags & ISLOST)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
107 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
108 if (obj->o_type == WEAPON)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
109 addmsg("The %s", weaps[obj->o_which].w_name);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
110 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
111 addmsg(inv_name(obj, LOWERCASE));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
112
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
113 msg(" vanishes in a puff of greasy smoke.");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
114 discard(item);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
115 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
116 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
117 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
118 fall(&player, item, TRUE, TRUE);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
119
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
120 if (obj->o_flags & CANRETURN)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
121 msg("You have %s.", inv_name(obj, LOWERCASE));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
122 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
123 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
124 else if (obj->o_flags & ISOWNED)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
125 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
126 add_pack(item, NOMESSAGE);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
127 msg("You have %s.", inv_name(obj, LOWERCASE));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
128 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
129
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
130 mvwaddch(cw, hero.y, hero.x, PLAYER);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
131 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
132
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
133 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
134 do_motion()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
135 do the actual motion on the screen done by an object
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
136 traveling across the room
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
137 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
138
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
139 coord
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
140 do_motion(int ob, int ydelta, int xdelta, struct thing *tp)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
141 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
142 coord pos;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
143 /* Come fly with us ... */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
144
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
145 pos = tp->t_pos;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
146
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
147 for (;;)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
148 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
149 int ch;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
150
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
151 /* Erase the old one */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
152
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
153 if (!ce(pos, tp->t_pos) &&
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
154 cansee(pos.y, pos.x) &&
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
155 mvwinch(cw, pos.y, pos.x) != ' ')
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
156 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
157 mvwaddch(cw, pos.y, pos.x, show(pos.y, pos.x));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
158 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
159
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
160 /* Get the new position */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
161
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
162 pos.y += ydelta;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
163 pos.x += xdelta;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
164
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
165 if (shoot_ok(ch = winat(pos.y, pos.x)) &&
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
166 ch != DOOR && !ce(pos, hero))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
167 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
168 /* It hasn't hit anything yet, so display it if it alright. */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
169
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
170 if (cansee(pos.y, pos.x) &&
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
171 mvwinch(cw, pos.y, pos.x) != ' ')
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
172 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
173 mvwaddch(cw, pos.y, pos.x, ob);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
174 wrefresh(cw);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
175 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
176
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
177 continue;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
178
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
179 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
180 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
181 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
182
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
183 return(pos);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
184 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
185
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
186 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
187 fall()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
188 Drop an item someplace around here.
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
189 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
190
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
191 void
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
192 fall(struct thing *tp, struct linked_list *item, int pr, int player_owned)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
193 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
194 struct object *obj;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
195 struct room *rp;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
196 coord fpos;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
197
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
198 obj = OBJPTR(item);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
199 rp = roomin(tp->t_pos);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
200
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
201 if (player_owned && obj->o_flags & CANRETURN)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
202 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
203 add_pack(item, NOMESSAGE);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
204 msg("You have %s.", inv_name(obj, LOWERCASE));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
205 return;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
206 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
207 else if (fallpos(obj->o_pos, &fpos))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
208 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
209 if (obj->o_flags & CANBURN && obj->o_type == WEAPON
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
210 && obj->o_which == MOLOTOV
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
211 && ntraps + 1 < 2 * MAXTRAPS)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
212 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
213 mvaddch(fpos.y, fpos.x, FIRETRAP);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
214 traps[ntraps].tr_type = FIRETRAP;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
215 traps[ntraps].tr_flags = ISFOUND;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
216 traps[ntraps].tr_show = FIRETRAP;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
217 traps[ntraps].tr_pos = fpos;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
218 ntraps++;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
219
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
220 if (rp != NULL)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
221 rp->r_flags &= ~ISDARK;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
222 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
223 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
224 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
225 obj->o_pos = fpos;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
226 add_obj(item, fpos.y, fpos.x);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
227 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
228
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
229 if (rp != NULL &&
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
230 (!(rp->r_flags & ISDARK) ||
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
231 (rp->r_flags & HASFIRE)))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
232 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
233 light(&hero);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
234 mvwaddch(cw, hero.y, hero.x, PLAYER);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
235 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
236 return;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
237 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
238
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
239 /* get here only if there isn't a place to put it */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
240
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
241 if (pr)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
242 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
243 if (cansee(obj->o_pos.y, obj->o_pos.x))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
244 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
245 if (obj->o_type == WEAPON)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
246 addmsg("The %s", weaps[obj->o_which].w_name);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
247 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
248 addmsg(inv_name(obj, LOWERCASE));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
249
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
250 msg(" vanishes as it hits the ground.");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
251 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
252 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
253 discard(item);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
254 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
255
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
256 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
257 init_weapon()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
258 Set up the initial goodies for a weapon
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
259 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
260
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
261 void
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
262 init_weapon(struct object *weap, int type)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
263 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
264 struct init_weps *iwp = &weaps[type];
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
265
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
266 weap->o_damage = iwp->w_dam;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
267 weap->o_hurldmg = iwp->w_hrl;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
268 weap->o_launch = iwp->w_launch;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
269 weap->o_flags = iwp->w_flags;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
270 weap->o_weight = iwp->w_wght;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
271
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
272 if (weap->o_flags & ISMANY)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
273 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
274 weap->o_count = rnd(8) + 8;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
275 weap->o_group = ++group;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
276 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
277 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
278 weap->o_count = 1;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
279 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
280
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
281 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
282 hit_monster()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
283 does the missile hit the target?
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
284 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
285
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
286 int
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
287 hit_monster(int y, int x, struct object *weapon, struct thing *thrower)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
288 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
289 struct linked_list *mon;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
290 coord target;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
291
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
292 target.y = y;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
293 target.x = x;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
294
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
295 if (thrower == &player)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
296 return(fight(&target, weapon, THROWN));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
297
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
298 if (ce(target, hero))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
299 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
300 if (good_monster(*thrower))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
301 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
302 if (on(*thrower, ISFAMILIAR))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
303 msg("Please get out of the way, Master! I nearly hit you.");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
304 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
305 msg("Get out of the way %s!", whoami);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
306
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
307 return(FALSE);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
308 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
309
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
310 return(attack(thrower, weapon, THROWN));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
311 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
312
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
313 if ((mon = find_mons(y, x)) != NULL)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
314 return(mon_mon_attack(thrower, mon, weapon, THROWN));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
315 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
316 return(FALSE);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
317 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
318
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
319
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
320 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
321 num()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
322 Figure out the plus number for armor/weapons
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
323 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
324
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
325 char *
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
326 num(int n1, int n2, char *buf)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
327 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
328 if (buf == NULL)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
329 return("UltraRogue Error #104");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
330
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
331 if (n1 == 0 && n2 == 0)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
332 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
333 strcpy(buf,"+0");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
334 return(buf);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
335 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
336
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
337 if (n2 == 0)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
338 sprintf(buf, "%s%d", n1 < 0 ? "" : "+", n1);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
339 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
340 sprintf(buf, "%s%d, %s%d", n1 < 0 ? "" : "+",
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
341 n1, n2 < 0 ? "" : "+", n2);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
342
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
343 return(buf);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
344 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
345
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
346 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
347 wield()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
348 Pull out a certain weapon
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
349 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
350
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
351 void
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
352 wield(void)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
353 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
354 struct linked_list *item;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
355 struct object *obj, *oweapon;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
356
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
357 oweapon = cur_weapon;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
358
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
359 if (!dropcheck(cur_weapon))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
360 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
361 cur_weapon = oweapon;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
362 return;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
363 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
364
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
365 cur_weapon = oweapon;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
366
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
367 if ((item = get_item("wield", WEAPON)) == NULL)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
368 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
369 after = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
370 return;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
371 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
372
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
373 obj = OBJPTR(item);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
374
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
375 if (is_current(obj))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
376 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
377 after = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
378 return;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
379 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
380
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
381 wield_ok(&player, obj, TRUE);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
382
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
383 msg("You are now wielding %s.", inv_name(obj, LOWERCASE));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
384
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
385 cur_weapon = obj;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
386 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
387
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
388 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
389 fallpos()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
390 pick a random position around the given (y, x) coordinates
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
391 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
392
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
393 int
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
394 fallpos(coord pos, coord *newpos) /*ARGSUSED*/
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
395 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
396 int y, x, cnt;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
397 coord places[9];
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
398
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
399 cnt = 0;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
400
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
401 /* look for all the places that qualify */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
402
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
403 for (y = pos.y - 1; y <= pos.y + 1; y++)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
404 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
405 for (x = pos.x - 1; x <= pos.x + 1; x++)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
406 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
407 switch(CCHAR(mvwinch(stdscr,y,x)))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
408 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
409 case GOLD:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
410 case POTION:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
411 case SCROLL:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
412 case FOOD:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
413 case WEAPON:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
414 case ARMOR:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
415 case RING:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
416 case STICK:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
417 case FLOOR:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
418 case PASSAGE:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
419 case ARTIFACT:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
420 places[cnt].y = y;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
421 places[cnt].x = x;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
422 cnt++;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
423 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
424 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
425 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
426
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
427 /* now, pick one of the places, if there are any */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
428
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
429 if (cnt > 0)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
430 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
431 int which = rnd(cnt);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
432
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
433 newpos->y = places[which].y;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
434 newpos->x = places[which].x;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
435
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
436 debug("Dropping object at %d, %d", newpos->y, newpos->x);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
437 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
438
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
439 return(cnt);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
440 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
441
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
442 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
443 wield_ok()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
444 enforce player class weapons restrictions
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
445 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
446
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
447 int
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
448 wield_ok(struct thing *wieldee, struct object *obj, int print_message)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
449 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
450 int ret_val = TRUE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
451 int class_type = wieldee->t_ctype;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
452
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
453 if (obj->o_type != WEAPON)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
454 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
455 ret_val = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
456 return(ret_val);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
457 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
458 else
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
459 switch (class_type)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
460 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
461 case C_MAGICIAN: /* need one hand free */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
462 case C_ILLUSION:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
463 if (obj->o_flags & ISTWOH)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
464 ret_val = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
465 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
466
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
467 case C_THIEF: /* need portable weapon */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
468 case C_ASSASIN:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
469 case C_NINJA:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
470 if (obj->o_flags & ISTWOH)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
471 ret_val = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
472 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
473
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
474 case C_CLERIC: /* No sharp weapons */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
475 if (obj->o_flags & ISSHARP)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
476 ret_val = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
477 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
478
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
479 case C_DRUID: /* No non-silver metal weapons */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
480 if (obj->o_flags & ISMETAL && !(obj->o_flags & ISSILVER))
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
481 ret_val = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
482 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
483
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
484 case C_PALADIN: /* must wield sharp stuff */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
485 if ((obj->o_flags & ISSHARP) == FALSE)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
486 ret_val = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
487 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
488
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
489 case C_FIGHTER: /* wield anything */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
490 case C_RANGER:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
491 case C_MONSTER:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
492 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
493
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
494 default: /* Unknown class */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
495 debug("Unknown class %d.", class_type);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
496 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
497 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
498
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
499 if (itemweight(obj) > 18 * pstats.s_str)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
500 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
501 if (wieldee == &player && print_message == TRUE)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
502 msg("That is too heavy for you to swing effectively!");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
503
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
504 ret_val = FALSE;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
505 return(ret_val);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
506 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
507
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
508 if (ret_val == FALSE && print_message == MESSAGE)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
509 switch (class_type)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
510 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
511 case C_MAGICIAN:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
512 case C_ILLUSION:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
513 msg("You'll find it hard to cast spells while wielding that!");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
514 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
515
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
516 case C_THIEF:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
517 case C_ASSASIN:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
518 case C_NINJA:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
519 msg("Don't expect to backstab anyone while wielding that!");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
520 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
521
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
522 case C_CLERIC:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
523 case C_DRUID:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
524 case C_PALADIN:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
525 msg("Your god strongly disapproves of your wielding that!");
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
526 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
527
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
528 case C_FIGHTER:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
529 case C_RANGER:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
530 case C_MONSTER:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
531 break;
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
532 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
533
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
534 return(ret_val);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
535 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
536
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
537 /*
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
538 shoot_ok()
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
539 returns true if it is ok for type to shoot over ch
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
540 */
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
541
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
542 int
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
543 shoot_ok(int ch)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
544 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
545 switch(ch)
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
546 {
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
547 case ' ':
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
548 case '|':
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
549 case '-':
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
550 case SECRETDOOR:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
551 return(FALSE);
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
552
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
553 default:
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
554 return(!isalpha(ch));
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
555 }
c495a4f288c6 Import UltraRogue from the Roguelike Restoration Project (r1490)
John "Elwin" Edwards
parents:
diff changeset
556 }