-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwands.c
191 lines (184 loc) · 4.49 KB
/
wands.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* wands.c: wand code
Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
This software may be copied and distributed for educational, research, and
not for profit purposes provided that this copyright and statement are
included in all such copies. */
#include "constant.h"
#include "config.h"
#include "types.h"
#include "externs.h"
#ifdef USG
#ifndef ATARIST_MWC
#include <string.h>
#endif
#else
#include <strings.h>
#endif
/* Wands for the aiming. */
void aim()
{
int32u i;
register int l, ident;
int item_val, j, k, chance, dir;
register inven_type *i_ptr;
register struct misc *m_ptr;
free_turn_flag = TRUE;
if (inven_ctr == 0)
msg_print("But you are not carrying anything.");
else if (!find_range(TV_WAND, TV_NEVER, &j, &k))
msg_print("You are not carrying any wands.");
else if (get_item(&item_val, "Aim which wand?", j, k))
{
i_ptr = &inventory[item_val];
free_turn_flag = FALSE;
if (get_dir(NULL, &dir))
{
if (py.flags.confused > 0)
{
msg_print("You are confused.");
do
{
dir = randint(9);
}
while (dir == 5);
}
ident = FALSE;
m_ptr = &py.misc;
chance = m_ptr->save + stat_adj(A_INT) - (int)i_ptr->level
+ (class_level_adj[m_ptr->pclass][CLA_DEVICE] * m_ptr->lev / 3);
if (py.flags.confused > 0)
chance = chance / 2;
if (chance <= 0) chance = 1;
if (randint(chance) < USE_DEVICE)
msg_print("You failed to use the wand properly.");
else if (i_ptr->p1 > 0)
{
i = i_ptr->flags;
(i_ptr->p1)--;
while (i != 0)
{
j = bit_pos(&i) + 1;
k = char_row;
l = char_col;
/* Wands */
switch(j)
{
case 1:
msg_print("A line of blue shimmering light appears.");
light_line(dir, char_row, char_col);
ident = TRUE;
break;
case 2:
fire_bolt(GF_LIGHTNING, dir, k, l, damroll(4, 8),
spell_names[8]);
ident = TRUE;
break;
case 3:
fire_bolt(GF_FROST, dir, k, l, damroll(6, 8),
spell_names[14]);
ident = TRUE;
break;
case 4:
fire_bolt(GF_FIRE, dir, k, l, damroll(9, 8),
spell_names[22]);
ident = TRUE;
break;
case 5:
ident = wall_to_mud(dir, k, l);
break;
case 6:
ident = poly_monster(dir, k, l);
break;
case 7:
ident = hp_monster(dir, k, l, -damroll(4, 6));
break;
case 8:
ident = speed_monster(dir, k, l, 1);
break;
case 9:
ident = speed_monster(dir, k, l, -1);
break;
case 10:
ident = confuse_monster(dir, k, l);
break;
case 11:
ident = sleep_monster(dir, k, l);
break;
case 12:
ident = drain_life(dir, k, l);
break;
case 13:
ident = td_destroy2(dir, k, l);
break;
case 14:
fire_bolt(GF_MAGIC_MISSILE, dir, k, l, damroll(2, 6),
spell_names[0]);
ident = TRUE;
break;
case 15:
ident = build_wall(dir, k, l);
break;
case 16:
ident = clone_monster(dir, k, l);
break;
case 17:
ident = teleport_monster(dir, k, l);
break;
case 18:
ident = disarm_all(dir, k, l);
break;
case 19:
fire_ball(GF_LIGHTNING, dir, k, l, 32, "Lightning Ball");
ident = TRUE;
break;
case 20:
fire_ball(GF_FROST, dir, k, l, 48, "Cold Ball");
ident = TRUE;
break;
case 21:
fire_ball(GF_FIRE, dir, k, l, 72, spell_names[28]);
ident = TRUE;
break;
case 22:
fire_ball(GF_POISON_GAS, dir, k, l, 12, spell_names[6]);
ident = TRUE;
break;
case 23:
fire_ball(GF_ACID, dir, k, l, 60, "Acid Ball");
ident = TRUE;
break;
case 24:
i = 1L << (randint(23) - 1);
break;
default:
msg_print("Internal error in wands()");
break;
}
/* End of Wands. */
}
if (ident)
{
if (!known1_p(i_ptr))
{
m_ptr = &py.misc;
/* round half-way case up */
m_ptr->exp += (i_ptr->level +(m_ptr->lev >> 1)) /
m_ptr->lev;
prt_experience();
identify(&item_val);
i_ptr = &inventory[item_val];
}
}
else if (!known1_p(i_ptr))
sample (i_ptr);
desc_charges(item_val);
}
else
{
msg_print("The wand has no charges left.");
if (!known2_p(i_ptr))
add_inscribe(i_ptr, ID_EMPTY);
}
}
}
}