Update to serial 210605
[snowed-in.git] / src / snowed-in.inf
index ebe3aca6e6a020c78f9198d245d35379509efefb..98bf07ed51183fc0b4bfa17abe0f56cd826d370c 100644 (file)
@@ -12,6 +12,9 @@
 !
 ! You should have received a copy of the GNU Affero General Public
 ! License along with this file. If not, see https://gnu.org/licenses/
+Global lantern_fuel_left = 20;
+Global body_temperature = 20;
+Global cabin_has_electricity = 1;
 Constant DEATH_MENTION_UNDO;
 Constant Story "Snowed In";
 Constant Headline 
@@ -20,7 +23,7 @@ Constant Headline
     ^Ongoing development: https://jxself.org/git/?p=snowed-in.git
     ^Send bugs and feedback by email to j@@64jxself.org.
     ^IFID DE9FA2E5-4EC7-4166-9218-E56EFA1DF40F
-    ^Copyright (C) 2021 Jason Self
+    ^Copyright (C) 2021 Jason Self <j@@64jxself.org>
     ^You can change and share this game under the terms of the GNU 
     Affero General Public License as published by the Free Software 
     Foundation (FSF), either version 3 of the License, or (at your 
@@ -32,7 +35,9 @@ Constant Headline
 Include "parser";
 Include "verblib";
 Release 0;
-Serial "210401";
+Serial "210605";
+
+Include "src/forest.inf";
 
 Object  mainroom "Main Room"
   with  description 
@@ -40,13 +45,50 @@ Object  mainroom "Main Room"
             happened in here. There's a ripped up sofa and a broken 
             old coffee table in the middle of the room. A flat-screen 
             TV is mounted against the wall, with the screen dangling 
-            out. Tis cabin has three other rooms. There's an office 
-            area with a desk and computer to the east. There's a 
-            bedroom to the north and a kitchenette to the west. 
-            There's a doorway in the south wall leading outside.",
+            out. This cabin has three other rooms. There's an office 
+            area to the east, and a bedroom to the north. A 
+            kitchenette can be found to the west. There's a doorway 
+            in the south wall leading outside.",
+        n_to bedroom,
+        s_to frontdoor,
         e_to office,
+        w_to kitchenette,
   has   light;
 
+Object  frontdoor "front door" mainroom
+  with  name 'door' 'front',
+        description 
+            "The wooden door is made of thick oak wood with the shape 
+            of a bear claw engraved in it.",
+        short_name [;
+            if (location == mainroom)
+                print "door to the outside";
+            else
+                print "door to the cabin";
+            return true;
+        ],
+        found_in mainroom southofcabin,
+        door_dir [;
+            if (location == mainroom)
+                return s_to;
+            else
+                return n_to;
+        ],
+        door_to [;
+            if (location == mainroom)
+                return southofcabin;
+            else
+                return mainroom;
+        ],
+  has   scenery door openable;
+
+Object  bearclaw "bear claw" mainroom
+  with  name 'bear' 'claw',
+  with  description 
+            "It's in the shape of a thin, sharp claw with three jagged 
+            points at the top of it.",
+  has   scenery;
+
 Object  sofa "sofa" mainroom
   with  name 'sofa' 'couch',
   with  description 
@@ -61,8 +103,8 @@ Object  sofa "sofa" mainroom
 Object  coffeetable "coffee table" mainroom
   with  name 'coffee' 'table',
   with  description 
-            "The old coffee table looks as if it's had quite a bit 
-            of use. There are burn marks covering it and the paint is 
+            "The old coffee table looks as if it's had quite a bit of 
+            use. There are burn marks covering it and the paint is 
             worn off in most places.",
         before [;
           Take, Pull, Push, PushDir, Turn:
@@ -70,11 +112,56 @@ Object  coffeetable "coffee table" mainroom
         ],
   has   scenery supporter enterable;
 
+Object  lantern "copper lantern" coffeetable
+  with  name 'lantern' 'copper' 'lamp',
+        description 
+            "This is an exceptionally beautiful lantern. About eleven 
+            inches high, with a base of about 5 inches or so in 
+            diameter and a large, brass-closed hook at the top. A 
+            rainbow of unique colors run through the copper. The 
+            glass in the lamp has a fresnel type of design, which is 
+            used to distribute light widely.",
+        time_left,
+        time_out [;
+            if (lantern has on) {
+                lantern_fuel_left = 0;
+                give lantern ~on;
+                give lantern ~light;
+                StopDaemon(lantern);
+                print_ret 
+                    "Suddenly, the lantern's flame begins to flicker 
+                    violently within its glass prison and then 
+                    extinguishes itself.";
+            }
+        ],
+        before [;
+          SwitchOn:
+            if (lantern_fuel_left > 0) {
+                give lantern light;
+                StartTimer(lantern, lantern_fuel_left);
+            }
+            else {
+                print_ret 
+                    "You snap the switch a few times, but nothing 
+                    happens.";
+            }
+          SwitchOff:
+            StopTimer(lantern);
+            give lantern ~light;
+        ],
+        daemon [;
+            if (lantern has on)
+                lantern_fuel_left = lantern.time_left;
+            if (lantern has on && lantern_fuel_left <= 5)
+                print_ret "The lantern's fuel runs low.";
+        ],
+  has   switchable;
+
 Object  television "flat-screen TV" mainroom
   with  name 'TV' 'television' 'flat' 'screen' 'flat-screen',
   with  description 
-            "The flat-screen TV looks fairly modern but it's 
-            been broken in a fight and the screen is dangling out.",
+             "The flat-screen TV looks fairly modern but it's been 
+             broken in a fight and the screen is dangling out.",
         before [;
           Take, Pull, Push, PushDir, Turn:
             print_ret (The) self, " is firmly mounted to the wall.";
@@ -99,7 +186,7 @@ Object  television "flat-screen TV" mainroom
   has   scenery switchable;
 
 Object  lightsocket "light socket" mainroom
-  with  name 'light' 'socket' 'lightsocket',
+  with  name 'socket' 'lightsocket',
         before [;
           Take, Pull, Push, PushDir, Turn:
             print_ret 
@@ -110,24 +197,54 @@ Object  lightsocket "light socket" mainroom
                 print "Put ";
                 print (a) noun;
                 print_ret 
-                    " into the light socket? Maybe you should come with a
-                    warning label because you contain more than a trace
-                    amount of nut.";
+                    " into the light socket? Maybe you should come 
+                    with a warning label because you contain more than 
+                    a trace amount of nut.";
             }
-            if (noun == lightbulb) {
+            if (noun == lightbulb && light has on) {
                 give mainroom light;
                 give office light;
+                give kitchenette light;
+                give bedroom light;
+                give eastofcabin light;
             }
         ],
   has   scenery container transparent open;
 
 Object  lightbulb "light bulb" lightsocket
   with  name 'light' 'bulb' 'lightbulb',
+        before [;
+          SwitchOn:
+            if (lightbulb in lightsocket) {
+                if (cabin_has_electricity == 1) {
+                    give mainroom light;
+                    give office light;
+                    give kitchenette light;
+                    give bedroom light;
+                    give eastofcabin light;
+                }
+                else {
+                    print_ret 
+                        "You flip the switch a few times, but nothing 
+                        happens.";
+                }
+            }
+            else {
+                print_ret 
+                    "Turn on a lightbulb when it's not in the 
+                    socket? What a strange idea.";
+            }
+        ],
         after [;
-          Take, Pull, Push, PushDir, Turn:
+          Take, Pull, Push, PushDir, Turn, SwitchOff:
+            give lightbulb ~on;
             give mainroom ~light;
             give office ~light;
-        ];
+            give kitchenette ~light;
+            give bedroom ~light;
+            give eastofcabin ~light;
+        ],
+  has   switchable on;
 
 Object  office "Office"
   with  description 
@@ -137,6 +254,7 @@ Object  office "Office"
             drywall and insulation cover the floor. The desk has a 
             bullet hole through the middle.",
         w_to mainroom,
+        e_to window,
   has   light;
 
 Object  desk "solid oak desk" office
@@ -204,6 +322,281 @@ Object  computer "computer" desk
         ],
   has   switchable;
 
