[Request Help] Shop & NPC Talk (5165)

03/28/2010 20:59 -NewDawn-#1
Hey Everyone.
Some of you might know that I'm working on the "Starter Quest" for Noobs.
I'm having a big problem though...

My problem is, I want to make this NPC:
[Only registered and activated users can see links. Click Here To Register...]
Code:
4 40 1 0 1002 412 366
and make it so that it can talk to you, and then if you click a link to Control 2, it will bring up the shop.
Help? =\
03/29/2010 09:43 -impulse-#2
And you still believe you are better than me?

The only way you can talk to a shop npc is through client packets, for e.g. if you start a quest , it will start walking to a npc, once you are around that npc, it will send a 10010 packet, with the npc's ID. Then you just answer to that packet with npc dialog packets.
And for opening the shop use a proxy to get the packet.
03/29/2010 22:30 Arcо#3
Sending packets.
Easy nuff right?
03/29/2010 23:34 -NewDawn-#4
I have no idea. I've never seen an example of it. I've been fooling around with it and trying to figure it out but I got nothing.

and impulse, reported.
I never said I'm better than you. I don't even know who you are.
Stop spamming my posts with flames.

however, impulse- u're saying that it can be done by using the 10010 packet and interaction with the client?
03/29/2010 23:46 ImmuneOne#5
Code:
-> Direction(Entity.X, Entity.Y, NPC.X, NPC.Y);
-> Walk into direction =
{
   if (Distance(Entity.X, NPC.X, Entity.Y, NPC.Y) <= 2)
         NPC.Interact();
}
As I don't know the definitions in your source, you can figure it out on your own.
03/29/2010 23:50 -NewDawn-#6
Quote:
Originally Posted by ImmuneOne View Post
Code:
-> Direction(Entity.X, Entity.Y, NPC.X, NPC.Y);
-> Walk into direction =
{
   if (Distance(Entity.X, NPC.X, Entity.Y, NPC.Y) <= 2)
         NPC.Interact();
}
As I don't know the definitions in your source, you can figure it out on your own.
That's not what I was trying to do but that's really helpful so thanks!
=]

What I'm trying to do is have it so that you can open the Armor shop after talking to him... here, i'll get some pictures- hold on.

Like this:
[Only registered and activated users can see links. Click Here To Register...]
and then "I need to buy some equipment" = control 2 which goes to this window:
[Only registered and activated users can see links. Click Here To Register...]

If you guys help me with this then I'll release the Starter Quest.
I admit that I'm not the best coder and i'm not ashamed of it since it's impossible to know everything about coding in 1 month. Please give me some help you guys, I'd really like to learn how to do this.

I also found this in Shop.dat:
Code:
[Shop14]
ID=4
Name=Armorer
Type=1
MoneyType=0
ItemAmount=39
Item0=123003
Item1=123013
Item2=123023
Item3=123033
Item4=112003
Item5=112013
Item6=112023
Item7=112033
Item8=132005
Item9=132015
Item10=118003
Item11=118013
Item12=118023
Item13=118033
Item14=111003
Item15=111013
Item16=111023
Item17=111033
Item18=113005
Item19=113013
Item20=114003
Item21=114013
Item22=114023
Item23=114033
Item24=135003
Item25=135013
Item26=135023
Item27=130005
Item28=130015
Item29=130025
Item30=131005
Item31=131015
Item32=131025
Item33=133005
Item34=133015
Item35=133025
Item36=134005
Item37=134015
Item38=134025
which means...
Code:
4 40 1 0 1002 412 366
4 is the id, 40 is the npc-mesh id, 1 means shop, 0 means non-pkable, and then location.
So if I change it to dialog (2) then... i have to figure out how to link it to the shop...

How does it link in the first place?
03/30/2010 00:05 ImmuneOne#7
Change the NPC Type and call the shop packet when clicking control 2?
03/30/2010 00:11 Korvacs#8
That would require re-spawning the npc everytime someone interacts with it.

It seems more like its a newer addition to the latest clients, i experimented with this exact thing a while back around 5100 and found that the only npcs i could make it work with without sending respawn packets and what not, are npcs which make a an NPCinteraction request (like requesting a dialog), and then the server responds with a 1010 dialog display.

Prime example would be the warehouse men, you can easily have a massive conversation and then display the warehouse, because its the same NPC type, if you wanted to do it with shops you would require 2 NPC definitions, one a shop, the other a text dialog npc, then spawn the second one when you click the second dialog, however the client displays the shop itself, and the server is never involved in that, so you would still need to click the npc again afterwards anyway.

So all in all, yes in much later clients, no in anything pre 5200 probably.
03/30/2010 01:09 -NewDawn-#9
Quote:
Originally Posted by Korvacs View Post
That would require re-spawning the npc everytime someone interacts with it.

It seems more like its a newer addition to the latest clients, i experimented with this exact thing a while back around 5100 and found that the only npcs i could make it work with without sending respawn packets and what not, are npcs which make a an NPCinteraction request (like requesting a dialog), and then the server responds with a 1010 dialog display.

Prime example would be the warehouse men, you can easily have a massive conversation and then display the warehouse, because its the same NPC type, if you wanted to do it with shops you would require 2 NPC definitions, one a shop, the other a text dialog npc, then spawn the second one when you click the second dialog, however the client displays the shop itself, and the server is never involved in that, so you would still need to click the npc again afterwards anyway.

