| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459 |
- using System.Text.RegularExpressions;
- public class ItemInfo
- {
- public int Index;
- public string Name = string.Empty;
- public ItemType Type;
- public ItemGrade Grade;
- public RequiredType RequiredType = RequiredType.Level;
- public RequiredClass RequiredClass = RequiredClass.None;
- public RequiredGender RequiredGender = RequiredGender.None;
- public ItemSet Set;
- public short Shape;
- public byte Weight, Light, RequiredAmount;
- public ushort Image, Durability;
- public uint Price;
- public ushort StackSize = 1;
- public bool StartItem;
- public byte Effect;
- public bool NeedIdentify, ShowGroupPickup, GlobalDropNotify;
- public bool ClassBased;
- public bool LevelBased;
- public bool CanMine;
- public bool CanFastRun;
- public bool CanAwakening;
- public BindMode Bind = BindMode.None;
- public SpecialItemMode Unique = SpecialItemMode.None;
- public byte RandomStatsId;
- public RandomItemStat RandomStats;
- public string ToolTip = string.Empty;
- public byte Slots;
- public Stats Stats;
- public bool IsConsumable
- {
- get { return Type == ItemType.Potion || Type == ItemType.Scroll || Type == ItemType.Food || Type == ItemType.Transform || Type == ItemType.Script || Type == ItemType.SealedHero; }
- }
- public bool IsFishingRod
- {
- get { return Globals.FishingRodShapes.Contains(Shape); }
- }
- public string FriendlyName
- {
- get
- {
- string temp = Name;
- temp = Regex.Replace(temp, @"\d+$", string.Empty); //hides end numbers
- temp = Regex.Replace(temp, @"\[[^\]]*\]", string.Empty); //hides square brackets
- return temp;
- }
- }
- public ItemInfo()
- {
- Stats = new Stats();
- }
- public ItemInfo(BinaryReader reader, int version = int.MaxValue, int customVersion = int.MaxValue)
- {
- Index = reader.ReadInt32();
- Name = reader.ReadString();
- Type = (ItemType)reader.ReadByte();
- Grade = (ItemGrade)reader.ReadByte();
- RequiredType = (RequiredType)reader.ReadByte();
- RequiredClass = (RequiredClass)reader.ReadByte();
- RequiredGender = (RequiredGender)reader.ReadByte();
- Set = (ItemSet)reader.ReadByte();
- Shape = reader.ReadInt16();
- Weight = reader.ReadByte();
- Light = reader.ReadByte();
- RequiredAmount = reader.ReadByte();
- Image = reader.ReadUInt16();
- Durability = reader.ReadUInt16();
- if (version <= 84)
- {
- StackSize = (ushort)reader.ReadUInt32();
- }
- else
- {
- StackSize = reader.ReadUInt16();
- }
- Price = reader.ReadUInt32();
- if (version <= 84)
- {
- Stats = new Stats();
- Stats[Stat.MinAC] = reader.ReadByte();
- Stats[Stat.MaxAC] = reader.ReadByte();
- Stats[Stat.MinMAC] = reader.ReadByte();
- Stats[Stat.MaxMAC] = reader.ReadByte();
- Stats[Stat.MinDC] = reader.ReadByte();
- Stats[Stat.MaxDC] = reader.ReadByte();
- Stats[Stat.MinMC] = reader.ReadByte();
- Stats[Stat.MaxMC] = reader.ReadByte();
- Stats[Stat.MinSC] = reader.ReadByte();
- Stats[Stat.MaxSC] = reader.ReadByte();
- Stats[Stat.HP] = reader.ReadUInt16();
- Stats[Stat.MP] = reader.ReadUInt16();
- Stats[Stat.Accuracy] = reader.ReadByte();
- Stats[Stat.Agility] = reader.ReadByte();
- Stats[Stat.Luck] = reader.ReadSByte();
- Stats[Stat.AttackSpeed] = reader.ReadSByte();
- }
- StartItem = reader.ReadBoolean();
- if (version <= 84)
- {
- Stats[Stat.BagWeight] = reader.ReadByte();
- Stats[Stat.HandWeight] = reader.ReadByte();
- Stats[Stat.WearWeight] = reader.ReadByte();
- }
- Effect = reader.ReadByte();
- if (version <= 84)
- {
- Stats[Stat.Strong] = reader.ReadByte();
- Stats[Stat.MagicResist] = reader.ReadByte();
- Stats[Stat.PoisonResist] = reader.ReadByte();
- Stats[Stat.HealthRecovery] = reader.ReadByte();
- Stats[Stat.SpellRecovery] = reader.ReadByte();
- Stats[Stat.PoisonRecovery] = reader.ReadByte();
- Stats[Stat.HPRatePercent] = reader.ReadByte();
- Stats[Stat.MPRatePercent] = reader.ReadByte();
- Stats[Stat.CriticalRate] = reader.ReadByte();
- Stats[Stat.CriticalDamage] = reader.ReadByte();
- }
- byte bools = reader.ReadByte();
- NeedIdentify = (bools & 0x01) == 0x01;
- ShowGroupPickup = (bools & 0x02) == 0x02;
- ClassBased = (bools & 0x04) == 0x04;
- LevelBased = (bools & 0x08) == 0x08;
- CanMine = (bools & 0x10) == 0x10;
- if (version >= 77)
- {
- GlobalDropNotify = (bools & 0x20) == 0x20;
- }
- if (version <= 84)
- {
- Stats[Stat.MaxACRatePercent] = reader.ReadByte();
- Stats[Stat.MaxMACRatePercent] = reader.ReadByte();
- Stats[Stat.Holy] = reader.ReadByte();
- Stats[Stat.Freezing] = reader.ReadByte();
- Stats[Stat.PoisonAttack] = reader.ReadByte();
- }
- Bind = (BindMode)reader.ReadInt16();
- if (version <= 84)
- {
- Stats[Stat.Reflect] = reader.ReadByte();
- Stats[Stat.HPDrainRatePercent] = reader.ReadByte();
- }
- Unique = (SpecialItemMode)reader.ReadInt16();
- RandomStatsId = reader.ReadByte();
- CanFastRun = reader.ReadBoolean();
- CanAwakening = reader.ReadBoolean();
- if (version > 83)
- {
- Slots = reader.ReadByte();
- }
- if (version > 84)
- {
- Stats = new Stats(reader, version, customVersion);
- }
- bool isTooltip = reader.ReadBoolean();
- if (isTooltip)
- {
- ToolTip = reader.ReadString();
- }
- if (version < 70) //before db version 70 all specialitems had wedding rings disabled, after that it became a server option
- {
- if ((Type == ItemType.Ring) && (Unique != SpecialItemMode.None))
- Bind |= BindMode.NoWeddingRing;
- }
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write(Index);
- writer.Write(Name);
- writer.Write((byte)Type);
- writer.Write((byte)Grade);
- writer.Write((byte)RequiredType);
- writer.Write((byte)RequiredClass);
- writer.Write((byte)RequiredGender);
- writer.Write((byte)Set);
- writer.Write(Shape);
- writer.Write(Weight);
- writer.Write(Light);
- writer.Write(RequiredAmount);
- writer.Write(Image);
- writer.Write(Durability);
- writer.Write(StackSize);
- writer.Write(Price);
- writer.Write(StartItem);
- writer.Write(Effect);
- byte bools = 0;
- if (NeedIdentify) bools |= 0x01;
- if (ShowGroupPickup) bools |= 0x02;
- if (ClassBased) bools |= 0x04;
- if (LevelBased) bools |= 0x08;
- if (CanMine) bools |= 0x10;
- if (GlobalDropNotify) bools |= 0x20;
- writer.Write(bools);
- writer.Write((short)Bind);
- writer.Write((short)Unique);
- writer.Write(RandomStatsId);
- writer.Write(CanFastRun);
- writer.Write(CanAwakening);
- writer.Write(Slots);
- Stats.Save(writer);
- writer.Write(ToolTip != null);
- if (ToolTip != null)
- writer.Write(ToolTip);
- }
- public static ItemInfo FromText(string text)
- {
- return null;
- }
- public string ToText()
- {
- return null;
- }
- public override string ToString()
- {
- return string.Format("{0}: {1}", Index, Name);
- }
- }
- public class UserItem
- {
- public ulong UniqueID;
- public int ItemIndex;
- public ItemInfo Info;
- public ushort CurrentDura, MaxDura;
- public ushort Count = 1,
- GemCount = 0;
- public RefinedValue RefinedValue = RefinedValue.None;
- public byte RefineAdded = 0;
- public int RefineSuccessChance = 0;
- public bool DuraChanged;
- public int SoulBoundId = -1;
- public bool Identified = false;
- public bool Cursed = false;
- public int WeddingRing = -1;
- public UserItem[] Slots = new UserItem[0];
- public DateTime BuybackExpiryDate;
- public ExpireInfo ExpireInfo;
- public RentalInformation RentalInformation;
- public SealedInfo SealedInfo;
- public bool IsShopItem;
- public Awake Awake = new Awake();
- public Stats AddedStats;
- public bool IsAdded
- {
- get { return AddedStats.Count > 0 || Slots.Length > Info.Slots; }
- }
- public int Weight
- {
- get { return (Info.Type == ItemType.Amulet || Info.Type == ItemType.Bait) ? Info.Weight : Info.Weight * Count; }
- }
- public string FriendlyName
- {
- get { return Count > 1 ? string.Format("{0} ({1})", Info.FriendlyName, Count) : Info.FriendlyName; }
- }
- public bool GMMade { get; set; }
- public UserItem(ItemInfo info)
- {
- SoulBoundId = -1;
- ItemIndex = info.Index;
- Info = info;
- AddedStats = new Stats();
-
- SetSlotSize();
- }
- public UserItem(BinaryReader reader, int version = int.MaxValue, int customVersion = int.MaxValue)
- {
- UniqueID = reader.ReadUInt64();
- ItemIndex = reader.ReadInt32();
- CurrentDura = reader.ReadUInt16();
- MaxDura = reader.ReadUInt16();
- if (version <= 84)
- {
- Count = (ushort)reader.ReadUInt32();
- }
- else
- {
- Count = reader.ReadUInt16();
- }
- if (version <= 84)
- {
- AddedStats = new Stats();
- AddedStats[Stat.MaxAC] = reader.ReadByte();
- AddedStats[Stat.MaxMAC] = reader.ReadByte();
- AddedStats[Stat.MaxDC] = reader.ReadByte();
- AddedStats[Stat.MaxMC] = reader.ReadByte();
- AddedStats[Stat.MaxSC] = reader.ReadByte();
- AddedStats[Stat.Accuracy] = reader.ReadByte();
- AddedStats[Stat.Agility] = reader.ReadByte();
- AddedStats[Stat.HP] = reader.ReadByte();
- AddedStats[Stat.MP] = reader.ReadByte();
- AddedStats[Stat.AttackSpeed] = reader.ReadSByte();
- AddedStats[Stat.Luck] = reader.ReadSByte();
- }
- SoulBoundId = reader.ReadInt32();
- byte Bools = reader.ReadByte();
- Identified = (Bools & 0x01) == 0x01;
- Cursed = (Bools & 0x02) == 0x02;
- if (version <= 84)
- {
- AddedStats[Stat.Strong] = reader.ReadByte();
- AddedStats[Stat.MagicResist] = reader.ReadByte();
- AddedStats[Stat.PoisonResist] = reader.ReadByte();
- AddedStats[Stat.HealthRecovery] = reader.ReadByte();
- AddedStats[Stat.SpellRecovery] = reader.ReadByte();
- AddedStats[Stat.PoisonRecovery] = reader.ReadByte();
- AddedStats[Stat.CriticalRate] = reader.ReadByte();
- AddedStats[Stat.CriticalDamage] = reader.ReadByte();
- AddedStats[Stat.Freezing] = reader.ReadByte();
- AddedStats[Stat.PoisonAttack] = reader.ReadByte();
- }
- int count = reader.ReadInt32();
- SetSlotSize(count);
- for (int i = 0; i < count; i++)
- {
- if (reader.ReadBoolean()) continue;
- UserItem item = new UserItem(reader, version, customVersion);
- Slots[i] = item;
- }
- if (version <= 84)
- {
- GemCount = (ushort)reader.ReadUInt32();
- }
- else
- {
- GemCount = reader.ReadUInt16();
- }
- if (version > 84)
- {
- AddedStats = new Stats(reader, version, customVersion);
- }
- Awake = new Awake(reader);
- RefinedValue = (RefinedValue)reader.ReadByte();
- RefineAdded = reader.ReadByte();
- if (version > 85)
- {
- RefineSuccessChance = reader.ReadInt32();
- }
- WeddingRing = reader.ReadInt32();
- if (version < 65) return;
- if (reader.ReadBoolean())
- {
- ExpireInfo = new ExpireInfo(reader, version, customVersion);
- }
- if (version < 76)
- return;
- if (reader.ReadBoolean())
- RentalInformation = new RentalInformation(reader, version, customVersion);
- if (version < 83) return;
- IsShopItem = reader.ReadBoolean();
- if (version < 92) return;
- if (reader.ReadBoolean())
- {
- SealedInfo = new SealedInfo(reader, version, customVersion);
- }
- if (version > 107)
- {
- GMMade = reader.ReadBoolean();
- }
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write(UniqueID);
- writer.Write(ItemIndex);
- writer.Write(CurrentDura);
- writer.Write(MaxDura);
- writer.Write(Count);
- writer.Write(SoulBoundId);
- byte Bools = 0;
- if (Identified) Bools |= 0x01;
- if (Cursed) Bools |= 0x02;
- writer.Write(Bools);
- writer.Write(Slots.Length);
- for (int i = 0; i < Slots.Length; i++)
- {
- writer.Write(Slots[i] == null);
- if (Slots[i] == null) continue;
- Slots[i].Save(writer);
- }
- writer.Write(GemCount);
- AddedStats.Save(writer);
- Awake.Save(writer);
- writer.Write((byte)RefinedValue);
- writer.Write(RefineAdded);
- writer.Write(RefineSuccessChance);
- writer.Write(WeddingRing);
- writer.Write(ExpireInfo != null);
- ExpireInfo?.Save(writer);
- writer.Write(RentalInformation != null);
- RentalInformation?.Save(writer);
- writer.Write(IsShopItem);
- writer.Write(SealedInfo != null);
- SealedInfo?.Save(writer);
- writer.Write(GMMade);
- }
- public int GetTotal(Stat type)
- {
- return AddedStats[type] + Info.Stats[type];
- }
- public uint Price()
- {
- if (Info == null) return 0;
- uint p = Info.Price;
- if (Info.Durability > 0)
- {
- float r = ((Info.Price / 2F) / Info.Durability);
- p = (uint)(MaxDura * r);
- if (MaxDura > 0)
- r = CurrentDura / (float)MaxDura;
- else
- r = 0;
- p = (uint)Math.Floor(p / 2F + ((p / 2F) * r) + Info.Price / 2F);
- }
- p = (uint)(p * (AddedStats.Count * 0.1F + 1F));
- return p * Count;
- }
- public uint RepairPrice()
- {
- if (Info == null || Info.Durability == 0)
- return 0;
- var p = Info.Price;
- if (Info.Durability > 0)
- {
- p = (uint)Math.Floor(MaxDura * ((Info.Price / 2F) / Info.Durability) + Info.Price / 2F);
- p = (uint)(p * (AddedStats.Count * 0.1F + 1F));
- }
- var cost = p * Count - Price();
- if (RentalInformation == null)
- return cost;
- return cost * 2;
- }
- public uint Quality()
- {
- uint q = (uint)(AddedStats.Count + Awake.GetAwakeLevel() + 1);
- return q;
- }
- public uint AwakeningPrice()
- {
- if (Info == null) return 0;
- uint p = 1500;
- p = (uint)((p * (1 + Awake.GetAwakeLevel() * 2)) * (uint)Info.Grade);
- return p;
- }
- public uint DisassemblePrice()
- {
- if (Info == null) return 0;
- uint p = 1500 * (uint)Info.Grade;
- p = (uint)(p * ((AddedStats.Count + Awake.GetAwakeLevel()) * 0.1F + 1F));
- return p;
- }
- public uint DowngradePrice()
- {
- if (Info == null) return 0;
- uint p = 3000;
- p = (uint)((p * (1 + (Awake.GetAwakeLevel() + 1) * 2)) * (uint)Info.Grade);
- return p;
- }
- public uint ResetPrice()
- {
- if (Info == null) return 0;
- uint p = 3000 * (uint)Info.Grade;
- p = (uint)(p * (AddedStats.Count * 0.2F + 1F));
- return p;
- }
- public void SetSlotSize(int? size = null)
- {
- if (size == null)
- {
- switch (Info.Type)
- {
- case ItemType.Mount:
- if (Info.Shape < 7)
- size = 4;
- else if (Info.Shape < 12)
- size = 5;
- break;
- case ItemType.Weapon:
- if (Info.Shape == 49 || Info.Shape == 50)
- size = 5;
- break;
- }
- }
- if (size == null && Info == null) return;
- if (size != null && size == Slots.Length) return;
- if (size == null && Info != null && Info.Slots == Slots.Length) return;
- Array.Resize(ref Slots, size ?? Info.Slots);
- }
- public ushort Image
- {
- get
- {
- switch (Info.Type)
- {
- #region Amulet and Poison Stack Image changes
- case ItemType.Amulet:
- if (Info.StackSize > 0)
- {
- switch (Info.Shape)
- {
- case 0: //Amulet
- if (Count >= 300) return 3662;
- if (Count >= 200) return 3661;
- if (Count >= 100) return 3660;
- return 3660;
- case 1: //Grey Poison
- if (Count >= 150) return 3675;
- if (Count >= 100) return 2960;
- if (Count >= 50) return 3674;
- return 3673;
- case 2: //Yellow Poison
- if (Count >= 150) return 3672;
- if (Count >= 100) return 2961;
- if (Count >= 50) return 3671;
- return 3670;
- }
- }
- break;
- }
- #endregion
- return Info.Image;
- }
- }
- public UserItem Clone()
- {
- UserItem item = new UserItem(Info)
- {
- UniqueID = UniqueID,
- CurrentDura = CurrentDura,
- MaxDura = MaxDura,
- Count = Count,
- GemCount = GemCount,
- DuraChanged = DuraChanged,
- SoulBoundId = SoulBoundId,
- Identified = Identified,
- Cursed = Cursed,
- Slots = Slots,
- AddedStats = new Stats(AddedStats),
- Awake = Awake,
- RefineAdded = RefineAdded,
- ExpireInfo = ExpireInfo,
- RentalInformation = RentalInformation,
- SealedInfo = SealedInfo,
- IsShopItem = IsShopItem,
- GMMade = GMMade
- };
- return item;
- }
- }
- public class ExpireInfo
- {
- public DateTime ExpiryDate;
- public ExpireInfo() { }
- public ExpireInfo(BinaryReader reader, int version = int.MaxValue, int Customversion = int.MaxValue)
- {
- ExpiryDate = DateTime.FromBinary(reader.ReadInt64());
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write(ExpiryDate.ToBinary());
- }
- }
- public class SealedInfo
- {
- public DateTime ExpiryDate;
- public DateTime NextSealDate;
- public SealedInfo() { }
- public SealedInfo(BinaryReader reader, int version = int.MaxValue, int Customversion = int.MaxValue)
- {
- ExpiryDate = DateTime.FromBinary(reader.ReadInt64());
- if (version > 92)
- {
- NextSealDate = DateTime.FromBinary(reader.ReadInt64());
- }
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write(ExpiryDate.ToBinary());
- writer.Write(NextSealDate.ToBinary());
- }
- }
- public class RentalInformation
- {
- public string OwnerName;
- public BindMode BindingFlags = BindMode.None;
- public DateTime ExpiryDate;
- public bool RentalLocked;
- public RentalInformation() { }
- public RentalInformation(BinaryReader reader, int version = int.MaxValue, int CustomVersion = int.MaxValue)
- {
- OwnerName = reader.ReadString();
- BindingFlags = (BindMode)reader.ReadInt16();
- ExpiryDate = DateTime.FromBinary(reader.ReadInt64());
- RentalLocked = reader.ReadBoolean();
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write(OwnerName);
- writer.Write((short)BindingFlags);
- writer.Write(ExpiryDate.ToBinary());
- writer.Write(RentalLocked);
- }
- }
- public class GameShopItem
- {
- public int ItemIndex;
- public int GIndex;
- public ItemInfo Info;
- public uint GoldPrice = 0;
- public uint CreditPrice = 0;
- public ushort Count = 1;
- public string Class = "";
- public string Category = "";
- public int Stock = 0;
- public bool iStock = false;
- public bool Deal = false;
- public bool TopItem = false;
- public DateTime Date;
- public bool CanBuyGold = false;
- public bool CanBuyCredit = false;
- public GameShopItem()
- {
- }
- public GameShopItem(BinaryReader reader, int version = int.MaxValue, int Customversion = int.MaxValue)
- {
- ItemIndex = reader.ReadInt32();
- GIndex = reader.ReadInt32();
- GoldPrice = reader.ReadUInt32();
- CreditPrice = reader.ReadUInt32();
- if (version <= 84)
- {
- Count = (ushort)reader.ReadUInt32();
- }
- else
- {
- Count = reader.ReadUInt16();
- }
- Class = reader.ReadString();
- Category = reader.ReadString();
- Stock = reader.ReadInt32();
- iStock = reader.ReadBoolean();
- Deal = reader.ReadBoolean();
- TopItem = reader.ReadBoolean();
- Date = DateTime.FromBinary(reader.ReadInt64());
- if (version > 105)
- {
- CanBuyCredit = reader.ReadBoolean();
- CanBuyGold = reader.ReadBoolean();
- }
- }
- public GameShopItem(BinaryReader reader, bool packet = false)
- {
- ItemIndex = reader.ReadInt32();
- GIndex = reader.ReadInt32();
- Info = new ItemInfo(reader);
- GoldPrice = reader.ReadUInt32();
- CreditPrice = reader.ReadUInt32();
- Count = reader.ReadUInt16();
- Class = reader.ReadString();
- Category = reader.ReadString();
- Stock = reader.ReadInt32();
- iStock = reader.ReadBoolean();
- Deal = reader.ReadBoolean();
- TopItem = reader.ReadBoolean();
- Date = DateTime.FromBinary(reader.ReadInt64());
- CanBuyCredit = reader.ReadBoolean();
- CanBuyGold = reader.ReadBoolean();
- }
- public void Save(BinaryWriter writer, bool packet = false)
- {
- writer.Write(ItemIndex);
- writer.Write(GIndex);
- if (packet) Info.Save(writer);
- writer.Write(GoldPrice);
- writer.Write(CreditPrice);
- writer.Write(Count);
- writer.Write(Class);
- writer.Write(Category);
- writer.Write(Stock);
- writer.Write(iStock);
- writer.Write(Deal);
- writer.Write(TopItem);
- writer.Write(Date.ToBinary());
- writer.Write(CanBuyCredit);
- writer.Write(CanBuyGold);
- }
- public override string ToString()
- {
- return string.Format("{0}: {1}", GIndex, Info.Name);
- }
- }
- public class Awake
- {
- //Awake Option
- public static byte AwakeSuccessRate = 70;
- public static byte AwakeHitRate = 70;
- public static int MaxAwakeLevel = 5;
- public static byte Awake_WeaponRate = 1;
- public static byte Awake_HelmetRate = 1;
- public static byte Awake_ArmorRate = 5;
- public static byte AwakeChanceMin = 1;
- public static float[] AwakeMaterialRate = new float[5] { 1.0F, 1.0F, 1.0F, 1.0F, 1.0F };
- public static byte[] AwakeChanceMax = new byte[5] { 1, 2, 3, 4, 5 };
- public static List<List<byte>[]> AwakeMaterials = new List<List<byte>[]>();
- public AwakeType Type = AwakeType.None;
- readonly List<byte> listAwake = new List<byte>();
- public Awake() { }
- public Awake(BinaryReader reader)
- {
- Type = (AwakeType)reader.ReadByte();
- int count = reader.ReadInt32();
- for (int i = 0; i < count; i++)
- {
- listAwake.Add(reader.ReadByte());
- }
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write((byte)Type);
- writer.Write(listAwake.Count);
- foreach (byte value in listAwake)
- {
- writer.Write(value);
- }
- }
- public bool IsMaxLevel() { return listAwake.Count == Awake.MaxAwakeLevel; }
- public int GetAwakeLevel() { return listAwake.Count; }
- public byte GetAwakeValue()
- {
- byte total = 0;
- foreach (byte value in listAwake)
- {
- total += value;
- }
- return total;
- }
- public bool CheckAwakening(UserItem item, AwakeType type)
- {
- if (item.Info.Bind.HasFlag(BindMode.DontUpgrade))
- return false;
- if (item.Info.CanAwakening != true)
- return false;
- if (item.Info.Grade == ItemGrade.None)
- return false;
- if (IsMaxLevel()) return false;
- if (this.Type == AwakeType.None)
- {
- if (item.Info.Type == ItemType.Weapon)
- {
- if (type == AwakeType.DC ||
- type == AwakeType.MC ||
- type == AwakeType.SC)
- {
- this.Type = type;
- return true;
- }
- else
- return false;
- }
- else if (item.Info.Type == ItemType.Helmet)
- {
- if (type == AwakeType.AC ||
- type == AwakeType.MAC)
- {
- this.Type = type;
- return true;
- }
- else
- return false;
- }
- else if (item.Info.Type == ItemType.Armour)
- {
- if (type == AwakeType.HPMP)
- {
- this.Type = type;
- return true;
- }
- else
- return false;
- }
- else
- return false;
- }
- else
- {
- if (this.Type == type)
- return true;
- else
- return false;
- }
- }
- public int UpgradeAwake(UserItem item, AwakeType type, out bool[] isHit)
- {
- //return -1 condition error, -1 = dont upgrade, 0 = failed, 1 = Succeed,
- isHit = null;
- if (CheckAwakening(item, type) != true)
- return -1;
- Random rand = new Random(DateTime.Now.Millisecond);
- if (rand.Next(0, 100) <= AwakeSuccessRate)
- {
- isHit = Awakening(item);
- return 1;
- }
- else
- {
- isHit = MakeHit(1, out _);
- return 0;
- }
- }
- public int RemoveAwake()
- {
- if (listAwake.Count > 0)
- {
- listAwake.Remove(listAwake[listAwake.Count - 1]);
- if (listAwake.Count == 0)
- Type = AwakeType.None;
- return 1;
- }
- else
- {
- Type = AwakeType.None;
- return 0;
- }
- }
- public int GetAwakeLevelValue(int i) { return listAwake[i]; }
- public byte GetDC() { return (Type == AwakeType.DC ? GetAwakeValue() : (byte)0); }
- public byte GetMC() { return (Type == AwakeType.MC ? GetAwakeValue() : (byte)0); }
- public byte GetSC() { return (Type == AwakeType.SC ? GetAwakeValue() : (byte)0); }
- public byte GetAC() { return (Type == AwakeType.AC ? GetAwakeValue() : (byte)0); }
- public byte GetMAC() { return (Type == AwakeType.MAC ? GetAwakeValue() : (byte)0); }
- public byte GetHPMP() { return (Type == AwakeType.HPMP ? GetAwakeValue() : (byte)0); }
- private bool[] MakeHit(int maxValue, out int makeValue)
- {
- float stepValue = (float)maxValue / 5.0f;
- float totalValue = 0.0f;
- bool[] isHit = new bool[5];
- Random rand = new Random(DateTime.Now.Millisecond);
- for (int i = 0; i < 5; i++)
- {
- if (rand.Next(0, 100) < AwakeHitRate)
- {
- totalValue += stepValue;
- isHit[i] = true;
- }
- else
- {
- isHit[i] = false;
- }
- }
- makeValue = totalValue <= 1.0f ? 1 : (int)totalValue;
- return isHit;
- }
- private bool[] Awakening(UserItem item)
- {
- int minValue = AwakeChanceMin;
- int maxValue = (AwakeChanceMax[(int)item.Info.Grade - 1] < minValue) ? minValue : AwakeChanceMax[(int)item.Info.Grade - 1];
- bool[] returnValue = MakeHit(maxValue, out int result);
- switch (item.Info.Type)
- {
- case ItemType.Weapon:
- result *= (int)Awake_WeaponRate;
- break;
- case ItemType.Armour:
- result *= (int)Awake_ArmorRate;
- break;
- case ItemType.Helmet:
- result *= (int)Awake_HelmetRate;
- break;
- default:
- result = 0;
- break;
- }
- listAwake.Add((byte)result);
- return returnValue;
- }
- }
- public class ItemRentalInformation
- {
- public ulong ItemId;
- public string ItemName;
- public string RentingPlayerName;
- public DateTime ItemReturnDate;
- public ItemRentalInformation() { }
- public ItemRentalInformation(BinaryReader reader, int version = int.MaxValue, int customVersion = int.MaxValue)
- {
- ItemId = reader.ReadUInt64();
- ItemName = reader.ReadString();
- RentingPlayerName = reader.ReadString();
- ItemReturnDate = DateTime.FromBinary(reader.ReadInt64());
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write(ItemId);
- writer.Write(ItemName);
- writer.Write(RentingPlayerName);
- writer.Write(ItemReturnDate.ToBinary());
- }
- }
- public class ItemSets
- {
- public ItemSet Set;
- public List<ItemType> Type;
- private byte Amount
- {
- get
- {
- switch (Set)
- {
- case ItemSet.Mundane:
- case ItemSet.NokChi:
- case ItemSet.TaoProtect:
- case ItemSet.Whisker1:
- case ItemSet.Whisker2:
- case ItemSet.Whisker3:
- case ItemSet.Whisker4:
- case ItemSet.Whisker5:
- return 2;
- case ItemSet.RedOrchid:
- case ItemSet.RedFlower:
- case ItemSet.Smash:
- case ItemSet.HwanDevil:
- case ItemSet.Purity:
- case ItemSet.FiveString:
- case ItemSet.Bone:
- case ItemSet.Bug:
- case ItemSet.DarkGhost:
- return 3;
- case ItemSet.Recall:
- return 4;
- case ItemSet.Spirit:
- case ItemSet.WhiteGold:
- case ItemSet.WhiteGoldH:
- case ItemSet.RedJade:
- case ItemSet.RedJadeH:
- case ItemSet.Nephrite:
- case ItemSet.NephriteH:
- case ItemSet.Hyeolryong:
- case ItemSet.Monitor:
- case ItemSet.Oppressive:
- case ItemSet.Paeok:
- case ItemSet.Sulgwan:
- case ItemSet.BlueFrostH:
- case ItemSet.BlueFrost:
- return 5;
- default:
- return 0;
- }
- }
- }
- public byte Count;
- public bool SetComplete
- {
- get
- {
- return Count >= Amount;
- }
- }
- }
- public class RandomItemStat
- {
- public byte MaxDuraChance, MaxDuraStatChance, MaxDuraMaxStat;
- public byte MaxAcChance, MaxAcStatChance, MaxAcMaxStat, MaxMacChance, MaxMacStatChance, MaxMacMaxStat, MaxDcChance, MaxDcStatChance, MaxDcMaxStat, MaxMcChance, MaxMcStatChance, MaxMcMaxStat, MaxScChance, MaxScStatChance, MaxScMaxStat;
- public byte AccuracyChance, AccuracyStatChance, AccuracyMaxStat, AgilityChance, AgilityStatChance, AgilityMaxStat, HpChance, HpStatChance, HpMaxStat, MpChance, MpStatChance, MpMaxStat, StrongChance, StrongStatChance, StrongMaxStat;
- public byte MagicResistChance, MagicResistStatChance, MagicResistMaxStat, PoisonResistChance, PoisonResistStatChance, PoisonResistMaxStat;
- public byte HpRecovChance, HpRecovStatChance, HpRecovMaxStat, MpRecovChance, MpRecovStatChance, MpRecovMaxStat, PoisonRecovChance, PoisonRecovStatChance, PoisonRecovMaxStat;
- public byte CriticalRateChance, CriticalRateStatChance, CriticalRateMaxStat, CriticalDamageChance, CriticalDamageStatChance, CriticalDamageMaxStat;
- public byte FreezeChance, FreezeStatChance, FreezeMaxStat, PoisonAttackChance, PoisonAttackStatChance, PoisonAttackMaxStat;
- public byte AttackSpeedChance, AttackSpeedStatChance, AttackSpeedMaxStat, LuckChance, LuckStatChance, LuckMaxStat;
- public byte CurseChance;
- public byte SlotChance, SlotStatChance, SlotMaxStat;
- public RandomItemStat(ItemType Type = ItemType.Book)
- {
- switch (Type)
- {
- case ItemType.Weapon:
- SetWeapon();
- break;
- case ItemType.Armour:
- SetArmour();
- break;
- case ItemType.Helmet:
- SetHelmet();
- break;
- case ItemType.Belt:
- case ItemType.Boots:
- SetBeltBoots();
- break;
- case ItemType.Necklace:
- SetNecklace();
- break;
- case ItemType.Bracelet:
- SetBracelet();
- break;
- case ItemType.Ring:
- SetRing();
- break;
- case ItemType.Mount:
- SetMount();
- break;
- }
- }
- public void SetWeapon()
- {
- MaxDuraChance = 2;
- MaxDuraStatChance = 13;
- MaxDuraMaxStat = 13;
- MaxDcChance = 15;
- MaxDcStatChance = 15;
- MaxDcMaxStat = 13;
- MaxMcChance = 20;
- MaxMcStatChance = 15;
- MaxMcMaxStat = 13;
- MaxScChance = 20;
- MaxScStatChance = 15;
- MaxScMaxStat = 13;
- AttackSpeedChance = 60;
- AttackSpeedStatChance = 30;
- AttackSpeedMaxStat = 3;
- StrongChance = 24;
- StrongStatChance = 20;
- StrongMaxStat = 2;
- AccuracyChance = 30;
- AccuracyStatChance = 20;
- AccuracyMaxStat = 2;
- }
- public void SetArmour()
- {
- MaxDuraChance = 2;
- MaxDuraStatChance = 10;
- MaxDuraMaxStat = 3;
- MaxAcChance = 30;
- MaxAcStatChance = 15;
- MaxAcMaxStat = 7;
- MaxMacChance = 30;
- MaxMacStatChance = 15;
- MaxMacMaxStat = 7;
- MaxDcChance = 40;
- MaxDcStatChance = 20;
- MaxDcMaxStat = 7;
- MaxMcChance = 40;
- MaxMcStatChance = 20;
- MaxMcMaxStat = 7;
- MaxScChance = 40;
- MaxScStatChance = 20;
- MaxScMaxStat = 7;
- }
- public void SetHelmet()
- {
- MaxDuraChance = 2;
- MaxDuraStatChance = 10;
- MaxDuraMaxStat = 3;
- MaxAcChance = 30;
- MaxAcStatChance = 15;
- MaxAcMaxStat = 7;
- MaxMacChance = 30;
- MaxMacStatChance = 15;
- MaxMacMaxStat = 7;
- MaxDcChance = 40;
- MaxDcStatChance = 20;
- MaxDcMaxStat = 7;
- MaxMcChance = 40;
- MaxMcStatChance = 20;
- MaxMcMaxStat = 7;
- MaxScChance = 40;
- MaxScStatChance = 20;
- MaxScMaxStat = 7;
- }
- public void SetBeltBoots()
- {
- MaxDuraChance = 2;
- MaxDuraStatChance = 10;
- MaxDuraMaxStat = 3;
- MaxAcChance = 30;
- MaxAcStatChance = 30;
- MaxAcMaxStat = 3;
- MaxMacChance = 30;
- MaxMacStatChance = 30;
- MaxMacMaxStat = 3;
- MaxDcChance = 30;
- MaxDcStatChance = 30;
- MaxDcMaxStat = 3;
- MaxMcChance = 30;
- MaxMcStatChance = 30;
- MaxMcMaxStat = 3;
- MaxScChance = 30;
- MaxScStatChance = 30;
- MaxScMaxStat = 3;
- AgilityChance = 60;
- AgilityStatChance = 30;
- AgilityMaxStat = 3;
- }
- public void SetNecklace()
- {
- MaxDuraChance = 2;
- MaxDuraStatChance = 10;
- MaxDuraMaxStat = 3;
- MaxDcChance = 15;
- MaxDcStatChance = 30;
- MaxDcMaxStat = 7;
- MaxMcChance = 15;
- MaxMcStatChance = 30;
- MaxMcMaxStat = 7;
- MaxScChance = 15;
- MaxScStatChance = 30;
- MaxScMaxStat = 7;
- AccuracyChance = 60;
- AccuracyStatChance = 30;
- AccuracyMaxStat = 7;
- AgilityChance = 60;
- AgilityStatChance = 30;
- AgilityMaxStat = 7;
- }
- public void SetBracelet()
- {
- MaxDuraChance = 2;
- MaxDuraStatChance = 10;
- MaxDuraMaxStat = 3;
- MaxAcChance = 20;
- MaxAcStatChance = 30;
- MaxAcMaxStat = 6;
- MaxMacChance = 20;
- MaxMacStatChance = 30;
- MaxMacMaxStat = 6;
- MaxDcChance = 30;
- MaxDcStatChance = 30;
- MaxDcMaxStat = 6;
- MaxMcChance = 30;
- MaxMcStatChance = 30;
- MaxMcMaxStat = 6;
- MaxScChance = 30;
- MaxScStatChance = 30;
- MaxScMaxStat = 6;
- }
- public void SetRing()
- {
- MaxDuraChance = 2;
- MaxDuraStatChance = 10;
- MaxDuraMaxStat = 3;
- MaxAcChance = 25;
- MaxAcStatChance = 20;
- MaxAcMaxStat = 6;
- MaxMacChance = 25;
- MaxMacStatChance = 20;
- MaxMacMaxStat = 6;
- MaxDcChance = 15;
- MaxDcStatChance = 30;
- MaxDcMaxStat = 6;
- MaxMcChance = 15;
- MaxMcStatChance = 30;
- MaxMcMaxStat = 6;
- MaxScChance = 15;
- MaxScStatChance = 30;
- MaxScMaxStat = 6;
- }
- public void SetMount()
- {
- SetRing();
- }
- }
- public class ChatItem
- {
- public ulong UniqueID;
- public string Title;
- public MirGridType Grid;
- public string RegexInternalName
- {
- get { return $"<{Title.Replace("(", "\\(").Replace(")", "\\)")}>"; }
- }
- public string InternalName
- {
- get { return $"<{Title}/{UniqueID}>"; }
- }
- public ChatItem() { }
- public ChatItem(BinaryReader reader)
- {
- UniqueID = reader.ReadUInt64();
- Title = reader.ReadString();
- Grid = (MirGridType)reader.ReadByte();
- }
- public void Save(BinaryWriter writer)
- {
- writer.Write(UniqueID);
- writer.Write(Title);
- writer.Write((byte)Grid);
- }
- }
|