Patrollers

version 12 by Michael Callaghan

  • Home page
  • Beginning
  • Previous
  • Next



  • Section 3.2 - Before rules for the patrolling activity
    Before Patrolling something (called the Bod) (this is the set current room for patrollers rule):
        if the Bod is a Patroller:
            now RouteAvailable is true;
            now the CurrentRoom is the location of the Bod.
    Before Patrolling something (called the Bod) (this is the set room-led patrollers rule):
        if the Bod is a RoomLed Patroller:
            [Find the correct row in the Patroller's room table.]
            choose row PathStage of the Bod in the RoomTable of the Bod;
            [Set the NextRoom from the room table.]
            now the NextRoom is the TargetRoom entry;
            [Calculate the route to the next room.]
            let tempWay be the best route from the CurrentRoom to the NextRoom, using even locked doors;
            if tempWay is nothing:
                now RouteAvailable is false;
            otherwise:
                now the Way is tempWay.
    Before Patrolling something (called the Bod) (this is the set direction-led patrollers rule):
        if the Bod is a DirectionLed Patroller:
            [Find the correct row in the Patroller's direction table.]
            choose row PathStage of the Bod in the DirectionTable of the Bod;
            [Set the direction if the Patroller is Outward Bound.]
            if the Bod is OutwardBound:
                now the Way is the TargetDirection entry;
            [Set the opposite direction if the Patroller in InwardBound.]
            if the Bod is InwardBound:
                now the Way is the opposite of the TargetDirection entry.
    Before Patrolling something (called the Bod) (this is the set aimless patrollers rule):
        if the Bod is an Aimless Patroller:
            [Create a list to hold adjoining rooms. We do this as a room on the other side of a door is not captured by the adjacent rooms command.]
            let RoomList be a list of objects;
            [Test each direction from the current room.]
            repeat with TestWay running through directions:
                [Look for rooms or doors]
                let NewPlace be the room-or-door the TestWay from the CurrentRoom;
                [if there is a room, add it to the room list.]
                if NewPlace is a room:
                    unless NewPlace is off-limits to the Bod:
                        add NewPlace to the RoomList;
                [if there is a door, add the other side of the door to the list.]
                if NewPlace is a door:
                    unless the other side of NewPlace is off-limits to the Bod:
                        add the other side of NewPlace to the RoomList;
            if the number of entries in RoomList is greater than 0:
                [Choose a random room from the list.]
                let Counter be a random number between 1 and the number of entries in RoomList;
                now NextRoom is entry Counter of RoomList;
            otherwise:
                [if there are no exits, setting the Next Room as the current room will ensure that Way is returned as nothing.]
                now NextRoom is the CurrentRoom;
            [Set the new direction to the way to the room.]
            let tempWay be the best route from the CurrentRoom to the NextRoom, using even locked doors;
            if tempWay is nothing:
                now RouteAvailable is false;
            otherwise:
                now the Way is tempWay.
    Before Patrolling something (called the Bod) (this is the set following patrollers rule):
        if the Bod is Following Patroller:
            let tempWay be the best route from the CurrentRoom to the location of the player, using even locked doors;
            if tempWay is nothing:
                now RouteAvailable is false;
            otherwise:
                now the Way is tempWay.
    Before Patrolling something (called the Bod) (this is the set targeted patrollers rule):
        if the Bod is Targeted Patroller:
            let tempWay be the best route from the CurrentRoom to the Destination of the Bod, using even locked doors;
            if tempWay is nothing:
                now RouteAvailable is false;
            otherwise:
                now the Way is tempWay.
    Before Patrolling something (called the Bod) (this is the test obstacles for patrollers rule):
        if the Bod is a Patroller and RouteAvailable is true:
            let Target be the room-or-door the Way from the CurrentRoom;
            if the Target is a door:
                now Obstacle is the Target;
                if the Obstacle is locked:
                    now ObstacleLocked is true;
                otherwise:
                    now ObstacleLocked is false;
                if the Obstacle is closed:
                    now ObstacleClosed is true;
                otherwise:
                    now ObstacleClosed is false;
                now NextRoom is the other side of the Target from the CurrentRoom;
            otherwise:
                now NextRoom is the Target.
    Before Patrolling something (called the Bod) (this is the try opening doors for patrollers rule):
        if the Bod is a Patroller:
            if the Obstacle is an openable closed door:
                if the Obstacle is locked and the Obstacle is lockable:
                    if the OpeningCapability of the Bod is Universal:
                        now the Obstacle is open;
                        now the Obstacle is unlocked;
                        if the CurrentRoom is the location of the player and Reporting is Individual:
                            say "[The Bod] [unlock] and [open] [the obstacle]." (A);
                        if the NextRoom is the location of the player and Reporting is Individual:
                            say "[We] [hear] the sound of someone unlocking and opening [the Obstacle]." (B);
                    if the OpeningCapability of the Bod is WithKey:
                        if the Bod encloses the matching key of the Obstacle:
                            now the Obstacle is open;
                            now the Obstacle is unlocked;
                            if the CurrentRoom is the location of the player and Reporting is Individual:
                                say "[text of try opening doors for patrollers rule response (A)]";
                            if the NextRoom is the location of the player and Reporting is Individual:
                                say "[text of try opening doors for patrollers rule response (B)]";
                otherwise if the Obstacle is unlocked:
                    if the OpeningCapability of the Bod is not None:
                        now the Obstacle is open;
                        if the CurrentRoom is the location of the player and Reporting is Individual:
                            say "[The Bod] [open] [the obstacle]." (C);
                        if the NextRoom is the location of the player and Reporting is Individual:
                            say "[We] [hear] the sound of someone opening [the Obstacle]." (D).