File: execute.c

package info (click to toggle)
spellcast 1.0-22
  • links: PTS
  • area: non-free
  • in suites: bookworm, bullseye, buster, sid, stretch
  • size: 728 kB
  • ctags: 834
  • sloc: ansic: 7,660; makefile: 94; sh: 11
file content (1188 lines) | stat: -rw-r--r-- 36,354 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
#include <stdio.h>
#include <strings.h>

#include "handwave.h"
#include "internal.h"

#include <libintl.h>
#define _(String) gettext (String)
#define _(String) gettext (String)

char exbuf[2048], exbuf2[2048], exbuf3[2048];
static char smallbuf[512];
static int summonelq;

static void exec_counters(), exec_summons(), check_elements(), exec_cancels(), exec_protects();
extern void exec_enchants(), exec_attacks(), exec_heals();

void clear_round(fred)
union being *fred;
{
    int ix;

    fred->both.enchant_caster = (-1);
    fred->both.enchant_ppend = 0;
    fred->both.raisedead_caster = (-1);
    fred->both.fl_resist_heat = 0;
    fred->both.fl_resist_cold = 0;
    fred->both.fl_resist_icestorm = 0;

    for (ix=0; ix<NUMSPELLS; ix++)
	fred->both.zaplist[ix] = 0;
}

/* add a zaplist entry. If the spell is a control spell, set the enchant_caster also; this can only store one value, but that's ok, since if there's more than one control spell they all fail. If the spell is raise dead, set raisedead_caster (only used when raising dead monsters) */
static void set_zap_flag(self, spel, spelnum)
struct realgame *self;
struct castspell *spel;
int spelnum;
{
    int set_enchanter=0, set_ppend=0;
    struct permstats *perm = NULL;
    int *ppend = NULL;

    if (spelnum==(-1))
	spelnum = spel->spellnum;

    if (spelnum==SP__PARALYSIS || spelnum==SP__CHARM_PERSON || spelnum==SP__CHARM_MONSTER) {
	set_enchanter=1;
    }

    if (spelnum==SP__PARALYSIS || spelnum==SP__CHARM_PERSON || spelnum==SP__CHARM_MONSTER || spelnum==SP__FEAR || spelnum==SP__AMNESIA || spelnum==SP__CONFUSION) {
	set_ppend=1;
    }

    switch (spel->targettype) {
	case QuVal_Target_Wizard:
	    perm = &(self->wiz[spel->target]->perm);
	    ppend = &(self->wiz[spel->target]->enchant_ppend);
	    self->wiz[spel->target]->zaplist[spelnum]++;
	    if (set_enchanter) 
		self->wiz[spel->target]->enchant_caster = spel->caster;
	    if (set_ppend)
		*ppend = spel->permanent;
	    if (spelnum==SP__RAISE_DEAD)
		self->wiz[spel->target]->raisedead_caster = spel->caster;
	    break;
	case QuVal_Target_Creature:
	    perm = &(self->cre[spel->target].perm);
	    ppend = &(self->cre[spel->target].enchant_ppend);
	    self->cre[spel->target].zaplist[spelnum]++;
	    if (set_enchanter) 
		self->cre[spel->target].enchant_caster = spel->caster;
	    if (set_ppend)
		*ppend = spel->permanent;
	    if (spelnum==SP__RAISE_DEAD)
		self->cre[spel->target].raisedead_caster = spel->caster;
	    break;
	default: /* up-in-air or area-effect */
	    break;
    }

    if (spel->permanent && perm) {
	struct wizard *wiz = self->wiz[spel->target];
	switch (spelnum) {
	    case SP__AMNESIA:
	    case SP__FEAR:
	    case SP__CHARM_PERSON:
	    case SP__CHARM_MONSTER:
	    case SP__PARALYSIS:
	    case SP__CONFUSION:
		break;
	    case SP__HASTE:
		perm->fl_haste = 1;
		break;
	    case SP__PROTECTION_FROM_EVIL:
		perm->fl_prot_evil = 1;
		break;
	    case SP__RESIST_HEAT:
		perm->fl_resist_heat = 1;
		break;
	    case SP__RESIST_COLD:
		perm->fl_resist_cold = 1;
		break;
	    case SP__INVISIBILITY:
		perm->fl_invisibility = 1;
		break;
	    case SP__BLINDNESS:
		perm->fl_blindness = 1;
		break;
	    default:
		printf(_("ERROR: do not know how to permanent %d.\n"), spelnum);
		break;
	}
    }
}

char *pro_himself(gender)
int gender;
{
    switch (gender) {
	case Gender_NONE:
	    return _("itself");
	case Gender_MALE:
	    return _("himself");
	case Gender_FEMALE:
	    return _("herself");
	case Gender_NEUTER:
	    return _("hirself");
	default:
	    return _("ERROR-himself");
    }
}

char *pro_him(gender)
int gender;
{
    switch (gender) {
	case Gender_NONE:
	    return _("it");
	case Gender_MALE:
	    return _("him");
	case Gender_FEMALE:
	    return _("her");
	case Gender_NEUTER:
	    return _("hir");
	default:
	    return _("ERROR-him");
    }
}

char *pro_he(gender)
int gender;
{
    switch (gender) {
	case Gender_NONE:
	    return _("it");
	case Gender_MALE:
	    return _("he");
	case Gender_FEMALE:
	    return _("she");
	case Gender_NEUTER:
	    return _("ke");
	default:
	    return _("ERROR-he");
    }
}

char *pro_his(gender) /* his head, not the head of his */
int gender;
{
    switch (gender) {
	case Gender_NONE:
	    return _("its");
	case Gender_MALE:
	    return _("his");
	case Gender_FEMALE:
	    return _("her");
	case Gender_NEUTER:
	    return _("hir");
	default:
	    return _("ERROR-his");
    }
}

