1 /* $Id$ */
2 /* File: cmd5.c */
3
4 /* Purpose: Spell/Prayer commands */
5
6 /*
7 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 *
9 * This software may be copied and distributed for educational, research, and
10 * not for profit purposes provided that this copyright and statement are
11 * included in all such copies.
12 */
13
14 #define SERVER
15
16 #include "angband.h"
17
18 /* Max radius of antimagic field generated by a monster */
19 #define MONSTER_ANTIDIS 8
20
21 /* Chance of weps/armors got discounted when enchanting via spells,
22 * in percent. [40] */
23 #define ENCHANT_DISCOUNT_CHANCE 40
24
25
26 #if 0 /* currently disabled because it's unused, just to kill compiler warning */
27 /*
28 * Return the skill associated with the realm
29 */
30 static int find_realm_skill(int realm)
31 {
32 switch (realm)
33 {
34 case REALM_MAGERY:
35 return SKILL_MAGERY;
36 case REALM_PRAYER:
37 return SKILL_PRAY;
38 case REALM_SORCERY:
39 return SKILL_SORCERY;
40 case REALM_SHADOW:
41 return SKILL_SHADOW;
42 case REALM_HUNT:
43 // return SKILL_ARCHERY;
44 return SKILL_HUNTING;
45 case REALM_FIGHTING:
46 // return SKILL_MASTERY;
47 return SKILL_TECHNIQUE;
48 // case REALM_PSI:
49 // return SKILL_;
50 };
51 return 0;
52 }
53
54 /*
55 * Returns spell chance of failure for spell -RAK-
56 */
57 static s16b spell_chance(int Ind, int realm, magic_type *s_ptr)
58 {
59 player_type *p_ptr = Players[Ind];
60
61 int chance, minfail, minminfail;
62
63 /* Extract the base spell failure rate */
64 chance = s_ptr->sfail;
65
66 /* Reduce failure rate by "effective" level adjustment */
67 minfail = 5;
68 chance -= 3 * (get_skill(p_ptr, find_realm_skill(realm)) - s_ptr->slevel);
69
70 /* Reduce failure rate by INT/WIS adjustment */
71 //chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[magic_info[realm].spell_stat]] - 1);
72
73 /* Not enough mana to cast */
74 if (s_ptr->smana > p_ptr->csp)
75 {
76 /* Hack -- Since at the moment casting spells without enough mana*/
77 /* is impossible, I'm taking this out, as it confuses people. */
78 /* chance += 5 * (s_ptr->smana - p_ptr->csp); */
79 }
80
81 /* Extract the minimum failure rate */
82 //minfail = adj_mag_fail[p_ptr->stat_ind[magic_info[realm].spell_stat]];
83
84 /* Non mage/sorceror/priest characters never get too good */
85 #if 0 // NEED to find a good way to do that without class
86 if ((p_ptr->pclass != CLASS_MAGE) && (p_ptr->pclass != CLASS_PRIEST) && (p_ptr->pclass != CLASS_SORCERER))
87 {
88 if (minfail < 5) minfail = 5;
89 }
90 #else
91 minminfail = 8 - get_skill_scale(p_ptr, find_realm_skill(realm), 5)
92 - get_skill_scale(p_ptr, SKILL_MAGIC, 3);
93 if (minminfail > 5) minminfail = 5;
94
95 if (minfail < minminfail) minfail = minminfail;
96
97 #endif
98 /* Hack -- Priest prayer penalty for "edged" weapons -DGK */
99 if ((realm == REALM_PRAYER) && (p_ptr->icky_wield)) chance += 25;
100
101 /* Minimum failure rate */
102 if (chance < minfail) chance = minfail;
103
104 /* Stunning makes spells harder */
105 if (p_ptr->stun > 50) chance += 25;
106 else if (p_ptr->stun) chance += 15;
107
108 /* Always a 5 percent chance of working */
109 if (chance > 95) chance = 95;
110
111 /* Return the chance */
112 return (chance);
113 }
114 #endif
115
116 /* ok, it's hacked :) */
117 /* of course, you can optimize it further by bandling
118 * monsters and players into one loop.. - Jir - */
check_antimagic(int Ind,int percentage)119 bool check_antimagic(int Ind, int percentage) {
120 player_type *p_ptr = Players[Ind];
121 worldpos *wpos = &p_ptr->wpos;
122 monster_type *m_ptr;
123 monster_race *r_ptr;
124 cave_type **zcave;
125 int i, x, y, x2 = p_ptr->px, y2 = p_ptr->py, m_idx;
126 int dis, antichance, antidis;
127
128 if (!percentage || !(zcave = getcave(wpos))) return(FALSE);
129
130 for (i = 1; i <= NumPlayers; i++) {
131 player_type *q_ptr = Players[i];
132
133 /* Skip disconnected players */
134 if (q_ptr->conn == NOT_CONNECTED) continue;
135
136 /* Skip players not on this depth */
137 if (!inarea(&q_ptr->wpos, &p_ptr->wpos)) continue;
138
139 /* Compute distance */
140 if (q_ptr->antimagic_dis < distance(y2, x2, q_ptr->py, q_ptr->px))
141 continue;
142
143 antichance = q_ptr->antimagic;
144
145 if (i != Ind) antichance -= p_ptr->lev >> 1;
146
147 if (antichance > ANTIMAGIC_CAP) antichance = ANTIMAGIC_CAP;/* AM cap */
148
149 /* Reduction for party */
150 if ((i != Ind) && player_in_party(p_ptr->party, i))
151 antichance >>= 2; /* was >>= 1 */
152
153 /* Got disrupted ? */
154 if (magik((antichance * percentage) / 100)) {
155 if (i == Ind) msg_format(Ind, "\377%cYour own anti-magic field disrupts your attempts.", COLOUR_AM_OWN);
156 else msg_format(Ind, "\377%c%s's anti-magic field disrupts your attempts.", COLOUR_AM_PLY, q_ptr->name);
157 return TRUE;
158 }
159 }
160
161 /* Scan the maximal area of radius "MONSTER_ANTIDIS" */
162 dis = 1;
163 for (i = 1; i <= tdi[MONSTER_ANTIDIS]; i++) {
164 if (i == tdi[dis]) dis++;
165
166 y = y2 + tdy[i];
167 x = x2 + tdx[i];
168
169 /* Ignore "illegal" locations */
170 if (!in_bounds2(wpos, y, x)) continue;
171
172 if ((m_idx = zcave[y][x].m_idx) <= 0) continue;
173
174 m_ptr = &m_list[m_idx]; // pfft, bad design
175
176 /* dont use removed monsters */
177 if (!m_ptr->r_idx) continue;
178
179 r_ptr = race_inf(m_ptr);
180
181 if (!(r_ptr->flags7 & RF7_DISBELIEVE)) continue;
182
183 antichance = r_ptr->level / 2 + 30;
184 antidis = r_ptr->level / 15 + 3;
185
186 if (dis > antidis) continue;
187 if (antichance > ANTIMAGIC_CAP) antichance = ANTIMAGIC_CAP; /* AM cap */
188
189 /* Got disrupted ? */
190 if (magik((antichance * percentage) / 100)) {
191 if (p_ptr->mon_vis[m_idx]) {
192 char m_name[MNAME_LEN];
193 monster_desc(Ind, m_name, m_idx, 0);
194 msg_format(Ind, "\377%c%^s's anti-magic field disrupts your attempts.", COLOUR_AM_MON, m_name);
195 } else {
196 msg_format(Ind, "\377%cAn anti-magic field disrupts your attempts.", COLOUR_AM_MON);
197 }
198 return TRUE;
199 }
200 }
201
202 /* Assume no antimagic */
203 return FALSE;
204 }
205
206 #if 0 /* not used? - mikaelh */
207 /*
208 * Brand the current weapon
209 */
210 static void brand_weapon(int Ind) {
211 player_type *p_ptr = Players[Ind];
212 object_type *o_ptr;
213 o_ptr = &p_ptr->inventory[INVEN_WIELD];
214
215 /* you can never modify artifacts / ego-items */
216 /* you can never modify broken / cursed items */
217 if ((o_ptr->k_idx) &&
218 (!artifact_p(o_ptr)) && (!ego_item_p(o_ptr)) &&
219 (!broken_p(o_ptr)) && (!cursed_p(o_ptr)))
220 {
221 cptr act = NULL;
222
223 char o_name[ONAME_LEN];
224
225 if (rand_int(100) < 25) {
226 act = "is covered in a fiery shield!";
227 o_ptr->name2 = EGO_BRAND_FIRE;
228 } else {
229 act = "glows deep, icy blue!";
230 o_ptr->name2 = EGO_BRAND_COLD;
231 }
232
233 object_desc(Ind, o_name, o_ptr, FALSE, 0);
234
235 msg_format(Ind, "Your %s %s", o_name, act);
236
237 enchant(Ind, o_ptr, rand_int(3) + 4, ENCH_TOHIT | ENCH_TODAM);
238
239 /* Hack -- you don't sell the wep blessed by your god, do you? :) */
240 o_ptr->discount = 100;
241 } else
242 msg_print(Ind, "The Branding failed.");
243 }
244 #endif // 0
245
246 /*
247 * Use a ghostly ability. --KLJ--
248 */
do_cmd_ghost_power(int Ind,int ability)249 void do_cmd_ghost_power(int Ind, int ability) {
250 player_type *p_ptr = Players[Ind];
251 magic_type *s_ptr = &ghost_spells[ability];
252 int plev = p_ptr->lev;
253 int i, j = 0;
254
255 /* Check for ghost-ness */
256 if (!p_ptr->ghost) return;
257
258 /* Must not be confused */
259 if (p_ptr->confused) {
260 /* Message */
261 msg_print(Ind, "You are too confused!");
262 return;
263 }
264
265 /* Check spells */
266 for (i = 0; i < 64; i++) {
267 s_ptr = &ghost_spells[i];
268
269 /* Check for existence */
270 if (s_ptr->slevel >= 99) continue;
271
272 /* Next spell */
273 if (j++ == ability) break;
274 }
275
276 /* Check for level */
277 if (s_ptr->slevel > plev) {
278 /* Message */
279 msg_print(Ind, "You aren't powerful enough to use that ability.");
280 return;
281 }
282
283 /* S(he) is no longer afk */
284 un_afk_idle(Ind);
285
286 /* Spell effects */
287 switch(i) {
288 case 0:
289 teleport_player(Ind, 10, TRUE);
290 break;
291 case 1:
292 get_aim_dir(Ind);
293 p_ptr->current_spell = 1;
294 return;
295 case 2:
296 get_aim_dir(Ind);
297 p_ptr->current_spell = 2;
298 return;
299 case 3:
300 teleport_player(Ind, plev * 8, TRUE);
301 break;
302 case 4:
303 get_aim_dir(Ind);
304 p_ptr->current_spell = 4;
305 return;
306 case 5:
307 get_aim_dir(Ind);
308 p_ptr->current_spell = 5;
309 return;
310 case 6:
311 get_aim_dir(Ind);
312 p_ptr->current_spell = 6;
313 return;
314 }
315
316 /* Take a turn */
317 p_ptr->energy -= level_speed(&p_ptr->wpos);
318
319 take_xp_hit(Ind, s_ptr->slevel * s_ptr->smana,
320 "the strain of ghostly powers", TRUE, TRUE, TRUE);
321 }
322
323
324 /*
325 * Directional ghost ability
326 */
do_cmd_ghost_power_aux(int Ind,int dir)327 void do_cmd_ghost_power_aux(int Ind, int dir) {
328 player_type *p_ptr = Players[Ind];
329 magic_type *s_ptr;
330
331 /* Verify spell number */
332 if (p_ptr->current_spell < 0)
333 return;
334
335 /* Acquire spell pointer */
336 s_ptr = &ghost_spells[p_ptr->current_spell];
337
338 /* S(he) is no longer afk */
339 un_afk_idle(Ind);
340
341 /* We assume everything is still OK to cast */
342 switch (p_ptr->current_spell) {
343 case 1:
344 (void)fear_monster(Ind, dir, 10 + p_ptr->lev + get_skill_scale(p_ptr, SKILL_DEVICE, 50));
345 break;
346 case 2:
347 confuse_monster(Ind, dir, 10 + p_ptr->lev + get_skill_scale(p_ptr, SKILL_DEVICE, 50));
348 break;
349 case 4:
350 sprintf(p_ptr->attacker, " casts a nether bolt for");
351 fire_bolt_or_beam(Ind, p_ptr->lev * 2, GF_NETHER, dir, 50 + damroll(5, 5) + p_ptr->lev, p_ptr->attacker);
352 break;
353 case 5:
354 sprintf(p_ptr->attacker, " casts a nether ball for");
355 fire_ball(Ind, GF_NETHER, dir, 100 + 2 * p_ptr->lev, 2, p_ptr->attacker);
356 break;
357 case 6:
358 sprintf(p_ptr->attacker, " casts a darkness storm for");
359 fire_ball(Ind, GF_DARK, dir, p_ptr->lev * 5 + damroll(10, 10), 3, p_ptr->attacker);
360 break;
361 }
362
363 /* No more spell */
364 p_ptr->current_spell = -1;
365
366 /* Take a turn */
367 p_ptr->energy -= level_speed(&p_ptr->wpos);
368
369 take_xp_hit(Ind, s_ptr->slevel * s_ptr->smana,
370 "the strain of ghostly powers", TRUE, TRUE, TRUE);
371 }
372
373 /* old spinning, now unused. Added spin_attack() to replace it - C. Blue */
do_spin(int Ind)374 void do_spin(int Ind)
375 {
376 player_type *p_ptr = Players[Ind];
377 int d, x, y;
378
379 for (d = 1; d <= 9; d++) {
380 if (d == 5) continue;
381
382 x = p_ptr->px + ddx[d];
383 y = p_ptr->py + ddy[d];
384
385 if (!in_bounds(y, x)) continue;
386 py_attack(Ind, y, x, TRUE);
387 }
388 }
389
do_mimic_power(int Ind,int power,int dir)390 static void do_mimic_power(int Ind, int power, int dir) {
391 player_type *p_ptr = Players[Ind];
392 monster_race *r_ptr = &r_info[p_ptr->body_monster];
393 int rlev = (r_ptr->level + p_ptr->lev * 2 + 1) / 3;
394 int j, chance;
395 magic_type *s_ptr = &innate_powers[power];
396
397 // j = power;
398
399 p_ptr->energy -= level_speed(&p_ptr->wpos);
400
401 /* No magic */
402 if (p_ptr->anti_magic) {
403 msg_format(Ind, "\377%cYour anti-magic shell disrupts your attempt.", COLOUR_AM_OWN);
404 return;
405 }
406 if (p_ptr->antimagic) {
407 msg_format(Ind, "\377%cYour anti-magic field disrupts your attempt.", COLOUR_AM_OWN);
408 return;
409 }
410
411 /* Not when confused */
412 if (p_ptr->confused) {
413 msg_print(Ind, "You are too confused!");
414
415 /* Paranoia? Cease fire-till-kill! */
416 p_ptr->shooting_till_kill = FALSE;
417 p_ptr->shooty_till_kill = FALSE;
418 p_ptr->shoot_till_kill_mimic = 0;
419 return;
420 }
421
422 j = power / 32;
423
424 if (j < 0 || j > 3) {
425 msg_format(Ind, "SERVER ERROR: Tried to use a strange innate power(%d)!", power);
426 return;
427 }
428
429 /* confirm the power */
430 if (!(p_ptr->innate_spells[j] & (1L << (power - j * 32)))) {
431 msg_print(Ind, "You cannot use that power.");
432
433 /* Paranoia? Cease fire-till-kill! */
434 p_ptr->shooting_till_kill = FALSE;
435 p_ptr->shooty_till_kill = FALSE;
436 p_ptr->shoot_till_kill_mimic = 0;
437 return;
438 }
439
440 j = power;
441
442 /* Check mana */
443 if (s_ptr->smana > p_ptr->csp) {
444 msg_print(Ind, "You do not have enough mana to use this power.");
445 //msg_format(Ind, "You need %d mana to use this power.", s_ptr->smana);
446
447 /* Cease fire-till-kill! */
448 p_ptr->shooting_till_kill = FALSE;
449 p_ptr->shooty_till_kill = FALSE;
450 p_ptr->shoot_till_kill_mimic = 0;
451 return;
452 }
453
454 /* S(he) is no longer afk */
455 un_afk_idle(Ind);
456
457 #if 0 /* note: currently s_ptr->slevel is always 0 and there is no SKILL_MAGERY (0 too), so chance = sptr->sfail basically. */
458 /* Spell failure chance -- Hack, use the same stats as magery*/
459 // chance = spell_chance(Ind, REALM_MAGERY, s_ptr);
460 // chance = spell_chance(Ind, REALM_MIMIC, s_ptr);
461 #else /* instead use newly added adj_int_pow[] - C. Blue */
462 chance = (s_ptr->sfail * adj_int_pow[p_ptr->stat_ind[A_INT]]) / 100;
463 if (chance < 1) chance = 1; /* minimum fail chance */
464 if (chance > 99) chance = 99; /* maximum fail chance */
465 #endif
466
467 if (j >= 32 && interfere(Ind, cfg.spell_interfere)) return; /* mimic spells interference chance */
468
469 /* Failed spell */
470 if (rand_int(100) < chance) {
471 msg_print(Ind, "You failed to use the power!");
472 /* Clients > 4.4.5.10 can already send a dir != 0 here, for directed spells */
473 /* Clients >= 4.4.6.2 can also use '+' (dir==11) fallback to manual mode here: */
474 } else if (dir != 0 && dir != 11) {
475 p_ptr->current_spell = j;
476 do_mimic_power_aux(Ind, dir);
477 return;
478 }
479 /* Non-directed spells // old way of handling directed spells.
480 OR: New way of '+' fallback to manual mode! (dir==11) */
481 else {
482 /* Hack -- preserve current 'realm' */
483 p_ptr->current_realm = REALM_MIMIC;
484
485 /* 0-31 = RF4, 32-63 = RF5, 64-95 = RF6 */
486 switch(j) {
487
488
489 /* RF_4 ------------------------------------------------------------------------------------------------- */
490
491 //#define RF4_SHRIEK 0x00000001 /* Shriek for help */
492 case 0:
493 msg_print(Ind, "You emit a high-pitched humming noise.");
494 msg_format_near(Ind, "%s emits a high-pitched humming noise.", p_ptr->name);
495 #ifdef USE_SOUND_2010
496 /* allow us to annoy others ;) */
497 sound_near(Ind, "shriek", NULL, SFX_TYPE_MON_SPELL);
498 #endif
499 aggravate_monsters(Ind, -1);
500 break;
501 //#define RF4_UNMAGIC 0x00000002 /* Cancel player's timed spell */
502 case 1:
503 break;
504 //#define RF4_S_ANIMAL 0x00000004 /* Summon animals */
505 case 2:
506 break;
507 //#define RF4_ROCKET 0x00000008 /* TY: Rocket */
508 case 3:
509 //#define RF4_ARROW_1 0x00000010 /* Fire an arrow (light) */
510 case 4:
511 //#define RF4_ARROW_2 0x00000020 /* Fire a shot (heavy) */
512 case 5:
513 //#define RF4_ARROW_3 0x00000040 /* Fire a bolt (heavy) */
514 case 6:
515 //#define RF4_ARROW_4 0x00000080 /* Generic missile */
516 case 7:
517 //#define RF4_BR_ACID 0x00000100 /* Breathe Acid */
518 case 8:
519 //#define RF4_BR_ELEC 0x00000200 /* Breathe Elec */
520 case 9:
521 //#define RF4_BR_FIRE 0x00000400 /* Breathe Fire */
522 case 10:
523 //#define RF4_BR_COLD 0x00000800 /* Breathe Cold */
524 case 11:
525 //#define RF4_BR_POIS 0x00001000 /* Breathe Poison */
526 case 12:
527 //#define RF4_BR_NETH 0x00002000 /* Breathe Nether */
528 case 13:
529 //#define RF4_BR_LITE 0x00004000 /* Breathe Lite */
530 case 14:
531 //#define RF4_BR_DARK 0x00008000 /* Breathe Dark */
532 case 15:
533 //#define RF4_BR_CONF 0x00010000 /* Breathe Confusion */
534 case 16:
535 //#define RF4_BR_SOUN 0x00020000 /* Breathe Sound */
536 case 17:
537 //#define RF4_BR_CHAO 0x00040000 /* Breathe Chaos */
538 case 18:
539 //#define RF4_BR_DISE 0x00080000 /* Breathe Disenchant */
540 case 19:
541 //#define RF4_BR_NEXU 0x00100000 /* Breathe Nexus */
542 case 20:
543 //#define RF4_BR_TIME 0x00200000 /* Breathe Time */
544 case 21:
545 //#define RF4_BR_INER 0x00400000 /* Breathe Inertia */
546 case 22:
547 //#define RF4_BR_GRAV 0x00800000 /* Breathe Gravity */
548 case 23:
549 //#define RF4_BR_SHAR 0x01000000 /* Breathe Shards */
550 case 24:
551 //#define RF4_BR_PLAS 0x02000000 /* Breathe Plasma */
552 case 25:
553 //#define RF4_BR_WALL 0x04000000 /* Breathe Force */
554 case 26:
555 //#define RF4_BR_MANA 0x08000000 /* Breathe Mana */
556 case 27:
557 //#define RF4_BR_DISI 0x10000000 /* Breathe Disintegration */
558 case 28:
559 //#define RF4_BR_NUKE 0x20000000 /* TY: Toxic Breath */
560 case 29:
561 p_ptr->current_spell = j;
562 get_aim_dir(Ind);
563 return;
564 //#define RF4_MOAN 0x40000000 /* For Halloween event :) -C. Blue */
565 case 30:
566 break;
567 // #define RF4_BOULDER 0x80000000
568 case 31:
569 p_ptr->current_spell = j;
570 get_aim_dir(Ind);
571 return;
572
573
574 /* RF_5 ------------------------------------------------------------------------------------------------- */
575
576 // RF5_BA_ACID 0x00000001 /* Acid Ball */
577 case 32:
578 // RF5_BA_ELEC 0x00000002 /* Elec Ball */
579 case 33:
580 // RF5_BA_FIRE 0x00000004 /* Fire Ball */
581 case 34:
582 // RF5_BA_COLD 0x00000008 /* Cold Ball */
583 case 35:
584 // RF5_BA_POIS 0x00000010 /* Poison Ball */
585 case 36:
586 // RF5_BA_NETH 0x00000020 /* Nether Ball */
587 case 37:
588 // RF5_BA_WATE 0x00000040 /* Water Ball */
589 case 38:
590 // RF5_BA_MANA 0x00000080 /* Mana Storm */
591 case 39:
592 // RF5_BA_DARK 0x00000100 /* Darkness Storm */
593 case 40:
594 // RF5_DRAIN_MANA 0x00000200 /* Drain Mana */
595 case 41:
596 // msg_print(Ind, "Haha, you wish ... :)");
597 // RF5_MIND_BLAST 0x00000400 /* Blast Mind */
598 case 42:
599 // RF5_BRAIN_SMASH 0x00000800 /* Smash Brain */
600 case 43:
601 //#define RF5_CURSE 0x00001000 /* Cause Wound */
602 case 44:
603 p_ptr->current_spell = j;
604 get_aim_dir(Ind);
605 return;
606 //UNUSED
607 case 45:
608 break;
609 //#define RF5_BA_NUKE 0x00004000 /* TY: Nuke Ball */
610 case 46:
611 //#define RF5_BA_CHAO 0x00008000 /* Chaos Ball */
612 case 47:
613 // RF5_BO_ACID 0x00010000 /* Acid Bolt */
614 case 48:
615 // RF5_BO_ELEC 0x00020000 /* Elec Bolt (unused) */
616 case 49:
617 // RF5_BO_FIRE 0x00040000 /* Fire Bolt */
618 case 50:
619 // RF5_BO_COLD 0x00080000 /* Cold Bolt */
620 case 51:
621 // RF5_BO_POIS 0x00100000 /* Poison Bolt (unused) */
622 case 52:
623 // RF5_BO_NETH 0x00200000 /* Nether Bolt */
624 case 53:
625 // RF5_BO_WATE 0x00400000 /* Water Bolt */
626 case 54:
627 // RF5_BO_MANA 0x00800000 /* Mana Bolt */
628 case 55:
629 // RF5_BO_PLAS 0x01000000 /* Plasma Bolt */
630 case 56:
631 // RF5_BO_ICEE 0x02000000 /* Ice Bolt */
632 case 57:
633 // RF5_MISSILE 0x04000000 /* Magic Missile */
634 case 58:
635 // RF5_SCARE 0x08000000 /* Frighten Player */
636 case 59:
637 // RF5_BLIND 0x10000000 /* Blind Player */
638 case 60:
639 // RF5_CONF 0x20000000 /* Confuse Player */
640 case 61:
641 // RF5_SLOW 0x40000000 /* Slow Player */
642 case 62:
643 // RF5_HOLD 0x80000000 /* Paralyze Player */
644 case 63:
645 p_ptr->current_spell = j;
646 get_aim_dir(Ind);
647 return;
648
649
650 /* RF_6 ------------------------------------------------------------------------------------------------- */
651
652 // RF6_HASTE 0x00000001 /* Speed self */
653 case 64:
654 if(!p_ptr->fast) set_fast(Ind, 3 + rlev / 6 + randint(2 + rlev / 4), 10);
655 break;
656 // RF6_HAND_DOOM 0x00000002 /* Should we...? */ /* YES! */
657 case 65:
658 p_ptr->current_spell = j;
659 get_aim_dir(Ind);
660 return;
661 // RF6_HEAL 0x00000004 /* Heal self */
662 case 66:
663 if (p_ptr->lev >= 40) hp_player(Ind, ((rlev + 100) * (rlev + 100)) / 100);//225..400 (335 as eg avg)
664 else hp_player(Ind, ((rlev + 5) * (rlev + 30)) / 14);
665 //hp_player(Ind, rlev * 2);
666 break;
667 //#define RF6_S_ANIMALS 0x00000008 /* Summon animals */
668 case 67:
669 break;
670 // RF6_BLINK 0x00000010 /* Teleport Short */
671 case 68:
672 teleport_player(Ind, 10, TRUE);
673 break;
674 // RF6_TPORT 0x00000020 /* Teleport Long */
675 case 69:
676 teleport_player(Ind, 200, FALSE);
677 break;
678 //#define RF6_RAISE_DEAD 0x00000040 /* Raise Dead */
679 case 70:
680 break;
681 //#define RF6_S_BUG 0x00000080 /* Summon Software bug */
682 case 71:
683 break;
684 //#define RF6_TELE_TO 0x00000100 /* Move player to monster */
685 case 72:
686 // RF6_TELE_AWAY 0x00000200 /* Move player far away */
687 case 73:
688 p_ptr->current_spell = j;
689 get_aim_dir(Ind);
690 return;
691 // RF6_TELE_LEVEL 0x00000400 /* Move player vertically */
692 case 74:
693 //Disabled to sync with scrolls. teleport_player_level(Ind, FALSE); /* wrong way, but useful */
694 break;
695 //#define RF6_S_RNG 0x00000800 /* Summon RNG */
696 case 75:
697 break;
698 // RF6_DARKNESS 0x00001000 /* Create Darkness */
699 case 76:
700 unlite_area(Ind, 10, 3);
701 break;
702 // RF6_TRAPS 0x00002000 /* Create Traps */
703 case 77:
704 // RF6_FORGET 0x00004000 /* Cause amnesia */
705 case 78:
706 p_ptr->current_spell = j;
707 get_aim_dir(Ind);
708 return;
709 // msg_print(Ind, "Haha, you wish ... :)");
710 break;
711
712 //following flags are just RF6_S_... summoning spells */
713 default:
714 msg_format(Ind, "Bad innate power %d.", power);
715 break;
716 }
717 }
718
719 if (s_ptr->smana <= p_ptr->csp) {
720 /* Use some mana */
721 p_ptr->csp -= s_ptr->smana;
722 }
723 /* Over-exert the player */
724 else {
725 int oops = s_ptr->smana - p_ptr->csp;
726
727 /* No mana left */
728 p_ptr->csp = 0;
729 p_ptr->csp_frac = 0;
730
731 /* Message */
732 msg_print(Ind, "You faint from the effort!");
733
734 /* Hack -- bypass free action */
735 (void)set_paralyzed(Ind, p_ptr->paralyzed + randint(5 * oops + 1));
736
737 /* Damage CON (possibly permanently) */
738 if (rand_int(100) < 50) {
739 bool perm = (rand_int(100) < 25);
740
741 /* Message */
742 msg_print(Ind, "You have damaged your health!");
743
744 /* Reduce constitution */
745 (void)dec_stat(Ind, A_CON, 15 + randint(10), perm);
746 }
747
748 /* Cease fire-till-kill! */
749 p_ptr->shooting_till_kill = FALSE;
750 p_ptr->shooty_till_kill = FALSE;
751 p_ptr->shoot_till_kill_mimic = 0;
752 }
753
754 /* Display the spellpoints */
755 p_ptr->redraw |= (PR_MANA);
756 }
757
758 /*
759 * Finish casting a spell that required a direction --KLJ--
760 */
do_mimic_power_aux(int Ind,int dir)761 void do_mimic_power_aux(int Ind, int dir)
762 {
763 player_type *p_ptr = Players[Ind];
764 monster_race *r_ptr = &r_info[p_ptr->body_monster];
765 int rad;
766 int rlev = (r_ptr->level + p_ptr->lev * 2 + 1) / 3;
767 int rlev_bonus;
768 magic_type *s_ptr = &innate_powers[p_ptr->current_spell];
769
770 #if 1 /* Fire-till-kill */
771 int cs = p_ptr->current_spell;
772
773 if (p_ptr->shooting_till_kill) { /* we were shooting till kill last turn? */
774 p_ptr->shooting_till_kill = FALSE; /* well, gotta re-test for another success now.. */
775 if (dir == 5) p_ptr->shooty_till_kill = TRUE; /* so for now we are just ATTEMPTING to shoot till kill (assumed we have a monster for target) */
776 }
777 #endif
778
779 if (rlev > 50) rlev = 50;
780 rlev_bonus = (rlev * rlev) / 10; /* polynomially growing summand for bolt and ball spells */
781
782 /* Determine the radius of the blast */
783 rad = (r_ptr->flags2 & RF2_POWERFUL) ? 3 : 2;
784
785 if (!is_newer_than(&p_ptr->version, 4, 4, 5, 10, 0, 0)) {
786 /* Only fire in direction 5 if we have a target */
787 if ((dir == 5) && !target_okay(Ind)) {
788 /* Reset current spell */
789 p_ptr->current_spell = -1;
790 /* Done */
791 return;
792 }
793 }
794 //s_printf("dmpa dir,current_spell=%d,%d\n", dir, p_ptr->current_spell);
795
796 /* We assume that the spell can be cast, and so forth */
797 switch(p_ptr->current_spell) {
798 //#define RF4_ARROW_1 0x00000010 /* Fire arrow(s) (light) */
799 /* XXX: ARROW_1 gives extra-shot to the player; we'd better
800 * remove this 'innate' power? (see calc_body_bonus) */
801 case 3:
802 sprintf(p_ptr->attacker, " fires a rocket for");
803 msg_print(Ind, "You fire a rocket.");
804 fire_ball(Ind, GF_ROCKET, dir, ((p_ptr->mhp / 2) > 600) ? 600 : (p_ptr->mhp / 2), rad, p_ptr->attacker);
805 break;
806 case 4:
807 {
808 //cool stuff, needs some testing:
809 // int k;
810 // for (k = 0; k < 1 + rlev / 20; k++) {
811 sprintf(p_ptr->attacker, " fires an arrow for");
812 msg_print(Ind, "You fire an arrow.");
813 fire_bolt(Ind, GF_ARROW, dir, damroll(1 + rlev / 8, 6), p_ptr->attacker);
814 break;
815 // }
816 }
817 //#define RF4_ARROW_2 0x00000020 /* Fire shot (heavy) */
818 case 5:
819 sprintf(p_ptr->attacker, " fires a shot for");
820 msg_print(Ind, "You fire a shot.");
821 fire_bolt(Ind, GF_ARROW, dir, damroll(3 + rlev / 15, 6), p_ptr->attacker);
822 break;
823 //#define RF4_ARROW_3 0x00000040 /* Fire bolt (heavy) */
824 case 6:
825 sprintf(p_ptr->attacker, " fires a bolt for");
826 msg_print(Ind, "You fire a bolt.");
827 fire_bolt(Ind, GF_ARROW, dir, damroll(3 + rlev / 15, 6), p_ptr->attacker);
828 break;
829 //#define RF4_ARROW_4 0x00000080 /* Fire generic missile (heavy) */
830 case 7:
831 sprintf(p_ptr->attacker, " fires a missile for");
832 msg_print(Ind, "You fire a missile.");
833 fire_bolt(Ind, GF_MISSILE, dir, damroll(3 + rlev / 15, 6), p_ptr->attacker);
834 break;
835 //#define RF4_BR_ACID 0x00000100 /* Breathe Acid */
836 case 8:
837 sprintf(p_ptr->attacker, " breathes acid for");
838 msg_print(Ind, "You breathe acid.");
839 fire_ball(Ind, GF_ACID, dir, ((p_ptr->chp / 3) > 500) ? 500 : (p_ptr->chp / 3), rad, p_ptr->attacker);
840 break;
841 //#define RF4_BR_ELEC 0x00000200 /* Breathe Elec */
842 case 9:
843 sprintf(p_ptr->attacker, " breathes lightning for");
844 msg_print(Ind, "You breathe lightning.");
845 fire_ball(Ind, GF_ELEC, dir, ((p_ptr->chp / 3) > 500) ? 500 : (p_ptr->chp / 3), rad, p_ptr->attacker);
846 break;
847 //#define RF4_BR_FIRE 0x00000400 /* Breathe Fire */
848 case 10:
849 sprintf(p_ptr->attacker, " breathes fire for");
850 msg_print(Ind, "You breathe fire.");
851 fire_ball(Ind, GF_FIRE, dir, ((p_ptr->chp / 3) > 500) ? 500 : (p_ptr->chp / 3), rad, p_ptr->attacker);
852 break;
853 //#define RF4_BR_COLD 0x00000800 /* Breathe Cold */
854 case 11:
855 sprintf(p_ptr->attacker, " breathes frost for");
856 msg_print(Ind, "You breathe frost.");
857 fire_ball(Ind, GF_COLD, dir, ((p_ptr->chp / 3) > 500) ? 500 : (p_ptr->chp / 3), rad, p_ptr->attacker);
858 break;
859 //#define RF4_BR_POIS 0x00001000 /* Breathe Poison */
860 case 12:
861 sprintf(p_ptr->attacker, " breathes gas for");
862 msg_print(Ind, "You breathe gas.");
863 fire_ball(Ind, GF_POIS, dir, ((p_ptr->chp / 3) > 450) ? 450 : (p_ptr->chp / 3), rad, p_ptr->attacker);
864 break;
865 //#define RF4_BR_NETH 0x00002000 /* Breathe Nether */
866 case 13:
867 sprintf(p_ptr->attacker, " breathes nether for");
868 msg_print(Ind, "You breathe nether.");
869 fire_ball(Ind, GF_NETHER, dir, ((p_ptr->chp / 4) > 450) ? 450 : (p_ptr->chp / 4), rad, p_ptr->attacker);
870 break;
871 //#define RF4_BR_LITE 0x00004000 /* Breathe Lite */
872 case 14:
873 sprintf(p_ptr->attacker, " breathes light for");
874 msg_print(Ind, "You breathe light.");
875 fire_ball(Ind, GF_LITE, dir, ((p_ptr->chp / 4) > 400) ? 400 : (p_ptr->chp / 4), rad, p_ptr->attacker);
876 break;
877 //#define RF4_BR_DARK 0x00008000 /* Breathe Dark */
878 case 15:
879 sprintf(p_ptr->attacker, " breathes darkness for");
880 msg_print(Ind, "You breathe darkness.");
881 fire_ball(Ind, GF_DARK, dir, ((p_ptr->chp / 4) > 400) ? 400 : (p_ptr->chp / 4) , rad, p_ptr->attacker);
882 break;
883 //#define RF4_BR_CONF 0x00010000 /* Breathe Confusion */
884 case 16:
885 sprintf(p_ptr->attacker, " breathes confusion for");
886 msg_print(Ind, "You breathe confusion.");
887 fire_ball(Ind, GF_CONFUSION, dir, ((p_ptr->chp / 4) > 350) ? 350 : (p_ptr->chp / 4), rad, p_ptr->attacker);
888 break;
889 //#define RF4_BR_SOUN 0x00020000 /* Breathe Sound */
890 case 17:
891 sprintf(p_ptr->attacker, " breathes sound for");
892 msg_print(Ind, "You breathe sound.");
893 fire_ball(Ind, GF_SOUND, dir, ((p_ptr->chp / 4) > 350) ? 350 : (p_ptr->chp / 4), rad, p_ptr->attacker);
894 break;
895 //#define RF4_BR_CHAO 0x00040000 /* Breathe Chaos */
896 case 18:
897 sprintf(p_ptr->attacker, " breathes chaos for");
898 msg_print(Ind, "You breathe chaos.");
899 fire_ball(Ind, GF_CHAOS, dir, ((p_ptr->chp / 4) > 450) ? 450 : (p_ptr->chp / 4), rad, p_ptr->attacker);
900 break;
901 //#define RF4_BR_DISE 0x00080000 /* Breathe Disenchant */
902 case 19:
903 sprintf(p_ptr->attacker, " breathes disenchantment for");
904 msg_print(Ind, "You breathe disenchantment.");
905 fire_ball(Ind, GF_DISENCHANT, dir, ((p_ptr->chp / 4) > 400) ? 400 : (p_ptr->chp / 4), rad, p_ptr->attacker);
906 break;
907 //#define RF4_BR_NEXU 0x00100000 /* Breathe Nexus */
908 case 20:
909 sprintf(p_ptr->attacker, " breathes nexus for");
910 msg_print(Ind, "You breathe nexus.");
911 fire_ball(Ind, GF_NEXUS, dir, ((p_ptr->chp / 3) > 250) ? 250 : (p_ptr->chp / 3), rad, p_ptr->attacker);
912 break;
913 //#define RF4_BR_TIME 0x00200000 /* Breathe Time */
914 case 21:
915 sprintf(p_ptr->attacker, " breathes time for");
916 msg_print(Ind, "You breathe time.");
917 fire_ball(Ind, GF_TIME, dir, ((p_ptr->chp / 3) > 200) ? 200 : (p_ptr->chp / 3), rad, p_ptr->attacker);
918 break;
919 //#define RF4_BR_INER 0x00400000 /* Breathe Inertia */
920 case 22:
921 sprintf(p_ptr->attacker, " breathes inertia for");
922 msg_print(Ind, "You breathe inertia.");
923 fire_ball(Ind, GF_INERTIA, dir, ((p_ptr->chp / 4) > 200) ? 200 : (p_ptr->chp / 4) , rad, p_ptr->attacker);
924 break;
925 //#define RF4_BR_GRAV 0x00800000 /* Breathe Gravity */
926 case 23:
927 sprintf(p_ptr->attacker, " breathes gravity for");
928 msg_print(Ind, "You breathe gravity.");
929 fire_ball(Ind, GF_GRAVITY, dir, ((p_ptr->chp / 3) > 200) ? 200 : (p_ptr->chp / 3) , rad, p_ptr->attacker);
930 break;
931 //#define RF4_BR_SHAR 0x01000000 /* Breathe Shards */
932 case 24:
933 sprintf(p_ptr->attacker, " breathes shards for");
934 msg_print(Ind, "You breathe shards.");
935 fire_ball(Ind, GF_SHARDS, dir, ((p_ptr->chp / 4) > 350) ? 350 : (p_ptr->chp / 4) , rad, p_ptr->attacker);
936 break;
937 //#define RF4_BR_PLAS 0x02000000 /* Breathe Plasma */
938 case 25:
939 sprintf(p_ptr->attacker, " breathes plasma for");
940 msg_print(Ind, "You breathe plasma.");
941 fire_ball(Ind, GF_PLASMA, dir, ((p_ptr->chp / 4) > 150) ? 150 : (p_ptr->chp / 4) , rad, p_ptr->attacker);
942 break;
943 //#define RF4_BR_WALL 0x04000000 /* Breathe Force */
944 case 26:
945 sprintf(p_ptr->attacker, " breathes force for");
946 msg_print(Ind, "You breathe force.");
947 fire_ball(Ind, GF_FORCE, dir, ((p_ptr->chp / 4) > 200) ? 200 : (p_ptr->chp / 4) , rad, p_ptr->attacker);
948 break;
949 //#define RF4_BR_MANA 0x08000000 /* Breathe Mana */
950 case 27:
951 sprintf(p_ptr->attacker, " breathes mana for");
952 msg_print(Ind, "You breathe mana.");
953 fire_ball(Ind, GF_MANA, dir, ((p_ptr->chp / 3) > 250) ? 250 : (p_ptr->chp / 3) , rad, p_ptr->attacker);
954 break;
955 /* RF4_BR_DISI */
956 case 28:
957 sprintf(p_ptr->attacker, " breathes disintegration for");
958 msg_print(Ind, "You breathe disintegration.");
959 fire_ball(Ind, GF_DISINTEGRATE, dir,
960 ((p_ptr->chp / 3) > 300 ? 300 : (p_ptr->chp / 3)), rad, p_ptr->attacker);
961 break;
962 /* RF4_BR_NUKE */
963 case 29:
964 sprintf(p_ptr->attacker, " breathes toxic waste for");
965 msg_print(Ind, "You breathe toxic waste.");
966 fire_ball(Ind, GF_NUKE, dir,
967 ((p_ptr->chp / 3) > 450 ? 450 : (p_ptr->chp / 3)), rad, p_ptr->attacker);
968 break;
969 /* RF4_BOULDER */
970 case 31:
971 sprintf(p_ptr->attacker, " hurls a boulder at you for");
972 msg_print(Ind, "You hurl a boulder.");
973 fire_bolt(Ind, GF_ARROW, dir, damroll(1 + rlev / 7, 12), p_ptr->attacker);
974 break;
975
976 /* RF5 */
977
978 // RF5_BA_ACID 0x00000001 /* Acid Ball */
979 case 32:
980 sprintf(p_ptr->attacker, " casts an acid ball for");
981 msg_print(Ind, "You cast an acid ball.");
982 fire_ball(Ind, GF_ACID, dir, randint(rlev * 3) + 15 + rlev_bonus, rad, p_ptr->attacker);
983 break;
984 // RF5_BA_ELEC 0x00000002 /* Elec Ball */
985 case 33:
986 sprintf(p_ptr->attacker, " casts a lightning ball for");
987 msg_print(Ind, "You cast a lightning ball.");
988 fire_ball(Ind, GF_ELEC, dir, randint(rlev * 3 / 2) + 8 + rlev_bonus, rad, p_ptr->attacker);
989 break;
990 // RF5_BA_FIRE 0x00000004 /* Fire Ball */
991 case 34:
992 sprintf(p_ptr->attacker, " casts a fire ball for");
993 msg_print(Ind, "You cast a fire ball.");
994 fire_ball(Ind, GF_FIRE, dir, randint(rlev * 7 / 2) + 10 + rlev_bonus, rad, p_ptr->attacker);
995 break;
996 // RF5_BA_COLD 0x00000008 /* Cold Ball */
997 case 35:
998 sprintf(p_ptr->attacker, " casts a cold ball for");
999 msg_print(Ind, "You cast a cold ball.");
1000 fire_ball(Ind, GF_COLD, dir, randint(rlev * 2) + 10 + rlev_bonus, rad, p_ptr->attacker);
1001 break;
1002 // RF5_BA_POIS 0x00000010 /* Poison Ball */
1003 case 36:
1004 sprintf(p_ptr->attacker, " casts a stinking cloud for");
1005 msg_print(Ind, "You cast a stinking cloud.");
1006 // fire_ball(Ind, GF_POIS, dir, damroll(12, 2) , rad, p_ptr->attacker);
1007 fire_cloud(Ind, GF_POIS, dir, damroll(4 + rlev / 5, 2), rad, 4, 9, p_ptr->attacker);
1008 break;
1009 // RF5_BA_NETH 0x00000020 /* Nether Ball */
1010 case 37:
1011 sprintf(p_ptr->attacker, " casts a nether ball for");
1012 msg_print(Ind, "You cast a nether ball.");
1013 fire_ball(Ind, GF_NETHER, dir, 50 + damroll(10, 10) + rlev + rlev_bonus, rad, p_ptr->attacker);
1014 break;
1015 // RF5_BA_WATE 0x00000040 /* Water Ball */
1016 case 38:
1017 sprintf(p_ptr->attacker, " casts a water ball for");
1018 msg_print(Ind, "You cast a water ball.");
1019 fire_ball(Ind, GF_WATER, dir, randint(rlev * 5 / 2) + 50 + rlev_bonus / 2, rad, p_ptr->attacker);
1020 break;
1021 // RF5_BA_MANA 0x00000080 /* Mana Storm */
1022 case 39:
1023 sprintf(p_ptr->attacker, " invokes a mana storm for");
1024 msg_print(Ind, "You invoke a mana storm.");
1025 fire_ball(Ind, GF_MANA, dir, damroll(10, 10) + (rlev * 2) + rlev_bonus, rad, p_ptr->attacker);
1026 break;
1027 // RF5_BA_DARK 0x00000100 /* Darkness Storm */
1028 case 40:
1029 sprintf(p_ptr->attacker, " invokes a darkness storm for");
1030 msg_print(Ind, "You invoke a darkness storm.");
1031 fire_ball(Ind, GF_DARK, dir, damroll(10, 10) + (rlev * 2) + rlev_bonus, rad, p_ptr->attacker);
1032 break;
1033 // RF5_MIND_BLAST 0x00000400 /* Blast Mind */
1034 case 42:
1035 //sprintf(p_ptr->attacker, " tries to blast your mind for");
1036 sprintf(p_ptr->attacker, " focusses on your mind for");
1037 fire_bolt(Ind, GF_PSI, dir, damroll(3 + rlev / 5, 8), "");
1038 break;
1039 // RF5_BRAIN_SMASH 0x00000800 /* Smash Brain */
1040 case 43:
1041 sprintf(p_ptr->attacker, " focusses on your mind for");
1042 fire_bolt(Ind, GF_PSI, dir, damroll(5 + rlev / 4, 8), "");
1043 break;
1044 // RF5_CAUSE_1 0x00001000 /* Cause Wound */
1045 case 44:
1046 sprintf(p_ptr->attacker, " causes wounds for");
1047 msg_print(Ind, "You cause wounds.");
1048 fire_bolt(Ind, GF_MANA, dir, damroll(3 + rlev / 4, 8), p_ptr->attacker);
1049 break;
1050 // RF5_CAUSE_2 0x00002000 /* XXX */
1051 case 45:
1052 break;
1053 /* RF5_BA_NUKE */
1054 case 32+14:
1055 sprintf(p_ptr->attacker, " invokes radiation for");
1056 msg_print(Ind, "You invoke radiation.");
1057 fire_ball(Ind, GF_NUKE, dir, (rlev + damroll(10, 6)) + rlev_bonus, 2, p_ptr->attacker);
1058 break;
1059 /* RF5_BA_CHAO */
1060 case 32+15:
1061 sprintf(p_ptr->attacker, " invokes raw chaos for");
1062 msg_print(Ind, "You invoke raw chaos.");
1063 fire_ball(Ind, GF_CHAOS, dir, (rlev * 2) + damroll(10, 10) + rlev_bonus, 4, p_ptr->attacker);
1064 break;
1065 // RF5_BO_ACID 0x00010000 /* Acid Bolt */
1066 case 48:
1067 sprintf(p_ptr->attacker, " casts an acid bolt for");
1068 msg_print(Ind, "You cast an acid bolt.");
1069 fire_bolt(Ind, GF_ACID, dir, damroll(7, 8) + (rlev / 3) + rlev_bonus / 3, p_ptr->attacker);
1070 break;
1071 // RF5_BO_ELEC 0x00020000 /* Elec Bolt (unused) */
1072 case 49:
1073 sprintf(p_ptr->attacker, " casts a lightning bolt for");
1074 msg_print(Ind, "You cast a lightning bolt.");
1075 fire_bolt(Ind, GF_ELEC, dir, damroll(4, 8) + (rlev / 3) + rlev_bonus / 3, p_ptr->attacker);
1076 break;
1077 // RF5_BO_FIRE 0x00040000 /* Fire Bolt */
1078 case 50:
1079 sprintf(p_ptr->attacker, " casts a fire bolt for");
1080 msg_print(Ind, "You cast a fire bolt.");
1081 fire_bolt(Ind, GF_FIRE, dir, damroll(9, 8) + (rlev / 3) + rlev_bonus / 3, p_ptr->attacker);
1082 break;
1083 // RF5_BO_COLD 0x00080000 /* Cold Bolt */
1084 case 51:
1085 sprintf(p_ptr->attacker, " casts a frost bolt for");
1086 msg_print(Ind, "You cast a frost bolt.");
1087 fire_bolt(Ind, GF_COLD, dir, damroll(6, 8) + (rlev / 3) + rlev_bonus / 3, p_ptr->attacker);
1088 break;
1089 // RF5_BO_POIS 0x00100000 /* Poison Bolt (unused) */
1090 case 52:
1091 sprintf(p_ptr->attacker, " casts a poison bolt for");
1092 msg_print(Ind, "You cast a poison bolt.");
1093 fire_bolt(Ind, GF_POIS, dir, damroll(3, 8) + (rlev / 3) + rlev_bonus / 3, p_ptr->attacker);
1094 break;
1095 // RF5_BO_NETH 0x00200000 /* Nether Bolt */
1096 case 53:
1097 sprintf(p_ptr->attacker, " casts a nether bolt for");
1098 msg_print(Ind, "You cast a nether bolt.");
1099 fire_bolt(Ind, GF_NETHER, dir, 30 + damroll(5, 5) + (rlev * 3) / 2 + rlev_bonus / 3, p_ptr->attacker);
1100 break;
1101 // RF5_BO_WATE 0x00400000 /* Water Bolt */
1102 case 54:
1103 sprintf(p_ptr->attacker, " casts a water bolt for");
1104 msg_print(Ind, "You cast a water bolt.");
1105 fire_bolt(Ind, GF_WATER, dir, damroll(10, 10) + (rlev) + rlev_bonus / 3, p_ptr->attacker);
1106 break;
1107 // RF5_BO_MANA 0x00800000 /* Mana Bolt */
1108 case 55:
1109 sprintf(p_ptr->attacker, " casts a mana bolt for");
1110 msg_print(Ind, "You cast a mana bolt.");
1111 fire_bolt(Ind, GF_MANA, dir, randint(rlev * 7 / 4) + 50 + rlev_bonus / 3, p_ptr->attacker);
1112 break;
1113 // RF5_BO_PLAS 0x01000000 /* Plasma Bolt */
1114 case 56:
1115 sprintf(p_ptr->attacker, " casts a plasma bolt for");
1116 msg_print(Ind, "You cast a plasma bolt.");
1117 fire_bolt(Ind, GF_PLASMA, dir, 10 + damroll(8, 7) + (rlev) + rlev_bonus / 3, p_ptr->attacker);
1118 break;
1119 // RF5_BO_ICEE 0x02000000 /* Ice Bolt */
1120 case 57:
1121 sprintf(p_ptr->attacker, " casts an ice bolt for");
1122 msg_print(Ind, "You cast an ice bolt.");
1123 fire_bolt(Ind, GF_ICE, dir, damroll(6, 6) + (rlev) + rlev_bonus / 3, p_ptr->attacker);
1124 break;
1125 // RF5_MISSILE 0x04000000 /* Magic Missile */
1126 case 58:
1127 sprintf(p_ptr->attacker, " fires a magic missile for");
1128 msg_print(Ind, "You fire a magic missile.");
1129 fire_bolt(Ind, GF_MISSILE, dir, damroll(2, 6) + (rlev / 3) + rlev_bonus / 5, p_ptr->attacker);
1130 break;
1131 // RF5_SCARE 0x08000000 /* Frighten Player */
1132 case 59:
1133 sprintf(p_ptr->attacker, " focusses on your mind");
1134 fire_grid_bolt(Ind, GF_TURN_ALL, dir, damroll(2, 6) + (rlev / 3), p_ptr->attacker);
1135 break;
1136 // RF5_BLIND 0x10000000 /* Blind Player */
1137 case 60:
1138 sprintf(p_ptr->attacker, " focusses on your mind");
1139 fire_grid_bolt(Ind, GF_BLIND, dir, damroll(2, 6) + (rlev / 3), p_ptr->attacker);
1140 break;
1141 // RF5_CONF 0x20000000 /* Confuse Player */
1142 case 61:
1143 sprintf(p_ptr->attacker, " focusses on your mind");
1144 fire_grid_bolt(Ind, GF_CONFUSION, dir, damroll(2, 6) + (rlev / 3), p_ptr->attacker);
1145 break;
1146 // RF5_SLOW 0x40000000 /* Slow Player */
1147 case 62:
1148 sprintf(p_ptr->attacker, " concentrates on your body");
1149 fire_grid_bolt(Ind, GF_OLD_SLOW, dir, damroll(2, 6) + (rlev / 3), p_ptr->attacker);
1150 break;
1151 // RF5_HOLD 0x80000000 /* Paralyze Player */
1152 case 63:
1153 sprintf(p_ptr->attacker, " concentrates on your body");
1154 fire_grid_bolt(Ind, GF_STASIS, dir, damroll(2, 6) + (rlev / 3), p_ptr->attacker);
1155 break;
1156 // RF6_HAND_DOOM 0x00000002 /* Should we...? */ /* YES! */
1157 case 65:
1158 sprintf(p_ptr->attacker, " invokes the hand of doom for");
1159 msg_print(Ind, "You invoke the hand of doom.");
1160 (void)project_hook(Ind, GF_HAND_DOOM, dir, 1, PROJECT_STOP | PROJECT_KILL, p_ptr->attacker);
1161 break;
1162 // RF6_TELE_TO
1163 case 72:
1164 sprintf(p_ptr->attacker, " commands you to return");
1165 (void)project_hook(Ind, GF_TELE_TO, dir, 1, PROJECT_STOP | PROJECT_KILL, p_ptr->attacker);
1166 break;
1167 // RF6_TELE_AWAY
1168 case 73:
1169 sprintf(p_ptr->attacker, " invokes a teleportation spell");
1170 (void)fire_beam(Ind, GF_AWAY_ALL, dir, rlev, p_ptr->attacker);
1171 break;
1172 // RF6_TRAPS 0x00002000 /* Create Traps */
1173 case 77:
1174 sprintf(p_ptr->attacker, " cackles evilly");
1175 #if 0 /* Note: These traps would be exploitable for xp badly. */
1176 //msg_print(Ind, "You cackle evilly.");
1177 fire_ball(Ind, GF_MAKE_TRAP, dir, 1, 1 + rlev / 30, p_ptr->attacker);
1178 #endif
1179 break;
1180 // RF6_FORGET
1181 case 78:
1182 sprintf(p_ptr->attacker, " tries to blank your mind");
1183 fire_grid_bolt(Ind, GF_CONFUSION, dir, damroll(4, 6) + (rlev / 2), p_ptr->attacker);
1184 break;
1185
1186 default: /* For some reason we got called for a spell that
1187 doesn't require a direction */
1188 msg_format(Ind, "SERVER ERROR: do_mimic_power_aux() called for non-directional power %d!", p_ptr->current_spell);
1189 p_ptr->current_spell = -1;
1190 return;
1191 }
1192
1193 // p_ptr->energy -= level_speed(&p_ptr->wpos);
1194
1195 if (s_ptr->smana <= p_ptr->csp) {
1196 /* Use some mana */
1197 p_ptr->csp -= s_ptr->smana;
1198 }
1199
1200 /* Over-exert the player */
1201 else {
1202 int oops = s_ptr->smana - p_ptr->csp;
1203
1204 /* No mana left */
1205 p_ptr->csp = 0;
1206 p_ptr->csp_frac = 0;
1207
1208 /* Message */
1209 msg_print(Ind, "You faint from the effort!");
1210
1211 /* Hack -- bypass free action */
1212 (void)set_paralyzed(Ind, p_ptr->paralyzed + randint(5 * oops + 1));
1213
1214 /* Damage CON (possibly permanently) */
1215 if (rand_int(100) < 50) {
1216 bool perm = (rand_int(100) < 25);
1217
1218 /* Message */
1219 msg_print(Ind, "You have damaged your health!");
1220
1221 /* Reduce constitution */
1222 (void)dec_stat(Ind, A_CON, 15 + randint(10), perm);
1223 }
1224
1225 /* Cease fire-till-kill! */
1226 p_ptr->shooting_till_kill = FALSE;
1227 p_ptr->shooty_till_kill = FALSE;
1228 p_ptr->shoot_till_kill_mimic = 0;
1229 }
1230
1231 /* Reset current spell */
1232 p_ptr->current_spell = -1;
1233
1234 /* Resend mana */
1235 p_ptr->redraw |= (PR_MANA);
1236
1237 /* Window stuff */
1238 p_ptr->window |= (PW_PLAYER);
1239
1240 #if 1 /* Fire-Till-Kill */
1241 if (p_ptr->shooty_till_kill) {
1242 int ftk;
1243 #if 0
1244 if (cs < 32) {
1245 ftk = monster_spell4[cs].ftk;
1246 } else if (cs < 64) {
1247 ftk = monster_spell5[cs - 32].ftk;
1248 } else {
1249 ftk = monster_spell6[cs - 64].ftk;
1250 }
1251 #else
1252 ftk = innate_powers[cs].ftk;
1253 #endif
1254 /* spell actually doesn't allow ftk? */
1255 if (!ftk) return;
1256
1257 /* To continue shooting_till_kill, check if spell requires clean LOS to target
1258 with no other monsters in the way, so we won't wake up more monsters accidentally. */
1259 #ifndef PY_PROJ_WALL
1260 if (ftk == 1 && !projectable_real(Ind, p_ptr->py, p_ptr->px, p_ptr->target_row, p_ptr->target_col, MAX_RANGE)) return;
1261 #else
1262 if (ftk == 1 && !projectable_wall_real(Ind, p_ptr->py, p_ptr->px, p_ptr->target_row, p_ptr->target_col, MAX_RANGE)) return;
1263 #endif
1264
1265 /* We lost our target? (monster dead?) */
1266 if (dir != 5 || !target_okay(Ind)) return;
1267
1268 /* we're now indeed ftk */
1269 p_ptr->shooting_till_kill = TRUE;
1270 p_ptr->shoot_till_kill_mimic = cs + 1;
1271 /* disable other ftk types */
1272 p_ptr->shoot_till_kill_spell = FALSE;
1273 p_ptr->shoot_till_kill_rcraft = FALSE;
1274 }
1275 #endif
1276 }
1277
do_mimic_change(int Ind,int r_idx,bool force)1278 void do_mimic_change(int Ind, int r_idx, bool force) {
1279 player_type *p_ptr = Players[Ind];
1280
1281 if (!force && r_info[r_idx].level > get_skill_scale(p_ptr, SKILL_MIMIC, 100)) {
1282 msg_print(Ind, "You do need a higher mimicry skill to use that shape.");
1283 return;
1284 }
1285
1286 /* No magic */
1287 if (p_ptr->anti_magic && !force) {
1288 msg_format(Ind, "\377%cYour anti-magic shell disrupts your attempt.", COLOUR_AM_OWN);
1289 return;
1290 }
1291 if (p_ptr->antimagic && !force) {
1292 msg_format(Ind, "\377%cYour anti-magic field disrupts your attempt.", COLOUR_AM_OWN);
1293 return;
1294 }
1295 /* Not when confused */
1296 if (p_ptr->confused && !force)
1297 {
1298 msg_print(Ind, "You are too confused!");
1299 return;
1300 }
1301
1302 /* mimics can easily restore from chauve-souris fruit bat form */
1303 if (p_ptr->fruit_bat == 2) p_ptr->fruit_bat = 0;
1304
1305 p_ptr->body_monster = r_idx;
1306 p_ptr->body_changed = TRUE;
1307
1308 if (p_ptr->tim_wraith) p_ptr->tim_wraith = 1; /* in xtra2.c it would prevent regular wraithform on istari */
1309
1310 if (!force) p_ptr->warning_mimic = 1;
1311
1312 if (r_idx) {
1313 msg_format(Ind, "You polymorph into a %s!", r_info[r_idx].name + r_name);
1314 msg_format_near(Ind, "%s polymorphs into a %s!", p_ptr->name, r_info[r_idx].name + r_name);
1315 } else {
1316 msg_print(Ind, "You polymorph back to normal form.");
1317 msg_format_near(Ind, "%s polymorphs back to normal form.", p_ptr->name);
1318 }
1319
1320 break_cloaking(Ind, 0); /* can happen, if vampire rogue! */
1321 break_shadow_running(Ind); /* can happen, if vampire rogue! */
1322 stop_precision(Ind);
1323 stop_shooting_till_kill(Ind);
1324
1325 note_spot(Ind, p_ptr->py, p_ptr->px);
1326 everyone_lite_spot(&p_ptr->wpos, p_ptr->py, p_ptr->px);
1327
1328 /* Piece together a 32-bit random seed */
1329 p_ptr->mimic_seed = rand_int(0xFFFF) << 16;
1330 p_ptr->mimic_seed += rand_int(0xFFFF);
1331
1332 /* Penalise form-switching just for using a spell */
1333 // p_ptr->csp /= 2;
1334
1335 /* Recalculate mana */
1336 p_ptr->update |= (PU_MANA | PU_HP | PU_BONUS | PU_VIEW);
1337
1338 /* Tell the client */
1339 p_ptr->redraw |= PR_VARIOUS | PR_MANA;//PR_MANA was for when p_ptr->csp was reduced as form-switch penalty
1340
1341 /* Window stuff */
1342 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1343
1344 #if 0 /* 0'ed - keep form 'saved' instead! */
1345 #if POLY_RING_METHOD == 1
1346 /* clear temporary mimicking from polymorph ring */
1347 p_ptr->tim_mimic = 0;
1348 p_ptr->tim_mimic_what = 0;
1349 #endif
1350 #endif
1351 }
1352
do_cmd_mimic(int Ind,int spell,int dir)1353 void do_cmd_mimic(int Ind, int spell, int dir) {
1354 player_type *p_ptr = Players[Ind];
1355 int j, k, offset = 3; /* offset: 3 polymorph powers */
1356 bool using_free_mimic = FALSE;
1357 bool admin = is_admin(p_ptr);
1358
1359 /* should it..? */
1360 // dun_level *l_ptr = getfloor(&p_ptr->wpos);
1361 //(changed it to no_tele) if(l_ptr && l_ptr->flags1 & LF1_NO_MAGIC) return;
1362
1363 if (!get_skill(p_ptr, SKILL_MIMIC)) {
1364 msg_print(Ind, "You are too solid.");
1365 return;
1366 }
1367
1368 /* No anti-magic fields around ? */
1369 /* Innate powers aren't hindered */
1370 if ((!spell || spell - offset >= 32) && check_antimagic(Ind, 100)) {
1371 p_ptr->energy -= level_speed(&p_ptr->wpos);
1372 return;
1373 }
1374 if (spell == 0 || spell == 1) {
1375 j = p_ptr->body_monster;
1376 k = 0;
1377
1378 while (TRUE) {
1379 j++;
1380 k++;
1381 if (k >= MAX_R_IDX - 1) {
1382 // j = 0;
1383 msg_print(Ind, "You don't know any forms!");
1384 return;
1385 }
1386
1387 if (j >= MAX_R_IDX - 1) j = 0;
1388
1389 if (p_ptr->pclass == CLASS_DRUID) {
1390 if (mimic_druid(j, p_ptr->lev) || (j == 0)) {
1391 /* (S)he is no longer afk */
1392 un_afk_idle(Ind);
1393 do_mimic_change(Ind, j, TRUE);
1394 p_ptr->energy -= level_speed(&p_ptr->wpos);
1395 return;
1396 } else continue;
1397 }
1398 if (p_ptr->prace == RACE_VAMPIRE) {
1399 if (mimic_vampire(j, p_ptr->lev) || (j == 0)) {
1400 /* (S)he is no longer afk */
1401 un_afk_idle(Ind);
1402 do_mimic_change(Ind, j, TRUE);
1403 p_ptr->energy -= level_speed(&p_ptr->wpos);
1404 return;
1405 } else continue;
1406 }
1407
1408 if (r_info[j].level > get_skill_scale(p_ptr, SKILL_MIMIC, 100)) continue;
1409 if (r_info[j].flags1 & RF1_UNIQUE) continue;
1410 if (r_info[j].flags8 & RF8_PSEUDO_UNIQUE) continue;
1411 if (p_ptr->r_killed[j] < r_info[j].level) continue;
1412 if (p_ptr->r_killed[j] < 1 && j) continue;
1413 if (strlen(r_info[j].name + r_name) <= 1) continue;
1414 // if (!r_info[j].level && !mon_allowed(&r_info[j])) continue;
1415 if (!mon_allowed_chance(&r_info[j])) continue;
1416 if ((j != 0) && ((p_ptr->pclass == CLASS_SHAMAN) && !mimic_shaman(j))) continue;
1417
1418 /* Don't accidentally poly into a form that suppresses polymorphing,
1419 to do so you need to use 'Polymorph into...' */
1420 if (r_info[j].flags7 & RF7_DISBELIEVE) continue;
1421
1422 if (spell == 1) { /* check for extremities matching? */
1423 if ((p_ptr->inventory[INVEN_HEAD].tval || p_ptr->inventory[INVEN_NECK].tval)
1424 && !r_info[j].body_parts[BODY_HEAD]) continue;
1425 if (p_ptr->inventory[INVEN_ARM].tval
1426 && !r_info[j].body_parts[BODY_ARMS]) continue;
1427 if (p_ptr->inventory[INVEN_HANDS].tval
1428 && !(r_info[j].body_parts[BODY_ARMS] && r_info[j].body_parts[BODY_FINGER])) continue;
1429 if ((p_ptr->inventory[INVEN_WIELD].tval || p_ptr->inventory[INVEN_BOW].tval)
1430 && !r_info[j].body_parts[BODY_WEAPON]) continue;
1431 if (p_ptr->inventory[INVEN_RIGHT].tval
1432 && !r_info[j].body_parts[BODY_FINGER]) continue;
1433 if (p_ptr->inventory[INVEN_LEFT].tval
1434 && r_info[j].body_parts[BODY_FINGER] < 2) continue;
1435 if ((p_ptr->inventory[INVEN_BODY].tval || p_ptr->inventory[INVEN_OUTER].tval || p_ptr->inventory[INVEN_AMMO].tval)
1436 && !r_info[j].body_parts[BODY_TORSO]) continue;
1437 if (p_ptr->inventory[INVEN_FEET].tval
1438 && !r_info[j].body_parts[BODY_LEGS]) continue;
1439 /* combined stuff */
1440 if (p_ptr->inventory[INVEN_TOOL].tval && !(
1441 r_info[j].body_parts[BODY_ARMS] || r_info[j].body_parts[BODY_WEAPON])) continue;
1442 if (p_ptr->inventory[INVEN_LITE].tval && !(
1443 r_info[j].body_parts[BODY_ARMS] || r_info[j].body_parts[BODY_WEAPON] ||
1444 r_info[j].body_parts[BODY_FINGER] || r_info[j].body_parts[BODY_HEAD])) continue;
1445 }
1446
1447 /* Ok we found */
1448 break;
1449 }
1450
1451 /* (S)he is no longer afk */
1452 un_afk_idle(Ind);
1453
1454 do_mimic_change(Ind, j, FALSE);
1455 p_ptr->energy -= level_speed(&p_ptr->wpos);
1456 } else if (spell >= 20000) { /* hack: 20000 masks poly into.. */
1457 k = p_ptr->body_monster;
1458 //j = get_quantity("Which form (0 for player form)?", 0);
1459 j = spell - 20000;
1460
1461 if (p_ptr->pclass == CLASS_DRUID) { /* SPecial ^^ */
1462 if (mimic_druid(j, p_ptr->lev) || (j == 0)) {
1463 /* (S)he is no longer afk */
1464 un_afk_idle(Ind);
1465
1466 do_mimic_change(Ind, j, TRUE);
1467 p_ptr->energy -= level_speed(&p_ptr->wpos);
1468 } else msg_print(Ind, "You cannot use that form!");
1469 } else if (p_ptr->prace == RACE_VAMPIRE) {
1470 if (mimic_vampire(j, p_ptr->lev) || (j == 0)) {
1471 /* (S)he is no longer afk */
1472 un_afk_idle(Ind);
1473
1474 do_mimic_change(Ind, j, TRUE);
1475 p_ptr->energy -= level_speed(&p_ptr->wpos);
1476 } else msg_print(Ind, "You cannot use that form!");
1477 } else {
1478 if ((j >= MAX_R_IDX - 1) || (j < 0)) {
1479 msg_print(Ind, "That form does not exist in the realm!");
1480 return;
1481 } else if (k == j) {
1482 msg_print(Ind, "You are already using that form!");
1483 return;
1484 } else if (r_info[j].flags1 & RF1_UNIQUE) {
1485 msg_print(Ind, "That form is unique!");
1486 return;
1487 } else if (r_info[j].flags8 & RF8_PSEUDO_UNIQUE) {
1488 msg_print(Ind, "That form is unlearnable!");
1489 return;
1490 } else if (j && p_ptr->r_killed[j] < 1
1491 && !(p_ptr->tim_mimic && p_ptr->tim_mimic_what == j)
1492 && !admin) {
1493 if (!p_ptr->free_mimic) {
1494 msg_print(Ind, "You have no experience with that form at all!");
1495 return;
1496 } else using_free_mimic = TRUE;
1497 } else if (p_ptr->r_killed[j] < r_info[j].level
1498 && !(p_ptr->tim_mimic && p_ptr->tim_mimic_what == j)
1499 && !admin) {
1500 if (!p_ptr->free_mimic) {
1501 msg_print(Ind, "You have not yet learned that form!");
1502 return;
1503 } else using_free_mimic = TRUE;
1504 }
1505
1506 if (strlen(r_info[j].name + r_name) <= 1) { /* <- ??? */
1507 msg_print(Ind, "You cannot use that form!");
1508 return;
1509 }
1510 // if (!r_info[j].level && !mon_allowed(&r_info[j])){ /* <- ? */
1511 else if (!mon_allowed_chance(&r_info[j])) { /* ! - C. Blue */
1512 msg_print(Ind, "You cannot use that form!");
1513 return;
1514 } else if ((j != 0) && ((p_ptr->pclass == CLASS_SHAMAN) && !mimic_shaman(j))) {
1515 msg_print(Ind, "You cannot use that form!");
1516 return;
1517 } else if (r_info[j].level > get_skill_scale(p_ptr, SKILL_MIMIC, 100)) {
1518 msg_print(Ind, "You are not powerful enough to change into that form!");
1519 return;
1520 }
1521
1522 /* using up PvP-mode free mimic transformation? */
1523 if (j && using_free_mimic) p_ptr->free_mimic--;
1524
1525 /* Activation tax */
1526 else if (j && p_ptr->r_killed[j] < r_info[j].level
1527 && p_ptr->tim_mimic_what == j && p_ptr->tim_mimic > 10)
1528 p_ptr->tim_mimic -= 10;
1529
1530 /* Ok we found */
1531 do_mimic_change(Ind, j, using_free_mimic);
1532 p_ptr->energy -= level_speed(&p_ptr->wpos);
1533 }
1534 } else {
1535 /* (S)he is no longer afk */
1536 un_afk_idle(Ind);
1537
1538 do_mimic_power(Ind, spell - offset, dir);
1539 }
1540 }
1541
1542 /*
1543 * School spells !
1544 */
1545 /* Hrm, 'item' should be used for spells like Identify;
1546 * TODO: revise the PKT_ACTIVATE_SKILL packet type
1547 */
cast_school_spell(int Ind,int book,int spell,int dir,int item,int aux)1548 void cast_school_spell(int Ind, int book, int spell, int dir, int item, int aux) {
1549 player_type *p_ptr = Players[Ind];
1550 object_type *o_ptr = &p_ptr->inventory[book];
1551 int ftk_maybe;
1552 int ftk_type;
1553 #ifdef ENABLE_XID_SPELL
1554 bool rep = (p_ptr->command_rep == PKT_ACTIVATE_SKILL)
1555 && p_ptr->current_item < 0; //extra sanity check, superfluous?
1556
1557 p_ptr->command_rep = 0;
1558 #endif
1559
1560 if (p_ptr->shooting_till_kill) { /* we were shooting till kill last turn? */
1561 p_ptr->shooting_till_kill = FALSE; /* well, gotta re-test for another success now.. */
1562 if (dir == 5) p_ptr->shooty_till_kill = TRUE; /* so for now we are just ATTEMPTING to shoot till kill (assumed we have a monster for target) */
1563 }
1564
1565 if (!can_use_verbose(Ind, o_ptr)) return;
1566
1567 if (o_ptr->tval != TV_BOOK) {
1568 /* log for debugging */
1569 s_printf("CAST_SCHOOL_SPELL_ERROR: TV_BOOK != %d\n", o_ptr->tval);
1570
1571 //msg_print(Ind, "Ahah dont try to hack your client please :) :: tval");
1572 return;
1573 } else if (o_ptr->sval == SV_SPELLBOOK) {
1574 if (o_ptr->pval != spell) {
1575 /* log for debugging */
1576 s_printf("CAST_SCHOOL_SPELL_ERROR: SV_SPELLBOOK - %d != %d\n", o_ptr->pval, spell);
1577
1578 //msg_print(Ind, "Ahah dont try to hack your client please :) :: sval 255");
1579 return;
1580 }
1581 } else {
1582 if (MY_VERSION < (4 << 12 | 4 << 8 | 1 << 4 | 8)) {
1583 if (exec_lua(Ind, format("return spell_in_book(%d, %d)", o_ptr->sval, spell)) == FALSE) {
1584 /* no longer supported! to make s_aux.lua slimmer */
1585 /* log for debugging */
1586 s_printf("CAST_SCHOOL_SPELL_ERROR: MY_VERSION < - %d, %d\n", o_ptr->sval, spell);
1587
1588 //msg_print(Ind, "Ahah dont try to hack your client please :) :: sval != 255");
1589 return;
1590 }
1591 } else {
1592 if (exec_lua(Ind, format("return spell_in_book2(%d, %d, %d)", book, o_ptr->sval, spell)) == FALSE) {
1593 /* log for debugging */
1594 s_printf("CAST_SCHOOL_SPELL_ERROR: MY_VERSION >= - %d, %d, %d\n", book, o_ptr->sval, spell);
1595
1596 //msg_print(Ind, "Ahah dont try to hack your client please :) :: sval != 255");
1597 return;
1598 }
1599 }
1600 }
1601
1602 /* New '+' feat in 4.4.6.2 */
1603 if (dir == 11) {
1604 get_aim_dir(Ind);
1605 p_ptr->current_realm = REALM_SCHOOL;
1606 p_ptr->current_item = item;
1607 p_ptr->current_book = book;
1608 p_ptr->current_spell = spell;
1609 p_ptr->current_aux = aux;
1610 return;
1611 }
1612
1613 break_cloaking(Ind, 5);
1614 break_shadow_running(Ind);
1615 stop_precision(Ind);
1616 stop_shooting_till_kill(Ind);
1617
1618 /* No magic */
1619 if (p_ptr->anti_magic) {
1620 msg_format(Ind, "\377%cYour anti-magic shell disrupts any magic attempts.", COLOUR_AM_OWN);
1621 return;
1622 }
1623 if (p_ptr->antimagic) {
1624 msg_format(Ind, "\377%cYour anti-magic field disrupts any magic attempts.", COLOUR_AM_OWN);
1625 return;
1626 }
1627
1628 /* Disruption shield prevents interfering! */
1629 if (!p_ptr->tim_manashield && interfere(Ind, cfg.spell_interfere)) return; /* school spell casting interference chance */
1630
1631 /* TODO: use energy */
1632
1633 /* (S)he is no longer afk */
1634 un_afk_idle(Ind);
1635
1636 #if 0 /* client-side, lacks Ind to set 'player' */
1637 /* Sanity check for direction */
1638 if (exec_lua(0, format("return pre_exec_spell_dir(%d)", spell)) && (dir == -1)) return;
1639 #endif
1640
1641 /* Actualy cast the choice */
1642 if (spell != -1) {
1643 ftk_maybe = (exec_lua(Ind, format("return cast_school_spell(%d, %d, spell(%d), nil, {dir = %d, book = %d, item = %d, aux = %d})", Ind, spell, spell, dir, book, item, aux)));
1644 ftk_type = (exec_lua(Ind, format("return get_spell_ftk(%d)", spell)));
1645
1646 #ifdef ENABLE_XID_SPELL
1647 /* hack: repeat ID-spell attempt until item is successfully identified */
1648 if (rep && !object_known_p(Ind, &p_ptr->inventory[-p_ptr->current_item - 1])) {
1649 sockbuf_t *conn_q = get_conn_q(Ind);
1650
1651 p_ptr->command_rep = PKT_ACTIVATE_SKILL;
1652 Packet_printf(conn_q, "%c%c%hd%hd%c%hd%hd", PKT_ACTIVATE_SKILL, MKEY_SCHOOL, book, spell, dir, item, aux);
1653 } else p_ptr->current_item = -1;
1654 #endif
1655
1656 if (!p_ptr->warning_macros && dir != 5 && dir < 10) {
1657 msg_print(Ind, "\374\377oHINT: Create a '\377Rmacro\377o' aka hotkey to cast a spell with a single keypress!");
1658 msg_print(Ind, "\374\377o Press '\377R%\377o' and then '\377Rz\377o' to invoke the macro wizard.");
1659 p_ptr->warning_macros = 1;
1660 s_printf("warning_macros: %s\n", p_ptr->name);
1661 }
1662
1663 #if 1 /* Fire-Till-Kill */
1664 if (p_ptr->shooty_till_kill && ftk_maybe) {
1665 /* spell actually doesn't allow ftk? */
1666 if (ftk_type == 0) return;
1667
1668 /* To continue shooting_till_kill, check if spell requires clean LOS to target
1669 with no other monsters in the way, so we won't wake up more monsters accidentally. */
1670 #ifndef PY_PROJ_WALL
1671 if (ftk_type == 1 && !projectable_real(Ind, p_ptr->py, p_ptr->px, p_ptr->target_row, p_ptr->target_col, MAX_RANGE)) return;
1672 #else
1673 if (ftk_type == 1 && !projectable_wall_real(Ind, p_ptr->py, p_ptr->px, p_ptr->target_row, p_ptr->target_col, MAX_RANGE)) return;
1674 #endif
1675
1676 /* We lost our target? (monster dead?) */
1677 if (dir != 5 || !target_okay(Ind)) return;
1678
1679 /* we're now indeed ftk */
1680 p_ptr->shooting_till_kill = TRUE;
1681 p_ptr->shoot_till_kill_book = book;
1682 p_ptr->shoot_till_kill_spell = spell + 1;
1683 /* disable other ftk types */
1684 p_ptr->shoot_till_kill_mimic = FALSE;
1685 p_ptr->shoot_till_kill_rcraft = FALSE;
1686 }
1687 #endif
1688 }
1689 }
1690