(Go back to the main GSoC 2015 page)
Our server and client are all coded in C++ and the database is MySql. The scriptable entities will have to be implemented mainly server side, so good knowledge of C++ is needed for this project. there will be most likely the need to add some new tables and records to the database, and so knowledge of relational database and MySql are needed.
This project consists in the creation of new system to allow a player to attach a scripts to a computer controlled entity (NPC). The NPC can be used as a guard for a building or an henchmen, or as the keeper of a player owned shop. Our engine already has a powerful scripting engine, which can be used to scripts dialogues, quests, and general interaction with the NPCs. As the scripting system is completely server side, we actually allow any kind of action, including the creation of new items, generation of coins, training skills, etc... The first part of this new system will be to to sandbox the current scripting engine by isolating only the commands which can be run by a player controlled entity. The second part is to connect this system to guildhouses, chests or player inventories to allow real exchange of items through the NPC.
We already analyzed the functionality and created diagrams to describe it. It's the first time we create such a level of detail, but we think it will be very useful for the implementation.
The following design diagrams realize the Scriptable Entities functionality.
Player Use Cases
Player can hire a NPC to do work for either the player or his guild.
To limit the number of Hired NPCs each player will only be able to hire at most one NPC. Guild might be allowed to hire more NPCs.
Using a NPC that hiring out other NPCs to start the hire. Each activity involving player is performed using NPC Dialogues.
Target NPC that hires out NPCs
Player target an NPC that hires out other NPCs.
Select working hours
Through NPC Dialogues the player can start a hiring process. The player will need to select if a night or day assignment is needed.
- Working day
- Working night
Example NPC dialogue:
- Player: I would like to hire a NPC.
- NPC: Would you like to hire for day or night?
- Player: For day work.
Select type of NPC to hire
Through NPC Dialogues the player can select type of NPC to hire. Merchant Player will only be available if the player meet a set of requirements Example: Level in crafting.
- Merchant Player
- Merchant Guild
Example NPC dialogue:
- NPC: Would you like a guard or a merchant?
- Player: I would like to have a guard.
Through NPC Dialogues the player should confirm that he would like to hire.
Example NPC dialogue:
- NPC: You can get one of my guard for 100 trias a day?
- Player: I accept the conditions.
Activate Hired NPC
After hire is confirmed a NPC will be spawned and assigned to the hiring player. The hired NPC will than start to follow the player.
Enable the Hire to define locations used when scripting their hired NPCs. This would be Work Locations and Guard Locations.
Using the /location command enabling players to define locations for Scripting Hired NPCs. Might need some kind of association so that when character/guild is deleted the location is deleted as well.
Script Hired NPC
Hired NPCs can be scripted. User open the Script Hired NPC Dialog to enter new scripts for the NPC.
Identify Item Source
Select the source of the items to be sold. For Guilds this will be a container the guild dedicate to serve as the storage for the hired merchant.
Select Work Location
From a list of locations defined by the Player using the /locate operation a work location can be defined for the Hired NPC.
It is important that only valid scripts are given to the server. Need to make sure that the script is correct before script is stored in the db and assigned to the NPC. This validation should identify illegal syntax, validate that the commands are ok for players to use. As an example commands that create new items will not be available for players. See Custom NPC Dialogues for details.
A NPC that is no longer needed can be released. This will be done from the Script Hired NPC Dialog.
Interact with Hired NPC
Using the standard interface to buy stuff from NPCs.
Admin Use Cases
In this context admin is defined as setting or rule team members.
Script NPCs that hire out NPCs
This activity creates NPC Dialogues for the NPC that are going to hire out NPCs.
Select NPCs that hire
Selection of NPCs are outside scope of this design. That is part of the Setting process.
Create NPC Dialogue
- Start Hire
- Confirm Hire
They might include steps to:
- Select working hours
- Select type of NPC to hire
- Merchant Player Items
- Merchant Guild Items
- Select experience level
Hired NPC Use Cases
Perform Guard duties. Pre-programmed guard action. Player select working hours, working position, a number of check points and interval for checking thous.
Through Quest script syntax with user safe commands enabling custom scripts to be crated for the NPC.
Sell Player Items
NPC can sell items for the hiring player. Using the standard trade front end with the trading character.
Sell Guild Items
NPC can sell guild items. Using the standard trade front end with the trading character.
This section will detail some of the activities identified in the Use Cases above. Down to a level that identifies messages between client, server and npc client and some of the sequences in the server as needed.
To keep track of hired NPCs and store the scripts new elements will be needed in the DB. Creating one new record to keep all information regarding hiring. This will be equivalent to the server side HireSession object.
Hire Session States
This section will be started when Use Cases has been agreed.
Sequence diagrams with focus on the messages going between the different programs.
Message Sequence Start Hire
See also Context Menu Design.
Message Sequence Confirm Hire
Message Sequence Script Hire
Server Sequence Diagrams
Sequence diagrams showing whats going on inside the server.
Server Start Hire Sequence
This sequence will establish the HireSession object in the HireManager. NetworkHandling is an abstraction of all the network related stuff.
Server Confirm Hire Sequence
Server Script Hired NPC Sequence
Admin /hire command
A admin /hire command equivalent to the NPC Dialogues will be created to allow testing and verification. Will also work as a GM tool to manipulate hires.