private static void SetSaveFlag( ref SaveFlag flags, SaveFlag toSet, bool setIf ) { if ( setIf ) flags |= toSet; }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)1); // version SaveFlag flags = SaveFlag.None; SetSaveFlag(ref flags, SaveFlag.Attributes, !m_AosAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.ArmorAttributes, !m_AosArmorAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.Crafter, m_Crafter != null); SetSaveFlag(ref flags, SaveFlag.Quality, m_Quality != CraftQuality.Regular); SetSaveFlag(ref flags, SaveFlag.Resource, m_Resource != DefaultResource); SetSaveFlag(ref flags, SaveFlag.StrReq, m_StrReq != -1); SetSaveFlag(ref flags, SaveFlag.DexReq, m_DexReq != -1); SetSaveFlag(ref flags, SaveFlag.IntReq, m_IntReq != -1); SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !m_AosSkillBonuses.IsEmpty); SetSaveFlag(ref flags, SaveFlag.PlayerConstructed, m_PlayerConstructed != false); SetSaveFlag(ref flags, SaveFlag.BonusRandomAttributes, m_BonusRandomAttributes != null && m_BonusRandomAttributes.Length > 0); writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.ArmorAttributes)) { m_AosArmorAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { writer.Write((Mobile)m_Crafter); } if (GetSaveFlag(flags, SaveFlag.Quality)) { writer.WriteEncodedInt((int)m_Quality); } if (GetSaveFlag(flags, SaveFlag.Resource)) { writer.WriteEncodedInt((int)m_Resource); } if (GetSaveFlag(flags, SaveFlag.StrReq)) { writer.WriteEncodedInt((int)m_StrReq); } if (GetSaveFlag(flags, SaveFlag.DexReq)) { writer.WriteEncodedInt((int)m_DexReq); } if (GetSaveFlag(flags, SaveFlag.IntReq)) { writer.WriteEncodedInt((int)m_IntReq); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.BonusRandomAttributes)) { writer.Write(m_BonusRandomAttributes.Length); for (int i = 0; i < m_BonusRandomAttributes.Length; i++) { m_BonusRandomAttributes[i].Serialize(writer); } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 2: { m_Start = reader.ReadDateTime(); m_BottleDuration = reader.ReadDouble(); m_AllowBottling = reader.ReadBool(); goto case 1; } case 1: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Held)) { m_Held = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (JuiceQuality)reader.ReadEncodedInt(); } else { m_Quality = JuiceQuality.Regular; } if (m_Quality == JuiceQuality.Low) { m_Quality = JuiceQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.Variety)) { m_Variety = ( FruitsVariety )reader.ReadEncodedInt(); } else { m_Variety = DefaultVariety; } if (m_Variety == FruitsVariety.None) { m_Variety = DefaultVariety; } break; } } }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write(4); // version writer.Write(_VvVItem); writer.Write(_Owner); writer.Write(_OwnerName); // Version 3 takes out LowerAmmoCost SaveFlag flags = SaveFlag.None; // Version 2 writer.Write(IsArrowAmmo); // Version 1 m_AosSkillBonuses.Serialize(writer); m_Resistances.Serialize(writer); SetSaveFlag(ref flags, SaveFlag.Attributes, !m_Attributes.IsEmpty); //SetSaveFlag(ref flags, SaveFlag.LowerAmmoCost, m_LowerAmmoCost != 0); SetSaveFlag(ref flags, SaveFlag.WeightReduction, m_WeightReduction != 0); SetSaveFlag(ref flags, SaveFlag.DamageIncrease, m_DamageIncrease != 0); SetSaveFlag(ref flags, SaveFlag.Crafter, m_Crafter != null); SetSaveFlag(ref flags, SaveFlag.Quality, true); SetSaveFlag(ref flags, SaveFlag.Capacity, m_Capacity > 0); #region Mondain's Legacy Sets SetSaveFlag(ref flags, SaveFlag.SetAttributes, !m_SetAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SetSkillAttributes, !m_SetSkillBonuses.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SetHue, m_SetHue != 0); SetSaveFlag(ref flags, SaveFlag.LastEquipped, m_LastEquipped); SetSaveFlag(ref flags, SaveFlag.SetEquipped, m_SetEquipped); SetSaveFlag(ref flags, SaveFlag.SetPhysical, m_SetPhysicalBonus != 0); SetSaveFlag(ref flags, SaveFlag.SetFire, m_SetFireBonus != 0); SetSaveFlag(ref flags, SaveFlag.SetCold, m_SetColdBonus != 0); SetSaveFlag(ref flags, SaveFlag.SetPoison, m_SetPoisonBonus != 0); SetSaveFlag(ref flags, SaveFlag.SetEnergy, m_SetEnergyBonus != 0); #endregion writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_Attributes.Serialize(writer); } //if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) // writer.Write((int)m_LowerAmmoCost); if (GetSaveFlag(flags, SaveFlag.WeightReduction)) { writer.Write((int)m_WeightReduction); } if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) { writer.Write((int)m_DamageIncrease); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { writer.Write((Mobile)m_Crafter); } if (GetSaveFlag(flags, SaveFlag.Quality)) { writer.Write((int)m_Quality); } if (GetSaveFlag(flags, SaveFlag.Capacity)) { writer.Write((int)m_Capacity); } #region Mondain's Legacy Sets if (GetSaveFlag(flags, SaveFlag.SetPhysical)) { writer.WriteEncodedInt((int)m_SetPhysicalBonus); } if (GetSaveFlag(flags, SaveFlag.SetFire)) { writer.WriteEncodedInt((int)m_SetFireBonus); } if (GetSaveFlag(flags, SaveFlag.SetCold)) { writer.WriteEncodedInt((int)m_SetColdBonus); } if (GetSaveFlag(flags, SaveFlag.SetPoison)) { writer.WriteEncodedInt((int)m_SetPoisonBonus); } if (GetSaveFlag(flags, SaveFlag.SetEnergy)) { writer.WriteEncodedInt((int)m_SetEnergyBonus); } if (GetSaveFlag(flags, SaveFlag.SetAttributes)) { m_SetAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.SetSkillAttributes)) { m_SetSkillBonuses.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.SetHue)) { writer.Write((int)m_SetHue); } if (GetSaveFlag(flags, SaveFlag.LastEquipped)) { writer.Write((bool)m_LastEquipped); } if (GetSaveFlag(flags, SaveFlag.SetEquipped)) { writer.Write((bool)m_SetEquipped); } #endregion }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)0); // version SaveFlag flags = SaveFlag.None; SetSaveFlag(ref flags, SaveFlag.Attributes, !m_AosAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !m_AosSkillBonuses.IsEmpty); SetSaveFlag(ref flags, SaveFlag.Protection, m_Protection != null && !m_Protection.IsEmpty); SetSaveFlag(ref flags, SaveFlag.Killer, m_Killer != null && !m_Killer.IsEmpty); SetSaveFlag(ref flags, SaveFlag.Summoner, !m_Summoner.IsEmpty); SetSaveFlag(ref flags, SaveFlag.Removal, m_Removal != TalismanRemoval.None); SetSaveFlag(ref flags, SaveFlag.KarmaLoss, m_KarmaLoss != 0); SetSaveFlag(ref flags, SaveFlag.Skill, (int)m_Skill != 0); SetSaveFlag(ref flags, SaveFlag.SuccessBonus, m_SuccessBonus != 0); SetSaveFlag(ref flags, SaveFlag.ExceptionalBonus, m_ExceptionalBonus != 0); SetSaveFlag(ref flags, SaveFlag.MaxCharges, m_MaxCharges != 0); SetSaveFlag(ref flags, SaveFlag.Charges, m_Charges != 0); SetSaveFlag(ref flags, SaveFlag.MaxChargeTime, m_MaxChargeTime != 0); SetSaveFlag(ref flags, SaveFlag.ChargeTime, m_ChargeTime != 0); SetSaveFlag(ref flags, SaveFlag.Blessed, m_Blessed); SetSaveFlag(ref flags, SaveFlag.Slayer, m_Slayer != TalismanSlayerName.None); writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.Protection)) { m_Protection.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.Killer)) { m_Killer.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.Summoner)) { m_Summoner.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.Removal)) { writer.WriteEncodedInt((int)m_Removal); } if (GetSaveFlag(flags, SaveFlag.KarmaLoss)) { writer.WriteEncodedInt(m_KarmaLoss); } if (GetSaveFlag(flags, SaveFlag.Skill)) { writer.WriteEncodedInt((int)m_Skill); } if (GetSaveFlag(flags, SaveFlag.SuccessBonus)) { writer.WriteEncodedInt(m_SuccessBonus); } if (GetSaveFlag(flags, SaveFlag.ExceptionalBonus)) { writer.WriteEncodedInt(m_ExceptionalBonus); } if (GetSaveFlag(flags, SaveFlag.MaxCharges)) { writer.WriteEncodedInt(m_MaxCharges); } if (GetSaveFlag(flags, SaveFlag.Charges)) { writer.WriteEncodedInt(m_Charges); } if (GetSaveFlag(flags, SaveFlag.MaxChargeTime)) { writer.WriteEncodedInt(m_MaxChargeTime); } if (GetSaveFlag(flags, SaveFlag.ChargeTime)) { writer.WriteEncodedInt(m_ChargeTime); } if (GetSaveFlag(flags, SaveFlag.Slayer)) { writer.WriteEncodedInt((int)m_Slayer); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 4: m_PlayerConstructed = reader.ReadBool(); m_LowerStatReq = reader.ReadInt(); goto case 3; case 3: m_UsesRemaining = reader.ReadInt(); m_ShowUsesRemaining = reader.ReadBool(); goto case 2; case 2: m_OriginalHue = reader.ReadInt(); int idx = reader.ReadInt(); m_BaitType = FishInfo.GetTypeFromIndex(idx); m_HookType = (HookType)reader.ReadInt(); m_HookUses = reader.ReadInt(); m_BaitUses = reader.ReadInt(); m_EnhancedBait = reader.ReadBool(); SaveFlag flags = (SaveFlag)reader.ReadInt(); if (GetSaveFlag(flags, SaveFlag.xAttributes)) { m_AosAttributes = new AosAttributes(this, reader); } else { m_AosAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses = new AosSkillBonuses(this, reader); } else { m_AosSkillBonuses = new AosSkillBonuses(this); } break; case 1: m_AosAttributes = new AosAttributes(this); m_AosSkillBonuses = new AosSkillBonuses(this); break; } if (Core.AOS && Parent is Mobile) { m_AosSkillBonuses.AddTo((Mobile)Parent); } int strBonus = m_AosAttributes.BonusStr; int dexBonus = m_AosAttributes.BonusDex; int intBonus = m_AosAttributes.BonusInt; if (this.Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { Mobile m = (Mobile)this.Parent; string modName = this.Serial.ToString(); if (strBonus != 0) { m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero)); } if (dexBonus != 0) { m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero)); } if (intBonus != 0) { m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero)); } } if (Parent is Mobile) { ((Mobile)Parent).CheckStatTimers(); } if (m_BaitType != null && m_BaitUses <= 0) { BaitType = null; } if (m_HookType != HookType.None && m_HookUses <= 0) { HookType = HookType.None; } if (version < 3 && m_Crafter != null) { m_PlayerConstructed = true; if (m_Resource == CraftResource.None) { Resource = CraftResource.RegularWood; } else { DistributeMaterialBonus(); } } }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)5); // version SaveFlag flags = SaveFlag.None; SetSaveFlag(ref flags, SaveFlag.Resource, m_Resource != DefaultResource); SetSaveFlag(ref flags, SaveFlag.Attributes, !m_AosAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.ClothingAttributes, !m_AosClothingAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !m_AosSkillBonuses.IsEmpty); SetSaveFlag(ref flags, SaveFlag.Resistances, !m_AosResistances.IsEmpty); SetSaveFlag(ref flags, SaveFlag.MaxHitPoints, m_MaxHitPoints != 0); SetSaveFlag(ref flags, SaveFlag.HitPoints, m_HitPoints != 0); SetSaveFlag(ref flags, SaveFlag.PlayerConstructed, m_PlayerConstructed != false); SetSaveFlag(ref flags, SaveFlag.Crafter, m_Crafter != null); SetSaveFlag(ref flags, SaveFlag.Quality, m_Quality != ClothingQuality.Regular); SetSaveFlag(ref flags, SaveFlag.StrReq, m_StrReq != -1); writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Resource)) { writer.WriteEncodedInt((int)m_Resource); } if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) { m_AosClothingAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.Resistances)) { m_AosResistances.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { writer.WriteEncodedInt((int)m_MaxHitPoints); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { writer.WriteEncodedInt((int)m_HitPoints); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { writer.Write((Mobile)m_Crafter); } if (GetSaveFlag(flags, SaveFlag.Quality)) { writer.WriteEncodedInt((int)m_Quality); } if (GetSaveFlag(flags, SaveFlag.StrReq)) { writer.WriteEncodedInt((int)m_StrReq); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 7: case 6: case 5: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Identified)) { m_Identified = version >= 7 || reader.ReadBool(); } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { m_MaxHitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { m_HitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (ArmorQuality)reader.ReadEncodedInt(); } else { m_Quality = ArmorQuality.Regular; } if (version == 5 && m_Quality == ArmorQuality.Low) { m_Quality = ArmorQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.Durability)) { m_Durability = (ArmorDurabilityLevel)reader.ReadEncodedInt(); if (m_Durability > ArmorDurabilityLevel.Indestructible) { m_Durability = ArmorDurabilityLevel.Durable; } } if (GetSaveFlag(flags, SaveFlag.Protection)) { m_Protection = (ArmorProtectionLevel)reader.ReadEncodedInt(); if (m_Protection > ArmorProtectionLevel.Invulnerability) { m_Protection = ArmorProtectionLevel.Defense; } } if (GetSaveFlag(flags, SaveFlag.Resource)) { m_Resource = (CraftResource)reader.ReadEncodedInt(); } else { m_Resource = DefaultResource; } if (m_Resource == CraftResource.None) { m_Resource = DefaultResource; } if (GetSaveFlag(flags, SaveFlag.BaseArmor)) { m_ArmorBase = reader.ReadEncodedInt(); } else { m_ArmorBase = -1; } if (GetSaveFlag(flags, SaveFlag.StrBonus)) { m_StrBonus = reader.ReadEncodedInt(); } else { m_StrBonus = -1; } if (GetSaveFlag(flags, SaveFlag.DexBonus)) { m_DexBonus = reader.ReadEncodedInt(); } else { m_DexBonus = -1; } if (GetSaveFlag(flags, SaveFlag.IntBonus)) { m_IntBonus = reader.ReadEncodedInt(); } else { m_IntBonus = -1; } if (GetSaveFlag(flags, SaveFlag.StrReq)) { m_StrReq = reader.ReadEncodedInt(); } else { m_StrReq = -1; } if (GetSaveFlag(flags, SaveFlag.DexReq)) { m_DexReq = reader.ReadEncodedInt(); } else { m_DexReq = -1; } if (GetSaveFlag(flags, SaveFlag.IntReq)) { m_IntReq = reader.ReadEncodedInt(); } else { m_IntReq = -1; } if (GetSaveFlag(flags, SaveFlag.MedAllowance)) { m_Meditate = (AMA)reader.ReadEncodedInt(); } else { m_Meditate = (AMA)(-1); } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = true; } break; } case 4: case 3: case 2: case 1: { m_Identified = reader.ReadBool(); goto case 0; } case 0: { m_ArmorBase = reader.ReadInt(); m_MaxHitPoints = reader.ReadInt(); m_HitPoints = reader.ReadInt(); m_Crafter = reader.ReadMobile(); m_Quality = (ArmorQuality)reader.ReadInt(); m_Durability = (ArmorDurabilityLevel)reader.ReadInt(); m_Protection = (ArmorProtectionLevel)reader.ReadInt(); AMT mat = (AMT)reader.ReadInt(); if (m_ArmorBase == RevertArmorBase) { m_ArmorBase = -1; } if (version >= 2) { m_Resource = (CraftResource)reader.ReadInt(); } else { OreInfo info; switch (reader.ReadInt()) { default: case 0: info = OreInfo.Iron; break; case 1: info = OreInfo.DullCopper; break; case 2: info = OreInfo.ShadowIron; break; case 3: info = OreInfo.Copper; break; case 4: info = OreInfo.Bronze; break; case 5: info = OreInfo.Gold; break; case 6: info = OreInfo.Agapite; break; case 7: info = OreInfo.Verite; break; case 8: info = OreInfo.Valorite; break; } m_Resource = CraftResources.GetFromOreInfo(info, mat); } m_StrBonus = reader.ReadInt(); m_DexBonus = reader.ReadInt(); m_IntBonus = reader.ReadInt(); m_StrReq = reader.ReadInt(); m_DexReq = reader.ReadInt(); m_IntReq = reader.ReadInt(); if (m_StrBonus == OldStrBonus) { m_StrBonus = -1; } if (m_DexBonus == OldDexBonus) { m_DexBonus = -1; } if (m_IntBonus == OldIntBonus) { m_IntBonus = -1; } if (m_StrReq == OldStrReq) { m_StrReq = -1; } if (m_DexReq == OldDexReq) { m_DexReq = -1; } if (m_IntReq == OldIntReq) { m_IntReq = -1; } m_Meditate = (AMA)reader.ReadInt(); if (m_Meditate == OldMedAllowance) { m_Meditate = (AMA)(-1); } if (m_Resource == CraftResource.None) { if (mat == ArmorMaterialType.Studded || mat == ArmorMaterialType.Leather) { m_Resource = CraftResource.RegularLeather; } else { m_Resource = CraftResource.Iron; } } if (m_MaxHitPoints == 0 && m_HitPoints == 0) { m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); } break; } } int strBonus = ComputeStatBonus(StatType.Str); int dexBonus = ComputeStatBonus(StatType.Dex); int intBonus = ComputeStatBonus(StatType.Int); if (Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { Mobile m = (Mobile)Parent; string modName = Serial.ToString(); if (strBonus != 0) { m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero)); } if (dexBonus != 0) { m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero)); } if (intBonus != 0) { m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero)); } } if (Parent is Mobile) { ((Mobile)Parent).CheckStatTimers(); } if (version < 7) { m_PlayerConstructed = true; // we don't know, so, assume it's crafted } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 2: { SaveFlag flags = (SaveFlag)reader.ReadByte(); if (GetSaveFlag(flags, SaveFlag.MaxItems)) { m_MaxItems = reader.ReadEncodedInt(); } else { m_MaxItems = -1; } if (GetSaveFlag(flags, SaveFlag.GumpID)) { m_GumpID = reader.ReadEncodedInt(); } else { m_GumpID = -1; } if (GetSaveFlag(flags, SaveFlag.DropSound)) { m_DropSound = reader.ReadEncodedInt(); } else { m_DropSound = -1; } break; } case 1: { m_MaxItems = reader.ReadInt(); goto case 0; } case 0: { if (version < 1) { m_MaxItems = m_GlobalMaxItems; } m_GumpID = reader.ReadInt(); m_DropSound = reader.ReadInt(); if (m_GumpID == DefaultGumpID) { m_GumpID = -1; } if (m_DropSound == DefaultDropSound) { m_DropSound = -1; } if (m_MaxItems == DefaultMaxItems) { m_MaxItems = -1; } //m_Bounds = new Rectangle2D( reader.ReadPoint2D(), reader.ReadPoint2D() ); reader.ReadPoint2D(); reader.ReadPoint2D(); break; } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 8: { m_Identified = reader.ReadMobileList(); goto case 7; } case 7: case 6: case 5: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes = new AosAttributes(this, reader); } else { m_AosAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.ArmorAttributes)) { m_AosArmorAttributes = new AosArmorAttributes(this, reader); } else { m_AosArmorAttributes = new AosArmorAttributes(this); } if (GetSaveFlag(flags, SaveFlag.PhysicalBonus)) { m_PhysicalBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.FireBonus)) { m_FireBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.ColdBonus)) { m_ColdBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.PoisonBonus)) { m_PoisonBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.EnergyBonus)) { m_EnergyBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Identified) && version < 7) { reader.ReadBool(); } //m_Identified = ( version >= 7 || reader.ReadBool() ); if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { m_MaxHitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { m_HitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (CraftQuality)reader.ReadEncodedInt(); } else { m_Quality = CraftQuality.Regular; } if (version == 5 && m_Quality == CraftQuality.Low) { m_Quality = CraftQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.Durability)) { m_Durability = (DurabilityLevel)reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Protection)) { m_Protection = (ArmorProtectionLevel)reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.BaseArmor)) { m_ArmorBase = reader.ReadEncodedInt(); } else { m_ArmorBase = -1; } if (GetSaveFlag(flags, SaveFlag.StrBonus)) { m_StrBonus = reader.ReadEncodedInt(); } else { m_StrBonus = -1; } if (GetSaveFlag(flags, SaveFlag.DexBonus)) { m_DexBonus = reader.ReadEncodedInt(); } else { m_DexBonus = -1; } if (GetSaveFlag(flags, SaveFlag.IntBonus)) { m_IntBonus = reader.ReadEncodedInt(); } else { m_IntBonus = -1; } if (GetSaveFlag(flags, SaveFlag.StrReq)) { m_StrReq = reader.ReadEncodedInt(); } else { m_StrReq = -1; } if (GetSaveFlag(flags, SaveFlag.DexReq)) { m_DexReq = reader.ReadEncodedInt(); } else { m_DexReq = -1; } if (GetSaveFlag(flags, SaveFlag.IntReq)) { m_IntReq = reader.ReadEncodedInt(); } else { m_IntReq = -1; } if (GetSaveFlag(flags, SaveFlag.MedAllowance)) { m_Meditate = (AMA)reader.ReadEncodedInt(); } else { m_Meditate = (AMA)(-1); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses = new AosSkillBonuses(this, reader); } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = true; } break; } case 4: { m_AosAttributes = new AosAttributes(this, reader); m_AosArmorAttributes = new AosArmorAttributes(this, reader); goto case 3; } case 3: { m_PhysicalBonus = reader.ReadInt(); m_FireBonus = reader.ReadInt(); m_ColdBonus = reader.ReadInt(); m_PoisonBonus = reader.ReadInt(); m_EnergyBonus = reader.ReadInt(); goto case 2; } case 2: case 1: { /*m_Identified = */ reader.ReadBool(); goto case 0; } case 0: { m_ArmorBase = reader.ReadInt(); m_MaxHitPoints = reader.ReadInt(); m_HitPoints = reader.ReadInt(); m_Crafter = reader.ReadMobile(); m_Quality = (CraftQuality)reader.ReadInt(); m_Durability = (DurabilityLevel)reader.ReadInt(); m_Protection = (ArmorProtectionLevel)reader.ReadInt(); AMT mat = (AMT)reader.ReadInt(); if (m_ArmorBase == RevertArmorBase) { m_ArmorBase = -1; } /*m_BodyPos = (ArmorBodyType)*/ reader.ReadInt(); if (version < 4) { m_AosAttributes = new AosAttributes(this); m_AosArmorAttributes = new AosArmorAttributes(this); } if (version < 3 && m_Quality == CraftQuality.Exceptional) { DistributeBonuses(6); } m_StrBonus = reader.ReadInt(); m_DexBonus = reader.ReadInt(); m_IntBonus = reader.ReadInt(); m_StrReq = reader.ReadInt(); m_DexReq = reader.ReadInt(); m_IntReq = reader.ReadInt(); if (m_StrBonus == OldStrBonus) { m_StrBonus = -1; } if (m_DexBonus == OldDexBonus) { m_DexBonus = -1; } if (m_IntBonus == OldIntBonus) { m_IntBonus = -1; } if (m_StrReq == OldStrReq) { m_StrReq = -1; } if (m_DexReq == OldDexReq) { m_DexReq = -1; } if (m_IntReq == OldIntReq) { m_IntReq = -1; } m_Meditate = (AMA)reader.ReadInt(); if (m_Meditate == OldMedAllowance) { m_Meditate = (AMA)(-1); } if (m_MaxHitPoints == 0 && m_HitPoints == 0) { m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); } break; } } if (m_AosSkillBonuses == null) { m_AosSkillBonuses = new AosSkillBonuses(this); } if (Core.AOS && Parent is Mobile) { m_AosSkillBonuses.AddTo((Mobile)Parent); } int strBonus = ComputeStatBonus(StatType.Str); int dexBonus = ComputeStatBonus(StatType.Dex); int intBonus = ComputeStatBonus(StatType.Int); if (Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { Mobile m = (Mobile)Parent; string modName = Serial.ToString(); if (strBonus != 0) { m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero)); } if (dexBonus != 0) { m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero)); } if (intBonus != 0) { m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero)); } } if (Parent is Mobile) { ((Mobile)Parent).CheckStatTimers(); } if (version < 7) { m_PlayerConstructed = true; // we don't know, so, assume it's crafted } }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write(3); // version // Version 3 takes out LowerAmmoCost SaveFlag flags = SaveFlag.None; // Version 2 writer.Write(IsArrowAmmo); // Version 1 m_AosSkillBonuses.Serialize(writer); m_Resistances.Serialize(writer); SetSaveFlag(ref flags, SaveFlag.Attributes, !this.m_Attributes.IsEmpty); //SetSaveFlag(ref flags, SaveFlag.LowerAmmoCost, this.m_LowerAmmoCost != 0); SetSaveFlag(ref flags, SaveFlag.WeightReduction, this.m_WeightReduction != 0); SetSaveFlag(ref flags, SaveFlag.DamageIncrease, this.m_DamageIncrease != 0); SetSaveFlag(ref flags, SaveFlag.Crafter, this.m_Crafter != null); SetSaveFlag(ref flags, SaveFlag.Quality, true); SetSaveFlag(ref flags, SaveFlag.Capacity, this.m_Capacity > 0); #region Mondain's Legacy Sets SetSaveFlag(ref flags, SaveFlag.SetAttributes, !this.m_SetAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SetSkillAttributes, !this.m_SetSkillBonuses.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SetHue, this.m_SetHue != 0); SetSaveFlag(ref flags, SaveFlag.LastEquipped, this.m_LastEquipped); SetSaveFlag(ref flags, SaveFlag.SetEquipped, this.m_SetEquipped); #endregion writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Attributes)) { this.m_Attributes.Serialize(writer); } //if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) // writer.Write((int)this.m_LowerAmmoCost); if (GetSaveFlag(flags, SaveFlag.WeightReduction)) { writer.Write((int)this.m_WeightReduction); } if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) { writer.Write((int)this.m_DamageIncrease); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { writer.Write((Mobile)this.m_Crafter); } if (GetSaveFlag(flags, SaveFlag.Quality)) { writer.Write((int)this.m_Quality); } if (GetSaveFlag(flags, SaveFlag.Capacity)) { writer.Write((int)this.m_Capacity); } #region Mondain's Legacy Sets if (GetSaveFlag(flags, SaveFlag.SetAttributes)) { this.m_SetAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.SetSkillAttributes)) { this.m_SetSkillBonuses.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.SetHue)) { writer.Write((int)this.m_SetHue); } if (GetSaveFlag(flags, SaveFlag.LastEquipped)) { writer.Write((bool)this.m_LastEquipped); } if (GetSaveFlag(flags, SaveFlag.SetEquipped)) { writer.Write((bool)this.m_SetEquipped); } #endregion }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)8); // version writer.WriteMobileList(m_Identified); SaveFlag flags = SaveFlag.None; SetSaveFlag(ref flags, SaveFlag.Attributes, !m_AosAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.ArmorAttributes, !m_AosArmorAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.PhysicalBonus, m_PhysicalBonus != 0); SetSaveFlag(ref flags, SaveFlag.FireBonus, m_FireBonus != 0); SetSaveFlag(ref flags, SaveFlag.ColdBonus, m_ColdBonus != 0); SetSaveFlag(ref flags, SaveFlag.PoisonBonus, m_PoisonBonus != 0); SetSaveFlag(ref flags, SaveFlag.EnergyBonus, m_EnergyBonus != 0); //SetSaveFlag( ref flags, SaveFlag.Identified, m_Identified != false ); SetSaveFlag(ref flags, SaveFlag.MaxHitPoints, m_MaxHitPoints != 0); SetSaveFlag(ref flags, SaveFlag.HitPoints, m_HitPoints != 0); SetSaveFlag(ref flags, SaveFlag.Crafter, m_Crafter != null); SetSaveFlag(ref flags, SaveFlag.Quality, m_Quality != CraftQuality.Regular); SetSaveFlag(ref flags, SaveFlag.Durability, m_Durability != DurabilityLevel.Regular); SetSaveFlag(ref flags, SaveFlag.Protection, m_Protection != ArmorProtectionLevel.Regular); SetSaveFlag(ref flags, SaveFlag.BaseArmor, m_ArmorBase != -1); SetSaveFlag(ref flags, SaveFlag.StrBonus, m_StrBonus != -1); SetSaveFlag(ref flags, SaveFlag.DexBonus, m_DexBonus != -1); SetSaveFlag(ref flags, SaveFlag.IntBonus, m_IntBonus != -1); SetSaveFlag(ref flags, SaveFlag.StrReq, m_StrReq != -1); SetSaveFlag(ref flags, SaveFlag.DexReq, m_DexReq != -1); SetSaveFlag(ref flags, SaveFlag.IntReq, m_IntReq != -1); SetSaveFlag(ref flags, SaveFlag.MedAllowance, m_Meditate != (AMA)(-1)); SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !m_AosSkillBonuses.IsEmpty); SetSaveFlag(ref flags, SaveFlag.PlayerConstructed, m_PlayerConstructed != false); writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.ArmorAttributes)) { m_AosArmorAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.PhysicalBonus)) { writer.WriteEncodedInt((int)m_PhysicalBonus); } if (GetSaveFlag(flags, SaveFlag.FireBonus)) { writer.WriteEncodedInt((int)m_FireBonus); } if (GetSaveFlag(flags, SaveFlag.ColdBonus)) { writer.WriteEncodedInt((int)m_ColdBonus); } if (GetSaveFlag(flags, SaveFlag.PoisonBonus)) { writer.WriteEncodedInt((int)m_PoisonBonus); } if (GetSaveFlag(flags, SaveFlag.EnergyBonus)) { writer.WriteEncodedInt((int)m_EnergyBonus); } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { writer.WriteEncodedInt((int)m_MaxHitPoints); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { writer.WriteEncodedInt((int)m_HitPoints); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { writer.Write((Mobile)m_Crafter); } if (GetSaveFlag(flags, SaveFlag.Quality)) { writer.WriteEncodedInt((int)m_Quality); } if (GetSaveFlag(flags, SaveFlag.Durability)) { writer.WriteEncodedInt((int)m_Durability); } if (GetSaveFlag(flags, SaveFlag.Protection)) { writer.WriteEncodedInt((int)m_Protection); } if (GetSaveFlag(flags, SaveFlag.BaseArmor)) { writer.WriteEncodedInt((int)m_ArmorBase); } if (GetSaveFlag(flags, SaveFlag.StrBonus)) { writer.WriteEncodedInt((int)m_StrBonus); } if (GetSaveFlag(flags, SaveFlag.DexBonus)) { writer.WriteEncodedInt((int)m_DexBonus); } if (GetSaveFlag(flags, SaveFlag.IntBonus)) { writer.WriteEncodedInt((int)m_IntBonus); } if (GetSaveFlag(flags, SaveFlag.StrReq)) { writer.WriteEncodedInt((int)m_StrReq); } if (GetSaveFlag(flags, SaveFlag.DexReq)) { writer.WriteEncodedInt((int)m_DexReq); } if (GetSaveFlag(flags, SaveFlag.IntReq)) { writer.WriteEncodedInt((int)m_IntReq); } if (GetSaveFlag(flags, SaveFlag.MedAllowance)) { writer.WriteEncodedInt((int)m_Meditate); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses.Serialize(writer); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 9: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Resource)) { m_Resource = (CraftResource)reader.ReadInt(); } else { m_Resource = DefaultResource; } if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_MagicalAttributes = new MagicalAttributes(this, reader); } else { m_MagicalAttributes = new MagicalAttributes(this); } if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) { m_ClothingAttributes = new ArmorAttributes(this, reader); } else { m_ClothingAttributes = new ArmorAttributes(this); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_SkillBonuses = new SkillBonuses(this, reader); } else { m_SkillBonuses = new SkillBonuses(this); } if (GetSaveFlag(flags, SaveFlag.Resistances)) { m_Resistances = new ElementAttributes(this, reader); } else { m_Resistances = new ElementAttributes(this); } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { m_MaxHitPoints = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { m_HitPoints = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Exceptional)) { m_Exceptional = true; } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = true; } if (GetSaveFlag(flags, SaveFlag.AbsorptionAttributes)) { m_AbsorptionAttributes = new AbsorptionAttributes(this, reader); } else { m_AbsorptionAttributes = new AbsorptionAttributes(this); } if (GetSaveFlag(flags, SaveFlag.Altered)) { m_Altered = true; } break; } case 8: { m_AbsorptionAttributes = new AbsorptionAttributes(this, reader); m_MaxHitPoints = reader.ReadInt(); m_HitPoints = reader.ReadInt(); m_Resource = (CraftResource)reader.ReadInt(); m_MagicalAttributes = new MagicalAttributes(this, reader); m_ClothingAttributes = new ArmorAttributes(this, reader); m_SkillBonuses = new SkillBonuses(this, reader); m_Resistances = new ElementAttributes(this, reader); break; } } Mobile parent = Parent as Mobile; if (parent != null) { m_SkillBonuses.AddTo(parent); AddStatBonuses(parent); parent.CheckStatTimers(); } }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)9); // version SaveFlag flags = SaveFlag.None; SetSaveFlag(ref flags, SaveFlag.Resource, m_Resource != DefaultResource); SetSaveFlag(ref flags, SaveFlag.Attributes, !m_MagicalAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.ClothingAttributes, !m_ClothingAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SkillBonuses, !m_SkillBonuses.IsEmpty); SetSaveFlag(ref flags, SaveFlag.Resistances, !m_Resistances.IsEmpty); SetSaveFlag(ref flags, SaveFlag.MaxHitPoints, m_MaxHitPoints != 0); SetSaveFlag(ref flags, SaveFlag.HitPoints, m_HitPoints != 0); SetSaveFlag(ref flags, SaveFlag.PlayerConstructed, m_PlayerConstructed != false); SetSaveFlag(ref flags, SaveFlag.Crafter, m_Crafter != null); SetSaveFlag(ref flags, SaveFlag.Exceptional, m_Exceptional != false); SetSaveFlag(ref flags, SaveFlag.AbsorptionAttributes, !m_AbsorptionAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.Altered, m_Altered); writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Resource)) { writer.Write((int)m_Resource); } if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_MagicalAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) { m_ClothingAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_SkillBonuses.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.Resistances)) { m_Resistances.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { writer.Write((int)m_MaxHitPoints); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { writer.Write((int)m_HitPoints); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { writer.Write((Mobile)m_Crafter); } if (GetSaveFlag(flags, SaveFlag.AbsorptionAttributes)) { m_AbsorptionAttributes.Serialize(writer); } }
private static void SetSaveFlag( ref SaveFlag flags, SaveFlag toSet, bool setIf ) { if ( setIf ) flags |= toSet; }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write((int)7); // version SaveFlag flags = SaveFlag.None; SetSaveFlag(ref flags, SaveFlag.Identified, m_Identified != false); SetSaveFlag(ref flags, SaveFlag.MaxHitPoints, m_MaxHitPoints != 0); SetSaveFlag(ref flags, SaveFlag.HitPoints, m_HitPoints != 0); SetSaveFlag(ref flags, SaveFlag.Crafter, m_Crafter != null); SetSaveFlag(ref flags, SaveFlag.Quality, m_Quality != ArmorQuality.Regular); SetSaveFlag(ref flags, SaveFlag.Durability, m_Durability != ArmorDurabilityLevel.Regular); SetSaveFlag(ref flags, SaveFlag.Protection, m_Protection != ArmorProtectionLevel.Regular); SetSaveFlag(ref flags, SaveFlag.Resource, m_Resource != DefaultResource); SetSaveFlag(ref flags, SaveFlag.BaseArmor, m_ArmorBase != -1); SetSaveFlag(ref flags, SaveFlag.StrBonus, m_StrBonus != -1); SetSaveFlag(ref flags, SaveFlag.DexBonus, m_DexBonus != -1); SetSaveFlag(ref flags, SaveFlag.IntBonus, m_IntBonus != -1); SetSaveFlag(ref flags, SaveFlag.StrReq, m_StrReq != -1); SetSaveFlag(ref flags, SaveFlag.DexReq, m_DexReq != -1); SetSaveFlag(ref flags, SaveFlag.IntReq, m_IntReq != -1); SetSaveFlag(ref flags, SaveFlag.MedAllowance, m_Meditate != (AMA)(-1)); SetSaveFlag(ref flags, SaveFlag.PlayerConstructed, m_PlayerConstructed != false); writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { writer.WriteEncodedInt((int)m_MaxHitPoints); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { writer.WriteEncodedInt((int)m_HitPoints); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { writer.Write((Mobile)m_Crafter); } if (GetSaveFlag(flags, SaveFlag.Quality)) { writer.WriteEncodedInt((int)m_Quality); } if (GetSaveFlag(flags, SaveFlag.Durability)) { writer.WriteEncodedInt((int)m_Durability); } if (GetSaveFlag(flags, SaveFlag.Protection)) { writer.WriteEncodedInt((int)m_Protection); } if (GetSaveFlag(flags, SaveFlag.Resource)) { writer.WriteEncodedInt((int)m_Resource); } if (GetSaveFlag(flags, SaveFlag.BaseArmor)) { writer.WriteEncodedInt((int)m_ArmorBase); } if (GetSaveFlag(flags, SaveFlag.StrBonus)) { writer.WriteEncodedInt((int)m_StrBonus); } if (GetSaveFlag(flags, SaveFlag.DexBonus)) { writer.WriteEncodedInt((int)m_DexBonus); } if (GetSaveFlag(flags, SaveFlag.IntBonus)) { writer.WriteEncodedInt((int)m_IntBonus); } if (GetSaveFlag(flags, SaveFlag.StrReq)) { writer.WriteEncodedInt((int)m_StrReq); } if (GetSaveFlag(flags, SaveFlag.DexReq)) { writer.WriteEncodedInt((int)m_DexReq); } if (GetSaveFlag(flags, SaveFlag.IntReq)) { writer.WriteEncodedInt((int)m_IntReq); } if (GetSaveFlag(flags, SaveFlag.MedAllowance)) { writer.WriteEncodedInt((int)m_Meditate); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 4: { _VvVItem = reader.ReadBool(); _Owner = reader.ReadMobile(); _OwnerName = reader.ReadString(); goto case 3; } case 3: case 2: IsArrowAmmo = reader.ReadBool(); goto case 1; case 1: { if (version == 1) { IsArrowAmmo = (Ammo == null || Ammo is Arrow); } m_AosSkillBonuses = new AosSkillBonuses(this, reader); m_Resistances = new AosElementAttributes(this, reader); goto case 0; } case 0: { if (version == 0) { m_AosSkillBonuses = new AosSkillBonuses(this); m_Resistances = new AosElementAttributes(this); } SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_Attributes = new AosAttributes(this, reader); } else { m_Attributes = new AosAttributes(this); } if (version < 3 && GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) { m_Attributes.LowerAmmoCost = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.WeightReduction)) { m_WeightReduction = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) { m_DamageIncrease = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (ItemQuality)reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Capacity)) { m_Capacity = reader.ReadInt(); } #region Mondain's Legacy Sets if (GetSaveFlag(flags, SaveFlag.SetPhysical)) { m_SetPhysicalBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetFire)) { m_SetFireBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetCold)) { m_SetColdBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetPoison)) { m_SetPoisonBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetEnergy)) { m_SetEnergyBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetAttributes)) { m_SetAttributes = new AosAttributes(this, reader); } else { m_SetAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.SetSkillAttributes)) { m_SetSkillBonuses = new AosSkillBonuses(this, reader); } else { m_SetSkillBonuses = new AosSkillBonuses(this); } if (GetSaveFlag(flags, SaveFlag.SetHue)) { m_SetHue = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.LastEquipped)) { m_LastEquipped = reader.ReadBool(); } if (GetSaveFlag(flags, SaveFlag.SetEquipped)) { m_SetEquipped = reader.ReadBool(); } #endregion break; } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 7: case 6: case 5: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Identified)) { m_Identified = (version >= 7 || reader.ReadBool()); } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { m_MaxHitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { m_HitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (ArmorQuality)reader.ReadEncodedInt(); } else { m_Quality = ArmorQuality.Regular; } if (version == 5 && m_Quality == ArmorQuality.Low) { m_Quality = ArmorQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.Durability)) { m_Durability = (ArmorDurabilityLevel)reader.ReadEncodedInt(); if (m_Durability > ArmorDurabilityLevel.Indestructible) { m_Durability = ArmorDurabilityLevel.Durable; } } if (GetSaveFlag(flags, SaveFlag.Protection)) { m_Protection = (ArmorProtectionLevel)reader.ReadEncodedInt(); if (m_Protection > ArmorProtectionLevel.Invulnerability) { m_Protection = ArmorProtectionLevel.Defense; } } if (GetSaveFlag(flags, SaveFlag.Resource)) { m_Resource = (CraftResource)reader.ReadEncodedInt(); } else { m_Resource = DefaultResource; } if (m_Resource == CraftResource.None) { m_Resource = DefaultResource; } if (GetSaveFlag(flags, SaveFlag.BaseArmor)) { m_ArmorBase = reader.ReadEncodedInt(); } else { m_ArmorBase = -1; } if (GetSaveFlag(flags, SaveFlag.StrBonus)) { m_StrBonus = reader.ReadEncodedInt(); } else { m_StrBonus = -1; } if (GetSaveFlag(flags, SaveFlag.DexBonus)) { m_DexBonus = reader.ReadEncodedInt(); } else { m_DexBonus = -1; } if (GetSaveFlag(flags, SaveFlag.IntBonus)) { m_IntBonus = reader.ReadEncodedInt(); } else { m_IntBonus = -1; } if (GetSaveFlag(flags, SaveFlag.StrReq)) { m_StrReq = reader.ReadEncodedInt(); } else { m_StrReq = -1; } if (GetSaveFlag(flags, SaveFlag.DexReq)) { m_DexReq = reader.ReadEncodedInt(); } else { m_DexReq = -1; } if (GetSaveFlag(flags, SaveFlag.IntReq)) { m_IntReq = reader.ReadEncodedInt(); } else { m_IntReq = -1; } if (GetSaveFlag(flags, SaveFlag.MedAllowance)) { m_Meditate = (AMA)reader.ReadEncodedInt(); } else { m_Meditate = (AMA)(-1); } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = true; } break; } case 4: case 3: case 2: case 1: { m_Identified = reader.ReadBool(); goto case 0; } case 0: { m_ArmorBase = reader.ReadInt(); m_MaxHitPoints = reader.ReadInt(); m_HitPoints = reader.ReadInt(); m_Crafter = reader.ReadMobile(); m_Quality = (ArmorQuality)reader.ReadInt(); m_Durability = (ArmorDurabilityLevel)reader.ReadInt(); m_Protection = (ArmorProtectionLevel)reader.ReadInt(); AMT mat = (AMT)reader.ReadInt(); if (m_ArmorBase == RevertArmorBase) { m_ArmorBase = -1; } /*m_BodyPos = (ArmorBodyType)*/ reader.ReadInt(); // if ( version < 3 && m_Quality == ArmorQuality.Exceptional ) // Add some AR and HP ?? if (version >= 2) { m_Resource = (CraftResource)reader.ReadInt(); } else { OreInfo info; switch (reader.ReadInt()) { default: case 0: info = OreInfo.Iron; break; case 1: info = OreInfo.DullCopper; break; case 2: info = OreInfo.ShadowIron; break; case 3: info = OreInfo.Copper; break; case 4: info = OreInfo.Bronze; break; case 5: info = OreInfo.Gold; break; case 6: info = OreInfo.Agapite; break; case 7: info = OreInfo.Verite; break; case 8: info = OreInfo.Valorite; break; } m_Resource = CraftResources.GetFromOreInfo(info, mat); } m_StrBonus = reader.ReadInt(); m_DexBonus = reader.ReadInt(); m_IntBonus = reader.ReadInt(); m_StrReq = reader.ReadInt(); m_DexReq = reader.ReadInt(); m_IntReq = reader.ReadInt(); if (m_StrBonus == OldStrBonus) { m_StrBonus = -1; } if (m_DexBonus == OldDexBonus) { m_DexBonus = -1; } if (m_IntBonus == OldIntBonus) { m_IntBonus = -1; } if (m_StrReq == OldStrReq) { m_StrReq = -1; } if (m_DexReq == OldDexReq) { m_DexReq = -1; } if (m_IntReq == OldIntReq) { m_IntReq = -1; } m_Meditate = (AMA)reader.ReadInt(); if (m_Meditate == OldMedAllowance) { m_Meditate = (AMA)(-1); } if (m_Resource == CraftResource.None) { if (mat == ArmorMaterialType.Studded || mat == ArmorMaterialType.Leather) { m_Resource = CraftResource.RegularLeather; } else if (mat == ArmorMaterialType.Spined) { m_Resource = CraftResource.SpinedLeather; } else if (mat == ArmorMaterialType.Horned) { m_Resource = CraftResource.HornedLeather; } else if (mat == ArmorMaterialType.Barbed) { m_Resource = CraftResource.BarbedLeather; } else { m_Resource = CraftResource.Iron; } } if (m_MaxHitPoints == 0 && m_HitPoints == 0) { m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); } break; } } if (Parent is Mobile) { ((Mobile)Parent).CheckStatTimers(); } if (version < 7) { m_PlayerConstructed = true; // we don't know, so, assume it's crafted } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 5: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Resource)) { m_Resource = (CraftResource)reader.ReadEncodedInt(); } else { m_Resource = DefaultResource; } if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes = new AosAttributes(this, reader); } else { m_AosAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) { m_AosClothingAttributes = new AosArmorAttributes(this, reader); } else { m_AosClothingAttributes = new AosArmorAttributes(this); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses = new AosSkillBonuses(this, reader); } else { m_AosSkillBonuses = new AosSkillBonuses(this); } if (GetSaveFlag(flags, SaveFlag.Resistances)) { m_AosResistances = new AosElementAttributes(this, reader); } else { m_AosResistances = new AosElementAttributes(this); } if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) { m_MaxHitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.HitPoints)) { m_HitPoints = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (ClothingQuality)reader.ReadEncodedInt(); } else { m_Quality = ClothingQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.StrReq)) { m_StrReq = reader.ReadEncodedInt(); } else { m_StrReq = -1; } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = true; } break; } case 4: { m_Resource = (CraftResource)reader.ReadInt(); goto case 3; } case 3: { m_AosAttributes = new AosAttributes(this, reader); m_AosClothingAttributes = new AosArmorAttributes(this, reader); m_AosSkillBonuses = new AosSkillBonuses(this, reader); m_AosResistances = new AosElementAttributes(this, reader); goto case 2; } case 2: { m_PlayerConstructed = reader.ReadBool(); goto case 1; } case 1: { m_Crafter = reader.ReadMobile(); m_Quality = (ClothingQuality)reader.ReadInt(); break; } case 0: { m_Crafter = null; m_Quality = ClothingQuality.Regular; break; } } if (version < 2) { m_PlayerConstructed = true; // we don't know, so, assume it's crafted } if (version < 3) { m_AosAttributes = new AosAttributes(this); m_AosClothingAttributes = new AosArmorAttributes(this); m_AosSkillBonuses = new AosSkillBonuses(this); m_AosResistances = new AosElementAttributes(this); } if (version < 4) { m_Resource = DefaultResource; } if (m_MaxHitPoints == 0 && m_HitPoints == 0) { m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); } Mobile parent = Parent as Mobile; if (parent != null) { if (Core.AOS) { m_AosSkillBonuses.AddTo(parent); } AddStatBonuses(parent); parent.CheckStatTimers(); } }
public override void Serialize(GenericWriter writer) { base.Serialize(writer); writer.Write(0); // version SaveFlag flags = SaveFlag.None; SetSaveFlag(ref flags, SaveFlag.Attributes, !m_Attributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.LowerAmmoCost, m_LowerAmmoCost != 0); SetSaveFlag(ref flags, SaveFlag.WeightReduction, m_WeightReduction != 0); SetSaveFlag(ref flags, SaveFlag.DamageIncrease, m_DamageIncrease != 0); SetSaveFlag(ref flags, SaveFlag.Crafter, m_Crafter != null); SetSaveFlag(ref flags, SaveFlag.Quality, true); SetSaveFlag(ref flags, SaveFlag.PlayerConstructed, m_PlayerConstructed); SetSaveFlag(ref flags, SaveFlag.Capacity, m_Capacity > 0); #region Mondain's Legacy Sets SetSaveFlag(ref flags, SaveFlag.SetAttributes, !m_SetAttributes.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SetSkillAttributes, !m_SetSkillBonuses.IsEmpty); SetSaveFlag(ref flags, SaveFlag.SetHue, m_SetHue != 0); SetSaveFlag(ref flags, SaveFlag.LastEquipped, m_LastEquipped); SetSaveFlag(ref flags, SaveFlag.SetEquipped, m_SetEquipped); #endregion writer.WriteEncodedInt((int)flags); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_Attributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) { writer.Write((int)m_LowerAmmoCost); } if (GetSaveFlag(flags, SaveFlag.WeightReduction)) { writer.Write((int)m_WeightReduction); } if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) { writer.Write((int)m_DamageIncrease); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { writer.Write((Mobile)m_Crafter); } if (GetSaveFlag(flags, SaveFlag.Quality)) { writer.Write((int)m_Quality); } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { writer.Write((bool)m_PlayerConstructed); } if (GetSaveFlag(flags, SaveFlag.Capacity)) { writer.Write((int)m_Capacity); } #region Mondain's Legacy Sets if (GetSaveFlag(flags, SaveFlag.SetAttributes)) { m_SetAttributes.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.SetSkillAttributes)) { m_SetSkillBonuses.Serialize(writer); } if (GetSaveFlag(flags, SaveFlag.SetHue)) { writer.Write((int)m_SetHue); } if (GetSaveFlag(flags, SaveFlag.LastEquipped)) { writer.Write((bool)m_LastEquipped); } if (GetSaveFlag(flags, SaveFlag.SetEquipped)) { writer.Write((bool)m_SetEquipped); } #endregion }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 4: { _VvVItem = reader.ReadBool(); _Owner = reader.ReadMobile(); _OwnerName = reader.ReadString(); goto case 3; } case 3: case 2: IsArrowAmmo = reader.ReadBool(); goto case 1; case 1: { if (version == 1) { IsArrowAmmo = (Ammo == null || Ammo is Arrow); } m_AosSkillBonuses = new AosSkillBonuses(this, reader); m_Resistances = new AosElementAttributes(this, reader); goto case 0; } case 0: { if (version == 0) { m_AosSkillBonuses = new AosSkillBonuses(this); m_Resistances = new AosElementAttributes(this); } SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_Attributes = new AosAttributes(this, reader); } else { m_Attributes = new AosAttributes(this); } if (version < 3 && GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) { m_Attributes.LowerAmmoCost = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.WeightReduction)) { m_WeightReduction = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) { m_DamageIncrease = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (ItemQuality)reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Capacity)) { m_Capacity = reader.ReadInt(); } #region Mondain's Legacy Sets if (GetSaveFlag(flags, SaveFlag.SetPhysical)) { m_SetPhysicalBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetFire)) { m_SetFireBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetCold)) { m_SetColdBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetPoison)) { m_SetPoisonBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetEnergy)) { m_SetEnergyBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SetAttributes)) { m_SetAttributes = new AosAttributes(this, reader); } else { m_SetAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.SetSkillAttributes)) { m_SetSkillBonuses = new AosSkillBonuses(this, reader); } else { m_SetSkillBonuses = new AosSkillBonuses(this); } if (GetSaveFlag(flags, SaveFlag.SetHue)) { m_SetHue = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.LastEquipped)) { m_LastEquipped = reader.ReadBool(); } if (GetSaveFlag(flags, SaveFlag.SetEquipped)) { m_SetEquipped = reader.ReadBool(); } #endregion break; } } int strBonus = ComputeStatBonus(StatType.Str); int dexBonus = ComputeStatBonus(StatType.Dex); int intBonus = ComputeStatBonus(StatType.Int); if (Parent is Mobile && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { Mobile m = (Mobile)Parent; string modName = Serial.ToString(); if (strBonus != 0) { m.AddStatMod(new StatMod(StatType.Str, modName + "Str", strBonus, TimeSpan.Zero)); } if (dexBonus != 0) { m.AddStatMod(new StatMod(StatType.Dex, modName + "Dex", dexBonus, TimeSpan.Zero)); } if (intBonus != 0) { m.AddStatMod(new StatMod(StatType.Int, modName + "Int", intBonus, TimeSpan.Zero)); } } if (Parent is Mobile) { m_AosSkillBonuses.AddTo((Mobile)Parent); ((Mobile)Parent).CheckStatTimers(); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_Attributes = new AosAttributes(this, reader); } else { m_Attributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.LowerAmmoCost)) { m_LowerAmmoCost = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.WeightReduction)) { m_WeightReduction = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.DamageIncrease)) { m_DamageIncrease = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (ClothingQuality)reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = reader.ReadBool(); } if (GetSaveFlag(flags, SaveFlag.Capacity)) { m_Capacity = reader.ReadInt(); } #region Mondain's Legacy Sets if (GetSaveFlag(flags, SaveFlag.SetAttributes)) { m_SetAttributes = new AosAttributes(this, reader); } else { m_SetAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.SetSkillAttributes)) { m_SetSkillBonuses = new AosSkillBonuses(this, reader); } else { m_SetSkillBonuses = new AosSkillBonuses(this); } if (GetSaveFlag(flags, SaveFlag.SetHue)) { m_SetHue = reader.ReadInt(); } if (GetSaveFlag(flags, SaveFlag.LastEquipped)) { m_LastEquipped = reader.ReadBool(); } if (GetSaveFlag(flags, SaveFlag.SetEquipped)) { m_SetEquipped = reader.ReadBool(); } #endregion if (version == 1) { Layer = Layer.Cloak; } }
private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0;
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 2: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (CiderQuality)reader.ReadEncodedInt(); } else { m_Quality = CiderQuality.Regular; } if (m_Quality == CiderQuality.Low) { m_Quality = CiderQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.Variety)) { m_Variety = (HopsVariety)reader.ReadEncodedInt(); } else { m_Variety = DefaultVariety; } if (m_Variety == HopsVariety.None) { m_Variety = DefaultVariety; } //break; goto case 1; } case 1: { m_Poisoner = reader.ReadMobile(); goto case 0; } case 0: { m_Poison = Poison.Deserialize(reader); m_FillFactor = reader.ReadInt(); /* * m_Crafter = reader.ReadMobile(); * m_Quality = (CiderQuality)reader.ReadInt(); * * if ( version >= 2 ) * { * m_Variety = (HopsVariety)reader.ReadInt(); * } * else * { * HopsInfo info; * * switch ( reader.ReadInt() ) * { * default: * case 0: info = HopsInfo.BitterHops; break; * case 1: info = HopsInfo.SnowHops; break; * case 2: info = HopsInfo.ElvenHops; break; * case 3: info = HopsInfo.SweetHops; break; * } * * m_Variety = BrewingResources.GetFromHopsInfo( info ); * } */ break; } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 0: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes = new AosAttributes(this, reader); } else { m_AosAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses = new AosSkillBonuses(this, reader); } else { m_AosSkillBonuses = new AosSkillBonuses(this); } // Backward compatibility if (GetSaveFlag(flags, SaveFlag.Owner)) { BlessedFor = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Protection)) { m_Protection = new TalismanAttribute(reader); } else { m_Protection = new TalismanAttribute(); } if (GetSaveFlag(flags, SaveFlag.Killer)) { m_Killer = new TalismanAttribute(reader); } else { m_Killer = new TalismanAttribute(); } if (GetSaveFlag(flags, SaveFlag.Summoner)) { m_Summoner = new TalismanAttribute(reader); } else { m_Summoner = new TalismanAttribute(); } if (GetSaveFlag(flags, SaveFlag.Removal)) { m_Removal = (TalismanRemoval)reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.KarmaLoss)) { m_KarmaLoss = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Skill)) { m_Skill = (SkillName)reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.SuccessBonus)) { m_SuccessBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.ExceptionalBonus)) { m_ExceptionalBonus = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.MaxCharges)) { m_MaxCharges = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Charges)) { m_Charges = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.MaxChargeTime)) { m_MaxChargeTime = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.ChargeTime)) { m_ChargeTime = reader.ReadEncodedInt(); } if (GetSaveFlag(flags, SaveFlag.Slayer)) { m_Slayer = (TalismanSlayerName)reader.ReadEncodedInt(); } m_Blessed = GetSaveFlag(flags, SaveFlag.Blessed); break; } } if (Parent is Mobile) { Mobile m = (Mobile)Parent; m_AosAttributes.AddStatBonuses(m); m_AosSkillBonuses.AddTo(m); if (m_ChargeTime > 0) { StartTimer(); } } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 5: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Resource)) { m_Resource = (CraftResource)reader.ReadEncodedInt(); } else { m_Resource = DefaultResource; } if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes = new AosAttributes(this, reader); } else { m_AosAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) { m_AosClothingAttributes = new AosArmorAttributes(this, reader); } else { m_AosClothingAttributes = new AosArmorAttributes(this); } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses = new AosSkillBonuses(this, reader); } else { m_AosSkillBonuses = new AosSkillBonuses(this); } if (GetSaveFlag(flags, SaveFlag.Resistances)) { m_AosResistances = new AosElementAttributes(this, reader); } else { m_AosResistances = new AosElementAttributes(this); } if (GetSaveFlag(flags, SaveFlag.StrReq)) { m_StrReq = reader.ReadEncodedInt(); } else { m_StrReq = -1; } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = true; } m_IsInvisible = GetSaveFlag(flags, SaveFlag.IPYInvisible); break; } case 4: { m_Resource = (CraftResource)reader.ReadInt(); goto case 3; } case 3: { m_AosAttributes = new AosAttributes(this, reader); m_AosClothingAttributes = new AosArmorAttributes(this, reader); m_AosSkillBonuses = new AosSkillBonuses(this, reader); m_AosResistances = new AosElementAttributes(this, reader); goto case 2; } case 2: { m_PlayerConstructed = reader.ReadBool(); goto case 1; } case 1: { break; } case 0: { break; } } if (version < 2) { m_PlayerConstructed = true; // we don't know, so, assume it's crafted } if (version < 3) { m_AosAttributes = new AosAttributes(this); m_AosClothingAttributes = new AosArmorAttributes(this); m_AosSkillBonuses = new AosSkillBonuses(this); m_AosResistances = new AosElementAttributes(this); } if (version < 4) { m_Resource = DefaultResource; } Mobile parent = Parent as Mobile; if (parent != null) { if (Core.AOS) { m_AosSkillBonuses.AddTo(parent); } AddStatBonuses(parent); parent.CheckStatTimers(); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 1: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Attributes)) { m_AosAttributes = new AosAttributes(this, reader); } else { m_AosAttributes = new AosAttributes(this); } if (GetSaveFlag(flags, SaveFlag.ArmorAttributes)) { m_AosArmorAttributes = new AosArmorAttributes(this, reader); } else { m_AosArmorAttributes = new AosArmorAttributes(this); } if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (CraftQuality)reader.ReadEncodedInt(); } else { m_Quality = CraftQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.Resource)) { m_Resource = (CraftResource)reader.ReadEncodedInt(); } else { m_Resource = DefaultResource; } if (m_Resource == CraftResource.None) { m_Resource = DefaultResource; } if (GetSaveFlag(flags, SaveFlag.StrReq)) { m_StrReq = reader.ReadEncodedInt(); } else { m_StrReq = -1; } if (GetSaveFlag(flags, SaveFlag.DexReq)) { m_DexReq = reader.ReadEncodedInt(); } else { m_DexReq = -1; } if (GetSaveFlag(flags, SaveFlag.IntReq)) { m_IntReq = reader.ReadEncodedInt(); } else { m_IntReq = -1; } if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) { m_AosSkillBonuses = new AosSkillBonuses(this, reader); } if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) { m_PlayerConstructed = true; } if (GetSaveFlag(flags, SaveFlag.BonusRandomAttributes)) { m_BonusRandomAttributes = new BonusAttribute[reader.ReadInt()]; for (int i = 0; i < m_BonusRandomAttributes.Length; i++) { m_BonusRandomAttributes[i] = new BonusAttribute(reader); } } break; } case 0: { m_InheritsItem = true; m_OldVersion = version; m_AosAttributes = new AosAttributes(this); m_AosArmorAttributes = new AosArmorAttributes(this); m_Quality = CraftQuality.Regular; m_Resource = DefaultResource; m_PlayerConstructed = true; break; } } if (m_AosSkillBonuses == null) { m_AosSkillBonuses = new AosSkillBonuses(this); } if (Core.AOS && Parent is Mobile) { m_AosSkillBonuses.AddTo((Mobile)Parent); } if (Parent is Mobile) { ((Mobile)Parent).CheckStatTimers(); } }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 2: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (JuiceQuality)reader.ReadEncodedInt(); } else { m_Quality = JuiceQuality.Regular; } if (m_Quality == JuiceQuality.Low) { m_Quality = JuiceQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.Variety)) { m_Variety = (FruitsVariety)reader.ReadEncodedInt(); } else { m_Variety = DefaultVariety; } if (m_Variety == FruitsVariety.None) { m_Variety = DefaultVariety; } //break; goto case 1; } case 1: { m_Poisoner = reader.ReadMobile(); goto case 0; } case 0: { m_Poison = Poison.Deserialize(reader); m_FillFactor = reader.ReadInt(); /* * m_Crafter = reader.ReadMobile(); * m_Quality = (JuiceQuality)reader.ReadInt(); * * if ( version >= 2 ) * { * m_Variety = (FruitsVariety)reader.ReadInt(); * } * else * { * FruitsInfo info; * * switch ( reader.ReadInt() ) * { * default: * case 0: info = FruitsInfo.Apple; break; * case 1: info = FruitsInfo.Banana; break; * case 2: info = FruitsInfo.Dates; break; * case 3: info = FruitsInfo.Grapes; break; * case 4: info = FruitsInfo.Lemon; break; * case 5: info = FruitsInfo.Lime; break; * case 6: info = FruitsInfo.Orange; break; * case 7: info = FruitsInfo.Peach; break; * case 8: info = FruitsInfo.Pear; break; * case 9: info = FruitsInfo.Pumpkin; break; * case 10: info = FruitsInfo.Tomato; break; * case 11: info = FruitsInfo.Watermelon; break; * case 12: info = FruitsInfo.Apricot; break; * case 13: info = FruitsInfo.Blackberries; break; * case 14: info = FruitsInfo.Blueberries; break; * case 15: info = FruitsInfo.Cherries; break; * case 16: info = FruitsInfo.Cranberries; break; * case 17: info = FruitsInfo.Grapefruit; break; * case 18: info = FruitsInfo.Kiwi; break; * case 19: info = FruitsInfo.Mango; break; * case 20: info = FruitsInfo.Pineappe; break; * case 21: info = FruitsInfo.Pomegranate; break; * case 22: info = FruitsInfo.Strawberry; break; * } * * m_Variety = BrewingResources.GetFromFruitsInfo( info ); * } */ break; } } }
private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) { return((flags & toGet) != 0); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); switch (version) { case 2: { SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); if (GetSaveFlag(flags, SaveFlag.Crafter)) { m_Crafter = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.Quality)) { m_Quality = (WineQuality)reader.ReadEncodedInt(); } else { m_Quality = WineQuality.Regular; } if (m_Quality == WineQuality.Low) { m_Quality = WineQuality.Regular; } if (GetSaveFlag(flags, SaveFlag.Variety)) { m_Variety = (GrapeVariety)reader.ReadEncodedInt(); } else { m_Variety = DefaultVariety; } if (m_Variety == GrapeVariety.None) { m_Variety = DefaultVariety; } goto case 1; } case 1: { m_Poisoner = reader.ReadMobile(); goto case 0; } case 0: { m_Poison = Poison.Deserialize(reader); m_FillFactor = reader.ReadInt(); break; } } }
private static bool GetSaveFlag( SaveFlag flags, SaveFlag toGet ) { return ( (flags & toGet) != 0 ); }
public virtual void Deserialize(GenericReader reader) { int version = reader.ReadInt(); SaveFlag flags = SaveFlag.None; if (version >= 4) { flags = (SaveFlag)reader.ReadInt(); } switch (version) { case 4: if (GetSaveFlag(flags, SaveFlag.ExpireActCondition)) { m_ExpireActCondition = reader.ReadString(); } if (GetSaveFlag(flags, SaveFlag.ExpireAction)) { m_ExpireAction = reader.ReadString(); } if (GetSaveFlag(flags, SaveFlag.ExpireTrigMob)) { m_ExpireTrigMob = reader.ReadMobile(); } if (GetSaveFlag(flags, SaveFlag.AttachedBy)) { m_AttachedBy = reader.ReadString(); } if (GetSaveFlag(flags, SaveFlag.OwnedByMobile)) { OwnedBy = reader.ReadMobile(); } else if (GetSaveFlag(flags, SaveFlag.OwnedByItem)) { OwnedBy = reader.ReadItem(); } if (GetSaveFlag(flags, SaveFlag.Name)) { Name = reader.ReadString(); } // if there are any active timers, then serialize if (GetSaveFlag(flags, SaveFlag.Expiration)) { m_Expiration = reader.ReadTimeSpan(); } if (GetSaveFlag(flags, SaveFlag.ExpirationEnd)) { TimeSpan remainingTime = reader.ReadTimeSpan(); if (remainingTime > TimeSpan.Zero) { DoTimer(remainingTime); } } if (GetSaveFlag(flags, SaveFlag.CreationTime)) { m_CreationTime = reader.ReadDateTime(); } // DO NOT GO ON TO CASE 3 OR BELOW! break; // =============== OLD DESERIALIZATION ===================== case 3: m_ExpireAction = reader.ReadString(); m_ExpireActCondition = reader.ReadString(); m_ExpireTrigMob = reader.ReadMobile(); goto case 2; case 2: m_AttachedBy = reader.ReadString(); goto case 1; case 1: int owned = reader.ReadInt(); if (owned == 0) { OwnedBy = reader.ReadItem(); } else if (owned == 1) { OwnedBy = reader.ReadMobile(); } else { OwnedBy = null; } goto case 0; case 0: // version 0 Name = reader.ReadString(); m_Expiration = reader.ReadTimeSpan(); TimeSpan remaining = reader.ReadTimeSpan(); if (remaining > TimeSpan.Zero) { DoTimer(remaining); } m_CreationTime = reader.ReadDateTime(); break; } }