public int BlackImbue(Equipment Item, ref ImbueStat stat, ImbueItem imbueitem, int success) { int value = (int)(Item.RequiredLevel) + imbueitem.IncreaseValue; value += (int)(((value * 0.1) * Item.Plus) + ((imbueitem.ImbueChance / 5) * Item.Plus)); value *= success; if (Item is Hand) { Item.Damage += (short)value; stat = ImbueStat.Damage; } if (Item is Cape) { if (Item.Damage > 0 && Item.Defence > 0) { Item.Defence += (short)value; Item.Damage += (short)value; stat = ImbueStat.DefenseAndDamage; } else { Item.Defence += (short)value; stat = ImbueStat.Defense; } } if (Item is Head) { Item.AttackRating += (short)value; stat = ImbueStat.AttackRating; } if (Item is Body) { Item.Defence += (short)value; stat = ImbueStat.Defense; } if (Item is Feet) { value = (int)(Math.Round((double)(value / 50))) + 1; Item.Critical += (short)value; stat = ImbueStat.CriticalHit; } if (Item is Ring) { Item.IncMaxLife += (short)value; stat = ImbueStat.MaxLife; } if (Item is Necklace) { Item.IncMaxMana += (short)value; stat = ImbueStat.MaxMana; } return(value); }
public BaseItem PickupItem(int mapItemId, Client c, short mapItemAmount) { MapItem m = null; try { m = mapItems.Where(x => x.MapItemID == mapItemId).First(); } catch (Exception) { return(null); } BaseItem item = null; if (m.DroppedByCharacterID == 0 || m.DroppedByCharacterID == c.MyCharacter.CharacterId) { if (m.bType != (byte)bType.Jeon) { if (m.ItemID != 0) { item = itemDataManager.GetItemByItemID(m.ItemID); } else { item = itemDataManager.GetItemByReferenceID(m.ReferenceID); } BagSlot bagSlot = gameEngine.TryPickToBags(c.MyCharacter.Bags.ToArray(), item); item.Slot = bagSlot.Slot; item.Bag = bagSlot.Bag; mapItemManager.DeleteMapItem(m.MapItemID, 0); mapItems.Remove(m); item.OwnerID = c.MyCharacter.CharacterId; if (item.ItemID != 0) { itemDataManager.UpdateItem(item); } else { item.ItemID = itemDataManager.InsertItem(item); if (item is Equipment) { // later add chance to get these items blabla Equipment Item = item as Equipment; ImbueStat stat = ImbueStat.None; ImbueItem imbueitem = new ImbueItem { ImbueChance = 1, IncreaseValue = 1, }; // Possible plus for drop if (XiahRandom.PercentSuccess(40)) { int plus = gameEngine.RandomChance(0, 5); for (int i = 0; i < plus; i++) { gameEngine.BlackImbue(Item, ref stat, imbueitem, 1); Item.Plus++; } } if (XiahRandom.PercentSuccess(40)) { // Possible slvl for drop int slvl = gameEngine.RandomChance(0, 5); for (int i = 0; i < slvl && !(Item is Cape); i++) { gameEngine.WhiteImbue(Item, ref stat, imbueitem); Item.Slvl++; } } item = Item; itemDataManager.UpdateItem(item); } } } else { item = itemDataManager.GetItemByReferenceID(m.ReferenceID); mapItemManager.DeleteMapItem(m.MapItemID, 0); mapItems.Remove(m); item.Amount = mapItemAmount; } } else { c.Send(PacketEngine.PacketManager.SendPickUpText(0, 0, 0)); // send pickuperror blabal } return(item); }
public int WhiteImbue(Equipment Item, ref ImbueStat stat, ImbueItem imbueitem) { int value = (int)(Item.RequiredLevel); value += (int)(((value * 0.1) * Item.Slvl) + ((imbueitem.ImbueChance / 5) * Item.Slvl)); List <ImbueStat> WhiteStats = new List <ImbueStat>(); WhiteStats.Add(ImbueStat.Damage); WhiteStats.Add(ImbueStat.Defense); WhiteStats.Add(ImbueStat.AttackRating); WhiteStats.Add(ImbueStat.MaxLife); WhiteStats.Add(ImbueStat.MaxMana); WhiteStats.Add(ImbueStat.LifeReg); WhiteStats.Add(ImbueStat.ManaReg); WhiteStats.Add(ImbueStat.CriticalHit); if (Item is Cape) { WhiteStats.Remove(ImbueStat.Damage); WhiteStats.Remove(ImbueStat.Defense); } if (Item is Hand) { Hand weapon = Item as Hand; WhiteStats.Remove(weapon.NotWithWhite); } if (Item is Head) { Head hat = Item as Head; WhiteStats.Remove(hat.NotWithWhite); } if (Item is Body) { Body armor = Item as Body; WhiteStats.Remove(armor.NotWithWhite); } if (Item is Ring) { Ring ring = Item as Ring; value *= (int)2.94; } if (Item is Necklace) { Necklace neck = Item as Necklace; value *= (int)1.85; } if (imbueitem.ImbueData == 0) { int randomStat = Random.Next(0, WhiteStats.Count); stat = WhiteStats[randomStat]; } else { switch (imbueitem.ImbueData) { case 2: stat = ImbueStat.Damage; break; case 3: stat = ImbueStat.Defense; break; case 4: stat = ImbueStat.AttackRating; break; case 5: stat = ImbueStat.CriticalHit; break; case 6: stat = ImbueStat.MaxLife; break; case 7: stat = ImbueStat.MaxMana; break; case 8: stat = ImbueStat.LifeReg; break; case 9: stat = ImbueStat.ManaReg; break; default: stat = ImbueStat.CriticalHit; break; } } switch (stat) { case ImbueStat.Damage: Item.Damage += (short)value; break; case ImbueStat.Defense: Item.Defence += (short)value; break; case ImbueStat.AttackRating: Item.AttackRating += (short)value; break; case ImbueStat.MaxLife: Item.IncMaxLife += (short)value; break; case ImbueStat.MaxMana: Item.IncMaxMana += (short)value; break; case ImbueStat.LifeReg: Item.IncLifeRegen += (short)value; break; case ImbueStat.ManaReg: Item.IncManaRegen += (short)value; break; case ImbueStat.CriticalHit: value = (int)(Math.Round((double)(value / 50))) + 1; Item.Critical += (short)value; break; } return(value); }
void c_ClientAcceptImbueItemInfo(object sender, ClientAcceptImbueItemEventArgs e) { Client c = (Client)sender; AcceptImbueItem i = e.Info; Equipment Item = null; BaseItem item = null; BaseItem imbueItem1 = null; ImbueError error; ImbueStat stat = ImbueStat.CriticalHit; try { item = c.MyCharacter.Bags[i.ToImbueItemBag - 1].Items.Single(x => (x.ItemID == i.ToImbueItemID && x.Slot == i.ToImbueItemSlot)); if (item is Equipment) { Item = item as Equipment; } imbueItem1 = c.MyCharacter.Bags[i.ImbueItem1Bag - 1].Items.Single(x => (x.ItemID == i.ImbueItem1ID)); double SuccessChance = 33.3f; // flat 1/3 chance as there chance to success, fail, and drop so :/ if (Item.Plus == 0 && imbueItem1 is Black) { SuccessChance = 100; } if (imbueItem1 is ImbueItem) { ImbueItem imbueitem = imbueItem1 as ImbueItem; SuccessChance += (double)imbueitem.ImbueChance; } // ADD UBER LEET REMOVE FROM BAG & SAVE DATABASE YOU LOST THE ITEM PLXO int value = 0; if (itemDataManager.PercentSuccess(SuccessChance)) { value = 1; // just - value to decrease xd Item.Damage += (short)value; Item.Plus++; error = ImbueError.Success; stat = ImbueStat.Damage; } else { if (Item.Plus >= 4 && itemDataManager.PercentSuccess(30)) { // I DROP YO STATS } error = ImbueError.FailedToRemake; stat = ImbueStat.None; value = 0; } c.Send(PacketManager.SendImbueMessage(error, stat, value, Item)); c.Send(PacketManager.SendRemoveItem(i.ImbueItem1Bag, i.ImbueItem1Slot)); Item.ImbueTries++; c.Send(PacketManager.SendImbuedItem((BaseItem)Item)); itemDataManager.UpdateItem((BaseItem)Item); } catch { } }
public List <BaseItem> GetAllItemsInNpcBag(byte bag, int npcId) { DbParameter bagIdParameter = _db.CreateParameter(DbNames.GETALLNPCITEMSBYBAGID_BAGID_PARAMETER, bag); bagIdParameter.DbType = DbType.Byte; DbParameter characterIdParameter = _db.CreateParameter(DbNames.GETALLNPCITEMSBYBAGID_NPCID_PARAMETER, npcId); characterIdParameter.DbType = DbType.Int32; List <BaseItem> items = new List <BaseItem>(); _db.Open(); DbDataReader reader = _db.ExcecuteReader(DbNames.GETALLNPCITEMSBYBAGID_STOREDPROC, CommandType.StoredProcedure, bagIdParameter, characterIdParameter); int ordinalITEM_REFERENCEID = reader.GetOrdinal(DbNames.ITEM_REFID); int ordinalITEM_BTYPE = reader.GetOrdinal(DbNames.ITEM_BTYPE); int ordinalITEM_BKIND = reader.GetOrdinal(DbNames.ITEM_BKIND); int ordinalITEM_VISUALID = reader.GetOrdinal(DbNames.ITEM_VISUALID); int ordinalITEM_CLASS = reader.GetOrdinal(DbNames.ITEM_CLASS); int ordinalITEM_AMOUNT = reader.GetOrdinal(DbNames.ITEM_AMOUNT); int ordinalITEM_PRICE = reader.GetOrdinal(DbNames.ITEM_PRICE); int ordinalITEM_LEVEL = reader.GetOrdinal(DbNames.ITEM_LEVEL); int ordinalITEM_DEX = reader.GetOrdinal(DbNames.ITEM_DEX); int ordinalITEM_STR = reader.GetOrdinal(DbNames.ITEM_STR); int ordinalITEM_STA = reader.GetOrdinal(DbNames.ITEM_STA); int ordinalITEM_ENE = reader.GetOrdinal(DbNames.ITEM_ENE); int ordinalITEM_DURABILITY = reader.GetOrdinal(DbNames.ITEM_DURABILITY); int ordinalITEM_DAMAGE = reader.GetOrdinal(DbNames.ITEM_DAMAGE); int ordinalITEM_DEFENCE = reader.GetOrdinal(DbNames.ITEM_DEFENCE); int ordinalITEM_ATTACKRATING = reader.GetOrdinal(DbNames.ITEM_ATTACKRATING); int ordinalITEM_ATTACKSPEED = reader.GetOrdinal(DbNames.ITEM_ATTACKSPEED); int ordinalITEM_ATTACKRANGE = reader.GetOrdinal(DbNames.ITEM_ATTACKRANGE); int ordinalITEM_INCMAXLIFE = reader.GetOrdinal(DbNames.ITEM_INCMAXLIFE); int ordinalITEM_INCMAXMANA = reader.GetOrdinal(DbNames.ITEM_INCMAXMANA); int ordinalITEM_LIFEREGEN = reader.GetOrdinal(DbNames.ITEM_LIFEREGEN); int ordinalITEM_MANAREGEN = reader.GetOrdinal(DbNames.ITEM_MANAREGEN); int ordinalITEM_CRITICAL = reader.GetOrdinal(DbNames.ITEM_CRITICAL); int ordinalITEM_TOMAPID = reader.GetOrdinal(DbNames.ITEM_TOMAPID); int ordinalITEM_IMBUERATE = reader.GetOrdinal(DbNames.ITEM_IMBUERATE); int ordinalITEM_IMBUEINCREASE = reader.GetOrdinal(DbNames.ITEM_IMBUEINCREASE); int ordinalITEM_BOOKSKILLID = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLID); int ordinalITEM_BOOKSKILLLEVEL = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLLEVEL); int ordinalITEM_BOOKSKILLDATA = reader.GetOrdinal(DbNames.ITEM_BOOKSKILLDATA); int ordinalITEM_MAXPOLISHTRIES = reader.GetOrdinal(DbNames.ITEM_MAXPOLISHTRIES); int ordinalITEM_MAXIMBUETRIES = reader.GetOrdinal(DbNames.ITEM_MAXIMBUES); int ordinalITEM_BAG = reader.GetOrdinal(DbNames.ITEM_BAG); int ordinalITEM_SLOT = reader.GetOrdinal(DbNames.ITEM_SLOT); int ordinalITEM_SIZEX = reader.GetOrdinal(DbNames.ITEM_SIZEX); int ordinalITEM_SIZEY = reader.GetOrdinal(DbNames.ITEM_SIZEY); while (reader.Read()) { BaseItem b = null; int BType = reader.GetByte(ordinalITEM_BTYPE); int BKind = reader.GetByte(ordinalITEM_BKIND); if (BType == (byte)bType.Weapon || BType == (byte)bType.Clothes || BType == (byte)bType.Hat || BType == (byte)bType.Necklace || BType == (byte)bType.Ring || BType == (byte)bType.Shoes || BType == (byte)bType.Cape) { if (BKind == (byte)bKindWeapons.Sword && BType == (byte)bType.Weapon) { b = new Sword(); } if (BKind == (byte)bKindWeapons.Blade && BType == (byte)bType.Weapon) { b = new Blade(); } if (BKind == (byte)bKindWeapons.Fan && BType == (byte)bType.Weapon) { b = new Fan(); } if (BKind == (byte)bKindWeapons.Brush && BType == (byte)bType.Weapon) { b = new Brush(); } if (BKind == (byte)bKindWeapons.Claw && BType == (byte)bType.Weapon) { b = new Claw(); } if (BKind == (byte)bKindWeapons.Axe && BType == (byte)bType.Weapon) { b = new Axe(); } if (BKind == (byte)bKindWeapons.Talon && BType == (byte)bType.Weapon) { b = new Talon(); } if (BKind == (byte)bKindWeapons.Tonfa && BType == (byte)bType.Weapon) { b = new Tonfa(); } if (BKind == (byte)bKindWeapons.Hammer && BType == (byte)bType.Weapon) { b = new Hammer(); } if (BKind == (byte)bKindArmors.SwordMan && BType == (byte)bType.Clothes) { b = new Clothes(); } if (BKind == (byte)bKindArmors.Mage && BType == (byte)bType.Clothes) { b = new Dress(); } if (BKind == (byte)bKindArmors.Warrior && BType == (byte)bType.Clothes) { b = new Armor(); } if (BKind == (byte)bKindArmors.GhostFighter && BType == (byte)bType.Clothes) { b = new LeatherClothes(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Hat) { b = new Hood(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Hat) { b = new Tiara(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Hat) { b = new Helmet(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Hat) { b = new Hat(); } if (BKind == (byte)bKindHats.SwordMan && BType == (byte)bType.Shoes) { b = new SmBoots(); } if (BKind == (byte)bKindHats.Mage && BType == (byte)bType.Shoes) { b = new MageBoots(); } if (BKind == (byte)bKindHats.Warrior && BType == (byte)bType.Shoes) { b = new WarriorShoes(); } if (BKind == (byte)bKindHats.GhostFighter && BType == (byte)bType.Shoes) { b = new GhostFighterShoes(); } if (BKind == 0 && BType == (byte)bType.Ring) { b = new Ring(); } if (BKind == 0 && BType == (byte)bType.Necklace) { b = new Necklace(); } if (BType == (byte)bType.Cape) { b = new Cape(); Cape c = b as Cape; c.MaxPolishImbueTries = reader.GetInt16(ordinalITEM_MAXPOLISHTRIES); } Equipment e = b as Equipment; e.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); e.RequiredDexterity = reader.GetInt16(ordinalITEM_DEX); e.RequiredStrength = reader.GetInt16(ordinalITEM_STR); e.RequiredStamina = reader.GetInt16(ordinalITEM_STA); e.RequiredEnergy = reader.GetInt16(ordinalITEM_ENE); e.Durability = reader.GetInt32(ordinalITEM_DURABILITY); e.MaxDurability = e.Durability; e.Damage = reader.GetInt16(ordinalITEM_DAMAGE); e.Defence = reader.GetInt16(ordinalITEM_DEFENCE); e.AttackRating = reader.GetInt16(ordinalITEM_ATTACKRATING); e.AttackSpeed = reader.GetInt16(ordinalITEM_ATTACKSPEED); e.AttackRange = reader.GetInt16(ordinalITEM_ATTACKRANGE); e.IncMaxLife = reader.GetInt16(ordinalITEM_INCMAXLIFE); e.IncMaxMana = reader.GetInt16(ordinalITEM_INCMAXMANA); e.IncLifeRegen = reader.GetInt16(ordinalITEM_LIFEREGEN); e.IncManaRegen = reader.GetInt16(ordinalITEM_MANAREGEN); e.Critical = reader.GetInt16(ordinalITEM_CRITICAL); e.MaxImbueTries = reader.GetByte(ordinalITEM_MAXIMBUETRIES); } if (BType == (byte)bType.ImbueItem) { if (BKind == (byte)bKindStones.Black) { b = new Black(); } if (BKind == (byte)bKindStones.White) { b = new White(); } if (BKind == (byte)bKindStones.Red) { b = new Red(); } if (BKind == (byte)bKindStones.Dragon) { b = new Dragon(); } ImbueItem im = b as ImbueItem; im.ImbueChance = reader.GetInt16(ordinalITEM_IMBUERATE); im.IncreaseValue = reader.GetInt16(ordinalITEM_IMBUEINCREASE); } if (BType == (byte)bType.Potion) { if (BKind == (byte)bKindPotions.Normal) { b = new Potion(); } if (BKind == (byte)bKindPotions.Elixir) { b = new Elixir(); } PotionItem pot = b as PotionItem; pot.HealHp = reader.GetInt16(ordinalITEM_INCMAXLIFE); pot.HealMana = reader.GetInt16(ordinalITEM_INCMAXMANA); } if (BType == (byte)bType.Book) { if (BKind == (byte)bKindBooks.SoftBook) { b = new SoftBook(); } if (BKind == (byte)bKindBooks.HardBook) { b = new HardBook(); } BookItem book = b as BookItem; book.RequiredClass = reader.GetByte(ordinalITEM_CLASS); book.RequiredLevel = reader.GetInt16(ordinalITEM_LEVEL); book.SkillID = reader.GetInt32(ordinalITEM_BOOKSKILLID); book.SkillLevel = reader.GetByte(ordinalITEM_BOOKSKILLLEVEL); book.SkillData = reader.GetInt32(ordinalITEM_BOOKSKILLDATA); } if (BType == (byte)bType.Bead) { if (BKind == (byte)bKindBeads.Normal) { b = new Bead(); } BeadItem bead = b as BeadItem; bead.ToMapID = reader.GetInt32(ordinalITEM_TOMAPID); } b.ReferenceID = reader.GetInt16(ordinalITEM_REFERENCEID); b.VisualID = reader.GetInt16(ordinalITEM_VISUALID); b.Bag = reader.GetByte(ordinalITEM_BAG); b.Slot = reader.GetByte(ordinalITEM_SLOT); b.bType = reader.GetByte(ordinalITEM_BTYPE); b.bKind = reader.GetByte(ordinalITEM_BKIND); b.RequiredClass = reader.GetByte(ordinalITEM_CLASS); b.Amount = reader.GetInt16(ordinalITEM_AMOUNT); b.SizeX = reader.GetByte(ordinalITEM_SIZEX); b.SizeY = reader.GetByte(ordinalITEM_SIZEY); b.Price = reader.GetInt32(ordinalITEM_PRICE); items.Add(b); } reader.Close(); _db.Close(); return(items); }