Import v6.12.5 of the Inform 6 standard library
[informlib.git] / verblib.h
index c5e73a896628f778739d88604838a7c9ed0bdd9b..ff27fab0464743e898503fd7e845ca204e2f8fcc 100644 (file)
--- a/verblib.h
+++ b/verblib.h
@@ -1,9 +1,9 @@
 ! ==============================================================================
 !   VERBLIB:  Front end to standard verbs library.
 !
-!   Supplied for use with Inform 6 -- Release 6.12.4 -- Serial number 200718
+!   Supplied for use with Inform 6 -- Release 6.12.5 -- Serial number 210605
 !
-!   Copyright Graham Nelson 1993-2004 and David Griffith 2012-2020
+!   Copyright Graham Nelson 1993-2004 and David Griffith 2012-2021
 !
 !   This file is free software: you can redistribute it and/or modify
 !   it under the terms of the GNU Affero General Public License as
@@ -17,7 +17,7 @@
 !
 !   You should have received a copy of the GNU Affero General Public
 !   License along with this program. If not, see
-!   https://gnu.org/licenses/
+!   https://gnu.org/licenses/.
 !
 !   In your game file, Include three library files in this order:
 !       Include "parser";
@@ -1678,8 +1678,8 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
         action = k;
     }
 
-    if (item has scenery) return L__M(##Take, 10, item);
     if (item has static)  return L__M(##Take, 11, item);
+    if (item has scenery) return L__M(##Take, 10, 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
@@ -1770,8 +1770,8 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
     ks = keep_silent; keep_silent = 2; AttemptToTakeObject(obj); keep_silent = ks;
     if (obj notin actor) rtrue;
     if (res == 0 && ~~keep_silent)
-        if (supcon) L__M(##Miscellany, 58, obj, supcon);
-        else        L__M(##Miscellany, 26, obj);
+        if (supcon) return L__M(##Miscellany, 58, obj, supcon);
+        else        return L__M(##Miscellany, 26, obj);
     rfalse;
 ];
 
@@ -1851,6 +1851,7 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
 ! ----------------------------------------------------------------------------
 
 [ TakeSub;
+    if (noun in actor && noun has worn) <<Disrobe noun, actor>>;
     if (onotheld_mode == 0 || noun notin actor)
         if (AttemptToTakeObject(noun)) return;
     if (AfterRoutines()) return;
@@ -1862,11 +1863,19 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
 [ RemoveSub i;
     i = parent(noun);
     if (i && i has container && i hasnt open && ImplicitOpen(i)) return L__M(##Remove, 1, i);
-    if (i ~= second)   return L__M(##Remove, 2, noun);
+    if (noun has clothing) {
+       if (noun has worn) <<Disrobe noun, actor>>;
+       if (i && i has container or supporter)
+           jump RSSkip;
+       else
+           if (i == actor) return L__M(##Disrobe, 1, noun);
+    }
+    if (i hasnt container && i hasnt supporter) return L__M(##Remove, 4, noun);
+    if (i ~= second && second ~= nothing) return L__M(##Remove, 2, noun);
     if (i has animate) return L__M(##Take, 6, i, noun);
 
+    .RSSkip;
     if (AttemptToTakeObject(noun)) rtrue;
-
     action = ##Remove; if (AfterRoutines()) return;
     action = ##Take;   if (AfterRoutines()) return;
     if (keep_silent) return;
@@ -1876,9 +1885,13 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
 [ DropSub;
     if (noun == actor)         return L__M(##PutOn, 4, noun);
     if (noun in parent(actor)) return L__M(##Drop, 1, noun);
-    if (noun notin actor && ~~ImplicitTake(noun)) return L__M(##Drop, 2, noun);
     if (noun has worn && no_implicit_actions) return L__M(##Disrobe, 4, noun);
     if (noun has worn && ImplicitDisrobe(noun)) return;
+    if (noun notin actor) {
+       if (no_implicit_actions) return L__M(##Drop, 4, noun, parent(noun));
+       L__M(##Miscellany, 58, noun, parent(noun));
+    }
+
     move noun to parent(actor);
     if (AfterRoutines() || keep_silent) return;
     L__M(##Drop, 3, noun);
@@ -1888,7 +1901,7 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
     receive_action = ##PutOn;
     if (second == d_obj || actor in second) <<Drop noun, actor>>;
     if (parent(noun) == second) return L__M(##Drop, 1, noun);
-    if (noun notin actor && ImplicitTake(noun)) return L__M(##PutOn, 1, noun);
+    if (ImplicitTake(noun) && noun notin actor) return L__M(##PutOn, 1, noun);
 
     ancestor = CommonAncestor(noun, second);
     if (ancestor == noun) return L__M(##PutOn, 2, noun);
@@ -1900,7 +1913,8 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
         action = ##PutOn;
     }
     if (second hasnt supporter) return L__M(##PutOn, 3, second);
-    if (ancestor == actor)      return L__M(##PutOn, 4, second);
+
+    if (noun has worn && no_implicit_actions) return L__M(##Disrobe, 4, noun);
     if (noun has worn && ImplicitDisrobe(noun)) return;
 
     if (ObjectDoesNotFit(noun, second) ||
@@ -1925,7 +1939,7 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
     receive_action = ##Insert;
     if (second == d_obj || actor in second) <<Drop noun, actor>>;
     if (parent(noun) == second) return L__M(##Drop, 1, noun);
-    if (noun notin actor && ImplicitTake(noun)) return L__M(##Insert, 1, noun);
+    if (ImplicitTake(noun) && noun notin actor) return L__M(##Insert, 1, noun);
     ancestor = CommonAncestor(noun, second);
     if (ancestor == noun) return L__M(##Insert, 5, noun);
     if (ObjectIsUntouchable(second)) return;
@@ -1937,6 +1951,7 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
             return L__M(##Insert, 3, second);
     }
     if (second hasnt container) return L__M(##Insert, 2, second);
+    if (noun has worn && no_implicit_actions) return L__M(##Disrobe, 4, noun);
     if (noun has worn && ImplicitDisrobe(noun)) return;
 
     if (ObjectDoesNotFit(noun, second) ||
@@ -2519,7 +2534,10 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
     if (ObjectIsUntouchable(noun)) return;
     if (noun hasnt lockable)     return L__M(##Unlock, 1, noun);
     if (noun hasnt locked)       return L__M(##Unlock, 2, noun);
-    if (noun.with_key ~= second) return L__M(##Unlock, 3, second);
+    if ((noun.with_key ofclass Object && noun.with_key ~= second) ||
+               (noun.with_key ofclass Routine && noun.with_key() ~= second) ||
+                noun.with_key == nothing)
+               return L__M(##Unlock, 3, second);
 
     give noun ~locked;
 
@@ -2532,7 +2550,10 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
     if (noun hasnt lockable) return L__M(##Lock, 1, noun);
     if (noun has locked)     return L__M(##Lock, 2 ,noun);
     if (noun has open && ImplicitClose(noun)) return L__M(##Lock, 3, noun);
-    if (noun.with_key ~= second) return L__M(##Lock, 4, second);
+    if ((noun.with_key ofclass Object && noun.with_key ~= second) ||
+               (noun.with_key ofclass Routine && noun.with_key() ~= second) ||
+                noun.with_key == nothing)
+               return L__M(##Lock, 4, second);
 
     give noun locked;
     if (AfterRoutines() || keep_silent) return;
@@ -2590,7 +2611,8 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
 
 [ DisrobeSub;
     if (ObjectIsUntouchable(noun)) return;
-    if (noun hasnt worn) return L__M(##Disrobe, 1, noun);
+    if (noun hasnt clothing) return L__M(##Disrobe,1, noun);
+    if (noun hasnt worn && noun has clothing) return L__M(##Disrobe, 1, noun);
 
     give noun ~worn;
     if (AfterRoutines() || keep_silent) return;
@@ -2600,7 +2622,15 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
 [ WearSub;
     if (ObjectIsUntouchable(noun)) return;
     if (noun hasnt clothing)    return L__M(##Wear, 1, noun);
-    if (noun notin actor && ImplicitTake(noun)) return L__M(##Wear, 2, noun);
+
+    if (noun notin actor && noun hasnt worn) {
+       if (IndirectlyContains(actor, noun) || parent(noun) has container or supporter) {
+           if (no_implicit_actions) return L__M(##Wear, 5, noun, parent(noun));
+           L__M(##Miscellany, 58, noun, parent(noun));
+           AttemptToTakeObject(noun);
+       } else
+           return L__M(##Wear, 2, noun, parent(noun));
+    }
     if (noun has worn)          return L__M(##Wear, 3, noun);
 
     give noun worn;
@@ -2840,7 +2870,7 @@ Constant ID_BIT        $2000;       ! Print object id after each entry
 [ WaveSub;
     if (noun == player) return L__M(##Wave, 2 ,noun, second);
     if (noun == actor) return L__M(##Wave, 3, noun, second);
-    if (noun notin actor && ImplicitTake(noun)) return L__M(##Wave, 1, noun);
+    if (ImplicitTake(noun) && noun notin actor) return L__M(##Wave, 1, noun);
     L__M(##Wave, 2, noun, second);
 ];