Simulating an NPC Server

Currently, there is no NPC Server available to us. Thus, we must use techniques, similar to the following, to help achieve the NPC Server experience. I am going to walk you through what it takes to simulate an NPC Server using flags and weapons.

Flags

A flag is Graal’s way of distributing a value to the different aspects of the game and all of the NPCs residing with it. Currently, we have no NPC server, but by utilizing flags, we can closely imitate the functions of the NPC server.

First, we have to figure out what NPCs will be using the flags, and which ones won’t be. A good example would be a door versus a castle (similar to what is found in Graal Classic for iPhone.) Doors that open and close by all means, don’t need server flags. However, a castle NPC may need to store a guild name for a long period of time, will need one, as NPCs themselves, cannot just store information reliably.

Let’s use the castle as an example. Perhaps the NPC, at all given times, must or should display the dominating guild’s name as a message. How can this be done? Through server flags. Server flags can hold a value as long as the NPC needs it to, and the NPC can retrieve the information at any given time.

They look like this:

[CODE]server.masterguild=Pulse
server.class.property=45
server.idontcarewhatevergoespasttheperiod=null

client.mybalance=4500
client.playerhouse.password=abc123[/CODE]

They are stored as strings, but they can be read as a string or integer value. Perhaps you want to keep track of bank donations, the flag can store that, too! All of the flags you manage to access can be set through the client’s NPC script, or the Remote Control (under the Server Flags button.) To ensure that the changes to the server flags are capable of being changed through the client, enable the option under the Server Configuration.

Types of Flags
Server Flags - They begin with “server.” and are stored in the server flags configuration file, which can be accessed by the client and the remote control. Their value will remain untouched until the value is changed by an administrator or an NPC.

Client Flags - They begin with “client.” and are stored in the player attributes, of each, individual player. Their value will remain untouched until the value is changed by an administrator or an NPC. They, too, cannot be changed by a normal player.

Local Flags - They begin with “this.” and are stored, temporarily, in the memory. They serve as a placeholder for a variable that needs to be accessed by the parent NPC and only the parent NPC. Changes will not be saved, which is why we need to use the previous flags, stated above.

Weapons

Weapons are more useful than you’d assume so. Think of them as miniature, client-side NPCs that follow the player everywhere he or she goes, and can only be accessed by that player in particular. Imagine it as an NPC in offline mode, where only YOU are visible to the NPC.

Imagine that you wrote a script that could access another player’s weapon NPC through the server flags. It is possible. It might be slow, but it, most definitely, can be done.

Weapon Names
Asterisk “*” - Weapon names that start with an asterisk may NOT be deleted by the user. This is helpful for NPC systems that control movement and the heads up display (HUD.) These weapons can also trigger the “weaponfired” event.

Hyphen “-” - Weapon names that start with a hyphen are not visible to the user, meaning they cannot delete it, nor fire it as a weapon. This is also good for systems, as it seamlessly fits in with the player’s inventory.

Forward Slash “/” - Weapons can be stored in folders, much like files are. With the use of the forward slash, followed by a weapon name, the weapon will be organized into “folders” with the bag icon. Keep in mind that you can still use the previous symbols in front of the weapon name.

Weapon names could possibly look like this:

*User -gr_movement Staff/Boots Prizes/Jump Rope

[SIZE=“3”]It will take A LOT of time and patience to get this to work, but you can create NPCs that simulate the NPC Server by implementing server flags and weapons. You will eventually figure out that data can be shared from player to player, and you will be able to take your imagination further with a simulated NPC Server.

I hope you enjoyed this article I wrote,
~Conner

P.S. Sorry, the weapon section seems to be a bit lazy, leave a reply with any questions or concerns you may have. :)[/SIZE]

this is a nice tutorial,new players will benefit alot from this.

Thanks! I’ll work on it some more and clarify the differences between each flag.

I think server flags take like 2 seconds to update for all players… not sure, coulda sworn there was some discussion on it a while back… this might just be for serverr.flags though.

Yeah, they do take a while. But it’s better than nothing, ya know. I have a fort system that uses the server. flags… I believe it updated seamlessly. Someone on the server was a witness.

Look into the tutorials on using that database thing built into the server instead of server. flags for your forts, I forget what it’s called but you will find it easy enough I hope.

[QUOTE=Agret;38759]
Look into the tutorials on using that database thing built into the server instead of server. flags for your forts, I forget what it’s called but you will find it easy enough I hope.
[/QUOTE]
What is he (you) talking about?

[QUOTE=Zartox;94269]What is he (you) talking about?[/QUOTE]

I wish I knew.