char *number_name(num)
int num;
{
    static char buf[16];

    switch (num) {
	case 0:
	    return _("zero");
	case 1:
	    return _("one");
	case 2:
	    return _("two");
	case 3:
	    return _("three");
	case 4:
	    return _("four");
	case 5:
	    return _("five");
	case 6:
	    return _("six");
	case 7:
	    return _("seven");
	case 8:
	    return _("eight");
	case 9:
	    return _("nine");
	case 10:
	    return _("ten");
	default:
	    sprintf(buf, _("%d"), num);
	    return buf;
    }
}

static void list_mind_spells(buf, zapl)
char *buf;
int *zapl;
{
    int any = 0;
    int ix, spel;
    static int spelist[6] = {SP__AMNESIA, SP__CONFUSION, SP__CHARM_PERSON, SP__CHARM_MONSTER, SP__PARALYSIS, SP__FEAR};
    strcpy(buf, "");

    for (ix=0; ix<6; ix++) {
	spel = spelist[ix];
	if (zapl[spel]) {
	    if (any)
		strcat(buf, ", ");
	    any = 1;
	    if (zapl[spel]==1) {
		strcat(buf, _(spelllist[spel].name));
	    }
	    else {
		sprintf(smallbuf, _("%s %s"), number_name(zapl[spel]), _(spelllist[spel].name));
		strcat(buf, smallbuf);
	    }
	}
    }
}

static int check_visibility(self, mcaster, mtarget, ctmp)
struct realgame *self;
struct wizard *mcaster;
union being *mtarget;
struct castspell *ctmp;
{
    if (!mtarget) 
	return 1; /* you can always see up-in-the-air */

    if ((union being *)mcaster != mtarget
	&& (mtarget->both.invisibility || mcaster->blindness)) {
	sprintf(exbuf, _("You are unable to see %s; your %s goes wild.\n"), mtarget->both.name, _(spelllist[ctmp->spellnum].name));
	sprintf(exbuf2, _("%s is unable to see you; %s %s goes wild.\n"), mcaster->name, pro_his(mcaster->gender), _(spelllist[ctmp->spellnum].name));
	sprintf(exbuf3, _("%s is unable to see %s; %s %s goes wild.\n"), mcaster->name, mtarget->both.name, pro_his(mcaster->gender), _(spelllist[ctmp->spellnum].name));
	if (ctmp->targettype==QuVal_Target_Wizard)
	    PrintMsg3(ctmp->caster, ctmp->target, exbuf, exbuf2, exbuf3);
	else
	    PrintMsg2(ctmp->caster, exbuf, exbuf3);
	return 0;
    }
    return 1;
}

void execute_spells(self)
struct realgame *self;
{
    struct castspell *ctmp, **pt;
    int ix, jx, wiznum;
    int *zapl;
    union being *mtarget;
    struct wizard *mcaster;

    for (ctmp = self->castlist; ctmp; ctmp = ctmp->next) {
	char *handage;
	switch (ctmp->handage) {
	    case MASK_LEFT:
		handage = _("with the left hand");
		break;
	    case MASK_RIGHT:
		handage = _("with the right hand");
		break;
	    case MASK_TWOHAND:
		handage = _("with both hands");
		break;
	    case 0:
		handage = _("from a Delayed Effect");
		break;
	    case MASK_LEFT|MASK_RIGHT:
		handage = _("ERROR:BOTH??? hands");
		break;
	    default:
		handage = _("ERROR:NEITHER??? hand");
		break;
	}
	switch (ctmp->targettype) {
	    case -1:
		strcpy(smallbuf, _("over the arena"));
		break;
	    case 0:
		strcpy(smallbuf, _("up into the air"));
		break;
	    default:
		if (ctmp->targettype==QuVal_Target_Wizard && ctmp->target==ctmp->caster) {
		    strcpy(smallbuf, _("at ")); 
		    strcat(smallbuf, pro_himself(self->wiz[ctmp->caster]->gender)); 
		}
		else {
		    switch (ctmp->targettype) {
			case QuVal_Target_Wizard:
			    mtarget = (union being *)self->wiz[ctmp->target];
			    break;
			case QuVal_Target_Creature:
			    mtarget = (union being *)&(self->cre[ctmp->target]);
			    break;
			default:
			    mtarget = NULL;
			    break;
		    }
		    sprintf(smallbuf, _("at %s"), mtarget->both.name);
		}
		break;
	}
	if (ctmp->spellnum == SP__STAB)
	    sprintf(exbuf, _("%s stabs (%s) %s.\n"), self->wiz[ctmp->caster]->name, handage, smallbuf);
	else
	    sprintf(exbuf, _("%s casts %s%s (%s) %s.\n"), self->wiz[ctmp->caster]->name, ((ctmp->permanent)?_("Permanent "):""), _(spelllist[ctmp->spellnum].name), handage, smallbuf);
	PrintMsg(exbuf);
    }

    /* CLEAR ROUND DATA */
    self->fl_icestorm = 0;
    self->fl_firestorm = 0;
    self->fl_dispelmagic = 0;
    for (ix=0; ix<self->numplayers; ix++) 
	clear_round(self->wiz[ix]);
    for (ix=0; ix<self->numcres; ix++) 
	clear_round(&self->cre[ix]);

