[REQUEST] ADD NPC to SOURCE CoEmu

01/04/2010 06:21 ktamer#1
I've looked all over and searched my butt off. How the crap do you add a non-existent NPC to the server? Example; I have no Blacksmith Lee existing in server so i added him via Navicat and then in NPCtalk.cs. Navicat - NPCID = 55122 NPc type = 45199 SubType = 146 Map = 1036 x = 207 y = 213 direction = 0 flag = 2. and case in source is 45199. he shows up but clicking does nothing. i even tried same npc setup with different ID and wouldnt click still? Any and all related info is appreciated.
01/04/2010 07:11 Santa#2
Quote:
Originally Posted by ktamer View Post
I've looked all over and searched my butt off. How the crap do you add a non-existent NPC to the server? Example; I have no Blacksmith Lee existing in server so i added him via Navicat and then in NPCtalk.cs. Navicat - NPCID = 55122 NPc type = 45199 SubType = 146 Map = 1036 x = 207 y = 213 direction = 0 flag = 2. and case in source is 45199. he shows up but clicking does nothing. i even tried same npc setup with different ID and wouldnt click still? Any and all related info is appreciated.
the case is 55122 not 45199.

EDIT:

If you adding a shop you need to edit the shop.dat...If i am correct, it has nothing to do with the source coding.
01/06/2010 07:45 ktamer#3
Unfortunately tried your suggestion...was a no go. I took an already placed "useless" npc and made it a blacksmith, which worked when I clicked him. Is there any guide specific rules for making non-shop based NPC's?
01/07/2010 00:40 pro4never#4
Yes, there are TONS of guides posted which you can find easily by searching the forum.

Also if you are interested the link in my siggy has some general scripting guides in it (they are formatted for cofuture but it's identical to coemu except you will need to change around some stuff like you use CSocket instead of Client and some other little things like that. The basis behind the guides apply to any source though)

Another example you could use is ANY npc script released for CoEmu (I suggest a simple/small one as it is easier to understand) and then go from there.


Case number in Handlers>npctalk.cs is the script for the npc (as controlled in the database). What you could do to avoid trouble is talk to a non-implemented npc ingame and it will tell you its case number. Then make a new case in npctalk for it and that will be your test npc for it. When done just add a new npc in the database and change the case number over.


For simplicity I took the time to open up the base coEmu source to give you a super simple sample npc incase you don't feel like searching (you really should, there is tons of info on here)

Code:
case 1152: // Simon the lab teleporter//case number is the script id for the npc in database
					{
						if(LinkBack == 0)//link back 0 is the STARTING option for any npc
							{
							Text("Hello My name is Simon, And I can help you train after you reach Level 70.\n Although I am willing to help you out I have one requirement:\n you pay me 100,000 gold for my services.", CSocket);//this is how text is handled in npcs, \n creates new line of text or you can do multiple Text("", CSocket);'s
							Link("I am prepared to pay you for your\n wonderful service!", 1, CSocket);//links change to a different LinkBack in the SAME case number
							Link("Not interested", 255, CSocket);//Link 255 closes the npc
							End(CSocket);//End CSocket ENDS the linkback. MUST BE USED IN EVERY LINK BACK OR YOU WILL GET SOME FUNKY BUGS!
						}
						else if(LinkBack == 1)//link back 1 comes from npc option 1 in last section
						{
							
							if(CSocket.Client.Level >= 70)//checks if player level is 70+
							{
								if(CSocket.Client.Money >= 100000)//checks if player money is 100000 +
								{//if money check passes these brackets happen
									Money(-100000, CSocket);//money is removed
									Teleport(1351, 20, 130, 0, CSocket);//player is teleported to map 1351 x20 y 130 instance 0
								}//end of money check
								else//if player money isn't 100k+
								{
									Text("Dare you try to rip me off?! Be gone, fool!", CSocket);//text for if player doesn't have money
									Link("Sorry sir.", 255, CSocket);//closes dialogue
									End(CSocket);//REMEMBER TO END IT!
								}
							}
							else//if player isn't 70+
							{
								Text("You are not yet level 70. Train harder.", CSocket);//text
								Link("Oh, sorry. Thanks!", 255 ,CSocket);//closes dialogue
								End(CSocket);//REMEMBER TO END IT ANY TIME YOU HAVE A NPC TEXT SCREEN!
							}
						}
						break;//ends the npc script! Use break; at the end or you will get errors
                    }//closes the last bracket

That should put you alot further along in understanding but a full guide may be better for you.