-
Notifications
You must be signed in to change notification settings - Fork 4
/
fight.c
1874 lines (1660 loc) · 44.6 KB
/
fight.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
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
/*
fight.c - All the fighting gets done here
Last Modified: Dec 29, 1990
UltraRogue
Copyright (C) 1984, 1985, 1986, 1987, 1990 Herb Chong
All rights reserved.
Based on "Advanced Rogue"
Copyright (C) 1983, 1984 Michael Morgan, Ken Dalka and AT&T
All rights reserved.
Based on "Super-Rogue"
Copyright (C) 1982, 1983 Robert D. Kindelberger
All rights reserved.
Based on "Rogue: Exploring the Dungeons of Doom"
Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
All rights reserved.
See the file LICENSE.TXT for full copyright and licensing information.*/
*/
#include <ctype.h>
#include "rogue.h"
#include "death.h"
/*
* This are the beginning experience levels for all players all further
* experience levels are computed by multiplying by 2
*/
static long e_levels[10] = {
113L, /* Fighter */
142L, /* Paladin */
129L, /* Ranger */
87L, /* Cleric */
114L, /* Druid */
135L, /* Magician */
129L, /* Illusionist */
72L, /* Thief */
86L, /* Assasin */
259L /* Ninja */
};
struct matrix att_mat[11] = {
/* Base, Max_lvl, Factor, Offset, Range */
{10, 17, 2, 1, 2}, /* fi */
{10, 17, 2, 1, 2}, /* pa */
{10, 17, 2, 1, 2}, /* ra */
{10, 19, 2, 1, 3}, /* cl */
{10, 19, 2, 1, 3}, /* dr */
{9, 21, 2, 1, 5}, /* mu */
{9, 21, 2, 1, 5}, /* il */
{10, 21, 2, 1, 4}, /* th */
{10, 21, 2, 1, 4}, /* as */
{10, 21, 2, 1, 4}, /* nj */
{7, 25, 1, 0, 2} /* mn */
};
do_fight(y, x, tothedeath)
{
if (!tothedeath && pstats.s_hpt < max_stats.s_hpt / 3) {
if (!terse)
msg("That's not wise.");
after = fighting = FALSE;
return;
}
if (isalpha(winat(hero.y + y, hero.x + x))) {
after = fighting = TRUE;
do_move(y, x);
}
else {
if (fighting == FALSE)
msg("Nothing there.");
after = fighting = FALSE;
}
}
/*
* fight: The player attacks the monster.
*/
fight(mp, weap, thrown)
coord *mp;
struct object *weap;
bool thrown;
{
struct thing *tp;
struct linked_list *item;
bool did_hit = TRUE;
char *mname;
/*
* Find the monster we want to fight
*/
if ((item = find_mons(mp->y, mp->x)) == NULL) {
debug("Fight what @ %d,%d", mp->y, mp->x);
return;
}
tp = THINGPTR(item);
mname = (on(player, ISBLIND)) ? "it" : monsters[tp->t_index].m_name;
/*
* Since we are fighting, things are not quiet so no healing takes
* place.
*/
player.t_rest_hpt = player.t_rest_pow = 0;
tp->t_rest_hpt = tp->t_rest_pow = 0;
/*
* Let him know it was really a mimic (if it was one).
*/
if (off(player, ISBLIND)) {
if (on(*tp, ISDISGUISE) && (tp->t_type != tp->t_disguise)) {
msg("Wait! That's a %s!", mname);
turn_off(*tp, ISDISGUISE);
did_hit = thrown;
}
if (on(*tp, CANSURPRISE)) {
turn_off(*tp, CANSURPRISE);
if ((player.t_ctype == C_RANGER && rnd(6) != 0) ||
(player.t_ctype == C_NINJA && rnd(pstats.s_lvl / 2)
!= 0))
msg("You notice a %s trying to hide!", mname);
else {
msg("Wait! There's a %s!", mname);
did_hit = thrown;
}
}
}
/* Protection from Normal Missiles */
if (thrown && on(*tp, HASMSHIELD)) {
msg("The %s slows as it approaches %s.",
weaps[weap->o_which].w_name, mname);
did_hit = FALSE;
}
if (did_hit) {
did_hit = FALSE;
if (!can_blink(tp) &&
(off(*tp, MAGICHIT) || (weap != NULL &&
(weap->o_hplus > 0 || weap->o_dplus > 0))) &&
(off(*tp, BMAGICHIT) || (weap != NULL &&
(weap->o_hplus > 2 || weap->o_dplus > 2))) &&
roll_em(&player, tp, weap, thrown, cur_weapon)) {
did_hit = TRUE;
tp->t_wasshot = TRUE;
if (thrown) {
if (weap != NULL && weap->o_type == WEAPON
&& weap->o_which == GRENADE) {
hearmsg("BOOOM!");
aggravate();
}
thunk(weap, mname);
}
else
hit(mname);
/* hitting a friendly monster is curtains */
if (on(*tp, ISFRIENDLY)) {
turn_off(*tp, ISFRIENDLY);
turn_on(*tp, ISMEAN);
}
/* Charmed monsters become uncharmed */
if (on(*tp, ISCHARMED)) {
turn_off(*tp, ISCHARMED);
turn_on(*tp, ISMEAN);
}
/*
* If the player hit a rust monster, he better have a
* + weapon
*/
if (on(*tp, CANRUST)) {
if (!thrown && (weap != NULL) &&
(weap->o_flags & ISMETAL) &&
!(weap->o_flags & ISPROT) &&
!(weap->o_flags & ISSILVER) &&
(weap->o_hplus < 1) && (weap->o_dplus < 1)) {
if (rnd(100) < 50)
weap->o_hplus--;
else
weap->o_dplus--;
msg(terse ? "Your %s weakens!"
: "Your %s appears to be weaker now!",
weaps[weap->o_which].w_name);
}
else if (!thrown && weap != NULL &&
(weap->o_flags & ISMETAL))
msg(terse ? "" : "The rust vanishes from your %s!",
weaps[weap->o_which].w_name);
}
/* flammable monsters die from burning weapons */
if (thrown && on(*tp, CANBBURN) &&
(weap->o_flags & CANBURN) &&
!save_throw(VS_WAND, tp)) {
msg("The %s vanishes in a ball of flame.",
monsters[tp->t_index].m_name);
tp->t_stats.s_hpt = 0;
}
/* spores explode and infest hero */
if (on(*tp, CANSPORE)) {
msg("The %s explodes in a cloud of dust.",
monsters[tp->t_index].m_name);
if (is_wearing(R_HEALTH) ||
player.t_ctype == C_PALADIN ||
(player.t_ctype == C_NINJA && pstats.s_lvl
> 6) ||
thrown && rnd(50) > 0 ||
rnd(20) > 0)
msg("The dust makes it hard to breath.");
else {
msg(terse ? "You have been infested."
: "You have contracted a parasitic infestation!");
infest_dam++;
turn_on(player, HASINFEST);
}
tp->t_stats.s_hpt = 0;
}
/*
* fireproof monsters laugh at you when burning
* weapon hits
*/
if (thrown && on(*tp, NOFIRE) && (weap->o_flags & CANBURN))
msg("The %s laughs as the %s bounces.",
monsters[tp->t_index].m_name,
weaps[weap->o_which].w_name);
/* sharp weapons have no effect on NOSHARP monsters */
if (on(*tp, NOSHARP) && (weap != NULL) &&
(weap->o_flags & ISSHARP)) {
msg("The %s has no effect on the %s!",
weaps[weap->o_which].w_name,
monsters[tp->t_index].m_name);
fighting = FALSE;
}
/* metal weapons pass through NOMETAL monsters */
if (on(*tp, NOMETAL) && (weap != NULL) &&
(weap->o_flags & ISMETAL)) {
msg("The %s passes through the %s!",
weaps[weap->o_which].w_name,
monsters[tp->t_index].m_name);
fighting = FALSE;
}
/*
* If the player hit something that shrieks, wake the
* dungeon
*/
if (on(*tp, CANSHRIEK)) {
turn_off(*tp, CANSHRIEK);
if (on(player, CANHEAR)) {
msg("You are stunned by the %s's shriek.", mname);
no_command += 4 + rnd(8);
}
else if (off(player, ISDEAF))
msg("The %s emits a piercing shriek.", mname);
else
msg("The %s seems to be trying to make some noise.", mname);
aggravate();
if (rnd(wizard ? 3 : 39) == 0 && cur_armor
!= NULL
&& cur_armor->o_which == CRYSTAL_ARMOR) {
struct linked_list *item;
struct object *obj;
for (item = pack; item != NULL; item = next(item)) {
obj = OBJPTR(item);
if (obj == cur_armor)
break;
}
if (item == NULL) {
debug("Can't find crystalline armor being worn.");
}
else {
msg("Your armor shatters from the shriek.");
cur_armor = NULL;
del_pack(item);
}
}
}
/*
* If the player hit something that can surprise, it
* can't now
*/
if (on(*tp, CANSURPRISE))
turn_off(*tp, CANSURPRISE);
/*
* If the player hit something that can summon, it
* will try to
*/
summon_help(tp, NOFORCE);
/* Can the player confuse? */
if (on(player, CANHUH) && !thrown) {
seemsg("Your hands stop glowing red!");
seemsg("The %s appears confused.", mname);
turn_on(*tp, ISHUH);
turn_off(player, CANHUH);
}
/* Merchants just disappear if hit */
/*
* increases prices and curses objects from now on
* though
*/
if (on(*tp, CANSELL)) {
msg("The %s disappears with his wares with a BOOM and a flash.", mname);
killed(NULL, item, NOMESSAGE, NOPOINTS);
aggravate();
luck++;
}
else if (tp->t_stats.s_hpt <= 0)
killed(&player, item, MESSAGE, POINTS);
/*
* If the monster is fairly intelligent and about to
* die, it may turn tail and run.
*/
else if ((tp->t_stats.s_hpt < max(10, tp->maxstats.s_hpt / 10)) &&
(rnd(25) < tp->t_stats.s_intel)) {
turn_on(*tp, ISFLEE);
/* If monster was suffocating, stop it */
if (on(*tp, DIDSUFFOCATE)) {
turn_off(*tp, DIDSUFFOCATE);
extinguish(suffocate);
}
/* If monster held us, stop it */
if (on(*tp, DIDHOLD) && (--hold_count == 0))
turn_off(player, ISHELD);
turn_off(*tp, DIDHOLD);
if (on(*tp, CANTELEPORT)) {
int rm;
/*
* Erase the monster from the old
* position
*/
if (isalpha(mvwinch(cw, tp->t_pos.y, tp->t_pos.x)))
mvwaddch(cw, tp->t_pos.y, tp->t_pos.x, tp->t_oldch);
mvwaddch(mw, tp->t_pos.y, tp->t_pos.x, ' ');
/* Get a new position */
do {
rm = rnd_room();
rnd_pos(&rooms[rm], &tp->t_pos);
} until(winat(tp->t_pos.y, tp->t_pos.x) == FLOOR);
/* Put it there */
mvwaddch(mw, tp->t_pos.y, tp->t_pos.x, tp->t_type);
tp->t_oldch = mvwinch(cw, tp->t_pos.y, tp->t_pos.x);
seemsg("The %s seems to have disappeared!", mname);
}
}
}
else if (thrown)
bounce(weap, mname);
else
miss(mname);
}
if (curr_mons)
runto(mp, &hero); /* after so that backstabbing can
* happen */
count = 0;
return did_hit;
}
/*
* attack: The monster attacks the player
*/
attack(mp, weapon, thrown)
struct thing *mp;
struct object *weapon;
bool thrown;
{
char *mname;
bool did_hit = FALSE;
char *find_slot(); /* actually (struct delayed_action *) */
/* If the monster is in a wall, it cannot attack */
if (on(*mp, ISINWALL))
return (FALSE);
/*
* If two monsters start to gang up on our hero, stop fight mode
*/
if (fighting) {
if (beast == NULL)
beast = mp;
else if (beast != mp)
fighting = FALSE;
}
/*
* Since this is an attack, stop running and any healing that was
* going on at the time.
*/
running = FALSE;
player.t_rest_hpt = player.t_rest_pow = 0;
mp->t_rest_hpt = mp->t_rest_pow = 0;
if (on(*mp, ISDISGUISE) && off(player, ISBLIND))
turn_off(*mp, ISDISGUISE);
mname = on(player, ISBLIND) ? "the monster" :
monsters[mp->t_index].m_name;
if (roll_em(mp, &player, weapon, thrown, wield_weap(weapon, mp)) &&
(!thrown || off(player, HASMSHIELD))) {
did_hit = TRUE;
m_thunk(weapon, mname);
if (pstats.s_hpt <= 0) {
death(mp->t_index); /* Bye bye life ... */
return TRUE;
}
/* surprising monsters appear after they shoot at you */
if (thrown && on(*mp, CANSURPRISE))
turn_off(*mp, CANSURPRISE);
else {
/*
* If a vampire hits, it may take half your hit
* points
*/
if (on(*mp, CANSUCK) &&
!save(VS_MAGIC)) {
if (pstats.s_hpt == 1) {
death(mp->t_index);
return TRUE;
}
else {
pstats.s_hpt /= 2;
msg("You feel your life force being drawn from you.");
}
}
/*
* strong monsters can shatter or gong crystalline
* armor
*/
if (cur_armor != NULL && cur_armor->o_which == CRYSTAL_ARMOR) {
if (rnd(mp->t_stats.s_str + (cur_armor->o_ac / 2)) > 20) {
struct linked_list *item;
struct object *obj;
for (item = pack; item != NULL; item = next(item)) {
obj = OBJPTR(item);
if (obj == cur_armor)
break;
}
if (item == NULL) {
debug("Can't find crystalline armor being worn.");
}
else {
msg("Your armor is shattered by the blow.");
cur_armor = NULL;
del_pack(item);
}
}
else if (rnd(mp->t_stats.s_str) > 15) {
msg("Your armor rings from the blow.");
aggravate();
}
}
/* Stinking monsters reduce the player's strength */
if (on(*mp, CANSTINK)) {
turn_off(*mp, CANSTINK);
if (player.t_ctype != C_PALADIN
&& !(player.t_ctype == C_NINJA && pstats.s_lvl > 12)
&& !save(VS_POISON)) {
if (on(player, CANSCENT)) {
msg("You pass out from the stench of the %s.", mname);
no_command += 4 + rnd(8);
}
else if (off(player, ISUNSMELL))
msg("The stench of the %s sickens you.", mname);
if (on(player, HASSTINK))
lengthen(unstink, STINKTIME);
else {
turn_on(player, HASSTINK);
fuse(unstink, 0, STINKTIME,
AFTER);
}
}
}
/* chilling monster reduces strength permanently */
if (on(*mp, CANCHILL) &&
(cur_armor == NULL || cur_armor->o_which != CRYSTAL_ARMOR)) {
msg("You cringe at the %s's chilling touch.", mname);
if (!is_wearing(R_SUSABILITY)) {
chg_str(-1, FALSE, TRUE);
if (lost_str == 0)
fuse(res_strength, 0, CHILLTIME, AFTER);
else
lengthen(res_strength, CHILLTIME);
}
}
/* itching monsters reduce dexterity (temporarily) */
if (on(*mp, CANITCH) && player.t_ctype != C_PALADIN
&& !(player.t_ctype == C_NINJA && pstats.s_lvl > 12)
&& !save(VS_POISON)) {
msg("The claws of the %s scratch you!", mname);
if (is_wearing(R_SUSABILITY)) {
msg("The scratch has no effect.");
}
else {
msg("You feel a burning itch.");
turn_on(player, HASITCH);
chg_dext(-1, FALSE, TRUE);
fuse(un_itch, 0, roll(4, 6), AFTER);
}
}
/* a hugging monster may SQUEEEEEEEZE */
if (on(*mp, CANHUG) &&
(cur_armor == NULL || cur_armor->o_which != CRYSTAL_ARMOR)) {
if (roll(1, 20) >= 18 || roll(1, 20) >= 18) {
msg("The %s squeezes you against itself.", mname);
if ((pstats.s_hpt -= roll(2, 8)) <= 0) {
death(mp->t_index);
return TRUE;
}
}
}
/* a trampling monster may step on the player */
if (on(*mp, CANTRAMPLE)) {
if (roll(1, 20) >= 16 || roll(1, 20) >= 16) {
msg("The %s steps on you.", mname);
if ((pstats.s_hpt -= roll(3, mp->t_stats.s_lvl)) <= 0) {
death(mp->t_index);
return TRUE;
}
}
}
/*
* a disease-carrying monster may transmit the
* disease
*/
if (on(*mp, CANDISEASE) &&
(rnd(pstats.s_const) < mp->t_stats.s_lvl) &&
off(player, HASDISEASE)) {
if (is_wearing(R_HEALTH)
|| (player.t_ctype == C_PALADIN)
|| (player.t_ctype == C_NINJA &&
pstats.s_lvl > 6))
msg("The wound heals quickly.");
else {
turn_on(player, HASDISEASE);
fuse(cure_disease, 0, roll(4, 4) *
SICKTIME, AFTER);
msg(terse ? "You have been diseased."
: "You have contracted a disease!");
}
}
/* a rust monster will weaken your armor */
if (on(*mp, CANRUST)) {
if (cur_armor != NULL &&
cur_armor->o_which != SOFT_LEATHER &&
cur_armor->o_which != HEAVY_LEATHER &&
cur_armor->o_which != CUIRBOLILLI &&
cur_armor->o_which != PADDED_ARMOR &&
cur_armor->o_which != CRYSTAL_ARMOR &&
cur_armor->o_which != MITHRIL &&
!(cur_armor->o_flags & ISPROT) &&
cur_armor->o_ac < pstats.s_arm + 1) {
msg(terse ? "Your armor weakens!"
: "Your armor appears to be weaker now. Oh my!");
cur_armor->o_ac++;
}
else if (cur_armor != NULL &&
(cur_armor->o_flags & ISPROT) &&
cur_armor->o_which != SOFT_LEATHER &&
cur_armor->o_which != HEAVY_LEATHER &&
cur_armor->o_which != CUIRBOLILLI &&
cur_armor->o_which != PADDED_ARMOR &&
cur_armor->o_which != CRYSTAL_ARMOR &&
cur_armor->o_which != MITHRIL)
msg(terse ? "" : "The rust vanishes instantly!");
}
/*
* If a surprising monster hit you, you can see it
* now
*/
if (on(*mp, CANSURPRISE))
turn_off(*mp, CANSURPRISE);
/*
* an infesting monster will give you a parasite or
* rot
*/
if (on(*mp, CANINFEST) && rnd(pstats.s_const) < mp->t_stats.s_lvl) {
if (is_wearing(R_HEALTH) || (player.t_ctype == C_PALADIN)
|| (player.t_ctype == C_NINJA && pstats.s_lvl > 6))
msg("The wound quickly heals.");
else {
turn_off(*mp, CANINFEST);
msg(terse ? "You have been infested."
: "You have contracted a parasitic infestation!");
infest_dam++;
turn_on(player, HASINFEST);
}
}
/* Some monsters have poisonous bites */
if (on(*mp, CANPOISON) && !save(VS_POISON)) {
if (is_wearing(R_SUSABILITY) || (player.t_ctype == C_PALADIN)
|| (player.t_ctype == C_NINJA && pstats.s_lvl > 12))
msg(terse ? "Sting has no effect."
: "A sting momentarily weakens you.");
else {
chg_str(-1, FALSE, FALSE);
msg(terse ? "A sting has weakened you." :
"You feel a sting in your arm and now feel weaker.");
}
}
/* a hideous monster may cause fear by touching */
if (on(*mp, TOUCHFEAR)) {
turn_off(*mp, TOUCHFEAR);
if (!save(VS_WAND)
&& !(on(player, ISFLEE) && (SAME_POS(player.t_dest,mp->t_pos)))) {
if (off(player, SUPERHERO)
&& (player.t_ctype != C_PALADIN)) {
turn_on(player, ISFLEE);
player.t_dest = mp->t_pos;
msg("The %s's touch terrifies you.", mname);
}
else
msg("The %s's touch feels cold and clammy.",
mname);
}
}
/* some monsters will suffocate our hero */
if (on(*mp, CANSUFFOCATE) && (rnd(100) < 15) &&
(find_slot(suffocate) == NULL)) {
turn_on(*mp, DIDSUFFOCATE);
msg("The %s is beginning to suffocate you.",
mname);
fuse(suffocate, 0, roll(4, 2), AFTER);
}
/* don't look now, you will get turned to stone */
if (on(*mp, TOUCHSTONE)) {
turn_off(*mp, TOUCHSTONE);
if (on(player, CANINWALL))
msg("The %s's touch has no effect.", mname);
else {
if (!save(VS_PETRIFICATION) && rnd(100) < 3) {
msg("Your body begins to solidify.");
msg("You are turned to stone !!! --More--");
wait_for(' ');
death(D_PETRIFY);
return TRUE;
}
else {
msg("The %s's touch stiffens your limbs.", mname);
no_command = rnd(STONETIME) + 2;
}
}
}
/* Undead might drain energy levels */
if ((on(*mp, CANDRAIN) || on(*mp, DOUBLEDRAIN)) && rnd(100) < 15) {
if (is_carrying(TR_AMULET))
msg("The Amulet protects you from the %s's negative energy!", mname);
else {
lower_level(mp->t_index);
if (on(*mp, DOUBLEDRAIN))
lower_level(mp->t_index);
}
turn_on(*mp, DIDDRAIN);
}
/* permanently drain a wisdom point */
if (on(*mp, DRAINWISDOM) && rnd(100) < 15) {
int ring_str; /* Value of ring
* strengths */
/* Undo any ring changes */
ring_str = ring_value(R_ADDWISDOM) +
(on(player, POWERWISDOM) ? 10 : 0);
pstats.s_wisdom -= ring_str;
msg("You feel slightly less wise now.");
pstats.s_wisdom = max(pstats.s_wisdom - 1, 3);
max_stats.s_wisdom = pstats.s_wisdom;
/* Now put back the ring changes */
pstats.s_wisdom += ring_str;
}
/* permanently drain a intelligence point */
if (on(*mp, DRAINBRAIN) && rnd(100) < 15) {
int ring_str; /* Value of ring
* strengths */
/* Undo any ring changes */
ring_str = ring_value(R_ADDINTEL) +
(on(player, POWERINTEL) ? 10 : 0);
pstats.s_intel -= ring_str;
msg("You feel slightly less intelligent now.");
pstats.s_intel = max(pstats.s_intel - 1, 3);
max_stats.s_intel = pstats.s_intel;
/* Now put back the ring changes */
pstats.s_intel += ring_str;
}
/* Violet fungi and others hold the hero */
if (on(*mp, CANHOLD) && off(*mp, DIDHOLD)
&& !is_wearing(R_FREEDOM)) {
turn_on(player, ISHELD);
turn_on(*mp, DIDHOLD);
hold_count++;
}
/* suckers will suck blood and run away */
if (on(*mp, CANDRAW)) {
turn_off(*mp, CANDRAW);
turn_on(*mp, ISFLEE);
msg("The %s sates itself with your blood.", mname);
if ((pstats.s_hpt -= 12) <= 0) {
death(mp->t_index);
return TRUE;
}
}
/* el stinkos will force a reduction in strength */
if (on(*mp, CANSMELL)) {
turn_off(*mp, CANSMELL);
if (save(VS_MAGIC) || is_wearing(R_SUSABILITY))
msg("You smell an unpleasant odor.");
else {
short odor_str = -(rnd(6) + 1);
if (on(player, CANSCENT)) {
msg("You pass out from a foul odor.");
no_command += 4 + rnd(8);
}
else if (off(player, ISUNSMELL))
msg("You are overcome by a foul odor.");
if (lost_str == 0) {
chg_str(odor_str, FALSE, TRUE);
fuse(res_strength, 0, SMELLTIME, AFTER);
}
else
lengthen(res_strength, SMELLTIME);
}
}
/* Paralyzation */
if (on(*mp, CANPARALYZE)) {
turn_off(*mp, CANPARALYZE);
if (!save(VS_PARALYZATION) && no_command == 0) {
if (on(player, CANINWALL))
msg("The %s's touch has no effect.", mname);
else {
msg("The %s's touch paralyzes you.", mname);
no_command = FREEZETIME;
}
}
}
/* Rotting */
if (on(*mp, CANROT)) {
turn_off(*mp, CANROT);
turn_on(*mp, DOROT);
}
/* some monsters steal gold */
if (on(*mp, STEALGOLD)) {
long lastpurse;
struct linked_list *item;
struct object *obj;
lastpurse = purse;
purse -= GOLDCALC;
if (!save(VS_MAGIC))
purse -= GOLDCALC + GOLDCALC + GOLDCALC + GOLDCALC;
if (purse < 0)
purse = 0;
if (purse != lastpurse) {
msg("Your purse feels lighter.");
/* Give the gold to the thief */
for (item = mp->t_pack; item != NULL; item = next(item)) {
obj = OBJPTR(item);
if (obj->o_type == GOLD) {
obj->o_count += lastpurse - purse;
break;
}
}
/* Did we do it? */
if (item == NULL) { /* Then make some */
item = new_item(sizeof *obj);
obj = OBJPTR(item);
obj->o_type = GOLD;
obj->o_count = lastpurse - purse;
obj->o_hplus = obj->o_dplus = 0;
obj->o_damage = obj->o_hurldmg = "0d0";
obj->o_ac = 11;
obj->o_group = 0;
obj->o_flags = 0;
obj->o_mark[0] = '\0';
obj->o_pos = mp->t_pos;
attach(mp->t_pack, item);
}
}
if (rnd(2))
turn_on(*mp, ISFLEE);
turn_on(*mp, ISINVIS);
}
/* other monsters steal magic */
if (on(*mp, STEALMAGIC)) {
struct linked_list *list, *steal;
struct object *obj;
int worth = 0;
steal = NULL;
for (list = pack; list != NULL; list = next(list)) {
obj = OBJPTR(list);
if (rnd(33) == 0) {
if (obj->o_flags & ISBLESSED)
obj->o_flags &= ~ISBLESSED;
else
obj->o_flags |= ISCURSED;
msg("You feel nimble fingers reach into you pack.");
}
if ((obj != cur_armor &&
obj != cur_weapon &&
obj != cur_ring[LEFT_1] &&
obj != cur_ring[LEFT_2] &&
obj != cur_ring[LEFT_3] &&
obj != cur_ring[LEFT_4] &&
obj != cur_ring[LEFT_5] &&
obj != cur_ring[RIGHT_1] &&
obj != cur_ring[RIGHT_2] &&
obj != cur_ring[RIGHT_3] &&
obj != cur_ring[RIGHT_4] &&
obj != cur_ring[RIGHT_5] &&
!(obj->o_flags & ISPROT) &&
is_magic(obj)
|| level > 95)
&& get_worth(obj) > worth) {
steal = list;
worth = get_worth(obj);
}
}
if (steal != NULL) {
struct object *obj;
obj = OBJPTR(steal);
if (obj->o_count > 1 && obj->o_group == 0) {
int oc;
struct linked_list *nitem;
struct object *op;
oc = --(obj->o_count);
obj->o_count = 1;
nitem = new_item(sizeof *obj);
op = OBJPTR(nitem);
*op = *obj;
msg("The %s stole %s!", mname, inv_name(obj, LOWERCASE));
obj->o_count = oc;
attach(mp->t_pack, nitem);
}
else {
msg("The %s stole %s!", mname, inv_name(obj, LOWERCASE));
obj->o_flags &= ~ISCURSED;
dropcheck(obj);
rem_pack(obj);
attach(mp->t_pack, steal);
if (obj->o_type == ARTIFACT)
has_artifact &= ~(1 << obj->o_which);
}
if (obj->o_flags & ISOWNED) {
turn_on(*mp, NOMOVE);
msg("The %s is transfixed by your ownership spell.",
mname);
}
if (rnd(2))
turn_on(*mp, ISFLEE);
turn_on(*mp, ISINVIS);
updpack();
}
}
}
}
else {
/* If the thing was trying to surprise, no good */
if (on(*mp, CANSURPRISE))
turn_off(*mp, CANSURPRISE);
if (on(*mp, DOROT)) {
if (player.t_ctype != C_PALADIN
|| !(player.t_ctype == C_NINJA && pstats.s_lvl > 6)) {
msg(terse ? "You feel weaker."
: "Your skin crawls and you feel weaker.");
pstats.s_hpt -= 2;
if (pstats.s_hpt <= 0) {
death(mp->t_index); /* Bye bye life ... */
return TRUE;
}
}
else
msg("You feel something cold and clammy against you.");
}
m_bounce(weapon, mname);
}
if (fight_flush)
flushout();
count = 0;
status(FALSE);
return (did_hit);
}
/*
* mon_mon_attack: A monster attacks another monster
*/
mon_mon_attack(attacker, mon, weapon, thrown)
struct thing *attacker;
struct linked_list *mon;
struct object *weapon;
bool thrown;
{
struct thing *attackee = THINGPTR(mon);
bool did_hit = FALSE;
bool visible = cansee(attackee->t_pos.y, attackee->t_pos.x);
char *mname1 = monsters[attacker->t_index].m_name;
char *mname2 = monsters[attackee->t_index].m_name;
/*
* Similar monsters don't hit each other
*/
if (attacker->t_index == attackee->t_index) {
if (attacker == THINGPTR(fam_ptr) && visible)
msg("Master, I cannot hit one of my brethen.");
return FALSE;
}
/*
* stop running and any healing
*/
attackee->t_rest_hpt = attackee->t_rest_pow = 0;
attacker->t_rest_hpt = attacker->t_rest_pow = 0;
if (roll_em(attacker, attackee, weapon, thrown,
wield_weap(weapon, attacker))) {
did_hit = TRUE;
if (visible && on(*attackee, CANSURPRISE))
turn_off(*attackee, CANSURPRISE);
if (visible && weapon != NULL)
msg("The %s's %s hits the %s.", mname1,
weaps[weapon->o_which].w_name, mname2);
else if (visible)
msg("The %s hits the %s.", mname1, mname2);
if (attackee->t_stats.s_hpt <= 0) {
killed(attacker, mon, MESSAGE,
on(*attacker, ISFAMILIAR) ? POINTS : NOPOINTS);
return TRUE;
}
}
else if (visible && weapon != NULL)
msg("The %s's %s misses the %s.", mname1,
weaps[weapon->o_which].w_name, mname2);