-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathA2.BAS.txt
2159 lines (2042 loc) · 81.4 KB
/
A2.BAS.txt
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
' Copyright (c) 1995 Jeffrey R. Olson
'
' Permission is hereby granted, free of charge, to any person obtaining a copy
' of this software and associated documentation files (the "Software"), to deal
' in the Software without restriction, including without limitation the rights
' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
' copies of the Software, and to permit persons to whom the Software is
' furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all
' copies or substantial portions of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
' SOFTWARE.
DECLARE SUB MaybeMessPause (fc%, bc%)
DECLARE FUNCTION LoadMaps% (mode%)
DECLARE SUB clpage2 ()
DECLARE SUB CrDamAlter (ch%, dam%, damtyp%)
DECLARE FUNCTION CaveCreat% ()
DECLARE SUB DrawCaves ()
DECLARE FUNCTION LairCreat% (strength%)
DECLARE SUB RemoveLocalGoody (mlocx%, mlocy%, dropped%)
DECLARE SUB Scatter (num%)
DECLARE SUB Mousify ()
DECLARE SUB Awaken (i%)
DECLARE SUB RemoveWall (sym%, x%, y%, removed%)
DECLARE SUB DrawSpecial (special%)
DECLARE FUNCTION RoomIt% CDECL (BYVAL xr%, BYVAL xl%, BYVAL yb%, BYVAL yt%)
DECLARE SUB SplitCre (ch%)
DECLARE SUB CreatSort CDECL (BYVAL nnear%, tentgrab%, SEG nn%)
DECLARE SUB PrintJnk (a%, b%, c%)
DECLARE SUB ErasePut ()
DECLARE SUB LjnkBig (a%, b%, c%, d%, e%, f%, a$, n%, i%)
DECLARE SUB ljnk (a%, b%, c%, i%)
DECLARE SUB Cave (numrms%, rms%())
DECLARE SUB Lair CDECL (xr%, xl%, yb%, yt%, xs%, ys%)
DECLARE SUB CrDef (ch%, atktyp%, roll%, missspec%, r%)
DECLARE SUB TeleCreat (x%, y%)
DECLARE SUB AddToDrop (num%)
DECLARE SUB ccls CDECL (BYVAL pag%)
DECLARE SUB cRandomize CDECL (BYVAL seed!)
DECLARE SUB ffEffect (damage%, ffkill%)
DECLARE SUB SetDark (dark%, old%, chang%)
DECLARE SUB Level (newlev%, a$)
DECLARE SUB DumpBuffer ()
DECLARE SUB DamSuit (i%, dam%)
DECLARE SUB ChangeDark ()
DECLARE SUB KillCreat (i%)
DECLARE SUB RemoveGoody (i%, pak%)
DECLARE SUB RemoveCreat (i%)
DECLARE SUB MakeCreature (x%, y%, border%, fake%)
DECLARE SUB MakeStuff (i%)
DECLARE SUB FindDot CDECL (x%, y%, BYVAL i%)
DECLARE SUB DrawRoom (xdoor%, ydoor%, dir%, doorsym%, sm%)
DECLARE SUB AddRoom (x%, y%, didit%, sm%)
DECLARE SUB DotCorn ()
DECLARE SUB DotIt (x%, y%)
DECLARE SUB RemoveWall (sym%, x%, y%, removed%)
DECLARE SUB DisplayGoodies (pak%)
DECLARE SUB DisplayCharacter ()
DECLARE SUB Dead (spec%)
DECLARE SUB PutCreat (i%)
DECLARE SUB ShowHits ()
DECLARE SUB EraseCreat (i%)
DECLARE SUB PauseForKey ()
DECLARE SUB SetCombatStats ()
DECLARE SUB FindMPos (i%, mx%, my%, mlocx%, mlocy%)
DECLARE SUB FindDxDy (x%, y%, dx%, dy%, n%)
DECLARE SUB MessPause (fc%, bc%)
DECLARE SUB ClearMess ()
DECLARE SUB putsym (sym%, col%, row%, fcolr%, bcolr%, pag%)
DECLARE SUB GetSym (sym%, col%, row%, fcolr%, bcolr%, pag%)
DECLARE SUB PrintMessage (fcolr%, bcolr%)
DECLARE SUB box CDECL (BYVAL lc%, BYVAL rc%, BYVAL tc%, BYVAL bc%, BYVAL nl%, BYVAL fclr%, BYVAL pag%)
DECLARE SUB Wrong ()
DECLARE SUB CreatMove (i%, moved%)
DECLARE SUB CreatAttack (i%, damage%)
DECLARE FUNCTION RollDice% CDECL (BYVAL dsize%, BYVAL nroll%, BYVAL nuse%)
DECLARE FUNCTION BadMoveCreat% CDECL (BYVAL dx%, BYVAL dy%, BYVAL nn%, BYVAL cre%, SEG n%)
DECLARE FUNCTION cFindDxDy% CDECL (BYVAL x%, BYVAL y%, BYVAL n%)
DECLARE FUNCTION creatnam$ (typ%, num%)
DECLARE FUNCTION Creature% (typ%, stat%)
DECLARE FUNCTION jnk$ (num%, strt%, leng%)
DECLARE FUNCTION Nc% ()
DECLARE FUNCTION Nf% ()
DECLARE FUNCTION cRd% CDECL (BYVAL x%, BYVAL y%)
DECLARE FUNCTION cRoll% CDECL (BYVAL max%)
DECLARE FUNCTION Terr$ (i%)
DECLARE FUNCTION SmartCre% (n%)
DECLARE FUNCTION Insect% (n%)
DECLARE FUNCTION Yuck% (n%)
DECLARE FUNCTION Plant% (n%)
DECLARE FUNCTION SameRoom% (x%, y%)
DECLARE FUNCTION Der$ (kil%, n%, i%)
DECLARE FUNCTION BerEff$ (i%)
DECLARE FUNCTION ssdnm$ (i%)
DECLARE FUNCTION lsdnm$ (i%)
DECLARE FUNCTION WepNm$ (i%)
DECLARE FUNCTION ShNm$ (i%)
DECLARE FUNCTION ArmNm$ (i%)
DECLARE FUNCTION kolr$ (i%)
DEFINT A-Z
REM $INCLUDE: 'alpha.dc2'
REM $INCLUDE: 'alpha.dec'
END
SUB AttackCreat (dx, dy)
okfester = true: DumpBuffer: SetCombatStats
ch = BadMoveCreat%(dx, dy, nnear, 0, ncre(0, 0))
IF ch = 0 THEN
putsym 250, localx + dx, localy + dy, 8, 0, -1
ljnk 50, 1, 12, 1: PrintMessage 4, 0: GOTO eac
END IF
typ = ncre(ch, 1): Awaken ch
wepnum = 0
FOR i = 1 TO ngoody
IF goody(i, 1) = -3 THEN wepnum = i: EXIT FOR
NEXT i
ClearMess
rol = cRoll(20)
IF wepnum > 0 THEN
hitbon = goody(wepnum, 6) + goody(wepnum, 9)
siz = goody(wepnum, 5): dic = goody(wepnum, 4)
wepadddam = goody(wepnum, 10)
ELSE
hitbon = -3: siz = 3: dic = 1
END IF
IF ncre(ch, 7) \ 1000 = 0 THEN
IF NOT ((pmut = 4 AND berpmut = 0) OR (berdet > 0)) THEN hitbon = hitbon - 3
END IF
IF ((ncre(ch, 11) AND 1) = 0) THEN 'asleep
hitbon = hitbon + 4
ELSEIF (ncre(ch, 11) AND 2) THEN 'blind
hitbon = hitbon + 3
ELSEIF (ncre(ch, 11) AND 28) THEN 'confused, sick or burping
hitbon = hitbon + 2
END IF
IF inglue THEN hitbon = hitbon - 2
IF inpit THEN hitbon = hitbon - 2
IF inbog THEN hitbon = hitbon - 3
IF insand THEN hitbon = hitbon - 4
IF inweb THEN hitbon = hitbon - 4
needed = tohitbase - str2hit - other2hitc - hitbon - ncre(ch, 9)
IF incastle = 0 THEN needed = needed + weather - 2
needed = needed - difficulty
IF needed > 18 THEN needed = 18 ELSE IF needed < 5 THEN needed = 5
CrDef ch, 1, rol, misspec, 0
IF rol >= needed THEN
dam = RollDice(siz, dic, dic) + strdam + otherdam + wepadddam
IF dam < dic THEN dam = dic
zz = SQR(lvl) * 100
dam = dam * (4.5 + RND * zz / 100) / 5
IF rol = 20 THEN ljnk 50, 13, 13, 2: dam = dam * 2
CrDamAlter ch, dam, 1
IF typ = gworm THEN SplitCre ch ELSE ncre(ch, 2) = ncre(ch, 2) - dam
LjnkBig 238, 31, 8, 0, 0, 0, Der$(false, ch, 1), 1, 1
dam1 = 0: dam2 = 0
IF ncre(ch, 10) AND 4096 THEN dam1 = cRoll(4)
IF ncre(ch, 10) AND 8192 THEN dam2 = cRoll(10)
dam = dam1 + dam2: ffEffect dam, ffkill
IF ffkill THEN
MessPause 4, 0: ClearMess
LjnkBig 83, 1, 5, 207, 1, 19, jnk$(205, 39, 21), 1, 2
END IF
IF dam > 0 THEN
ljnk 86, 53, 16, 2: hits = hits - dam: ShowHits
IF hits < 0 THEN st1 = jnk$(296, 61, 8) + bl + Der$(true, ch, 3): Dead 0
END IF
IF ncre(ch, 2) < 0 THEN KillCreat ch: okfester = false
ELSEIF misspec = 0 THEN
LjnkBig 50, 33, 10, 0, 0, 0, bl + Der$(false, ch, 1), 1, 1
IF typ = bush THEN l2 = l1: ljnk 50, 43, 14, 1
IF rol = 1 THEN
ljnk 51, 1, 42, 1: ljnk 52, 1, 41, 2
END IF
END IF
IF okfester AND (ncre(ch, 1) = fester) THEN ljnk 382, 1, 31, 2: RemoveCreat ch 'NOT typ!
MaybeMessPause 5, 0
fatadd! = fatig! + 4
eac:
END SUB
SUB Cave (numrms, rms())
param1 = cRoll(cRoll(1000)): clpage2
numrms = -1 '0 to 7
FOR i = 3 TO 50: FOR j = 3 TO 20: putsym 219, i, j, wallcolr, 0, 2: NEXT j, i
box 2, 51, 2, 21, 1, wallcolr, 2
x = cRoll(30) + 10: y = cRoll(10) + 5: tries = 0
DO
bad = false: tries = tries + 1
FOR j = 0 TO numrms
dx = x - rms(j, 0): dy = y - rms(j, 1)
differ = cRd(dx, 1.3 * dy)
IF differ < 10 THEN bad = true
NEXT
IF bad THEN
GOSUB cavefdot
ELSE
rx = cRoll(3): ry = cRoll(2): GOSUB caverm
END IF
GOSUB meander
LOOP UNTIL numrms = 7 OR tries > 200
FOR iextra = 1 TO param1: GOSUB cavefdot: GOSUB meander: NEXT iextra
FOR i = 3 TO 50: FOR j = 3 TO 20
GetSym sym, i, j, fc, bc, 2
IF sym = 32 THEN putsym 250, i, j, 8, 0, 2
NEXT j, i
FOR i = 2 TO 51: putsym 219, i, 2, wallcolr, 0, 2: putsym 219, i, 21, wallcolr, 0, 2: NEXT i
FOR j = 3 TO 20: putsym 219, 2, j, wallcolr, 0, 2: putsym 219, 51, j, wallcolr, 0, 2: NEXT j
EXIT SUB
meander:
putsym 250, x, y, 8, 0, 2
goon = true: numdots = 0
WHILE goon
FOR i = 1 TO 10
bad = false: dx = 0: dy = 0
SELECT CASE cRoll(3)
CASE 1 TO 2: dx = 2 * cRoll(2) - 3
CASE ELSE: dy = 2 * cRoll(2) - 3
END SELECT
xnew = x + dx: ynew = y + dy
IF xnew < 3 OR xnew > 50 OR ynew < 3 OR ynew > 20 THEN bad = true
IF dx THEN
FOR j = 0 TO dx STEP dx: FOR k = -1 TO 1
GetSym sym, xnew + j, ynew + k, fc, bc, 2
IF (sym <> 219 AND sym <> 32) THEN bad = true
NEXT k, j
ELSE
FOR j = -1 TO 1: FOR k = 0 TO dy STEP dy
GetSym sym, xnew + j, ynew + k, fc, bc, 2
IF (sym <> 219 AND sym <> 32) THEN bad = true
NEXT k, j
END IF
IF NOT bad THEN
x = xnew: y = ynew: putsym 250, x, y, 8, 0, 2: numdots = numdots + 1
EXIT FOR
END IF
NEXT i
IF bad THEN goon = false
WEND
RETURN
caverm:
FOR i = -rx TO rx: FOR j = -ry TO ry
GetSym sym, x + i, y + j, fc, bc, 2
IF sym = 219 OR sym = 250 THEN putsym 32, x + i, y + j, 8, 0, 2
NEXT j, i
numrms = numrms + 1
rms(numrms, 0) = x: rms(numrms, 1) = y
RETURN
cavefdot:
found = false
WHILE NOT found
x = cRoll(50) + 1: y = cRoll(20) + 1
GetSym sym, x, y, fc, bc, 2
IF sym = 32 OR ((sym = 250) AND (cRoll(10) = 1)) THEN found = true
WEND
RETURN
END SUB
FUNCTION CaveCreat
SELECT CASE cRoll(100)
CASE 1 TO 60 'Anywhere critters
maxcre = 3 + 3.49 * lvl + ncastle
redocc1:
l = cRoll(maxcre)
SELECT CASE l
CASE 3, 4, 8, 10, 13, 15, 20, 22, 24, 30 '15 is chamel, 30 is kbee
CASE 31, 33, 40, 43, 45, 48, 53, 57, 60, 61 '48 is grizz, 61 is Tricer
CASE ELSE: GOTO redocc1
END SELECT
CASE 61 TO 97 'terrain critters
maxcre = lvl: IF maxcre > 17 THEN maxcre = 17
l = cRoll(maxcre)
SELECT CASE cRoll(4)
CASE 1: l = ncreat + l
CASE 2: l = ncreat + crecas + l
CASE 3: l = ncreat + crecas + crefor + l
CASE 4: l = ncreat + crecas + crefor + creswa + l
END SELECT
CASE ELSE 'water
maxcre = 1 + 1.5 * lvl: IF maxcre > creh2o THEN maxcre = creh2o
l = ncreat + crecas + crefor + creswa + crepla + cRoll(maxcre)
END SELECT
CaveCreat = l
END FUNCTION
SUB CrDef (ch, atktyp, rol, missspec, r)
typ = ncre(ch, 1)
missspec = 0
IF r < 1 THEN
pp = cRoll(20)
SELECT CASE typ
CASE gill
IF (pp < 18) AND (atktyp <> 26) THEN
rol = 1: missspec = 1: a = 299: b = 46: c = 23: d = 300
SELECT CASE cRoll(5)
CASE 1, 2: e = 1: f = 26 'coconuts
hits = hits - RollDice(lvl / 2, 3, 3): ShowHits
IF hits < 0 THEN
ljnk a, b, c, 1: ljnk d, e, f, 2: MessPause 12, 0
st1 = jnk$(380, 47, 16): Dead 0: EXIT SUB
END IF
CASE 3: e = 27: f = 21 'glue
inglue = true: fatadd! = fatadd! + 3
CASE 4: d = 116: e = 35: f = 30 'hair tonic
berhic = berhic + cRoll(4): ber$ = "aaaChoo!"
CASE ELSE: e = 48: f = 21 'glasses
END SELECT
END IF
CASE mara, mary, ging, mrshow, ivana, bunny
IF pp < 12 + 6 * (typ = bunny OR typ = ivana) THEN
rol = 1: missspec = 2
a = 301: b = 1: c = 29: dd = 301: ee = 31: ff = 10
fatadd! = 0
END IF
CASE cubs
IF pp < 6 THEN
rol = 1: missspec = 3
a = 299: b = 46: c = 23: d = 301: e = 44: f = 24
END IF
END SELECT
IF c > 0 THEN ljnk a, b, c, 1
IF f > 0 THEN ljnk d, e, f, 2
IF ff > 0 THEN LjnkBig dd, ee, ff, 0, 0, 0, Der$(false, ch, 1), 1, 2
END IF
END SUB
SUB CreatAttack (inew, damage)
i = inew: ClearMess
damage = 0: showchan = 40: touch = false
typ = ncre(i, 1): cx = ncre(i, 4): cy = ncre(i, 5)
FOR j = 6 TO 14 STEP 2
ppp = Creature(typ, j): ppp1 = Creature(typ, j + 1)
atype = ppp1 \ 100: attackrange = ppp1 MOD 100
astr = ppp \ 100: tohit = ppp MOD 100
IF atype = 0 THEN EXIT FOR
SELECT CASE typ
CASE robot, rdro, sdro, ddro
astr = ncre(i, 14) MOD 10: tohit = ncre(i, 14) \ 100
attackrange = (ncre(i, 14) \ 10) MOD 10
CASE webspid
astr = ncre(i, 14) MOD 100: tohit = (ncre(i, 14) \ 100)
END SELECT
range! = cRd%(cx, cy): IF range! > attackrange THEN EXIT FOR
SELECT CASE atype
CASE 2: tohit = tohit - ac * .7 'radiation
CASE 8, 13: tohit = mr - tohit - 4 * (berscience > 0) 'mentals
CASE 9: tohit = tohit - ac + (armor - 2 - shield \ 2) 'electric
SELECT CASE armor
CASE 1, 2, 3, 4, 5, 8, 9: tohit = tohit - 4
CASE 6, 7, 10, 11: tohit = tohit + 6
END SELECT
SELECT CASE shield
CASE 1 TO 6: tohit = tohit - 2
CASE 7, 8: tohit = tohit + 3
END SELECT
CASE 14, 16, 22, 23, 27: tohit = tohit - 4 'no AC depend
CASE 18: tohit = tohit - ac * .5 'spores
CASE 20, 21: tohit = tohit + mr \ 2 - 6 'attrac,deevol
CASE ELSE: tohit = tohit - ac
END SELECT
IF ncre(i, 7) \ 1000 = 0 THEN
IF NOT ((pmut = 4 AND berpmut = 0) OR (berdet > 0)) THEN tohit = tohit - 3
END IF
IF beryum > 0 THEN tohit = tohit - 4
IF asleep THEN
tohit = tohit - 4
ELSEIF berblind THEN
tohit = tohit - 3
ELSEIF berhic OR berconfuse THEN
tohit = tohit - 2
END IF
IF zippy < 0 THEN tohit = tohit - 3 ELSE IF zippy > 0 THEN tohit = tohit + 3
IF (bergreen > 0) AND (typ = herm) THEN tohit = tohit - 5
tohit = tohit + difficulty
IF tohit > 17 THEN tohit = 17 ELSE IF tohit < 5 THEN tohit = 5
IF (ncre(i, 13) AND (2 ^ (j \ 2 - 2))) AND (atype = 12) THEN tohit = 0: showchan = 1
rol = cRoll(20): dam = 0
IF rol >= tohit THEN
c = 0: f = 0: cc = 0
SELECT CASE atype
CASE 8, 13, 20, 21, 27
IF mindweb AND (cRoll(10) = 1) THEN
mindweb = 0: ljnk 111, 14, 23, 1: MessPause 10, 0
END IF
IF mindweb THEN
LjnkBig 114, 21, 23, 0, 0, 0, Der$(false, i, 1), 1, 1
ljnk 114, 44, 15, 2: damage = -1: GOTO nxcreatk
END IF
CASE 17
IF berfresh GOTO nxcreatk
END SELECT
SELECT CASE atype
CASE 1 'kinetic
siz = 6: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr): DamSuit 0, dam
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
IF damage <> 0 THEN a = 53: b = 11: c = 20 ELSE a = 53: b = 1: c = 10
damage = damage + dam
IF attackrange > 1 THEN a = 53: b = 31: c = 20
IF attackrange = 1 THEN touch = true
CASE 2 'radiation
siz = 5: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr)
IF rr > 1 THEN dam = dam * 12 / (rr + 1) ELSE dam = dam * 5
DamSuit 1, dam
IF (pmut = 8 AND berpmut = 0) THEN dam = dam * (.75 + .25 * (berhpmut > 0))
IF dam < 1 THEN dam = 1
damage = damage + dam: a = 54: b = 1: c = 15
CASE 3 'poison type 1
siz = 4: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr)
IF con > 2 THEN dam = dam * 12 / (con + 1) ELSE dam = dam * 4
IF (pmut = 7 AND berpmut = 0) THEN dam = (dam + 1) / (2 - 2 * (berhpmut > 0))
damage = damage + dam: a = 54: b = 28: c = 13
IF cRoll(50) <= astr THEN
IF NOT (pmut = 7 AND berpmut = 0 AND cRoll(5) > 1) THEN
dex = dex - 1: IF RND < .9 THEN dextox = dextox + 1
IF rdisp = 1 THEN DisplayCharacter
END IF
END IF
IF attackrange = 1 THEN touch = true
CASE 4 'type 2
siz = 4: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr)
IF con > 1 THEN dam = dam * 7 / (con + 1) ELSE dam = dam * 4
IF (pmut = 7 AND berpmut = 0) THEN dam = (dam + 1) / (2 - 2 * (berhpmut > 0))
damage = damage + dam
IF cRoll(10) <= astr THEN
IF NOT (pmut = 7 AND berpmut = 0 AND cRoll(5) > 1) THEN
str = str - 1: IF RND < .9 THEN strtox = strtox + 1
IF rdisp = 1 THEN DisplayCharacter
END IF
END IF
SetCombatStats
IF attackrange = 1 THEN touch = true
a = 54: b = 28: c = 13
CASE 5 'type 3
IF cRoll(10) <= astr THEN
IF NOT (pmut = 7 AND berpmut = 0 AND cRoll(5) > 1) THEN
damg = cRoll((lvl + astr) \ 2): hitmax = hitmax - damg
IF cRoll(10) <> 1 THEN hittox = hittox + damg
con = con - 1: IF RND < .9 THEN contox = contox + 1
IF rdisp = 1 THEN DisplayCharacter
END IF
ELSEIF cRoll(3) = 1 AND NOT (pmut = 7 AND berpmut = 0 AND cRoll(5) > 1) THEN
damg = astr \ 3 + 1: hitmax = hitmax - damg: hittox = hittox + damg
END IF
dam = RollDice(2, astr, astr)
IF con > 3 THEN dam = dam * 12 / (con + 1) ELSE dam = dam * 3
IF (pmut = 7 AND berpmut = 0) THEN dam = (dam + 1) / (2 - 2 * (berhpmut > 0))
damage = damage + dam + damg: a = 256: b = 52: c = 10
IF attackrange = 1 THEN touch = true
CASE 6 'acid
siz = 6: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr): DamSuit 5, dam
damage = damage + dam: a = 54: b = 41: c = 28
IF attackrange = 1 AND pmut = 1 THEN touch = true
CASE 7 'laser
siz = 4: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr)
IF (pmut = 8 AND berpmut = 0) THEN dam = dam * (.5 + .3 * (berhpmut > 0))
IF (mmut = 10 AND bermmut = 0) THEN dam = dam * (.75 + .25 * (berhmmut > 0))
a = 55: b = 1: c = 22
IF (mirror > 0) AND (cRoll(100) < 30 + 3 * (dex + dexadd)) THEN
IF (cRoll(100) < 30 + 3 * (dex + dexadd)) THEN
a = 257: b = 1: c = 31
LjnkBig 257, 32, 17, 0, 0, 0, Der$(false, i, 1), 0, 2
ncre(i, 2) = ncre(i, 2) - dam
ELSE
LjnkBig 257, 1, 24, 285, 1, 15, bl, 2, 1: c = 0: l2 = bl
END IF
damage = -1
ELSE
DamSuit 3, dam: damage = damage + dam
END IF
CASE 8 'mental
siz = 3: IF astr = 0 THEN astr = 1: siz = 2
dic = RollDice(siz, astr, astr)
dam = RollDice(siz, dic, dic)
IF mr >= 0 THEN dam = dam * 17 / (mr + 6) ELSE dam = dam * 3
IF (mmut = 3 AND bermmut = 0) THEN dam = (dam + 1) / (2 - 2 * (berhmmut > 0))
IF berscience > 0 THEN dam = dam / 3: IF dam = 0 THEN dam = 1
damage = damage + dam: a = 55: b = 23: c = 21
CASE 9 'electrical
siz = 8: IF astr = 0 THEN astr = 1: siz = 4
IF attackrange = 1 OR pmut = 1 THEN touch = true
dam = RollDice(siz, astr, astr)
IF pmut = 1 AND berpmut = 0 THEN dam = dam * (.5 + .5 * (berhpmut > 0))
DamSuit 4, dam: damage = damage + dam
a = 55: b = 44: c = 12
CASE 10 'heat
siz = 5: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr)
IF (pmut = 8 AND berpmut = 0) THEN dam = dam * (.67 + .33 * (berhpmut > 0))
DamSuit 2, dam: damage = damage + dam
a = 55: b = 56: c = 10
IF attackrange = 1 AND pmut = 1 THEN touch = true
CASE 11 'cold
siz = 7: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr)
IF brandy > 0 AND dam > 1 THEN dam = dam - 1
DamSuit 2, dam: damage = damage + dam
a = 56: b = 1: c = 12
IF attackrange = 1 AND pmut = 1 THEN touch = true
CASE 12 'tenticles
IF (ncre(i, 13) AND (2 ^ (j \ 2 - 2))) OR (vehicle <> 0) THEN 'leave
dam = RollDice(3, astr, astr): a = 56: b = 13: c = 16
ELSE
dam = cRoll(astr): a = 52: b = 42: c = 13
IF ncre(i, 13) = 0 THEN grabbed = grabbed + 1
ncre(i, 13) = (ncre(i, 13) OR (2 ^ (j \ 2 - 2)))
END IF
damage = damage + dam: touch = true
CASE 13 'life leech
dam = cRoll(astr / 2) + cRoll(astr / 2)
IF mr >= 0 THEN dam = dam * 17 / (mr + 6) ELSE dam = dam * 3
IF berscience > 0 THEN dam = dam / 3: IF dam = 0 THEN dam = 1
damage = damage + dam: a = 56: b = 29: c = 26
ncre(i, 2) = ncre(i, 2) + dam: ncre(i, 3) = ncre(i, 3) + dam \ 3
CASE 14 'steal
IF astr = 0 THEN astr = cRoll(8)
stol = 0
FOR k = 1 TO ngoody
l = cRoll(ngoody)
IF ABS(goody(l, 1)) = astr THEN stol = l: EXIT FOR
IF (astr = 1 OR astr = 2) AND (cRoll(2) = 1) THEN astr = 3 - astr
IF (astr = 7 OR astr = 8) AND (cRoll(2) = 1) THEN astr = 15 - astr
NEXT
IF stol > 0 THEN 'no steal Pres ID
IF ABS(goody(stol, 1)) = 7 AND goody(stol, 11) = 19 AND goody(stol, 5) > 3 THEN stol = 0
END IF
IF stol > 0 THEN
IF typ = japb THEN
st1 = jnk$(56, 55, 7) + RTRIM$(gdy(stol))
ELSEIF typ = gill THEN
st1 = jnk$(117, 17, 12) + RTRIM$(gdy(stol))
ELSEIF ABS(goody(stol, 1)) < 3 THEN
st1 = jnk$(330, 48, 18) + RTRIM$(gdy(stol))
ELSE
st1 = jnk$(332, 55, 10) + RTRIM$(gdy(stol))
IF ABS(goody(stol, 1)) = 3 AND goody(stol, 3) > 1 THEN st1 = st1 + "s"
END IF
l1 = Der$(false, i, 2) + st1
IF ABS(goody(stol, 1)) = 7 AND goody(stol, 11) = 2 THEN 'backpack
IF cRoll(2) = 1 THEN Scatter 1
ELSEIF ABS(goody(stol, 1)) = 8 AND goody(stol, 11) = 8 THEN 'safe
IF cRoll(2) = 1 THEN Scatter 2
END IF
IF ABS(goody(stol, 1)) < 3 THEN 'food
remchance = 0: goody(stol, 3) = goody(stol, 3) - 1
IF goody(stol, 3) <= 0 THEN RemoveGoody stol, false
ELSE
RemoveGoody stol, false: SetCombatStats: remchance = 95
END IF
damage = -1
IF typ = gill THEN remchance = 0
IF cRoll(100) < remchance AND i <> tentgrab THEN ncre(i, 2) = -2000' removecreat
DisplayCharacter
IF fastfight THEN MessPause 12, 0
ELSE
a = 53: b = 1: c = 10: siz = lvl: numd = 1
IF typ = gill THEN siz = lvl / 3 + 1: numd = 4
dam = RollDice(siz, numd, numd): damage = damage + dam
END IF
CASE 15 'tickle
siz = 4: IF astr = 0 THEN astr = 1: siz = 2
dam = RollDice(siz, astr, astr)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * 3 / (4 - 4 * (berhpmut > 0))
damage = damage + dam: a = 57: b = 1: c = 24: touch = true
CASE 16 'damage armor
IF j <> 6 GOTO nxcreatk
damage = -1: hits = hits - RollDice(astr + 1, astr + 1, astr + 1)
touch = true: zzz = 100
FOR k = 1 TO astr + 1
zz = cRoll(105 - 5 * k): IF zzz > zz THEN zzz = zz
NEXT
aa = 55: bb = 2: cc = 7
SELECT CASE zzz
CASE IS < 13: GOSUB damarmor
CASE IS < 40: GOSUB damshield
END SELECT
CASE 17 'pooped
aa = 55: bb = 2: cc = 7: d = 219: e = 22: f = 18: damage = -1
IF fatigue! < 130 THEN fatigue! = 130 ELSE fatigue! = fatigue! + 9
IF attackrange = 1 THEN touch = true
CASE 18 'spores
IF astr > 0 THEN dam = RollDice(5, astr, astr) ELSE dam = -1
damage = damage + dam: a = 226: b = 49: c = 20
SELECT CASE ncre(i, 1)
CASE lotus: aa = 226: bb = 50: cc = 19: c = 0
d = 227: e = 1: f = 12: berconfuse = berconfuse + 1
CASE rweed: aa = 226: bb = 50: cc = 19: c = 0
berhic = berhic + cRoll(4): ber$ = "aaaChoo!"
IF cRoll(4) = 1 AND i <> tentgrab THEN ncre(i, 2) = -2000 'sign to removecreat
CASE gmold: damage = damage + spore: spore = spore + 1: d = 137
SELECT CASE spore
CASE 1 TO 3: e = 1: f = 12 'odd
CASE 4 TO 6: e = 13: f = 15 'sweat
CASE 7 TO 9: e = 28: f = 20 'lightheaded
CASE ELSE: e = 48: f = 20 'heart racing
END SELECT
CASE ELSE: l2 = "for" + STR$(dam) + jnk$(227, 16, 17)
END SELECT
CASE 19 'trample
touch = true: siz = 6: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
damage = damage + dam: ljnk 226, 37, 12, 1: l1 = bl + l1
CASE 20 'attract
IF ncre(i, 13) = 0 THEN
damage = -1: aa = 236: bb = 57: cc = 11
attractx = SGN(ncre(i, 4)): attracty = SGN(ncre(i, 5))
ELSE
dam = 0: a = 56: b = 61: c = 7
END IF
CASE 21 'drain
damage = -1: IF attackrange = 1 THEN touch = true
aa = 239: bb = 15: cc = 10: d = 239: e = 25: f = 16
rnds = RollDice(12, astr, astr): lostexp = false
IF (cRoll(2) = 1) THEN
IF pmutturns = 0 THEN
pmutturns = rnds: berpmut = pmutturns
SELECT CASE pmut
CASE 2: dex = dex - 10
CASE 3: str = str - 10
CASE 4: other2hitc = other2hitc - 1: other2hitr = other2hitr - 2
CASE 5: skinac = skinac - 5: SetCombatStats
CASE 7: con = con - 10: hits = hits - 2 * lvl: hitmax = hitmax - 2 * lvl
IF hits < 0 THEN st1 = jnk$(17, 15, 12): Dead 0: GOTO nxcreatk
CASE 8: rr = rr - 10
CASE 14: zippy = 0
END SELECT
ELSE
lostexp = true
END IF
ELSE
IF mmutturns = 0 THEN
mmutturns = mmutturns + rnds: bermmut = mmutturns
SELECT CASE mmut
CASE 1: other2hitc = other2hitc - 2: other2hitr = other2hitr - 2
otherdam = otherdam - 4
CASE 2: intl = intl - 10
CASE 3: mr = mr - 10
CASE 7: forcefield = false
END SELECT
ELSE
lostexp = true
END IF
END IF
IF lostexp THEN
lose& = (expr& * RND * .05 + 2) * astr
expr& = expr& - lose&
IF typ = grinch THEN grinchstole = grinchstole + lose&
Level newlev, b$: DisplayCharacter
IF newlev THEN
LjnkBig aa, bb, cc, 0, 0, 0, Der$(false, i, 2) + bl, 0, 1
l2 = b$: MaybeMessPause 13, 0: cc = 0: f = 0
LjnkBig 14, 26, 17, 0, 0, 0, STR$(lvl), 1, 1: l2 = b$
END IF
END IF
SetCombatStats
DisplayCharacter
CASE 22 'blind
damage = -1: aa = 249: bb = 34: cc = 11
IF attackrange = 1 THEN touch = true
rnds = RollDice(4, astr, astr)
IF (pmut = 8 AND berpmut = 0) THEN rnds = rnds * (.67 + .33 * (berhpmut > 0))
IF (pmut = 4 AND berpmut = 0) THEN rnds = rnds * (.4 + .2 * (berhpmut > 0))
IF (mmut = 10 AND bermmut = 0) THEN rnds = rnds * (.3 + .15 * (berhmmut > 0))
IF sunglasses THEN
damage = 0
ELSE
berblind = berblind + rnds
SetDark dark, olddark, changed: IF changed THEN ChangeDark
END IF
CASE 23 'sick
IF NOT (gasmask OR spacesuit) THEN
damage = -1: aa = 249: bb = 45: cc = 13
rnds = RollDice(3, astr, astr): sick = sick + rnds
END IF
CASE 24 'help
CASE 25 'gore
siz = 6: IF astr = 0 THEN astr = 1: siz = 3
dam = RollDice(siz, astr, astr)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
touch = true: damage = damage + dam: a = 298: b = 58: c = 11
CASE 26 'special
damage = -1: l1 = "Special attack - not yet implemented"
SELECT CASE typ
CASE tworm: tapeworm = true
aa = 311: bb = 38: cc = 24: d = 285: e = 65: f = 4
ncre(i, 2) = -2000 'sign to removecreat
CASE skip
dam = RollDice(lvl / 2, 6, 4)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
touch = true: damage = damage + dam: a = 412: b = 1: c = 21
CASE prof
dam = RollDice(lvl / 2, 3, 3)
SELECT CASE cRoll(5)
CASE 1, 2 'acid
DamSuit 5, dam: a = 112: b = 39: c = 27
CASE 3, 4 'electrical
DamSuit 4, dam: a = 113: b = 17: c = 35
CASE ELSE 'flashpowder
IF (pmut = 8 AND berpmut = 0) THEN dam = dam * (.67 + .33 * (berhpmut > 0))
DamSuit 2, dam: a = 115: b = 7: c = 36
berblind = berblind + 5
SetDark dark, olddark, changed: IF changed THEN ChangeDark
END SELECT
damage = damage + dam
CASE ging, mary
dam = RollDice(lvl, 1, 1)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
touch = true: damage = damage + dam: a = 389: b = 1: c = 26
CASE mrhow
dam = RollDice(lvl / 2, 3, 2)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
touch = true: damage = damage + dam: a = 412: b = 22: c = 28
CASE mrshow
dam = RollDice(lvl, 1, 1)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
touch = true: damage = damage + dam: a = 413: b = 1: c = 27
CASE herm
dam = RollDice(lvl / 2, 6, 4)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
touch = true: damage = damage + dam: a = 151: b = 41: c = 12
CASE gramp
a = 382: b = 32: c = 32: d = 383: e = 1: f = 48: Mousify
CASE elvis, elvimp
dam = RollDice(lvl, 2, 2)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
touch = true: damage = damage + dam: a = 381: b = 1: c = 38
CASE buzz
touch = true: dam = RollDice(lvl, 5, 2)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
damage = damage + dam
ljnk 226, 37, 12, 1: l1 = bl + l1: d = 389: e = 27: f = 27
inew = -ABS(inew) 'so creatdo won't change l2
CASE cubs
dam = RollDice(lvl, 4, 4)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
IF metshat THEN dam = dam \ 3
damage = damage + dam: touch = true
a = 405: b = 29: c = 26: d = 406: e = 1: f = 24
inew = -ABS(inew) 'so creatdo won't change l2
CASE saddam
dam = RollDice(lvl, 6, 4)
IF pmut = 5 AND berpmut = 0 THEN dam = dam * (.75 + .25 * (berhpmut > 0))
damage = damage + dam: a = 405: b = 1: c = 28
END SELECT
CASE 27 'snooze
damage = -1: aa = 237: bb = 21: cc = 20
asleep = true: berhic = 0: sick = 0: zippy = -2
ncre(i, 2) = -2000 'sign to removecreat
END SELECT
IF c > 0 THEN ljnk a, b, c, 1
IF cc > 0 THEN LjnkBig aa, bb, cc, 0, 0, 0, Der$(false, i, 2) + bl, 0, 1
IF f > 0 THEN ljnk d, e, f, 2
showchan = 10
ELSE 'missed
SELECT CASE atype
CASE 1, 2, 6, 7, 9, 10, 11, 12, 15, 19, 25
zzz = cRoll(75)
IF zzz = 1 AND j = 6 THEN
ClearMess
GOSUB damarmor: IF num = 0 GOTO nxcreatk
ELSEIF zzz = 2 AND j = 6 THEN
ClearMess
GOSUB damshield: IF num = 0 GOTO nxcreatk
END IF
END SELECT
END IF
nxcreatk: NEXT j
IF ncre(i, 7) \ 1000 = 0 THEN 'fc=0: sometimes show critter
IF cRoll(showchan) = 1 THEN
putsym ncre(i, 7) MOD 1000, localx + ncre(i, 4), localy + ncre(i, 5), 8, 0, -1
END IF
END IF
IF damage > 0 THEN damage = damage * (13 - difficulty) / 13
EXIT SUB
damarmor:
num = 0
FOR k = 1 TO ngoody
IF goody(k, 1) = -4 THEN num = k
NEXT
IF num = 0 THEN RETURN
goody(num, 4) = goody(num, 4) - 1
inew = -ABS(inew) 'so creatdo won't change l2
IF goody(num, 4) < 1 THEN
FOR mmm = 1 TO ngoody
IF ABS(goody(mmm, 1)) = 7 AND goody(mmm, 11) = 16 AND goody(mmm, 3) > 0 THEN
IF cRoll(10) < 9 THEN nobrk = true
END IF
NEXT
l2 = "****** " + UCASE$(jnk$(93, 13, 23)) + " ******"
IF nobrk THEN
goody(num, 4) = cRoll(2): goody(num, 5) = goody(num, 5) - 1
l1 = l2: ljnk 123, 13, 33, 2: c = 0: cc = 0
inew = 0 'so creatdo won't change l2 or l1
ELSE
armor = narm: RemoveGoody num, false: SetCombatStats: DisplayCharacter
END IF
ELSE
LjnkBig 93, 13, 14, 93, 36, 7, bl, 2, 2
END IF
f = 0
RETURN
damshield:
num = 0
FOR k = 1 TO ngoody
IF goody(k, 1) = -5 THEN num = k
NEXT
IF num = 0 THEN RETURN
goody(num, 4) = goody(num, 4) - 1
inew = -ABS(inew) 'so creatdo won't change l2
IF goody(num, 4) < 1 THEN
FOR mmm = 1 TO ngoody
IF ABS(goody(mmm, 1)) = 7 AND goody(mmm, 11) = 16 AND goody(mmm, 3) > 0 THEN
IF cRoll(10) < 9 THEN nobrk = true
END IF
NEXT
l2 = "****** " + UCASE$(jnk$(93, 13, 5) + jnk$(93, 43, 6) + jnk$(93, 23, 13)) + " ******"
IF nobrk THEN
goody(num, 4) = cRoll(2): goody(num, 5) = goody(num, 5) - 1
l1 = l2: ljnk 123, 13, 33, 2: c = 0: cc = 0
inew = 0 'so creatdo won't change l2 or l1
ELSE
shield = nsh: RemoveGoody num, false: SetCombatStats: DisplayCharacter
END IF
ELSE
ljnk 315, 1, 22, 2
END IF
f = 0
RETURN
END SUB
SUB CreatDo
IF incastle = -1 THEN
chan = (4 - 6 * (beryum <> 0)) * (1 + (nnear = 0)) * (1 + tent)
SELECT CASE castle
CASE 1: IF castlelevel = elvislevel THEN chan = 0
CASE 2: IF castlelevel = -7 THEN chan = 0
CASE 3: IF castlelevel = 5 THEN chan = 0
CASE 4: IF castlelevel = 7 THEN chan = 0
CASE 5: IF castlelevel = -5 THEN chan = 0
CASE 6: IF castlelevel = grinchlevel THEN chan = 0
END SELECT
ELSEIF incastle = 0 THEN
chan = (8 - 16 * (beryum <> 0) - 4 * (terrain = 15) - 4 * (terrain = 177)) * (1 + tent)
END IF
IF incastle <> 1 AND cRoll(15) = 1 THEN CreatSort nnear, tentgrab, ncre(0, 0)
IF cRoll(1000) < chan THEN MakeCreature 0, 0, true, false: Awaken nnear
ErasePut
FOR i = 1 TO nnear
typ = ncre(i, 1): kild = false: touch = false: ClearMess
xx = ncre(i, 4): yy = ncre(i, 5): wake = false
srxxyy = SameRoom(xx, yy)
IF (ncre(i, 11) AND 1) = 0 THEN
chan = 3 - 3 * asleep - 30 * srxxyy
IF beryum AND NOT (typ = elvis OR typ = elvimp) THEN
wake = true
ELSEIF ncre(i, 11) AND 56 THEN 'sneeze, burp, sick
wake = true
ELSEIF incastle = 1 THEN
ccc = cRd(xx, yy)
IF (ccc <= 2) OR (srxxyy AND (ccc <= 12)) OR (cRoll(1000) < chan) THEN wake = true
ELSEIF i = tentgrab THEN
wake = true
ELSEIF cRoll(1000) < chan AND typ <= ncreat + creextra + 1 THEN
wake = true
END IF
IF wake THEN Awaken i ELSE ncre(i, 11) = 0 'if asleep, no sneeze etc
END IF
IF i = tentgrab THEN touch = true
SELECT CASE typ
CASE elvis, trump
IF (NOT srxxyy) AND cRoll(10) = 1 AND ((ncre(i, 11) AND 56) = 0) THEN ncre(i, 11) = ncre(i, 11) AND (NOT 1)
CASE mph: ncre(i, 2) = ncre(i, 2) - (cRoll(20) = 1)
CASE grinch, max: ncre(i, 6) = ABS(ncre(i, 6))
END SELECT
IF (ncre(i, 10) AND 256) THEN ncre(i, 2) = ncre(i, 2) + 1
IF (ncre(i, 10) AND 2048) THEN ncre(i, 2) = ncre(i, 2) + 3
IF ncre(i, 2) > ncre(i, 3) THEN ncre(i, 2) = ncre(i, 3)
IF ((ncre(i, 11) AND 1) = 0) OR bitit GOTO ncd
creconfu = false
IF (ncre(i, 11) AND 8) THEN 'sick
IF cRoll(9) = 1 THEN ncre(i, 11) = ncre(i, 11) AND (NOT 8)
IF srxxyy THEN
LjnkBig 343, 61, 8, 0, 0, 0, Der$(false, i, 2), 0, 1
MaybeMessPause 2, 0
END IF
GOTO ncd
ELSEIF (ncre(i, 11) AND 16) THEN 'burping
IF cRoll(12) = 1 THEN ncre(i, 11) = ncre(i, 11) AND (NOT 16)
IF srxxyy THEN
LjnkBig 162, 61, 8, 0, 0, 0, Der$(false, i, 2), 0, 1
MaybeMessPause 2, 0
END IF
GOTO ncd
ELSEIF (ncre(i, 11) AND 32) THEN 'sneezing
IF cRoll(18) = 1 THEN ncre(i, 11) = ncre(i, 11) AND (NOT 32)
IF srxxyy THEN
LjnkBig 385, 60, 9, 0, 0, 0, Der$(false, i, 2), 0, 1
MaybeMessPause 2, 0
END IF
GOTO ncd
ELSEIF (ncre(i, 11) AND 6) THEN 'blind or confused
IF cRoll(30) = 1 THEN ncre(i, 11) = ncre(i, 11) AND (NOT 2)
IF cRoll(15) = 1 THEN ncre(i, 11) = ncre(i, 11) AND (NOT 4)
creconfu = NOT (tentgrab = i)
END IF
range = cRd(xx, yy): IF range < 1 THEN range = 1
SELECT CASE typ
CASE robot, rdro, ddro, sdro
attackrange = (ncre(i, 14) \ 10) MOD 10
CASE ELSE
attackrange = Creature(typ, 7) MOD 100
END SELECT
IF ncre(i, 13) THEN ncre(i, 6) = ABS(ncre(i, 6)) 'no flee if constrict
IF srxxyy OR (typ = brain) THEN
SELECT CASE typ
CASE grinch, max, elvis: sensed = true
CASE gramp: sensed = (bergreen = 0)
CASE lily, eddie, mara
sensed = ((invisible = 0) OR (cRoll(range * 4) = 1))
sensed = (sensed OR (beryum <> 0)) AND (bergreen = 0)
CASE skip: sensed = ((invisible = 0) OR (cRoll(range * 4) = 1))
sensed = sensed OR (beryum <> 0) OR (cRoll(2) = 1)
CASE brain: sensed = (mindweb = false)
CASE ELSE: sensed = ((invisible = 0) OR (cRoll(range * 4) = 1))
sensed = sensed AND ((camosuit = 0) OR (cRoll(6) <> 1))
sensed = sensed OR (beryum <> 0)
END SELECT
sensed = sensed AND ((NOT creconfu) OR (cRoll(3) = 1))
sensed = sensed OR (tentgrab = i)
FOR j = 6 TO 14 STEP 2
atype = Creature(typ, j + 1) \ 100
IF (ncre(i, 13) AND (2 ^ (j \ 2 - 2))) AND (atype = 12) THEN sensed = true
NEXT j
ELSE
sensed = false
END IF
IF (range <= attackrange) AND (ncre(i, 6) >= 0) AND sensed THEN
IF (typ = elvis) THEN
noimpersonators = true
FOR zn = 1 TO nnear
IF ncre(zn, 1) = elvimp THEN noimpersonators = false: zn = nnear
NEXT zn
IF noimpersonators THEN
finishedcastles = finishedcastles OR 1
xdro = xx + localx: ydro = yy + localy: candrop = false
WHILE NOT candrop
xdro = xdro + cRoll(3) - 2: ydro = ydro + cRoll(3) - 2
IF xdro < 2 OR xdro > 50 THEN xdro = xx + localx
IF ydro < 2 OR ydro > 20 THEN ydro = yy + localy
GetSym ss, xdro, ydro, fc, bc, 2: IF ss = 250 THEN candrop = true
WEND
AddToDrop -nberry - 5: putsym 145, xdro, ydro, 1, 0, -1 'drop BSS
drgoody(1, 15) = xdro: drgoody(1, 16) = ydro
st1 = RTRIM$(LTRIM$(name$)): blpos = INSTR(st1, bl)
IF blpos = 0 THEN blpos = LEN(st1) + 1
IF blpos > 13 THEN blpos = 13