[RELEASE]How to code an decent npc with NPCs.txt entry

03/16/2010 20:49 Paralyzer[GM]#1
Ok well I though I would release the basic NPCDialog and how to make an npc with the entry in NPC.txt so here
we go

Ok so every npc will start of with a
Code:
#Region npcname
and were it says
Code:
npcname
you
can change to what ever you want it to be so, next you will have this
Code:
case 123456:
you can change
the
Code:
123456
with a random number 1-6 digits but we will come back to that so we have this
Code:
#Region npcname //The name of NPC
case  123456: // case number
{
if (Control == 0);
{
and next we add an
Code:
{
the { is opening the case so we have this
Code:
#Region npcname // The name of NPC
case  123456: // case number
{
if (Control == 0);
{ // Opening the case
Oh and I forgot at the begging of EVERY NPC it has
Code:
if (Control == 0);
ok so next we add the dialog witch looks like this
Code:
GC.MyChar.AddSend(Packets.NPCSay("Hello this is my first npc"));
ok so were is says
Code:
Hello this is my first npc
you can change that with whatever you want :) ok so now it looks like
this
Code:
#Region npcname // The name of NPC
case  123456: // case number
{
if (Control == 0);
{ // Opening the case
GC.MyChar.AddSend(Packets.NPCSay("Hello this is my first npc")); // What the NPC says
ok so now we want a link also known as when you can click Yes or No or whatever so this is how its done
Code:
GC.MyChar.AddSend(Packets.NPCLink("Yes", 2));
      GC.MyChar.AddSend(Packets.NPCLink("No", 255));
ok so just change the Yes and the No to whatever you want now your gonna want to know what the
Code:
", 2)); and the ", 255));
well the ", 255)); is on the No and 255 is to end the npc so
when you click the no it will end the npc ok so on to the
Code:
", 2));
well thats goes to the
second part of the npc so far we have this
Code:
#Region npcname // The name of NPC
case  123456: // case number
{
if (Control == 0);
{ // Opening the case
GC.MyChar.AddSend(Packets.NPCSay("Hello this is my first npc")); // What the NPC says
GC.MyChar.AddSend(Packets.NPCLink("Yes", 2)); // Second part of npc
GC.MyChar.AddSend(Packets.NPCLink("No", 255)); // To end the npc
Ok and to finish a peace of dialog we ALWAYS add this
Code:
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
ok so this is the npc so far
Code:
#region npcname
case 987787:
{
if (Control == 0)
{
GC.AddSend(Packets.NPCSay("This is my first npc"));
GC.AddSend(Packets.NPCLink("Yes.", 2));
GC.AddSend(Packets.NPCLink("No.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
right I want to hurry this up so... after that on the second part of the npc will look the same nearly
it will look like this, this will give the player 200CPs
Code:
if (Control == 2)
{
GC.MyChar.CPs += 200;
GC.MyChar.AddSend(Packets.NPCSay("This is my second-part npc"));
GC.AddSend(Packets.NPCLink("Thank you.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
and to end an npc after we done it all after the } we add this
Code:
break;
}
#endregion
so this is our finished npc
Code:
#region npcname
case 987787:
{
if (Control == 0)
{
GC.AddSend(Packets.NPCSay("This is my first npc"));
GC.AddSend(Packets.NPCLink("Yes.", 2));
GC.AddSend(Packets.NPCLink("No.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
if (Control == 2)
{
GC.MyChar.CPs += 200;
GC.MyChar.AddSend(Packets.NPCSay("This is my second-part npc"));
GC.AddSend(Packets.NPCLink("Thank you.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
break;
}
#endregion
and that an npc :)

Ok so next im going to teach you is how to make a comment on a line of code a comment looks like this
Code:
// This is a comment
so lets use our npc for an example
Code:
#region mynpc
if (Control == 0)
{
GC.MyChar.CPs += 200;
GC.MyChar.AddSend(Packets.NPCSay("This is my second-part npc")); //This is a comment and the program wont read this comment :)
GC.AddSend(Packets.NPCLink("Thank you.", 255)); //This is a comment to
GC.AddSend(Packets.NPCSetFace(N.Avatar)); //So is this a comment
GC.AddSend(Packets.NPCFinish()); // AND THIS IS ANOTHER COMMENY jeez lol
} // This is 1 more damn commend haha
and thats an comment
anyway for an npc after a
Code:
{
do give the character some cps you can do
Code:
GC.MyChar.CPs += 200;
and to take away cps do this
Code:
GC.MyChar.CPs -= 200;
and for silvers do this
Code:
GC.MyChar.Silvers += 200;
And to remove the silvers do this
Code:
GC.MyChar.Silvers -= 200;
and for both you can do something like this
Code:
GC.MyChar.CPs -= 200;
GC.MyChar.Silvers += 29929292;
that will remove 200 cps and add 29929292 Silvers ok,
so for the teleport a character again after the
Code:
{
you can do something like
Code:
GC.MyChar.Teleport(1004, 068, 123);
Ok so the (1004 is the map ID and the 068, is the X-cord and the 123 is the Y-Cord and that code will teleport you to
the promotion center and near a corner :D

ok the
[code]
case 123456:
[/CODE}
right you can change that to a UNIQUE number so first go into
Code:
OldCODB/ and open up NPC.txt
and do a CTRL + F and search a unique number and if it says
Code:
Cannot be find
you can use it so at the end of the file add this
[code]
123456 8099 2 28 1002 456 378
[CODE]
ok so change the 123456 to your number that you chose ok and the
Code:
1002 456 378
is the map id, X-Cord, Y-Cord so the mapid ycord xcord and thats all there is to it click File-Save and there you are
you have added an npc

this took me A LONG TIME to write out like 1 hour writing this out mainly because I wanted to test out my new
Notepad++ and it is very nice So far I have type 190 lines lol

Please hit +Thanks THIS IS ALL MY WORK NOT LEECHED ONE LITTLE BIT!
03/16/2010 20:55 -NewDawn-#2
Quote:
Originally Posted by Paralyzer[GM] View Post
Ok well I though I would release the basic NPCDialog and how to make an npc with the entry in NPC.txt so here
we go


Code:
GC.MyChar.CPs + 200;
and to take away cps do this
Code:
GC.MyChar.CPs - 200;
and for silvers do this
Code:
GC.MyChar.Silvers + 200;
And to remove the silvers do this
Code:
GC.MyChar.Silvers - 200;
and for both you can do something like this
Code:
GC.MyChar.CPs - 200;
GC.MyChar.Silvers + 29929292;
that will remove 200 cps and add 29929292 Silvers ok,
so for the teleport a character again after the
[CODE]

Please hit +Thanks THIS IS ALL MY WORK NOT LEECHED ONE LITTLE BIT!
You mean += and -=
03/16/2010 20:57 dodolinobobo#3
it's a good guide,but not for an advanced npc,if you can make an advanced npc ,the guide will be aprecieated and you will have some +Thanks for sure:)
03/16/2010 21:15 Paralyzer[GM]#4
#UPDATED

#REPORTED requested name change
03/16/2010 22:31 hunterman01#5
Quote:
Originally Posted by -FREEZE- View Post
lol seriously?
You call this a "advanced" npc?
Well I don't know what world your from but this is definitely not a advanced npc.
Thx for that bit of info never knew.
03/16/2010 22:38 walmartboi#6
What do you mean by 'advanced'? Like.. advanced as is 'so easy even a cave man could do it'(obviously you).
03/17/2010 02:38 killersub#7
welll I see him contributing so I'll +k him since he's helping the community...I jus dont do "Flame/spamming" lol...anyways keep up da good work!
03/17/2010 03:36 .Beatz#8
Good work man keep it up
03/17/2010 17:34 Paralyzer[GM]#9
Well as you can see I thought of a gay name and as I said I #Reported it for a name change so shutup Freeze haha ur banned HAHA!
03/18/2010 07:38 maximumbrutal#10
One question about the npc were going to add
123456 8099 2 28 1002 456 378
what is the 8099 2 28?
you explained the 1002 456 378
but you did not explain the 8099 2 28
04/13/2010 06:11 gme4l1f3#11
Quote:
Originally Posted by maximumbrutal View Post
One question about the npc were going to add
123456 8099 2 28 1002 456 378
what is the 8099 2 28?
you explained the 1002 456 378
but you did not explain the 8099 2 28
second number is mesh
third number is flag
fourth number is direction
05/12/2010 21:33 2010mrsurfer#12
hmmm ive done everything u said and the npc comes up as a Carpenter saying Hi, i do not speak anything useful yet, my ID 987787
05/12/2010 23:41 Arcо#13
Have you compiled the source yet? (f5)
05/13/2010 14:06 2010mrsurfer#14
Yes ive compiled it but i get 21 errors... and it still says the same
07/01/2010 05:20 ▪◦כֿסּףּצּגּפֿђ◦▪#15
Nice Guide :D + Thanks To YOu