+Object  drywall "drywall" office
+  with  name 'drywall' 'dry' 'wall',
+        before [;
+          Take, Pull, Push, PushDir, Turn:
+            print_ret "Taking that would achieve little.";
+        ],
+  has   scenery;
+
+Object  insulation "insulation" office
+  with  name 'insulation',
+        before [;
+          Take, Pull, Push, PushDir, Turn:
+            print_ret "Taking that would achieve little.";
+        ],
+  has   scenery;
+
+Object  bullethole "bullet hole" desk
+  with  name 'bullet' 'hole' 'holes',
+  with  description 
+            "Looks to have come from something that's capable of 
+            doing a lot of damage.",
+        found_in desk bedroom,
+  has   scenery;
+
+Object  window "window" office
+  with  name 'window' 'windows',
+        description 
+            "The window faces the east side of the cabin. It's broken, 
+            letting in the cold air from outside.",
+        short_name [;
+            if (location == office)
+                print "window";
+            else
+                print "window into the cabin";
+            return true;
+        ],
+        found_in office eastofcabin,
+        door_dir [;
+            if (location == office)
+                return e_to;
+            else
+                return w_to;
+        ],
+        door_to [;
+            if (location == office)
+                return eastofcabin;
+            else
+                return office;
+        ],
+        before [;
+          Search:
+            print_ret "The window faces the east side of the cabin.";
+          Open, Close:
+            print_ret 
+                "The window's broken so it's not clear how 
+                you'd do that.";
+        ],
+  has   scenery door openable open;
+
+Object  kitchenette "Kitchenette"
+  with  description 
+            "The kitchenette is empty. A sink, you think, though it's 
+            hard to tell what's a pipe and what's a faucet. A 
+            refrigerator, standing open and empty. The door has been 
+            ripped off. There's no indication as to where it 
+            went. There's no food anywhere in here.",
+        e_to mainroom,
+  has   light;
+
+Object  refrigerator "refrigerator" kitchenette
+  with  name 'fridge' 'refrigerator',
+  with  description 
+            "An old rusty refrigerator, standing open and empty. The 
+            door has been ripped off. There's no indication as to 
+            where it went.",
+        before [;
+          Take, Pull, Push, PushDir, Turn:
+            print_ret (The) self, " is too heavy for that.";
+          Open, Close:
+            print_ret (The) self, " door is missing.";
+        ],
+  has   scenery enterable container openable open;
+
+Object  sink "sink" kitchenette
+  with  name 'sink' 'pipe' 'faucet',
+  with  description 
+            "A sink, you think, though it's hard to tell what's a 
+            pipe and what's a faucet.",
+        after [;
+          SwitchOn:
+            print_ret 
+                "Pipes from in the walls make a groaning sound, 
+                almost like pain and despair. No water comes out.";
+        ],
+  has   scenery container switchable;
+
+Object  bedroom "Bedroom"
+  with  description 
+            "This bedroom is small and cramped, and looks like a 
+            major fight happened as the exterior wall has bullet 
+            holes. The bed is lying on the floor, torn to shreds. It 
+            has no sheets, just a bare mattress.",
+        s_to mainroom,
+  has   light;
+
+Object  bed "bed" bedroom
+  with  name 'bed' 'mattress',
+  with  description "The mattress is bare and empty.",
+        before [;
+          Take, Pull, Push, PushDir, Turn:
+            print_ret (The) self, " is too heavy for that.";
+        ],
+  has   scenery supporter;
+
+Object  suitcase "suitcase" bedroom
+  with  name 'suitcase',
+  with  description 
+            "The suitcase is made of a light metallic material that 
+            you can't quite make out. The color of it is somewhere 
+            between silver and grey.",
+  has   container open openable;
+
+Object  snowsuit "snowsuit" suitcase
+  with  name 'snowsuit' 'snow' 'suit',
+  with  description 
+            "The snowsuit is blue, decorated with white and purple 
+            designs. On the chest is a large emblem with the letters 
+            ~CE~ in purple.",
+        before [;
+          Wear:
+            if (snowshoes in player && snowshoes has worn) {
+                print_ret "The snowsuit can't fit over the snowshoes.";
+            }
+          Disrobe, Remove:
+            if (snowshoes in player && snowshoes has worn) {
+                print_ret "The snowsuit can't be taken off over the snowshoes.";
+            }
+        ],
+        daemon [;
+            if (location ~= mainroom && location ~= office && location ~=
+            kitchenette && location ~= bedroom && location ~= thedark &&
+            snowsuit hasnt worn) {
+                body_temperature = --body_temperature;
+            }
+            if (location == mainroom || location == office || location ==
+            kitchenette || location == bedroom || location ~= thedark ||
+            snowsuit has worn && body_temperature < 20) {
+                body_temperature = ++body_temperature;
+            }
+            if (body_temperature == 0) {
+                deadflag = 4;
+            }
+            if (body_temperature <= 5)
+                print_ret 
+                    "You're shivering uncontrollably, and it's hard 
+                    to move. You feel very exhausted and drowsy. It's 
+                    all you can do to keep from falling over.";
+            if (body_temperature > 5 && location ~= mainroom && location
+            ~= office && location ~= kitchenette && location ~= bedroom
+            && location ~= thedark && snowsuit hasnt worn) {
+                switch (body_temperature) {
+                  19:
+                    "The feeling of cold overwhelms you. Surely the cold will get to 
+                    you before anything else does. Right?";
+                  18:
+                    "You can feel yourself getting colder and colder.";
+                  17:
+                    "You can see your own breath freezing in the air, forming little 
+                    clouds.";
+                  16:
+                    "You shiver in the cold.";
+                  15:
+                    "You continue to shiver in the cold.";
+                  14:
+                    "Your hands grow numb from the cold.";
+                  13:
+                    "You continue shivering in order to keep warm.";
+                  12:
+                    "Your shivering grows worse as your body becomes colder by the
+                    minute.";
+                  11:
+                    "Your teeth begin to chatter as you desperately try to warm 
+                    yourself up.";
+                  10:
+                    "Your shivering intensifies as your body begins to freeze over 
+                    from the cold.";
+                  9:
+                    "Your fingers become stiff and you feel sharp pains all over your
+                    body.";
+                  8:
+                    "The cold has gotten to a point where it is too much for you. You 
+                    begin to shiver uncontrollably.";
+                  7:
+                    "Your eyesight begins to fade and you can't even feel yourself 
+                    shivering anymore.";
+                  6:
+                    "You can feel your body shutting down from the cold as you slowly 
+                    begin to lose consciousness.";
+                }
+            }
+        ],
+  has   clothing;
+
+Object  snowshoes "snowshoes" bedroom
+  with  name 'snowshoe' 'snowshoes' 'snow' 'boot' 'boots' 'shoe' 'shoes'
+        'metal' 'frame',
+  with  description 
+            "They're light blue in color and have a thick, hard 
+            rubber bottom that's attached to a metal frame that keeps 
+            you from sinking into the snow. They look to be warm and 
+            comfortable.",
+        after [;
+          Wear:
+            print_ret (The) self, 
+                " fit perfectly and go up to your 
+                knees.";
+        ],
+        daemon [;
+            if (location ~= mainroom && location ~= office && location ~=
+            kitchenette && location ~= bedroom && location ~= thedark &&
+            snowshoes hasnt worn) {
+                deadflag = 3;
+            }
+        ],
+  has   pluralname clothing;
+
+Forest  southofcabin "South Of Cabin"
+  with  description [;
+            print "The wind is howling, and there's snow flying everywhere.";
+            if (snowsuit hasnt worn)
+                print 
+                    " It's really cold and 
+                    you're not dressed for this weather.";
+            print 
+                " The snow stings your face and you 
+                can barely see three feet in front of you.^";
+        ],
+        n_to frontdoor,
+        e_to eastofcabin,
+        w_to westofcabin,
+  has   light;
+
+Forest  eastofcabin "East Of Cabin"
+  with  description [;
+            print "It's dark outside. ";
+            if (lightbulb has on) {
+                print 
+                    "The light from inside the cabin only penetrates 
+                    a few feet from the building. ";
+            }
+            else
+                if (lantern in player && lantern has on) {
+                    print 
+                        "The lantern provides the only source of 
+                        light. ";
+                }
+            if (snowshoes in player && snowshoes has worn) {
+                print 
+                    "The snowshoes are doing their job by making sure 
+                    you don't sink into the snow.^";
+            }
+        ],
+        w_to window,
+        s_to southofcabin,
+  has   light;
+
+Forest  westofcabin "Westh Of Cabin"
+  with  description
+            "The snow is falling so fast that you can barely see 
+            anything. You can't even be sure you're going in the right 
+            direction.",
+        s_to southofcabin,
+  has   light;
+
+
 [ Initialise;
     Location = mainroom;
     thedark.description = 
@@ -219,11 +612,39 @@ Object  computer "computer" desk
         the town. You finally manage to find an old cabin in the 
         woods and get inside but have no idea where you are. You're 
         not dressed for this weather.^";
+    StartDaemon(lantern);
+    StartDaemon(snowshoes);
+    StartDaemon(snowsuit);
+    StartDaemon(grue);
+];
+
+[ DeathMessage;
+    if (deadflag == 3)
+        print "You sink into the deep snow and are unable to move.";
+    if (deadflag == 4)
+        print 
+            "Finally, you succumb to the cold. Your mind goes blank as 
+            you slip away into the endless darkness and the deep sleep 
+            of death.";
+];
+
+! Don't have 'take all' take the lightbulb in the mainroom of the 
+! cabin
+
+[ ChooseObjects obj code;
+    if (code < 2) {
+        if (obj has scenery)
+            return 2;
+        rfalse;
+    }
+    if (obj == lightbulb)
+        return 0;
 ];
 
 [ InScope;
     if (location == thedark && real_location == mainroom) {
         PlaceInScope(lightsocket);
+        PlaceInScope(lightbulb);
     }
     return false;
 ];
