Chapter 10. Interacting with NPC

In a virtual world, there are some characters that are not controlled by the users. These characters are called Non-Player Characters, or NPC in short. Traditionally, NPCs are controlled by the game master in role-playing board games. In virtual a world, the NPCs are controlled by the server or the computers that serve some distinguished purposes. They can range from a house guard to the king in the castle.

In this chapter, we will discuss the purpose of having non-player characters in the virtual world. We will control the NPC to move around the world. We will also let players interact with the NPC by chatting or trading items.

We will also cover an advanced server-side extension technique to use Java extension instead of ActionScript extension to gain performance.

Running virtual world smoothly with NPCs

The main purpose of the non-player character is to help the virtual world run smoothly. The NPCs are like the characters in a novel. The purpose of each character is different and depends on the type of the novel. But the final purpose of the characters are to shape the novel in a smooth way.

The purpose of each NPC in a virtual world is different. A newbie guide will provide basic information to the new players and guide them through some newbie practices. For instance, a guard in front of the castle will stop the players from entering without meeting some requirements; a shopkeeper will provide some trading services to players; some other NPCs may be talkative and provide different background information of the virtual world. Every NPC has its own purpose and their final purpose is to make the players play in the virtual world smoothly.

In some online virtual world, NPC will act as player replacement. Sometimes players want to play in the virtual world without interacting with other players. Let's assume there is a real-time action game that requires four players to start the game. A player can add NPCs as opponents to join the game. An NPC will have its own AI script to run the game.

Classifying different roles of NPC

There are two types of NPC, one is essential to the virtual world and the other is non-essential.

Those essential NPCs are important to the virtual world and carry specific purposes. For instance, the shopkeeper that sells items, the guides that help players, or the enemies that interact with players.

Besides those essential NPCs, there are often other NPCs in the virtual world. The virtual world can run smoothly without these non-essential NPCs. The role of these NPCs is to enhance the game experience or to provide some sidetrack background information.

For example, when the player walks into a restaurant, the main NPC is the cashier to whom the player needs to place the order. This NPC is important because players need the food to recharge their energy or finish quests. Besides the cashier, there may also be waiters and other clients. The waiters may say welcome to the player and different clients may share their thoughts on the food. Some may say that the food is delicious while some may be drunk and may be saying something funny. These NPCs give players a feeling as if they have actually walked into a real restaurant. Without these waiters and clients, the player can still buy foods and refill his energy. But the existence of these non-essential NPCs enhance the player's experience.

Assume there is a virtual world where players need to rescue the princess. Players need to chat with those major NPCs to get hints on where the princess is locked. Besides this major story of the virtual world, there are some sidetrack challenges that the players can complete as a bonus. Those non-essential NPCs can reveal the information or hints about these non-critical challenges.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.144.217