[Question]Adding an NPC?

03/18/2012 10:27 itachi26#1
Hello guys,

first of all, I'm just a very noob coder and I learn everyday how to code in C#, and now I have a little problem with adding an NPC. Also, my English isn't perfect so don't pay attention to my mistakes.

Because the sources are made by different people and different ways, adding a NPC isn't the same on every sources. I can't even remember where I get mine si I uploaded the source again. I think that you don't need a guide for making the server so, here's the [Only registered and activated users can see links. Click Here To Register...]. It is a 5375 source so you need a client, I think that you've got one already .

My problem is, I correctly added the NPC but I can't even change his name. Let me show you how my code added is and the modified tables are right now.

Quote:
Originally Posted by Dialog.cs
Code:
                #region MyNewNPC
                case 7685:
                    {
                        switch (npcRequest.OptionID)
                        {
                            case 0:
                                {
                                    dialog.Text("Yop mec, j'peux que te parler pour le moment, mais on va faire des choses plus intéressantes ŕ l'avenir !");
                                    dialog.Link("Ouais ouais...", 255);
                                    dialog.Avatar(55);
                                    dialog.Send();
                                    break;
                                }
                        } break;
                    }
                #endregion
Quote:
Originally Posted by cq_npc
id | ownerid | name | type | lookface |mapid | cellx | celly | direction | action
7685 | 0 | MyNewNPC | 2 | 4450 | 1002 | 436 | 384 | 0 | 0
I tried also with "npc" table but gives the same result. The two tables modifed also. I really don't know how to add my NPC because when I try "CTRL+F" on "cq_npc", "npc" or in the entire solution and I search "Wolfe", I don't have any results...

I have seen a gui, "Manager.cs" and it looks like we can add NPC by that GUI, but she doesn't appear when I generate the executable file. I really don't have any idea on my problem, I hope that someone will get interesting in my problem.

Photo :
[Only registered and activated users can see links. Click Here To Register...]
Uploaded with [Only registered and activated users can see links. Click Here To Register...]
03/18/2012 10:29 Spirited#2
Names are client sided. They're in "npc.ini" in the INI folder of the client.
03/18/2012 10:37 itachi26#3
Oh my gosh, you're right... I didn't know that. Thanks a lot for you're fast answer!
07/20/2012 23:32 itachi26#4
#UP

Back to annoy you again.

Well, I choiced an easier source because of my coding level, and I still have some problems to add my own NPC without editing an existant one.

Of course, you were right, there is "npc.ini" in the client, with the name but for exemple, for Alex :

INI :
Quote:
[NpcType216]
Name=Alex
SimpleObjID=265
StandByMotion=999265100
BlazeMotion=999265102
RestMotion=999265101
Effect=none
ASB=5
ADB=6
FixDir=0
Here is his code :

CODE :
Code:
                            #region Alex

                            case 3600:
                                {
                                    if (option == 0)
                                    {

                                        GC.AddSend(Packets.NPCSay("So you feel like getting 2nd reborn? Well then you came to the right place. In order to get 2nd reborn you need to be level 120 and have a Exemption Token"));
                                        GC.AddSend(Packets.NPCLink("I want 2nd reborn", 1));
                                        GC.AddSend(Packets.NPCLink("Nope, you're mistaken.", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
This is not the entire code but anyway, I can't see a link between the "npc.ini" in the client and the "Case n°" in the code.

Can someone tell me where do I have to take a look?

EDIT : Moreoever, no "npc" tables in the database.

Thanks!
07/21/2012 00:58 _DreadNought_#5
Okay.

PHP Code:
[NpcType216]
Name=Alex
SimpleObjID
=265
StandByMotion
=999265100
BlazeMotion
=999265102
RestMotion
=999265101
Effect
=none
ASB
=5
ADB
=6
FixDir
=
216 is the TYPE of the npc, not its ID.

Look into OldCODB/ and there will be an npcs file, which will have a line like this
PHP Code:
//ID TYPE MAPID X Y
2600 216 1002 400 400 
or something of the sort, the case number is the ID in the database.
07/21/2012 01:07 pro4never#6
Please note that you CAN send the npc names from the server's end for on the fly changes but it's (slightly) more efficient to use client side editing only.

Just append the name string into the npc spawn packet and it should work fine.
07/21/2012 02:02 itachi26#7
_DreadNought_ : I checked it out immediately but it lookds like it doesn't have the same look :
Quote:
3600(1) 2160(2) 2(3) 67(4) 1020(5) 436(6) 311(7)
(1) I guess this is the case number
(2) I really don't what is that thing
(3) I think that it is the flag*
(4) Well... haha
(5) It should be the map ID
(6) & (7) x & y

*flag : I can see that in a part of the source code :
Code:
 public enum NPCActionType
    {
        Shop = 1,
        Dialog = 2,//3, 4, 10, 15, 27
I will test to add mine and keep both of you informed.

pro4never : I won't lie and say that I didn't understand. At the moment I'm swimming into that large code but for sure, I note what you said.

Thanks!

EDIT : Oh no, can't build the solution, it looks like there is an error in the source. It was written in VS 2008 and I translated into 2010, now I've got an error... I think I am gonna take 5375's source which works fine.