    /* check DISPEL MAGIC, MAGIC MIRROR, COUNTER_SPELL */
    for (ctmp = self->castlist; ctmp; ctmp = ctmp->next) {

	switch (ctmp->targettype) {
	    case QuVal_Target_Wizard:
		mtarget = (union being *)self->wiz[ctmp->target];
		break;
	    case QuVal_Target_Creature:
		mtarget = (union being *)&(self->cre[ctmp->target]);
		break;
	    default:
		mtarget = NULL;
		break;
	}
	mcaster = self->wiz[ctmp->caster];

	/* convert counter_spell2 to counter_spell */
	if (ctmp->spellnum==SP__COUNTER_SPELL2)
	    ctmp->spellnum = SP__COUNTER_SPELL;

	if (ctmp->spellnum==SP__DISPEL_MAGIC) {
	    if (check_visibility(self, mcaster, mtarget, ctmp)) {
		self->fl_dispelmagic = 1;
		set_zap_flag(self, ctmp, SP__SHIELD); /* auto-shield */
	    }
	}
	else if (ctmp->spellnum==SP__COUNTER_SPELL) {
	    if (check_visibility(self, mcaster, mtarget, ctmp)) {
		set_zap_flag(self, ctmp, SP__COUNTER_SPELL);
	    }
	}
	else if (ctmp->spellnum==SP__MAGIC_MIRROR) {
	    if (check_visibility(self, mcaster, mtarget, ctmp)) {
		set_zap_flag(self, ctmp, SP__MAGIC_MIRROR);
	    }
	}
    }

    if (self->fl_dispelmagic)
	PrintMsg(_("The magical energies in the arena fade away.\n"));

    /* EXECUTE DISPEL MAGIC, MAGIC MIRROR, COUNTER_SPELL : all beings and corpses. This sets the zapl[] for those spells. */
    for (ix=0; ix<self->numplayers; ix++) {
	exec_counters(self, self->wiz[ix], ix, 1);
    }
    for (ix=0; ix<self->numcres; ix++) {
	exec_counters(self, &self->cre[ix], ix, 0);
    }

