-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrintChar.pas
1346 lines (1107 loc) · 43.1 KB
/
PrintChar.pas
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) 2024 Jeffrey Getzin.
Licensed under the GNU General Public License v3.0 with additional terms.
See the LICENSE file in the repository root for details.
*)
[Inherit ('SYS$LIBRARY:STARLET','Types','LIBRTL','SMGRTL','STRRTL')]Module PrintCharacter;
Const
Success = '* * * Success! * * *';
Failure = '* * * Failure * * *';
Done_It = '* * * Done! * * *';
Up_Arrow = CHR(18); Down_Arrow = CHR(19);
Left_Arrow = CHR(20); Right_Arrow = CHR(21);
ZeroOrd=ORD('0');
Cler_Spell = 1; Wiz_Spell = 2;
Type
Spell_List_Type = Set of Spell_Name;
Spell_List = Packed Array [1..9] of Spell_List_Type;
ItemSet = ^ItemNode;
ItemNode = Record
Identified: Boolean; { Is the item identified? }
Item_Num: Integer; { Which item is it? }
Position: 1..8; { Where is it held? }
Next_Item: ItemSet; { The other items... }
End;
Choice_Array = Array [Item_Type] of ItemSet;
Var
No_Magic: [Global]Boolean;
Camp_Spells: [Global]Set of Spell_Name;
SpellDisplay: Unsigned;
ScreenDisplay,keyboard,pasteboard,campdisplay,optionsdisplay,characterdisplay: [External]Unsigned;
CommandsDisplay,spellsdisplay,messagedisplay,monsterdisplay,viewdisplay,GraveDisplay: [External]Unsigned;
Rounds_Left: [External]Array [Spell_Name] of Unsigned;
Maze: [External]Level;
Direction: [External]Direction_Type;
Location: [External]Place_Type;
Spell: [External]Array [Spell_Name] of Varying [4] of Char;
PosX,PosY,PosZ: [Byte,External]0..20;
AbilName: [External]Array [1..7] of Packed Array [1..12] of char;
Item_List: [External]List_of_Items;
WizSpells,ClerSpells: [External]Spell_List;
Item_Name: [External]Array [Item_Type] of Varying [7] of char;
(******************************************************************************)
[External]Function Spell_Duration (Spell: Spell_Name; Caster_Level: Integer):Integer;External;
[External]Procedure Ring_Bell (Display_Id: Unsigned; Number_of_Times: Integer:=1);External;
[External]Procedure Special_Occurance (Var Character: Character_Type; Number: Integer);External;
[External]Procedure Delay (Seconds: Real);External;
[External]Function Get_Level (Level_Number: Integer; Maze: Level; PosZ: Vertical_Type:=0): [Volatile]Level;External;
[External]Procedure Change_Score (Var Character: Character_Type; Score_Num, Inc: Integer);External;
[External]Procedure No_Cursor;External;
[External]Procedure Cursor;External;
[External]Function String(Num: Integer; Len: Integer:=0):Line;External;
[External]Function Make_Choice (Choices: Char_Set; Time_Out: Integer:=-1;
Time_Out_Char: Char:=' '): Char;External;
[External]Function Yes_or_No (Time_Out: Integer:=-1;
Time_Out_Char: Char:=' '): [Volatile]Char;External;
[External]Function Zero_Through_Six (Var Number: Integer; Time_Out: Integer:=-1;
Time_Out_Char: Char:='0'): Char;External;
[External]Procedure Race_Adjustments (Var Character: Character_Type; Race: Race_Type);External;
[External]Procedure Wait_Key (Time_Out: Integer:=-1);External;
[External]Function Get_Num (Display: Unsigned): Integer;External;
[External]Function Roll_Die (Die_Type: Integer): [Volatile]Integer;External;
[External]Function Random_Number (Die: Die_Type): [Volatile]Integer;External;
[External]Function Made_Roll (Needed: Integer): [Volatile]Boolean;external;
[External]Function Compute_AC (Character: Character_Type; PosZ: Integer:=0): Integer;external;
[External]Function Regenerates (Character: Character_Type; PosZ: Integer:=0):Integer;external;
[External]Function Alive (Character: Character_Type): Boolean;External;
[External]Procedure Find_Spell_Group (Spell: Spell_Name; Character: Character_Type; Var Class,Level: Integer);External;
[External]Function Caster_Level (Cls: Integer; Character: Character_Type): Integer;External;
[External]Procedure Cast_Camp_Spell (Var Character: Character_Type; Var Leave_Maze: Boolean; Direction: Direction_Type;
Var Party: Party_Type; Var Party_Size: Integer);External;
[External]Procedure Handle_Spell (Var Character: Character_Type; Spell: Spell_Name; Class,Spell_Level: Integer; Var Leave_Maze: Boolean;
Direction: Direction_Type; Var Party: Party_Type; Var Party_Size: Integer; Item_Spell: Boolean:=False);External;
(******************************************************************************)
Function Can_Use (Character: Character_Type; Stats: Equipment_Type): Boolean;
Var
Temp: Boolean;
Item: Item_Record;
Begin { Can Use }
Item:=Item_List[Stats.Item_Num];
Temp:=Stats.isEquipped or (Item.kind=Scroll);
Temp:=Temp and ((Item.Spell_Cast<>NoSp) or (Item.Special_Occurance_No>0));
Temp:=Temp and ((Item.Alignment=NoAlign) or (Item.Alignment=Character.Alignment));
Temp:=Temp and ((Character.Class in Item.Usable_By) or (Character.PreviousClass in Item.Usable_By));
Can_Use:=Temp;
End; { Can Use }
(******************************************************************************)
Function Can_Identify (Character: Character_Type): Boolean;
Begin { Can Identify }
Can_Identify:=((Character.Class=Bard) or (Character.PreviousClass=Bard)) and (Character.No_of_Items>0);
End; { Can Identify }
(******************************************************************************)
Function Can_Trade (Character: Character_Type; Party_Size: Integer): Boolean;
Begin { Can Trade }
Can_Trade:=(Party_Size > 1) and ((Character.No_Of_Items>0) or (Character.Gold>0));
End; { Can Trade }
(******************************************************************************)
Procedure Initialize;
Begin { Initialize }
Camp_Spells:=[AnDe,Crlt,Lght,CrPs,CrSe,CoLi,CrVs,CrCr,Raze,heal,Ress,WoRe,PaHe,Loct,LtId,BgId,DuBl,Tele,Rein,DiPr,HgSh,Comp,CrPa,
UnCu,Levi,ReFe,DetS];
No_Magic:=False;
If PosZ > 0 then No_Magic:=(Maze.Special_Table[Maze.Room[PosX,PosY].Contents].Special=AntiMagic);
End; { Initialize }
(******************************************************************************)
[Global]Function Center_Text (Txt: Line; Line_Length: Integer:=80): Integer;
Var Half: Integer;
Indent: Integer;
Begin { Center Text }
Indent:=Txt.Length div 2;
Half:=Line_Length Div 2;
Center_Text:=Half-Indent;
End; { Center Text }
(******************************************************************************)
Procedure Print_Item (Character: Character_Type; Position: Integer);
Var
Item: Item_Record;
Temp: Equipment_Type;
Begin
If Position Mod 2=1 then SMG$Erase_Line(ScreenDisplay);
SMG$Put_Chars (ScreenDisplay,
String(Position,1)
+')');
If Position<=Character.No_of_Items then
Begin
Temp:=Character.Item[Position];
Item:=Item_List[Temp.Item_num];
If (Temp.isEquipped) and (Temp.Cursed) then
SMG$Put_Chars (ScreenDisplay,
'-')
Else
If Temp.isEquipped then
SMG$Put_Chars (ScreenDisplay,
'*')
Else
If Not((Character.class in Item.usable_by) or (Character.PreviousClass in Item.Usable_By)) or
((Character.Alignment<>Item.Alignment) and (Item.Alignment<>NoAlign)) then
SMG$Put_Chars (ScreenDisplay,
'#')
Else
SMG$Put_Chars (ScreenDisplay,
' ');
If Temp.Ident then
SMG$Put_Chars (ScreenDisplay,
Pad(Item.True_Name,
' ',20))
Else
SMG$Put_Chars (ScreenDisplay,
Pad(Item.Name,
' ',20));
End;
If (Position Mod 2)=0 then SMG$Put_Line (
ScreenDisplay, '')
Else SMG$Set_Cursor_ABS (
ScreenDisplay,,32);
End;
(******************************************************************************)
Procedure Print_Equipment (Character: Character_Type);
Var
Eq: Integer;
Begin { Print Equipment }
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Set_Cursor_ABS (ScreenDisplay,14,5);
SMG$Put_Line (ScreenDisplay, '* = Equipped, - = Cursed, ? = Unknown, # = Unusable');
For Eq:=1 to 8 do
Print_Item (Character,Eq);
SMG$End_Display_Update (ScreenDisplay);
End; { Print Equipment }
(******************************************************************************)
[Global]Function Choose_Item (Character: Character_Type; Action: Line): [Volatile]Integer;
Var
Choices: Char_Set;
Answer: Char;
Begin { Choose Item }
If Character.No_of_items>0 then
Begin
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay,19,1);
Print_Equipment (Character);
SMG$Put_Line (ScreenDisplay, Action + ' which item? (1-' + String(Character.No_of_items,1) + ', [RETURN] exits)', 0);
SMG$End_Display_Update (ScreenDisplay);
Choices:=['1'..CHR(Character.No_of_Items + ZeroOrd),CHR(13)];
Answer:=Make_Choice(Choices);
If Answer=CHR(13)
then Answer:='0';
Choose_Item:=Ord(Answer)-ZeroOrd;
End
Else
Choose_Item:=0;
End; { Choose Item }
(******************************************************************************)
[Global]Function Choose_Character (Txt: Line; Party: Party_Type; Party_Size: Integer; HP: Boolean:=False;
Items: Boolean:=False): [Volatile]Integer;
Var
StatusName: [External]Array [Status_Type] of Varying [14] of char;
Character,Temp: Integer;
Options: Char_Set;
Answer: Char;
Begin { Choose Character }
Temp:=0;
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay,14,1);
SMG$Set_Cursor_ABS (ScreenDisplay,15,1);
Options:=['1'..CHR(Party_Size + 48)]+[CHR(13)];
For Character:=1 to Party_size do
Begin
SMG$Put_Chars (ScreenDisplay,
CHR(Character + 48)
+') '
+Pad(Party[Character].Name, ' ',20));
If HP then
Begin
SMG$Put_Chars (ScreenDisplay,
' '
+String(Party[Character].Curr_HP,4)
+'/'
+String(Party[Character].Max_HP,4));
SMG$Put_Chars (ScreenDisplay,
' '
+StatusName[Party[Character].Status][1]);
SMG$Put_Chars (ScreenDisplay,
StatusName[Party[Character].Status][2]);
End;
If Items and not HP then SMG$Put_Chars (ScreenDisplay,
' ('
+String(Party[Character].No_of_Items)
+' items ) ');
If (Character mod 2)=0 then
SMG$Put_Line (ScreenDisplay,
'')
Else
Begin
SMG$Put_Chars (ScreenDisplay,
' ');
If Not (Items or HP) then SMG$Put_Chars (ScreenDisplay,
Pad('',' ',13));
End;
End;
SMG$Put_Line (ScreenDisplay,
'');
SMG$Put_Chars (ScreenDisplay,Txt,19,1);
SMG$End_Display_Update (ScreenDisplay);
Answer:=Make_Choice (Options);
If Answer=CHR(13) then Temp:=0
Else Temp:=Ord(Answer)-48;
Choose_Character:=Temp;
End; { Choose Character }
(******************************************************************************)
[Global]Procedure Get_Rid_of_Item (Var Character: Character_Type; Which_Item: Integer);
Var
Loop: Integer;
Begin
If Which_Item<>Character.No_of_Items then
For Loop:=Which_Item to Character.No_of_Items-1 do
Character.Item[Loop]:=Character.Item[Loop + 1];
Character.No_of_Items:=Max(Character.No_of_Items - 1, 0);
End;
(******************************************************************************)
Procedure Drop_Item (Var Character: Character_Type);
Var
Num: Integer;
Begin
Num:=Choose_Item (Character, 'Drop');
If Num <> 0 then
If Character.Item[Num].Cursed then
Begin
SMG$Put_Line (ScreenDisplay,'That item is cursed.',0);
Delay(1);
End
Else If Character.Item[Num].isEquipped then
Begin
SMG$Put_Line (ScreenDisplay,'That item is equipped.',0);
Delay(1);
End
Else
Begin
Get_Rid_of_Item (Character,Num);
Print_Equipment (Character);
SMG$Put_Line (ScreenDisplay,'Dropped.',0);
Delay(1);
End;
End;
(******************************************************************************)
[Global]Function Usable_Item (Character: Character_Type; Item: Item_Record): Boolean;
Var
Temp: Boolean;
Begin
Temp:=(Character.Class in Item.Usable_By) or (Character.PreviousClass in Item.Usable_By);
Temp:=Temp and ((Character.Alignment=Item.Alignment) or (Item.Alignment=NoAlign));
Usable_Item:=Temp;
End;
(******************************************************************************)
Procedure Item_Breaks (Character: Character_Type; Var Equipment: Equipment_Type);
Var
Old_Item: Item_Record;
Begin
Old_Item:=Item_List[Equipment.Item_Num];
Equipment.Item_num:=Old_Item.Turns_Into;
Equipment.Cursed:=False;
Equipment.Ident:=False;
Equipment.isEquipped:=False;
Equipment.Usable:=Usable_Item (Character,Item_List[Equipment.Item_Num]);
End;
(******************************************************************************)
Procedure Collect_Items (Var Character: Character_Type; Var Choices: Choice_Array);
Var
Item: Item_Record;
Item_Kind: Item_Type;
Item_No,Num: Integer;
Temp: ItemSet;
Begin
Choices:=Zero;
Num:=Character.No_of_Items;
For Item_No:=1 to Num do
Begin
Item:=Item_List[Character.Item[Item_No].Item_Num];
If Not (Character.item[Item_no].Cursed) and Usable_Item (Character,Item) then
Begin
Item_Kind:=Item.Kind;
New (Temp);
Temp^.Identified:=Character.Item[Item_No].Ident;
Temp^.Next_Item:=Choices[Item_Kind];
Temp^.Item_Num:=Item.Item_Number;
Temp^.Position:=Item_No;
Choices[Item_Kind]:=Temp;
End;
End;
For Item_No:=1 to Num do
If Character.Item[Item_No].Cursed then
Choices[Item.Kind]:=Nil
Else
Character.Item[Item_No].isEquipped:=False;
End;
(******************************************************************************)
Procedure Delete (Node: ItemSet; Var List: ItemSet);
Var
Temp: ItemSet;
Begin
If List<>Nil then
If List=Node then
Begin
Temp:=List;
List:=List^.Next_Item;
End
Else
Begin
Temp:=List^.Next_Item;
Delete (Node,Temp);
List^.Next_Item:=Temp;
End;
End;
(******************************************************************************)
Procedure Print_Centered_Text (L: Line; W: Integer:=80);
Begin
SMG$Put_Chars (ScreenDisplay,L,,Center_Text(L));
SMG$Put_Line (ScreenDisplay,'');
End;
(******************************************************************************)
Function Choose_From_List (Class,Class1: Class_Type; Var Choices: ItemSet; kind: Item_Type; name: Name_Type): [Volatile]ItemSet;
Var
loop,chosen: Integer;
temp,tempPtr: ItemSet;
options: Set of Char;
answer: Char;
item: Item_Record;
Begin
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay);
Print_Centered_Text ('Please select a '+item_name[kind]+' for '+name);
Options:=[CHR(13)];
Loop:=0;
tempPtr:=choices;
While tempPtr<>Nil do
Begin
loop:=loop + 1;
item:=Item_List[TempPtr^.Item_Num];
If (Class in Item.Usable_By) or (Class1 in Item.Usable_By) then
Begin
SMG$Put_Chars (ScreenDisplay, '['+CHR(Loop + 64)+'] ');
If TempPtr^.Identified then
SMG$Put_Line (ScreenDisplay,Item.True_Name)
Else
SMG$Put_Line (ScreenDisplay,Item.Name);
Options:=Options+[CHR(Loop + 64)];
End;
TempPtr:=TempPtr^.Next_Item;
End;
SMG$Put_Line (ScreenDisplay,'Which?',0);
SMG$End_Display_Update (ScreenDisplay);
Answer:=Make_Choice (Options);
If Answer<>CHR(13) then
Begin
Chosen:=Ord(Answer)-64;
TempPtr:=Choices;
If Chosen>1 then
For Loop:=2 to Chosen do
TempPtr:=TempPtr^.Next_Item;
Temp:=TempPtr;
Delete (TempPtr,Choices);
End
Else
Temp:=Nil;
Choose_From_List:=Temp;
End;
(******************************************************************************)
Procedure Select_Item (Var Character: Character_Type; Kind: Item_Type; Var Choices: ItemSet);
Var
ItemPtr: ItemSet;
Item: Item_Record;
Begin
If Choices<>Nil then
Begin
ItemPtr:=Choose_From_List (Character.Class,Character.PreviousClass,Choices,Kind,Character.Name);
If ItemPtr<>Nil then
Begin
Item:=Item_List[ItemPtr^.Item_Num];
Character.Item[ItemPtr^.Position].Ident:=ItemPtr^.Identified;
Character.Item[ItemPtr^.Position].Cursed:=Item.cursed;
Character.Item[ItemPtr^.Position].isEquipped:=True;
If Character.Item[ItemPtr^.Position].Cursed then
Begin
SMG$Put_Line (ScreenDisplay,'Cursed!!!',1,1);
Ring_Bell (ScreenDisplay,3);
Delay(2)
End
End
End
End;
(******************************************************************************)
Function Not_Stuck (Character: Character_Type; Kind: Item_Type): Boolean;
Var
Loop: Integer;
Temp: Boolean;
Item: Item_Record;
Begin
If Character.No_of_Items=0 then
Not_Stuck:=True
Else
Begin
Temp:=True;
For Loop:=1 to Character.No_of_Items do
Begin
Item:=Item_List[Character.Item[Loop].Item_Num];
If (Character.Item[Loop].Cursed) and (Item.Kind=kind) then
Temp:=False;
End;
Not_Stuck:=Temp;
End;
End;
(******************************************************************************)
Procedure Redistribute_Remainders (Var Choices: Choice_Array);
Var
Kind: Item_Type;
Traveller: ItemSet;
Temp: ItemSet;
Begin
For Kind:=Weapon to Cloak do
Begin
Traveller:=Choices[Kind];
While Traveller<>Nil do
Begin
Temp:=Traveller;
Traveller:=Traveller^.Next_Item;
Dispose (Temp);
End;
Choices[Kind]:=Nil;
End;
End;
(******************************************************************************)
Procedure Special_Occurances (Var Character: Character_Type);
Var
Item: Integer;
T: Line;
Character_Item: Item_Record;
Begin
For Item:=1 to Character.No_of_Items do
Begin
Character_Item:=Item_List[Character.Item[Item].Item_Num];
If (Character_Item.Special_Occurance_No>0) and (Character.Item[Item].isEquipped) then
Begin
T:='Dost thou wish to invoke the special power of thine ';
If Character.Item[Item].Ident then
T:=T + Character_Item.True_Name
Else
T:=T + Character_Item.Name;
T:=T+'?';
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay);
SMG$Put_Chars (ScreenDisplay,T,1,Center_Text(T));
SMG$End_Display_Update (ScreenDisplay);
If Yes_or_No='Y' then
Begin
Special_Occurance (Character,Character_Item.Special_Occurance_No);
If Made_Roll (Character_Item.Percentage_Breaks) then
Item_Breaks (Character,Character.Item[Item]);
End;
End;
End;
End;
(******************************************************************************)
Procedure Equip_Character (Var Character: Character_Type);
Var
Choices: Choice_Array;
Kind: Item_Type;
Begin
Choices:=Zero;
Collect_Items (Character,Choices);
For Kind:=Weapon to Cloak do
If Not_Stuck (Character,Kind) and (Choices[Kind]<>Nil) and (Kind<>Scroll) then
Select_Item (Character,Kind,Choices[Kind]);
Redistribute_Remainders (Choices);
Special_Occurances (Character);
Character.Armor_Class:=Compute_AC (Character,PosZ);
Character.Regenerates:=Regenerates (Character,PosZ);
End;
(******************************************************************************)
Procedure Identify_Object (Var Character: Character_Type);
Var
Item,Chance: Integer;
T: Line;
Hold_Item: Item_Record;
Begin
If Character.No_of_Items>0 then
Item:=Choose_Item (Character,'Identify')
Else
Item:=0;
If (Item>0) then
Begin
Hold_Item:=Item_List[Character.Item[Item].Item_Num];
T:='';
Case Character.Class of
Bard: Case Character.PreviousClass of
Bard: Chance:=4 * Max(Character.Level,Character.Previous_Lvl);
Otherwise Chance:=4 * Character.Level;
End;
Otherwise Chance:=4 * Character.Previous_Lvl;
End;
Chance:=Chance-Round(Hold_Item.Item_Number * (1/8));
If Character.Items_Seen[Hold_Item.Item_Number] then
Chance:=Chance+Trunc(Chance*15/100);
If Made_Roll (Chance) then
Begin
T:=Success;
Character.Item[Item].Ident:=True;
Character.Items_Seen[Hold_Item.Item_Number]:=True;
End
Else
Begin
T:=Failure;
If Made_Roll (Chance) then
Begin
If Hold_Item.Cursed and Made_Roll (27) then
Begin
Character.Item[Item].isEquipped:=true;
Character.Item[Item].Cursed:=True;
Equip_Character (Character);
T:='';
End
End;
End;
SMG$Put_Chars (ScreenDisplay,T,23,Center_Text(T));
Delay(1)
End
End;
(******************************************************************************)
Procedure Print_Spell_Points (Character: Character_Type);
Var
Caster_Name: Array [Cler_Spell..Wiz_Spell] of Line;
Spell_Level,Spell_Type: Integer;
T: Line;
Begin
SMG$Begin_Display_Update (ScreenDisplay);
Caster_Name[Cler_Spell]:='Cleric spell points';
Caster_Name[Wiz_Spell] :='Wizard spell points';
For Spell_Type:=Cler_Spell to Wiz_Spell do
Begin
T:=' '+Caster_Name[Spell_Type]+' /';
For Spell_Level:=1 to 9 do
T:=T + String(Character.SpellPoints[Spell_Type,Spell_Level],1)+'/';
SMG$Put_Line (ScreenDisplay, T);
End;
SMG$End_Display_Update (ScreenDisplay);
End;
(******************************************************************************)
Procedure Print_Spells_of_a_Class (Class: Class_Type; SpellList: Spell_List_Type; List: Spell_List);
Var
Level,X,Y: Integer;
Loop: Spell_Name;
Printed: Set of Spell_Name;
Long_Spell: [External]Array [Spell_Name] of Varying [25] of Char;
Begin
Printed:=[];
X:=1; Y:=2;
For Level:=1 to 9 do
For Loop:=MIN_SPELL_NAME to MAX_SPELL_NAME do
If (Loop in (SpellList * List[Level])) and Not (Loop in Printed) then
Begin
Printed:=Printed+[Loop];
SMG$Put_Chars (ScreenDisplay,Long_Spell[Loop]+'('+Spell[Loop]+')['+String(Level)+']',Y,X);
If Y>22 then
Begin
Y:=2;
X:=35;
End
Else
Y:=Y + 1;
End;
End;
(******************************************************************************)
Procedure List_Spells (Character: Character_Type; Class: Class_Type);
Var
SpellList: Spell_List_Type;
List: Spell_List;
ClassName: [External]Array [Class_Type] of Varying [13] of char;
Begin
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay);
SMG$Home_Cursor (ScreenDisplay);
SMG$Put_Line (ScreenDisplay,Pad('',' ',Center_Text(ClassName[Class]))+ClassName[Class],1,1);
If Class=Cleric then
Begin
SpellList:=Character.Cleric_Spells;
List:=ClerSpells;
End
Else
Begin
SpellList:=Character.Wizard_Spells;
List:=WizSpells;
End;
If SpellList=[] then
SMG$Put_Line (ScreenDisplay,'Thou have no '+ClassName[Class]+' spells.',0)
Else
Print_Spells_of_a_Class (Class,SpellList,List);
SMG$Put_Chars(ScreenDisplay,'Press any key to continue',23,27,1);
SMG$End_Display_Update (ScreenDisplay);
Wait_Key;
End;
(******************************************************************************)
Procedure Print_Books (Character: Character_Type);
Var
Answer: Char;
Begin
Repeat
Begin
SMG$Begin_Display_Update (ScreenDisplay);
SMG$Erase_Display (ScreenDisplay);
SMG$Put_Line (ScreenDisplay,'');
Print_Spell_Points (Character);
SMG$Put_Line (ScreenDisplay,'');
SMG$Put_Line (ScreenDisplay,'Thou may read thine W)izard spell book, thine C)leric spell book, or L)eave',0);
SMG$End_Display_Update (ScreenDisplay);
Answer:=Make_Choice(['C','W','L']);
Case Answer of
'W': List_Spells (Character,Wizard);
'C': List_Spells (Character,Cleric);
'L': ;
End;
End;
Until Answer='L';
End;
(******************************************************************************)
Function Scenarios_Won (P: Int_Set): Integer;
Var
Temp,Loop: Integer;
Begin { Scenarios Won }
Temp:=0;
For Loop:=0 to 999 do
If P[Loop] then Temp:=Temp + 1;
Scenarios_Won:=Temp;
End; { Scenarios Won }
(******************************************************************************)
Function Print_Wins (Character: Character_Type): Line;
{ Indicates how many scenarios this character has beaten }
Var
Num,Loop: Integer;
T: Line;
Begin { Print Wins }
T:='';
Num:=Scenarios_Won (Character.Scenarios_Won);
If Num>8 then
Begin
T:='';
For Loop:=1 to Num-8 do
T:=T+'*';
End;
Print_Wins:=T;
End; { Print Wins }
(******************************************************************************)
Procedure Print_Top_Line (Character: Character_Type);
Var
ClassName: [External]Array [Class_Type] of Varying [13] of char;
AlignName: [External]Array [Align_Type] of Packed Array [1..7] of char;
RaceName: [External]Array [Race_Type] of Packed Array [1..12] of char;
SexName: [External]Array [Sex_Type] of Packed Array [1..11] of char;
Begin { Print Top Line }
SMG$Put_Chars (ScreenDisplay,
'Name: '
+Pad(Character.Name,' ',21));
If Character.Sex=NoSex then
SMG$Put_Chars (ScreenDisplay,
' ')
Else
SMG$Put_Chars (ScreenDisplay,
SexName[Character.Sex][1]
+'-');
If Character.Race=NoRace then
SMG$Put_Chars (ScreenDisplay, ' ')
Else
SMG$Put_Chars (screenDisplay, RaceName[Character.Race] + ' ');
If Character.Alignment=NoAlign then
SMG$Put_Chars (ScreenDisplay, ' ')
Else
SMG$Put_Chars (ScreenDisplay, AlignName[Character.Alignment][1] + '-');
If Character.Class<>NoClass then
Begin
SMG$Put_Chars (ScreenDisplay,
ClassName[Character.Class] );
If Character.PreviousClass<>Noclass then
SMG$Put_Chars (ScreenDisplay,
'/'+
ClassName[Character.PreviousClass] )
End;
If Character.Psionics then
Begin
SMG$Put_Chars (ScreenDisplay, ' (');
If Character.DetectTrap<>0 then
SMG$Put_Chars (ScreenDisplay, 'T');
If Character.DetectSecret<>0 then
SMG$Put_Chars (ScreenDisplay, 'S');
If Character.Regenerate<>0 then
SMG$Put_Chars (ScreenDisplay, 'R');
SMG$Put_Chars (ScreenDisplay, ')');
End;
SMG$Put_Line (ScreenDisplay,
'');
Case Scenarios_Won (Character.Scenarios_Won) of
0: SMG$Put_Line (ScreenDisplay,
'');
1: SMG$Put_Line (ScreenDisplay,
'Rank: Private');
2: SMG$Put_Line (ScreenDisplay,
'Rank: Corporal');
3: SMG$Put_Line (ScreenDisplay,
'Rank: Sargent');
4: SMG$Put_Line (ScreenDisplay,
'Rank: Lieutenant');
5: SMG$Put_Line (ScreenDisplay,
'Rank: Captain');
6: SMG$Put_Line (ScreenDisplay,
'Rank: Major');
7: SMG$Put_Line (ScreenDisplay,
'Rank: Lt. Colonel');
8: SMG$Put_Line (ScreenDisplay,
'Rank: Colonel');
Otherwise SMG$Put_Line (ScreenDisplay,
'Rank: General ('
+Print_Wins(Character)
+')');
End;
End; { Print Top Line }
(******************************************************************************)
Procedure Print_Gold (Character: Character_Type);
Begin { Print Gold }
If Character.Age>0 then
Begin
SMG$Put_Chars (ScreenDisplay,
'Gold: ');
SMG$Put_Chars (ScreenDisplay,
String(Character.Gold,12));
End;
SMG$Put_Line (ScreenDisplay,
'');
End; { Print Gold }
(******************************************************************************)
Procedure Print_Experience (Character: Character_Type);
Begin { Print Experience }
If Character.Age>0 then
Begin
SMG$Put_Chars (ScreenDisplay,
'Experience: ');
SMG$Put_Chars(ScreenDisplay,
String(Trunc(Character.Experience),12));
End;
SMG$Put_Line (ScreenDisplay,'');
End; { Print Experience }
(******************************************************************************)
Procedure Print_Level_And_Age (Character: Character_Type);
Begin { Print Level and Age }
If Character.Age>0 then
Begin
SMG$Put_Chars (ScreenDisplay,
'Level: ');
SMG$Put_Chars (ScreenDisplay,
String(Character.Level,3));
If Character.PreviousClass <> NoClass then
SMG$Put_Chars (ScreenDisplay,
'/'
+String(Character.Previous_Lvl,3))
Else
SMG$Put_Chars (ScreenDisplay,
' ');
SMG$Put_Chars (ScreenDisplay,
' Age: ');
SMG$Put_Chars (ScreenDisplay,
String(Trunc(Character.Age/365),3));
End;
SMG$Put_Line (ScreenDisplay,'');
End; { Print Level and Age }
(******************************************************************************)
Procedure Print_Hit_Points_and_AC (Character: Character_Type);
Begin { Print Hit Points and Armor Class }
If Character.Age>0 then
Begin
SMG$Put_Chars (ScreenDisplay,
'Hit Points: ');
SMG$Put_Chars (ScreenDisplay,
String(Character.Curr_HP,5)
+'/'
+String(Character.Max_HP,5));
SMG$Put_Chars (ScreenDisplay,
' Armor Class: ');