[Release]Coding NPC's (Very basic)

10/01/2009 02:01 Fish*#1
This is for LOTF
---------------------------------------------------------------------
Here is a guide about how to code NPC's (Very basic)
There is 2parts, when creating NPC's.
The 2parts is NPCtalk and NPCdo

Both examples is build on same

NPCtalk = What the NPC says and wich choices you can choose.
ex.


Code:
if (CurrentNPC == 585858)
{
SendPacket(General.MyPackets.NPCSay("Make a choice"));
SendPacket(General.MyPackets.NPCLink("Yes", 1));
SendPacket(General.MyPackets.NPCLink("No", 2));
SendPacket(General.MyPackets.NPCLink("Just passing here", 255));
SendPacket(General.MyPackets.NPCSetFace(30));
SendPacket(General.MyPackets.NPCFinish());
}
When you make something to choose, then is called NPClink
, 1)); is for control 1
, 2)); is for control 2
, 255)); is for end conversation or control

NPCdo = What the NPC do, when choosing a choice or when click on them. This is called the control.
ex.


Code:
if (CurrentNPC == 585858)
{
if (Control == 1)
{
SendPacket(General.MyPackets.NPCSay("You have choosed yes"));
SendPacket(General.MyPackets.NPCLink("I see", 255));
SendPacket(General.MyPackets.NPCSetFace(30));
SendPacket(General.MyPackets.NPCFinish());
}
if (Control == 2)
{
SendPacket(General.MyPackets.NPCSay("You have choosed no"));
SendPacket(General.MyPackets.NPCLink("I see", 255));
SendPacket(General.MyPackets.NPCSetFace(30));
SendPacket(General.MyPackets.NPCFinish());
}
I know is not a big guide, but i hope some can learn how to code NPC's :)
is only for basic things :)
And for you that think this is not helping cause is easy, then there is some that just dont understand anything about coding and could use even the smallest help they can get.
And another thing im not a great coder, im trying to learn it :)

----------------------------------------------------------------------------------------
Here is some small codes you can add to conversation:(NPCdo)
For adding items to char:
Code:
                                        MyChar.AddItem("ID#-Bonus+-Bless-Enchant-Gem1-Gem2", Amount, (uint)General.Rand.Next(36457836));
}
For buying item for cps:
Code:
                                if (MyChar.ItemsInInventory < 40)
                                {
                                    if (MyChar.CPs >= Amount)
                                    {
                                        MyChar.CPs -= Amount;
                                        MyChar.AddItem("ID#-Bonus+-Bless-Enchant-Gem1-Gem2", Amount, (uint)General.Rand.Next(36457836));
                                        SendPacket(General.MyPackets.Vital(MyChar.UID, 30, MyChar.CPs));
}
For adding skill:
Code:
                                        MyChar.LearnSkill(Skill ID#, Skill level);
}
For teleporting player:
Code:
                                    MyChar.Teleport(Map ID#, XPosition, YPosition);
}
For Removing Silvers or Cps:
Silvers:
Code:
                                    if (MyChar.Silvers >= Amount)
                                    {
                                    MyChar.Silvers -= Amount;
                                    SendPacket(General.MyPackets.Vital(MyChar.UID, 4, MyChar.Silvers));
}
CPs:
Code:
                                    if (MyChar.CPs >= Amount)
                                    {
                                        MyChar.CPs -= Amount;
                                        SendPacket(General.MyPackets.Vital(MyChar.UID, 30, MyChar.CPs));
}
For remove item:
Code:
                                if (MyChar.InventoryContains(Item ID#, Amount))
                                {
                                    MyChar.RemoveItem(MyChar.ItemNext(Item ID#));
}
10/01/2009 02:21 Fish*#2
Quote:
Originally Posted by |^ØnëwïngëÐ^| View Post
Nice guide :P
Thanks :)

Really i used it to learn my friend how to add NPC's, but then i thought
i could make a little guide and post it here ;D
10/01/2009 02:23 Empty Project#3
Good Job :)
10/01/2009 02:31 Fish*#4
Quote:
Originally Posted by Empty Project View Post
Good Job :)
hehe thank you EP :mofo:
I thought about, on your forum?
Whats on there? :D


But goodnight everyone
ill go bed :D
10/01/2009 02:36 Arco:)#5
great job dude!
this will help DDBills
i mean
all the noobs
10/01/2009 02:38 -Shunsui-#6
its a verry nice guide for learners , GOOD JOB!
10/01/2009 19:43 Fish*#7
Thank you all.
I hope it helped :)
10/01/2009 20:02 Arcо#8
Awesome job guy!
Bet this will help alot of people learning to code!
10/01/2009 20:07 Fish*#9
Quote:
Originally Posted by Tiku View Post
Awesome job guy!
Bet this will help alot of people learning to code!
Thank you thank you

Edit:
Is just bad,when the thread ends long in section, so no one will find it XD
10/01/2009 23:27 Arcо#10
By the way grillmad.
Instead of using [ Quote][ /Quote] use [ Code][ /Code]
10/01/2009 23:28 Fish*#11
kk ill edit now thanks :D
10/12/2009 03:13 Fish*#12
#BUMPED :)
10/12/2009 09:26 ~Yuki~#13
thanks that will hopefully stop some noobthreads
10/12/2009 09:36 zbest#14
Wow i like LOTF Coding ;).
I wanna learn,who want to teach me?
By the way grillmad at link 1/link2 i understand are the options when you click do action but can you tell me what are the numbers (30),(255) and so on...??
This numbers are making the action do when click the link?
10/12/2009 09:55 ~Yuki~#15
if u dont bind the nubers to a control it will exit the dialoge

I wouldnt mind of helping u understanding the lotf code, u got my msn