    /* set up spell tables */
    for (ctmp = self->castlist; ctmp; ctmp = ctmp->next) {
	
	switch (ctmp->targettype) {
	    case QuVal_Target_Wizard:
		mtarget = (union being *)self->wiz[ctmp->target];
		break;
	    case QuVal_Target_Creature:
		mtarget = (union being *)&(self->cre[ctmp->target]);
		break;
	    default:
		mtarget = NULL;
		break;
	}
	mcaster = self->wiz[ctmp->caster];

	switch (ctmp->spellnum) {
	    case SP__SHIELD:
	    case SP__REMOVE_ENCHANTMENT:
	    case SP__RAISE_DEAD:
	    case SP__CURE_LIGHT_WOUNDS:
	    case SP__CURE_HEAVY_WOUNDS:
	    case SP__SUMMON_GOBLIN:
	    case SP__SUMMON_OGRE:
	    case SP__SUMMON_TROLL:
	    case SP__SUMMON_GIANT:
	    case SP__SUMMON_ELEMENTAL:
	    case SP__PROTECTION_FROM_EVIL:
	    case SP__RESIST_HEAT:
	    case SP__RESIST_COLD:
	    case SP__INVISIBILITY:
	    case SP__HASTE:
	    case SP__TIME_STOP:
	    case SP__DELAYED_EFFECT:
	    case SP__PERMANENCY:
		/* spells not affected by magic mirror */

		/* check for dispel magic */
		if (self->fl_dispelmagic) {
		    sprintf(exbuf, _("The %s is dispelled.\n"), _(spelllist[ctmp->spellnum].name));
		    PrintMsg(exbuf);
		    break;
		}

		if (!mtarget) {
		    /* up in air, or (shouldn't happen) area-effect */
		    break;
		}

		/* sight check */
		if (!check_visibility(self, mcaster, mtarget, ctmp)) {
		    break;
		}

		/* check for counterspell */
		if (mtarget->both.zaplist[SP__COUNTER_SPELL]) {
		    sprintf(exbuf, _("The %s is destroyed by your Counter-Spell.\n"), _(spelllist[ctmp->spellnum].name));
		    sprintf(exbuf2, _("The %s is destroyed by the Counter-Spell around %s.\n"), _(spelllist[ctmp->spellnum].name), mtarget->both.name);
		    if (ctmp->targettype==QuVal_Target_Wizard)
			PrintMsg2(ctmp->target, exbuf, exbuf2);
		    else
			PrintMsg(exbuf2);
		    break;
		}
		set_zap_flag(self, ctmp, -1);
		break;

	    case SP__STAB:
		/* not affected by magic mirror or dispel magic */
		if (!mtarget) {
		    /* up in air, or (shouldn't happen) area-effect */
		    break;
		}
		/* sight check */
		if (!check_visibility(self, mcaster, mtarget, ctmp)) {
		    break;
		}

		set_zap_flag(self, ctmp, -1);
		break;

	    case SP__MISSILE:
	    case SP__FINGER_OF_DEATH:
	    case SP__LIGHTNING_BOLT:
	    case SP__LIGHTNING_BOLT2:
	    case SP__CAUSE_LIGHT_WOUNDS:
	    case SP__CAUSE_HEAVY_WOUNDS:
	    case SP__FIREBALL:
	    case SP__AMNESIA:
	    case SP__CONFUSION:
	    case SP__CHARM_PERSON:
	    case SP__CHARM_MONSTER:
	    case SP__PARALYSIS:
	    case SP__FEAR:
	    case SP__ANTI_SPELL:
	    case SP__DISEASE:
	    case SP__POISON:
	    case SP__BLINDNESS:
		/* spells affected by magic mirror */

		/* check for repeat of short lightning bolt */
		if (ctmp->spellnum==SP__LIGHTNING_BOLT2) {
		    if (!mcaster->fl_cast_lightning) {
			mcaster->fl_cast_lightning = 1;
			ctmp->spellnum = SP__LIGHTNING_BOLT;
		    }
		    else {
			sprintf(exbuf2, _("%s's Lightning Bolt fizzles.\n"), mcaster->name);
			PrintMsg2(ctmp->caster, _("Since you have already cast Lightning Bolt with that formulation, the spell fizzles.\n"), exbuf2);
			break;
		    }
		}

		/* check for dispel magic */
		if (self->fl_dispelmagic) {
		    sprintf(exbuf, _("The %s is dispelled.\n"), _(spelllist[ctmp->spellnum].name));
		    PrintMsg(exbuf);
		    break;
		}

		if (!mtarget) {
		    /* up in air, or (shouldn't happen) area-effect */
		    break;
		}

		/* sight check */
		if (!check_visibility(self, mcaster, mtarget, ctmp)) {
		    break;
		}

		/* check for counterspell */
		if (ctmp->spellnum != SP__FINGER_OF_DEATH) {
		    if (mtarget->both.zaplist[SP__COUNTER_SPELL]) {
			sprintf(exbuf, _("The %s is destroyed by your Counter-Spell.\n"), _(spelllist[ctmp->spellnum].name));
			sprintf(exbuf2, _("The %s is destroyed by the Counter-Spell around %s.\n"), _(spelllist[ctmp->spellnum].name), mtarget->both.name);
			if (ctmp->targettype==QuVal_Target_Wizard)
			    PrintMsg2(ctmp->target, exbuf, exbuf2);
			else
			    PrintMsg(exbuf2);
			break;
		    }
		}

		ix = mtarget->both.zaplist[SP__MAGIC_MIRROR];
		/* if the caster is the target, ignore magic mirror. */
		if (ix && ((union being *)mcaster!=mtarget)) {
		    /* magic mirror -- terrific */
		    /* we assume that the caster is a wizard. */
		    
		    /* check to see if caster has mirror too */
		    if (mcaster->zaplist[SP__MAGIC_MIRROR]) {
			sprintf(exbuf, _("Your %s is reflected back and forth between %s's Magic Mirror and your own! It rapidly decays and dissipates.\n"), _(spelllist[ctmp->spellnum].name), mtarget->both.name);
			sprintf(exbuf2, _("%s's %s is reflected back and forth between your Magic Mirror and %s own! It rapidly decays and dissipates.\n"), mcaster->name, _(spelllist[ctmp->spellnum].name), pro_his(mcaster->gender)); 
			sprintf(exbuf3, _("%s's %s is reflected back and forth between %s's Magic Mirror and %s own! It rapidly decays and dissipates.\n"), mcaster->name, _(spelllist[ctmp->spellnum].name), mtarget->both.name, pro_his(mcaster->gender));
			if (ctmp->targettype==QuVal_Target_Wizard)
			    PrintMsg3(ctmp->caster, ctmp->target, exbuf, exbuf2, exbuf3);
			else
			    PrintMsg2(ctmp->caster, exbuf, exbuf3);
			break; /* spell is lost */
		    }

		    sprintf(exbuf, _("Your %s is reflected from %s's Magic Mirror back at you.\n"), _(spelllist[ctmp->spellnum].name), mtarget->both.name);
		    sprintf(exbuf2, _("%s's %s reflects from your Magic Mirror back at %s.\n"), mcaster->name, _(spelllist[ctmp->spellnum].name), pro_him(mcaster->gender)); 
		    sprintf(exbuf3, _("%s's %s reflects from %s's Magic Mirror back at %s.\n"), mcaster->name, _(spelllist[ctmp->spellnum].name), mtarget->both.name, pro_him(mcaster->gender));
		    if (ctmp->targettype==QuVal_Target_Wizard)
			PrintMsg3(ctmp->caster, ctmp->target, exbuf, exbuf2, exbuf3);
		    else
			PrintMsg2(ctmp->caster, exbuf, exbuf3);
		    /* reverse spell */
		    ix = ctmp->caster;
		    if (ctmp->targettype==QuVal_Target_Wizard)
			ctmp->caster = ctmp->target;
		    else
			ctmp->caster = (-1);
		    ctmp->targettype = QuVal_Target_Wizard;
		    ctmp->target = ix;
		    /* now, check AGAIN for counterspell */
		    if (ctmp->spellnum != SP__FINGER_OF_DEATH) {
			if (mcaster->zaplist[SP__COUNTER_SPELL]) {
			    sprintf(exbuf, _("The reflected %s is destroyed by your Counter-Spell.\n"), _(spelllist[ctmp->spellnum].name));
			    sprintf(exbuf2, _("The reflected %s is destroyed by the Counter-Spell around %s.\n"), _(spelllist[ctmp->spellnum].name), mcaster->name);
			    if (ctmp->targettype==QuVal_Target_Wizard)
				PrintMsg2(ctmp->target, exbuf, exbuf2);
			    else
				PrintMsg(exbuf2);
			    break;
			}
		    }
		    set_zap_flag(self, ctmp, -1);
		}
		else {
		    set_zap_flag(self, ctmp, -1);
		}
		break;

	    case SP__ICE_STORM:
		/* area-effect spell; mtarget is NULL */
		/* check for dispel magic */
		 if (self->fl_dispelmagic) {
		     sprintf(exbuf, _("The %s is dispelled.\n"), _(spelllist[ctmp->spellnum].name));
		     PrintMsg(exbuf);
		     break;
		 }
		self->fl_icestorm++;
		break;
	    case SP__FIRE_STORM:
		/* area-effect spell; mtarget is NULL */
		/* check for dispel magic */
		if (self->fl_dispelmagic) {
		    sprintf(exbuf, _("The %s is dispelled.\n"), _(spelllist[ctmp->spellnum].name));
		    PrintMsg(exbuf);
		    break;
		}
		self->fl_firestorm++;
		break;

	    case SP__SURRENDER:
		PrintMsg(_("ERROR: Surrender got through to spell table setup\n"));
		break;

	    case SP__COUNTER_SPELL:
	    case SP__COUNTER_SPELL2:
	    case SP__DISPEL_MAGIC:
	    case SP__MAGIC_MIRROR:
		/* already taken care of */
		break;

	    default:
		PrintMsg(_("ERROR: Unknown spell in spell table setup\n"));
		break;
	}
    }

    /* before summoning, do any queries for elemental type. */
    erase_queries(self);
    for (ix=0; ix<self->numplayers; ix++)
	if (self->wiz[ix]->alive) {
	    for (jx=0; jx<self->wiz[ix]->zaplist[SP__SUMMON_ELEMENTAL]; jx++) {
		add_query(self, ix, Qu_ElementalType, 0);
	    }
	}
    if (self->numqueries)
	Queries(self->numqueries, self->querylist);

