-
Notifications
You must be signed in to change notification settings - Fork 11
/
senseRegion.t
1807 lines (1509 loc) · 61 KB
/
senseRegion.t
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
#charset "us-ascii"
#include "advlite.h"
/*----------------------------------------------------------------------------*/
/*
* senseRegion.t
*
* This file defines the senseRegion class and the modifications to other
* classes needed to support it. It can be omitted from games that don't need
* the functionality it provides.
*
* This file forms part of the adv3Lite library by Eric Eve (c) 2012, 2013
*
*/
/*
* A SenseRegion is a special kind of Region allowing sensory connection
* between rooms
*/
class SenseRegion: Region
/* Is it possible to see from one room to another in this SenseRegion? */
canSeeAcross = true
/*
* Is it possible to hear sounds (but not necessarily converse) in one
* room from another in this SenseRegion?
*/
canHearAcross = true
/* Do smells travel from one room to another in this SenseRegion? */
canSmellAcross = true
/*
* By default actors have to be in the same room to be able to converse.
* Even if sound can travel from one location to another that doesn't
* necessarily mean that one could converse over that distance. The only
* exception might be where a senseRegion models a relatively small area,
* like two ends of a room.
*
* Note that if canHearAcross is nil setting canTalkAcross to true will
* have no effect.
*/
canTalkAcross = nil
/*
* Are rooms in this SenseRegion close enough together to allow objects to
* be thrown from one room to another; by default we'll assume not.
*/
canThrowAcross = nil
/*
* Use this method to carry out some additional initialization useful to
* SenseRegions
*/
setFamiliarRooms()
{
/* Carry out the inherited handling. */
inherited();
/*
* Also take the opportunity to build each room's list of
* sensory-connected rooms.
*/
/* Go through each room in our room list */
foreach(local rm in roomList)
{
/*
* If we can see into remote rooms from here, append our list of
* visible rooms to the other room's list of visible rooms,
* excluding itself.
*/
if(canSeeAcross)
rm.visibleRooms = rm.visibleRooms.appendUnique(roomList - rm);
/* And so on for the other senses */
if(canHearAcross)
rm.audibleRooms = rm.audibleRooms.appendUnique(roomList - rm);
if(canSmellAcross)
rm.smellableRooms = rm.smellableRooms.appendUnique(roomList - rm);
if(canTalkAcross)
rm.talkableRooms = rm.talkableRooms.appendUnique(roomList - rm);
if(canThrowAcross)
rm.throwableRooms = rm.throwableRooms.appendUnique(roomList - rm);
rm.linkedRooms = rm.linkedRooms.appendUnique(roomList - rm);
/*
* Sort each room's sensory room lists in ascending orfer of their
* remoteRoomListOrder(pov) from the pov of that room.
*/
rm.visibleRooms = rm.sortRoomSublist(rm.visibleRooms, rm);
rm.audibleRooms = rm.sortRoomSublist(rm.audibleRooms, rm);
rm.smellableRooms = rm.sortRoomSublist(rm.smellableRooms, rm);
}
}
/*
* Add everything to scope for all the rooms that belong to this
* SenseRegion. We do this by sending a senseProbe into each of the rooms
* and adding what would be in scope for that probe.
*/
addExtraScopeItems(action)
{
/* Carry out the inherited handling */
inherited(action);
/* Initialize a new vector for our extra scope items */
local extraScope = new Vector(30);
/* Go through every room in our list */
foreach(local rm in roomList)
{
/* Move the scopeProbe_ object into the room */
scopeProbe_.moveInto(rm);
/*
* Add to our scope everything that's in scope for our scopeProbe_
* while it's in the other room.
*/
extraScope.appendAll(Q.scopeList(scopeProbe_).toList);
}
/*
* Restrict the extra scope items to those that the actor knows about.
*/
extraScope = extraScope.subset({o: gActor.knowsAbout(o)} );
/*
* Append our list of extra scope items to the action's scope list,
* removing any duplicates.
*/
action.scopeList = action.scopeList.appendUnique(extraScope.toList -
scopeProbe_);
/* Remove the scopeProbe_ from the map */
scopeProbe_.moveInto(nil);
}
/*
* Since the PC should be able to see round the whole of a SenseRegion,
* presumably the PC should also be able to find their way around a
* SenseRegion once any of its rooms has been visited, even if the PC is
* yet to visit the other rooms. We can achieve this effect by making the
* SenseRegion familiar once any of its rooms has been visited, provided
* there's line of sight across the rooms in the SenseRegion and the PC is
* in a room in the SenseRegion which has light.
*/
familiar()
{
local fam = nil;
local loc = gPlayerChar.getOutermostRoom;
if(canSeeAcross && loc.isIn(self) && loc.isIlluminated)
fam = true;
/*
* Once our familiar property becomes true it should never become nil
* again, so we can simply convert familiar to the constant value true
* and avoid the need to keep recalculating it.
*/
if(fam)
familiar = fam;
return fam;
}
/*
* Flag: do we want the touchObj PreCondition to move the actor from one
* Room in the SenseRegion to another by implicit action to allow an actio
* to proceed? By default we set this to the value of contSpace, since if
* contSpace is true (i.e. we're using this SenseRegion to model a fairly
* small continuous space, such as a room) it probably makes sense for
* autoGoTo to be true as well, but it's nonetheless perfectly all right
* to override the values of autoGoTo and contSpace independently.
*/
autoGoTo = contSpace
/*
* If our autoGoTo flag is set, our fastGoTo flag should normally also be
* set so that autoGoTo works smoothly without breaks for CONTINUE
* commands impeding the workings of an implicit GoTo. Note, however, that
* it's perfectly okay to override fastGoTo to true on a SenseRegion for
* which autoGoTo is nil; it just may not be such a good idea to do it the
* other way round.
*/
fastGoTo = autoGoTo
/*
* Flag, do we want this SenseRegion to act as a continuous space (e.g.
* representing parts of the same room, so that moving from one room to
* another within this SenseRegion does not trigger a new room
* description, thereby creating the impression that we have moved within
* the same room rather than to another. This should probably be used
* sparingly and only for SenseRegions representing a relatively small
* area, otherwise the lack of a new room description (i.e. a LOOK AROUND)
* could be confusing to the player.
*/
contSpace = nil
;
/*
* modifications to Room to allow SenseRegions to work.
*/
modify Room
/*
* The list of rooms that are visible from this room. Ordinarily this list
* is constructed at Preinit by any Sense Regions this room belongs to, so
* shouldn't normally be manually adjusted by game code. It's conceivable
* that game code could tweak these lists after Preinit, though, perhaps
* to create a one-way connection (e.g. to model a high room that
* overlooks lower ones)
*/
visibleRooms = []
/*
* The lists of rooms we can smell, hear, talk or throw from/into from
* this room.
*/
audibleRooms = []
smellableRooms = []
talkableRooms = []
throwableRooms = []
/*
* The list of rooms to which we're linked by virtue of being in the same
* SenseRegion.
*/
linkedRooms = []
/*
* Show the specialDescs of any items in the other rooms in our
* SenseRegions, where specialDescBeforeContents is true
*/
showFirstConnectedSpecials(pov)
{
foreach(local rm in visibleRooms)
rm.showFirstRemoteSpecials(pov);
}
/*
* Show the specialDescs of any items in the other rooms in our
* SenseRegions, where specialDescBeforeContents is nil
*/
showSecondConnectedSpecials(pov)
{
foreach(local rm in visibleRooms)
rm.showSecondRemoteSpecials(pov);
}
/* List the miscellaneous contents of a remote room */
showConnectedMiscContents(pov)
{
foreach(local rm in visibleRooms)
rm.showRemoteMiscContents(pov);
}
/*
* These properties are for the internal use of the remote listing
* routines, and should normally be left alone by game code.
*/
remoteSecondSpecialList = nil
remoteMiscContentsList = nil
/*
* In additional to showing the first (i.e. pre-miscellaneous) list of
* items with specialDescs in remote locations, the
* showFirstRemoteSpecials() method builds the other lists of objects for
* the subsequent methods to use. pov is the point of view object
* (typically the player character) from whose point of view the list is
* being constructed.
*/
showFirstRemoteSpecials(pov)
{
/*
* The list of items whose specialDescs are to be displayed before the
* list of miscellaneous items.
*/
local specialVec1 = new Vector(10);
/*
* The list of items whose specialDescs are to be displayed after the
* list of miscellaneous items.
*/
local specialVec2 = new Vector(10);
/* The list of miscellaneous items */
local miscVec = new Vector(10);
/*
* Reduce our list to that subset of the list that is visible to the
* pov object.
*/
local lst = contents.subset({o: o.isVisibleFrom(pov) && !o.isHidden});
/*
* Sort the objects to be listed into three separate lists: those with
* specialDescs to be shown before the lists of miscellaneous items,
* the list of miscellaneous items, and the list of objects with
* specialDescs to be listed after the miscellaneous items.
*/
foreach(local obj in lst)
{
/*
* See if obj defines an initSpecialDesc property or specialDesc
* property that is currently in use.
*/
if((obj.propType(&initSpecialDesc) != TypeNil &&
obj.useInitSpecialDesc()) ||
(obj.propType(&specialDesc) != TypeNil && obj.useSpecialDesc()))
{
/*
* If so, and obj's specialDesc is to be shown before any
* miscellaneous contents, add obj to the first specials list
*/
if(obj.specialDescBeforeContents)
specialVec1.append(obj);
/*
* If obj's specialDesc is to be shown after this list of
* miscellaneous context, add obj to the second list of
* specials.
*/
else
specialVec2.append(obj);
}
/*
* Otherwise, if obj doesn't define a currently usable specialDesc
* or initSpecialDesc, add it to the list of miscellaneous items.
*/
else
miscVec.append(obj);
}
/* Sort the first list of specials in specialDescOrder */
specialVec1.sort(nil, {a, b: a.specialDescOrder - b.specialDescOrder});
/* Sort the second list of specials in specialDescOrder */
specialVec2.sort(nil, {a, b: a.specialDescOrder - b.specialDescOrder});
/*
* Show the items in the first list, i.e. the list of items with
* specialDescs to be shown before the miscellaneous items.
*/
foreach(local obj in specialVec1)
{
obj.showRemoteSpecialDesc(pov);
listRemoteContents(obj.contents, remoteSubContentsLister, pov);
}
/* Store the other two lists for later use by other methods. */
remoteSecondSpecialList = specialVec2.toList();
remoteMiscContentsList = miscVec.toList().subset({o:
o.location.ofKind(Room)});
}
/* Show the removeSpecialDesc of each item in the second list of specials */
showSecondRemoteSpecials(pov)
{
foreach(local obj in remoteSecondSpecialList)
{
obj.showRemoteSpecialDesc(pov);
listRemoteContents(obj.contents, remoteSubContentsLister, pov);
}
}
/* List the miscellaneous list of items in this remote location */
showRemoteMiscContents(pov)
{
remoteContentsLister.show(remoteMiscContentsList, inRoomName(pov));
listRemoteContents(remoteMiscContentsList, remoteSubContentsLister,
pov);
}
/*
* The contents lister to use to list this room's miscellaneous contents
* when viewed from a remote location.
*/
remoteContentsLister = remoteRoomContentsLister
/*
* Reset the contents of all the remote rooms visible from this room to
* not having been mentioned.
*/
unmentionRemoteContents()
{
foreach(local rm in visibleRooms)
unmention(rm.allContents);
}
/*
* The name that's used to introduce a list of miscellaneous objects in
* this room when viewed from a remote location containing the pov object
* (normally the player character).
*/
inRoomName(pov)
{
return BMsg(in room name, 'in {1}', theName);
}
/*
* The following six methods take effect only if there would otherwise be
* a sensory connection between the current room and loc due to their
* being in the same SenseRegion.
*
* Can we see into this room from loc?
*/
canSeeInFrom(loc) { return canSeeOutTo(loc); }
/* Can we see out of this room to loc? */
canSeeOutTo(loc) { return true; }
/*
* Can we hear into this room from loc (i.e. can an actor in loc hear
* something in this room?
*/
canHearInFrom(loc) { return canHearOutTo(loc); }
/*
* Can we hear out from this room to loc (i.e. can an actor in this room
* hear something in loc)?
*/
canHearOutTo(loc) { return true; }
/*
* Can we smell into this room from loc (i.e. can an actor in loc smell
* something in this room?
*/
canSmellInFrom(loc) { return canSmellOutTo(loc); }
/*
* Can we hear out from this room to loc (i.e. can an actor in this room
* hear something in loc)?
*/
canSmellOutTo(loc) { return true; }
/*
* Should we look around on entering this room? Normally we should, unless
* both the room obj is travelling from and the room it's travelling to
* (normally this room) both belong in a SenseRegion whose contSpace
* property is true.
*/
lookOnEnter(obj)
{
return obj.getOutermostRoom.regionsInCommonWith(destination).indexWhich(
{ reg: reg.contSpace } ) == nil;
}
/*
* listOrder is inherited from Thing with a default value of 100. For a Room in a SenseRegion
* it can control the order in which other rooms in the SenseRegion have their contents
* described (higher = later), although this can be adjusted via the remoteRoomListOrder(pov)
* method.
*/
// listOrder = 100
/*
* For a Room in a SenseRegion return the order in which other rooms in the SenseRegion have
* their contents described (higher = later) from the point of view of the pov object, which
* will normally be the room from which the viewing, smelling or listening is being performed.
* By default we just return the Room's listOrder.
*/
remoteRoomListOrder(pov)
{
return listOrder;
}
/*
* Sort a sublist of rooms in ascending order of their remoteRoomListOrder(pov) and return the
* result.
*/
sortRoomSublist(sublist, pov)
{
/*
* If our sublist contains less than two elements return our sublist unchanged.
*/
if(sublist.length < 2)
return sublist;
return sublist.sort(nil, {a, b: a.remoteRoomListOrder(pov) - b.remoteRoomListOrder(pov) });
}
;
/*
* The default Lister for listing miscellaneous objects in a remote location.
*/
remoteRoomContentsLister: ItemLister
/* is the object listed in a LOOK AROUND description? */
listed(obj) { return obj.lookListed && !obj.isHidden; }
/*
* Show the list prefix. The irName parameter is the inRoomName(pov)
* passed from Room.showRemoteMiscContents(pov).
*/
showListPrefix(lst, pl, irName)
{
DMsg(remote contents prefix, '<.p>\^{1} {i} {see} ', irName);
}
showListSuffix(lst, pl, irName)
{
DMsg(remote contents suffix, '. ');
}
contentsListedProp = &contentsListedInLook
;
/*
* The default Lister for listing the miscellaneous contents of objects in a
* remote location.
*/
remoteSubContentsLister: ItemLister
/* is the object listed in a LOOK AROUND description? */
listed(obj) { return obj.lookListed && !obj.isHidden; }
/*
* Show the list prefix. The irName parameter is the inRoomName(pov)
* passed from Room.showRemoteMiscContents(pov).
*/
showListPrefix(lst, pl, inParentName)
{
DMsg(remote subcontents prefix, '<.p>\^{1} <<pl ? '{plural}
{is}' : '{dummy} {is}'>> ', inParentName);
}
showListSuffix(lst, pl, irName)
{
DMsg(remote subcontents suffix, '. ');
}
contentsListedProp = &contentsListedInLook
;
/*
* Modifications to Thing to support the other mods required for use with
* SenseRegion.
*/
modify Thing
/*
* Show our remoteSpecialDesc, i.e. the version of our specialDesc that
* should be seen when this item is viewed from a remote location.
*/
showRemoteSpecialDesc(pov)
{
/* If we've already been mentioned, don't do anything */
if(mentioned)
return;
/*
* Otherwise note that we've now been mentioned before doing anything
* else.
*/
else
mentioned = true;
/*
* If we have a non-nil initSpecialDesc and our useInitSpecialDesc
* property is true, show our remoteInitSpecialDesc from pov's point
* of view.
*/
if(propType(&initSpecialDesc) != TypeNil && useInitSpecialDesc)
remoteInitSpecialDesc(pov);
/* Otherwise show our remoteSpecialDesc() */
else
remoteSpecialDesc(pov);
/* Then add a paragraph break */
"<.p>";
/* Note that we've been seen */
noteSeen();
}
/* List contents as seen from a remote location */
listRemoteContents(lst, lister, pov)
{
local contList = lst.subset({o: o.isVisibleFrom(pov) && !o.isHidden});
/*
* Sort the contList in listOrder. Although we're listing the contents
* of each item in the contList, it seems good to mention each item's
* contents in the listOrder order of the item. Amongst other things
* this helps give a consistent ordering for the listing of
* SubComponents.
*/
contList = contList.sort(nil, {a, b: a.listOrder - b.listOrder});
foreach(local obj in contList)
{
/* Note that the object has been seen by the pc. */
obj.noteSeen();
/*
* Don't list the inventory of any actors, or of any items that don't want their
* contents listed, or any items we can't see in, or of any items that don't have any
* contents to list, or of any items whose contents isn't visible remotely from pov.
*/
if(obj.contType == Carrier
|| obj.(lister.contentsListedProp) == nil
|| obj.canSeeIn() == nil
|| obj.contents.length == 0
|| obj.contentsVisibleFrom(pov) == nil)
continue;
/*
* Don't list any items that have already been mentioned or which
* aren't visible from the pov.
*/
local objList = obj.contents.subset({x: x.mentioned == nil &&
x.isVisibleFrom(pov)});
/*
* Extract the list of items that have active specialDescs or
* initSpecial Descs
*/
local firstSpecialList = objList.subset(
{o: (o.propType(&specialDesc) != TypeNil && o.useSpecialDesc())
|| (o.propType(&initSpecialDesc) != TypeNil &&
o.useInitSpecialDesc() )
}
);
/*
* Remove items with specialDescs or initSpecialDescs from the
* list of miscellaneous items.
*/
objList = objList - firstSpecialList;
/*
* From the list of items with specialDescs, extract those whose
* specialDescs should be listed after any miscellaneous items
*/
local secondSpecialList = firstSpecialList.subset(
{ o: o.specialDescBeforeContents == nil });
/*
* Remove the items whose specialDescs should be listed after the
* miscellaneous items from the list of all items with
* specialDescs to give the list of items with specialDescs that
* should be listed before the miscellaneous items.
*/
firstSpecialList = firstSpecialList - secondSpecialList;
/*
* Sort the list of items with specialDescs to be displayed before
* miscellaneous items by specialDescOrder
*/
firstSpecialList = firstSpecialList.sort(nil, {a, b: a.specialDescOrder -
b.specialDescOrder});
/*
* Sort the list of items with specialDescs to be displayed after
* miscellaneous items by specialDescOrder
*/
secondSpecialList = secondSpecialList.sort(nil, {a, b: a.specialDescOrder -
b.specialDescOrder});
/*
* Show the specialDescs of items whose specialDescs should be
* shown before the list of miscellaneous items.
*/
foreach(local cur in firstSpecialList)
cur.showRemoteSpecialDesc(pov);
/* List the miscellaneous items */
if(objList.length > 0)
{
lister.show(objList, obj.remoteObjInName(pov),
paraBrksBtwnSubcontents);
objList.forEach({o: o.mentioned = true });
}
/*
* If we're not putting paragraph breaks between each subcontents
* listing sentence, insert a space instead.
*/
if(!paraBrksBtwnSubcontents)
" ";
/*
* Show the specialDescs of items whose specialDescs should be
* shown after the list of miscellaneous items.
*/
foreach(local cur in secondSpecialList)
cur.showRemoteSpecialDesc(pov);
/*
* Recursively list the contents of each item in this object's
* contents, if it has any; but don't list recursively for an
* object that's just been opened.
*/
if(obj.contents.length > 0 && lister != openingContentsLister)
listRemoteContents(obj.contents, lister, pov);
}
}
/*
* Our remoteSpecialDesc is the paragraph describing this item in a room
* description when viewed from a remote location containing the pov
* object. By default we just show our ordinary specialDesc, but in
* practice we'll normally want to override this.
*/
remoteSpecialDesc(pov) { specialDesc; }
/*
* Our remoteInitSpecialDesc, used when viewing this item from a remote
* location.By default we just show our ordinary initSpecialDesc, but in
* practice we'll normally want to override this.
*/
remoteInitSpecialDesc(pov) { initSpecialDesc; }
/*
* Is this item visible from the remote location containing pov? By
* default it is if it's sightSize is not small, but this can be
* overridden, for example to vary with the pov.
*/
isVisibleFrom(pov) { return sightSize != small; }
/*
* Is this item audible from the remote location containing pov? By
* default it is if it's soundSize is not small, but this can be
* overridden, for example to vary with the pov.
*/
isAudibleFrom(pov) { return soundSize != small; }
/*
* Is this item smellable from the remote location containing pov? By
* default it is if it's smellSize is not small, but this can be
* overridden, for example to vary with the pov.
*/
isSmellableFrom(pov) { return smellSize != small; }
/*
* Assuming this item is readable at all, is it readable from the remote
* location containing pov? By default we assume this is the case if and
* only if the item's sightSize is large, but this can be overridden, for
* example for a large item with small lettering.
*/
isReadableFrom(pov) { return sightSize == large; }
/*
* The sightSize can be small, medium or large and controls how visible
* this object is from a remote location. If it's small, it can't be seen
* from a remote location at all. It it's medium, the object can be seen,
* but it's not possible to discern any detail. If it's large, it can be
* seen and described. Note that this behaviour is only the default,
* however, since it can be changed by overriding the isVisibleFrom() and
* remoteDesc() methods. Note also that sightSize is not related to the
* bulk property (unless you override sightSize to make it so).
*/
sightSize = medium
/*
* The soundSize can be small, medium or large. By default something is
* audible from a remote location either if its soundSize is large or if
* it soundSize is not small and its remoteListenDesc() method has been
* defined. Overriding isAudibleFrom(pov) may change these rules.
*/
soundSize = medium
/*
* The smellSize can be small, medium or large. By default something is
* smellable from a remote location either if its smellSize is large or if
* it smellSize is not small and its remoteSmellDesc() method has been
* defined. Overriding isSmellableFrom(pov) may change these rules.
*/
smellSize = medium
/*
* The following three properties only take effect on objects on which
* they're explicitly defined.
*/
/*
* Define the remoteDesc() property to define the description of this item
* as it should be displayed when the item is examined from the remote
* location containing the pov object. Note that defining this property
* nullifies the distinction between a medium and a large sightSize, since
* the remoteDesc will be used in either case.
*/
// remoteDesc(pov) { desc; }
/*
* Define the remoteListenDesc() property to define the description of
* this item as it should be displayed when the item is listened to from
* the remote location containing the pov object. Note that defining this
* property nullifies the distinction between a medium and a large
* soundSize, since the remoteListenDesc will be used in either case.
*/
// remoteListenDesc(pov) { listenDesc; }
/*
* Define the remoteSmellDesc() property to define the description of this
* item as it should be displayed when the item is smelled from the remote
* location containing the pov object. Note that defining this property
* nullifies the distinction between a medium and a large smellSize, since
* the remoteSmellDesc will be used in either case.
*/
// remoteSmellDesc(pov) { smellDesc; }
/*
* The name given to this object when it's the container for another
* object viewed remotely, e.g. 'in the distant bucket' as opposed to just
* 'in the bucket'. By default we just use the objInName.
*/
remoteObjInName(pov) { return objInName; }
/*
* Modify the effect of Examine to show the remoteDesc if appropriate, or
* else our regular desc if our sightSize is large, or else a message to
* say we're too far away to see any detail. If we're in the same room as
* the actor, simply carry out the regular (inherited) method.
*/
dobjFor(Examine)
{
action()
{
/*
* If the actor doing the examining is in the same room as this
* object, simply carry out the inherited handling.
*/
if(isIn(gActor.getOutermostRoom))
inherited;
/* Otherwise, if we're being examined from a remote location... */
else
{
/*
* If this Thing defines the remoteDesc() property, display
* our remoteDesc() from the pov of the examining actor.
*/
if(propDefined(&remoteDesc))
{
remoteDesc(gActor);
"<.p>";
}
/*
* Otherwise if our sightSize is large, carry out the standard
* (inherited) handling
*/
else if(sightSize == large)
inherited;
/*
* Otherwise say this object is too far away for the actor to
* see any detail.
*/
else
{
say(tooFarAwayToSeeDetailMsg);
"<.p>";
}
}
}
}
tooFarAwayToSeeDetailMsg = BMsg(too far away to see detail, '{The subj dobj}
{is} too far away to make out any detail. ')
/*
* Modify the effect of ListenTo to show the remoteListenDesc if
* appropriate, or else our regular listenDesc if our soundSize is large,
* or else a message to say we're too far away to hear. If we're in the
* same room as the actor, simply carry out the regular (inherited)
* method.
*/
dobjFor(ListenTo)
{
action()
{
/*
* If the actor doing the listening is in the same room as this
* object, simply carry out the inherited handling.
*/
if(isIn(gActor.getOutermostRoom))
inherited;
/* Otherwise, if we're being listened to from a remote location... */
else
{
/*
* If this Thing defines the remoteListenDesc() property,
* display our remoteListenDesc() from the pov of the
* examining actor.
*/
if(propDefined(&remoteListenDesc))
{
remoteListenDesc(gActor);
"<.p>";
}
/*
* Otherwise if our soundSize is large, carry out the standard
* (inherited) handling
*/
else if(soundSize == large)
inherited;
/*
* Otherwise say this object is too far away for the actor to
* hear.
*/
else
{
say(tooFarAwayToHearMsg);
"<.p>";
}
}
}
}
tooFarAwayToHearMsg = BMsg(too far away to hear, '{The subj dobj} {is} too
far away to hear distinctly. ')
/*
* Modify the effect of a Read action to prevent this item being read from
* a remote location unless isReadableFrom(gActor) is true.
*/
dobjFor(Read)
{
verify()
{
inherited;
if(!isIn(gActor.getOutermostRoom) && !isReadableFrom(gActor))
illogicalNow(tooFarAwayToReadMsg);
}
}
tooFarAwayToReadMsg = BMsg(too far away to read, '{The subj dobj} {is} too
far away to read. ')
/*
* Modify the effect of SmellSomething to show the remoteSmellDesc if
* appropriate, or else our regular smellDesc if our smellSize is large,
* or else a message to say we're too far away to smell. If we're in the
* same room as the actor, simply carry out the regular (inherited)
* method.
*/
dobjFor(SmellSomething)
{
action()
{
/*
* If the actor doing the smelling is in the same room as this
* object, simply carry out the inherited handling.
*/
if(isIn(gActor.getOutermostRoom))
inherited;