So all in all, yes in much later clients, no in anything pre 5200 probably.
What about this? What does this code do exactly?
Does it just buy an item... or could this possibly be used to make a shop appear?
Code:
public void BuyItem(uint NPCID, uint ItemID, byte Amount)
        {
            if (Game.World.H_NPCs.Contains(NPCID) || NPCID == 2888 && Database.Shops.Contains(NPCID))
            {
                Game.NPC N = (Game.NPC)Game.World.H_NPCs[NPCID];
                Shop S = (Shop)Database.Shops[NPCID];

                if ((N != null && N.Loc.Map == Loc.Map && MyMath.PointDistance(N.Loc.X, N.Loc.Y, Loc.X, Loc.Y) < 18 || NPCID == 2888) && S.Items.Contains(ItemID))
                {
                    DatabaseItem DBI = (DatabaseItem)Database.DatabaseItems[ItemID];
                    if (DBI.ID == 0)
                    {
                        Program.WriteLine("Error Database item = null, item id = " + ItemID);
                        return;
                    }
                    for (byte i = 0; i < Amount; i++)
                    {
                        if (Inventory.Count < 40)
                        {
                            if (S.MoneyType == 0 && Silvers >= DBI.Worth)
                            {
                                Game.Item I = new NewestCOServer.Game.Item();
                                I.ID = ItemID;
                                I.UID = (uint)Game.World.Rnd.Next(10000000);
                                try
                                {
                                    I.MaxDur = DBI.Durability;
                                    I.CurDur = I.MaxDur;
                                }
                                catch (Exception Exc) { Program.WriteLine(Exc); }
                                Game.ItemIDManipulation e = new NewestCOServer.Game.ItemIDManipulation(I.ID);
                                if (e.Part(0, 2) == 11 || e.Part(0, 2) == 13 || e.Part(0, 3) == 123 || e.Part(0, 3) == 141 || e.Part(0, 3) == 142)
                                    I.Color = NewestCOServer.Game.Item.ArmorColor.Orange;
                                AddItem(I);
                                Silvers -= DBI.Worth;
                            }
                            else if (S.MoneyType == 1 && CPs >= DBI.CPsWorth)
                            {
                                Game.Item I = new NewestCOServer.Game.Item();
                                I.ID = ItemID;
                                I.UID = (uint)Game.World.Rnd.Next(10000000);
                                try
                                {
                                    I.MaxDur = DBI.Durability;
                                    I.CurDur = I.MaxDur;
                                }
                                catch (Exception Exc) { Program.WriteLine(Exc); }

                                if (Game.ItemIDManipulation.Part(I.ID, 0, 2) == 73)
                                    I.Plus = Game.ItemIDManipulation.Digit(I.ID, 6);
                                AddItem(I);
                                CPs -= DBI.CPsWorth;
                            }
                        }
                    }
                }
            }
        }
03/30/2010 06:10 Arcо#10
Quote:
Originally Posted by -NewDawn- View Post
What about this? What does this code do exactly?
Does it just buy an item... or could this possibly be used to make a shop appear?
Code:
public void BuyItem(uint NPCID, uint ItemID, byte Amount)
        {
            if (Game.World.H_NPCs.Contains(NPCID) || NPCID == 2888 && Database.Shops.Contains(NPCID))
            {
                Game.NPC N = (Game.NPC)Game.World.H_NPCs[NPCID];
                Shop S = (Shop)Database.Shops[NPCID];

                if ((N != null && N.Loc.Map == Loc.Map && MyMath.PointDistance(N.Loc.X, N.Loc.Y, Loc.X, Loc.Y) < 18 || NPCID == 2888) && S.Items.Contains(ItemID))
                {
                    DatabaseItem DBI = (DatabaseItem)Database.DatabaseItems[ItemID];
                    if (DBI.ID == 0)
                    {
                        Program.WriteLine("Error Database item = null, item id = " + ItemID);
                        return;
                    }
                    for (byte i = 0; i < Amount; i++)
                    {
                        if (Inventory.Count < 40)
                        {
                            if (S.MoneyType == 0 && Silvers >= DBI.Worth)
                            {
                                Game.Item I = new NewestCOServer.Game.Item();
                                I.ID = ItemID;
                                I.UID = (uint)Game.World.Rnd.Next(10000000);
                                try
                                {
                                    I.MaxDur = DBI.Durability;
                                    I.CurDur = I.MaxDur;
                                }
                                catch (Exception Exc) { Program.WriteLine(Exc); }
                                Game.ItemIDManipulation e = new NewestCOServer.Game.ItemIDManipulation(I.ID);
                                if (e.Part(0, 2) == 11 || e.Part(0, 2) == 13 || e.Part(0, 3) == 123 || e.Part(0, 3) == 141 || e.Part(0, 3) == 142)
                                    I.Color = NewestCOServer.Game.Item.ArmorColor.Orange;
                                AddItem(I);
                                Silvers -= DBI.Worth;
                            }
                            else if (S.MoneyType == 1 && CPs >= DBI.CPsWorth)
                            {
                                Game.Item I = new NewestCOServer.Game.Item();
                                I.ID = ItemID;
                                I.UID = (uint)Game.World.Rnd.Next(10000000);
                                try
                                {
                                    I.MaxDur = DBI.Durability;
                                    I.CurDur = I.MaxDur;
                                }
                                catch (Exception Exc) { Program.WriteLine(Exc); }

                                if (Game.ItemIDManipulation.Part(I.ID, 0, 2) == 73)
                                    I.Plus = Game.ItemIDManipulation.Digit(I.ID, 6);
                                AddItem(I);
                                CPs -= DBI.CPsWorth;
                            }
                        }
                    }
                }
            }
        }
That's removing currency, adding items, and so on and so forth, not opening an npc.