    /* SUMMON SPELLS : live wizards */
    summonelq = 0; /* counter for queries */
    for (ix=0; ix<self->numplayers; ix++) {
	if (self->wiz[ix]->alive)
	    exec_summons(self, self->wiz[ix], ix, 1);
    }

    /* CHECK FOR ELEMENTAL / STORM CANCELS */
    check_elements(self);

    /* CHECK FOR CANCELS : live beings */
    for (ix=0; ix<self->numplayers; ix++) {
	if (self->wiz[ix]->alive)
	    exec_cancels(self, self->wiz[ix], ix, 1);
    }
    for (ix=0; ix<self->numcres; ix++) {
	if (self->cre[ix].alive)
	    exec_cancels(self, &self->cre[ix], ix, 0);
    }
   
    /* CHECK FOR PROTECTS : live beings */
    for (ix=0; ix<self->numplayers; ix++) {
	if (self->wiz[ix]->alive)
	    exec_protects(self, self->wiz[ix], ix, 1);
    }
    for (ix=0; ix<self->numcres; ix++) {
	if (self->cre[ix].alive)
	    exec_protects(self, &self->cre[ix], ix, 0);
    }
   
    /* CHECK FOR ENCHANTMENTS : live beings */
    for (ix=0; ix<self->numplayers; ix++) {
	if (self->wiz[ix]->alive)
	    exec_enchants(self, self->wiz[ix], ix, 1);
    }
    for (ix=0; ix<self->numcres; ix++) {
	if (self->cre[ix].alive)
	    exec_enchants(self, &self->cre[ix], ix, 0);
    }

    /* DAMAGE SPELLS : live beings */
    for (ix=0; ix<self->numplayers; ix++) {
	if (self->wiz[ix]->alive)
	    exec_attacks(self, self->wiz[ix], ix, 1);
    }
    for (ix=0; ix<self->numcres; ix++) {
	if (self->cre[ix].alive)
	    exec_attacks(self, &self->cre[ix], ix, 0);
    }

    /* HEALING SPELLS : all beings */
    for (ix=0; ix<self->numplayers; ix++) {
	exec_heals(self, self->wiz[ix], ix, 1);
    }
    for (ix=0; ix<self->numcres; ix++) {
	exec_heals(self, &self->cre[ix], ix, 0);
    }

}

