[Help,Request]Change item npc

12/18/2008 14:12 ~jochemke~#1
hey,

i've been trying to add a npc that can trade ur item as example lvl 15 super +4 tro armor and hten u can choose the class u want for example warrior it will give a lvl 15 sup +4 warrior armor and takes away ur old +4 item
i wanna do this for all items but i really don't know how i can make it like that

if anyone can help me
ty very much
12/18/2008 17:47 kinshi88#2
If you look at the ItemTypes, you will see patterns in the IDs, you can then use those patterns to change it.
Also look into the Reborn code, that can probably help you.


Edit:

Have a look at this code, just made it by looking at the armor patterns, haven't tested it since I'm unable to.
Note: It uses a different NPC System, so you can't just copy & paste, but you can get sorta how to do it.

Code:
                if (NPCID == 99999)//Armor Swaper
                {
                    byte J = Char.Job;
                    int Change = 0;
                    if (Control == 0)
                    {
                        Say("Would you like to swap your armor for another classes?");
                        Link("Trojan's.", 1);
                        Link("Warrior's.", 2);
                        Link("Taoist's.", 3);
                        Link("Archer's.", 4);
                        Face(20);
                        Finish();
                    }
                    if (Control >= 1 && Control <= 4)
                    {
                        if (Control == 1)//Make Trojan
                        {
                            if (J >= 10 && J <= 15)
                            {
                                Say("You're already that class!");
                                Link("Sorry.", 255);
                                Face(20);
                                Finish();
                            }
                            if (J >= 20 && J <= 25)
                                Change = 1000;
                            if (J >= 40 && J <= 45)
                                Change = 3000;
                            if (J >= 100 && J <= 145)
                                Change = 4000;
                        }
                        else if (Control == 2)//Make Warrior
                        {
                            if (J >= 20 && J <= 25)
                            {
                                Say("You're already that class!");
                                Link("Sorry.", 255);
                                Face(20);
                                Finish();
                            }
                            if (J >= 10 && J <= 15)
                                Change = -1000;
                            if (J >= 40 && J <= 45)
                                Change = 2000;
                            if (J >= 100 && J <= 145)
                                Change = 3000;
                        }
                        else if (Control == 3)//Make Taoist
                        {
                            if (J >= 10 && J <= 15)
                                Change = -4000;
                            if (J >= 20 && J <= 25)
                                Change = -3000;
                            if (J >= 40 && J <= 45)
                                Change = -1000;
                            if (J >= 100 && J <= 145)
                            {
                                Say("You're already that class!");
                                Link("Sorry.", 255);
                                Face(20);
                                Finish();
                            }
                        }
                        else if (Control == 4)//Make Archer
                        {
                            if (J >= 10 && J <= 15)
                                Change = -2000;
                            if (J >= 20 && J <= 25)
                                Change = -1000;
                            if (J >= 40 && J <= 45)
                            {
                                Say("You're already that class!");
                                Link("Sorry.", 255);
                                Face(20);
                                Finish();
                            }
                            if (J >= 100 && J <= 145)
                                Change = 1000;
                        }

                        string[] Armor_Sp = Char.Equips[3].Split('-');//Get the Armors full ID split up
                        string Armor_ID = Armor_Sp[0];//Armor ID
                        string Armor_Details = Armor_Sp[1] + "-" + Armor_Sp[2] + "-" + Armor_Sp[3] + "-" + Armor_Sp[4] + "-" + Armor_Sp[5];//Detials; +, -, HP, etc
                        uint F_Armor = Convert.ToUInt32(Convert.ToUInt32(Armor_ID) + Change);//Change the ID to the new ID

                        Char.RemoveItem(Char.Equips_UIDs[3]);//Delete old Armor

                        Char.AddItem(F_Armor + "-" + Armor_Details, 3, (uint)General.Rand.Next(346623472));//Add New Armor
                        //NOTE: Change the "3" to "0" if you want to add the item to your inventory instead of equiping it.

                        //Send Packets =P
                        World.UpdateSpawn(Char);
                        Char.SendEquips(true);

                        Say("There's your new armor!");
                        Link("Thanks!.", 255);
                        Face(20);
                        Finish();
                    }
                }
12/18/2008 18:46 ~jochemke~#3
kk changed it so it works on lotf /u just deleted some things right?
gonna test it right now
tnx for ur help already
12/18/2008 22:31 tao4229#4
Yikes... Sending a lot of unneeded packets there :\
Code:
                        Char.RemoveItem(Char.Equips_UIDs[3]);//Delete old Armor

                        Char.AddItem(F_Armor + "-" + Armor_Details, 3, (uint)General.Rand.Next(346623472));//Add New Armor
                        //NOTE: Change the "3" to "0" if you want to add the item to your inventory instead of equiping it.

                        //Send Packets =P
                        //Char.MyClient.SendPacket(General.MyPackets.Vital(Char.UID, 26, Char.GetStat())); Don't need this, unless you updated their statflags, which for all I can see you didn't.
                        //Char.MyClient.SendPacket(General.MyPackets.Vital(Char.UID, 12, ulong.Parse(Char.Avatar.ToString() + Char.Model.ToString()))); Didn't change model either.
                        World.UpdateSpawn(Char);

                        //World.SpawnMeToOthers(Char, false); Don't need this, its the same as UpdateSpawn pretty much.
                        //World.SpawnOthersToMe(Char, false); Why do you need to get the entites around them when you change armor??
                        Char.SendEquips(true);

                        Say("There's your new armor!");
                        Link("Thanks!.", 255);
                        Face(20);
                        Finish();
12/18/2008 23:46 kinshi88#5
Quote:
Originally Posted by tao4229 View Post
Yikes... Sending a lot of unneeded packets there :\
Code:
                        Char.RemoveItem(Char.Equips_UIDs[3]);//Delete old Armor

                        Char.AddItem(F_Armor + "-" + Armor_Details, 3, (uint)General.Rand.Next(346623472));//Add New Armor
                        //NOTE: Change the "3" to "0" if you want to add the item to your inventory instead of equiping it.

                        //Send Packets =P
                        //Char.MyClient.SendPacket(General.MyPackets.Vital(Char.UID, 26, Char.GetStat())); Don't need this, unless you updated their statflags, which for all I can see you didn't.
                        //Char.MyClient.SendPacket(General.MyPackets.Vital(Char.UID, 12, ulong.Parse(Char.Avatar.ToString() + Char.Model.ToString()))); Didn't change model either.
                        World.UpdateSpawn(Char);

                        //World.SpawnMeToOthers(Char, false); Don't need this, its the same as UpdateSpawn pretty much.
                        //World.SpawnOthersToMe(Char, false); Why do you need to get the entites around them when you change armor??
                        Char.SendEquips(true);

                        Say("There's your new armor!");
                        Link("Thanks!.", 255);
                        Face(20);
                        Finish();
Yes I know =P
12/19/2008 12:12 ~jochemke~#6
well i doesn't work yet
but i'm trying to get it to work
and i don't want help yet cause then i learned nothing
now i will learn it or something xD