@@ -231,26 +652,65 @@ Object  computer "computer" desk
 Object  grue "grue" thedark
   with  article "the",
         name 'grue' 'monster',
-        each_turn [;
-            StartDaemon(self);
-        ],
-        turns_active,
+        grue_active_around_cabin,
+        grue_active_in_the_dark,
         daemon [;
-            if (location ~= thedark) {
-                self.turns_active = 0;
-                StopDaemon(self);
-                rtrue;
+            if (location == thedark) {
+                switch (++(self.grue_active_in_the_dark)) {
+                  1:
+                    "^You hear horrible gurgling sounds in the dark.";
+                  2:
+                    "^You hear the clink of razor-sharp claws nearby.";
+                  3:
+                    deadflag = 1;
+                    "^Your last memory is of the slavering fangs of the 
+                    horrible Grue as it claims you for a meal.";
+                }
             }
-            switch (++(self.turns_active)) {
-              1:
-                "^You hear horrible gurgling sounds in the dark.";
-              2:
-                "^You hear the clink of razor-sharp claws nearby.";
-              3:
-                deadflag = true;
-                "^Your last memory is of the slavering fangs of the 
-                horrible Grue as it claims you for a meal.";
+            if (location == mainroom || location == office || location ==
+            kitchenette || location == bedroom) {
+                switch (++(self.grue_active_around_cabin)) {
+                  1:
+                    "^You hear the wind howling outside, if it is the wind.";
+                  2:
+                    "^You hear horrible gurgling sounds outside.";
+                  3:
+                    "^The noise outside gets louder.";
+                  4:
+                    "^You hear the sound of shuffling feet outside.";
+                  5:
+                    "^You hear something sniffing around the cabin.";
+                  6:
+                    "^You hear a deep guttural sound from outside that sends a chill down your spine.";
+                  7:
+                    "^You hear something scratching on the cabin walls from outside.";
+                  8:
+                    "^You hear something howl outside. It's a chilling, mournful wail that sends a chill down your spine.";
+                  9:
+                    "^A thunderous CRACK can be heard coming from outside.";
+                  10:
+                    "^There's a sudden crashing sound as something is thrown against the cabin walls.";
+                  11:
+                    "^Something begins to beat against the walls of the cabin, as if trying to to break in. It makes a loud, thunderous noise.";
+                  12:
+                    "^The wind is howling and the walls are being beaten so hard it feels like the cabin is shaking.";
+                  13:
+                    "^Suddenly, there's ominous silence from outside the cabin.";
+                }
             }
+            if (location == mainroom || location == office || location ==
+            kitchenette || location == bedroom && self.grue_active_around_cabin
+            == 15) {
+                print "^The lights flicker and suddenly go out.";
+                cabin_has_electricity = 0;
+                give lightbulb ~on;
+                give mainroom ~light;
+                give office ~light;
+                give kitchenette ~light;
+                give bedroom ~light;
+                give eastofcabin ~light;
+            }
+            return true;
         ],
   has   scenery;
 
@@ -294,4 +754,19 @@ Verb 'Hint'
     * -> Help;
 
 Verb 'xyzzy'
-    * -> Xyzzy;
\ No newline at end of file
+    * -> Xyzzy;
+
+Verb 'crawl'
+    * 'through' / 'out' / 'via' noun -> Go;
+
+Verb 'escape'
+    * 'through' / 'out' / 'via' noun -> Go;
+
+Extend 'jump'
+    * 'through' / 'out' / 'via' noun -> Go;
+
+Extend 'climb'
+    * 'through' / 'out' / 'via' noun -> Go;
+
+Extend 'go'
+    * 'through' / 'out' / 'via' noun -> Go;
\ No newline at end of file