[ AttemptToTakeObject item ancestor after_recipient i j k; ! Try to transfer the given item to the player: return false ! if successful, true if unsuccessful, printing a suitable message ! in the latter case. ! People cannot ordinarily be taken. if (item == player) return L__M(##Take,2); if (item has animate) return L__M(##Take,3,item); ancestor = CommonAncestor(player, item); if (ancestor == 0) { i = ObjectScopedBySomething(item); if (i ~= 0) ancestor = CommonAncestor(player, i); } ! Are player and item in totally different places? if (ancestor == 0) return L__M(##Take,8,item); ! Is the player indirectly inside the item? if (ancestor == item) return L__M(##Take,4,item); ! Does the player already directly contain the item? if (item in player) return L__M(##Take,5,item); ! Can the player touch the item, or is there (e.g.) a closed container ! in the way? if (ObjectIsUntouchable(item,false,true)) return; ! The item is now known to be accessible. ! Consult the immediate possessor of the item, if it's in a container ! which the player is not in. i=parent(item); if (i ~= ancestor && (i has container || i has supporter)) { after_recipient=i; k=action; action=##LetGo; if (RunRoutines(i,before)~=0) { action=k; rtrue; } action=k; } if (item has scenery) return L__M(##Take,10,item); if (item has static) return L__M(##Take,11,item); ! The item is now known to be available for taking. Is the player ! carrying too much? If so, possibly juggle items into the rucksack ! to make room. k=0; objectloop (j in player) if (j hasnt worn) k++; if (k >= ValueOrRun(player,capacity)) { if (SACK_OBJECT~=0) { if (parent(SACK_OBJECT)~=player) return L__M(##Take,12); j=0; objectloop (k in player) if (k~=SACK_OBJECT && k hasnt worn && k hasnt light) j=k; if (j~=0) { L__M(##Take,13,j); keep_silent = 1; ; keep_silent = 0; if (j notin SACK_OBJECT) rtrue; } else return L__M(##Take,12); } else return L__M(##Take,12); } ! Transfer the item. move item to player; ! Send "after" message to the object letting go of the item, if any. if (after_recipient~=0) { k=action; action=##LetGo; if (RunRoutines(after_recipient,after)~=0) { action=k; rtrue; } action=k; } rfalse; ];