In this tutorial we will look at creating a npc and how it works. This tutorial assumes you have given yourself the proper access to edit the game. If not refer to these link how to do so;
After you have logged into the game with your character hit the F1 key. This will bring up the Administration Panel which has 3 Tabs; Player, World, and Editor. We will be working in the Editor tab, so click the editor tab and you will see several buttons;
Edit Map, Edit Spells, Edit Items, Edit Shops, Edit Npcs, Edit Arrows, Edit Emoticons, and Edit Elements.
Click the Edit Npcs button, which will bring up another window which will say Edit Choice and a bunch of numbers ranging from 1 to 14 (you can scroll down for more). Each number represents a slot for a npc to take up, so each unique npc needs its own slot. So click the first slot and hit the Ok button.
This will bring up a big menu labeled Npc Editor and have a bunch of data and sliding bars. This is where we will create the npc and set its behavior. I’ll describe what everything is and how it works going from top left corner and going down then going to the top right side down.
Name: This is simply the name of your npc that will be displayed to everyone.The name can’t be longer than 20 characters (includes spaces,symbols,numbers,etc)
Speak: This is simply the dialogue that will appear when an action (Either hostile or not) is done to the npc. The dialogue can’t be longer than 100 characters (includes spaces,symbols,numbers,etc)
Sprite: This is simply how you choose what your npc looks like. Slide the bar to the desired sprite, the sprites start at 0 and end at 500.
*Note: If the Big Npc box is checked it selects the npc from the BigSprites.bmp instead of Sprites.bmp in your gfx folder.
*Note: The 32x32 bubble is selected by default, if the sprite seems cut off try selecting the 64x32. .
Sight: This simply sets how far your npc can see (useful for attacks). The range is from 0 tiles to 30 tiles
Strength: This determines how strong and how much damage your npc does. At least 1 strength is required even if your npc is friendly to prevent errors with dialogue. This ranges from 0 to 1000.
Defense: This determines how armor and how much damage reduction your npc receives. At least 1 defense is required even if your npc is friendly to prevent errors with dialogue. This ranges from 0 to 1000.
Speed: This isn’t used by npcs and it stays on 0.
Magic: This isn’t used by npcs and it stays on 0.
Hitpoints: This determines how much health your npc has, simply how much damage can it take before it dies. This ranges from 0 to 32767 and at least 1 hitpoint is required even if your npc is friendly to prevent errors with dialogue.
Experience: This determines how much experience points your party receives upon killing the npc. This ranges from 0 to 32767.
Now to the top of the right side of the menu.
Spawn Rate: This is how many seconds it takes for the npc to respawn when destroyed. You can also check or uncheck the boxes to allow it to respawn at night and/or day.
Behavior: This selects how your Npc will react with others.
Attack When Sight- Simply your npc will attack all players as soon as they see them (remember the Sight Bar).
Attack When Attacked- Simply your npc will wander and be happy until something attacks it then the npc will go hostile.
Friendly- Simply your npc doesn’t fight, when you hit the ctrl key instead of attacking them you instead talk to them (remember the speak box).
Shopkeeper- Simply your npc doesn’t fight, when you hit the ctrl key its supposed to bring up a shop window. It however seems it don’t work, instead you will have to lay down a shop by tile or use the Scripted behavior. (If it does work please tell me and I’ll edit)
Guard- If a player kills another player, his name will turn red. The guard will automatically attack a rednamed player.
Scripted- This makes the npc use a script in your main.txt. It ranges from 0 to 10,0000. I’ll go more into detail at the end of this.
Dropping: Basically you can set what the npc drops upon death from 0 items up to 10. It starts on dropping 1 just edit the data below (number,valure, chance) then slide the bar to dropping 2 to create another dropped item, all the way up to 10 items.
Number: This is the number of the item it drops, ranges from 0 to 500.
*Warning to many items cause the slider bar to get overflow error and crash when you move the slider bar to high.
Value: How many items are dropped, ranging from 0 to 10,000.
Chance: How often does the item drop ranging from 1 out of 0 (always) to 1 out of 10,000.
*Note: Every NPC (both hostile and friendly) must have everything filled out or errors can occur with dialogue.
As I said earlier I would come back to this, but not into to much detail. Basically if you want your npc to do something special other than the default behaviors it has to be scripted and added.
To create a scripted npc you need to go to your main.txt located in your server/scripts folder and open it in notepad.
Now hit Ctrl + F this will bring up the find window and type “scriptednpc” without the quotes. This will bring you to the Scripted npc section (just close the find window now)
Your script should look something similiar to this;
Sub ScriptedNPC(Index, Script) Select Case Script Case 0 Call PlayerMsg(Index, "NPC: Hi I'm a scripted NPC with yellow text", YELLOW) Exit Sub Case 1 Call PlayerMsg(Index, "NPC: Hi I'm a scripted NPC with white text", WHITE) Exit Sub Case Else Call PlayerMsg(Index, "NPC: I dont have a script yet >:(", YELLOW) End Select Exit Sub End Sub
If you want to add another script its easy, after Case 1 add this;
Case 2 Call PlayerMsg(Index, "NPC: Hi I'm a scripted NPC with red text", Red) Exit Sub
Each time you do this you must increase the case # by 1. When you select what script the npc uses 1 to 10000 this is what case the npc is calling.
You can create all kinda of custom npc scripts such as having the npc heal you or do all kinds of things.
I am not the best of writers, however hopefully this will help anyone that is new out with npcs. If you see any corrections just let me know or an errors I have made.