static void exec_counters(self, fred, cnum, wizflag) /* dead allowed */
struct realgame *self;
union being *fred;
int cnum;
int wizflag;
{
    struct castspell *ctmp, **pt;
    int ix, jx, wiznum;
    int *zapl;

    zapl = fred->both.zaplist;

    /*{
	for (jx=0; jx<NUMSPELLS; jx++)
	    putchar('0'+zapl[jx]);
	printf(_(" : %s\n"), fred->both.name);
    }*/

    if (self->fl_dispelmagic) {
	/* dispel magic in effect: neutralize counter_spells and magic mirrors */
	if (zapl[SP__COUNTER_SPELL]) {
	    zapl[SP__COUNTER_SPELL] = 0;
	    sprintf(exbuf, _("The Counter-Spell on %s is dispelled.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, _("The Counter-Spell on you is dispelled.\n"), exbuf);
	    else
		PrintMsg(exbuf);
	}
	if (zapl[SP__MAGIC_MIRROR]) {
	    zapl[SP__MAGIC_MIRROR] = 0;
	    sprintf(exbuf, _("The Magic Mirror on %s is dispelled.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, _("The Magic Mirror on you is dispelled.\n"), exbuf);
	    else
		PrintMsg(exbuf);
	}

	if (!wizflag) {
	    struct creature *cre = (struct creature *)fred;
	    if (cre->alive) {
		sprintf(exbuf, _("The Dispel Magic starts to tear %s apart.\n"), cre->name);
		PrintMsg(exbuf);
		cre->hitpoints = (-100);
		cre->nocorpse = 1;
	    }
	    else if (!cre->nocorpse) {
		sprintf(exbuf, _("The corpse of %s disintegrates, destroyed by the Dispel Magic.\n"), cre->name);
		PrintMsg(exbuf);	
		cre->nocorpse = 1;
	    }
	}
    }
    else {
	/* no dispel magic */
	if (zapl[SP__COUNTER_SPELL]) {
	    zapl[SP__SHIELD]++; /* auto-shield */

	    sprintf(exbuf, _("A Counter-Spell flares around %s.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, _("Your magical senses go numb as a Counter-Spell surrounds you.\n"), exbuf);
	    else
		PrintMsg(exbuf);

	    if (zapl[SP__MAGIC_MIRROR]) {
		/* counterspell beats mirror */
		zapl[SP__MAGIC_MIRROR] = 0;
		sprintf(exbuf, _("The Magic Mirror on %s is destroyed by the Counter-Spell.\n"), fred->both.name);
		if (wizflag)
		    PrintMsg2(cnum, _("The Magic Mirror on you is destroyed by the Counter-Spell.\n"), exbuf);
		else
		    PrintMsg(exbuf);
	    }

	}

	if (zapl[SP__MAGIC_MIRROR]) {

	    sprintf(exbuf, _("A Magic Mirror swirls around %s.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, _("The bright haze of a Magic Mirror surrounds you.\n"), exbuf);
	    else
		PrintMsg(exbuf);

	}
    }
}

static void exec_summons(self, fred, cnum, wizflag) /* no deaders or monsters */
struct realgame *self;
union being *fred;
int cnum;
int wizflag;
{
    int ix, jx, spelnum;
    int *zapl = fred->both.zaplist;
    char *elm;
    /* counterspell, dispel magic, magic mirror have already been taken care of. */
    static int summonspells[4] = {SP__SUMMON_GOBLIN, SP__SUMMON_OGRE, SP__SUMMON_TROLL, SP__SUMMON_GIANT};
    /* have to put this into startup initialization */
    static char *summonnames[4] = {"Goblin", "Ogre", "Troll", "Giant"};

    for (ix=0; ix<4; ix++) {
	spelnum = summonspells[ix];
	if (zapl[spelnum]) {
	    if (zapl[spelnum]==1) {
		sprintf(exbuf, _("Your %s materializes by your side.\n"), summonnames[ix]);
		sprintf(exbuf2, _("%s's %s appears by %s side.\n"), fred->both.name, summonnames[ix], pro_his(fred->both.gender));
		if (wizflag)
		    PrintMsg2(cnum, exbuf, exbuf2);
		else
		    PrintMsg(exbuf2);
	    }
	    else {
		sprintf(exbuf, _("Your %s %ss materialize by your side.\n"), number_name(zapl[spelnum]), summonnames[ix]);
		sprintf(exbuf2, _("%s's %s %ss appear by %s side.\n"), fred->both.name, number_name(zapl[spelnum]), summonnames[ix], pro_his(fred->both.gender));
		if (wizflag)
		    PrintMsg2(cnum, exbuf, exbuf2);
		else
		    PrintMsg(exbuf2);
	    }
	    for (jx=0; jx<zapl[spelnum]; jx++)
		create_creature(self, ix+1, cnum);
	}
    }

    for (jx=0; jx<self->wiz[cnum]->zaplist[SP__SUMMON_ELEMENTAL]; jx++) {
	ix = self->querylist[summonelq].answer; /* 0 fire, 1 ice */
	summonelq++;
	if (!ix) {
	    sprintf(exbuf, _("A blazing Fire Elemental materializes above you.\n"));
	    sprintf(exbuf2, _("A blazing Fire Elemental materializes above %s.\n"), fred->both.name);
	}
	else {
	    sprintf(exbuf, _("A glittering Ice Elemental materializes above you.\n"));
	    sprintf(exbuf2, _("A glittering Ice Elemental materializes above %s.\n"), fred->both.name);
	}
	if (wizflag)
	    PrintMsg2(cnum, exbuf, exbuf2);
	else
	    PrintMsg(exbuf2);
	create_creature(self, 6-ix, cnum);
    }

}

/* actually, check for cancellation of creatures for any cause. */
static void check_elements(self)
struct realgame *self;
{
    int num_fire, num_ice, firel, icel;
    int ix, nukit;
    int *zapl;

    num_fire = 0;
    num_ice = 0;
    for (ix=0; ix<self->numcres; ix++) 
	if (self->cre[ix].alive) {
	    if (self->cre[ix].type==Creature_FIREL) {
		num_fire++;
		if (num_fire == 1) {
		    firel = ix;
		}
		else {
		    self->cre[firel].hitpoints = 3; /* max strength */
		    self->cre[ix].nocorpse = 1;
		    self->cre[ix].alive = 0;
		}
	    }
	    if (self->cre[ix].type==Creature_ICEL) {
		num_ice++;
		if (num_ice == 1) {
		    icel = ix;
		}
		else {
		    self->cre[icel].hitpoints = 3; /* max strength */
		    self->cre[ix].nocorpse = 1;
		    self->cre[ix].alive = 0;
		}
	    }
	}
    if (num_fire>1) {
	sprintf(exbuf, _("The %s Fire Elementals merge into single raging form.\n"), number_name(num_fire));
	PrintMsg(exbuf);
    }
    if (num_ice>1) {
	sprintf(exbuf, _("The %s Ice Elementals merge into single whirling form.\n"), number_name(num_ice));
	PrintMsg(exbuf);
    }

    ix = (num_fire ? 1 : 0)
      | (num_ice ? 2 : 0)
      | (self->fl_firestorm ? 4 : 0)
      | (self->fl_icestorm ? 8 : 0);

    switch (ix) {
	case 5: /* 0101 */
	    PrintMsg(_("The Fire Elemental is dispersed into the Fire Storm.\n"));
	    self->cre[firel].nocorpse = 1;
	    self->cre[firel].alive = 0;
	    break;
	case 10: /* 1010 */
	    PrintMsg(_("The Ice Elemental is dispersed into the Ice Storm.\n"));
	    self->cre[icel].nocorpse = 1;
	    self->cre[icel].alive = 0;
	    break;
	case 12: /* 1100 */
	    PrintMsg(_("The Fire and Ice Storms tear each other into shreds of vapor.\n"));
	    self->fl_firestorm = 0;
	    self->fl_icestorm = 0;
	    break;
	case 3: /* 0011 */
	    PrintMsg(_("The Fire and Ice Elementals tear into each other, and whirl into a column of steam that dissipates in moments.\n"));
	    self->cre[firel].nocorpse = 1;
	    self->cre[firel].alive = 0;
	    self->cre[icel].nocorpse = 1;
	    self->cre[icel].alive = 0;
	    break;
	case 6: /* 0110 */
	    PrintMsg(_("The Ice Elemental is dispersed into the Fire Storm, destroying both.\n"));
	    self->cre[icel].nocorpse = 1;
	    self->cre[icel].alive = 0;
	    self->fl_firestorm = 0;
	    break;
	case 9: /* 1001 */
	    PrintMsg(_("The Fire Elemental is dispersed into the Ice Storm, destroying both.\n"));
	    self->cre[firel].nocorpse = 1;
	    self->cre[firel].alive = 0;
	    self->fl_icestorm = 0;
	    break;
	case 13: /* 1101 */
	    PrintMsg(_("The Fire and Ice Storms tear each other into shreds of vapor, destroying the Fire Elemental as well.\n"));
	    self->cre[firel].nocorpse = 1;
	    self->cre[firel].alive = 0;
	    self->fl_firestorm = 0;
	    self->fl_icestorm = 0;
	    break;
	case 14: /* 1110 */
	    PrintMsg(_("The Fire and Ice Storms tear each other into shreds of vapor, destroying the Ice Elemental as well.\n"));
	    self->cre[icel].nocorpse = 1;
	    self->cre[icel].alive = 0;
	    self->fl_firestorm = 0;
	    self->fl_icestorm = 0;
	    break;
	case 11: /* 1011 */
	    PrintMsg(_("The Fire and Ice Elementals tear into each other, and whirl into a column of steam that dissipates in moments. The Ice Storm is absorbed as well.\n"));
	    self->cre[firel].nocorpse = 1;
	    self->cre[firel].alive = 0;
	    self->cre[icel].nocorpse = 1;
	    self->cre[icel].alive = 0;
	    self->fl_icestorm = 0;
	    break;
	case 7: /* 0111 */
	    PrintMsg(_("The Fire and Ice Elementals tear into each other, and whirl into a column of steam that dissipates in moments. The Fire Storm is absorbed as well.\n"));
	    self->cre[firel].nocorpse = 1;
	    self->cre[firel].alive = 0;
	    self->cre[icel].nocorpse = 1;
	    self->cre[icel].alive = 0;
	    self->fl_firestorm = 0;
	    break;
	case 15: /* 1111 */
	    PrintMsg(_("The Fire and Ice Elementals whirl into each other, screaming in fury, and the Fire and Ice storms shriek in response. The column of Elemental energy rises to meet the cloud of vapor that descends over the arena. You are buffeted by the conflicting energies; but within moments, nothing remains.\n"));
	    self->cre[firel].nocorpse = 1;
	    self->cre[firel].alive = 0;
	    self->cre[icel].nocorpse = 1;
	    self->cre[icel].alive = 0;
	    self->fl_icestorm = 0;
	    self->fl_firestorm = 0;
	    break;
    }

    for (ix=0; ix<self->numcres; ix++) 
	if (self->cre[ix].alive) {
	    zapl = self->cre[ix].zaplist;
	    nukit = 0;

	    if (self->cre[ix].type==Creature_FIREL) {
		if (!nukit && zapl[SP__RESIST_HEAT]) {
		    sprintf(exbuf, _("%s gutters and flickers out under the influence of the Resist Heat.\n"), self->cre[ix].name);
		    PrintMsg(exbuf);
		    nukit = 1;
		}
	    }
	    if (self->cre[ix].type==Creature_ICEL) {
		if (!nukit && zapl[SP__RESIST_COLD]) {
		    sprintf(exbuf, _("%s melts away under the influence of the Resist Cold.\n"), self->cre[ix].name);
		    PrintMsg(exbuf);
		    nukit = 1;
		}
		if (!nukit && zapl[SP__FIREBALL]) {
		    sprintf(exbuf, _("%s is vaporized by the Fireball.\n"), self->cre[ix].name);
		    PrintMsg(exbuf);
		    nukit = 1;
		}
	    }
	    if (!nukit && zapl[SP__BLINDNESS]) {
		sprintf(exbuf, _("Under the stress of the Blindness, %s shivers and disintegrates into random energies.\n"), self->cre[ix].name);
		PrintMsg(exbuf);
		nukit = 1;
	    }
	    if (!nukit && zapl[SP__INVISIBILITY]) {
		sprintf(exbuf, _("Under the stress of the Invisibility, %s shivers and disintegrates into random energies.\n"), self->cre[ix].name);
		PrintMsg(exbuf);
		nukit = 1;
	    }

	    if (nukit) {
		self->cre[ix].alive = 0;
		self->cre[ix].nocorpse = 1;
	    }

	    /* dispel magic was taken care of earlier */
	    if (self->cre[ix].alive && zapl[SP__REMOVE_ENCHANTMENT]) {
		sprintf(exbuf, _("The Remove Enchantment starts to tear %s apart.\n"), self->cre[ix].name);
		PrintMsg(exbuf);
		self->cre[ix].hitpoints = (-100);
		self->cre[ix].nocorpse = 1;
	    }
	}
}

static void exec_cancels(self, fred, cnum, wizflag) /* no deaders */
struct realgame *self;
union being *fred;
int cnum;
int wizflag;
{
    int ix;
    int *zapl = fred->both.zaplist;
    struct permstats *perm = &(fred->both.perm);
    /* counterspell, dispel magic, magic mirror have already been taken care of. */

    if (zapl[SP__RAISE_DEAD] && zapl[SP__FINGER_OF_DEATH]) {
	sprintf(exbuf2, _("The Finger of Death and Raise Dead spells aimed at %s cancel each other.\n"), fred->both.name);
	if (wizflag)
	    PrintMsg2(cnum, _("For a moment, you feel a sudden pressure in your chest, as if an iron band was squeezing your heart. Then it fades, as the Raise Dead spell burns through you.\n"), exbuf2);
	else
	    PrintMsg(exbuf2);
	zapl[SP__RAISE_DEAD]=0;
	zapl[SP__FINGER_OF_DEATH]=0;
    }

    if (zapl[SP__FIREBALL] && self->fl_icestorm) {
	sprintf(exbuf2, _("The Fireball hurtling towards %s is snuffed by the Ice Storm, leaving %s enveloped in a cloud of steam.\n"), fred->both.name, pro_him(fred->both.gender));
	if (wizflag)
	    PrintMsg2(cnum, _("The Fireball hurtling towards you is snuffed by the Ice Storm, leaving you enveloped in warm steam.\n"), exbuf2);
	else
	    PrintMsg(exbuf2);
	zapl[SP__FIREBALL]=0;
	fred->both.fl_resist_icestorm = 1;
    }

    ix = (zapl[SP__AMNESIA] ? 1 : 0)
      + (zapl[SP__CONFUSION] ? 1 : 0)
      + (zapl[SP__CHARM_PERSON] ? 1 : 0)
      + (zapl[SP__CHARM_MONSTER] ? 1 : 0)
      + (zapl[SP__PARALYSIS] ? 1 : 0)
      + (zapl[SP__FEAR] ? 1 : 0);

    if (ix>1
	|| (zapl[SP__PARALYSIS]>1 && (wizflag && fred->wiz.hand_paralyzed==(-1))) 
	|| zapl[SP__CHARM_PERSON]>1
	|| zapl[SP__CHARM_MONSTER]>1) {
	/* all mind spells cancel. */
	list_mind_spells(exbuf3, zapl);

	sprintf(exbuf, _("The mind-control spells (%s) aimed at you interfere with each other and fizzle, leaving you with a pounding headache.\n"), exbuf3);
	sprintf(exbuf2, _("The mind-control spells (%s) aimed at %s interfere with each other and fizzle.\n"), exbuf3, fred->both.name);
	if (wizflag)
	    PrintMsg2(cnum, exbuf, exbuf2);
	else
	    PrintMsg(exbuf2);

	zapl[SP__AMNESIA] = 0;
	zapl[SP__CONFUSION] = 0;
	zapl[SP__CHARM_PERSON] = 0;
	zapl[SP__CHARM_MONSTER] = 0;
	zapl[SP__PARALYSIS] = 0;
	zapl[SP__FEAR] = 0;
	fred->both.enchant_ppend = 0;
    }
    /* now only a legal set of mind spells remain, and at most one control spell, whose caster is in enchant_caster. (Which may be -1, if the spell mirrored off a creature.) */

}

static void exec_protects(self, fred, cnum, wizflag) /* no deaders */
struct realgame *self;
union being *fred;
int cnum;
int wizflag;
{
    int *zapl = fred->both.zaplist;
    struct permstats *perm = &(fred->both.perm);
    /* counterspell, dispel magic, magic mirror have already been taken care of. */

    /* don't bother checking permanency -- it doesn't change anything */
    if (zapl[SP__RESIST_HEAT]) {
	if (!fred->both.resistant_heat) {
	    sprintf(exbuf2, _("The Resist Heat shrouds %s in a cool blue veil.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, _("The Resist Heat wraps you in a pleasant blue coolness.\n"), exbuf2);
	    else
		PrintMsg(exbuf2);
	    fred->both.resistant_heat = 1;
	}
	else {
	    sprintf(exbuf2, _("%s's veil of Resist Heat continues to glow coolly.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, _("Your veil of Resist Heat continues to glow coolly.\n"), exbuf2);
	    else
		PrintMsg(exbuf2);
	}
    }

    /* don't bother checking permanency -- it doesn't change anything */
    if (zapl[SP__RESIST_COLD]) {
	if (!fred->both.resistant_cold) {
	    sprintf(exbuf2, _("The Resist Cold shrouds %s in a warm pink veil.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, _("The Resist Cold wraps you in a pleasant pink warmth.\n"), exbuf2);
	    else
		PrintMsg(exbuf2);
	    fred->both.resistant_cold = 1;
	}
	else {
	    sprintf(exbuf2, _("%s's veil of Resist Cold continues to glow warmly.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, _("Your veil of Resist Cold continues to glow warmly.\n"), exbuf2);
	    else
		PrintMsg(exbuf2);
	}
    }

    if (zapl[SP__PROTECTION_FROM_EVIL] || perm->fl_prot_evil) {
	if (!fred->both.prot_from_evil) {
	    sprintf(exbuf, _("A white circle of Protection from Evil springs up around you. You feel the Shield aura cloaking your skin.\n"));
	    sprintf(exbuf2, _("A white circle of Protection from Evil springs up around %s.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, exbuf, exbuf2);
	    else
		PrintMsg(exbuf2);
	}
	else {
	    sprintf(exbuf, _("Your circle of Protection from Evil flares back to full strength.\n"));
	    sprintf(exbuf2, _("%s's circle of Protection from Evil flares back to full strength.\n"), fred->both.name);
	    if (wizflag)
		PrintMsg2(cnum, exbuf, exbuf2);
	    else
		PrintMsg(exbuf2);
	}
	fred->both.prot_from_evil = 4;
    }

    if (!(self->turntype==Turn_TIMESTOP && fred->both.timestop!=1)) {
	fred->both.fl_resist_heat = (fred->both.resistant_heat);
	fred->both.fl_resist_cold = (fred->both.resistant_cold);

	if (fred->both.prot_from_evil>0) {
	    int doit = 1;
	    switch (fred->both.prot_from_evil) {
		case 4:
		default:
		    doit = 0;
		    /*sprintf(exbuf, _("Your circle of Protection from Evil is still glowing strongly.\n"));
		    sprintf(exbuf2, _("%s's circle of Protection from Evil is still glowing strongly.\n"), fred->both.name);*/
		    break;
		case 3:
		    sprintf(exbuf, _("Your circle of Protection from Evil is beginning to fade.\n"));
		    sprintf(exbuf2, _("%s's circle of Protection from Evil is beginning to fade.\n"), fred->both.name);
		    break;
		case 2:
		    sprintf(exbuf, _("Your circle of Protection from Evil is dimmer now.\n"));
		    sprintf(exbuf2, _("%s's circle of Protection from Evil is dimmer now.\n"), fred->both.name);
		    break;
		case 1:
		    sprintf(exbuf, _("Your circle of Protection from Evil is nearly gone.\n"));
		    sprintf(exbuf2, _("%s's circle of Protection from Evil is nearly gone.\n"), fred->both.name);
		    break;
	    }
	    if (doit)
		if (wizflag)
		    PrintMsg2(cnum, exbuf, exbuf2);
		else
		    PrintMsg(exbuf2);

	    fred->both.prot_from_evil--;
	    zapl[SP__SHIELD] += 64; /* auto-shield, special mark */
	}
    }
    else {
	/* the protections are timestopped and have no effect. */
    }
}