-
Notifications
You must be signed in to change notification settings - Fork 0
/
custroom.pas
1434 lines (1284 loc) · 42.5 KB
/
custroom.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'),
ENVIRONMENT ('CUSTROOM')]
MODULE CustRoom(OUTPUT);
%include 'headers.txt'
VAR
maxcmds : [EXTERNAL] INTEGER;
(* ------------------------------------------------------------------------- *)
[GLOBAL]
FUNCTION GetRoomOwner(N : INTEGER; VAR Owner : ShortString) : BYTE_BOOL;
VAR
Own : LongNameRec;
BEGIN
GetRoomOwner := FALSE;
IF GetLongName(l_na_roomown, own) THEN
BEGIN
Owner := Own.Idents[N];
GetRoomOwner := TRUE;
END;
END;
[GLOBAL]
FUNCTION SetRoomOwner(N : INTEGER; Owner : ShortString) : BYTE_BOOL;
VAR
Own : LongNameRec;
BEGIN
SetRoomOwner := FALSE;
IF GetLongName(l_na_roomown, own) THEN
BEGIN
Own.Idents[N] := Owner;
IF SaveLongName(l_na_roomown, own) THEN
BEGIN
LogEvent(-1, -1, e_setname, 0, 0, nt_long, l_na_roomown, '', r_allrooms,
owner, n);
SetRoomOwner := TRUE;
END;
END;
END;
[GLOBAL]
FUNCTION IsRoomOwner(RoomNo : INTEGER; Privd : BYTE_BOOL;
CheckPub : Byte_Bool) : BYTE_BOOL;
VAR
MyId, Own : ShortString;
BEGIN
MyId := LowCase(UserId);
IF GetRoomOwner(RoomNo, Own) THEN
IsRoomOwner := (CheckPub AND (Own = '')) OR (LowCase(Own) = MyId) OR Privd
ELSE IsRoomOwner := Privd;
END;
(* ------------------------------------------------------------------------- *)
[GLOBAL]
FUNCTION GetRoomName(N : INTEGER; VAR Name : ShortString) : BYTE_BOOL;
VAR
Nam : LongNameRec;
BEGIN
GetRoomName := FALSE;
Name := 'ERROR';
IF GetLongName(l_na_roomnam, Nam) THEN
BEGIN
Name := Nam.Idents[N];
GetRoomName := TRUE;
END;
END;
[GLOBAL]
FUNCTION SetRoomName(N : INTEGER; Name : ShortString) : BYTE_BOOL;
VAR
Nam : LongNameRec;
BEGIN
SetRoomName := FALSE;
IF GetLongName(l_na_roomnam, nam) THEN
BEGIN
Nam.Idents[N] := Name;
IF SaveLongName(l_na_roomnam, Nam) THEN
BEGIN
LogEvent(-1, -1, e_setname, 0, 0, nt_long, l_na_roomnam, '', r_allrooms,
name, n);
LogEvent(0, 0, E_READ_ROOMDESC, 0, 0, 0, 0, '', N);
SetRoomName := TRUE;
END;
END;
END;
(* ------------------------------------------------------------------------- *)
FUNCTION GetExitType(N : INTEGER) : String;
VAR
S : String;
BEGIN
CASE N OF
0: S := ' no exit';
1: S := ' Open passage';
2: S := '* Door, object required to pass';
3: S := '* No passage if holding object';
4: S := ' Randomly fails';
5: S := ' Potential exit';
6: S := '* Only exists while holding the required object';
7: S := ' Timed exit';
8: S := '* Passworded exit';
OTHERWISE S := 'ERROR';
END;
GetExitType := S;
END;
PROCEDURE PrintExitTypes;
VAR
Loop : INTEGER;
BEGIN
For Loop := 0 TO 8 DO
Writeln(Loop:0, ') ', GetExitType(Loop));
END;
(* ------------------------------------------------------------------------- *)
FUNCTION GetRoomType(N : INTEGER) : String;
BEGIN
CASE N OF
0: getroomtype :='Market or Store';
1: getroomtype :='No Combat/Spells in this area';
2: getroomtype :='No hiding in this area';
3: getroomtype :='Hard to Hide in this area';
4: getroomtype :='Object destroying area';
5: getroomtype :='Treasure dropping area';
6: getroomtype :='Monster generator';
7: getroomtype :='Generates monsters of a group';
8: getroomtype :='Lair of a monster';
9:getroomtype :='Generates monsters of min level';
10:getroomtype :='Generates monsters of max level';
11:getroomtype :='Healing room';
otherwise getroomtype := 'Unknown';
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE ListRoomTypes;
VAR
I : INTEGER;
BEGIN
FOR I := 0 TO MaxRoomType DO
Writeln(I:2,' ',GetRoomType(I));
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
FUNCTION CanAlterExit(Dir : INTEGER; RoomNum : INTEGER;
Privd : BYTE_BOOL := FALSE) : BYTE_BOOL;
(* Assumes a valid direction "dir", and a valid room number "roomnum" *)
(* RETURNS TRUE if they can alter the exit in room "roomnum" in the *)
(* direction "dir", else RETURNS FALSE *)
VAR
HereDesc : RoomDesc;
BEGIN
CanAlterExit := FALSE;
IF IsRoomOwner(RoomNum, Privd, FALSE) THEN
CanAlterExit := TRUE
ELSE
BEGIN
IF GetRoomDesc(RoomNum, HereDesc) THEN
IF HereDesc.Exits[Dir].ToLoc > 0 THEN
IF IsRoomOwner(HereDesc.Exits[Dir].ToLoc, Privd, FALSE) THEN
CanAlterExit := TRUE;
END;
END;
(* -------------------------------------------------------------------------- *)
FUNCTION CanMakeExit(Dir, RoomNum : INTEGER; Alink : BYTE_BOOL;
Privd : BYTE_BOOL) : BYTE_BOOL;
(* Assumes that Dir is a valid Direction, and that RoomNum is valid. *)
(* RETURNS TRUE, if they are able to create an exit in Room "RoomNum" *)
(* in the direction "Dir" *)
VAR
HereDesc : RoomDesc;
BEGIN
CanMakeExit := FALSE;
IF GetRoomDesc(RoomNum, HereDesc) THEN
BEGIN
IF (HereDesc.Exits[Dir].ToLoc <> 0) THEN
IF (Alink) AND (Privd) THEN
CanMakeExit := TRUE
ELSE
IF Privd THEN
Writeln('There is already an exit there. Use UNLINK to remove it.')
ELSE
INFORM_NoAlterExit
ELSE
IF IsRoomOwner(RoomNum, Privd, FALSE) OR
(HereDesc.Exits[Dir].Kind = EK_ACCEPTOR) THEN
CanMakeExit := TRUE
ELSE
INFORM_NoAlterExit
END
ELSE
INFORM_NoAlterExit
END;
(* -------------------------------------------------------------------------- *)
FUNCTION LinksPossible(RoomNum : INTEGER; Privd : BYTE_BOOL := FALSE) : BYTE_BOOL;
VAR
I : INTEGER;
HereDesc : RoomDesc;
BEGIN
LinksPossible := FALSE;
IF IsRoomOwner(RoomNum, Privd, FALSE) THEN
LinksPossible := TRUE
ELSE
IF GetRoomDesc(RoomNum, HereDesc) THEN
FOR I := 1 TO MaxExit DO
IF (HereDesc.Exits[I].ToLoc = 0) AND
(HereDesc.Exits[I].Kind = EK_ACCEPTOR) THEN
LinksPossible := TRUE;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE InitExit(Dir : INTEGER; VAR HereDesc : RoomDesc);
BEGIN
WITH HereDesc.Exits[Dir] DO
BEGIN
Kind := 1;
Exitdesc := DEFAULT_DESC;
Fail := DEFAULT_DESC;
Success := DEFAULT_DESC;
Comeout := DEFAULT_DESC;
Goin := DEFAULT_DESC;
DoorEffect := 0;
ObjReq := 0;
Hidden := 0;
ReqAlias := FALSE;
ReqVerb := FALSE;
AutoLook := TRUE;
Alias := '';
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE LinkRoom(Start, Dir, Finish, EndDir : INTEGER; MySlot : INTEGER;
Name : String);
VAR
TargName : String;
HereDesc : RoomDesc;
BEGIN
IF GetRoomDesc(Start, HereDesc) THEN
BEGIN
WITH HereDesc.Exits[Dir] DO
BEGIN
ToLoc := Finish;
Slot := EndDir;
InitExit(Dir, HereDesc);
END;
IF SaveRoomDesc(Start, HereDesc) THEN
LogEvent(0, 0, E_READ_ROOMDESC, 0, 0, 0, 0, '', Start);
END
ELSE
Writeln('Error linking room.');
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE DoLink(S : String; Alink :BYTE_BOOL := FALSE;VAR AllStats : AllMyStats);
VAR
Ok : BYTE_BOOL;
OrgExitNam, TargNam, TrgExitNam : String;
TargRoom, TargDir, OrigDir : INTEGER;
RoomNum : INTEGER;
TempLoc : INTEGER;
BEGIN
RoomNum := AllStats.Stats.Location;
IF LinksPossible(RoomNum, AllStats.Stats.Privd) THEN
BEGIN
Writeln('Hit return alone at any prompt to terminate exit creation.');
Writeln;
IF S = '' THEN
GrabLine('Direction of exit? ', OrgExitNam,AllStats)
ELSE
OrgExitNam := Bite(S);
WHILE (OrgExitNam <> '') AND (NOT LookupDir(OrigDir, OrgExitNam)) DO
GrabLine('Direction of exit? ', OrgExitNam,AllStats);
OK := LookupDir(OrigDir, OrgExitnam);
IF OK THEN
BEGIN
IF S = '' THEN
GrabLine('Room to link to? ',TargNam,AllStats)
ELSE
TargNam := Bite(S);
WHILE (Targnam <> '') AND
(NOT LookupRoomName(Targnam, TargRoom, false, false)) DO
GrabLine('Room to link to? ',TargNam,AllStats);
OK := LookupRoomName(Targnam, TargRoom, false, true);
END;
IF OK THEN
BEGIN
IF S = '' THEN
BEGIN
Writeln('Exit comes out in target room');
GrabLine('from what direction? ',TrgExitNam,AllStats);
END
ELSE
TrgExitNam := Bite(S);
WHILE (TrgExitNam <> '') AND (NOT LookupDir(TargDir, TrgExitNam)) DO
GrabLine('from what direction? ',TrgExitNam,AllStats);
OK := LookupDir(TargDir, TrgExitNam);
END;
IF OK THEN
Ok := CanMakeExit(Targdir, TargRoom, Alink, AllStats.Stats.Privd);
IF OK THEN
BEGIN
LinkRoom(RoomNum, Origdir, TargRoom, TargDir, AllStats.Stats.Slot,
AllStats.Stats.Name);
IF NOT Alink THEN
LinkRoom(TargRoom, TargDir, RoomNum, OrigDir, 0, AllStats.Stats.Name);
END;
END
ELSE
Writeln('No links are possible here.');
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE DoDescribe(S : String; VAR AllStats : AllMyStats);
VAR
I, NewDsc : INTEGER;
HereDesc : RoomDesc;
RoomNum : INTEGER;
Slot : INTEGER;
BEGIN
RoomNum := AllStats.Stats.Location;
Slot := AllStats.Stats.Slot;
IF GetRoomDesc(RoomNum, HereDesc) THEN
BEGIN
IF Length(S) > VeryShortLen THEN
Writeln('Your detail keyword can only be ',veryshortlen:1,' characters.')
ELSE
IF IsRoomOwner(RoomNum, AllStats.Stats.Privd, FALSE) THEN
BEGIN
IF NOT (LookupDetail(I, S)) THEN
IF NOT (AllocDetail(I, S, RoomNum)) THEN
BEGIN
Writeln('You have used all ',maxdetail:1,' details.');
Writeln('To delete a detail, DESCRIBE <the detail> and delete all the text.');
END;
IF I <> 0 THEN
BEGIN
HereDesc.Detail[I] := S;
Writeln('[ Editing detail "', HereDesc.Detail[i],'" of this room ]');
NewDsc := HereDesc.DetailDesc[I];
IF EditDesc(NewDsc, ,AllStats) THEN
BEGIN
HereDesc.DetailDesc[I] := NewDsc;
IF NewDsc = 0 THEN
HereDesc.Detail[I] := '';
IF SaveRoomDesc(RoomNum, HereDesc) THEN
LogEvent(0, 0, E_READ_ROOMDESC, 0, 0, 0, 0, '', RoomNum);
END;
END;
END;
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE RoomHelp(Privd : BYTE_BOOL := FALSE);
BEGIN
Writeln;
Writeln('B Edit the target room (G) "bounced in" description');
Writeln('C Set the room''s alignment.');
Writeln('D Alter the way the room description prints');
Writeln('F Edit the default line others will see when an exit fails');
Writeln('G Set the location that a dropped object really Goes to');
Writeln('M Define the magic object for this room');
Writeln('N Change how the room Name prints');
Writeln('O Edit the object drop description (for drop effects)');
Writeln('P Edit the Primary room description [the default one]');
Writeln('R Rename the room');
Writeln('S Edit the Secondary room description');
Writeln('T Set the trapdoor direction and chance');
Writeln('X Define a mystery message');
Writeln('Y Set a secondary mystery message');
Writeln('Z Change the amounts available in a shop.');
Writeln;
Writeln('V View settings on this room');
Writeln('Q/E Quit/Exit');
IF Privd THEN
BEGIN
Writeln(', Set a room attribute');
Writeln('> Delete a room attribute');
Writeln('1/2 Set window');
Writeln('A Set special action');
END;
Writeln('? This list');
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoRename(VAR AllStats : AllMyStats; VAR HereDesc : RoomDesc);
VAR
Dummy : INTEGER;
NewName, S : String;
Nam : LongNameRec;
Privd : BYTE_BOOL;
BEGIN
Privd := AllStats.Stats.Privd;
Writeln('This room is named ',HereDesc.nicename);
Writeln;
GrabLine('New name: ', NewName,AllStats, , ShortLen);
IF (Length(NewName) = 0) THEN
Writeln('No changes.')
ELSE
IF LookupRoomName(newname, Dummy, TRUE, true) AND (NOT Privd) THEN
Writeln(newname,' is not a unique room name.')
ELSE
HereDesc.NiceName := NewName;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE ViewRoom(HereDesc : RoomDesc; AllStats : AllMyStats);
VAR
S : String;
tmp,I : INTEGER;
Where : ShortString;
ObjName : ShortNameRec;
BEGIN
Writeln;
WITH HereDesc DO
BEGIN
Writeln('Room: ',nicename);
PrintParticle(NamePrint, 'precedes roomname.', AllStats);
Writeln('Room owner: ', OwnTrans(Owner));
Writeln('Alignment: ', ReturnAlignment(Alignment, tmp));
Write('Primary description is set : ');
Writeln(Primary <> 0);
Write('Secondary description is set : ');
Writeln(Secondary <> 0);
CASE Which OF
0: Writeln('Only the primary description will print');
1: Writeln('Only the secondary description will print');
2: Writeln('Both the primary and secondary descriptions will print');
3: BEGIN
Writeln('The primary description will print, followed by the seconary description');
Writeln('if the player is holding the magic object');
END;
4: BEGIN
Writeln('If the player is holding the magic object, the secondary description will print');
Writeln(' Otherwise, the primary description will print');
END;
OTHERWISE Writeln('The way the room description prints is damaged');
END;
Writeln;
FOR I := 0 to maxroomtype do
if check_bit(heredesc.spcroom, I) then
Writeln('Room type : [', heredesc.mag[i]:0, '] ',
GetRoomType(I));
IF MagicObj <> 0 THEN BEGIN
GetShortName(s_na_objnam, objname);
Writeln('Magic object: ', Objname.idents[magicobj]);
END;
IF ObjDrop <> 0 THEN
BEGIN
GetRoomName(objdrop, where);
Writeln('Dropped objects go to: ', Where ,' - ');
Write('Drop description set : ');
Writeln(ObjDesc <> 0);
Write('Destination description set: ');
Writeln(ObjDest <> 0);
END;
IF TrapTo <> 0 THEN
Writeln('The trapdoor sends players ',Direct[TrapTo], ' with a chance factor of ',trapchance:1,'%');
Write('Special action: ');
IF Special_act in [1..maxcmds] THEN
Writeln(get_command_by_number(special_act))
ELSE
IF -Special_act in [1..MaxAtmospheres] THEN
Writeln(Atmosphere[-special_act].trigger)
ELSE
Writeln('none');
FOR I := 1 TO MaxDetail DO
IF Length(Detail[I]) > 0 THEN
BEGIN
Write('Detail "',detail[i],'" ');
IF DetailDesc[I] > 0 THEN
Writeln('has a description')
ELSE
Writeln('has no description');
END;
Writeln;
END; (* With *)
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE DoWindow(WindowNum : INTEGER; VAR HereDesc : RoomDesc;
VAR AllStats : AllMyStats);
VAR
TargName : ShortString;
TargNum, N : INTEGER;
S : String;
WindRoomDesc : RoomDesc;
OneLiner : LineRec;
RoomNum : INTEGER;
BEGIN
RoomNum := AllStats.Stats.Location;
IF (HereDesc.WindowDesc[Windownum] <>0) THEN
BEGIN
IF (GetRoomDesc(HereDesc.Window[WindowNum], WindRoomDesc)) THEN
BEGIN
TargName := WindRoomDesc.NiceName;
IF GetLine(-HereDesc.WindowDesc[WindowNum], OneLiner) THEN
BEGIN
Writeln('The window looks at room ', TargName,' with this description:');
Writeln(OneLiner.Line);
END;
END;
END;
IF GetName(nt_long, l_na_roomnam, 'New room: ', targnum,,AllStats) THEN
IF TargNum = RoomNum THEN
TargNum := 0;
Writeln('Enter a new window description, # for people.');
MakeLine(HereDesc.windowdesc[windownum],'window',AllStats);
IF HereDesc.WindowDesc[WindowNum] = 0 THEN
HereDesc.Window[WindowNum] := 0
ELSE
HereDesc.Window[WindowNum] := TargNum;
IF SaveRoomDesc(RoomNum, HereDesc) THEN
LogEvent(0, 0, E_READ_ROOMDESC, 0, 0, 0, 0, '', RoomNum);
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE CustomRoom(RoomNum : INTEGER; VAR AllStats : AllMyStats);
VAR
Done, OK : BYTE_BOOL;
Prompt, S, Name : String;
N, NewDsc : INTEGER;
HereDesc : RoomDesc;
Here : Room;
ObjName : ShortNameRec;
Obj : ObjectRec;
Nam : LongNameRec;
Privd : BYTE_BOOL;
DummyShort : ShortString;
Itmp : INTEGER;
BEGIN
Privd := AllStats.Stats.Privd;
Name := AllStats.Stats.Name;
Done := FALSE;
IF IsRoomOwner(RoomNum, Privd, FALSE) THEN
BEGIN
IF GetroomDesc(RoomNum, HereDesc) THEN
BEGIN
REPEAT
GrabLine('Custom '+HereDesc.NiceName+'> ',S,AllStats, , 1);
S := Lowcase(S);
IF (Length(S) = 0) THEN
S := 'q';
CASE S[1] OF
'c' : BEGIN
GrabLine('Room Alignment? ', S, AllStats);
Itmp := LookUpAlign(S);
IF Itmp <> 0 THEN
HereDesc.alignment := Itmp * align_thres
ELSE
BadAlignment;
END;
'q' : BEGIN
IF GrabYes('Really quit? ', AllStats) THEN
Done := TRUE
ELSE
Writeln('Quit aborted.');
END;
'e' : IF SaveRoomDesc(RoomNum, HereDesc) AND
SetRoomName(RoomNum, HereDesc.NiceName) THEN
Done := TRUE;
'?' : RoomHelp(Privd);
'1' : DoWindow(1, HereDesc, AllStats);
'2' : DoWindow(2, HereDesc, AllStats);
'r' : DoRename(AllStats, HereDesc);
'>' : IF CheckPrivs(Privd, Name) THEN
BEGIN
ListRoomTypes;
Grab_Num('Type of room to delete? ', Itmp, -1,
maxroomtype, -1, AllStats);
if (Itmp>=0) then
ClearBit(HereDesc.SpcRoom, Itmp);
END;
'v' : ViewRoom(HereDesc, AllStats);
',' : IF CheckPrivs(Privd, Name) THEN
BEGIN
ListRoomTypes;
Grab_Num('Type of room to add? ', Itmp, -1,
maxroomtype, -1, AllStats);
if (Itmp >= 0) then begin
setbit(heredesc.spcroom, itmp);
Grab_num('Room magnitude? ', HereDesc.mag[Itmp],,,,
AllStats);
end;
END;
't' : BEGIN
GrabLine('What direction does the trapdoor exit through? ',
S, AllStats);
IF Length(S) > 0 THEN
BEGIN
LookupDir(HereDesc.Trapto, S);
IF (HereDesc.TrapTo <> 0) THEN
BEGIN
Writeln('Enter the chance that the player will fall');
Writeln('through the trapdoor (0-100) :');
Writeln;
Grab_Num('% Chance: ', HereDesc.trapchance,0,100,
HereDesc.trapchance,AllStats);
END
ELSE
HereDesc.TrapChance := 0;
END
ELSE
BEGIN
HereDesc.TrapTo := 0;
HereDesc.TrapChance := 0;
END;
END;
'a' : IF CheckPrivs(Privd, Name) THEN
BEGIN
GrabLine('Special action> ',s,AllStats);
HereDesc.Special_Act := Lookup_Command(S);
IF HereDesc.Special_Act = 0 THEN
HereDesc.Special_Act := -LookupAtmosphere(S);
IF HereDesc.Special_Act <> 0 THEN
EditDesc(HereDesc.Special_Effect,'person''s actions',AllStats)
ELSE
IF GrabYes('Deallocate description? ',AllStats) THEN
DeallocateDesc(hereDesc.special_effect);
END;
's' : IF EditDesc(hereDesc.secondary,'secondary room',AllStats) THEN;
'p' : IF EditDesc(hereDesc.primary,'primary room',AllStats) THEN;
'f' : IF EditDesc(hereDesc.ofail,'exit fail',AllStats) THEN;
'o' : IF MakeLine(hereDesc.objdesc,'object drop',AllStats) THEN;
'x' : IF MakeLine(hereDesc.rndmsg,'random message',AllStats) THEN;
'y' : IF EditDesc(hereDesc.xmsg2,'alternate mystery',AllStats) THEN;
'b' : IF MakeLine(hereDesc.objdest,'bounced in (# = object name)',
AllStats) THEN;
'm' : BEGIN
IF GetShortName(s_na_objnam, ObjName) THEN
IF HereDesc.MagicObj = 0 THEN
Writeln('there is currently no magic object for this room.')
ELSE
Writeln(ObjName.Idents[hereDesc.magicobj],
' is currently the magic object for this room.');
Writeln;
IF GetName(nt_short, s_na_objnam,'New magic object? ',
HereDesc.magicobj,,AllStats) THEN;
END;
'g' : BEGIN
IF HereDesc.ObjDrop = 0 THEN
Writeln('Objects dropped fall here.')
ELSE BEGIN
GetRoomName(HereDesc.ObjDrop, DummyShort);
Writeln('Objects dropped fall in ', DummyShort, '.');
END;
Writeln;
GetName(nt_long, l_na_roomnam,'Room dropped objects go do? ',
n, RoomNum,AllStats);
OK := TRUE;
IF (N <> 0) AND (N <> RoomNum) THEN
IF (check_bit(heredesc.spcroom, rm$b_store)) THEN
OK := FALSE;
IF OK THEN
HereDesc.ObjDrop := N;
END;
'd' : BEGIN
Writeln('0) Print primary (main) description only [default]');
Writeln('1) Print only secondary description.');
Writeln('2) Print both primary and secondary descriptions togther.');
Writeln('3) Print primary description first; then print secondary description only if');
Writeln(' the player is holding the magic object for this room.');
Writeln('4) Print secondary if holding the magic obj; print primary otherwise');
Writeln;
Grab_Num('How to print description? ',hereDesc.which,
0,4,hereDesc.which,AllStats);
END;
'n' : BEGIN
Write('0) '); PrintParticle(0, 'No name is shown.',
AllStats);
Write('1) '); PrintParticle(1, '...', AllStats);
Write('2) '); PrintParticle(2, '...', AllStats);
Write('3) '); PrintParticle(3, '...', AllStats);
Write('4) '); PrintParticle(4, '...', AllStats);
Write('5) '); PrintParticle(5, '...', AllStats);
Write('6) '); PrintParticle(6, '...', AllStats);
Writeln;
Grab_Num('How name prints ',hereDesc.nameprint,0,6,
HereDesc.nameprint,AllStats);
END;
'z' : BEGIN
IF GetRoom(RoomNum, Here) THEN
FOR N := 1 TO MaxObjs DO
IF Here.Objs[N] MOD 1000 <> 0 THEN
BEGIN
Obj := GlobalObjects[Here.Objs[N] MOD 1000];
Writeln('There were ',Here.ObjHide[N],' of them.');
S := 'New number of '+ Obj.ObjName + ': ';
Grab_Num(S,Here.objhide[n],-1,99999,Here.objhide[n],AllStats);
IF SaveRoom(RoomNum, Here) THEN;
END;
END;
OTHERWISE inform_badcmd;
END;
UNTIL Done;
END;
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE CustomExitHelp(Privd : BYTE_BOOL := FALSE);
BEGIN
Writeln;
Writeln('A Set an Alias for the exit');
Writeln('C Conceal an exit');
Writeln('D Edit the exit''s main Description');
Writeln('E EXIT custom (saves changes)');
Writeln('F Edit the exit''s failure line');
Writeln('I Edit the line that others see when a player goes Into an exit');
Writeln('K Set the object that is the Key to this exit');
Writeln('L Automatically look [default] / don''t look on exit');
Writeln('O Edit the line that people see when a player comes Out of an exit');
Writeln('Q QUIT Custom (throw away changes)');
Writeln('R Require/don''t require alias for exit; ignore direction');
Writeln('S Edit the success line');
Writeln('T Alter Type of exit (passage, door, etc)');
Writeln('V View exit information');
Writeln('X Require/don''t require exit name to be a verb');
IF Privd THEN
Writeln('W What happens when you go through the exit');
Writeln('? This list');
Writeln;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE AnalyzeExit(Dir : INTEGER; HereDesc : RoomDesc);
VAR
X, Y : INTEGER;
S : String;
DummyShort : ShortString;
ObjName : ShortNameRec;
RoomName : LongNameRec;
BEGIN
Writeln;
WITH HereDesc.Exits[Dir] DO
BEGIN
IF Alias <> '' THEN
S := '('+Alias
ELSE
S := '(no alias';
IF ReqAlias THEN
S := S + ' required)'
ELSE
S := S + ')';
IF Toloc <> 0 THEN
BEGIN
GetRoomName(toloc, dummyshort);
Writeln('The ',direct[dir],' exit ',s,' goes to ', DummyShort);
END
ELSE
Writeln('The ',direct[dir],' exit goes nowhere.');
Writeln('Hidden : ', Hidden <> 0);
Writeln('Exit type: ', GetExitType(Kind));
IF ObjReq <> 0 THEN
IF GetShortName(s_na_objnam, ObjName) THEN
Writeln('Required object is: ',ObjName.Idents[ObjReq])
ELSE
Writeln('Required object is: unknown - error');
Writeln;
IF ExitDesc = DEFAULT_DESC THEN BEGIN
GetLongName(l_na_roomnam, roomname);
ExitDefault(Dir, Kind, Toloc, RoomName);
END
ELSE
PrintDesc(exitdesc);
IF Success = 0 THEN
Writeln('(no success message)')
ELSE
PrintDesc(success);
IF Fail = DEFAULT_DESC THEN
IF Kind = EK_ACCEPTOR THEN
Writeln('There isn'' an exit there yet.')
ELSE
Writeln('You can''t go that way.')
ELSE
PrintDesc(Fail);
IF ComeOut = DEFAULT_DESC THEN
Writeln('# has come into the room from: ',direct[dir])
ELSE
PrintDesc(comeout);
IF Goin = DEFAULT_DESC THEN
Writeln('# has gone ',direct[dir])
ELSE
PrintDesc(goin);
Writeln;
Writeln('Look automatically done : ', AutoLook);
Writeln('Require alias to be verb: ', ReqVerb);
EffectDecompress(Y, X, DoorEffect);
Writeln('Type: ',x,' Power:',y);
Writeln;
END; (* With *)
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE GetKey(Dir : INTEGER; VAR HereDesc : RoomDesc;
VAR AllStats : AllMyStats);
VAR
S : String;
N : INTEGER;
ObjName : ShortNameRec;
BEGIN
IF GetShortName(s_na_objnam, ObjName) THEN
BEGIN
Writeln('Key: ');
IF HereDesc.Exits[Dir].ObjReq = 0 THEN
Writeln('none')
ELSE
Writeln(ObjName.idents[hereDesc.exits[dir].objreq]);
N := HereDesc.Exits[Dir].ObjReq;
GetName(nt_short, s_na_objnam,'What object is the door key? ', N, ,AllStats);
HereDesc.Exits[Dir].ObjReq := N;
END;
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE CustomExit(Dir : INTEGER; VAR AllStats : AllMyStats);
VAR
S: String;
Done : BYTE_BOOL;
N, Temp, X, Y : INTEGER;
HereDesc : RoomDesc;
RoomNum : INTEGER;
Privd : BYTE_BOOL;
Dummy_s, Name : String;
Dummy : INTEGER;
BEGIN
RoomNum := AllStats.Stats.Location;
Privd := AllStats.Stats.Privd;
Name := AllStats.Stats.Name;
Done := TRUE;
IF GetRoomDesc(RoomNum, HereDesc) THEN
IF CanAlterExit(Dir, RoomNum, Privd) THEN
BEGIN
Writeln('Customizing ',direct[dir],' exit in ',HereDesc.NiceName);
Writeln;
Done := FALSE;
END
ELSE
Writeln('You are not allowed to alter that exit.');
WHILE NOT(Done) DO
BEGIN
GrabLine('Custom '+direct[dir]+'> ',s,AllStats, , 1);
S := lowcase(S);
IF Length(S) = 0 THEN
S := 'q';
CASE S[1] OF
'?' : CustomExitHelp(Privd);
'q' : IF GrabYes('Really quit? ', AllStats) THEN
Done := TRUE
ELSE
Writeln('Quit cancelled.');
'e' : IF SaveRoomDesc(RoomNum, HereDesc) THEN
BEGIN
LogEvent(0, 0, E_READ_ROOMDESC, 0, 0, 0, 0, '', RoomNum);
Done := TRUE;
END;
'k' : GetKey(Dir, HereDesc, AllStats);
'c' : IF EditDesc(HereDesc.Exits[Dir].Hidden,'hidden exitfound',
AllStats) THEN;
'r' : IF CheckPrivs(Privd, Name) THEN
DoToggle(HereDesc.Exits[Dir].ReqAlias,
'The alias will #be required to reference this exit.');
'x' : DoToggle(HereDesc.Exits[Dir].ReqVerb,
'The exit name will #be required to be used as a verb.');
'l' : DoToggle(HereDesc.Exits[Dir].AutoLook,
'A LOOK will #be done after someone moves through the exit.');
'a' : BEGIN
GrabLine('Alternate name for the exit?',
dummy_s, AllStats, , VeryShortLen);
HereDesc.Exits[dir].alias := substr(dummy_s, 1, dummy_s.length);
HereDesc.Exits[Dir].Alias := Lowcase(HereDesc.Exits[Dir].Alias);
END;
'v' : AnalyzeExit(Dir, HereDesc);
't' : BEGIN
Writeln;
Write('Select the type of your exit:');
PrintExitTypes;
Writeln;
Grab_Num('Which type? ',Dummy,0,8,,AllStats);
IF ((HereDesc.Exits[Dir].Kind IN [0,1,4,7]) OR (Privd)) THEN
BEGIN
HereDesc.Exits[Dir].Kind := Dummy;
IF (HereDesc.Exits[Dir].Kind IN [2,3,6]) THEN
GetKey(Dir, HereDesc, AllStats);
END
ELSE
Writeln('Sorry, that is a privd selection.');
END;
'f' : IF EditDesc(HereDesc.Exits[Dir].Fail,'failure',AllStats) THEN;
'i' : IF EditDesc(HereDesc.Exits[Dir].Goin,
'go in (# = player name)',AllStats) THEN;
'o' : IF EditDesc(HereDesc.Exits[Dir].Comeout,
'come out (# = player name)',AllStats) THEN;
'd' : IF MakeLine(hereDesc.exits[dir].exitdesc,'look',AllStats) THEN;
'w' : IF CheckPrivs(Privd, Name) THEN
BEGIN
Writeln('Valid exit effects');
Writeln('1 experience +/-');
Writeln('2 wealth +/-');
Writeln('3 bankwealth +/-');
Writeln('4 health +/-');
Writeln('5 mana +/-');
Writeln('6 exp set');
Writeln('7 class set and reset');
Writeln('8 class set same level');
Writeln('9 alarmed');
Writeln('10 health <');
Writeln('11 guardian');
Writeln('12 modified experience');
EffectDecompress(y,x,HereDesc.exits[dir].dooreffect);
Writeln('Current values: Type: ',x,' Power:',y);
Writeln;
Grab_Num('Type ',n,1,12,,AllStats);
Grab_Num('Amount ',x,,,,AllStats);
EffectCompress(x,n,temp);
HereDesc.Exits[Dir].DoorEffect := Temp;
END;
's' : IF EditDesc(HereDesc.Exits[Dir].Success,'success',AllStats) THEN;
OTHERWISE inform_badcmd;