-
Notifications
You must be signed in to change notification settings - Fork 0
/
monmain.pas
5882 lines (5228 loc) · 162 KB
/
monmain.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
[INHERIT ('MONCONST', 'MONTYPE', 'MONGLOBL','CUSTROOM')]
MODULE MonMain(INPUT, OUTPUT);
%include 'parser.pas'
%include 'headers.txt'
%include 'equip.inc'
(* -------------------------------------------------------------------------- *)
[EXTERNAL] FUNCTION ObjPrice(ObjNum : INTEGER) : INTEGER; extern;
[EXTERNAL] FUNCTION IsProg(S : String) : BYTE_BOOL; extern;
[EXTERNAL] PROCEDURE ReadGlobalNames; EXTERN;
(* -------------------------------------------------------------------------- *)
TYPE
$DEFTYP = [UNSAFE] INTEGER;
$DEFPTR = [UNSAFE] ^$DEFTYP;
[ASYNCHRONOUS]
FUNCTION Lib$Init_Timer (
VAR context : [VOLATILE] UNSIGNED := %IMMED 0) : INTEGER; EXTERNAL;
[ASYNCHRONOUS]
FUNCTION lib$show_timer (Handle_address : $DEFPTR := %IMMED 0;
code : INTEGER := %IMMED 0;
%IMMED [UNBOUND, ASYNCHRONOUS] PROCEDURE user_action_procedure := %IMMED 0;
%IMMED user_argument_value : [UNSAFE] INTEGER := %IMMED 0) : INTEGER; EXTERNAL;
(* -------------------------------------------------------------------------- *)
function numcansee(log : integer) : integer; forward;
[GLOBAL]
FUNCTION SetPersName(N : INTEGER; Name : ShortString) : BYTE_BOOL;
VAR
Nam : ShortNameRec;
BEGIN
SetPersName := FALSE;
IF GetShortName(s_na_pers, nam) THEN
BEGIN
Nam.Idents[N] := Name;
IF SaveShortName(s_na_pers, Nam) THEN
BEGIN
LogEvent(-1, -1, e_setname, 0, 0, nt_short, s_na_pers, '', r_allrooms,
name, n);
SetPersName := TRUE;
END;
END;
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE SaveKiller(C1, C2 : INTEGER);
{ c1 - his group, c2 - my group }
VAR
Kill : KillRec;
BEGIN
IF GetKill(C2, Kill) THEN { increment our death count for that group }
BEGIN
Kill.WeKilled[C1] := Kill.WeKilled[C1] + 1;
IF SaveKill(C2, Kill) THEN;
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE PrintScore;
{ c1 - his group, c2 - my group }
VAR
Kill : KillRec;
Nam : RealShortNameRec;
Indx : IndexRec;
Loop, Loop2 : INTEGER;
BEGIN
IF GetRealShortName(RSNR_GroupName, Nam) AND GetIndex(I_GroupName, Indx) THEN
BEGIN
FOR Loop := 1 TO MaxGroup DO
BEGIN
IF NOT Indx.Free[Loop] THEN
BEGIN
Writeln('Kills for group: ', Nam.Idents[Loop]);
IF GetKill(Loop, Kill) THEN
BEGIN
FOR Loop2 := 1 TO MaxGroup DO
IF NOT Indx.Free[Loop2] THEN
BEGIN
WriteNice(Nam.Idents[Loop2], 20);
Writeln(': ',Kill.WeKilled[Loop2]);
END;
END;
END;
END;
END;
END;
(*-----------------------------------------------------------------------*)
[EXTERNAL] PROCEDURE UpdateClassName; EXTERN;
PROCEDURE DoUpdate;
BEGIN
UpdateClassName;
Writeln('everything should be correct now');
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
FUNCTION SaveHold(Log : INTEGER; Hold : HoldObj) : BYTE_BOOL;
VAR
Charac : CharRec;
Loop : INTEGER;
BEGIN
SaveHold := FALSE;
IF GetChar(log, charac) then
begin
FOR Loop := 1 TO MaxHold DO
BEGIN
Charac.Item[Loop] := Hold.Holding[Loop];
Charac.Condition[Loop] := Hold.Condition[Loop];
Charac.Charges[Loop] := Hold.Charges[Loop];
Charac.Equip[Loop] := (Hold.Slot[Loop] <> 0);
END;
SaveHold := SaveChar(Log, Charac);
end;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoSell(S : String; VAR AllStats : AllMyStats);
VAR
Slot, NW, N : INTEGER;
Obj : ObjectRec;
BEGIN
IF (check_bit(HereDesc.SpcRoom, rm$b_store)) THEN
BEGIN
IF LookUpName(nt_short, s_na_objnam, N, S, FALSE, FALSE) THEN
BEGIN
Obj := GlobalObjects[N];
IF ObjHere(N) THEN
BEGIN
Slot := FindHold(N, AllStats.MyHold);
IF Slot > 0 THEN
BEGIN
IF Here.ObjHide[Slot] <> -1 THEN
Here.ObjHide[Slot] := Here.ObjHide[Slot] + 1;
IF SaveRoom(AllStats.Stats.Location, Here) THEN
BEGIN
IF AllStats.Stats.Privd THEN
Writeln('There are ',here.objhide[slot]:0,' of them here now.');
NW := Obj.Worth;
CASE Obj.Kind OF
O_EQUIP: BEGIN
NW := (NW * AllStats.MyHold.Condition[Slot]) DIV 100;
NW := (NW * AllStats.MyHold.Charges[Slot]) DIV 10;
END;
O_MISSILE: NW := (NW * AllStats.MyHold.Charges[Slot]) DIV 100;
END;
(* MWG, let the new worth be half *)
NW := NW DIV 2;
AllStats.Stats.Wealth := AllStats.Stats.Wealth + NW;
AttribAssignValue(AllStats.Stats.Log, ATT_Wealth,
AllStats.Stats.Wealth);
LogEvent(AllStats.Stats.Slot, AllStats.Stats.Log, E_SELL, 0, 0, 0,
0, AllStats.Stats.Name + ' has sold ' +ObjPart(N)+ '.',
AllStats.Stats.Location, , Slot, Here.Objs[Slot],
Here.ObjHide[Slot]);
DropObj(Slot, AllStats);
SaveHold(AllStats.Stats.Log, AllStats.MyHold);
Writeln('Sold for ', NW:0,'!');
END; (* IF SaveRoom *)
END ELSE Writeln('You''re not holding that item. To see what you''re holding, type INV.')
END ELSE Writeln('You cannot sell that here.')
END;
END ELSE Writeln('You cannot sell that here.');
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE DoDrop(S : String; VAR AllStats : AllMyStats);
VAR
Slot, N : INTEGER;
G : String;
RoomNum : INTEGER;
Obj : ObjectRec;
Temp : String;
BEGIN
WAIT(0.50); (* MWG to stop duping objects, give time to update *)
Temp := S;
G := Trim(Bite(Temp));
IF G = '' THEN
BEGIN
Writeln('To drop an object, type DROP <object name>.');
Writeln('To see what you are carrying, type INV (inventory).');
END
ELSE
IF G = 'gold' THEN
BEGIN
Writeln('You have ', AllStats.Stats.Wealth:0, ' gold.');
IF NOT IsNum(Temp) THEN
Grab_Num('How much do you want to drop? ',N, 0, AllStats.Stats.Wealth,
0, AllStats)
ELSE N := Number(Temp);
IF N > AllStats.Stats.Wealth THEN
N := AllStats.Stats.Wealth; (* MWG fixed stuff up here *)
IF N > 0 THEN
BEGIN
AllStats.Stats.Wealth := AllStats.Stats.Wealth - N;
AttribAssignValue(AllStats.Stats.Log, Att_WEALTH, AllStats.Stats.Wealth);
IF HereDesc.ObjDrop <> 0 THEN
RoomNum := HereDesc.ObjDrop
ELSE
RoomNum := AllStats.Stats.Location;
IF GetRoom(RoomNum, Here) THEN
BEGIN
Here.GoldHere := Here.GoldHere + N;
IF SaveRoom(RoomNum, Here) THEN
BEGIN
WriteV (G, AllStats.Stats.Name,' has dropped ', N:1,' gold here.');
Writeln('You drop ',N:0,' gold.');
LogEvent(AllStats.Stats.Slot, AllStats.Stats.Log, E_DROP, 0, 0, 1,
0, G, AllStats.Stats.Location, , N);
END;
END;
END;
END
ELSE
IF (check_bit(HereDesc.SpcRoom, rm$b_store)) THEN
Writeln('Maybe you want to *sell* it?')
ELSE
BEGIN
IF GetRoom(AllStats.Stats.Location, Here) THEN
BEGIN
IF ParseObj(N, S, AllStats.MyHold) THEN
BEGIN
Slot := FindHold(N, AllStats.MyHold);
IF Slot <> 0 THEN
BEGIN
Obj := GlobalObjects[N];
IF Obj.Sticky THEN
INFORM_Sticky(Obj.ObjName)
ELSE
IF LookupEffect(Obj, EF_CURSED) > 0 THEN
Writeln('The ', Obj.ObjName,' is cursed.')
ELSE
IF PlaceObj(N, AllStats.Stats.Location, AllStats.MyHold.Condition[slot],
AllStats.MyHold.Charges[Slot], , , ,AllStats) THEN
DropObj(Slot, AllStats);
END
ELSE inform_notholding;
END
ELSE inform_notholding;
END;
END;
END;
(* -------------------------------------------------------------------------- *)
FUNCTION IsBomb(Obj : ObjectRec) : BYTE_BOOL;
BEGIN
IsBomb := ((LookupEffect(Obj, EF_BOMBBASE) > 0) OR
(LookupEffect(Obj, EF_BOMBRANDOM) > 0));
END;
(* ------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE DoThrow(S : String := ''; ObjNum : INTEGER;
VAR AllStats : AllMyStats);
VAR
Slot, DropLoc : INTEGER;
Good : BYTE_BOOL := FALSE;
BEGIN
IF ObjNum<>0 then Good := TRUE
ELSE Good := LookUpname(nt_short,s_na_objnam,ObjNum,S);
IF Good THEN
BEGIN
Slot := FindHold(ObjNum, AllStats.MyHold);
IF(Slot = 0)THEN
Inform_NotHolding
ELSE
BEGIN
DropLoc := EffectDist(
LookupEffect(GlobalObjects[ObjNum], EF_THROWBASE),
LookupEffect(GlobalObjects[ObjNum], EF_THROWRANDOM),
LookupEffect(GlobalObjects[ObjNum], EF_THROWRANGE),
LookupEffect(GlobalObjects[ObjNum], EF_THROWBEHAVIOR),
0, 0, FALSE, GlobalObjects[ObjNum].ObjName,
AllStats);
IF DropLoc < 0 then DropLoc := -DropLoc;
PlaceObj(ObjNum, DropLoc, AllStats.MyHold.Condition[slot],
AllStats.MyHold.Charges[Slot], TRUE, FALSE, TRUE,
AllStats);
DropObj(Slot, AllStats);
Freeze(AllStats.Stats.AttackSpeed/100, AllStats);
END;
END
ELSE
Inform_NotHolding
END;
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE DoLob(S : String := ''; VAR AllStats : AllMyStats);
VAR
Slot,
N,
Lobbed,
Dir,
Damage : INTEGER;
Obj : ObjectRec;
MyName : String;
MyLoc : INTEGER;
MySlot : INTEGER;
BEGIN
MyName := AllStats.Stats.Name;
MyLoc := AllStats.Stats.Location;
MySlot := AllStats.Stats.Slot;
IF (check_bit(HereDesc.Spcroom, rm$b_nofight)) THEN
Writeln('You cannot fight here.')
ELSE
BEGIN
IF S = '' THEN
Writeln('To lob a bomb or magic monster, type LOB <object name>.')
ELSE
IF LookupName(nt_short, s_na_objnam, N, S, FALSE, FALSE) THEN
BEGIN
IF ObjHold(N, AllStats.MyHold) THEN
BEGIN
Obj := GlobalObjects[N];
IF IsBomb(Obj) THEN
BEGIN
GrabLine('Direction? ',S, AllStats);
IF NOT (GetDir(S, Dir)) THEN
Writeln('Invalid direction.')
ELSE
BEGIN
Lobbed := HereDesc.Exits[Dir].ToLoc;
IF Lobbed = 0 THEN
Lobbed := MyLoc;
Damage := LookupEffect(Obj, EF_BOMBBASE) +
RND(LookupEffect(Obj, EF_BOMBRANDOM));
LogEvent(MySlot, AllStats.Stats.Log, E_MSG, 0,0,0,0, MyName+
' has lobbed ' + ObjPart(N) + ' somewhere.', MyLoc);
LogEvent(MySlot, 0, E_LOB, LookupEffect(Obj, EF_BOMBTIME)*10, 0,
Damage, 0, MyName+'''s ' + Obj.ObjName, Lobbed);
Writeln('Lobbing...');
N := FindHold(N, AllStats.MyHold);
DropObj(N, AllStats);
Freeze(AllStats.Stats.AttackSpeed/100, AllStats);
END;
END
ELSE
Writeln('You can only lob bombs or magic monsters.');
END
ELSE
Inform_NotHolding
END;
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoOperators;
BEGIN
Writeln('CURRENT MONSTER MANAGERS:');
Writeln('-------------------------');
Writeln(MM_USERID,' ',MVM_USERID,' ',MPGR_USERID);
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE ListGet(ShowHidden : BYTE_BOOL);
VAR
First : BYTE_BOOL := TRUE;
I : INTEGER;
BEGIN
FOR I := 1 TO MaxObjs DO
BEGIN
IF (Here.Objs[I] MOD 1000 <> 0) THEN
IF (Here.ObjHide[I] MOD 1000 = 0) OR ShowHidden THEN
BEGIN
IF First THEN
BEGIN
(* MWG attempt to show price in stores, seems to work *)
IF ShowHidden THEN
WriteLn('Objects that you can buy here: Price:')
ELSE
Writeln('Objects that you see here:');
First := FALSE;
END;
(* MWG attempt to show price in stores *)
IF ShowHidden THEN
WriteLn(' ',ObjPart(Here.Objs[I] MOD 1000):20,' ',
ObjPrice(Here.Objs[I] MOD 1000):5)
ELSE
Writeln(ObjPart(Here.Objs[I] MOD 1000):20)
END;
END;
IF First THEN
writeln('There is nothing you see here that you can get.');
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE GetOriginalStats(ObjNum : INTEGER; VAR Condition : INTEGER;
VAR Charges : INTEGER);
VAR
Obj : ObjectRec;
BEGIN
Obj := GlobalObjects[ObjNum];
Condition := LookupEffect(Obj, ef_condition);
IF Condition = 0 THEN
Condition := 100;
Charges := LookupEffect(Obj, ef_charges);
IF Charges = 0 THEN
Charges := 10;
CASE Obj.Kind OF
O_SCROLL: Charges := Obj.Parms[2];
O_WAND: Charges := Obj.Parms[2];
O_MISSILE: Charges := Obj.Parms[3];
END;
END;
(* -------------------------------------------------------------------------- *)
FUNCTION CanHold(VAR MyHold : HoldObj) : BYTE_BOOL;
VAR
Slot : INTEGER := 0;
Loop : INTEGER;
BEGIN
FOR Loop := 1 TO MaxHold DO
IF MyHold.Holding[Loop] = 0 THEN
Slot := Loop;
CanHold := Slot <> 0;
END;
(* -------------------------------------------------------------------------- *)
FUNCTION GetMissileHold(ObjNum: INTEGER; VAR NumGet : INTEGER;
MyHold : HoldObj) : INTEGER;
VAR
I : INTEGER;
First : BYTE_BOOL;
BEGIN
GetMissileHold := 0;
First := TRUE;
NumGet := 0;
FOR I := 1 TO MaxHold DO
IF (MyHold.Holding[I] = ObjNum) AND First THEN
BEGIN
NumGet := MyHold.Charges[I];
First := FALSE;
GetMissileHold := I;
END;
END;
{ put object number n into the player's inventory; returns false if
he's holding too many things to carry another }
(* -------------------------------------------------------------------------- *)
[GLOBAL]
FUNCTION Put_Obj_In_Hold(N, Cond, C : INTEGER; VAR MyHold : HoldObj;
VAR Speed : INTEGER; Log : INTEGER) : BYTE_BOOL;
VAR
Found, FoundMissile : BYTE_BOOL;
I : INTEGER;
Obj : ObjectRec;
OldCharges : INTEGER;
BEGIN
Obj := GlobalObjects[N];
I := 0;
Found := FALSE;
FoundMissile := FALSE;
IF Obj.Kind = O_MISSILE THEN
I := GetMissileHold(N, OldCharges, MyHold);
IF I <> 0 THEN
Found := TRUE
ELSE
BEGIN
OldCharges := 0;
I := 1;
WHILE (I <= MaxHold) AND (NOT Found) DO
IF MyHold.Holding[I] = 0 THEN
Found := TRUE
ELSE
I := I + 1;
END;
Put_Obj_In_Hold := Found;
IF Found THEN
BEGIN
Speed := Speed + Obj.Weight;
MyHold.Holding[I] := N;
MyHold.Condition[I] := Cond;
MyHold.Charges[I] := OldCharges + C;
SaveHold(Log, MyHold);
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoBuy(S : String; VAR AllStats : AllMyStats);
VAR
Slot, N, Cond, C : INTEGER;
Obj : ObjectRec;
BEGIN
Cond := 0;
C := 0;
IF ParseObj(N, S, AllStats.MyHold) THEN
BEGIN
Obj := GlobalObjects[N];
IF ObjHere(N) THEN
BEGIN
IF AllStats.Stats.Wealth >= Obj.Worth THEN
BEGIN
GetOriginalStats(N, Cond, C);
Slot := FindObj(N, AllStats.Stats.Location);
IF (Here.ObjHide[Slot] > 0) OR (Here.ObjHide[Slot] = -1) THEN
BEGIN
IF Put_Obj_In_Hold(N,Cond,C,AllStats.MyHold, AllStats.Stats.MoveSpeed,
AllStats.Stats.Log) THEN
BEGIN
AllStats.Stats.Wealth := AllStats.Stats.Wealth - Obj.Worth;
AttribAssignValue(AllStats.Stats.Log, ATT_Wealth,
AllStats.Stats.Wealth);
IF Here.ObjHide[Slot] <> - 1 THEN
BEGIN
Here.ObjHide[Slot] := Here.ObjHide[Slot] - 1;
IF SaveRoom(AllStats.Stats.Location, Here) THEN;
END;
IF AllStats.Stats.Privd THEN
Writeln('There are ', Here.ObjHide[Slot],' of them now.');
LogEvent(AllStats.Stats.Slot, AllStats.Stats.Log, E_MSG, 0, 0,
0,0, AllStats.Stats.Name + ' has bought ' +
ObjPart(N) + '.', AllStats.Stats.Location);
Writeln('All yours for ', Obj.Worth:0,' gold.')
END
ELSE
writeln('Your hands are full. You''ll have to drop something you''re carrying first.')
END
ELSE
Writeln('We are out of them now.')
END
ELSE
Writeln('You don''t have enough gold!')
END
ELSE
Writeln('You cannot buy that here.');
END
ELSE
Writeln('What are you talking about?');
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE P_GetSucc(N : INTEGER; Obj : ObjectRec);
BEGIN
IF IsDescription(Obj.GetSuccess) THEN
PrintDesc(Obj.GetSuccess)
ELSE
Writeln('You have taken ', ObjPart(N) ,'.');
END;
(* -------------------------------------------------------------------------- *)
FUNCTION TakeObj(ObjNum, Slot : INTEGER; VAR Q : INTEGER;
VAR C : INTEGER; RoomNum : INTEGER) : BYTE_BOOL;
BEGIN
IF GetRoom(RoomNum, Here) THEN
BEGIN
IF Here.Objs[Slot] MOD 1000 = ObjNum THEN
BEGIN
Q := Here.Objs[Slot] DIV 1000;
C := Here.ObjHide[Slot] DIV 1000;
Here.Objs[Slot] := 0;
Here.ObjHide[Slot] := 0;
TakeObj := TRUE;
IF NOT SaveRoom(RoomNum, Here) THEN
TakeObj := FALSE;
END
ELSE
TakeObj := FALSE;
END
ELSE
TakeObj := FALSE;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoMetaGet(N : INTEGER; Silent : BYTE_BOOL := FALSE;
VAR AllStats : AllMyStats; VAR Obj : ObjectRec);
VAR
Slot, Q, C : INTEGER;
BEGIN
Q := 0;
if ObjHere(N) THEN
BEGIN
IF CanHold(AllStats.MyHold) THEN
BEGIN
Slot := FindObj(N, AllStats.Stats.Location);
IF Slot > 0 THEN
IF TakeObj(N, Slot, Q, C,AllStats.Stats.Location) THEN
BEGIN
Put_Obj_In_Hold(N, Q, C, AllStats.MyHold, AllStats.Stats.MoveSpeed,
AllStats.Stats.Log);
IF NOT Silent THEN
LogEvent(AllStats.Stats.Slot, AllStats.Stats.Log, E_TAKE, 0,0,0,0,
ObjPart(N), AllStats.Stats.Location);
P_GetSucc(N, Obj);
END
ELSE
Writeln('Someone got to it before you did.');
END
ELSE
Writeln(
'Your hands are full. You''ll have to drop something you''re carrying first.');
END
ELSE
IF ObjHold(N, AllStats.MyHold) THEN
Writeln('You''re already holding that item.')
ELSE
Writeln('That item isn''t in an obvious place.');
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE DoGet(S : String; VAR AllStats : AllMyStats);
VAR
G, Ext : String;
N : INTEGER;
Ok : BYTE_BOOL := TRUE;
Obj : ObjectRec;
BEGIN
WAIT(0.50); (* MWG to stop gold and object duping *)
IF GetRoom(AllStats.Stats.Location, Here) THEN
BEGIN
Ext := S;
IF S = '' THEN
ListGet(check_bit(HereDesc.SpcRoom, rm$b_store))
ELSE
IF Bite(Ext) = 'gold' THEN
BEGIN
IF IsNum(Ext) THEN
N := Number(ext)
ELSE
N := 0;
IF N = 0 THEN
N := Here.GoldHere;
IF (N <= Here.GoldHere) AND (N > 0) THEN
BEGIN
LogEvent(AllStats.Stats.Slot, AllStats.Stats.Log, E_GETGOLD,
0, 0, N, Here.GoldHere, AllStats.Stats.Name,
AllStats.Stats.Location);
END
ELSE
BEGIN
Writeln('There is ',here.goldhere:1,' gold here.');
END;
END
ELSE
IF check_bit(HereDesc.SpcRoom, rm$b_store) THEN
DoBuy(S, AllStats)
ELSE
IF ParseObj(N, S, AllStats.MyHold) THEN
BEGIN
Obj := GlobalObjects[N];
OK := TRUE;
IF Obj.Sticky THEN
BEGIN
OK := FALSE;
LogEvent(AllStats.Stats.Slot, AllStats.Stats.Log, E_FAILGET, 0,0,
N,0, AllStats.Stats.Name, AllStats.Stats.Location);
IF NOT IsDescription(Obj.GetFail) THEN
Writeln('You can''t take ',ObjPart(N),'.')
ELSE
PrintDesc(Obj.GetFail);
END
ELSE
IF Obj.GetObjReq > 0 THEN
BEGIN
IF NOT(ObjHold(Obj.GetObjReq, AllStats.MyHold)) THEN
BEGIN
OK := FALSE;
LogEvent(AllStats.Stats.Slot, AllStats.Stats.Log, E_FAILGET, 0,0, N,0,
AllStats.Stats.Name, AllStats.Stats.Location);
IF NOT IsDescription(Obj.GetFail) THEN
Writeln('You''ll need something first to get the ',
ObjPart(N),'.')
ELSE
PrintDesc(Obj.GetFail);
END;
END
ELSE
IF Obj.Holdability > RND(100) THEN
BEGIN
OK := FALSE;
LogEvent(AllStats.Stats.Slot, AllStats.Stats.Log, E_FAILGET, 0,0, N,0,
AllStats.Stats.Name, AllStats.Stats.Location);
IF NOT IsDescription(Obj.GetFail) THEN
Writeln(ObjPart(N),' slipped from your grasp.')
ELSE
PrintDesc(Obj.GetFail);
END;
IF OK THEN
DoMetaGet(N, , AllStats, Obj);
END
ELSE
Writeln('There is no object here by that name.');
END
ELSE
IF LookupDetail(N, S) THEN
BEGIN
writeln('That detail of this room is here for the enjoyment of all Monster players,');
writeln('and may not be taken.');
END
ELSE
Writeln('There is no object here by that name.');
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoDuplicate(S : String; VAR AllStats : AllMyStats);
VAR
ObjNum, Cond, C : INTEGER;
BEGIN
Cond := 0;
C := 0;
IF Length(s) > 0 THEN
BEGIN
IF Not IsRoomOwner(AllStats.Stats.Location, AllStats.Stats.Privd, FALSE) THEN
Writeln('You may only create objects when fyou are in one of your own rooms.')
ELSE
BEGIN
IF LookupName(nt_short, s_na_objnam, ObjNum, S) THEN
BEGIN
IF IsOwner(nt_short, s_na_objown, ObjNum,AllStats.Stats.Privd, FALSE) THEN
BEGIN
GetOriginalStats(ObjNum, Cond, C);
IF NOT PlaceObj(Objnum, AllStats.Stats.Location, Cond, C, TRUE,
TRUE, AllStats.Stats.Privd, AllStats) THEN
Writeln('There isn''t enough room here to make that.')
ELSE
Writeln('Object created.');
END
ELSE
writeln('You don''t own that object.');
END
ELSE
writeln('There is no object by that name.');
END;
END
ELSE
writeln('To duplicate an object, type DUPLICATE <object name>.');
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE SpecialEffectSubs(Text, S : String; VAR AllStats : AllMyStats);
BEGIN
Text := SubsParm(Text, S, '#');
Text := SubsParm(Text, AllStats.Stats.Name, '&');
Parser(Text, AllStats);
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE DoSpecialEffect(S : String := ''; VAR AllStats : AllMyStats);
VAR
I : INTEGER;
G : String;
OldPrivs : BYTE_BOOL;
Line : LineRec;
Desc : DescRec;
BEGIN
OldPrivs := AllStats.Stats.Privd;
AllStats.Stats.Privd := TRUE;
IF HereDesc.Special_Effect < 0 THEN
BEGIN
IF GetLine(-HereDesc.Special_Effect, Line) THEN
SpecialEffectSubs(Line.Line, S, AllStats);
END
ELSE
IF HereDesc.Special_Effect > 0 THEN
BEGIN
IF GetDesc(HereDesc.Special_Effect, Desc) THEN
FOR I := 1 TO Desc.DescLen DO
SpecialEffectSubs(Desc.Lines[I], S, AllStats);
END;
AllStats.Stats.Privd := OldPrivs;
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE ReadAtmosphere;
VAR
Loop : INTEGER;
Atmos : AtmosphereRec;
BEGIN
Atmosphere := Zero;
FOR Loop := 1 TO MaxAtmospheres DO
BEGIN
IF GetAtmosphere(Loop, Atmos, TRUE) THEN
Atmosphere[Loop] := Atmos
ELSE
Atmosphere[Loop].Trigger.Length := 0;
END;
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE DoAtmosphere(S : String; At_Type : INTEGER;
Slot, Log, Location : INTEGER);
VAR
N : INTEGER;
Victim : ShortString;
TargLog : INTEGER;
BEGIN
IF (S = '') OR ParsePers(N, Targlog, S) THEN
BEGIN
IF S = '' THEN
BEGIN
Victim := 'yourself';
N := 0;
END
ELSE
Victim := Here.People[N].Name;
LogEvent(Slot, Log, E_ATMOSPHERE, N, 0, At_Type,0, '', Location);
IF N = 0 then
Writeln(Atmosphere[At_Type].Isee)
ELSE
Writeln(SubsParm(Atmosphere[At_Type].ISeeExtra, Victim));
END
ELSE
Writeln(S, ' can not be seen in this room.');
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE EventAtmosphere(Targ : INTEGER; Sendname : String; P : INTEGER;
VAR AllStats : AllMyStats);
VAR
Victim, S : String;
BEGIN
IF Targ = 0 THEN
Writeln(SubsParm(Atmosphere[P].EventSee, SendName, '&'))
ELSE
BEGIN
IF Targ = AllStats.Stats.Slot THEN
Victim := 'you'
ELSE
Victim := Here.People[Targ].Name;
S := SubsParm(Atmosphere[P].EventSeeExtra, Victim);
S := SubsParm(S, SendName, '&');
Writeln(s);
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoSelf(S : String; VAR AllStats : AllMyStats);
VAR
N : INTEGER;
Charac : CharRec;
User : INTEGER;
BEGIN
User := AllStats.Stats.Log;
IF (Length(S) <> 0) AND AllStats.Stats.Privd THEN
IF LookupName(nt_short, s_na_pers, N, S, FALSE, FALSE) THEN
User := N;
Writeln('[ Editing self description ]');
IF GetChar(User, Charac) THEN
IF EditDesc(Charac.Self, ,AllStats) THEN
IF SaveChar(User, Charac) THEN
Writeln('Self description modified.');
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoPlayers(Loc : INTEGER; Slot : INTEGER);
VAR
I, J : INTEGER;
Location : IntArray;
RoomName : LongNameRec;
User : ShortNameRec;
Pers : ShortNameRec;
ASleep : IndexRec;
Date : ShortNameRec;
Ok : BYTE_BOOL := TRUE;
Indx : IndexRec;
BEGIN
Ok := GetIndex(I_ASLEEP, ASleep) AND
GetIndex(I_PLAYER, Indx) AND
GetInt(N_LOCATION, Location) AND
GetShortName(s_NA_USER, user) AND
GetShortName(s_NA_PERS, pers) AND
GetShortName(s_NA_DATE, date) AND
GetLongName(l_NA_ROOMNAM, RoomName);
IF Ok THEN
BEGIN
Writeln;
Writeln('Userid Personal Name Last Play');
FOR I := 1 TO Indx.Top DO
BEGIN
IF NOT(Indx.Free[I]) THEN
BEGIN
WriteNice(User.Idents[I], 10);
WriteNice(Pers.Idents[I], 21);
IF Asleep.Free[I] THEN
WriteNice(Date.Idents[I], 18)
ELSE
Write(' -playing now- ');
Writeln(' ',RoomName.Idents[Location[I]]);
END;
END;
Writeln;
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoWhoIs(S : String; Check : INTEGER := 3);
(* IF Check =
1 : then check against game names
2 : then check against user names
3 : then check against both *)
VAR
Len : INTEGER;
Pers : ShortNameRec;
User : ShortNameRec;
Indx : IndexRec;
Loop : INTEGER;
Found : BYTE_BOOL;
S_Pers : ShortString;
S_User : ShortString;
BEGIN