public Enchant(Enchant enchant) { enchantType = enchant.enchantType; effectValue = enchant.effectValue; effectDuration = enchant.effectDuration; strength = 1; }
private static void HandleBeginEnchant(GameSession session, PacketReader packet) { EnchantType type = (EnchantType)packet.ReadByte(); long itemUid = packet.ReadLong(); IInventory inventory = session.Player.Inventory; Item item = inventory.GetFromInventoryOrEquipped(itemUid); if (item is null) { return; } if (item.DisableEnchant || EnchantLimitMetadataStorage.IsEnchantable(item.GetItemType(), item.Level, item.EnchantLevel)) { session.Send(ItemEnchantPacket.Notice((short)ItemEnchantError.ItemCannotBeEnchanted)); return; } if (item.Type is ItemType.Necklace or ItemType.Belt or ItemType.Earring or ItemType.Ring or ItemType.Shield or ItemType.Spellbook) { session.Send(ItemEnchantPacket.Notice((short)ItemEnchantError.ItemCannotBeEnchanted)); return; } session.Player.ItemEnchant = GetEnchantInfo(item, type); // Get stat difference between current and next enchant level Dictionary <StatAttribute, ItemStat> statDiff = GetEnchantStatDiff(item.Stats.Enchants, session.Player.ItemEnchant.Stats); session.Send(ItemEnchantPacket.BeginEnchant(type, item, session.Player.ItemEnchant, statDiff)); }
public EnchantScroll(EnchantType enchantType, EnchantTarget enchantTarget, CrystalTypeId enchantCrystall, byte bonus) { Type = enchantType; Target = enchantTarget; Crystall = enchantCrystall; Bonus = bonus; }
public ExecEnchantItem(EnchantType type, int count) : base(ExecutableType.enchant, count,Formuls.CostEnchant(type,MainController.Instance.PlayerData.Level)) { IconSprite = UnityEngine.Resources.Load<Sprite>("sprites/Enchant/" + type.ToString()); ItemType = type; name = type.ToString(); }
public EnchantScroll(EnchantType enchantType, EnchantTarget enchantTarget, ItemTemplate.L2ItemGrade enchantCrystall, byte bonus) { this.Type = enchantType; this.Target = enchantTarget; this.Crystall = enchantCrystall; this.bonus = bonus; }
public EnchantData(EnchantType Type, Byte[] Unused1, Byte[] Unused2, EnchantFlags Flags, Byte[] Unused3) { this.Type = Type; this.Unused1 = Unused1; this.Unused2 = Unused2; this.Flags = Flags; this.Unused3 = Unused3; }
public EnchantData(string Tag = null) : base(Tag) { Type = new EnchantType(); Unused1 = new byte[4]; Unused2 = new byte[4]; Flags = new EnchantFlags(); Unused3 = new byte[3]; }
/// <summary> /// Returns the index of the first EnchantType Type in EnchantList /// Returns -1 if none /// </summary> public int Contains(List <Enchant> EnchantList, EnchantType Type) { for (int i = 0; i < EnchantList.Count; i++) { if (EnchantList[i].enchantType == Type) { return(i); } } return(-1); }
public static PacketWriter BeginEnchant(EnchantType type, Item item, ItemEnchant enchantInfo, Dictionary <StatAttribute, ItemStat> stats) { PacketWriter pWriter = PacketWriter.Of(SendOp.ItemEnchant); pWriter.Write(ItemEnchantPacketMode.BeginEnchant); pWriter.Write(type); pWriter.WriteLong(item.Uid); pWriter.WriteByte((byte)enchantInfo.Ingredients.Count); foreach (EnchantIngredient ingredient in enchantInfo.Ingredients) { pWriter.WriteInt(); pWriter.Write(ingredient.Tag); pWriter.WriteInt(ingredient.Amount); } pWriter.WriteShort(); pWriter.WriteInt(enchantInfo.Stats.Count); foreach (ItemStat stat in stats.Values) { pWriter.Write(stat.ItemAttribute); pWriter.WriteInt(stat.Flat); pWriter.WriteFloat(stat.Rate); } if (type is EnchantType.Ophelia) { WriteEnchantRates(pWriter, enchantInfo.Rates); pWriter.WriteLong(); pWriter.WriteLong(); pWriter.WriteByte(1); } // Item copies required if (type is EnchantType.Ophelia or EnchantType.Peachy) { pWriter.WriteInt(enchantInfo.CatalystAmountRequired > 0 ? item.Id : 0); pWriter.WriteShort((short)(enchantInfo.CatalystAmountRequired > 0 ? item.Rarity : 0)); pWriter.WriteInt(enchantInfo.CatalystAmountRequired > 0 ? item.Amount : 0); } return(pWriter); }
private static ItemEnchant GetEnchantInfo(Item item, EnchantType type) { ItemEnchant itemEnchantStats = new(type, item.Uid, item.EnchantLevel); Script script = ScriptLoader.GetScript("Functions/calcEnchantValues"); DynValue successRateScriptResult = script.RunFunction("calcEnchantRates", item.EnchantLevel + 1); DynValue ingredientsResult = script.RunFunction("calcEnchantIngredients", item.EnchantLevel + 1, item.Rarity, (int)item.Type, item.Level); itemEnchantStats.Rates.BaseSuccessRate = (float)successRateScriptResult.Tuple[0].Number; itemEnchantStats.Rates.CatalystRate = (float)successRateScriptResult.Tuple[1].Number; itemEnchantStats.PityCharges = (int)successRateScriptResult.Tuple[2].Number; itemEnchantStats.Rates.ChargesRate = (float)successRateScriptResult.Tuple[3].Number; itemEnchantStats.CatalystAmountRequired = (int)ingredientsResult.Tuple[0].Number; for (int i = 1; i < ingredientsResult.Tuple.Length; i += 2) { EnchantIngredient ingredient = new((ItemStringTag)Enum.Parse(typeof(ItemStringTag), ingredientsResult.Tuple[i].String), (int)ingredientsResult.Tuple[i + 1].Number); itemEnchantStats.Ingredients.Add(ingredient); } itemEnchantStats.Stats = EnchantHelper.GetEnchantStats(item.EnchantLevel + 1, item.Type, item.Level); return(itemEnchantStats); }
public static int CostEnchant(EnchantType t,int lvl) { switch (t) { case EnchantType.weaponUpdate: return 1600; case EnchantType.powerUpdate: return 1100; case EnchantType.armorUpdate: return 1400; // case EnchantType.healthUpdate: // return 2600; } return 900; }
public Enchant(EnchantType Type, int Strength) { enchantType = Type; strength = Strength; CalculateStrength(); }
public EnchantScroll(EnchantType enchantType, EnchantTarget enchantTarget, CrystalTypeId enchantCrystall) { Type = enchantType; Target = enchantTarget; Crystall = enchantCrystall; }