i discovered a bug on my magic artisan, and because i'm not a pro coder yet (only 2 weeks of learning) i couldn't solve the problem or figure out where it comes from
i'm not used to that kind of codes(too difficult for me), my first interest is knowing how is that npc working and how that bug is happening, then fix it
after upgrading the item level many times(everytime, the attack madly decreases) i end up with this
this is the npc code:
PHP Code:
#region Magic Artisan
case 10062:
{
switch (npcRequest.OptionID)
{
case 0:
{
dialog.Text("Hello! I can always succeed in upgrading item quality as i´ve penetrated the mystery of their powers.");
dialog.Text("But I`II ask for a few more dragon balls tha Artisan Wind.");
dialog.Text("I can also upgrade or lower item levels. How can I help you?");
dialog.Option("Upgrade The Quality.", 3);
dialog.Option("Upgrade The Level.", 1);
dialog.Option("Lower Equipment Level.", 2);
dialog.Send();
break;
}
case 1:
case 2:
case 3:
{
int aut = npcRequest.OptionID * 10;
dialog.Text("Select which item's details you want to change?");
dialog.Option("Headgear.", (byte)(aut + 1));
dialog.Option("Necklace/Bag.", (byte)(aut + 2));
dialog.Option("Armor.", (byte)(aut + 3));
dialog.Option("Main Weapon.", (byte)(aut + 4));
dialog.Option("Left Weapon/Shield.", (byte)(aut + 5));
dialog.Option("Heavy Ring, Ring, Bracelet.", (byte)(aut + 6));
dialog.Option("Boots.", (byte)(aut + 8));
dialog.Option("No need thanks", 255);
dialog.Send();
break;
}
case 100:
{
if (client.SelectedItem == 0)
return;
var item = client.Equipment.TryGetItem(client.SelectedItem);
var itemdetail = Conquer_Online_Server.Database.ConquerItemInformation.BaseInformations[item.ID];
Conquer_Online_Server.Database.ConquerItemInformation infos = new Conquer_Online_Server.Database.ConquerItemInformation(item.ID, item.Plus);
switch (client.UpdateType)
{
case 1:
case 2:
{
//Cost: 36
//Metscrolls: 4
byte cost = (byte)(itemdetail.Level / 5);
byte scrolls = 0;
bool useScrolls = false;
byte extraScroll = 0;
int addMets = 0;
cost += (byte)((item.ID % 10) / 3);
cost += (byte)(itemdetail.Level / 10);
uint id = 1088001;
if (client.UpdateType == 2)
id++;
foreach (IConquerItem scroll in client.Inventory.Objects)
if (scroll.ID == 720027)
scrolls++;
if (cost % 10 != 0)
{
addMets = 10 - (cost % 10);
extraScroll = 1;
}
if (scrolls >= (cost / 10) + extraScroll)
useScrolls = true;
if (client.Inventory.Contains(id, cost) || useScrolls)
{
if (useScrolls)
{
client.Inventory.Remove(720027, Convert.ToByte((cost / 10) + extraScroll));
client.Inventory.Add(1088001, 0, (byte)addMets);
}
else
client.Inventory.Remove(id, cost);
client.UnloadItemStats(item, false);
if (client.UpdateType == 1)
{
Conquer_Online_Server.Database.ConquerItemInformation infos2 = new Conquer_Online_Server.Database.ConquerItemInformation(infos.CalculateUplevel(), item.Plus);
if (infos2.BaseInformation.ID == infos.BaseInformation.ID)
return;
if (client.Entity.Level < infos2.BaseInformation.Level)
{
dialog.Text("You need level " + infos2.BaseInformation.Level + " first.");
dialog.Option("Ahh sorry.", 255);
dialog.Send();
client.SelectedItem = 0;
client.UpdateType = 0;
return;
}
item.ID = infos.CalculateUplevel();
}
else
item.ID = infos.CalculateDownlevel();
Conquer_Online_Server.Database.ConquerItemTable.UpdateItemID(item, client);
item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
item.Send(client);
_String str = new _String(true);
str.UID = client.Entity.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("perfect");
client.Screen.SendScreen(str, true);
client.LoadItemStats(item);
client.Equipment.UpdateEntityPacket();
}
break;
}
case 3:
{
byte cost = (byte)(itemdetail.Level / 30);
cost += (byte)((item.ID % 10) / 2);
uint id = 1088000;
if (client.Inventory.Contains(id, cost))
{
client.Inventory.Remove(id, cost);
client.UnloadItemStats(item, false);
if (item.ID % 10 < 5)
item.ID += 5 - item.ID % 10;
item.ID++;
Conquer_Online_Server.Database.ConquerItemTable.UpdateItemID(item, client);
item.Mode = Conquer_Online_Server.Game.Enums.ItemMode.Update;
item.Send(client);
_String str = new _String(true);
str.UID = client.Entity.UID;
str.TextsCount = 1;
str.Type = _String.Effect;
str.Texts.Add("perfect");
client.Screen.SendScreen(str, true);
client.LoadItemStats(item);
client.Equipment.UpdateEntityPacket();
}
break;
}
}
break;
}
default:
{
if (npcRequest.OptionID == 255)
break;
client.SelectedItem = (byte)(npcRequest.OptionID % 10);
client.UpdateType = (byte)(npcRequest.OptionID / 10);
if (client.Equipment.Free(client.SelectedItem))
{
dialog.Text("You have to be wearing the selected item.");
dialog.Option("I'll just leave", 255);
dialog.Send();
return;
}
var item = client.Equipment.TryGetItem(client.SelectedItem);
var itemdetail = Conquer_Online_Server.Database.ConquerItemInformation.BaseInformations[item.ID];
if (itemdetail == null)
{
dialog.Text("An error occured. Please relogin and try again.");
dialog.Option("Ok.", 255);
dialog.Send();
return;
}
switch (client.UpdateType)
{
case 1:
case 2:
{
if (itemdetail.Level == Conquer_Online_Server.Network.PacketHandler.ItemMaxLevel(client.SelectedItem) && client.UpdateType == 1)
{
dialog.Text("This item's level cannot be upgraded anymore.");
dialog.Option("Ahh sorry.", 255);
dialog.Send();
client.SelectedItem = 0;
client.UpdateType = 0;
return;
}
if (itemdetail.Level == Conquer_Online_Server.Network.PacketHandler.ItemMinLevel(client.SelectedItem) && client.UpdateType == 2)
{
dialog.Text("This item's level cannot be downgraded anymore.");
dialog.Option("Ahh sorry.", 255);
dialog.Send();
client.SelectedItem = 0;
client.UpdateType = 0;
return;
}
byte cost = (byte)(itemdetail.Level / 5);
cost += (byte)((item.ID % 10) / 3);
cost += (byte)(itemdetail.Level / 10);
dialog.Text("It will cost you " + cost + " meteor" + (client.UpdateType == 2 ? " tears" : "s") + ". Do you accept?");
dialog.Option("Yes please.", 100);
dialog.Option("No thanks.", 255);
dialog.Send();
break;
}
case 3:
{
if (item.ID % 10 == 9)
{
dialog.Text("This item's quality cannot be upgraded anymore.");
dialog.Option("Ahh sorry.", 255);
dialog.Send();
client.SelectedItem = 0;
client.UpdateType = 0;
return;
}
byte cost = (byte)(itemdetail.Level / 30);
cost += (byte)((item.ID % 10) / 2);
dialog.Text("It will cost you " + cost + " dragonballs. Do you accept?");
dialog.Option("Yes please.", 100);
dialog.Option("No thanks.", 255);
dialog.Send();
break;
}
}
break;
}
}
break;
}
#endregion
i hope to solve that problem(with your help) or at least learn something new






