Creating a Faction Plug-in

From Multiverse

Jump to: navigation, search
Contributed by: Slinky Last Tested: 12 Jan 08 Tested By: Brianinfairoaks Tested With: 1.1

This tutorial is based on code and resources created by the UT Dallas Student Game Developers' Association. It begins with a brief description of the design, and moves through the implementation of the system.

Overview

This multi-part tutorial will describe how to create a dynamic NPC faction system. In this system, mobs or non-player characters (NPCs) belong to factions (similar to allied groups or teams). An NPC has an opinion of player characters and other NPCs that depends in part on the relationship between their respective factions. The NPC will then take action based on its opinion of nearby characters. For example: quests may only be available for valued allies, hated PCs may be killed on sight by city guards, and NPCs from warring towns may fight if they cross each others' path.

Note as of version 1.0 some of this code still needs fixing

Design

Conceptually, the faction system is very simple: NPCs' opinions of other characters are expressed as a number between 5000 and -5000. Every NPC has a faction. Every faction has a list of players and its opinion of the player. Factions also have a list of other factions and its opinion of the faction. Finally, factions have a default opinion that is immediately applied anytime the faction meets a new player.

For example, Captain Rick is a member of the Hometown faction. The Hometown faction has an opinion of -5000 of Undead and an opinion 1200 toward Othertown. When Captain Rick sees a zombie, he determines that the zombie is a member of the Undead faction and attacks. When he sees a guard from Othertown, on the other hand, he lets him pass unscathed. When he meets a new player which Hometown has no opinion of, hometown uses its default opinion (3000) on that player and adds the player to the list. If the player completes a quest that helps out the hated Undead, though, that quest may also lower Hometown's opinion of the player.

The following table explains the scale of opinion values.

Opinion value Description
-5,000 to -4,500 Most hated of enemies.
-3,000 to -4,500 Kill on sight
-1,500 to -3,000 Hostile- Warn the player, then attack
0 to -1,500 Unfriendly. Will ignore the player, but the player may attack.
0 to 1,500 Distrustful. Will serve the player, but will use angry conversation options.
1,500 to 3,000 Cordial. Will offer the player some quests.
3,000 to 4,500 Friendly. Offers the player best quests and will give the player great deals.
4,500 to 5,000 Hero. Everyone of the faction welcomes the hero and offers fantastic prices.

Tutorials

  1. Create the Faction Plugin
  2. Create a Faction Behavior
  3. Create the Faction Sub-objects
  4. Your First Message
  5. Creating the Faction Objects
  6. Completing the Project
Personal tools