Agoraphobic Posted February 7, 2009 Author Share Posted February 7, 2009 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;http://www.touchofdeathforums.com/smf/index.php?topic=36390.msg343082;topicseen#newAfter 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._Drop Table_**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.**Scripted Npc**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 ScriptCase 0Call PlayerMsg(Index, "NPC: Hi I'm a scripted NPC with yellow text", YELLOW) Exit SubCase 1Call PlayerMsg(Index, "NPC: Hi I'm a scripted NPC with white text", WHITE) Exit SubCase ElseCall PlayerMsg(Index, "NPC: I dont have a script yet >:(", YELLOW)End SelectExit SubEnd Sub```If you want to add another script its easy, after Case 1 add this;```Case 2Call 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. Link to comment Share on other sites More sharing options...
Eviltyphoon Posted February 8, 2009 Share Posted February 8, 2009 Whats up with all these low post ppl posting great tuts?Very nice, this will help a lot of newbs. Link to comment Share on other sites More sharing options...
Admiral Refuge Posted March 31, 2009 Share Posted March 31, 2009 Very nice tutorial!I can tell you what the NPC Guard mode does:**Guard- If a player kills another player, his name will turn red. The guard will automatically attack a rednamed player** Link to comment Share on other sites More sharing options...
deity Posted April 16, 2009 Share Posted April 16, 2009 the script and everything has no prob but how exactly does it work? Does the npc talk to u when u do an action on him? Link to comment Share on other sites More sharing options...
Admiral Refuge Posted April 17, 2009 Share Posted April 17, 2009 @deity:> the script and everything has no prob but how exactly does it work? Does the npc talk to u when u do an action on him?You can script the NPC to do whatever you want. Like in the example you made the NPC's Case 2 have this code:```Case 2Call PlayerMsg(Index, "NPC: Hi I'm a scripted NPC with red text", Red) Exit Sub```That script calls a player msg that says "NPC: Hi I'm a scripted NPC with red text", so when you attack that NPC, it will say that.You could replace that command with "Call goshopping(index, 2)", and when you attack that NPC, he will open up a shop ;) Link to comment Share on other sites More sharing options...
Sudden Impact Posted April 29, 2009 Share Posted April 29, 2009 Great tut!! It's very informative & clear cut. 10/10 ;) Link to comment Share on other sites More sharing options...
Guest Posted May 1, 2009 Share Posted May 1, 2009 it's great n clear. but my npc still doesn't say ath though i attack her. Sth wrong? :icon_crap: Link to comment Share on other sites More sharing options...
YuraguKoto Posted May 1, 2009 Share Posted May 1, 2009 Give the friendly NPC max stats in everything, there's an ingame bug. Link to comment Share on other sites More sharing options...
deity Posted May 1, 2009 Share Posted May 1, 2009 yays! K thx alot! Link to comment Share on other sites More sharing options...
Admiral Refuge Posted May 1, 2009 Share Posted May 1, 2009 @[æ‹:> YuraguKoto♥♥ link=topic=38183.msg439204#msg439204 date=1241173766]> Give the friendly NPC max stats in everything, there's an ingame bug.He doesn't need max states, just a state of atleast 1 Link to comment Share on other sites More sharing options...
Guest Posted May 2, 2009 Share Posted May 2, 2009 thz.. cool it works now. Link to comment Share on other sites More sharing options...
Patrick Posted May 14, 2009 Share Posted May 14, 2009 Great for newies and this should be used by many.Never knew that guards attack people who player killed. Weird. Link to comment Share on other sites More sharing options...
Ridrik Posted July 22, 2009 Share Posted July 22, 2009 newbish but cool :) Link to comment Share on other sites More sharing options...
Ruins of Hell Posted July 23, 2009 Share Posted July 23, 2009 Agreed with E1vl. For some reason the low posters have good tuts. Anyway pretty clear although it's pretty self explaintory for most of it Link to comment Share on other sites More sharing options...
Mr. Bob Firefarter Posted July 23, 2009 Share Posted July 23, 2009 @Ridrik:> newbish but cool :)ONCE AGAIN, a necropost! Link to comment Share on other sites More sharing options...
Patrick Posted July 23, 2009 Share Posted July 23, 2009 I posted in this when I had about 200 posts. I really found this useful but now the forums colours have changed I suggest editing that black text to make it visible. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now