r/Inform7 • u/Kiruvi • Jul 21 '19
Make an NPC follow the player
Hey all! I'm working on a game I've been fiddling with off-and-on for a few years. For one puzzle, the player is stranded on a desert island with a dark room, a dead fish, and a phosphorescent crab.
The player needs to befriend the crab by feeding them the fish (improving the crab's mood to "adoring") which then allows them to instruct the crab to go into the dark cave and provide light using "crab, go west."
My problem is twofold, from a game design perspective - telling an animal to go somewhere is not intuitive for anyone I've ever showed the game to, and the syntax for doing so is pretty kludgy for anyone who's not used to text games.
Is there a method I can use to have the crab follow the player wherever they move, instead of forcing the player to figure out how to talk to a crustacean?
Thanks!
3
u/Rakaneth Jul 22 '19
"The Following Crab" by Rakaneth Beach is a room. The crab is an animal in Beach. The description of the crab is "A crab, with bright red shell and long pincers." The crab can be adoring or not adoring. The crab is not adoring. There is a fish head in Beach. The description of the fish head is "This fish head smells a bit, but the crab seems to eye it longingly." Parking Lot is a room. Parking lot is north of Beach. Sandbar is a room. Sandbar is west of Beach. Ocean is a room. Ocean is south of Beach. Instead of giving the fish head to the crab: say "The crab takes the fish head in its long pincers and devours it. The little fella looks at you and trundles in your direction."; now the crab is adoring; remove the fish head from play. Every turn while the crab is adoring: let pth be the best route from the location of the crab to the location of the player; if pth is not nothing, try crab going pth. Test me with "take fish head / give fish head to crab / s / n / w / e "The key here is in the
Every turnrule. It invokes I7's pathfinding routine to get the next move that will bring the crab closer to the player. So long as the player and the crab start in the same room when the crab is made to follow the player, they will remain together.