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
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
|
/*
* fight.c Phantasia monster fighting routines
*/
#include <string.h>
#include "include.h"
/************************************************************************
/
/ FUNCTION NAME: encounter()
/
/ FUNCTION: monster battle routine
/
/ AUTHOR: E. A. Estes, 2/20/86
/
/ ARGUMENTS:
/ int particular - particular monster to fight if >= 0
/
/ RETURN VALUE: none
/
/ MODULES CALLED: monsthits(), playerhits(), readmessage(), callmonster(),
/ writerecord(), pickmonster(), displaystats(), pow(), cancelmonster(),
/ awardtreasure(), more(), death(), wmove(), setjmp(), drandom(), printw(),
/ longjmp(), wrefresh(), mvprintw(), wclrtobot()
/
/ GLOBAL INPUTS: Curmonster, Whichmonster, LINES, Lines, Circle, Shield,
/ Player, *stdscr, Fileloc, Fightenv[], *Enemyname
/
/ GLOBAL OUTPUTS: Curmonster, Whichmonster, Lines, Shield, Player, Luckout
/
/ DESCRIPTION:
/ Choose a monster and check against some special types.
/ Arbitrate between monster and player. Watch for either
/ dying.
/
*************************************************************************/
encounter(particular)
int particular;
{
bool firsthit = Player.p_blessing; /* set if player gets the first hit */
int flockcnt = 1; /* how many time flocked */
/* let others know what we are doing */
Player.p_status = S_MONSTER;
writerecord(&Player, Fileloc);
#ifdef SYS5
flushinp();
#endif
Shield = 0.0; /* no shield up yet */
if (particular >= 0)
/* monster is specified */
Whichmonster = particular;
else
/* pick random monster */
Whichmonster = pickmonster();
setjmp(Fightenv); /* this is to enable changing fight state */
move(6, 0);
clrtobot(); /* clear bottom area of screen */
Lines = 9;
callmonster(Whichmonster); /* set up monster to fight */
Luckout = FALSE; /* haven't tried to luckout yet */
if (Curmonster.m_type == SM_MORGOTH)
mvprintw(4, 0, "You've encountered %s, Bane of the Council and Valar.\n",
Enemyname);
if (Curmonster.m_type == SM_UNICORN)
{
if (Player.p_virgin)
{
printw("You just subdued %s, thanks to the virgin.\n", Enemyname);
Player.p_virgin = FALSE;
}
else
{
printw("You just saw %s running away!\n", Enemyname);
Curmonster.m_experience = 0.0;
Curmonster.m_treasuretype = 0;
}
}
else
/* not a special monster */
for (;;)
/* print header, and arbitrate between player and monster */
{
mvprintw(6, 0, "You are being attacked by %s, EXP: %.0f (Size: %.0f)\n",
Enemyname, Curmonster.m_experience, Circle);
displaystats();
mvprintw(1, 26, "%20.0f", Player.p_energy + Shield); /* overprint energy */
readmessage();
if (Curmonster.m_type == SM_DARKLORD
&& Player.p_blessing
&& Player.p_charms > 0)
/* overpower Dark Lord with blessing and charm */
{
mvprintw(7, 0, "You just overpowered %s!", Enemyname);
Lines = 8;
Player.p_blessing = FALSE;
--Player.p_charms;
break;
}
/* allow paralyzed monster to wake up */
Curmonster.m_speed = MIN(Curmonster.m_speed + 1.0, Curmonster.m_maxspeed);
if (drandom() * Curmonster.m_speed > drandom() * Player.p_speed
/* monster is faster */
&& Curmonster.m_type != SM_DARKLORD
/* not D. L. */
&& Curmonster.m_type != SM_SHRIEKER
/* not mimic */
&& !firsthit)
/* monster gets a hit */
monsthits();
else
/* player gets a hit */
{
firsthit = FALSE;
playerhits();
}
refresh();
if (Lines > LINES - 2)
/* near bottom of screen - pause */
{
more(Lines);
move(Lines = 8, 0);
clrtobot();
}
if (Player.p_energy <= 0.0)
/* player died */
{
more(Lines);
death(Enemyname);
cancelmonster();
break; /* fight ends if the player is saved from death */
}
if (Curmonster.m_energy <= 0.0)
/* monster died */
break;
}
/* give player credit for killing monster */
Player.p_experience += Curmonster.m_experience;
if (drandom() < Curmonster.m_flock / 100.0)
/* monster flocks */
{
more(Lines);
++flockcnt;
longjmp(Fightenv, 0);
/*NOTREACHED*/
}
else if (Circle > 1.0
&& Curmonster.m_treasuretype > 0
&& drandom() > 0.2 + pow(0.4, (double) (flockcnt / 3 + Circle / 3.0)))
/* monster has treasure; this takes # of flocks and size into account */
{
more(Lines);
awardtreasure();
}
/* pause before returning */
getyx(stdscr, Lines, flockcnt);
more(Lines + 1);
Player.p_ring.ring_inuse = FALSE; /* not using ring */
/* clean up the screen */
move(4, 0);
clrtobot();
}
/**/
/************************************************************************
/
/ FUNCTION NAME: pickmonster()
/
/ FUNCTION: choose a monster based upon where we are
/
/ AUTHOR: E. A. Estes, 2/20/86
/
/ ARGUMENTS: none
/
/ RETURN VALUE: monster number to call
/
/ MODULES CALLED: floor(), drandom()
/
/ GLOBAL INPUTS: Marsh, Circle, Player
/
/ GLOBAL OUTPUTS: none
/
/ DESCRIPTION:
/ Certain monsters can be found in certain areas of the grid.
/ We take care of rolling them here.
/ Unfortunately, this routine assumes that the monster data
/ base is arranged in a particular order. If the data base
/ is altered (to add monsters, or make them tougher), this
/ routine may also need to be changed.
/
*************************************************************************/
pickmonster()
{
if (Player.p_specialtype == SC_VALAR)
/* even chance of any monster */
return((int) ROLL(0.0, 100.0));
if (Marsh)
/* water monsters */
return((int) ROLL(0.0, 15.0));
else if (Circle > 24)
/* even chance of all non-water monsters */
return((int) ROLL(14.0, 86.0));
else if (Circle > 15)
/* chance of all non-water monsters, weighted toward middle */
return((int) (ROLL(0.0, 50.0) + ROLL(14.0, 37.0)));
else if (Circle > 8)
/* not all non-water monsters, weighted toward middle */
return((int) (ROLL(0.0, 50.0) + ROLL(14.0, 26.0)));
else if (Circle > 3)
/* even chance of some tamer non-water monsters */
return((int) ROLL(14.0, 50.0));
else
/* even chance of some of the tamest non-water monsters */
return((int) ROLL(14.0, 25.0));
}
/**/
/************************************************************************
/
/ FUNCTION NAME: playerhits()
/
/ FUNCTION: prompt player for action in monster battle, and process
/
/ AUTHOR: E. A. Estes, 12/4/85
/
/ ARGUMENTS: none
/
/ RETURN VALUE: none
/
/ MODULES CALLED: hitmonster(), throwspell(), inputoption(), cancelmonster(),
/ floor(), wmove(), drandom(), altercoordinates(), waddstr(), mvprintw(),
/ wclrtoeol(), wclrtobot()
/
/ GLOBAL INPUTS: Curmonster, Lines, Player, *stdscr, Luckout, *Enemyname
/
/ GLOBAL OUTPUTS: Curmonster, Lines, Player, Luckout
/
/ DESCRIPTION:
/ Process all monster battle options.
/
*************************************************************************/
playerhits()
{
double inflict; /* damage inflicted */
int ch; /* input */
mvaddstr(7, 0, "1:Melee 2:Skirmish 3:Evade 4:Spell 5:Nick ");
if (!Luckout) {
/* haven't tried to luckout yet */
if (Curmonster.m_type == SM_MORGOTH)
/* cannot luckout against Morgoth */
addstr("6:Ally ");
else
addstr("6:Luckout ");
}
if (Player.p_ring.ring_type != R_NONE)
/* player has a ring */
addstr("7:Use Ring ");
else
clrtoeol();
ch = inputoption();
move(8, 0);
clrtobot(); /* clear any messages from before */
Lines = 9;
mvaddstr(4, 0, "\n\n"); /* clear status area */
switch (ch)
{
case 'T': /* timeout; lose turn */
break;
case ' ':
case '1': /* melee */
/* melee affects monster's energy and strength */
inflict = ROLL(Player.p_might / 2.0 + 5.0, 1.3 * Player.p_might)
+ (Player.p_ring.ring_inuse ? Player.p_might : 0.0);
Curmonster.m_melee += inflict;
Curmonster.m_strength = Curmonster.m_o_strength
- Curmonster.m_melee / Curmonster.m_o_energy
* Curmonster.m_o_strength / 4.0;
hitmonster(inflict);
break;
case '2': /* skirmish */
/* skirmish affects monter's energy and speed */
inflict = ROLL(Player.p_might / 3.0 + 3.0, 1.1 * Player.p_might)
+ (Player.p_ring.ring_inuse ? Player.p_might : 0.0);
Curmonster.m_skirmish += inflict;
Curmonster.m_maxspeed = Curmonster.m_o_speed
- Curmonster.m_skirmish / Curmonster.m_o_energy
* Curmonster.m_o_speed / 4.0;
hitmonster(inflict);
break;
case '3': /* evade */
/* use brains and speed to try to evade */
if ((Curmonster.m_type == SM_DARKLORD
|| Curmonster.m_type == SM_SHRIEKER
/* can always run from D. L. and shrieker */
|| drandom() * Player.p_speed * Player.p_brains
> drandom() * Curmonster.m_speed * Curmonster.m_brains)
&& (Curmonster.m_type != SM_MIMIC))
/* cannot run from mimic */
{
mvaddstr(Lines++, 0, "You got away!");
cancelmonster();
altercoordinates(0.0, 0.0, A_NEAR);
}
else
mvprintw(Lines++, 0, "%s is still after you!", Enemyname);
break;
case 'M':
case '4': /* magic spell */
throwspell();
break;
case '5': /* nick */
/* hit 1 plus sword; give some experience */
inflict = 1.0 + Player.p_sword;
Player.p_experience += floor(Curmonster.m_experience / 10.0);
Curmonster.m_experience *= 0.92;
/* monster gets meaner */
Curmonster.m_maxspeed += 2.0;
Curmonster.m_speed = (Curmonster.m_speed < 0.0) ? 0.0 : Curmonster.m_speed + 2.0;
if (Curmonster.m_type == SM_DARKLORD)
/* Dark Lord; doesn't like to be nicked */
{
mvprintw(Lines++, 0,
"You hit %s %.0f times, and made him mad!", Enemyname, inflict);
Player.p_quickness /= 2.0;
altercoordinates(0.0, 0.0, A_FAR);
cancelmonster();
}
else
hitmonster(inflict);
break;
case 'B':
case '6': /* luckout */
if (Luckout)
mvaddstr(Lines++, 0, "You already tried that.");
else
{
Luckout = TRUE;
if (Curmonster.m_type == SM_MORGOTH)
/* Morgoth; ally */
{
if (drandom() < Player.p_sin / 100.0)
{
mvprintw(Lines++, 0, "%s accepted!", Enemyname);
cancelmonster();
}
else
mvaddstr(Lines++, 0, "Nope, he's not interested.");
}
else
/* normal monster; use brains for success */
{
if ((drandom() + 0.333) * Player.p_brains
< (drandom() + 0.333) * Curmonster.m_brains)
mvprintw(Lines++, 0, "You blew it, %s.", Player.p_name);
else
{
mvaddstr(Lines++, 0, "You made it!");
Curmonster.m_energy = 0.0;
}
}
}
break;
case '7': /* use ring */
if (Player.p_ring.ring_type != R_NONE)
{
mvaddstr(Lines++, 0, "Now using ring.");
Player.p_ring.ring_inuse = TRUE;
if (Player.p_ring.ring_type != R_DLREG)
/* age ring */
--Player.p_ring.ring_duration;
}
break;
}
}
/**/
/************************************************************************
/
/ FUNCTION NAME: monsthits()
/
/ FUNCTION: process a monster hitting the player
/
/ AUTHOR: E. A. Estes, 12/4/85
/
/ ARGUMENTS: none
/
/ RETURN VALUE: none
/
/ MODULES CALLED: cancelmonster(), scramblestats(), more(), floor(), wmove(),
/ drandom(), altercoordinates(), longjmp(), waddstr(), mvprintw(),
/ getanswer()
/
/ GLOBAL INPUTS: Curmonster, Lines, Circle, Shield, Player, *stdscr,
/ Fightenv[], *Enemyname
/
/ GLOBAL OUTPUTS: Curmonster, Whichmonster, Lines, Shield, Player,
/ *Enemyname
/
/ DESCRIPTION:
/ Handle all special monsters here. If the monster is not a special
/ one, simply roll a hit against the player.
/
*************************************************************************/
monsthits()
{
double inflict; /* damage inflicted */
int ch; /* input */
switch (Curmonster.m_type)
/* may be a special monster */
{
case SM_DARKLORD:
/* hits just enough to kill player */
inflict = (Player.p_energy + Shield) * 1.02;
goto SPECIALHIT;
case SM_SHRIEKER:
/* call a big monster */
mvaddstr(Lines++, 0,
"Shrieeeek!! You scared it, and it called one of its friends.");
more(Lines);
Whichmonster = (int) ROLL(70.0, 30.0);
longjmp(Fightenv, 0);
/*NOTREACHED*/
case SM_BALROG:
/* take experience away */
inflict = ROLL(10.0, Curmonster.m_strength);
inflict = MIN(Player.p_experience, inflict);
mvprintw(Lines++, 0,
"%s took away %.0f experience points.", Enemyname, inflict);
Player.p_experience -= inflict;
return;
case SM_FAERIES:
if (Player.p_holywater > 0)
/* holy water kills when monster tries to hit */
{
mvprintw(Lines++, 0, "Your holy water killed it!");
--Player.p_holywater;
Curmonster.m_energy = 0.0;
return;
}
break;
case SM_NONE:
/* normal hit */
break;
default:
if (drandom() > 0.2)
/* normal hit */
break;
/* else special things */
switch (Curmonster.m_type)
{
case SM_LEANAN:
/* takes some of the player's strength */
inflict = ROLL(1.0, (Circle - 1.0) / 2.0);
inflict = MIN(Player.p_strength, inflict);
mvprintw(Lines++, 0, "%s sapped %0.f of your strength!",
Enemyname, inflict);
Player.p_strength -= inflict;
Player.p_might -= inflict;
break;
case SM_SARUMAN:
if (Player.p_palantir)
/* take away palantir */
{
mvprintw(Lines++, 0, "Wormtongue stole your palantir!");
Player.p_palantir = FALSE;
}
else if (drandom() > 0.5)
/* gems turn to gold */
{
mvprintw(Lines++, 0,
"%s transformed your gems into gold!", Enemyname);
Player.p_gold += Player.p_gems;
Player.p_gems = 0.0;
}
else
/* scramble some stats */
{
mvprintw(Lines++, 0, "%s scrambled your stats!", Enemyname);
scramblestats();
}
break;
case SM_THAUMATURG:
/* transport player */
mvprintw(Lines++, 0, "%s transported you!", Enemyname);
altercoordinates(0.0, 0.0, A_FAR);
cancelmonster();
break;
case SM_VORTEX:
/* suck up some mana */
inflict = ROLL(0, 7.5 * Circle);
inflict = MIN(Player.p_mana, floor(inflict));
mvprintw(Lines++, 0,
"%s sucked up %.0f of your mana!", Enemyname, inflict);
Player.p_mana -= inflict;
break;
case SM_NAZGUL:
/* try to take ring if player has one */
if (Player.p_ring.ring_type != R_NONE)
/* player has a ring */
{
mvaddstr(Lines++, 0, "Will you relinguish your ring ? ");
ch = getanswer("YN", FALSE);
if (ch == 'Y')
/* take ring away */
{
Player.p_ring.ring_type = R_NONE;
Player.p_ring.ring_inuse = FALSE;
cancelmonster();
break;
}
}
/* otherwise, take some brains */
mvprintw(Lines++, 0,
"%s neutralized 1/5 of your brain!", Enemyname);
Player.p_brains *= 0.8;
break;
case SM_TIAMAT:
/* take some gold and gems */
mvprintw(Lines++, 0,
"%s took half your gold and gems and flew off.", Enemyname);
Player.p_gold /= 2.0;
Player.p_gems /= 2.0;
cancelmonster();
break;
case SM_KOBOLD:
/* steal a gold piece and run */
mvprintw(Lines++, 0,
"%s stole one gold piece and ran away.", Enemyname);
Player.p_gold = MAX(0.0, Player.p_gold - 1.0);
cancelmonster();
break;
case SM_SHELOB:
/* bite and (medium) poison */
mvprintw(Lines++, 0,
"%s has bitten and poisoned you!", Enemyname);
Player.p_poison -= 1.0;
break;
case SM_LAMPREY:
/* bite and (small) poison */
mvprintw(Lines++, 0, "%s bit and poisoned you!", Enemyname);
Player.p_poison += 0.25;
break;
case SM_BONNACON:
/* fart and run */
mvprintw(Lines++, 0, "%s farted and scampered off.", Enemyname);
Player.p_energy /= 2.0; /* damage from fumes */
cancelmonster();
break;
case SM_SMEAGOL:
if (Player.p_ring.ring_type != R_NONE)
/* try to steal ring */
{
mvprintw(Lines++, 0,
"%s tried to steal your ring, ", Enemyname);
if (drandom() > 0.1)
addstr("but was unsuccessful.");
else
{
addstr("and ran away with it!");
Player.p_ring.ring_type = R_NONE;
cancelmonster();
}
}
break;
case SM_SUCCUBUS:
/* inflict damage through shield */
inflict = ROLL(15.0, Circle * 10.0);
inflict = MIN(inflict, Player.p_energy);
mvprintw(Lines++, 0, "%s sapped %.0f of your energy.",
Enemyname, inflict);
Player.p_energy -= inflict;
break;
case SM_CERBERUS:
/* take all metal treasures */
mvprintw(Lines++, 0,
"%s took all your metal treasures!", Enemyname);
Player.p_crowns = 0;
Player.p_sword =
Player.p_shield =
Player.p_gold = 0.0;
cancelmonster();
break;
case SM_UNGOLIANT:
/* (large) poison and take a quickness */
mvprintw(Lines++, 0,
"%s poisoned you, and took one quik.", Enemyname);
Player.p_poison += 5.0;
Player.p_quickness -= 1.0;
break;
case SM_JABBERWOCK:
/* fly away, and leave either a Jubjub bird or Bonnacon */
mvprintw(Lines++, 0,
"%s flew away, and left you to contend with one of its friends.",
Enemyname);
Whichmonster = 55 + (drandom() > 0.5) ? 22 : 0;
longjmp(Fightenv, 0);
/*NOTREACHED*/
case SM_TROLL:
/* partially regenerate monster */
mvprintw(Lines++, 0,
"%s partially regenerated his energy.!", Enemyname);
Curmonster.m_energy +=
floor((Curmonster.m_o_energy - Curmonster.m_energy) / 2.0);
Curmonster.m_strength = Curmonster.m_o_strength;
Curmonster.m_melee = Curmonster.m_skirmish = 0.0;
Curmonster.m_maxspeed = Curmonster.m_o_speed;
break;
case SM_WRAITH:
if (!Player.p_blindness)
/* make blind */
{
mvprintw(Lines++, 0, "%s blinded you!", Enemyname);
Player.p_blindness = TRUE;
Enemyname = "A monster";
}
break;
}
return;
}
/* fall through to here if monster inflicts a normal hit */
inflict = drandom() * Curmonster.m_strength + 0.5;
SPECIALHIT:
mvprintw(Lines++, 0, "%s hit you %.0f times!", Enemyname, inflict);
if ((Shield -= inflict) < 0)
{
Player.p_energy += Shield;
Shield = 0.0;
}
}
/**/
/************************************************************************
/
/ FUNCTION NAME: cancelmonster()
/
/ FUNCTION: mark current monster as no longer active
/
/ AUTHOR: E. A. Estes, 12/4/85
/
/ ARGUMENTS: none
/
/ RETURN VALUE: none
/
/ MODULES CALLED: none
/
/ GLOBAL INPUTS: none
/
/ GLOBAL OUTPUTS: Curmonster
/
/ DESCRIPTION:
/ Clear current monster's energy, experience, treasure type, and
/ flock. This is the same as having the monster run away.
/
*************************************************************************/
cancelmonster()
{
Curmonster.m_energy = 0.0;
Curmonster.m_experience = 0.0;
Curmonster.m_treasuretype = 0;
Curmonster.m_flock = 0.0;
}
/**/
/************************************************************************
/
/ FUNCTION NAME: hitmonster()
/
/ FUNCTION: inflict damage upon current monster
/
/ AUTHOR: E. A. Estes, 12/4/85
/
/ ARGUMENTS:
/ double inflict - damage to inflict upon monster
/
/ RETURN VALUE: none
/
/ MODULES CALLED: monsthits(), wmove(), strcmp(), waddstr(), mvprintw()
/
/ GLOBAL INPUTS: Curmonster, Lines, Player, *stdscr, *Enemyname
/
/ GLOBAL OUTPUTS: Curmonster, Lines
/
/ DESCRIPTION:
/ Hit monster specified number of times. Handle when monster dies,
/ and a few special monsters.
/
*************************************************************************/
hitmonster(inflict)
double inflict;
{
mvprintw(Lines++, 0, "You hit %s %.0f times!", Enemyname, inflict);
Curmonster.m_energy -= inflict;
if (Curmonster.m_energy > 0.0)
{
if (Curmonster.m_type == SM_DARKLORD || Curmonster.m_type == SM_SHRIEKER)
/* special monster didn't die */
monsthits();
}
else
/* monster died. print message. */
{
if (Curmonster.m_type == SM_MORGOTH)
mvaddstr(Lines++, 0, "You have defeated Morgoth, but he may return. . .");
else
/* all other types of monsters */
{
mvprintw(Lines++, 0, "You killed it. Good work, %s.", Player.p_name);
if (Curmonster.m_type == SM_MIMIC
&& strcmp(Curmonster.m_name, "A Mimic") != 0
&& !Player.p_blindness)
mvaddstr(Lines++, 0, "The body slowly changes into the form of a mimic.");
}
}
}
/**/
/************************************************************************
/
/ FUNCTION NAME: throwspell()
/
/ FUNCTION: throw a magic spell
/
/ AUTHOR: E. A. Estes, 12/4/85
/
/ ARGUMENTS: none
/
/ RETURN VALUE: none
/
/ MODULES CALLED: hitmonster(), cancelmonster(), sqrt(), floor(), wmove(),
/ drandom(), altercoordinates(), longjmp(), infloat(), waddstr(), mvprintw(),
/ getanswer()
/
/ GLOBAL INPUTS: Curmonster, Whichmonster, Nomana[], Player, *stdscr,
/ Fightenv[], Illspell[], *Enemyname
/
/ GLOBAL OUTPUTS: Curmonster, Whichmonster, Shield, Player
/
/ DESCRIPTION:
/ Prompt player and process magic spells.
/
*************************************************************************/
throwspell()
{
double inflict; /* damage inflicted */
double dtemp; /* for dtemporary calculations */
int ch; /* input */
mvaddstr(7, 0, "\n\n"); /* clear menu area */
if (Player.p_magiclvl >= ML_ALLORNOTHING)
mvaddstr(7, 0, "1:All or Nothing ");
if (Player.p_magiclvl >= ML_MAGICBOLT)
addstr("2:Magic Bolt ");
if (Player.p_magiclvl >= ML_FORCEFIELD)
addstr("3:Force Field ");
if (Player.p_magiclvl >= ML_XFORM)
addstr("4:Transform ");
if (Player.p_magiclvl >= ML_INCRMIGHT)
addstr("5:Increase Might\n");
if (Player.p_magiclvl >= ML_INVISIBLE)
mvaddstr(8, 0, "6:Invisibility ");
if (Player.p_magiclvl >= ML_XPORT)
addstr("7:Transport ");
if (Player.p_magiclvl >= ML_PARALYZE)
addstr("8:Paralyze ");
if (Player.p_specialtype >= SC_COUNCIL)
addstr("9:Specify");
mvaddstr(4, 0, "Spell ? ");
ch = getanswer(" ", TRUE);
mvaddstr(7, 0, "\n\n"); /* clear menu area */
if (Curmonster.m_type == SM_MORGOTH && ch != '3')
/* can only throw force field against Morgoth */
ILLSPELL();
else
switch (ch)
{
case '1': /* all or nothing */
if (drandom() < 0.25)
/* success */
{
inflict = Curmonster.m_energy * 1.01 + 1.0;
if (Curmonster.m_type == SM_DARKLORD)
/* all or nothing doesn't quite work against D. L. */
inflict *= 0.9;
}
else
/* failure -- monster gets stronger and quicker */
{
Curmonster.m_o_strength = Curmonster.m_strength *= 2.0;
Curmonster.m_maxspeed *= 2.0;
Curmonster.m_o_speed *= 2.0;
/* paralyzed monsters wake up a bit */
Curmonster.m_speed = MAX(1.0, Curmonster.m_speed * 2.0);
}
if (Player.p_mana >= MM_ALLORNOTHING)
/* take a mana if player has one */
Player.p_mana -= MM_ALLORNOTHING;
hitmonster(inflict);
break;
case '2': /* magic bolt */
if (Player.p_magiclvl < ML_MAGICBOLT)
ILLSPELL();
else
{
do
/* prompt for amount to expend */
{
mvaddstr(4, 0, "How much mana for bolt? ");
dtemp = floor(infloat());
}
while (dtemp < 0.0 || dtemp > Player.p_mana);
Player.p_mana -= dtemp;
if (Curmonster.m_type == SM_DARKLORD)
/* magic bolts don't work against D. L. */
inflict = 0.0;
else
inflict = dtemp * ROLL(15.0, sqrt(Player.p_magiclvl / 3.0 + 1.0));
mvaddstr(5, 0, "Magic Bolt fired!\n");
hitmonster(inflict);
}
break;
case '3': /* force field */
if (Player.p_magiclvl < ML_FORCEFIELD)
ILLSPELL();
else if (Player.p_mana < MM_FORCEFIELD)
NOMANA();
else
{
Player.p_mana -= MM_FORCEFIELD;
Shield = (Player.p_maxenergy + Player.p_shield) * 4.2 + 45.0;
mvaddstr(5, 0, "Force Field up.\n");
}
break;
case '4': /* transform */
if (Player.p_magiclvl < ML_XFORM)
ILLSPELL();
else if (Player.p_mana < MM_XFORM)
NOMANA();
else
{
Player.p_mana -= MM_XFORM;
Whichmonster = (int) ROLL(0.0, 100.0);
longjmp(Fightenv, 0);
/*NOTREACHED*/
}
break;
case '5': /* increase might */
if (Player.p_magiclvl < ML_INCRMIGHT)
ILLSPELL();
else if (Player.p_mana < MM_INCRMIGHT)
NOMANA();
else
{
Player.p_mana -= MM_INCRMIGHT;
Player.p_might +=
(1.2 * (Player.p_strength + Player.p_sword)
+ 5.0 - Player.p_might) / 2.0;
mvprintw(5, 0, "New strength: %.0f\n", Player.p_might);
}
break;
case '6': /* invisible */
if (Player.p_magiclvl < ML_INVISIBLE)
ILLSPELL();
else if (Player.p_mana < MM_INVISIBLE)
NOMANA();
else
{
Player.p_mana -= MM_INVISIBLE;
Player.p_speed +=
(1.2 * (Player.p_quickness + Player.p_quksilver)
+ 5.0 - Player.p_speed) / 2.0;
mvprintw(5, 0, "New quickness: %.0f\n", Player.p_speed);
}
break;
case '7': /* transport */
if (Player.p_magiclvl < ML_XPORT)
ILLSPELL();
else if (Player.p_mana < MM_XPORT)
NOMANA();
else
{
Player.p_mana -= MM_XPORT;
if (Player.p_brains + Player.p_magiclvl
< Curmonster.m_experience / 200.0 * drandom())
{
mvaddstr(5, 0, "Transport backfired!\n");
altercoordinates(0.0, 0.0, A_FAR);
cancelmonster();
}
else
{
mvprintw(5, 0, "%s is transported.\n", Enemyname);
if (drandom() < 0.3)
/* monster didn't drop its treasure */
Curmonster.m_treasuretype = 0;
Curmonster.m_energy = 0.0;
}
}
break;
case '8': /* paralyze */
if (Player.p_magiclvl < ML_PARALYZE)
ILLSPELL();
else if (Player.p_mana < MM_PARALYZE)
NOMANA();
else
{
Player.p_mana -= MM_PARALYZE;
if (Player.p_magiclvl >
Curmonster.m_experience / 1000.0 * drandom())
{
mvprintw(5, 0, "%s is held.\n", Enemyname);
Curmonster.m_speed = -2.0;
}
else
mvaddstr(5, 0, "Monster unaffected.\n");
}
break;
case '9': /* specify */
if (Player.p_specialtype < SC_COUNCIL)
ILLSPELL();
else if (Player.p_mana < MM_SPECIFY)
NOMANA();
else
{
Player.p_mana -= MM_SPECIFY;
mvaddstr(5, 0, "Which monster do you want [0-99] ? ");
Whichmonster = (int) infloat();
Whichmonster = MAX(0, MIN(99, Whichmonster));
longjmp(Fightenv, 0);
/*NOTREACHED*/
}
break;
}
}
/**/
/************************************************************************
/
/ FUNCTION NAME: callmonster()
/
/ FUNCTION: read monster from file, and fill structure
/
/ AUTHOR: E. A. Estes, 2/25/86
/
/ ARGUMENTS:
/ int which - which monster to call
/
/ RETURN VALUE: none
/
/ MODULES CALLED: truncstring(), fread(), fseek(), floor(), drandom(),
/ strcpy()
/
/ GLOBAL INPUTS: Curmonster, Circle, Player, *Monstfp
/
/ GLOBAL OUTPUTS: Curmonster, Player, *Enemyname
/
/ DESCRIPTION:
/ Read specified monster from monster database and fill up
/ current monster structure.
/ Adjust statistics based upon current size.
/ Handle some special monsters.
/
*************************************************************************/
callmonster(which)
int which;
{
struct monster Othermonster; /* to find a name for mimics */
which = MIN(which, 99); /* make sure within range */
/* fill structure */
fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, 0);
fread((char *) &Curmonster, SZ_MONSTERSTRUCT, 1, Monstfp);
/* handle some special monsters */
if (Curmonster.m_type == SM_MODNAR)
{
if (Player.p_specialtype < SC_COUNCIL)
/* randomize some stats */
{
Curmonster.m_strength *= drandom() + 0.5;
Curmonster.m_brains *= drandom() + 0.5;
Curmonster.m_speed *= drandom() + 0.5;
Curmonster.m_energy *= drandom() + 0.5;
Curmonster.m_experience *= drandom() + 0.5;
Curmonster.m_treasuretype =
(int) ROLL(0.0, (double) Curmonster.m_treasuretype);
}
else
/* make Modnar into Morgoth */
{
strcpy(Curmonster.m_name, "Morgoth");
Curmonster.m_strength = drandom() * (Player.p_maxenergy + Player.p_shield) / 1.4
+ drandom() * (Player.p_maxenergy + Player.p_shield) / 1.5;
Curmonster.m_brains = Player.p_brains;
Curmonster.m_energy = Player.p_might * 30.0;
Curmonster.m_type = SM_MORGOTH;
Curmonster.m_speed = Player.p_speed * 1.1
+ (Player.p_specialtype == SC_EXVALAR) ? Player.p_speed : 0.0;
Curmonster.m_flock = 0.0;
Curmonster.m_treasuretype = 0;
Curmonster.m_experience = 0.0;
}
}
else if (Curmonster.m_type == SM_MIMIC)
/* pick another name */
{
which = (int) ROLL(0.0, 100.0);
fseek(Monstfp, (long) which * (long) SZ_MONSTERSTRUCT, 0);
fread(&Othermonster, SZ_MONSTERSTRUCT, 1, Monstfp);
strcpy(Curmonster.m_name, Othermonster.m_name);
}
truncstring(Curmonster.m_name);
if (Curmonster.m_type != SM_MORGOTH)
/* adjust stats based on which circle player is in */
{
Curmonster.m_strength *= (1.0 + Circle / 2.0);
Curmonster.m_brains *= Circle;
Curmonster.m_speed += Circle * 1.e-9;
Curmonster.m_energy *= Circle;
Curmonster.m_experience *= Circle;
}
if (Player.p_blindness)
/* cannot see monster if blind */
Enemyname = "A monster";
else
Enemyname = Curmonster.m_name;
if (Player.p_speed <= 0.0)
/* make Player.p_speed positive */
{
Curmonster.m_speed += -Player.p_speed;
Player.p_speed = 1.0;
}
/* fill up the rest of the structure */
Curmonster.m_o_strength = Curmonster.m_strength;
Curmonster.m_o_speed = Curmonster.m_maxspeed = Curmonster.m_speed;
Curmonster.m_o_energy = Curmonster.m_energy;
Curmonster.m_melee = Curmonster.m_skirmish = 0.0;
}
/**/
/************************************************************************
/
/ FUNCTION NAME: awardtreasure()
/
/ FUNCTION: select a treasure
/
/ AUTHOR: E. A. Estes, 12/4/85
/
/ ARGUMENTS: none
/
/ RETURN VALUE: none
/
/ MODULES CALLED: pickmonster(), collecttaxes(), more(), cursedtreasure(),
/ floor(), wmove(), drandom(), sscanf(), printw(), altercoordinates(),
/ longjmp(), infloat(), waddstr(), getanswer(), getstring(), wclrtobot()
/
/ GLOBAL INPUTS: Somebetter[], Curmonster, Whichmonster, Circle, Player,
/ *stdscr, Databuf[], *Statptr, Fightenv[]
/
/ GLOBAL OUTPUTS: Whichmonster, Shield, Player
/
/ DESCRIPTION:
/ Roll up a treasure based upon monster type and size, and
/ certain player statistics.
/ Handle cursed treasure.
/
*************************************************************************/
awardtreasure()
{
register int whichtreasure; /* calculated treasure to grant */
int temp; /* temporary */
int ch; /* input */
double treasuretype; /* monster's treasure type */
double gold = 0.0; /* gold awarded */
double gems = 0.0; /* gems awarded */
double dtemp; /* for temporary calculations */
whichtreasure = (int) ROLL(1.0, 3.0); /* pick a treasure */
treasuretype = (double) Curmonster.m_treasuretype;
move(4, 0);
clrtobot();
move(6, 0);
if (drandom() > 0.65)
/* gold and gems */
{
if (Curmonster.m_treasuretype > 7)
/* gems */
{
gems = ROLL(1.0, (treasuretype - 7.0)
* (treasuretype - 7.0) * (Circle - 1.0) / 4.0);
printw("You have discovered %.0f gems!", gems);
}
else
/* gold */
{
gold = ROLL(treasuretype * 10.0, treasuretype
* treasuretype * 10.0 * (Circle - 1.0));
printw("You have found %.0f gold pieces.", gold);
}
addstr(" Do you want to pick them up ? ");
ch = getanswer("NY", FALSE);
addstr("\n\n");
if (ch == 'Y') {
if (drandom() < treasuretype / 35.0 + 0.04)
/* cursed */
{
addstr("They were cursed!\n");
cursedtreasure();
}
else
collecttaxes(gold, gems);
}
return;
}
else
/* other treasures */
{
addstr("You have found some treasure. Do you want to inspect it ? ");
ch = getanswer("NY", FALSE);
addstr("\n\n");
if (ch != 'Y')
return;
else
if (drandom() < 0.08 && Curmonster.m_treasuretype != 4)
{
addstr("It was cursed!\n");
cursedtreasure();
return;
}
else
switch (Curmonster.m_treasuretype)
{
case 1: /* treasure type 1 */
switch (whichtreasure)
{
case 1:
addstr("You've discovered a power booster!\n");
Player.p_mana += ROLL(Circle * 4.0, Circle * 30.0);
break;
case 2:
addstr("You have encountered a druid.\n");
Player.p_experience +=
ROLL(0.0, 2000.0 + Circle * 400.0);
break;
case 3:
addstr("You have found a holy orb.\n");
Player.p_sin = MAX(0.0, Player.p_sin - 0.25);
break;
}
break;
/* end treasure type 1 */
case 2: /* treasure type 2 */
switch (whichtreasure)
{
case 1:
addstr("You have found an amulet.\n");
++Player.p_amulets;
break;
case 2:
addstr("You've found some holy water!\n");
++Player.p_holywater;
break;
case 3:
addstr("You've met a hermit!\n");
Player.p_sin *= 0.75;
Player.p_mana += 12.0 * Circle;
break;
}
break;
/* end treasure type 2 */
case 3: /* treasure type 3 */
switch (whichtreasure)
{
case 1:
dtemp = ROLL(7.0, 30.0 + Circle / 10.0);
printw("You've found a +%.0f shield!\n", dtemp);
if (dtemp >= Player.p_shield)
Player.p_shield = dtemp;
else
SOMEBETTER();
break;
case 2:
addstr("You have rescued a virgin. Will you be honorable ? ");
ch = getanswer("NY", FALSE);
addstr("\n\n");
if (ch == 'Y')
Player.p_virgin = TRUE;
else
{
Player.p_experience += 2000.0 * Circle;
++Player.p_sin;
}
break;
case 3:
addstr("You've discovered some athelas!\n");
--Player.p_poison;
break;
}
break;
/* end treasure type 3 */
case 4: /* treasure type 4 */
addstr("You've found a scroll. Will you read it ? ");
ch = getanswer("NY", FALSE);
addstr("\n\n");
if (ch == 'Y')
switch ((int) ROLL(1, 6))
{
case 1:
addstr("It throws up a shield for you next monster.\n");
getyx(stdscr, whichtreasure, ch);
more(whichtreasure);
Shield =
(Player.p_maxenergy + Player.p_energy) * 5.5 + Circle * 50.0;
Whichmonster = pickmonster();
longjmp(Fightenv, 0);
/*NOTREACHED*/
case 2:
addstr("It makes you invisible for you next monster.\n");
getyx(stdscr, whichtreasure, ch);
more(whichtreasure);
Player.p_speed = 1e6;
Whichmonster = pickmonster();
longjmp(Fightenv, 0);
/*NOTREACHED*/
case 3:
addstr("It increases your strength ten fold to fight your next monster.\n");
getyx(stdscr, whichtreasure, ch);
more(whichtreasure);
Player.p_might *= 10.0;
Whichmonster = pickmonster();
longjmp(Fightenv, 0);
/*NOTREACHED*/
case 4:
addstr("It is a general knowledge scroll.\n");
Player.p_brains += ROLL(2.0, Circle);
Player.p_magiclvl += ROLL(1.0, Circle / 2.0);
break;
case 5:
addstr("It tells you how to pick your next monster.\n");
addstr("Which monster do you want [0-99] ? ");
Whichmonster = (int) infloat();
Whichmonster = MIN(99, MAX(0, Whichmonster));
longjmp(Fightenv, 0);
case 6:
addstr("It was cursed!\n");
cursedtreasure();
break;
}
break;
/* end treasure type 4 */
case 5: /* treasure type 5 */
switch (whichtreasure)
{
case 1:
dtemp = ROLL(Circle / 4.0 + 5.0, Circle / 2.0 + 9.0);
printw("You've discovered a +%.0f dagger.\n", dtemp);
if (dtemp >= Player.p_sword)
Player.p_sword = dtemp;
else
SOMEBETTER();
break;
case 2:
dtemp = ROLL(7.5 + Circle * 3.0, Circle * 2.0 + 160.0);
printw("You have found some +%.0f armour!\n", dtemp);
if (dtemp >= Player.p_shield)
Player.p_shield = dtemp;
else
SOMEBETTER();
break;
case 3:
addstr("You've found a tablet.\n");
Player.p_brains += 4.5 * Circle;
break;
}
break;
/* end treasure type 5 */
case 6: /* treasure type 6 */
switch (whichtreasure)
{
case 1:
addstr("You've found a priest.\n");
Player.p_energy = Player.p_maxenergy + Player.p_shield;
Player.p_sin /= 2.0;
Player.p_mana += 24.0 * Circle;
Player.p_brains += Circle;
break;
case 2:
addstr("You have come upon Robin Hood!\n");
Player.p_shield += Circle * 2.0;
Player.p_strength += Circle / 2.5 + 1.0;
break;
case 3:
dtemp = ROLL(2.0 + Circle / 4.0, Circle / 1.2 + 10.0);
printw("You have found a +%.0f axe!\n", dtemp);
if (dtemp >= Player.p_sword)
Player.p_sword = dtemp;
else
SOMEBETTER();
break;
}
break;
/* end treasure type 6 */
case 7: /* treasure type 7 */
switch (whichtreasure)
{
case 1:
addstr("You've discovered a charm!\n");
++Player.p_charms;
break;
case 2:
addstr("You have encountered Merlyn!\n");
Player.p_brains += Circle + 5.0;
Player.p_magiclvl += Circle / 3.0 + 5.0;
Player.p_mana += Circle * 10.0;
break;
case 3:
dtemp = ROLL(5.0 + Circle / 3.0, Circle / 1.5 + 20.0);
printw("You have found a +%.0f war hammer!\n", dtemp);
if (dtemp >= Player.p_sword)
Player.p_sword = dtemp;
else
SOMEBETTER();
break;
}
break;
/* end treasure type 7 */
case 8: /* treasure type 8 */
switch (whichtreasure)
{
case 1:
addstr("You have found a healing potion.\n");
Player.p_poison = MIN(-2.0, Player.p_poison - 2.0);
break;
case 2:
addstr("You have discovered a transporter. Do you wish to go anywhere ? ");
ch = getanswer("NY", FALSE);
addstr("\n\n");
if (ch == 'Y')
{
double x, y;
addstr("X Y Coordinates ? ");
getstring(Databuf, SZ_DATABUF);
sscanf(Databuf, "%lf %lf", &x, &y);
altercoordinates(x, y, A_FORCED);
}
break;
case 3:
dtemp = ROLL(10.0 + Circle / 1.2, Circle * 3.0 + 30.0);
printw("You've found a +%.0f sword!\n", dtemp);
if (dtemp >= Player.p_sword)
Player.p_sword = dtemp;
else
SOMEBETTER();
break;
}
break;
/* end treasure type 8 */
case 10:
case 11:
case 12:
case 13: /* treasure types 10 - 13 */
if (drandom() < 0.33)
{
if (Curmonster.m_treasuretype == 10)
{
addstr("You've found a pair of elven boots!\n");
Player.p_quickness += 2.0;
break;
}
else if (Curmonster.m_treasuretype == 11
&& !Player.p_palantir)
{
addstr("You've acquired Saruman's palantir.\n");
Player.p_palantir = TRUE;
break;
}
else if (Player.p_ring.ring_type == R_NONE
&& Player.p_specialtype < SC_COUNCIL
&& (Curmonster.m_treasuretype == 12
|| Curmonster.m_treasuretype == 13))
/* roll up a ring */
{
if (drandom() < 0.8)
/* regular rings */
{
if (Curmonster.m_treasuretype == 12)
{
whichtreasure = R_NAZREG;
temp = 35;
}
else
{
whichtreasure = R_DLREG;
temp = 0;
}
}
else
/* bad rings */
{
whichtreasure = R_BAD;
temp = 15 + Statptr->c_ringduration + (int) ROLL(0,5);
}
addstr("You've discovered a ring. Will you pick it up ? ");
ch = getanswer("NY", FALSE);
addstr("\n\n");
if (ch == 'Y')
{
Player.p_ring.ring_type = whichtreasure;
Player.p_ring.ring_duration = temp;
}
break;
}
}
/* end treasure types 10 - 13 */
/* fall through to treasure type 9 if no treasure from above */
case 9: /* treasure type 9 */
switch (whichtreasure)
{
case 1:
if (Player.p_level <= 1000.0
&& Player.p_crowns <= 3
&& Player.p_level >= 10.0)
{
addstr("You have found a golden crown!\n");
++Player.p_crowns;
break;
}
/* fall through otherwise */
case 2:
addstr("You've been blessed!\n");
Player.p_blessing = TRUE;
Player.p_sin /= 3.0;
Player.p_energy = Player.p_maxenergy + Player.p_shield;
Player.p_mana += 100.0 * Circle;
break;
case 3:
dtemp = ROLL(1.0, Circle / 5.0 + 5.0);
dtemp = MIN(dtemp, 99.0);
printw("You have discovered some +%.0f quicksilver!\n",dtemp);
if (dtemp >= Player.p_quksilver)
Player.p_quksilver = dtemp;
else
SOMEBETTER();
break;
}
break;
/* end treasure type 9 */
}
}
}
/**/
/************************************************************************
/
/ FUNCTION NAME: cursedtreasure()
/
/ FUNCTION: take care of cursed treasure
/
/ AUTHOR: E. A. Estes, 12/4/85
/
/ ARGUMENTS: none
/
/ RETURN VALUE: none
/
/ MODULES CALLED: waddstr()
/
/ GLOBAL INPUTS: Player, *stdscr
/
/ GLOBAL OUTPUTS: Player
/
/ DESCRIPTION:
/ Handle cursed treasure. Look for amulets and charms to save
/ the player from the curse.
/
*************************************************************************/
cursedtreasure()
{
if (Player.p_charms > 0)
{
addstr("But your charm saved you!\n");
--Player.p_charms;
}
else if (Player.p_amulets > 0)
{
addstr("But your amulet saved you!\n");
--Player.p_amulets;
}
else
{
Player.p_energy = (Player.p_maxenergy + Player.p_shield) / 10.0;
Player.p_poison += 0.25;
}
}
/**/
/************************************************************************
/
/ FUNCTION NAME: scramblestats()
/
/ FUNCTION: scramble some selected statistics
/
/ AUTHOR: E. A. Estes, 12/4/85
/
/ ARGUMENTS: none
/
/ RETURN VALUE: none
/
/ MODULES CALLED: floor(), drandom()
/
/ GLOBAL INPUTS: Player
/
/ GLOBAL OUTPUTS: Player
/
/ DESCRIPTION:
/ Swap a few player statistics randomly.
/
*************************************************************************/
scramblestats()
{
double dbuf[6]; /* to put statistic in */
double dtemp1, dtemp2; /* for swapping values */
register int first, second; /* indices for swapping */
register double *dptr; /* pointer for filling and emptying buf[] */
/* fill buffer */
dptr = &dbuf[0];
*dptr++ = Player.p_strength;
*dptr++ = Player.p_mana;
*dptr++ = Player.p_brains;
*dptr++ = Player.p_magiclvl;
*dptr++ = Player.p_energy;
*dptr = Player.p_sin;
/* pick values to swap */
first = (int) ROLL(0, 5);
second = (int) ROLL(0, 5);
/* swap values */
dptr = &dbuf[0];
dtemp1 = dptr[first];
/* this expression is split to prevent a compiler loop on some compilers */
dtemp2 = dptr[second];
dptr[first] = dtemp2;
dptr[second] = dtemp1;
/* empty buffer */
Player.p_strength = *dptr++;
Player.p_mana = *dptr++;
Player.p_brains = *dptr++;
Player.p_magiclvl = *dptr++;
Player.p_energy = *dptr++;
Player.p_sin = *dptr;
}
|