forked from dungeons-of-moria/icmoria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magic.c
311 lines (255 loc) · 7.84 KB
/
magic.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
/* magic.c */
/**/
#include "imoria.h"
#include "dungeon.h"
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
void c__mage_spell_effects(integer effect)
{
/*{ Spells... }*/
integer i2,dir;
integer dumy,y_dumy,x_dumy;
y_dumy = char_row;
x_dumy = char_col;
switch (effect+1) {
case 1 : /*{ Magic Missile }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
fire_bolt(0,dir,char_row,char_col,
damroll("2d6")+1,"Magic Missile");
}
break;
case 2 : /*{ Detect Monster }*/
detect_creatures(c_monster);
break;
case 3 : /*{ Phase Door }*/
teleport(10);
break;
case 4 : /*{ Light }*/
light_area(char_row,char_col);
break;
case 5 : /*{ Cure Light }*/
hp_player(damroll("4d4"),"a magic spell.");
break;
case 6 : /*{ Find Hidden Traps/Door }*/
detect_sdoor();
detect_trap();
break;
case 7 : /*{ Stinking Cloud }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
fire_ball(c_gas,dir,char_row,char_col,9,"Stinking Cloud");
}
break;
case 8 : /*{ Confuse Monster }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
zap_monster(dir,char_row,char_col,0,c_confuse);
}
break;
case 9 : /*{ Lightning Bolt }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
fire_bolt(c_lightning,dir,char_row,char_col,
damroll("3d8")+1,"Lightning Bolt");
}
break;
case 10 : /*{ Trap/Door Destruction }*/
td_destroy();
break;
case 11 : /*{ Sleep I }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
zap_monster(dir,char_row,char_col,0,c_sleep);
}
break;
case 12 : /*{ Cure Poison }*/
cure_me(&(py.flags.poisoned));
break;
case 13 : /*{ Shadow Door }*/
teleport(py.misc.lev*5);
break;
case 14 : /*{ Remove Curse }*/
for (i2 = Equipment_min ; i2 <= EQUIP_MAX-1 ; i2++) {
//with equipment[i2] do;
equipment[i2].flags &= 0x7FFFFFFF;
}
break;
case 15 : /*{ Frost Bolt }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
fire_bolt(c_cold,dir,char_row,char_col,
damroll("4d8")+1,"Frost Bolt");
}
break;
case 16 : /*{ Create Food }*/
create_food(7,7,0,0,0);
break;
case 17 : /*{ Infravision }*/
py.flags.tim_infra += 50 + randint(50);
break;
case 18 : /*{ Invisibility }*/
py.flags.temp_stealth += randint(15)+10;
break;
case 19 : /*{ Turn Stone to Mud }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
wall_to_mud(dir,char_row,char_col);
}
break;
case 20 : /*{ Recharge Item I }*/
recharge(20);
break;
case 21 : /*{ Sleep II }*/
sleep_monsters1(char_row,char_col);
break;
case 22 : /*{ Phantasmal Force }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
fire_bolt(c_illusion,dir,char_row,char_col,damroll("8d4"),
"phantasmal force");
}
break;
case 23 : /*{ Polymorph Other }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
poly_monster(dir,char_row,char_col);
}
break;
case 24 : /*{ Identify }*/
ident_spell();
break;
case 25 : /*{ Ring of Frost }*/
py.flags.ring_ice += 3 + randint(3);
break;
case 26 : /*{ Sleep III }*/
zap_area(0,0,c_sleep);
break;
case 27 : /*{ Hold Monster }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
zap_monster(dir,char_row,char_col,4+randint(4),c_hold);
}
break;
case 28 : /*{ Fire Bolt }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
fire_bolt(c_fire,dir,char_row,char_col,
damroll("6d8")+1,"Fire Bolt");
}
break;
case 29 : /*{ Slow Creature }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
zap_monster(dir,char_row,char_col,-1,c_speed);
}
break;
case 30 : /*{ Protection From Magic }*/
py.flags.magic_prot += 20 + randint(20);
break;
case 31 : /*{ Frost Ball }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
fire_ball(c_cold,dir,char_row,char_col,40,"Frost Ball");
}
break;
case 32 : /*{ Death Spell }*/
zap_area(0,py.misc.lev div 2+damroll("4d8"),c_drain);
break;
case 33 : /*{ Ring of Fire }*/
py.flags.ring_fire += 3 + randint(3);
break;
case 34 : /*{ Recharge Item II }*/
recharge(50);
break;
case 35 : /*{ Teleport Other }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
teleport_monster(dir,char_row,char_col);
}
break;
case 36 : /*{ Haste Self }*/
PF.fast += randint(20) + py.misc.lev;
break;
case 37 : /*{ Fire Ball }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
fire_ball(c_fire,dir,char_row,char_col,59,"Fire Ball");
}
break;
case 38 : /*{ Power Word: Destruction }*/
destroy_area(char_row,char_col);
break;
case 39 : /*{ Power Word: Kill }*/
if (d__get_dir("Which direction?",&dir,&dumy,&y_dumy,&x_dumy)) {
fire_bolt(0,dir,char_row,char_col,
damroll("24d8"),"Black Bolt");
}
break;
case 40 : /*{ Genocide }*/
genocide();
break;
default:
break;
}
/*{ End of spells... }*/
};
//////////////////////////////////////////////////////////////////////
void cast()
{
/*{ Throw a magic spell -RAK- }*/
treas_ptr i1,item_ptr;
integer choice,chance,i2;
char trash_char;
boolean redraw;
obj_set magic_books = {Magic_Book, 0};
reset_flag = true;
if (py.flags.blind > 0) {
msg_print("You can't see to read your spell book!");
} else if (no_light()) {
msg_print("You have no light to read by.");
} else if (py.flags.confused > 0) {
msg_print("You are too confused...");
} else if (class[py.misc.pclass].mspell) {
if (inven_ctr > 0) {
if (find_range(magic_books,false,&i1,&i2)) {
redraw = false;
if (get_item(&item_ptr,"Use which spell-book?",&redraw,
i2,&trash_char,false,false)) {
if (cast_spell("Cast which spell?",item_ptr,
&choice,&chance,&redraw)) {
//with magic_spell[py.misc.pclass,choice] do;
reset_flag = false;
if (randint(100) < chance) {
msg_print("You failed to get the spell off!");
} else {
c__mage_spell_effects(choice);
if (!(reset_flag)) {
//with py.misc do;
PM.exp += magic_spell[PM.pclass][choice].sexp;
prt_experience();
magic_spell[PM.pclass][choice].sexp = 0;
}
}
//with py.misc do;
if (!(reset_flag)) {
if (magic_spell[PM.pclass][choice].smana > PM.cmana) {
msg_print("You faint from the effort!");
py.flags.paralysis =
randint(5*trunc(magic_spell[PM.pclass][choice].smana-PM.cmana));
PM.cmana = 0;
if (randint(3) == 1) {
/*{lower_stat == no sustain}*/
lower_stat(CON,"You have damaged your health!");
}
} else {
PM.cmana -= magic_spell[PM.pclass][choice].smana;
}
prt_mana();
}
} /* end if which spell */
} else {
if (redraw) {
draw_cave();
}
}
} else {
msg_print("But you are not carrying any spell-books!");
}
} else {
msg_print("But you are not carrying any spell-books!");
}
} else {
msg_print("You can't cast spells!");
}
};
/* END FILE magic.c */
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////