1 /* File: mutation.c */
2 
3 /* Purpose: Mutation effects (and racial powers) */
4 
5 /*
6  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
7  *
8  * This software may be copied and distributed for educational, research, and
9  * not for profit purposes provided that this copyright and statement are
10  * included in all such copies.
11  */
12 
13 #include "angband.h"
14 
15 
16 
17 /*
18  * Hack - to allow bias for collecting
19  * certain mutations dependent upon your race
20  */
21 #define M1_HYPN_GAZE	 2
22 #define M1_SHRIEK		13
23 #define M1_POLYMORPH	17
24 #define M2_HORNS		39
25 #define M2_TENTACLES	48
26 
27 
28 /* Does the player have the given mutation? */
player_has_mut(int mutation)29 bool player_has_mut(int mutation)
30 {
31 	if (mutation < MUT_PER_SET)
32 	{
33 		return (p_ptr->muta1 & mutations[mutation].which ? TRUE : FALSE);
34 	}
35 	else if (mutation < MUT_PER_SET * 2)
36 	{
37 		return (p_ptr->muta2 & mutations[mutation].which ? TRUE : FALSE);
38 	}
39 	else
40 	{
41 		return (p_ptr->muta3 & mutations[mutation].which ? TRUE : FALSE);
42 	}
43 }
44 
45 
46 /*
47  * Select a random mutation.
48  *
49  * Note that if choose_mut is non-zero (specified
50  * via p_ptr->command_arg in debugging mode) we
51  * select the specified mutation.
52  *
53  * This function is really silly.
54  * We should use the (depth) rarity method used
55  * for everything else to select the mutation
56  */
select_mutation(int choose_mut,bool gain,int * mutation)57 static bool select_mutation(int choose_mut, bool gain, int *mutation)
58 {
59 	u32b flag;
60 
61 	int attempts_left;
62 
63 	int num = -1;
64 
65 
66 	/* Sanity check */
67 	if (choose_mut < 0 || choose_mut > 193) choose_mut = 0;
68 
69 	attempts_left = (choose_mut ? 1 : (gain ? 20 : 2000));
70 
71 	while (attempts_left--)
72 	{
73 		switch (choose_mut ? choose_mut : randint1(193))
74 		{
75 			case 1:  case 2:  case 3:  case 4:
76 				/* Spit acid */
77 				num = 0;
78 				break;
79 			case 5:  case 6:  case 7:
80 				/* Breathe fire */
81 				num = 1;
82 				break;
83 			case 8:  case 9:
84 				/* Hypnotic gaze */
85 				num = 2;
86 				break;
87 			case 10:  case 11:
88 				/* Telekinesis */
89 				num = 3;
90 				break;
91 			case 12:  case 13:  case 14:
92 				/* Vteleport */
93 				num = 4;
94 				break;
95 			case 15:  case 16:
96 				/* Mind blast */
97 				num = 5;
98 				break;
99 			case 17:  case 18:
100 				/* Radiation */
101 				num = 6;
102 				break;
103 			case 19:  case 20:
104 				/* Vampirism */
105 				num = 7;
106 				break;
107 			case 21:  case 22:  case 23:
108 				/* Smell metal */
109 				num = 8;
110 				break;
111 			case 24:  case 25:  case 26:  case 27:
112 				/* Smell monsters */
113 				num = 9;
114 				break;
115 			case 28:  case 29:  case 30:
116 				/* Blink */
117 				num = 10;
118 				break;
119 			case 31:  case 32:
120 				/* Eat rock */
121 				num = 11;
122 				break;
123 			case 33:  case 34:
124 				/* Swap position */
125 				num = 12;
126 				break;
127 			case 35:  case 36:  case 37:
128 				/* Shriek */
129 				num = 13;
130 				break;
131 			case 38:  case 39:  case 40:
132 				/* Illuminate */
133 				num = 14;
134 				break;
135 			case 41:  case 42:
136 				/* Detect curse */
137 				num = 15;
138 				break;
139 			case 43:  case 44:  case 45:
140 				/* Berserk */
141 				num = 16;
142 				break;
143 			case 46:
144 				/* Polymorph */
145 				num = 17;
146 				break;
147 			case 47:  case 48:
148 				/* Midas */
149 				/* Only rich characters can get this */
150 				if (p_ptr->au >= p_ptr->lev * 1000L)
151 				{
152 					num = 18;
153 				}
154 				break;
155 			case 49:
156 				/* Mold */
157 				num = 19;
158 				break;
159 			case 50:  case 51:  case 52:
160 				/* Resist Elements */
161 				num = 20;
162 				break;
163 			case 53:  case 54:  case 55:
164 				/* Earthquake */
165 				num = 21;
166 				break;
167 			case 56:
168 				/* Eat magic */
169 				num = 22;
170 				break;
171 			case 57:  case 58:
172 				/* Weigh magic */
173 				num = 23;
174 				break;
175 			case 59:
176 				/* Sterilize */
177 				num = 24;
178 				break;
179 			case 60:  case 61:
180 				/* Panic hit */
181 				num = 25;
182 				break;
183 			case 62:  case 63:  case 64:
184 				/* Dazzle */
185 				num = 26;
186 				break;
187 			case 65:  case 66:  case 67:
188 				/* Laser eye */
189 				num = 27;
190 				break;
191 			case 68:  case 69:
192 				/* Recall */
193 				num = 28;
194 				break;
195 			case 70:
196 				/* Banish */
197 				num = 29;
198 				break;
199 			case 71:  case 72:
200 				/* Cold touch */
201 				num = 30;
202 				break;
203 			case 73:  case 74:
204 				/* Throw */
205 				num = 31;
206 				break;
207 			case 75:
208 				/* Berserk */
209 				num = 32;
210 				break;
211 			case 76:
212 				/* Fear */
213 				num = 33;
214 				break;
215 			case 77:
216 				/* Teleport */
217 				num = 34;
218 				break;
219 			case 78:
220 				/* Ethanol */
221 				num = 35;
222 				break;
223 			case 79:
224 				/* Hallucinate */
225 				num = 36;
226 				break;
227 			case 80:
228 				/* Flatulent */
229 				num = 37;
230 				break;
231 			case 81:  case 82:
232 				/* Scorpion */
233 				num = 38;
234 				break;
235 			case 83:  case 84:
236 				/* Horns */
237 				num = 39;
238 				break;
239 			case 85:  case 86:
240 				/* Beak */
241 				num = 40;
242 				break;
243 			case 87:  case 88:
244 				/* Demons */
245 				num = 41;
246 				break;
247 			case 89:
248 				/* Mana */
249 				num = 42;
250 				break;
251 			case 90:  case 91:
252 				/* Speed flux */
253 				num = 43;
254 				break;
255 			case 92:  case 93:
256 				/* Banish */
257 				num = 44;
258 				break;
259 			case 94:
260 				/* Eat lite */
261 				num = 45;
262 				break;
263 			case 95:  case 96:
264 				/* Trunk */
265 				num = 46;
266 				break;
267 			case 97:
268 				/* Animal */
269 				num = 47;
270 				break;
271 			case 98:
272 				/* Tentacles */
273 				num = 48;
274 				break;
275 			case 99:
276 				/* Raw Chaos */
277 				num = 49;
278 				break;
279 			case 100:  case 101:  case 102:
280 				/* Normal */
281 				num = 50;
282 				break;
283 			case 103:
284 				/* Wraith */
285 				num = 51;
286 				break;
287 			case 104:
288 				/* Poly wound */
289 				num = 52;
290 				break;
291 			case 105:
292 				/* Disease */
293 				num = 53;
294 				break;
295 			case 106:
296 				/* Dragon */
297 				num = 54;
298 				break;
299 			case 107:  case 108:
300 				/* Esp */
301 				num = 55;
302 				break;
303 			case 109:
304 				/* Sick */
305 				num = 56;
306 				break;
307 			case 110:  case 111:
308 				/* Chaos warriors already have a chaos deity */
309 				if (p_ptr->rp.pclass != CLASS_CHAOS_WARRIOR)
310 				{
311 					/* Patron */
312 					num = 57;
313 				}
314 				break;
315 			case 112:
316 				/* Shadow walk */
317 				num = 58;
318 				break;
319 			case 113:  case 114:
320 				/* Warn */
321 				num = 59;
322 				break;
323 			case 115:
324 				/* Invuln */
325 				num = 60;
326 				break;
327 			case 116:  case 117:
328 				/* Healing */
329 				num = 61;
330 				break;
331 			case 118:
332 				/* HP2SP */
333 				num = 62;
334 				break;
335 			case 119:
336 				/* Disarm */
337 				num = 63;
338 				break;
339 			case 120:  case 121:  case 122:
340 				/* Strong */
341 				num = 64;
342 				break;
343 			case 123:  case 124:  case 125:
344 				/* Weak */
345 				num = 65;
346 				break;
347 			case 126:  case 127:  case 128:
348 				/* Smart */
349 				num = 66;
350 				break;
351 			case 129:  case 130:  case 131:
352 				/* Dumb */
353 				num = 67;
354 				break;
355 			case 132:  case 133:
356 				/* Con */
357 				num = 68;
358 				break;
359 			case 134:  case 135:
360 				/* Fat */
361 				num = 69;
362 				break;
363 			case 136:  case 137:
364 				/* Frail */
365 				num = 70;
366 				break;
367 			case 138:  case 139:  case 140:
368 				/* Rot */
369 				num = 71;
370 				break;
371 			case 141:  case 142:
372 				/* Squeak */
373 				/* Restricted to chars with several muts already */
374 				if (count_mutations() >= 3)
375 				{
376 					num = 72;
377 				}
378 				break;
379 			case 143:  case 144:
380 				/* Blank face */
381 				num = 73;
382 				break;
383 			case 145:
384 				/* Illusion face */
385 				num = 74;
386 				break;
387 			case 146:  case 147:  case 148:
388 				/* eyes */
389 				num = 75;
390 				break;
391 			case 149:  case 150:
392 				/* Res magic */
393 				num = 76;
394 				break;
395 			case 151:  case 152:  case 153:
396 				/* Noise */
397 				num = 77;
398 				break;
399 			case 154:  case 155:  case 156:
400 				/* Infra */
401 				num = 78;
402 				break;
403 			case 157:  case 158:
404 				/* Legs fast */
405 				num = 79;
406 				break;
407 			case 159:  case 160:
408 				/* Legs slow */
409 				num = 80;
410 				break;
411 			case 161:  case 162:
412 				/* Aura elec */
413 				num = 81;
414 				break;
415 			case 163:  case 164:
416 				/* Aura fire */
417 				num = 82;
418 				break;
419 			case 165:  case 166:  case 167:
420 				/* Warts */
421 				num = 83;
422 				break;
423 			case 168:  case 169:  case 170:
424 				/* Scales */
425 				num = 84;
426 				break;
427 			case 171:  case 172:
428 				/* Iron */
429 				num = 85;
430 				break;
431 			case 173:  case 174:
432 				/* Wings */
433 				num = 86;
434 				break;
435 			case 175:  case 176:  case 177:
436 				/* Res fear */
437 				num = 87;
438 				break;
439 			case 178:  case 179:
440 				/* Regen */
441 				num = 88;
442 				break;
443 			case 180:  case 181:
444 				/* ESP */
445 				num = 89;
446 				break;
447 			case 182:  case 183:  case 184:
448 				/* Limber */
449 				num = 90;
450 				break;
451 			case 185:  case 186:  case 187:
452 				/* Arthritis */
453 				num = 91;
454 				break;
455 			case 188:
456 				/* Bad luck */
457 				num = 92;
458 				break;
459 			case 189:
460 				/* Bad element */
461 				/* Restricted to chars with several muts already */
462 				if (count_mutations() >= 3)
463 				{
464 					num = 93;
465 				}
466 				break;
467 			case 190:  case 191:  case 192:
468 				/* Stealth */
469 				num = 94;
470 				break;
471 			case 193:
472 				/* Good luck */
473 				num = 95;
474 				break;
475 			default:
476 				num = -1;
477 		}
478 
479 		/* Lower chance of getting an unusable mutation */
480 		if (num >= 0 && mutations[num].level > p_ptr->lev &&
481 				!one_in_(mutations[num].level - p_ptr->lev + 1))
482 		{
483 			num = -1;
484 		}
485 
486 		/* Have we picked anything? */
487 		if (num >= 0)
488 		{
489 			/* Can we gain / lose the mutation as desired? */
490 			if (num < MUT_PER_SET)
491 			{
492 				flag = p_ptr->muta1;
493 			}
494 			else if (num < MUT_PER_SET * 2)
495 			{
496 				flag = p_ptr->muta2;
497 			}
498 			else
499 			{
500 				flag = p_ptr->muta3;
501 			}
502 
503 			/* Save the mutation we are using */
504 			*mutation = num;
505 
506 			return ((flag & mutations[num].which ? FALSE : TRUE) == gain);
507 		}
508 	}
509 
510 	return FALSE;
511 }
512 
513 
514 /*
515  * Gain a mutation
516  */
gain_mutation(int choose_mut)517 bool gain_mutation(int choose_mut)
518 {
519 	const mutation_type *mut_ptr;
520 
521 	u32b muta_which;
522 
523 	int num;
524 
525 	/* Choose a mutation */
526 	if (!select_mutation(choose_mut, TRUE, &num))
527 	{
528 		msgf("You feel normal.");
529 		return FALSE;
530 	}
531 	else
532 	{
533 		chg_virtue(V_CHANCE, 1);
534 
535 		if (p_ptr->rp.prace == RACE_VAMPIRE &&
536 			!(p_ptr->muta1 & MUT1_HYPN_GAZE) && (randint1(10) < 7))
537 		{
538 			num = M1_HYPN_GAZE;
539 		}
540 
541 		else if (p_ptr->rp.prace == RACE_IMP &&
542 				 !(p_ptr->muta2 & MUT2_HORNS) && (randint1(10) < 7))
543 		{
544 			num = M2_HORNS;
545 		}
546 
547 		else if (p_ptr->rp.prace == RACE_YEEK &&
548 				 !(p_ptr->muta1 & MUT1_SHRIEK) && (randint1(10) < 7))
549 		{
550 			num = M1_SHRIEK;
551 		}
552 
553 		else if (p_ptr->rp.prace == RACE_BEASTMAN &&
554 				 !(p_ptr->muta1 & MUT1_POLYMORPH) && (randint1(10) < 2))
555 		{
556 			num = M1_POLYMORPH;
557 		}
558 
559 		else if (p_ptr->rp.prace == RACE_MIND_FLAYER &&
560 				 !(p_ptr->muta2 & MUT2_TENTACLES) && (randint1(10) < 7))
561 		{
562 			num = M2_TENTACLES;
563 		}
564 
565 		/* Point to the mutation */
566 		mut_ptr = &mutations[num];
567 
568 		muta_which = mut_ptr->which;
569 
570 		msgf("You mutate!");
571 		msgf(mut_ptr->gain_text);
572 
573 		/* Gain the mutation */
574 		if (num < MUT_PER_SET)
575 		{
576 			p_ptr->muta1 |= muta_which;
577 		}
578 		else if (num < MUT_PER_SET * 2)
579 		{
580 			p_ptr->muta2 |= muta_which;
581 		}
582 		else
583 		{
584 			p_ptr->muta3 |= muta_which;
585 		}
586 
587 		/* Some mutations cancel others */
588 		if (num >= MUT_PER_SET * 2)
589 		{
590 			if (muta_which == MUT3_PUNY)
591 			{
592 				if (p_ptr->muta3 & MUT3_HYPER_STR)
593 				{
594 					msgf("You no longer feel super-strong!");
595 					p_ptr->muta3 &= ~(MUT3_HYPER_STR);
596 				}
597 			}
598 			else if (muta_which == MUT3_HYPER_STR)
599 			{
600 				if (p_ptr->muta3 & MUT3_PUNY)
601 				{
602 					msgf("You no longer feel puny!");
603 					p_ptr->muta3 &= ~(MUT3_PUNY);
604 				}
605 			}
606 			else if (muta_which == MUT3_MORONIC)
607 			{
608 				if (p_ptr->muta3 & MUT3_HYPER_INT)
609 				{
610 					msgf("Your brain is no longer a living computer.");
611 					p_ptr->muta3 &= ~(MUT3_HYPER_INT);
612 				}
613 			}
614 			else if (muta_which == MUT3_HYPER_INT)
615 			{
616 				if (p_ptr->muta3 & MUT3_MORONIC)
617 				{
618 					msgf("You are no longer moronic.");
619 					p_ptr->muta3 &= ~(MUT3_MORONIC);
620 				}
621 			}
622 			else if (muta_which == MUT3_IRON_SKIN)
623 			{
624 				if (p_ptr->muta3 & MUT3_SCALES)
625 				{
626 					msgf("You lose your scales.");
627 					p_ptr->muta3 &= ~(MUT3_SCALES);
628 				}
629 				if (p_ptr->muta3 & MUT3_FLESH_ROT)
630 				{
631 					msgf("Your flesh rots no longer.");
632 					p_ptr->muta3 &= ~(MUT3_FLESH_ROT);
633 				}
634 				if (p_ptr->muta3 & MUT3_WART_SKIN)
635 				{
636 					msgf("You lose your warts.");
637 					p_ptr->muta3 &= ~(MUT3_WART_SKIN);
638 				}
639 			}
640 			else if ((muta_which == MUT3_WART_SKIN) ||
641 					 (muta_which == MUT3_SCALES) ||
642 					 (muta_which == MUT3_FLESH_ROT))
643 			{
644 				if (p_ptr->muta3 & MUT3_IRON_SKIN)
645 				{
646 					msgf("Your skin is no longer made of steel.");
647 					p_ptr->muta3 &= ~(MUT3_IRON_SKIN);
648 				}
649 			}
650 			else if (muta_which == MUT3_FEARLESS)
651 			{
652 				if (p_ptr->muta2 & MUT2_COWARDICE)
653 				{
654 					msgf("You are no longer cowardly.");
655 					p_ptr->muta2 &= ~(MUT2_COWARDICE);
656 				}
657 			}
658 			else if (muta_which == MUT3_FLESH_ROT)
659 			{
660 				if (p_ptr->muta3 & MUT3_REGEN)
661 				{
662 					msgf("You stop regenerating.");
663 					p_ptr->muta3 &= ~(MUT3_REGEN);
664 				}
665 			}
666 			else if (muta_which == MUT3_REGEN)
667 			{
668 				if (p_ptr->muta3 & MUT3_FLESH_ROT)
669 				{
670 					msgf("Your flesh stops rotting.");
671 					p_ptr->muta3 &= ~(MUT3_FLESH_ROT);
672 				}
673 			}
674 			else if (muta_which == MUT3_LIMBER)
675 			{
676 				if (p_ptr->muta3 & MUT3_ARTHRITIS)
677 				{
678 					msgf("Your joints stop hurting.");
679 					p_ptr->muta3 &= ~(MUT3_ARTHRITIS);
680 				}
681 			}
682 			else if (muta_which == MUT3_ARTHRITIS)
683 			{
684 				if (p_ptr->muta3 & MUT3_LIMBER)
685 				{
686 					msgf("You no longer feel limber.");
687 					p_ptr->muta3 &= ~(MUT3_LIMBER);
688 				}
689 			}
690 		}
691 		else if (num >= MUT_PER_SET)
692 		{
693 			if (muta_which == MUT2_COWARDICE)
694 			{
695 				if (p_ptr->muta3 & MUT3_FEARLESS)
696 				{
697 					msgf("You no longer feel fearless.");
698 					p_ptr->muta3 &= ~(MUT3_FEARLESS);
699 				}
700 			}
701 			if (muta_which == MUT2_BEAK)
702 			{
703 				if (p_ptr->muta2 & MUT2_TRUNK)
704 				{
705 					msgf("Your nose is no longer elephantine.");
706 					p_ptr->muta2 &= ~(MUT2_TRUNK);
707 				}
708 			}
709 			if (muta_which == MUT2_TRUNK)
710 			{
711 				if (p_ptr->muta2 & MUT2_BEAK)
712 				{
713 					msgf("You no longer have a hard beak.");
714 					p_ptr->muta2 &= ~(MUT2_BEAK);
715 				}
716 			}
717 		}
718 
719 		p_ptr->update |= PU_BONUS;
720 		handle_stuff();
721 		return TRUE;
722 	}
723 }
724 
725 /*
726  * Lose a mutation
727  */
lose_mutation(int choose_mut)728 bool lose_mutation(int choose_mut)
729 {
730 	int num;
731 
732 	u32b muta_which;
733 	const mutation_type *mut_ptr;
734 
735 
736 	if (!select_mutation(choose_mut, FALSE, &num))
737 	{
738 		return FALSE;
739 	}
740 	else
741 	{
742 		/* Point to the mutation */
743 		mut_ptr = &mutations[num];
744 
745 		muta_which = mut_ptr->which;
746 
747 		msgf(mut_ptr->lose_text);
748 
749 		if (num < MUT_PER_SET)
750 		{
751 			p_ptr->muta1 &= ~(muta_which);
752 		}
753 		else if (num < MUT_PER_SET * 2)
754 		{
755 			p_ptr->muta2 &= ~(muta_which);
756 		}
757 		else
758 		{
759 			p_ptr->muta3 &= ~(muta_which);
760 		}
761 
762 		p_ptr->update |= PU_BONUS;
763 		handle_stuff();
764 		return TRUE;
765 	}
766 }
767 
768 
769 /*
770  * Print out a description of the current mutations
771  */
dump_mutations(FILE * fff)772 void dump_mutations(FILE *fff)
773 {
774 	const mutation_type *mut_ptr;
775 
776 	int i;
777 
778 	if (!fff) return;
779 
780 	/* Run through the mutations */
781 	for (i = 0; i < MUT_PER_SET * 3; i++)
782 	{
783 		mut_ptr = &mutations[i];
784 
785 		if (player_has_mut(i))
786 		{
787 			froff(fff, "%s\n", mut_ptr->desc_text);
788 		}
789 	}
790 }
791 
792 
793 /*
794  * List mutations we have...
795  */
do_cmd_knowledge_mutations(int dummy)796 bool do_cmd_knowledge_mutations(int dummy)
797 {
798 	FILE *fff;
799 	char file_name[1024];
800 
801 	/* Hack - ignore parameter */
802 	(void) dummy;
803 
804 	/* Open a temporary file */
805 	fff = my_fopen_temp(file_name, sizeof(file_name));
806 
807 	/* Failure */
808 	if (!fff) return (FALSE);
809 
810 	/* Dump the mutations to file */
811 	if (fff) dump_mutations(fff);
812 
813 	/* Close the file */
814 	my_fclose(fff);
815 
816 	/* Display the file contents */
817 	(void)show_file(file_name, "Mutations", 0, 0);
818 
819 	/* Remove the file */
820 	(void)fd_kill(file_name);
821 
822 	return (FALSE);
823 }
824 
825 
826 
count_mutations(void)827 int count_mutations(void)
828 {
829 	return (count_bits(p_ptr->muta1) +
830 			count_bits(p_ptr->muta2) + count_bits(p_ptr->muta3));
831 }
832 
833 
834 /*
835  * Use an activatable mutation power
836  */
mutation_power_aux(const mutation_type * mut_ptr)837 void mutation_power_aux(const mutation_type *mut_ptr)
838 {
839 	int px = p_ptr->px;
840 	int py = p_ptr->py;
841 
842 	int dir = 0;
843 	int lvl = p_ptr->lev;
844 	cptr q, s;
845 
846 
847 	if (!(racial_aux(mut_ptr->level, mut_ptr->cost, mut_ptr->stat,
848 					 mut_ptr->diff))) return;
849 
850 	if (mut_ptr->which == MUT1_SPIT_ACID)
851 	{
852 		msgf("You spit acid...");
853 		if (get_aim_dir(&dir))
854 		{
855 			(void)fire_ball(GF_ACID, dir, lvl, 1 + (lvl / 30));
856 		}
857 	}
858 
859 	else if (mut_ptr->which == MUT1_BR_FIRE)
860 	{
861 		msgf("You breathe fire...");
862 		if (get_aim_dir(&dir))
863 		{
864 			(void)fire_ball(GF_FIRE, dir, lvl * 2, 1 + (lvl / 20));
865 		}
866 	}
867 
868 	else if (mut_ptr->which == MUT1_HYPN_GAZE)
869 	{
870 		msgf("Your eyes look mesmerizing...");
871 		if (get_aim_dir(&dir))
872 		{
873 			(void)charm_monster(dir, lvl);
874 		}
875 	}
876 
877 	else if (mut_ptr->which == MUT1_TELEKINES)
878 	{
879 		msgf("You concentrate...");
880 		if (get_aim_dir(&dir))
881 		{
882 			fetch(dir, lvl * 10, TRUE);
883 		}
884 	}
885 
886 	else if (mut_ptr->which == MUT1_VTELEPORT)
887 	{
888 		msgf("You concentrate...");
889 		teleport_player(10 + 4 * lvl);
890 	}
891 	else if (mut_ptr->which == MUT1_MIND_BLST)
892 	{
893 		msgf("You concentrate...");
894 		if (get_aim_dir(&dir))
895 		{
896 			(void)fire_bolt(GF_PSI, dir, damroll(3 + ((lvl - 1) / 5), 3));
897 		}
898 		else
899 		{
900 			/* Is this statement needed? */
901 			return;
902 		}
903 	}
904 
905 	else if (mut_ptr->which == MUT1_RADIATION)
906 	{
907 		msgf("Radiation flows from your body!");
908 		(void)fire_ball(GF_NUKE, 0, (lvl * 2), 3 + (lvl / 20));
909 	}
910 
911 	else if (mut_ptr->which == MUT1_VAMPIRISM)
912 	{
913 		int x, y, dummy;
914 		cave_type *c_ptr;
915 
916 		/* Handle player fear */
917 		if (p_ptr->tim.afraid)
918 		{
919 			/* Message */
920 			msgf("You are too afraid!");
921 			return;
922 		}
923 
924 		/* Only works on adjacent monsters */
925 		if (!get_rep_dir(&dir)) return;
926 		y = py + ddy[dir];
927 		x = px + ddx[dir];
928 
929 		/* paranoia */
930 		if (!in_bounds2(x, y)) return;
931 
932 		c_ptr = area(x, y);
933 
934 		if (!(c_ptr->m_idx))
935 		{
936 			msgf("You bite into thin air!");
937 			return;
938 		}
939 		msgf("You grin and bare your fangs...");
940 
941 		dummy = lvl * 2;
942 
943 		if (drain_gain_life(dir, dummy))
944 		{
945 			/* Gain nutritional sustenance: 150/hp drained */
946 			/* A Food ration gives 5000 food points (by contrast) */
947 			/* Don't ever get more than "Full" this way */
948 			/* But if we ARE Gorged,  it won't cure us */
949 			dummy = p_ptr->food + MIN(5000, 100 * dummy);
950 			if (p_ptr->food < PY_FOOD_MAX)	/* Not gorged already */
951 				(void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy);
952 		}
953 		else
954 			msgf("Yechh. That tastes foul.");
955 	}
956 
957 	else if (mut_ptr->which == MUT1_SMELL_MET)
958 	{
959 		(void)detect_treasure();
960 	}
961 
962 	else if (mut_ptr->which == MUT1_SMELL_MON)
963 	{
964 		(void)detect_monsters_normal();
965 	}
966 
967 	else if (mut_ptr->which == MUT1_BLINK)
968 	{
969 		teleport_player(10);
970 	}
971 
972 	else if (mut_ptr->which == MUT1_EAT_ROCK)
973 	{
974 		int x, y, ox, oy;
975 		cave_type *c_ptr;
976 
977 		if (!get_rep_dir(&dir)) return;
978 		y = py + ddy[dir];
979 		x = px + ddx[dir];
980 
981 		/* paranoia */
982 		if (!in_bounds2(x, y)) return;
983 
984 		c_ptr = area(x, y);
985 
986 		if (cave_floor_grid(c_ptr))
987 		{
988 			msgf("You bite into thin air!");
989 			return;
990 		}
991 		else if (cave_perma_grid(c_ptr) || (c_ptr->feat == FEAT_MOUNTAIN))
992 		{
993 			msgf("Ouch!  This wall is harder than your teeth!");
994 			return;
995 		}
996 		else if (c_ptr->m_idx)
997 		{
998 			msgf("There's something in the way!");
999 			return;
1000 		}
1001 		else if (c_ptr->feat == FEAT_TREES)
1002 		{
1003 			msgf("You don't like the woody taste!");
1004 			return;
1005 		}
1006 		else
1007 		{
1008 			if ((c_ptr->feat >= FEAT_CLOSED) && (c_ptr->feat <= FEAT_RUBBLE))
1009 			{
1010 				(void)set_food(p_ptr->food + 3000);
1011 			}
1012 			else if ((c_ptr->feat >= FEAT_MAGMA) &&
1013 					 (c_ptr->feat <= FEAT_QUARTZ_K))
1014 			{
1015 				(void)set_food(p_ptr->food + 5000);
1016 			}
1017 			else
1018 			{
1019 				msgf("This granite is very filling!");
1020 				(void)set_food(p_ptr->food + 10000);
1021 			}
1022 		}
1023 		(void)wall_to_mud(dir);
1024 
1025 		/* Save old location */
1026 		oy = py;
1027 		ox = px;
1028 
1029 		/* Move the player */
1030 		py = y;
1031 		px = x;
1032 
1033 		/* Move the player */
1034 		p_ptr->py = y;
1035 		p_ptr->px = x;
1036 
1037 		/* Notice movement */
1038 		Term_move_player();
1039 
1040 		if (!p_ptr->depth)
1041 		{
1042 			/* Scroll wilderness */
1043 			p_ptr->wilderness_x = px;
1044 			p_ptr->wilderness_y = py;
1045 			move_wild();
1046 		}
1047 
1048 		lite_spot(px, py);
1049 		lite_spot(ox, oy);
1050 
1051 		/* Process fields under the player. */
1052 		field_script(area(px, py), FIELD_ACT_PLAYER_ENTER, "");
1053 
1054 		verify_panel();
1055 
1056 		p_ptr->update |= (PU_VIEW | PU_FLOW | PU_MON_LITE);
1057 		p_ptr->update |= (PU_DISTANCE);
1058 		p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1059 	}
1060 
1061 	else if (mut_ptr->which == MUT1_SWAP_POS)
1062 	{
1063 		if (get_aim_dir(&dir))
1064 		{
1065 			(void)teleport_swap(dir);
1066 		}
1067 	}
1068 
1069 	else if (mut_ptr->which == MUT1_SHRIEK)
1070 	{
1071 		(void)fire_ball(GF_SOUND, 0, 2 * lvl, 8);
1072 		(void)aggravate_monsters(0);
1073 	}
1074 
1075 	else if (mut_ptr->which == MUT1_ILLUMINE)
1076 	{
1077 		(void)lite_area(damroll(2, (lvl / 2)), (lvl / 10) + 1);
1078 	}
1079 
1080 	else if (mut_ptr->which == MUT1_DET_CURSE)
1081 	{
1082 		object_type *o_ptr;
1083 
1084 		OBJ_ITT_START (p_ptr->inventory, o_ptr)
1085 		{
1086 			if (!o_ptr->k_idx) continue;
1087 			if (!cursed_p(o_ptr)) continue;
1088 
1089 			o_ptr->feeling = FEEL_CURSED;
1090 		}
1091 		OBJ_ITT_END;
1092 	}
1093 
1094 	else if (mut_ptr->which == MUT1_BERSERK)
1095 	{
1096 		if (!p_ptr->tim.shero)
1097 		{
1098 			(void)hp_player(30);
1099 		}
1100 
1101 		(void)inc_shero(rand_range(25, 50));
1102 		(void)clear_afraid();
1103 	}
1104 
1105 	else if (mut_ptr->which == MUT1_POLYMORPH)
1106 	{
1107 		do_poly_self();
1108 	}
1109 
1110 	else if (mut_ptr->which == MUT1_MIDAS_TCH)
1111 	{
1112 		(void)alchemy();
1113 	}
1114 
1115 	/* Summon pet molds around the player */
1116 	else if (mut_ptr->which == MUT1_GROW_MOLD)
1117 	{
1118 		int i;
1119 
1120 		for (i = 0; i < 8; i++)
1121 		{
1122 			(void)summon_specific(-1, px, py, lvl, SUMMON_BIZARRE1, FALSE,
1123 								  TRUE, TRUE);
1124 		}
1125 	}
1126 
1127 	else if (mut_ptr->which == MUT1_RESIST)
1128 	{
1129 		int num = lvl / 10;
1130 		int dur = rand_range(20, 40);
1131 
1132 		if (randint0(5) < num)
1133 		{
1134 			(void)inc_oppose_acid(dur);
1135 			num--;
1136 		}
1137 		if (randint0(4) < num)
1138 		{
1139 			(void)inc_oppose_elec(dur);
1140 			num--;
1141 		}
1142 		if (randint0(3) < num)
1143 		{
1144 			(void)inc_oppose_fire(dur);
1145 			num--;
1146 		}
1147 		if (randint0(2) < num)
1148 		{
1149 			(void)inc_oppose_cold(dur);
1150 			num--;
1151 		}
1152 		if (num)
1153 		{
1154 			(void)inc_oppose_pois(dur);
1155 			num--;
1156 		}
1157 	}
1158 
1159 	else if (mut_ptr->which == MUT1_EARTHQUAKE)
1160 	{
1161 		(void)earthquake(px, py, 10);
1162 	}
1163 
1164 	else if (mut_ptr->which == MUT1_EAT_MAGIC)
1165 	{
1166 		object_type *o_ptr;
1167 		int lev;
1168 
1169 		item_tester_hook = item_tester_hook_recharge;
1170 
1171 		/* Get an item */
1172 		q = "Drain which item? ";
1173 		s = "You have nothing to drain.";
1174 
1175 		o_ptr = get_item(q, s, (USE_INVEN | USE_FLOOR));
1176 
1177 		/* Not a valid item */
1178 		if (!o_ptr) return;
1179 
1180 		lev = get_object_level(o_ptr);
1181 
1182 		if (o_ptr->tval == TV_ROD)
1183 		{
1184 			if (o_ptr->pval > 0)
1185 			{
1186 				msgf("You can't absorb energy from a discharged rod.");
1187 			}
1188 			else
1189 			{
1190 				p_ptr->csp += 2 * lev;
1191 				o_ptr->pval = 500;
1192 			}
1193 		}
1194 		else
1195 		{
1196 			if (o_ptr->pval > 0)
1197 			{
1198 				p_ptr->csp += o_ptr->pval * lev;
1199 				o_ptr->pval = 0;
1200 			}
1201 			else
1202 			{
1203 				msgf("There's no energy there to absorb!");
1204 			}
1205 			o_ptr->info |= OB_EMPTY;
1206 		}
1207 
1208 		if (p_ptr->csp > p_ptr->msp)
1209 		{
1210 			p_ptr->csp = p_ptr->msp;
1211 		}
1212 
1213 		/* Notice changes */
1214 		notice_inven();
1215 	}
1216 
1217 	else if (mut_ptr->which == MUT1_WEIGH_MAG)
1218 	{
1219 		report_magics();
1220 	}
1221 
1222 	/* Fake a population explosion. */
1223 	else if (mut_ptr->which == MUT1_STERILITY)
1224 	{
1225 		msgf("You suddenly have a headache!");
1226 		take_hit(rand_range(17, 34), "the strain of forcing abstinence");
1227 		num_repro += MAX_REPRO;
1228 	}
1229 
1230 	else if (mut_ptr->which == MUT1_PANIC_HIT)
1231 	{
1232 		int x, y;
1233 
1234 		if (!get_rep_dir(&dir)) return;
1235 		y = py + ddy[dir];
1236 		x = px + ddx[dir];
1237 
1238 		/* paranoia */
1239 		if (!in_bounds2(x, y)) return;
1240 
1241 		if (area(x, y)->m_idx)
1242 		{
1243 			py_attack(x, y);
1244 			teleport_player(30);
1245 		}
1246 		else
1247 		{
1248 			msgf("You don't see any monster in this direction");
1249 			message_flush();
1250 		}
1251 	}
1252 
1253 	else if (mut_ptr->which == MUT1_DAZZLE)
1254 	{
1255 		(void)stun_monsters(lvl * 4);
1256 		(void)confuse_monsters(lvl * 4);
1257 		(void)turn_monsters(lvl * 4);
1258 	}
1259 
1260 	else if (mut_ptr->which == MUT1_LASER_EYE)
1261 	{
1262 		if (get_aim_dir(&dir))
1263 			(void)fire_beam(GF_LITE, dir, 2 * lvl);
1264 	}
1265 
1266 	else if (mut_ptr->which == MUT1_RECALL)
1267 	{
1268 		word_of_recall();
1269 	}
1270 
1271 	else if (mut_ptr->which == MUT1_BANISH)
1272 	{
1273 		int x, y;
1274 		cave_type *c_ptr;
1275 		monster_type *m_ptr;
1276 		monster_race *r_ptr;
1277 
1278 		if (!get_rep_dir(&dir)) return;
1279 		y = py + ddy[dir];
1280 		x = px + ddx[dir];
1281 
1282 		/* paranoia */
1283 		if (!in_bounds2(x, y)) return;
1284 
1285 		c_ptr = area(x, y);
1286 
1287 		if (!c_ptr->m_idx)
1288 		{
1289 			msgf("You sense no evil there!");
1290 			return;
1291 		}
1292 
1293 		m_ptr = &m_list[c_ptr->m_idx];
1294 		r_ptr = &r_info[m_ptr->r_idx];
1295 
1296 		if (FLAG(r_ptr, RF_EVIL) &&
1297 			!FLAG(r_ptr, RF_QUESTOR) && !FLAG(r_ptr, RF_UNIQUE))
1298 		{
1299 			/* Delete the monster, rather than killing it. */
1300 			delete_monster_idx(c_ptr->m_idx);
1301 			msgf
1302 				("The evil creature vanishes in a puff of sulfurous smoke!");
1303 		}
1304 		else
1305 		{
1306 			msgf("Your invocation is ineffectual!");
1307 		}
1308 	}
1309 	else if (mut_ptr->which == MUT1_COLD_TOUCH)
1310 	{
1311 		int x, y;
1312 		cave_type *c_ptr;
1313 
1314 		if (!get_rep_dir(&dir)) return;
1315 		y = py + ddy[dir];
1316 		x = px + ddx[dir];
1317 
1318 		/* paranoia */
1319 		if (!in_bounds2(x, y)) return;
1320 
1321 		c_ptr = area(x, y);
1322 
1323 		if (!c_ptr->m_idx)
1324 		{
1325 			msgf("You wave your hands in the air.");
1326 			return;
1327 		}
1328 		(void)fire_bolt(GF_COLD, dir, 2 * lvl);
1329 	}
1330 
1331 	/* Gives a multiplier of 2 at first, up to 3 at level 30 */
1332 	else if (mut_ptr->which == MUT1_LAUNCHER)
1333 	{
1334 		do_cmd_throw_aux(2 + lvl / 30);
1335 	}
1336 }
1337 
1338 
1339 /*
1340  * Proces the random mutations
1341  */
mutation_random_aux(const mutation_type * mut_ptr)1342 void mutation_random_aux(const mutation_type *mut_ptr)
1343 {
1344 	if (!one_in_(mut_ptr->chance * 100)) return;
1345 
1346 	if (mut_ptr->which == MUT2_BERS_RAGE)
1347 	{
1348 		disturb(FALSE);
1349 		msgf("RAAAAGHH!");
1350 		msgf("You feel a fit of rage coming over you!");
1351 		(void)inc_shero(10 + randint1(p_ptr->lev));
1352 	}
1353 
1354 	else if (mut_ptr->which == MUT2_COWARDICE)
1355 	{
1356 		if (!((FLAG(p_ptr, TR_RES_FEAR)) ||
1357 				p_ptr->tim.hero || p_ptr->tim.shero))
1358 		{
1359 			disturb(FALSE);
1360 			msgf("It's so dark... so scary!");
1361 			(void)inc_afraid(rand_range(13, 40));
1362 		}
1363 	}
1364 
1365 	else if (mut_ptr->which == MUT2_RTELEPORT)
1366 	{
1367 		if (!(FLAG(p_ptr, TR_RES_NEXUS)) &&
1368 			!(p_ptr->muta1 & MUT1_VTELEPORT) &&
1369 			!(FLAG(p_ptr, TR_NO_TELE)))
1370 		{
1371 			disturb(FALSE);
1372 
1373 			/* Teleport player */
1374 			msgf("Your position suddenly seems very uncertain...");
1375 			message_flush();
1376 			teleport_player(40);
1377 		}
1378 	}
1379 
1380 	else if (mut_ptr->which == MUT2_ALCOHOL)
1381 	{
1382 		if (!(FLAG(p_ptr, TR_RES_CONF)) &&
1383 			!(FLAG(p_ptr, TR_RES_CHAOS)))
1384 		{
1385 			disturb(FALSE);
1386 			p_ptr->redraw |= PR_EXTRA;
1387 			msgf("You feel a SSSCHtupor cOmINg over yOu... *HIC*!");
1388 		}
1389 
1390 		if (!(FLAG(p_ptr, TR_RES_CONF)))
1391 		{
1392 			(void)inc_confused(rand_range(15, 35));
1393 		}
1394 
1395 		if (!(FLAG(p_ptr, TR_RES_CHAOS)))
1396 		{
1397 			if (one_in_(20))
1398 			{
1399 				message_flush();
1400 				if (one_in_(3)) (void)lose_all_info();
1401 				else
1402 					wiz_dark();
1403 				teleport_player(100);
1404 				wiz_dark();
1405 				msgf("You wake up somewhere with a sore head...");
1406 				msgf("You can't remember a thing, or how you got here!");
1407 			}
1408 			else
1409 			{
1410 				if (one_in_(3))
1411 				{
1412 					msgf("Thishcischs GooDSChtuff!");
1413 					(void)inc_image(rand_range(150, 300));
1414 				}
1415 			}
1416 		}
1417 	}
1418 
1419 	else if (mut_ptr->which == MUT2_HALLU)
1420 	{
1421 		if (!(FLAG(p_ptr, TR_RES_CHAOS)))
1422 		{
1423 			disturb(FALSE);
1424 			p_ptr->redraw |= PR_EXTRA;
1425 			(void)inc_image(rand_range(20, 70));
1426 		}
1427 	}
1428 
1429 	else if (mut_ptr->which == MUT2_FLATULENT)
1430 	{
1431 		disturb(FALSE);
1432 
1433 		msgf("BRRAAAP! Oops.");
1434 		message_flush();
1435 		(void)fire_ball(GF_POIS, 0, p_ptr->lev, 3);
1436 	}
1437 
1438 	else if ((mut_ptr->which == MUT2_PROD_MANA) &&
1439 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1440 	{
1441 		int dire = 0;
1442 		disturb(FALSE);
1443 		msgf("Magical energy flows through you! You must release it!");
1444 		flush();
1445 		message_flush();
1446 		(void)get_hack_dir(&dire);
1447 		(void)fire_ball(GF_MANA, dire, p_ptr->lev * 2, 3);
1448 	}
1449 
1450 	else if ((mut_ptr->which == MUT2_ATT_DEMON) &&
1451 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1452 	{
1453 		bool pet = (one_in_(6));
1454 
1455 		if (summon_specific((pet ? -1 : 0), p_ptr->px, p_ptr->py,
1456 							p_ptr->depth, SUMMON_DEMON, TRUE, FALSE, pet))
1457 		{
1458 			msgf("You have attracted a demon!");
1459 			disturb(FALSE);
1460 		}
1461 	}
1462 
1463 	else if (mut_ptr->which == MUT2_SPEED_FLUX)
1464 	{
1465 		disturb(FALSE);
1466 		if (one_in_(2))
1467 		{
1468 			msgf("You feel less energetic.");
1469 			if (p_ptr->tim.fast > 0)
1470 			{
1471 				(void)clear_fast();
1472 			}
1473 			else
1474 			{
1475 				(void)inc_slow(rand_range(10, 40));
1476 			}
1477 		}
1478 		else
1479 		{
1480 			msgf("You feel more energetic.");
1481 			if (p_ptr->tim.slow > 0)
1482 			{
1483 				(void)clear_slow();
1484 			}
1485 			else
1486 			{
1487 				(void)inc_fast(rand_range(10, 40));
1488 			}
1489 		}
1490 		message_flush();
1491 	}
1492 
1493 	else if (mut_ptr->which == MUT2_BANISH_ALL)
1494 	{
1495 		disturb(FALSE);
1496 		msgf("You suddenly feel almost lonely.");
1497 		(void)banish_monsters(100);
1498 		message_flush();
1499 	}
1500 
1501 	else if (mut_ptr->which == MUT2_EAT_LIGHT)
1502 	{
1503 		object_type *o_ptr;
1504 		cave_type *c_ptr = area(p_ptr->px, p_ptr->py);
1505 
1506 		msgf("A shadow passes over you.");
1507 		message_flush();
1508 
1509 		/* Absorb light from the current possition */
1510 		if (c_ptr->info & CAVE_GLOW)
1511 		{
1512 			(void)hp_player(10);
1513 		}
1514 
1515 		o_ptr = &p_ptr->equipment[EQUIP_LITE];
1516 
1517 		/* Absorb some fuel in the current lite */
1518 		if (o_ptr->tval == TV_LITE)
1519 		{
1520 			/* Use some fuel (except on artifacts) */
1521 			if (!(FLAG(o_ptr, TR_INSTA_ART)) && (o_ptr->timeout > 0))
1522 			{
1523 				/* Heal the player a bit */
1524 				(void)hp_player(o_ptr->timeout / 20);
1525 
1526 				/* Decrease life-span of lite */
1527 				o_ptr->timeout /= 2;
1528 
1529 				msgf("You absorb energy from your light!");
1530 
1531 				/* Notice interesting fuel steps */
1532 				notice_lite_change(o_ptr);
1533 			}
1534 		}
1535 
1536 		/*
1537 		 * Unlite the area (radius 10) around player and
1538 		 * do 50 points damage to every affected monster
1539 		 */
1540 		(void)unlite_area(50, 10);
1541 	}
1542 
1543 	else if ((mut_ptr->which == MUT2_ATT_ANIMAL) &&
1544 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1545 	{
1546 		bool pet = (one_in_(3));
1547 
1548 		if (summon_specific((pet ? -1 : 0), p_ptr->px, p_ptr->py,
1549 							p_ptr->depth, SUMMON_ANIMAL, TRUE, FALSE, pet))
1550 		{
1551 			msgf("You have attracted an animal!");
1552 			disturb(FALSE);
1553 		}
1554 	}
1555 
1556 	else if ((mut_ptr->which == MUT2_RAW_CHAOS) &&
1557 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1558 	{
1559 		disturb(FALSE);
1560 		msgf("You feel the world warping around you!");
1561 		message_flush();
1562 		(void)fire_ball(GF_CHAOS, 0, p_ptr->lev, 8);
1563 	}
1564 
1565 	else if (mut_ptr->which == MUT2_NORMALITY)
1566 	{
1567 		if (!lose_mutation(0))
1568 		{
1569 			msgf("You feel oddly normal.");
1570 		}
1571 	}
1572 
1573 	else if ((mut_ptr->which == MUT2_WRAITH) &&
1574 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1575 	{
1576 		disturb(FALSE);
1577 		msgf("You feel insubstantial!");
1578 		message_flush();
1579 		(void)inc_wraith_form(rand_range(p_ptr->lev / 2, p_ptr->lev));
1580 	}
1581 
1582 	else if (mut_ptr->which == MUT2_POLY_WOUND)
1583 	{
1584 		do_poly_wounds();
1585 	}
1586 
1587 	else if (mut_ptr->which == MUT2_WASTING)
1588 	{
1589 		int which_stat = randint0(6);
1590 		int sustained = FALSE;
1591 
1592 		switch (which_stat)
1593 		{
1594 			case A_STR:
1595 				if (FLAG(p_ptr, TR_SUST_STR)) sustained = TRUE;
1596 				break;
1597 			case A_INT:
1598 				if (FLAG(p_ptr, TR_SUST_INT)) sustained = TRUE;
1599 				break;
1600 			case A_WIS:
1601 				if (FLAG(p_ptr, TR_SUST_WIS)) sustained = TRUE;
1602 				break;
1603 			case A_DEX:
1604 				if (FLAG(p_ptr, TR_SUST_DEX)) sustained = TRUE;
1605 				break;
1606 			case A_CON:
1607 				if (FLAG(p_ptr, TR_SUST_CON)) sustained = TRUE;
1608 				break;
1609 			case A_CHR:
1610 				if (FLAG(p_ptr, TR_SUST_CHR)) sustained = TRUE;
1611 				break;
1612 			default:
1613 				msgf("Invalid stat chosen!");
1614 				sustained = TRUE;
1615 		}
1616 
1617 		if (!sustained)
1618 		{
1619 			disturb(FALSE);
1620 			msgf("You can feel yourself wasting away!");
1621 			message_flush();
1622 			(void)dec_stat(which_stat, rand_range(6, 12), 0);
1623 		}
1624 	}
1625 
1626 	else if ((mut_ptr->which == MUT2_ATT_DRAGON) &&
1627 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1628 	{
1629 		bool pet = (one_in_(5));
1630 
1631 		if (summon_specific((pet ? -1 : 0), p_ptr->px, p_ptr->py,
1632 							p_ptr->depth, SUMMON_DRAGON, TRUE, FALSE, pet))
1633 		{
1634 			msgf("You have attracted a dragon!");
1635 			disturb(FALSE);
1636 		}
1637 	}
1638 
1639 	else if ((mut_ptr->which == MUT2_WEIRD_MIND) &&
1640 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1641 	{
1642 		if (p_ptr->tim.esp > 0)
1643 		{
1644 			msgf("Your mind feels cloudy!");
1645 			(void)clear_tim_esp();
1646 		}
1647 		else
1648 		{
1649 			msgf("Your mind expands!");
1650 			(void)inc_tim_esp(p_ptr->lev);
1651 		}
1652 	}
1653 
1654 	else if ((mut_ptr->which == MUT2_NAUSEA) &&
1655 				!(FLAG(p_ptr, TR_SLOW_DIGEST)))
1656 	{
1657 		disturb(FALSE);
1658 		msgf("Your stomach roils, and you lose your lunch!");
1659 		message_flush();
1660 		(void)set_food(PY_FOOD_WEAK);
1661 	}
1662 
1663 	else if ((mut_ptr->which == MUT2_WALK_SHAD) &&
1664 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1665 	{
1666 		alter_reality();
1667 	}
1668 
1669 	else if (mut_ptr->which == MUT2_WARNING)
1670 	{
1671 		int danger_amount = 0;
1672 		int monster;
1673 
1674 		for (monster = 0; monster < m_max; monster++)
1675 		{
1676 			monster_type *m_ptr = &m_list[monster];
1677 			monster_race *r_ptr = &r_info[m_ptr->r_idx];
1678 
1679 			/* Paranoia -- Skip dead monsters */
1680 			if (!m_ptr->r_idx) continue;
1681 
1682 			if (r_ptr->level >= p_ptr->lev)
1683 			{
1684 				danger_amount += r_ptr->level - p_ptr->lev + 1;
1685 			}
1686 		}
1687 
1688 		if (danger_amount > 100)
1689 			msgf("You feel utterly terrified!");
1690 		else if (danger_amount > 50)
1691 			msgf("You feel terrified!");
1692 		else if (danger_amount > 20)
1693 			msgf("You feel very worried!");
1694 		else if (danger_amount > 10)
1695 			msgf("You feel paranoid!");
1696 		else if (danger_amount > 5)
1697 			msgf("You feel almost safe.");
1698 		else
1699 			msgf("You feel lonely.");
1700 	}
1701 
1702 	else if ((mut_ptr->which == MUT2_INVULN) &&
1703 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1704 	{
1705 		disturb(FALSE);
1706 		msgf("You feel invincible!");
1707 		message_flush();
1708 		(void)inc_invuln(rand_range(8, 16));
1709 	}
1710 
1711 	else if (mut_ptr->which == MUT2_SP_TO_HP)
1712 	{
1713 		int wounds = p_ptr->mhp - p_ptr->chp;
1714 
1715 		if (wounds > 0)
1716 		{
1717 			int healing = p_ptr->csp;
1718 
1719 			if (healing > wounds)
1720 			{
1721 				healing = wounds;
1722 			}
1723 
1724 			(void)hp_player(healing);
1725 			p_ptr->csp -= healing;
1726 		}
1727 	}
1728 
1729 	else if ((mut_ptr->which == MUT2_HP_TO_SP) &&
1730 		!(FLAG(p_ptr, TR_NO_MAGIC)))
1731 	{
1732 		int wounds = p_ptr->msp - p_ptr->csp;
1733 
1734 		if (wounds > 0)
1735 		{
1736 			int healing = p_ptr->chp;
1737 
1738 			if (healing > wounds)
1739 			{
1740 				healing = wounds;
1741 			}
1742 
1743 			p_ptr->csp += healing;
1744 			take_hit(healing, "blood rushing to the head");
1745 		}
1746 	}
1747 
1748 	else if (mut_ptr->which == MUT2_DISARM)
1749 	{
1750 		object_type *o_ptr;
1751 
1752 		disturb(FALSE);
1753 		msgf("You trip over your own feet!");
1754 		take_hit(randint1(p_ptr->rp.wt / 6), "tripping");
1755 
1756 		message_flush();
1757 		o_ptr = &p_ptr->equipment[EQUIP_WIELD];
1758 		if ((o_ptr->k_idx) && !cursed_p(o_ptr))
1759 		{
1760 			msgf("You drop your weapon!");
1761 			inven_drop(o_ptr, 1);
1762 		}
1763 	}
1764 }
1765 
1766 /*
1767  * Constant mutation effects
1768  *
1769  * Note that the commented out effects are actually handled in player_flags().
1770  */
mutation_effect(void)1771 void mutation_effect(void)
1772 {
1773 	if (p_ptr->muta1 & MUT1_HYPN_GAZE)
1774 	{
1775 		p_ptr->stat[A_WIS].add -= 1;
1776 	}
1777 
1778 	if (p_ptr->muta1 & MUT1_TELEKINES)
1779 	{
1780 		p_ptr->stat[A_CON].add -= 1;
1781 	}
1782 
1783 	if (p_ptr->muta1 & MUT1_MIND_BLST)
1784 	{
1785 		p_ptr->stat[A_STR].add -= 1;
1786 	}
1787 
1788 	if (p_ptr->muta1 & MUT1_RADIATION)
1789 	{
1790 		p_ptr->stat[A_CON].add -= 1;
1791 	}
1792 
1793 	if (p_ptr->muta1 & MUT1_SHRIEK)
1794 	{
1795 		p_ptr->stat[A_CHR].add -= 1;
1796 	}
1797 
1798 	if (p_ptr->muta1 & MUT1_ILLUMINE)
1799 	{
1800 		p_ptr->skills[SKILL_STL] -= 1;
1801 	}
1802 
1803 	if (p_ptr->muta1 & MUT1_BERSERK)
1804 	{
1805 		p_ptr->stat[A_WIS].add -= 1;
1806 	}
1807 
1808 	if (p_ptr->muta1 & MUT1_MIDAS_TCH)
1809 	{
1810 		p_ptr->stat[A_CHR].add -= 1;
1811 		p_ptr->stat[A_WIS].add -= 1;
1812 	}
1813 
1814 	if (p_ptr->muta1 & MUT1_RESIST)
1815 	{
1816 		p_ptr->skills[SKILL_SAV] -= 10;
1817 	}
1818 
1819 	if (p_ptr->muta1 & MUT1_EARTHQUAKE)
1820 	{
1821 		p_ptr->stat[A_WIS].add -= 1;
1822 	}
1823 
1824 	if (p_ptr->muta1 & MUT1_STERILITY)
1825 	{
1826 		p_ptr->stat[A_INT].add -= 1;
1827 	}
1828 
1829 	if (p_ptr->muta1 & MUT1_DAZZLE)
1830 	{
1831 		p_ptr->skills[SKILL_STL] -= 1;
1832 	}
1833 
1834 	if (p_ptr->muta1 & MUT1_LASER_EYE)
1835 	{
1836 		p_ptr->skills[SKILL_SNS] -= 10;
1837 	}
1838 
1839 	if (p_ptr->muta1 & MUT1_COLD_TOUCH)
1840 	{
1841 		p_ptr->stat[A_DEX].add -= 1;
1842 	}
1843 
1844 	if (p_ptr->muta1 & MUT1_LAUNCHER)
1845 	{
1846 		p_ptr->stat[A_DEX].add -= 1;
1847 	}
1848 
1849 	if (p_ptr->muta2 & MUT2_SCOR_TAIL)
1850 	{
1851 		p_ptr->stat[A_CHR].add -= 2;
1852 	}
1853 
1854 	if (p_ptr->muta2 & MUT2_TRUNK)
1855 	{
1856 		p_ptr->stat[A_CHR].add -= 1;
1857 	}
1858 
1859 	if (p_ptr->muta2 & MUT2_TENTACLES)
1860 	{
1861 		p_ptr->stat[A_DEX].add += 1;
1862 		p_ptr->stat[A_CHR].add -= 2;
1863 	}
1864 
1865 	if (p_ptr->muta2 & MUT2_WRAITH)
1866 	{
1867 		p_ptr->stat[A_CON].add -= 3;
1868 	}
1869 
1870 	if (p_ptr->muta2 & MUT2_INVULN)
1871 	{
1872 		p_ptr->stat[A_WIS].add -= 2;
1873 	}
1874 
1875 
1876 	/* Hyper Strength */
1877 	if (p_ptr->muta3 & MUT3_HYPER_STR)
1878 	{
1879 		p_ptr->stat[A_STR].add += 4;
1880 		p_ptr->stat[A_INT].add -= 1;
1881 		p_ptr->stat[A_WIS].add -= 1;
1882 	}
1883 
1884 	/* Puny */
1885 	if (p_ptr->muta3 & MUT3_PUNY)
1886 	{
1887 		p_ptr->stat[A_STR].add -= 4;
1888 		p_ptr->stat[A_DEX].add += 2;
1889 	}
1890 
1891 	/* Living computer */
1892 	if (p_ptr->muta3 & MUT3_HYPER_INT)
1893 	{
1894 		p_ptr->stat[A_INT].add += 4;
1895 		p_ptr->stat[A_WIS].add += 4;
1896 		/* p_ptr->flags[3] |= TR3_HURT_ELEC */
1897 	}
1898 
1899 	/* Moronic */
1900 	if (p_ptr->muta3 & MUT3_MORONIC)
1901 	{
1902 		p_ptr->stat[A_INT].add -= 4;
1903 		p_ptr->stat[A_WIS].add -= 4;
1904 		/* p_ptr->flags[1] |= TR1_RES_FEAR */
1905 		/* p_ptr->flags[1] |= TR1_RES_CONF */
1906 	}
1907 
1908 	if (p_ptr->muta3 & MUT3_RESILIENT)
1909 	{
1910 		p_ptr->stat[A_CON].add += 4;
1911 	}
1912 
1913 	if (p_ptr->muta3 & MUT3_XTRA_FAT)
1914 	{
1915 		p_ptr->stat[A_CON].add += 2;
1916 		p_ptr->pspeed -= 2;
1917 	}
1918 
1919 	if (p_ptr->muta3 & MUT3_ALBINO)
1920 	{
1921 		p_ptr->stat[A_CON].add -= 4;
1922 		/* p_ptr->flags[1] |= TR1_RES_DARK */
1923 	}
1924 
1925 	if (p_ptr->muta3 & MUT3_FLESH_ROT)
1926 	{
1927 		p_ptr->stat[A_CON].add -= 2;
1928 		p_ptr->stat[A_CHR].add -= 1;
1929 		/* p_ptr->flags[2] &= ~(TR2_REGEN); */
1930 		/* Cancel innate regeneration */
1931 	}
1932 
1933 	if (p_ptr->muta3 & MUT3_SILLY_VOI)
1934 	{
1935 		p_ptr->stat[A_CHR].add -= 4;
1936 	}
1937 
1938 	if (p_ptr->muta3 & MUT3_BLANK_FAC)
1939 	{
1940 		p_ptr->stat[A_CHR].add -= 1;
1941 		/* p_ptr->Flags3 |= TR2_SEE_INVIS; */
1942 	}
1943 
1944 	if (p_ptr->muta3 & MUT3_XTRA_EYES)
1945 	{
1946 		p_ptr->skills[SKILL_FOS] += 15;
1947 		p_ptr->skills[SKILL_SNS] += 15;
1948 		p_ptr->stat[A_CHR].add -= 1;
1949 	}
1950 
1951 	if (p_ptr->muta3 & MUT3_MAGIC_RES)
1952 	{
1953 		p_ptr->skills[SKILL_SAV] += (15 + (p_ptr->lev / 5));
1954 	}
1955 
1956 	if (p_ptr->muta3 & MUT3_XTRA_NOIS)
1957 	{
1958 		p_ptr->skills[SKILL_STL] -= 3;
1959 	}
1960 
1961 	if (p_ptr->muta3 & MUT3_INFRAVIS)
1962 	{
1963 		p_ptr->see_infra += 3;
1964 	}
1965 
1966 	if (p_ptr->muta3 & MUT3_XTRA_LEGS)
1967 	{
1968 		p_ptr->pspeed += 3;
1969 		p_ptr->stat[A_DEX].add -= 1;
1970 	}
1971 
1972 	if (p_ptr->muta3 & MUT3_SHORT_LEG)
1973 	{
1974 		p_ptr->stat[A_CON].add += 1;
1975 		p_ptr->pspeed -= 3;
1976 	}
1977 
1978 	if (p_ptr->muta3 & MUT3_ELEC_TOUC)
1979 	{
1980 		p_ptr->stat[A_CON].add -= 1;
1981 		/* SET_FLAG(p_ptr, TR_SH_ELEC) */;
1982 	}
1983 
1984 	if (p_ptr->muta3 & MUT3_FIRE_BODY)
1985 	{
1986 		p_ptr->stat[A_DEX].add -= 1;
1987 		/* SET_FLAG(p_ptr, TR_SH_FIRE) */;
1988 		/* SET_FLAG(p_ptr, TR_LITE) */;
1989 	}
1990 
1991 	if (p_ptr->muta3 & MUT3_WART_SKIN)
1992 	{
1993 		p_ptr->stat[A_CHR].add -= 2;
1994 		p_ptr->to_a += 5;
1995 		p_ptr->dis_to_a += 5;
1996 	}
1997 
1998 	if (p_ptr->muta3 & MUT3_SCALES)
1999 	{
2000 		p_ptr->stat[A_CHR].add -= 1;
2001 		p_ptr->to_a += 10;
2002 		p_ptr->dis_to_a += 10;
2003 	}
2004 
2005 	if (p_ptr->muta3 & MUT3_IRON_SKIN)
2006 	{
2007 		p_ptr->stat[A_DEX].add -= 3;
2008 		p_ptr->to_a += 25;
2009 		p_ptr->dis_to_a += 25;
2010 	}
2011 
2012 	if (p_ptr->muta3 & MUT3_WINGS)
2013 	{
2014 		p_ptr->stat[A_CON].add -= 1;
2015 		p_ptr->stat[A_CHR].add += 3;
2016 		/* SET_FLAG(p_ptr, TR_FEATHER) */;
2017 	}
2018 
2019 	if (p_ptr->muta3 & MUT3_FEARLESS)
2020 	{
2021 		/* SET_FLAG(p_ptr, TR_RES_FEAR) */;
2022 	}
2023 
2024 	if (p_ptr->muta3 & MUT3_REGEN)
2025 	{
2026 		/* SET_FLAG(p_ptr, TR_REGEN) */;
2027 	}
2028 
2029 	if (p_ptr->muta3 & MUT3_ESP)
2030 	{
2031 		p_ptr->stat[A_CON].add -= 1;
2032 		/* SET_FLAG(p_ptr, TR_TELEPATHY) */;
2033 	}
2034 
2035 	if (p_ptr->muta3 & MUT3_LIMBER)
2036 	{
2037 		p_ptr->stat[A_DEX].add += 3;
2038 		p_ptr->stat[A_STR].add -= 1;
2039 	}
2040 
2041 	if (p_ptr->muta3 & MUT3_ARTHRITIS)
2042 	{
2043 		p_ptr->stat[A_DEX].add -= 3;
2044 	}
2045 
2046 	if (p_ptr->muta3 & MUT3_MOTION)
2047 	{
2048 		/* SET_FLAG(p_ptr, TR_FREE_ACT) */;
2049 		p_ptr->skills[SKILL_STL] += 1;
2050 	}
2051 
2052 	if (p_ptr->muta3 & MUT3_ILL_NORM)
2053 	{
2054 		p_ptr->stat[A_CHR].add = 0;
2055 	}
2056 }
2057