-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMILCMD.PAS
5188 lines (4962 loc) · 187 KB
/
MILCMD.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
Procedure TrapCheck (Var Obj: ObjectPoint; Trap: Integer);
Var
Dmg: Integer;
Begin
Dmg := 0;
If Trap > 0
Then
If User^.Dex - Rnd (6) < Trap
Then
Begin
If Trap <= 35
Then
Case Trap of
1,2,3:
B1 := 'Splinters on your hand';
4,5:
B1 := 'Spring dart';
6:
B1 := 'Small knife flies at you';
7:
Begin
User^.Poisoned := True;
B1 := 'Poison dart'
End (*7*);
8:
B1 := 'Spear shoots out of the ground at you';
9:
B1 := 'Dust sprays in your eyes';
10:
B1 := 'Grubs bite you';
11:
B1 := 'Steel wire cuts your hand';
12:
B1 := 'Needles stab your toes';
13:
Begin
User^.Poisoned := True;
B1 := 'Poison needles'
End (*13*);
14:
Begin
User^.Poisoned := True;
B1 := 'Cobra lunges at you'
End (*14*);
15:
Begin
User^.Poisoned := True;
B1 := 'Gas spores explode'
End (*15*);
16:
B1 := 'Rocks fall from the ceiling';
17:
B1 := 'Blam! Explosion in your face';
18:
B1 := 'Acid splashes in your face';
19:
B1 := 'Flames shoot out at you';
20,21,22,23,24,25:
Begin
User^.Fatigue := 0;
B1 := 'Spear impales your stomach'
End (*20*);
26,27,28,29,30:
B1 := 'Boooooom';
31,32,33,34,35:
B1 := 'A rack of knives falls and crushes you'
End (*Case*)
Else
Begin
User^.Fatigue := 0;
B1 := 'Tons of rocks tumble down upon you'
End (*Else*);
B1 := '0' + B1 + '!';
QOut (Term, B1);
Dmg := Max (0, Trap + User^.AC - 10);
Dmg := Dmg Div 2 + Rnd (Dmg);
PrintDmg (User, Dmg, User^.Brief, B1);
B1 := '0It hits you for ' + B1;
QOut (Term, B1);
If User^.Hits + User^.Fatigue <= Dmg
Then
Begin
User^.Dead := True;
User^.Fatigue := 0;
User^.Hits := 0;
PS (User^.Name, B1);
B1 := '0### ' + B1 + ' was just killed by a deadly trap.';
For ILoop := 1 to MsgTerm (TermList, All) Do
QOut (TermList [ILoop], B1)
End (*If*)
Else
Begin
If Dmg > User^.Fatigue Then
User^.Hits := User^.Hits - Dmg + User^.Fatigue;
User^.Fatigue := Max (0, User^.Fatigue - Dmg)
End (*Else*)
End (*If*)
End (*TrapCheck*);
Procedure StopUsing (Usr: UserPoint; Object: ObjectPoint);
Begin
If Object <> NIL
Then
With Usr ^ Do
If Object = USWeap
Then
USWeap := NIL
Else
If Object = USShield
Then
Begin
AC := Max (-50, Min (50, AC + Object ^.ShPlus));
USShield := NIL
End (*If*)
Else
If Object = USArm
Then
Begin
AC := Max (-50, Min (50, AC + Object ^.ArmPlus));
USArm := NIL
End (*If*)
End (*StopUsing*);
Procedure GetObj (Var Word: Alfa; Num: Integer; Rm: RmCodeType);
Var
Obj2, Box, ObTail, Object: ObjectPoint;
Monster: MonsterPoint;
Num2, ILoop: Integer;
Where: (Ground,Container,NoWhere);
Held: Boolean;
Word2: Alfa;
Begin
Held := False;
With Room [Rm] Do
Begin
ObTail := RmObjectTail;
Box := NIL;
Where := Ground;
Object := FindObject (Word, Num, ObTail);
GetWord (Word2, Num2, Buffer, LenBuf, Loc);
If Word2 <> Blanks Then
Begin
Box := FindObject (Word2, Num, RmObjectTail);
If Box = NIL Then
Begin
Box := FindObject (Word2, Num, User^.ObjectTail);
If Box <> NIL Then
Held := True
End (*If*);
If Box <> NIL
Then
If Box ^.ObClass = Chest Then
If Not Box ^.Closed Then
Begin
ObTail := Box ^.ObjectTail;
Where := Container
End (*If*)
Else
Begin
Where := NoWhere;
QOut (Term, '0You can''t. It''s closed.')
End (*Else*)
Else
Begin
Where := NoWhere;
QOut (Term, '0That''s not a container.')
End (*Else*)
Else
Begin
Where := NoWhere;
QOut (Term, '0That container isn''t here.')
End (*Else*);
If Where = Container Then
Object := FindObject (Word, Num, ObTail)
End (*If*);
(* Pointer now equals object selected by user. *)
If (Object <> NIL) And (Where <> NoWhere)
Then
If Not Object ^.Carry Then
QOut (Term, '0You are not able to take that!')
Else
Begin
Monster := RmMonsterTail;
Num := 0;
While (Monster <> NIL) And (Num = 0) Do
If Monster ^.Guard and Not Held
Then
Num := 1
Else
Monster := Monster ^.Next;
If Num > 0
Then
Begin
PM (Monster, True, B1);
B1 := '0' + B1 + ' stops you from getting it.';
QOut (Term, B1)
End
Else
If (User^.Weight + Object^.Weight > User^.Str * 10) And
Not Held
Then
QOut (Term, '0It''s too much for you to carry!')
Else
Begin
If DeleteObject (Object, ObTail) Then
ObTail := ObTail ^.Next;
QOut (Term, '0Ok.');
Object ^.Invisible := False;
PS (User^.Name, B1);
PrintObj (Object ^, True, False, B2);
B1 := '0' + B1 + ' picked up ' + B2;
If Where = Container Then
Begin
PrintObj (Box ^, False, False, B2);
B1 := B1 + ' from inside ' + B2
End (*If*);
B1 := B1 + '.';
For ILoop := 1 to MsgTerm (TermList, Local) Do
QOut (TermList [ILoop], B1);
If Object ^.ObClass = Coins Then
Begin
User^.Money := User^.Money + Object ^.Price;
Writev (B1, '0You now have ', User^.Money: 0,
' shillings in cash.');
QOut (Term, B1);
Dispose (Object)
End (*If*)
Else
Begin
If Not Held Then
User^.Weight := Min (2500, User^.Weight +
Object ^.Weight);
If User^.ObjectTail = NIL Then
Begin
Object ^.Next := NIL;
User^.ObjectTail := Object
End (*If*)
Else
Begin
Obj2 := User^.ObjectTail;
While Obj2 ^.Next <> NIL Do
Obj2 := Obj2 ^.Next;
Obj2 ^.Next := Object;
Object ^.Next := NIL
End (*Else*)
End (*Else*);
If Where = Container
Then
Begin
Box ^.Weight := Max (0, Box ^.Weight -
Object ^.Weight);
Box ^.NumInside := Max (0, Box ^.NumInside - 1);
Box ^.ObjectTail := ObTail
End (*If*)
Else
RmObjectTail := ObTail
End (*Else*)
End (*Else*)
Else
If Where <> NoWhere Then
QOut (Term, '0That object isn''t here.')
End (*With*)
End (*GetObj*);
Procedure DropObj (Var Word: Alfa; Num: Integer; Rm: RmCodeType);
Var
Box, ObTail, Object: ObjectPoint;
Num2, ILoop: Integer;
Where: (Ground, Container, NoWhere);
Held: Boolean;
Word2: Alfa;
Begin
Held := False;
Object := FindObject (Word, Num, User^.ObjectTail);
If Object <> NIL
Then
Begin
ObTail := Room[Rm].RmObjectTail;
Box := Nil;
Where := Ground;
GetWord (Word2, Num2, Buffer, LenBuf, Loc);
Box := FindObject (Word2, Num2, Room[Rm].RmObjectTail);
If Box = NIL Then
Begin
Box := FindObject (Word2, Num, User^.ObjectTail);
If Box <> NIL Then
Held := True
End (*If*);
If Box <> NIL
Then
If Box ^.ObClass = Chest
Then
If Not Box ^.Closed
Then
Begin
ObTail := Box ^.ObjectTail;
If (Box ^.NumInside >= 6) or (Box ^.Weight > 200)
Then
Begin
PrintObj (Box ^, True, False, B1);
B1 := '0There is no more room inside ' + B1 +
' for more objects!';
QOut (Term, B1);
Where := NoWhere
End (*If*)
Else
If Box = Object
Then
Begin
Where := NoWhere;
QOut (Term,
'0You can''t put an object inside itself!')
End (*If*)
Else
Where := Container
End (*If*)
Else
Begin
Where := NoWhere;
QOut (Term, '0You can''t. It''s closed!')
End (*Else*)
Else
Begin
Where := NoWhere;
QOut (Term, '0It won''t fit in that!')
End (*Else*)
Else
If Word2 <> Blanks Then
Begin
Where := NoWhere;
QOut (Term, '0That container isn''t here!')
End (*If*);
If Where <> NoWhere
Then
Begin
If DeleteObject (Object, User^.ObjectTail) Then
User^.ObjectTail := User^.ObjectTail ^.Next;
Object ^.Next := ObTail;
ObTail := Object;
If Not Held Then
User^.Weight := Max (0, User^.Weight - Object ^.Weight);
StopUsing (User, Object);
If Where = Container
Then
Begin
QOut (Term, '0Ok. You drop it.');
Box^.Weight := Min (1000, Box^.Weight + Object^.Weight);
Box ^.NumInside := Min (10, Box ^.NumInside + 1);
Box ^.ObjectTail := ObTail
End (*If*)
Else
Begin
Room[Rm].RmObjectTail := ObTail;
QOut (Term, '0Ok.')
End (*Else*);
PS (User^.Name, B1);
PrintObj (Object ^, False, False, B2);
B1 := '0' + B1 + ' dropped ' + B2;
If Where = Container
Then
Begin
PrintObj (Box ^, True, False, B2);
B1 := B1 + ' into ' + B2
End (*If*);
B1 := B1 + '.';
For ILoop := 1 to MsgTerm (TermList, Local) Do
QOut (TermList [ILoop], B1)
End (*If*)
End (*If*)
Else
QOut (Term, '0You aren''t carrying that!')
End (*DropObj*);
Function SpellLimit: Boolean;
Begin
{
If User^.SpellDay >= 7
Then
Begin
SpellLimit := True;
QOut (Term, '0Daily spell limit exceeded, sorry.')
End
Else
Begin
SpellLimit := False;
User^.SpellDay := User^.SpellDay + 1
End
}
SpellLimit := False;
End (*SpellLimit*);
Function SpellCost (User: UserPoint;
Cost, MinLvl, MinInt: Integer): Boolean;
Begin
SpellCost := False;
With User^ Do
If Int < MinInt
Then
QOut (Term, '0You don''t have the intelligence to cast the spell.')
Else
Begin
MinLvl := MinLvl + 2;
Case Class of
Fighter:
MinLvl := MinLvl + 2;
Thief:
MinLvl := MinLvl + 1;
MagicUser:
MinLvl := MinLvl - 2;
Cleric:
MinLvl := MinLvl - 1;
Barbarian:
MinLvl := MinLvl + 3
End (*Case*);
If MinLvl > Lvl
Then
QOut (Term,
'0You aren''t high enough level to cast the spell!')
Else
If Magic - Cost < 0
Then
QOut (Term, '0You''re too weak to cast that spell.')
Else
Begin
Magic := Magic - Cost;
SpellCost := True
End (*Else*)
End (*Else*)
End (*SpellCost*);
Function Lk (Var Word: Alfa; Num: Integer; CmdCode: Integer): Integer;
Var
Player: UserPoint;
Monster: MonsterPoint;
TObj, Object: ObjectPoint;
Legal: Boolean;
Lev: Integer;
Where: (Ground, Person);
Dummy: Alfa;
Temp1: Alfa;
Temp2: Integer;
Begin
Lk := 0;
Legal := True;
If CmdCode = 31 Then
Begin
Legal := SpellCost (User, 10, 5, 10);
Legal := Legal and Not SpellLimit
End (*If*);
If Legal Then
With Room [User^.RmCode] Do
Begin
Player := FindPlayer (Word, RmPlayerTail);
If Player <> NIL
Then
With Player ^ Do
Begin
B1 := '0';
If UsArm = NIL
Then
B1 := B1 + 'You see ';
Ps (Name, B2);
B1 := B1 + B2;
Writev (B2, ' the ', CName [Class]);
B1 := B1 + B2;
If UsArm <> NIL
Then
Begin
PrintObj (UsArm ^, False, False, B2);
B1 := B1 + ' is wearing ' + B2
End (*If*);
B1 := B1 + '.';
QOut (Term, B1);
If (UsWeap <> NIL) Or (UsShield <> NIL)
Then
Begin
If Sex = Male
Then
B1 := '0He '
Else
B1 := '0She ';
B1 := B1 + 'is holding ';
If UsWeap <> NIL
Then
Begin
PrintObj (UsWeap ^, False, False, B2);
B1 := B1 + B2;
If UsShield <> NIL
Then
B1 := B1 + ' and '
End (*If*);
If UsShield <> NIL
Then
Begin
PrintObj (UsShield ^, False, False, B2);
B1 := B1 + B2
End;
B1 := B1 + '.';
QOut (Term, B1)
End (*If*);
If CmdCode = 31
Then
PlayerDisplay (Player)
End (*With*)
Else
Begin
Object := FindObject (Word, Num, User^.ObjectTail);
Where := Person;
If Object = NIL
Then
Begin
Where := Ground;
Object := FindObject (Word, Num, RmObjectTail)
End (*If*);
If Object <> NIL
Then
If (Object ^.ObClass = Scroll) And (Where = Ground)
Then
QOut (Term, '0Pick it up first, Eagle Eyes!')
Else
Begin
If CmdCode = 31
Then
ObjDisplay (Object)
Else
Begin
If (CmdCode = 64) And (Object ^.ObClass = Scroll)
Then
If ReadyCheck (User^.LastAtk)
Then
Begin
Temp1 := User ^.WData;
Temp2 := User ^.Data;
GetWord (Temp1, Temp2, Buffer, LenBuf, Loc);
User ^.WData := Temp1;
User ^.Data := Temp2;
Lk := Object ^.Spell
End (*If*)
Else
CmdCode := 31 (*Inhibit scroll destruction*)
Else
Begin
If Object ^.DescRec <> 0 Then
Begin
B2 := '0';
With Object ^ Do
PrintDesc (DescRec, DescCode, 0, False,
B2, B1);
QOut (Term, B1)
End (*If*)
Else
Begin
If Where = Ground
Then
B1 := '0It''s '
Else
B1 := '0You are holding ';
PrintObj (Object ^, False, False, B2);
B1 := B1 + B2 + '.';
QOut (Term, B1)
End (*Else*);
If Object ^.ObClass = Weap
Then
Begin
Case Object ^.WeapType of
Sharp:
B1 := 'sharp, bladed';
Thrust:
B1 := 'thrusting';
Blunt:
B1 := 'blunt';
Long:
B1 := 'pole'
End (*Case*);
B1 := '0This is a ' + B1 + ' weapon.';
QOut (Term, B1)
End (*If*);
If Object ^.ObClass = Chest Then
If Not Object ^.Closed Then
If Object ^.ObjectTail <> NIL Then
Begin
PrintObj (Object ^, True, False, B1);
B1 := '0Inside ' + B1 +
' you see the following:';
QOut (Term, B1);
TObj := Object ^.ObjectTail;
While TObj <> NIL Do
Begin
PrintObj (TObj ^, False, False, B1);
B1 := '0 ' + B1;
QOut (Term, B1);
TObj := TObj ^.Next
End (*While*)
End (*If*)
Else
QOut (Term, '0It''s empty.')
Else
QOut (Term, '0It''s closed.')
End (*Else*);
If (Object ^.ObClass = Scroll) And (CmdCode <> 31)
Then
Begin
PrintObj (Object ^, True, True, B1);
B1 := '0' + B1 + ' disintegrates!';
QOut (Term, B1);
If DeleteObject (Object, User^.ObjectTail)
Then
User^.ObjectTail := User^.ObjectTail^.Next;
User^.Weight := User^.Weight - Object^.Weight;
Dispose (Object)
End (*If*)
End (*Else*)
End (*If*)
Else (*Monster?*)
Begin
If Num = 0
Then
GetWord (Dummy, Num, Buffer, LenBuf, Loc);
Monster := FindMonster (Word, Num, RmMonsterTail);
If Monster = NIL
Then
QOut (Term, '0I don''t see that here.')
Else
If CmdCode = 31
Then
MonDisplay (Monster)
Else
Begin
Lev := (Monster ^.Lvl Div 5) * 5 + 1;
Ps (Monster ^.Name, B1);
PNth (Lev, B2);
B1 := '0It''s a ' + B1 + ', ' + B2 + 'to ';
PNth (Lev + 4, B2);
B1 := B1 + B2 + 'level.';
QOut (Term, B1);
If Monster ^.Magic Then
QOut (Term, '0It looks magical!');
If Monster ^.SlowReact or Monster ^.FastReact Then
QOut (Term, '0It looks hostile!')
End (*Else*)
End (*Else*)
End (*Else*)
End (*With*)
End (*Lk*);
Procedure Tr;
Var
TRoom: Integer;
Begin
TRoom := 0;
Case User^.Class of
Fighter:
TRoom := 20;
Paladin:
TRoom := 21;
Cleric:
TRoom := 22;
Thief:
TRoom := 23;
MagicUser:
TRoom := 24;
Ranger:
TRoom := 25
End (*Case*);
TRoom := Max (20, TRoom);
With User^ Do
If W (RmCode) <> TRoom
Then
QOut (Term, '0This is not the proper place for training!')
Else
If Money * 2 < Expr (Lvl + 1) - Expr (Lvl)
Then
QOut (Term, '0You haven''t enough funds to spend on training!')
Else
If Experience + Expr (Lvl) < Expr (Lvl + 1)
Then
QOut (Term,
'0You are not experienced enough for further training.')
Else
If Lvl >= 20
Then
QOut (Term, '0You have reached the peak of excellence.')
Else
Begin
Money := Money - (Expr (Lvl + 1) - Expr (Lvl)) Div 2;
B1 := '0After many weeks of training';
If Not (Class in [Barbarian, Thief, Fighter]) Then
B1 := B1 + ' and meditation';
B1 := B1 + ' you find......';
QOut (Term, B1);
Experience := 0;
MaxHits := Min (2500, MaxHits + MaxHits Div Lvl);
MaxFatigue := Min (2500, MaxFatigue + MaxFatigue Div Lvl);
MaxMagic := Min (2500, MaxMagic + MaxMagic Div Lvl);
Lvl := Lvl + 1;
Case Rnd (5) of
1:
Str := Min (25, Str + 1);
2:
Dex := Min (25, Dex + 1);
3:
Int := Min (25, Int + 1);
4:
Pty := Min (25, Pty + 1);
5:
Con := Min (25, Con + 1)
End (*Case*);
SkillNew := False;
If Lvl <= 10 Then
Con := Min (25, Con + 1);
PlayerDisplay (User)
End (*Else*)
End (*Tr*);
Procedure OpenClo (CmdCode: Integer; Var Word: Alfa; Num: Integer);
Var
OthrDoor, Key, Obj: ObjectPoint;
ObTrap: 0..50;
ObClosed, Found: Boolean;
ObLocked: 0..1000;
Num2, ILoop: Integer;
ObType: (Portl, Box, Neither);
Begin
ObType := Neither;
Obj := FindObject (Word, Num, User^.ObjectTail);
If Obj = NIL Then
Obj := FindObject (Word, Num, Room[User^.RmCode].RmObjectTail);
If Obj = NIL
Then
QOut (Term, '0That object isn''t here!')
Else
If Obj ^.ObClass = Chest
Then
Begin
ObTrap := Obj ^.Trap;
ObLocked := Obj ^.Locked;
ObType := Box;
ObClosed := Obj ^.Closed
End (*If*)
Else
If Obj ^.ObClass = Door
Then
Begin
ObTrap := Obj ^.DTrap;
ObLocked := Obj ^.DLocked;
ObType := Portl;
ObClosed := Obj ^.DClosed
End (*If*)
Else
QOut (Term, '0I don''t know how to do such a thing.');
If ObType <> Neither
Then
Begin
If CmdCode = 66 (*Close*)
Then
If ObClosed
Then
QOut (Term, '0It''s already closed!')
Else
Begin
ObClosed := True;
PS (User^.Name, B1);
PrintObj (Obj ^, True, False, B2);
B1 := '0' + B1 + ' just closed ' + B2 + '.';
For ILoop := 1 to MsgTerm (TermList, Local) Do
QOut (TermList [ILoop], B1);
QOut (Term, '0Ok.')
End (*Else*)
Else
If (CmdCode = 67) or (CmdCode = 68) (*Lock/UnLock*)
Then
Begin
GetWord (Word, Num2, Buffer, LenBuf, Loc);
Key := FindObject (Word, Num2, User^.ObjectTail);
If Word = Blanks
Then
QOut (Term, '0With what?')
Else
If Key = NIL
Then
QOut (Term,'0You don''t have the right key.')
Else
If Key ^.ObClass <> Keys
Then
QOut (Term, '0That won''t unlock anything!')
Else
If ((Key ^.UnLock Mod 10 = 0) And (Key ^.UnLock <>
ObLocked - ObLocked Mod 10) Or (Key ^.UnLock Mod
10 <> 0) And (Key ^.UnLock <> ObLocked)) And
(Key ^.UnLock <> 1000)
Then
Begin
PrintObj (Key ^, True, False, B1);
B1 := '0' + B1 + ' doesn''t work!';
QOut (Term, B1)
End (*If*)
Else
Begin
If CmdCode = 67
Then
ObClosed := True
Else
ObClosed := False;
PS (User^.Name, B1);
B1 := '0' + B1 + ' just ';
If CmdCode = 67
Then
B1 := B1 + 'locked '
Else
B1 := B1 + 'unlocked ';
PrintObj (Obj ^, True, False, B2);
B1 := B1 + B2 + ' with ';
PrintObj (Key ^, False, False, B2);
B1 := B1 + B2 + '.';
For ILoop := 1 to MsgTerm (TermList, Local) Do
QOut (TermList [ILoop], B1);
QOut (Term, '0Ok.')
End (*Else*)
End (*If*)
Else
If CmdCode = 65 (*Open*)
Then
If Not ObClosed
Then
QOut (Term, '0It''s already open!')
Else
If ObLocked > 0
Then
QOut (Term, '0You can''t. It''s locked!')
Else
Begin
ObClosed := False;
PS (User^.Name, B1);
PrintObj (Obj ^, True, False, B2);
B1 := '0' + B1 + ' just opened ' + B2 + '.';
For ILoop := 1 to MsgTerm (TermList, Local) Do
QOut (TermList [ILoop], B1);
QOut (Term, '0Ok.');
TrapCheck (Obj, ObTrap)
End (*Else*)
Else
If CmdCode = 69 (*PickLock*)
Then
Begin
If User^.Class <> Thief
Then
ILoop := -10
Else
ILoop := 3;
If ReadyCheck (User^.LastAtk)
Then
If ((User^.Lvl + User^.Dex Div 2 + ILoop) Div 3 <
ObLocked Mod 10) Or (ObLocked Mod 10 = 0)
Then
Begin
User^.LastAtk := RealTime + 15;
QOut (Term, '0You fail to pick the lock!')
End (*If*)
Else
Begin
ObClosed := False;
PS (User^.Name, B1);
PrintObj (Obj ^, True, False, B2);
B1 := '0' + B1 + ' pickes the lock on ' + B2 +
' open!';
For ILoop := 1 to MsgTerm (TermList, Local) Do
QOut (TermList [ILoop], B1);
QOut (Term, '0You picked the lock open!');
TrapCheck (Obj, ObTrap)
End (*Else*)
End (*If*)
Else
If CmdCode = 70 (*Smash*)
Then
If ReadyCheck (User^.LastAtk)
Then
If Not ObClosed
Then
QOut (Term, '0It''s already open!')
Else
If (Rnd (3) <> 1) or (User^.Str * 10 < Obj^.Weight)
Then
Begin
User^.LastAtk := RealTime + 15;
PS (User^.Name, B1);
PrintObj (Obj ^, True, False, B2);
B1 := '0' + B1 + ' fails to smash ' + B2 +
' open.';
For ILoop := 1 to MsgTerm (TermList, Local) Do
QOut (TermList [ILoop], B1);
QOut (Term, '0Bang! You fail to smash it open!')
End (*If*)
Else
Begin
PS (User^.Name, B1);
PrintObj (Obj ^, True, False, B2);
B1 := '0' + B1 + ' smashes ' + B2 + ' open.';
For ILoop := 1 to MsgTerm (TermList, Local) Do
QOut (TermList [ILoop], B1);
ObClosed := False;
QOut (Term, '0You smash it open!');
TrapCheck (Obj, ObTrap)
End (*Else*);
If ObType = Box
Then
Begin
Obj ^.Closed := ObClosed;
Obj ^.Trap := ObTrap;
Obj ^.Locked := ObLocked
End (*If*)
Else
If ObType = Portl
Then
Begin
Obj ^.DClosed := ObClosed;
Obj ^.DTrap := ObTrap;
Obj ^.DLocked := ObLocked;
Found := False;
OthrDoor := Room[S (Obj ^.ToWhere)].RmObjectTail;
While (OthrDoor <> NIL) And Not Found Do
If Pad (OthrDoor ^.Name, ' ', 20) =
Pad (Obj ^.Name, ' ', 20)
Then
Found := True
Else
OthrDoor := OthrDoor ^.Next;
If Found And (OthrDoor <> NIL)
Then
Begin
OthrDoor ^.DClosed := ObClosed;
OthrDoor ^.DTrap := ObTrap;
OthrDoor ^.DLocked := ObLocked
End (*If*)
End (*If*)
End (*If*)
End (*OpenClo*);
Procedure HitShArmor (Plyr: UserPoint; Var Damage: Integer);
Var
Temp: ObjectPoint;
Begin
With Plyr ^ Do
Begin
If UsArm <> NIL
Then
Begin
Damage := Max (0, Damage - UsArm ^.ArmPlus);
UsArm ^.ArmHits := Max (0, UsArm ^.ArmHits - 1);
If UsArm ^.ArmHits = 0 Then
Begin
QOut (Term, '0Your armor falls apart!');
If DeleteObject (UsArm, ObjectTail) Then
ObjectTail := ObjectTail ^.Next;
Weight := Weight - UsArm ^.Weight;
Temp := UsArm;
StopUsing (Plyr, UsArm);
Dispose (Temp)
End (*If*)
End (*If*);
If UsShield <> NIL
Then
Begin
UsShield ^.ArmHits := Max (0, UsShield ^.ArmHits - 1);
If UsShield ^.ArmHits = 0 Then
Begin
QOut (Term, '0Your shield falls apart!');
If DeleteObject (UsShield, ObjectTail) Then
ObjectTail := ObjectTail ^.Next;
Weight := Weight - UsShield ^.Weight;
Temp := UsShield;
StopUsing (Plyr, UsShield);
Dispose (Temp)
End (*If*)
End (*If*)
End (*With*)
End (*HitShArmor*);
Procedure Train;
Begin
Tr
End (*Train*);