Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ! made up a couple new constants for the FORMAT mask to be used by the
- ! replaced routines
- constant OVERRIDEHERE_F 8192
- constant ALSO_F 16384
- replace WhatsIn(obj)
- {
- local i, totallisted
- local initial_list_nest
- if FORMAT & NORECURSE_F
- return
- for i in obj
- {
- i is not already_listed
- if i is not hidden
- totallisted++
- }
- if totallisted = 0
- return
- list_count = totallisted
- if obj is not container or obj is platform or
- (obj is container and (obj is not openable or
- (obj is openable and
- (obj is open or obj is transparent)))) and
- (obj ~= player or FORMAT & INVENTORY_F) and obj is not quiet
- {
- SpecialDesc(obj)
- ! If list_count is 0 now, but totallisted was not, something must have been
- ! printed by SpecialDesc
- if list_count = 0
- {
- if FORMAT & INVENTORY_F and not (FORMAT & LIST_F) and
- list_nest = 0
- {
- print newline ! was ' print "" '
- }
- return totallisted
- }
- if obj.list_contents
- return totallisted
- initial_list_nest = list_nest
- if FORMAT & LIST_F
- {
- if list_nest
- {
- ! Indent the first time so that it lines up with
- ! paragraph indentation:
- i = list_nest
- if list_nest = 1 and not (FORMAT & NOINDENT_F)
- {
- Indent
- i--
- }
- print to (i * 2); ! INDENT_SIZE);
- }
- }
- else
- {
- Indent
- }
- if obj.contains_desc ! custom heading
- {
- if FORMAT & LIST_F
- RLibMessage(&WhatsIn, 1 ) ! ":"
- }
- else
- {
- if obj = player
- {
- if FORMAT & LIST_F and list_count < totallisted
- print "\n";
- ! "You are carrying..."
- Message(&WhatsIn, 1, totallisted)
- if FORMAT & LIST_F
- RLibMessage(&WhatsIn, 1 ) ! ":"
- }
- elseif obj is living and not obj.prep
- {
- ! "X has..."
- Message(&WhatsIn, 2, obj, totallisted)
- if FORMAT & LIST_F
- RLibMessage(&WhatsIn, 1 ) ! ":"
- }
- elseif not (FORMAT & OVERRIDEHERE_F)
- {
- if list_count < totallisted
- ! "Also sitting on/in..."
- RLibMessage(&WhatsIn, 2, obj )
- else
- ! "Sitting on/in..."
- RLibMessage(&WhatsIn, 3, obj )
- FORMAT = FORMAT | ISORARE_F
- }
- }
- ListObjects(obj)
- list_nest = initial_list_nest
- }
- return totallisted
- }
- replace ListObjects(thisobj, conjunction)
- {
- local i, obj, count, pluralcount
- local templist_count ! temporary total of unlisted objs.
- local id_count ! for identical (or plural) objects
- #ifset USE_PLURAL_OBJECTS
- local j, this_class
- #endif
- if not conjunction
- conjunction = AND_WORD
- list_nest++
- for obj in thisobj
- {
- if obj is hidden
- {
- obj is already_listed
- #ifclear NO_OBJLIB
- if obj.type = scenery
- obj is known
- #endif
- }
- else
- obj is known
- #ifset USE_PLURAL_OBJECTS
- ! Need to count identical (and possibly plural) objects
- ! for grouping in listing
- if obj.identical_to and obj is not already_listed
- {
- this_class = obj.identical_to
- if this_class.type = identical_class or
- FORMAT & GROUPPLURALS_F
- {
- id_count = 1
- for (i=1; i<=this_class.#plural_of; i++)
- {
- j = this_class.plural_of #i
- if j in thisobj and j~=obj and j is not hidden
- {
- id_count++
- pluralcount++
- list_count--
- j is already_listed
- }
- }
- }
- }
- #endif
- if obj is not already_listed
- {
- ! May have a leading "is" or "are" that needs to
- ! be printed at the head of the list
- if FORMAT & ISORARE_F
- {
- if list_count = 1 and id_count <= 1 and
- obj is not plural
- {
- RLibMessage(&ListObjects,1, IS_WORD) ! "is"
- ! print " "; IS_WORD;
- }
- else
- {
- RLibMessage(&ListObjects,1, ARE_WORD) ! "are"
- ! print " "; ARE_WORD;
- }
- if FORMAT & LIST_F
- RLibMessage(&ListObjects,2) ! ":"
- FORMAT = FORMAT & ~ISORARE_F ! clear it
- }
- need_newline = false
- if obj is plural
- pluralcount++
- AssignPronoun(obj)
- if not (FORMAT & LIST_F)
- {
- if list_count > 2 and count
- print ",";
- if list_count > 1 and count = list_count - 1
- print " "; conjunction;
- if not (FORMAT & FIRSTCAPITAL_F)
- print " ";
- }
- else
- {
- print to (list_nest * 2); ! INDENT_SIZE);
- }
- #ifset USE_PLURAL_OBJECTS
- ! If a number of identical (or possibly plural)
- ! objects are grouped together, they are printed
- ! as a single entry in the list
- !
- if obj.identical_to and
- (this_class.type = identical_class or
- FORMAT & GROUPPLURALS_F)
- {
- if id_count = 1
- {
- if FORMAT & FIRSTCAPITAL_F
- CArt(obj)
- else
- Art(obj)
- }
- else
- {
- if FORMAT & FIRSTCAPITAL_F
- print NumberWord(id_count, true);
- else
- print NumberWord(id_count);
- print " "; this_class.name;
- if this_class.type = plural_class
- {
- local k
- if FORMAT & LIST_F
- print ":";
- else
- print " (";
- k = 0
- for (i=1; i<=this_class.#plural_of; i++)
- {
- j = this_class.plural_of #i
- if parent(j) = thisobj
- {
- if not (FORMAT & LIST_F)
- {
- if id_count > 2 and k
- print ",";
- if k = id_count - 1
- print " "; AND_WORD;
- if k
- print " ";
- }
- else
- {
- print "\n";
- print to ((list_nest+1) * 2); ! INDENT_SIZE);
- }
- Art(j)
- if not (FORMAT & NOPARENTHESES_F)
- ObjectIs(j)
- k++
- }
- }
- if not (FORMAT & LIST_F): print ")";
- }
- }
- }
- else
- {
- #endif
- ! Regular old non-plural, non-identical
- ! objects get listed here:
- if FORMAT & FIRSTCAPITAL_F
- CArt(obj)
- else: Art(obj)
- if not (FORMAT & NOPARENTHESES_F)
- ObjectIs(obj)
- #ifset USE_PLURAL_OBJECTS
- }
- #endif
- FORMAT = FORMAT & ~FIRSTCAPITAL_F ! clear it
- count++
- }
- ! For itemized listings, list the children of
- ! each object immediately after that object (unless
- ! it is a SpecialDesc-printed description)
- if obj is not hidden and FORMAT & LIST_F
- {
- print newline
- if children(obj)
- {
- if not obj.list_contents
- {
- templist_count = list_count
- WhatsIn(obj)
- list_count = templist_count
- }
- }
- }
- }
- ! If not an itemized list, it is necessary to finish off the
- ! sentence, adding any necessary words at the end. Then, the
- ! children of all previously objects listed at this level are
- ! listed.
- if not (FORMAT & LIST_F)
- {
- if count
- {
- if list_nest = 1 and FORMAT & ISORAREHERE_F
- {
- if count + pluralcount > 1
- print " "; ARE_WORD;
- else: print " "; IS_WORD;
- if not (FORMAT & OVERRIDEHERE_F) or
- ((FORMAT & OVERRIDEHERE_F) and thisobj = parent(player))
- print " "; HERE_WORD;
- if FORMAT & OVERRIDEHERE_F
- {
- if FORMAT & ALSO_F
- {
- print " also";
- FORMAT = FORMAT & ~ALSO_F
- }
- print " ";
- if thisobj = location and player not in location and
- parent(player) is container
- {
- print "outside ";
- }
- elseif thisobj is container
- print "inside ";
- else
- print "on ";
- The(parent(player))
- }
- FORMAT = FORMAT & ~ISORAREHERE_F ! clear it
- if FORMAT & OVERRIDEHERE_F
- FORMAT = FORMAT & ~OVERRIDEHERE_F ! clear it
- if not (FORMAT&LIST_F or FORMAT&TEMPLIST_F)
- override_indent = true
- }
- if not (FORMAT & NORECURSE_F)
- print ".";
- }
- i = 0
- local char_count
- for obj in thisobj
- {
- if children(obj) and obj is not hidden and
- (obj is not already_listed or
- thisobj ~= location) and not ClothingCheck(obj)
- char_count++
- if char_count = 2
- break
- }
- for obj in thisobj
- {
- if children(obj) and obj is not hidden and
- (obj is not already_listed or
- thisobj ~= location) and not ClothingCheck(obj)
- {
- if FORMAT & TEMPLIST_F
- {
- FORMAT = FORMAT | LIST_F & ~TEMPLIST_F
- i = true
- print newline
- }
- if count > 1 and obj.type = character
- {
- FORMAT = FORMAT | USECHARNAMES_F
- if char_count = 2
- {
- print newline
- override_indent = false
- }
- }
- templist_count = list_count
- WhatsIn(obj)
- list_count = templist_count
- }
- }
- }
- if --list_nest = 0
- {
- if not (FORMAT & LIST_F) and not (FORMAT & NORECURSE_F)
- {
- print newline
- override_indent = false
- need_newline = false
- }
- }
- }
- replace Describeplace(place, long)
- {
- local obj, count, notlisted, tempformat, charcount
- if not place
- place = location
- if AssignPronounsToRoom
- parser_data[PARSER_STATUS] &= ~PRONOUNS_SET
- ! Since, for example, a room description following entering via
- ! DoGo does not trigger before/after properties tied to looking
- ! around:
- !
- #ifclear NO_VERBS
- if verbroutine = &MovePlayer
- {
- if place is not visited and verbosity ~= 1
- return Perform(&DoLookAround)
- elseif long = true or verbosity = 2
- return Perform(&DoLookAround)
- }
- #endif
- exit_type = 0 ! clear the exit_type global
- if not light_source
- {
- Message(&DescribePlace, 1) ! "It's too dark to see..."
- return
- }
- place is known
- ! Print the name of the location as a heading
- RLibMessage(&DescribePlace,1,place)
- override_indent = false
- if place is not visited and verbosity ~= 1
- {
- if &place.initial_desc or &place.long_desc
- Indent
- if not place.initial_desc
- run place.long_desc
- }
- elseif long = true or verbosity = 2
- {
- if &place.long_desc
- Indent
- run place.long_desc
- }
- elseif place is not visited and verbosity = 1
- {
- if &place.initial_desc
- Indent
- run place.initial_desc
- }
- if &place.list_contents and FORMAT & DESCFORM_F
- print "" ! for double-space-after-heading formatting
- ! A location may contain an overriding listing routine, as may any
- ! parent, in the list_contents property
- !
- if not place.list_contents
- {
- list_nest = 0
- ! For double-space-after-heading formatting:
- if FORMAT & DESCFORM_F
- {
- for obj in place
- {
- if obj is not hidden and
- (player not in obj or children(obj) > 1)
- {
- print ""
- break
- }
- }
- }
- ! List contents of chair, vehicle, etc. player is in
- if player not in location
- {
- tempformat = FORMAT
- if SmartParents(parent(player))
- {
- FORMAT = FORMAT | FIRSTCAPITAL_F | ISORAREHERE_F | \
- OVERRIDEHERE_F
- if FORMAT & LIST_F
- {
- FORMAT = FORMAT & ~LIST_F ! clear it
- FORMAT = FORMAT | TEMPLIST_F
- }
- list_nest = 0
- }
- else
- list_nest = 1
- WhatsIn(Parent(player))
- FORMAT = tempformat
- }
- ! List all characters, if any
- count = 0
- for obj in place
- {
- if obj is hidden or obj is not living or
- player in obj
- {
- obj is already_listed
- }
- else
- {
- obj is not already_listed
- }
- }
- for obj in place
- {
- if obj is not already_listed
- {
- print newline
- ShortDescribe(obj)
- if obj is not already_listed
- count++
- }
- }
- list_count = count
- count = 0
- if list_count ! if characters are to be listed
- {
- charcount++
- tempformat = FORMAT
- FORMAT = FORMAT | FIRSTCAPITAL_F | ISORAREHERE_F
- if SmartParents
- FORMAT = FORMAT | OVERRIDEHERE_F
- if list_count > 1
- FORMAT = FORMAT | USECHARNAMES_F
- if FORMAT & LIST_F
- {
- FORMAT = FORMAT & ~LIST_F ! clear it
- FORMAT = FORMAT | TEMPLIST_F
- }
- Indent
- list_nest = 0
- ListObjects(place)
- FORMAT = tempformat
- }
- for obj in place
- {
- #ifset USE_ATTACHABLES
- ! Exclude all attachables for now (and characters)
- if obj is living or obj.type = attachable or
- player in obj
- #else
- if obj is living or player in obj
- #endif
- obj is already_listed
- else
- obj is not already_listed
- }
- for obj in place
- {
- #ifset USE_PLURAL_OBJECTS
- ! ...And don't list identical objects yet, either
- if (obj.identical_to).type = identical_class
- {
- if obj is not hidden
- count++
- }
- elseif player not in obj
- #else
- if player not in obj
- #endif
- {
- if obj is not already_listed and
- obj is not hidden
- {
- ShortDescribe(obj)
- if obj is not already_listed
- notlisted++
- }
- }
- }
- if notlisted or count
- {
- list_count = notlisted + count
- tempformat = FORMAT
- FORMAT = FORMAT | FIRSTCAPITAL_F | ISORAREHERE_F
- Indent
- if SmartParents
- {
- FORMAT = FORMAT | OVERRIDEHERE_F
- if charcount
- {
- FORMAT = FORMAT | ALSO_F
- }
- }
- if FORMAT & LIST_F
- {
- FORMAT = FORMAT & ~LIST_F ! clear it
- FORMAT = FORMAT | TEMPLIST_F
- }
- list_nest = 0
- ListObjects(place)
- FORMAT = tempformat
- }
- #ifclear NO_OBJLIB
- #ifset USE_ATTACHABLES
- for obj in place
- {
- ! Print attachables last
- if obj.type = attachable and obj is not hidden
- {
- ShortDescribe(obj)
- if obj is not already_listed
- Message(&DescribePlace, 2, obj)
- }
- }
- #endif
- print newline
- override_indent = false
- ! Finally, list contents of scenery objects (unless we've
- ! already done so as the parent of the player)
- !
- for obj in place
- {
- if obj.type = scenery
- {
- obj is known
- if player not in obj and
- ! (obj is open or obj is not openable)
- ! ((obj is container and (obj is open or obj is transparent)) or
- ! obj is platform) and obj is not quiet
- (obj is open or obj is not openable or obj is platform or
- obj is transparent) and obj is not quiet
- {
- list_nest = 1
- WhatsIn(obj)
- }
- }
- ! For scenery-derived objects that may change the type
- elseif obj is static, hidden
- obj is known
- }
- #endif ! ifclear NO_OBJLIB
- print newline
- need_newline = false
- }
- }
- routine SmartParents(obj)
- {
- if player not in location and parent(player) is container
- return true
- else
- return false
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement