First, you'll need to enter the MySql Database. In there, create a new NPC. You'll want to set flags to 2, and provide a mesh of your liking. The direction should be between 0-7, this will of course determine the direction the NPC is facing. Make sure to take note of the UID. You can make any UID you wish, but I myself tend to make the number following the last in my list to avoid getting errors from duplicate UID's.
Here is an example of the NPC direction, to help you avoid trial and error on a regular basis.
Ignore how ugly it is, I'm not trying to win an art show here.
Now onto the actual coding. There are two locations you'll always have to add the code for an NPC, and both locations are found in the Client.cs
If you want to find these locations easy, take an NPC UID from your MySql Database, go into the source, press ctrl+h and enter...
Code:
if (CurrentNPC == UID)
Of course replace UID with the actual UID.
Now you need to come up with the opening speach for when you press your NPC. Here I'll make a simple example.
Code:
if (CurrentNPC == 119928)
{
SendPacket(General.MyPackets.NPCSay("Hi, I'm the example NPC.")); [COLOR="seagreen"]//simply what the NPC says.//Opening speach, but not enough, we need options.[/COLOR]
SendPacket(General.MyPackets.NPCLink("Really?", [COLOR="Blue"]1[/COLOR])); [COLOR="seagreen"]//the number at the end in blue is the control number. Whenever you create an option, you need a control number to access the next window.[/COLOR]
SendPacket(General.MyPackets.NPCLink("Sorry!", [COLOR="Blue"]255[/COLOR])); [COLOR="seagreen"]//control 255 automatically closes the window.[/COLOR]
SendPacket(General.MyPackets.NPCSetFace(30)); [COLOR="seagreen"]//the NPC face, not required, but nice to have.[/COLOR]
SendPacket(General.MyPackets.NPCFinish()); [COLOR="seagreen"]//ends the options for the npc.
}[/COLOR]
Now you could always get a bit more spiffy with it if you want, giving 2 possible openings for the NPC. This is handy when making an NPC for something like marriage, or divorce, getting reborn, etc...
I'll make this example like a cheap rb npc.
Code:
if (CurrentNPC == 10101010)
{
if (MyChar.RBCount >1)
{
SendPacket(General.MyPackets.NPCSay("You can't get first reborn two times moron."));
SendPacket(General.MyPackets.NPCLink("Sorry", 255));
SendPacket(General.MyPackets.NPCSetFace(30));
SendPacket(General.MyPackets.NPCFinish());
}
else
{
If (MyChar.Level >=120
{
SendPacket(General.MyPackets.NPCSay("Want to get reborn? Then give me a CelestialStone"));
SendPacket(General.MyPackets.NPCLink("Take it, just make me a noob again.", 1));
SendPacket(General.MyPackets.NPCLink("No way, I worked hard for this stone.", 255));
SendPacket(General.MyPackets.NPCSetFace(30));
SendPacket(General.MyPackets.NPCFinish());
}
}
}
See... Simple enough. Now to add the controls. Go to the NPC below the one you made, highlight it's UID line, press ctrl+h again, hit enter, and bam, you're down in the controls section to place your controls (that is of course if the NPC you just did that with is complete, lol). Now, it starts like the other code, but works a bit different.
Code:
if (CurrentNPC == 119928)
{
if (Control == 1) [COLOR="SeaGreen"]//Remember the control you added to the option? Here it is at work...[/COLOR]
{
SendPacket(General.MyPackets.NPCSay("Yes, I am the example NPC."));
SendPacket(General.MyPackets.NPCLink("For real?", 5));
SendPacket(General.MyPackets.NPCLink("Liar, Goodbye.", 255));
SendPacket(General.MyPackets.NPCSetFace(30));
SendPacket(General.MyPackets.NPCFinish());
}
if (Control == 5)
{
SendPacket(General.MyPackets.NPCSay("Yes, I'll prove it... Bring me Meteor, and I'll give you a MeteorTear"));
SendPacket(General.MyPackets.NPCLink("Give me a meteor.", 7));
SendPacket(General.MyPackets.NPCLink("BS, I'm out of here.", 255));
SendPacket(General.MyPackets.NPCSetFace(30));
SendPacket(General.MyPackets.NPCFinish());
}
if (Control == 7)
{
if (MyChar.InventoryContains(ItemID, 1))
{
MyChar.RemoveItem(MyChar.ItemNext(ItemID));
MyChar.AddItem("ItemID-0-0-0-0-0", 0, (uint)General.Rand.Next(263573635));
}
else
{
SendPacket(General.MyPackets.NPCSay("How stupid do you think I am? Think you can cheat me that easy?"));
SendPacket(General.MyPackets.NPCLink("Sorry o.o", 255));
SendPacket(General.MyPackets.NPCSetFace(30));
SendPacket(General.MyPackets.NPCFinish());
}
}
}
Now there are a large variety of options that can be given of course, but I'm not exactly going to post them all... This is just to give a rough idea. Hope it helps some, if it doesn't not much else I can do.