AttemptToTakeObject (lines 1026-1108)
Back to List
Browsing verblibm.h
1026 [ AttemptToTakeObject item ancestor after_recipient i j k;
1027 ! Try to transfer the given item to the player: return false
1028 ! if successful, true if unsuccessful, printing a suitable message
1029 ! in the latter case.
1030
1031 ! People cannot ordinarily be taken.
1032 if (item == player) return L__M(##Take,2);
1033 if (item has animate) return L__M(##Take,3,item);
1034
1035 ancestor = CommonAncestor(player, item);
1036
1037 if (ancestor == 0)
1038 { i = ObjectScopedBySomething(item);
1039 if (i ~= 0) ancestor = CommonAncestor(player, i);
1040 }
1041
1042 ! Are player and item in totally different places?
1043
1044 if (ancestor == 0) return L__M(##Take,8,item);
1045
1046 ! Is the player indirectly inside the item?
1047 if (ancestor == item) return L__M(##Take,4,item);
1048
1049 ! Does the player already directly contain the item?
1050 if (item in player) return L__M(##Take,5,item);
1051
1052 ! Can the player touch the item, or is there (e.g.) a closed container
1053 ! in the way?
1054 if (ObjectIsUntouchable(item,false,true)) return;
1055
1056 ! The item is now known to be accessible.
1057
1058 ! Consult the immediate possessor of the item, if it's in a container
1059 ! which the player is not in.
1060
1061 i=parent(item);
1062 if (i ~= ancestor && (i has container || i has supporter))
1063 { after_recipient=i;
1064 k=action; action=##LetGo;
1065 if (RunRoutines(i,before)~=0) { action=k; rtrue; }
1066 action=k;
1067 }
1068
1069 if (item has scenery) return L__M(##Take,10,item);
1070 if (item has static) return L__M(##Take,11,item);
1071
1072 ! The item is now known to be available for taking. Is the player
1073 ! carrying too much? If so, possibly juggle items into the rucksack
1074 ! to make room.
1075
1076 k=0; objectloop (j in player) if (j hasnt worn) k++;
1077
1078 if (k >= ValueOrRun(player,capacity))
1079 { if (SACK_OBJECT~=0)
1080 { if (parent(SACK_OBJECT)~=player)
1081 return L__M(##Take,12);
1082 j=0;
1083 objectloop (k in player)
1084 if (k~=SACK_OBJECT && k hasnt worn && k hasnt light) j=k;
1085
1086 if (j~=0)
1087 { L__M(##Take,13,j);
1088 keep_silent = 1; <Insert j SACK_OBJECT>; keep_silent = 0;
1089 if (j notin SACK_OBJECT) rtrue;
1090 }
1091 else return L__M(##Take,12);
1092 }
1093 else return L__M(##Take,12);
1094 }
1095
1096 ! Transfer the item.
1097
1098 move item to player;
1099
1100 ! Send "after" message to the object letting go of the item, if any.
1101
1102 if (after_recipient~=0)
1103 { k=action; action=##LetGo;
1104 if (RunRoutines(after_recipient,after)~=0) { action=k; rtrue; }
1105 action=k;
1106 }
1107 rfalse;
1108 ];
Last updated 27 February 2004.
This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation.
Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight.