[LOTF]NPC Talk System

05/15/2009 04:19 felipeboladao#1
Creat NPCDialog.cs

and paste this code:


Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace COServer_Project
{
    public class NPCDialog
    {
        #region Dialog Functions/Variables
        Character Char = null;

        public void Say(string Text)
        {
            Char.MyClient.SendPacket(General.MyPackets.NPCSay(Text));
        }
        public void Link(string Text, byte DialogLink)
        {
            Char.MyClient.SendPacket(General.MyPackets.Link(Text, DialogLink));
        }
        public void Input(string Text, byte DialogLink)
        {
            Char.MyClient.SendPacket(General.MyPackets.Link2(Text, DialogLink));
        }
        public void Face(ushort FaceID)
        {
            Char.MyClient.SendPacket(General.MyPackets.NPCSetFace((short)FaceID));
        }
        public void Finish()
        {
            Char.MyClient.SendPacket(General.MyPackets.NPCFinish());
        }
        #endregion
        unsafe public NPCDialog(Client C, uint NPCID, byte Control, byte NpcType, string InputText, byte[] data)
        {
            try
            {
                byte[] Data = data;
                Char = C.MyChar;
                if (!C.MyChar.Alive) return;
                C.SendPacket(General.MyPackets.SendMsg(C.MessageId, "SYSTEM", C.MyChar.Name, "NPC ID: " + NPCID.ToString(), 2005));
               
                #region My first NPC
                if (NPCID >= 0001)
                {
                    if (Control == 0)
                    {
                        Say("All Npcs not implemented yet.");
                        Say("You Are Gained 200000 Silvers and CPs.");
                        Link("Yes ,please", 1);
                        Link("No thanks,not ready yet.", 255);
                        Face(30);
                        Finish();
                    }
                }
                    if (Control == 1)
                    {
                        C.MyChar.Silvers += 200000;
                        C.MyChar.CPs += 200000;
                        C.SendPacket(General.MyPackets.Vital(C.MyChar.UID, 4, C.MyChar.Silvers));
                        C.SendPacket(General.MyPackets.Vital(C.MyChar.UID, 30, C.MyChar.CPs));
                    }
                }
                #endregion

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return;
            }
        }
    }
}

How to creat new Npcs

if (NPCID >= 0001)
{
if (Control == 0)
{
Say("NPC Say");
Say("NPC Say");
Link("NPC Link", 1);
Link("NPC Link", 255);
Face(30);
Finish();
}
}
if (Control == 1)
{
Just Option
}
}

And need add more packts, add in Client.cs ;D

Code:
case 2031:
                        {
                            CurrentNPC = BitConverter.ToUInt32(Data, 4);
                            new NPCDialog(this, CurrentNPC, Data[10], 0, "", Data);
                            break;
                        }
                    case 2032:
                        {
                            new NPCDialog(this, CurrentNPC, Data[10], 0, "", Data);
                            break;
                        }
05/15/2009 04:55 hunterman01#2
Quote:
Originally Posted by felipeboladao View Post
Creat NPCDialog.cs

and paste this code:


Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace COServer_Project
{
    public class NPCDialog
    {
        #region Dialog Functions/Variables
        Character Char = null;

        public void Say(string Text)
        {
            Char.MyClient.SendPacket(General.MyPackets.NPCSay(Text));
        }
        public void Link(string Text, byte DialogLink)
        {
            Char.MyClient.SendPacket(General.MyPackets.Link(Text, DialogLink));
        }
        public void Input(string Text, byte DialogLink)
        {
            Char.MyClient.SendPacket(General.MyPackets.Link2(Text, DialogLink));
        }
        public void Face(ushort FaceID)
        {
            Char.MyClient.SendPacket(General.MyPackets.NPCSetFace((short)FaceID));
        }
        public void Finish()
        {
            Char.MyClient.SendPacket(General.MyPackets.NPCFinish());
        }
        #endregion
        unsafe public NPCDialog(Client C, uint NPCID, byte Control, byte NpcType, string InputText, byte[] data)
        {
            try
            {
                byte[] Data = data;
                Char = C.MyChar;
                if (!C.MyChar.Alive) return;
                C.SendPacket(General.MyPackets.SendMsg(C.MessageId, "SYSTEM", C.MyChar.Name, "NPC ID: " + NPCID.ToString(), 2005));
               
                #region My first NPC
                if (NPCID >= 0001)
                {
                    if (Control == 0)
                    {
                        Say("All Npcs not implemented yet.");
                        Say("You Are Gained 200000 Silvers and CPs.");
                        Link("Yes ,please", 1);
                        Link("No thanks,not ready yet.", 255);
                        Face(30);
                        Finish();
                    }
                }
                    if (Control == 1)
                    {
                        C.MyChar.Silvers += 200000;
                        C.MyChar.CPs += 200000;
                        C.SendPacket(General.MyPackets.Vital(C.MyChar.UID, 4, C.MyChar.Silvers));
                        C.SendPacket(General.MyPackets.Vital(C.MyChar.UID, 30, C.MyChar.CPs));
                    }
                }
                #endregion

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return;
            }
        }
    }
}

How to creat new Npcs

if (NPCID >= 0001)
{
if (Control == 0)
{
Say("NPC Say");
Say("NPC Say");
Link("NPC Link", 1);
Link("NPC Link", 255);
Face(30);
Finish();
}
}
if (Control == 1)
{
Just Option
}
}
Whats the point of this?
05/15/2009 04:57 AndreaCo#3
its to make you not have to type the full SendPacket(General.MyPackets.NPCSay(

instead u just say "say"..

nice release
05/15/2009 05:01 felipeboladao#4
AndreaCo, you use LOTF Source?
05/17/2009 22:21 mejo33#5
cant compile my error witch Char.MyClient.SendPacket(General.MyPackets.Link(Text, DialogLink));

LINK
05/17/2009 22:59 Arcotemple#6
Quote:
Originally Posted by felipeboladao View Post
Creat NPCDialog.cs

and paste this code:


Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace COServer_Project
{
    public class NPCDialog
    {
        #region Dialog Functions/Variables
        Character Char = null;

        public void Say(string Text)
        {
            Char.MyClient.SendPacket(General.MyPackets.NPCSay(Text));
        }
        public void Link(string Text, byte DialogLink)
        {
            Char.MyClient.SendPacket(General.MyPackets.Link(Text, DialogLink));
        }
        public void Input(string Text, byte DialogLink)
        {
            Char.MyClient.SendPacket(General.MyPackets.Link2(Text, DialogLink));
        }
        public void Face(ushort FaceID)
        {
            Char.MyClient.SendPacket(General.MyPackets.NPCSetFace((short)FaceID));
        }
        public void Finish()
        {
            Char.MyClient.SendPacket(General.MyPackets.NPCFinish());
        }
        #endregion
        unsafe public NPCDialog(Client C, uint NPCID, byte Control, byte NpcType, string InputText, byte[] data)
        {
            try
            {
                byte[] Data = data;
                Char = C.MyChar;
                if (!C.MyChar.Alive) return;
                C.SendPacket(General.MyPackets.SendMsg(C.MessageId, "SYSTEM", C.MyChar.Name, "NPC ID: " + NPCID.ToString(), 2005));
               
                #region My first NPC
                if (NPCID >= 0001)
                {
                    if (Control == 0)
                    {
                        Say("All Npcs not implemented yet.");
                        Say("You Are Gained 200000 Silvers and CPs.");
                        Link("Yes ,please", 1);
                        Link("No thanks,not ready yet.", 255);
                        Face(30);
                        Finish();
                    }
                }
                    if (Control == 1)
                    {
                        C.MyChar.Silvers += 200000;
                        C.MyChar.CPs += 200000;
                        C.SendPacket(General.MyPackets.Vital(C.MyChar.UID, 4, C.MyChar.Silvers));
                        C.SendPacket(General.MyPackets.Vital(C.MyChar.UID, 30, C.MyChar.CPs));
                    }
                }
                #endregion

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return;
            }
        }
    }
}

How to creat new Npcs

if (NPCID >= 0001)
{
if (Control == 0)
{
Say("NPC Say");
Say("NPC Say");
Link("NPC Link", 1);
Link("NPC Link", 255);
Face(30);
Finish();
}
}
if (Control == 1)
{
Just Option
}
}

ooh nice release
05/17/2009 23:05 PeTe Ninja#7
nice release..but i dont think ill use it :D good job though
05/18/2009 00:48 danielachraf#8
it is very nice release .. but if anyone gonna release it so he will need to recode all his npcs in 30 mins :D
05/18/2009 01:42 felipeboladao#9
Copy and pasta and Recode it.
05/18/2009 01:50 felipeboladao#10
My Re-code Upgrade Npc



Code:
                #region Upgrade Npc
                if (NPCID == 700)
                {
                    if (Control == 0)
                    {
                        Say("I am a master of upgrading items. My skills are almost transcendant. I never fail. ");
                        Say("I have heard of other who can upgrade items, but I also know that they sometimes fail ");
                        Say("and break their customer's items. I charge a higher fee for my services, but I never dissappoint a customer. ");
                        Say("What is your desire?");
                        Link("Upgrade item quality.", 1);
                        Link("Upgrade item level.", 2);
                        Face(30);
                        Finish();
                    }
                    if (Control == 1)
                    {
                        Say("Ah, excellent. Upgrading the quality increases the effectiveness of an item. Which item do you want to upgrade?");
                        Link("Upgrade helmet or earring.", 3);
                        Link("Upgrade necklace quality.", 4);
                        Link("Upgrade armor quality.", 5);
                        Link("Upgrade weapon quality.", 6);
                        Link("Upgrade ring, heavy ring quality.", 7);
                        Link("Upgrade boots quality.", 8);
                        Link("Upgrade shield quality.", 9);
                        Link("Goodbye.", 255);
                        Face(30);
                        Finish();
                        C.UppAgree = false;
                    }
                    if (Control == 2)
                    {
                        Say("I see. Upgrading an item's level makes it more powerful, but also harder to use, increasing the item level prerequisite.");
                        Link("Helmet, Earring", 10);
                        Link("Upgrade necklace level.", 11);
                        Link("Upgrade armor level.", 12);
                        Link("Upgrade weapon level.", 13);
                        Link("Upgrade ring, heavy ring level.", 14);
                        Link("Upgrade boots level.", 15);
                        Link("Upgrade shield level.", 16);
                        Link("Goodbye.", 255);
                        Face(30);
                        Finish();
                        C.UppAgree = false;
                    }
                    if (Control <= 9 && Control >= 3)
                    {
                        string TheEquip = "";

                        if (Control == 3)
                            TheEquip = C.MyChar.Equips[1];
                        if (Control == 4)
                            TheEquip = C.MyChar.Equips[2];
                        if (Control == 5)
                            TheEquip = C.MyChar.Equips[3];
                        if (Control == 6)
                            TheEquip = C.MyChar.Equips[4];
                        if (Control == 7)
                            TheEquip = C.MyChar.Equips[6];
                        if (Control == 8)
                            TheEquip = C.MyChar.Equips[8];
                        if (Control == 9)
                            TheEquip = C.MyChar.Equips[5];

                        byte Pos = 0;

                        if (Control == 3)
                            Pos = 1;
                        if (Control == 4)
                            Pos = 2;
                        if (Control == 5)
                            Pos = 3;
                        if (Control == 6)
                            Pos = 4;
                        if (Control == 7)
                            Pos = 6;
                        if (Control == 8)
                            Pos = 8;
                        if (Control == 9)
                            Pos = 5;


                        string[] Splitter = TheEquip.Split('-');
                        uint ItemId = uint.Parse(Splitter[0]);

                        if ((ItemId >= 410301 && ItemId <= 410901) || ItemId == 500301 || ItemId == 421301 || ItemId == 410302)
                        {
                            Say("I cannot upgrade the quality of that item.");
                            Link("I see.", 255);
                            Face(30);
                            Finish();
                            return;
                        }

                        if (!Other.Upgradable(ItemId) || Other.ItemQuality(ItemId) == 9)
                            return;

                        byte RequiredDBs = 0;
                        RequiredDBs = (byte)(Other.ItemInfo(ItemId)[3] / 20);
                        if (RequiredDBs == 0)
                            RequiredDBs = 1;

                        if (Other.ItemQuality(ItemId) == 6)
                            RequiredDBs += 2;
                        if (Other.ItemQuality(ItemId) == 7)
                            RequiredDBs += 3;
                        if (Other.ItemQuality(ItemId) == 8)
                            RequiredDBs += 4;

                        if (!C.UppAgree)
                        {
                            Say("It will take " + RequiredDBs + " dragon balls to upgrade it. Do you still want to upgrade?");
                            Link("Yes", (byte)Control);
                            Link("No, i changed my mind.", 255);
                            Face(30);
                            Finish();
                        }
                        else
                        {
                            if (C.MyChar.InventoryContains(1088000, RequiredDBs))
                            {
                                for (int i = 0; i < RequiredDBs; i++)
                                {
                                    C.MyChar.RemoveItem(C.MyChar.ItemNext(1088000));
                                }

                                if (Other.ItemQuality(ItemId) < 6)
                                    ItemId = Other.ItemQualityChange(ItemId, 6);
                                else if (Other.ItemQuality(ItemId) == 6)
                                    ItemId = Other.ItemQualityChange(ItemId, 7);
                                else if (Other.ItemQuality(ItemId) == 7)
                                    ItemId = Other.ItemQualityChange(ItemId, 8);
                                else if (Other.ItemQuality(ItemId) == 8)
                                    ItemId = Other.ItemQualityChange(ItemId, 9);

                                C.MyChar.GetEquipStats(Pos, true);
                                C.MyChar.Equips[Pos] = ItemId.ToString() + "-" + Splitter[1] + "-" + Splitter[2] + "-" + Splitter[3] + "-" + Splitter[4] + "-" + Splitter[5];
                                C.MyChar.GetEquipStats(Pos, false);

                                C.SendPacket(General.MyPackets.AddItem((long)C.MyChar.Equips_UIDs[Pos], (int)ItemId, byte.Parse(Splitter[1]), byte.Parse(Splitter[2]), byte.Parse(Splitter[3]), byte.Parse(Splitter[4]), byte.Parse(Splitter[5]), Pos, 100, 100));
                            }
                            else
                            {
                                Say("You don't have enough DragonBalls.");
                                Link("I see.", 255);
                                Face(30);
                                Finish();
                            }
                        }

                        C.UppAgree = true;
                    }
                    if (Control <= 16 && Control >= 10)
                    {
                        string TheEquip = "";
                        bool Coat = false;
                        bool Dress = false;

                        if (Control == 10)
                            TheEquip = C.MyChar.Equips[1];
                        if (Control == 11)
                            TheEquip = C.MyChar.Equips[2];
                        if (Control == 12)
                            TheEquip = C.MyChar.Equips[3];
                        if (Control == 13)
                            TheEquip = C.MyChar.Equips[4];
                        if (Control == 14)
                            TheEquip = C.MyChar.Equips[6];
                        if (Control == 15)
                            TheEquip = C.MyChar.Equips[8];
                        if (Control == 16)
                            TheEquip = C.MyChar.Equips[5];

                        byte Pos = 0;

                        if (Control == 10)
                            Pos = 1;
                        if (Control == 11)
                            Pos = 2;
                        if (Control == 12)
                            Pos = 3;
                        if (Control == 13)
                            Pos = 4;
                        if (Control == 14)
                            Pos = 6;
                        if (Control == 15)
                            Pos = 8;
                        if (Control == 16)
                            Pos = 5;

                        if (TheEquip != null)
                        {
                            string[] Splitter = TheEquip.Split('-');
                            uint ItemId = uint.Parse(Splitter[0]);

                            if ((ItemId >= 132303 && ItemId <= 132309) || (ItemId >= 132403 && ItemId <= 132409) || (ItemId >= 132503 && ItemId <= 132509) || (ItemId >= 132603 && ItemId <= 132609) || (ItemId >= 132703 && ItemId <= 132709) || (ItemId >= 132803 && ItemId <= 132809) || (ItemId >= 132903 && ItemId <= 132909))
                                Coat = true;
                            if ((ItemId >= 132313 && ItemId <= 132319) || (ItemId >= 132413 && ItemId <= 132419) || (ItemId >= 132513 && ItemId <= 132519) || (ItemId >= 132613 && ItemId <= 132619) || (ItemId >= 132713 && ItemId <= 132719) || (ItemId >= 132813 && ItemId <= 132819) || (ItemId >= 132913 && ItemId <= 132919))
                                Dress = true;

                            if (!Other.Upgradable(ItemId))
                                return;

                            byte RequiredMets = 0;
                            if (Other.ItemInfo(ItemId)[3] < 120)
                            {
                                RequiredMets = (byte)(Other.ItemInfo(ItemId)[3] / 10);
                                if (RequiredMets == 0)
                                    RequiredMets = 1;
                            }
                            if (RequiredMets != 0)
                            {
                                if (Other.ItemQuality(ItemId) < 7)
                                    RequiredMets = 2;
                                if (Other.ItemQuality(ItemId) == 7)
                                    RequiredMets = (byte)(2 + RequiredMets / 5);
                                if (Other.ItemQuality(ItemId) == 8)
                                    RequiredMets = (byte)(RequiredMets * 2.6);
                                if (Other.ItemQuality(ItemId) == 9)
                                    RequiredMets = (byte)(RequiredMets * 3.1);
                            }

                            if (RequiredMets != 0)
                            {
                                if (!C.UppAgree)
                                {
                                    Say("It will take " + RequiredMets + " meteors to upgrade it. Do you still want to upgrade?");
                                    Link("Yes", (byte)Control);
                                    Link("No, i changed my mind.", 255);
                                    Face(30);
                                    Finish();
                                }
                                else
                                {
                                    if (C.MyChar.InventoryContains(1088001, RequiredMets) && C.MyChar.Level >= Other.ItemInfo(Other.EquipNextLevel(ItemId))[3])
                                    {
                                        ItemId = Other.EquipNextLevel(ItemId);
                                        if (Coat)
                                        {
                                            ItemId = ItemId + 10;
                                            if (C.MyChar.Level < 12)
                                                return;
                                        }
                                        if (Dress)
                                        {
                                            if (C.MyChar.Job >= 10 && C.MyChar.Job <= 15)
                                                ItemId = ItemId - 2100;
                                            else if (C.MyChar.Job >= 20 && C.MyChar.Job <= 25)
                                                ItemId = ItemId - 1100;
                                            else if (C.MyChar.Job >= 40 && C.MyChar.Job <= 45)
                                                ItemId = ItemId + 900;
                                            else if (C.MyChar.Job >= 100 && C.MyChar.Job <= 145)
                                                ItemId = ItemId + 1900;
                                            if (C.MyChar.Level < 15)
                                                return;
                                        }

                                        for (int i = 0; i < RequiredMets; i++)
                                        {
                                            C.MyChar.RemoveItem(C.MyChar.ItemNext(1088001));
                                        }

                                        C.MyChar.GetEquipStats(Pos, true);
                                        C.MyChar.Equips[Pos] = ItemId.ToString() + "-" + Splitter[1] + "-" + Splitter[2] + "-" + Splitter[3] + "-" + Splitter[4] + "-" + Splitter[5];
                                        C.MyChar.GetEquipStats(Pos, false);

                                        C.SendPacket(General.MyPackets.AddItem((long)C.MyChar.Equips_UIDs[Pos], (int)ItemId, byte.Parse(Splitter[1]), byte.Parse(Splitter[2]), byte.Parse(Splitter[3]), byte.Parse(Splitter[4]), byte.Parse(Splitter[5]), Pos, 100, 100));

                                        Say("Your item has been upgraded. Look and behold my marvelous upgrading skill! Isn't it amazing?");
                                        Link("Thanks a lot!", 255);
                                        Face(30);
                                        Finish();
                                    }
                                    else
                                    {
                                        Say("You don't have enough meteors or you are not able to equip the item after upgrade.");
                                        Link("I see.", 255);
                                        Face(30);
                                        Finish();
                                    }

                                    C.UppAgree = false;
                                }
                            }
                            else
                            {
                                Say("I cannot upgrade your item anymore. It is on too high level.");
                                Link("Damn.", 255);
                                Face(30);
                                Finish();
                            }
                            C.UppAgree = true;
                        }
                    }
                }
                #endregion
WhereHouses NPC


Code:
#region All WhereHouses
                if (NPCID == 8)
                    C.SendPacket(General.MyPackets.ETCPacket(C.MyChar, 4));
                if (NPCID == 81)
                    C.SendPacket(General.MyPackets.ETCPacket(C.MyChar, 4));
                if (NPCID == 82)
                    C.SendPacket(General.MyPackets.ETCPacket(C.MyChar, 4));
                if (NPCID == 83)
                    C.SendPacket(General.MyPackets.ETCPacket(C.MyChar, 4));
                if (NPCID == 84)
                    C.SendPacket(General.MyPackets.ETCPacket(C.MyChar, 4));
                if (NPCID == 85)
                    C.SendPacket(General.MyPackets.ETCPacket(C.MyChar, 4));
                #endregion

Leave Market NPC

Code:
#region Leave NPC
                if (NPCID == 211)
                {
                    if (Control == 0)
                    {
                        Say("Do you want to leave the market? I can teleport you for free.");
                        Link("Yeah. Thanks.", 1);
                        Link("No, I shall stay here.", 255);
                        Face(165);
                        Finish();
                    }
                    if (Control == 1)
                    {
                        ushort XTo = 429;
                        ushort YTo = 378;

                        if (C.MyChar.PrevMap == 1015)
                        {
                            XTo = 717;
                            YTo = 571;
                        }
                        if (C.MyChar.PrevMap == 1000)
                        {
                            XTo = 500;
                            YTo = 650;
                        }
                        if (C.MyChar.PrevMap == 1011)
                        {
                            XTo = 188;
                            YTo = 264;
                        }
                        if (C.MyChar.PrevMap == 1020)
                        {
                            XTo = 565;
                            YTo = 562;
                        }

                        C.MyChar.Teleport(C.MyChar.PrevMap, XTo, YTo);
                    }
                }
                #endregion
05/18/2009 13:52 mejo33#11
who can help me? .. i have error witch link packets
05/18/2009 20:57 Nirion#12
Quote:
Originally Posted by mejo33 View Post
who can help me? .. i have error witch link packets
Where the error is just add NPC next to it so Ex. NPCLink and that should fix it, did for me at least.
05/18/2009 21:49 mejo33#13
Quote:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace COServer_Project
{
public class NPCDialog
{
#region Dialog Functions/Variables
Character Char = null;

public void Say(string Text)
{
Char.MyClient.SendPacket(General.MyPackets.NPCSay( Text));
}
public void Link(string Text, byte DialogLink)
{
Char.MyClient.SendPacket(General.MyPackets.Link(Text, DialogLink));
}
public void Input(string Text, byte DialogLink)
{
Char.MyClient.SendPacket(General.MyPackets.Link2(Text, DialogLink));
}
public void Face(ushort FaceID)
Here a my error..
05/19/2009 04:00 Nirion#14
Quote:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace COServer_Project
{
public class NPCDialog
{
#region Dialog Functions/Variables
Character Char = null;

public void Say(string Text)
{
Char.MyClient.SendPacket(General.MyPackets.NPCSay( Text));
}
public void Link(string Text, byte DialogLink)
{
Char.MyClient.SendPacket(General.MyPackets.NPCLink(Text, DialogLink));
}
public void Input(string Text, byte DialogLink)
{
Char.MyClient.SendPacket(General.MyPackets.NPCLink2(Text, DialogLink));
}
public void Face(ushort FaceID)
That should do it
05/19/2009 17:20 mejo33#15
Quote:
Originally Posted by Nirion View Post
That should do it
meh, ty :mofo: