Exemplo n.º 1
0
    private void SpawnUI()
    {
        if (currentlySpawnablePrefabs.Count == 0)
        {
            return;
        }

        int        spawnIndex             = Random.Range(0, currentlySpawnablePrefabs.Count);
        GameObject currentSpawnablePrefab = currentlySpawnablePrefabs[spawnIndex];
        var        spawned = Instantiate <GameObject>(currentSpawnablePrefab, canvas.transform);

        ruleController.RandomizeObject(spawned);

        ElementAttributes eA = currentSpawnablePrefab.GetComponent <ElementAttributes>();

        if (eA.IsUnique)
        {
            currentlySpawnablePrefabs.RemoveAt(spawnIndex);
        }

        if (eA.IsPersistent)
        {
            ++currentPresistentElements;
            if (currentPresistentElements >= GetLevelArrayValue(maxPersistentElement))
            {
                PurgetPersistentElements();
            }
        }
    }
Exemplo n.º 2
0
        public void DealElementalDamage(ElementAttributes e, int duration, int damage = -1)
        {
            int power = (damage != -1)? damage : Engine.Engine.currentLevel.DungeonLevel;

            if (elementDamageTime <= 0)
            {
                elementDamageTime = duration;

            }

            if (e == ElementAttributes.Fire)
            {
                elementDamage = (int)(1.5d * (double)power);
            }
            else if (e == ElementAttributes.Ice)
            {
                elementDamage = power;
                isFrozen = true;
            }
            else if (e == ElementAttributes.Lighting)
            {
                elementDamage = 2 * power;
            }
            else if (e == ElementAttributes.Arcane)
            {
                if (elementDamageTime > 1)
                {
                    elementDamage = (int)((double)power);
                }
                else if (elementDamageTime == 1)
                {
                    elementDamage = (int)(6 * (double)power);
                }
               }
        }
Exemplo n.º 3
0
        public void DealElementalDamage(ElementAttributes e, int duration, int damage = -1)
        {
            int power = (damage != -1)? damage : Engine.Engine.currentLevel.DungeonLevel;

            if (elementDamageTime <= 0)
            {
                elementDamageTime = duration;
            }

            if (e == ElementAttributes.Fire)
            {
                elementDamage = (int)(1.5d * (double)power);
            }
            else if (e == ElementAttributes.Ice)
            {
                elementDamage = power;
                isFrozen      = true;
            }
            else if (e == ElementAttributes.Lighting)
            {
                elementDamage = 2 * power;
            }
            else if (e == ElementAttributes.Arcane)
            {
                if (elementDamageTime > 1)
                {
                    elementDamage = (int)((double)power);
                }
                else if (elementDamageTime == 1)
                {
                    elementDamage = (int)(6 * (double)power);
                }
            }
        }
        private void ConfigureTabIndex()
        {
            const string tabIndexKey = "tabindex";

            if (ElementTag == "button")
            {
                return;
            }

            if (!ElementAttributes.ContainsKey(tabIndexKey))
            {
                ElementAttributes.Add(tabIndexKey, 0);
            }

            if (TabIndex.HasValue)
            {
                ElementAttributes[tabIndexKey] = TabIndex.Value;
                return;
            }

            if (Disabled)
            {
                ElementAttributes[tabIndexKey] = -1;
                return;
            }

            if (ElementTag == "div")
            {
                ElementAttributes[tabIndexKey] = 0;
            }
        }
 private void ConfigureRole()
 {
     if (!string.IsNullOrWhiteSpace(Role))
     {
         if (!ElementAttributes.ContainsKey("role"))
         {
             ElementAttributes.Add("role", Role);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Combines the attributes, id and classnames into an HTML string.
        /// </summary>
        public virtual string FormatAttributes()
        {
            var attributes = ElementAttributes
                             .Guard()
                             .ChainSet("id", ElementId)
                             .ChainSet("class", string.Join(" ", ElementClassNames.Guard()))
                             .Where(kvp => !string.IsNullOrEmpty(kvp.Value))
                             .Select(kvp => $"{EscapeString(kvp.Key)}=\"{EscapeString(kvp.Value)}\"");

            return(string.Join(" ", attributes));
        }
        /// <inheritdoc />
        protected override void ConfigureComponent()
        {
            ElementTag   = "button";
            ElementClass = "ui";

            ConfigureAnimation();

            ConfigureSize();

            ConfigureAttached();

            ConfigureTabIndex();

            ConfigureRole();

            ConfigureFloated();

            ConfigureLabelPosition();

            ConfigureColor();

            ConfigureBasic();

            ConfigureCompact();

            ConfigureActive();

            ConfigureToggle();

            ConfigureCircular();

            ConfigureLoading();

            ConfigureEmphasis();

            ConfigureIcon();

            ConfigurePositive();

            ConfigureNegative();

            ConfigureFluid();

            ConfigureDisabled();

            ConfigureInverted();

            ElementClass = $"{ElementClass} button";

            if (!ElementAttributes.ContainsKey("onclick"))
            {
                ElementAttributes.Add("onclick", OnClick);
            }
        }
Exemplo n.º 8
0
        }                                                                   // Talisman

        public BaseTalisman(int ItemID)
            : base(ItemID)
        {
            Layer = Layer.Talisman;

            m_MagicalAttributes = new MagicalAttributes(this);
            m_AosResistances    = new ElementAttributes(this);
            m_SkillBonuses      = new SkillBonuses(this);

            // 1% chance to spawn with the "Owned by no one" property.
            m_Ownable = (0.01 > Utility.RandomDouble());

            m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits);
        }
Exemplo n.º 9
0
        public BaseJewel( int itemID, Layer layer )
            : base(itemID)
        {
            m_MagicalAttributes = new MagicalAttributes( this );
            m_AosResistances = new ElementAttributes( this );
            m_SkillBonuses = new SkillBonuses( this );
            m_AbsorptionAttributes = new AbsorptionAttributes( this );

            m_Resource = CraftResource.Iron;
            m_GemType = GemType.None;

            Layer = layer;

            m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax( InitMinHits, InitMaxHits );
        }
Exemplo n.º 10
0
        public BaseJewel(int itemID, Layer layer)
            : base(itemID)
        {
            m_MagicalAttributes    = new MagicalAttributes(this);
            m_AosResistances       = new ElementAttributes(this);
            m_SkillBonuses         = new SkillBonuses(this);
            m_AbsorptionAttributes = new AbsorptionAttributes(this);

            m_Resource = CraftResource.Iron;
            m_GemType  = GemType.None;

            Layer = layer;

            m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits);
        }
Exemplo n.º 11
0
        /// <inheritdoc />
        protected override void ConfigureComponent()
        {
            ElementClass = "or";

            if (string.IsNullOrEmpty(Text))
            {
                return;
            }

            if (!ElementAttributes.ContainsKey(DataTextKey))
            {
                ElementAttributes.Add(DataTextKey, Text);
            }
            ElementAttributes[DataTextKey] = Text;
        }
Exemplo n.º 12
0
        public BaseClothing( int itemID, Layer layer, int hue )
            : base(itemID)
        {
            Layer = layer;
            Hue = hue;

            m_Resource = DefaultResource;

            m_MagicalAttributes = new MagicalAttributes( this );
            m_ClothingAttributes = new ArmorAttributes( this );
            m_SkillBonuses = new SkillBonuses( this );
            m_Resistances = new ElementAttributes( this );
            m_AbsorptionAttributes = new AbsorptionAttributes( this );

            m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax( InitMinHits, InitMaxHits );
        }
Exemplo n.º 13
0
 public void PurgetPersistentElements()
 {
     for (int i = 0; i < currentlySpawnablePrefabs.Count;)
     {
         GameObject        currentSpawnablePrefab = currentlySpawnablePrefabs[i];
         ElementAttributes eA = currentSpawnablePrefab.GetComponent <ElementAttributes>();
         if (eA.IsPersistent)
         {
             currentlySpawnablePrefabs.RemoveAt(i);
         }
         else
         {
             ++i;
         }
     }
 }
Exemplo n.º 14
0
        public BaseClothing(int itemID, Layer layer, int hue)
            : base(itemID)
        {
            Layer = layer;
            Hue   = hue;

            m_Resource = DefaultResource;

            m_MagicalAttributes    = new MagicalAttributes(this);
            m_ClothingAttributes   = new ArmorAttributes(this);
            m_SkillBonuses         = new SkillBonuses(this);
            m_Resistances          = new ElementAttributes(this);
            m_AbsorptionAttributes = new AbsorptionAttributes(this);

            m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits);
        }
Exemplo n.º 15
0
        public virtual void AlterFrom(BaseClothing orig)
        {
            m_Altered = true;

            m_MagicalAttributes    = orig.Attributes;
            m_ClothingAttributes   = orig.ClothingAttributes;
            m_SkillBonuses         = orig.SkillBonuses;
            m_Resistances          = orig.Resistances;
            m_AbsorptionAttributes = orig.AbsorptionAttributes;

            Crafter     = orig.Crafter;
            Exceptional = orig.Exceptional;

            MaxHitPoints = orig.MaxHitPoints;
            HitPoints    = orig.HitPoints;
        }
 private void ConfigureToggle()
 {
     if (Toggle)
     {
         ElementClass = $"{ElementClass} toggle";
         if (!ElementAttributes.ContainsKey("aria-pressed"))
         {
             ElementAttributes.Add("aria-pressed", $"{Toggle}".ToLowerInvariant());
         }
     }
     else
     {
         if (ElementAttributes.ContainsKey("aria-pressed"))
         {
             ElementAttributes["aria-pressed"] = Toggle.ToString().ToLowerInvariant();
         }
     }
 }
    private static Dictionary <string, ElementAttributes> BuildDictionary(XElement element)
    {
        XNamespace tcm = "http://www.tridion.com/ContentManager/5.0";
        var        resultDictionary = new Dictionary <string, ElementAttributes>();

        foreach (XElement childElement in element.Elements(tcm + "Item"))
        {
            var attributeDictionary = new ElementAttributes(childElement);
            foreach (XAttribute attribute in childElement.Attributes())
            {
                string[] excludedColumns = { "Title", "Modified" };
                if (excludedColumns.Contains(attribute.Name.LocalName))
                {
                    continue;
                }
                attributeDictionary.Attributes.Add(attribute.Name.LocalName, attribute.Value);
            }
            resultDictionary.Add(childElement.Attribute("Title").Value, attributeDictionary);
        }
        return(resultDictionary);
    }
Exemplo n.º 18
0
        public virtual void AlterFrom( BaseClothing orig )
        {
            m_Altered = true;

            m_MagicalAttributes = orig.Attributes;
            m_ClothingAttributes = orig.ClothingAttributes;
            m_SkillBonuses = orig.SkillBonuses;
            m_Resistances = orig.Resistances;
            m_AbsorptionAttributes = orig.AbsorptionAttributes;

            Crafter = orig.Crafter;
            Exceptional = orig.Exceptional;

            MaxHitPoints = orig.MaxHitPoints;
            HitPoints = orig.HitPoints;
        }
Exemplo n.º 19
0
        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();
            }
        }
Exemplo n.º 20
0
 private static void ApplyAttribute( ElementAttributes attrs, int min, int max, ElementAttribute attr, int low, int high )
 {
     ApplyAttribute( attrs, min, max, attr, low, high, 0 );
 }
Exemplo n.º 21
0
 private static void ApplyAttribute( ElementAttributes attrs, int min, int max, ElementAttribute attr, int low, int high, int offset )
 {
     attrs[attr] = Scale( min, max, low + offset, high + offset );
 }
Exemplo n.º 22
0
        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();
            }
        }
Exemplo n.º 23
0
 public Meta(string name, string content)
 {
     ElementAttributes.ChainSet("name", name).ChainSet("content", content);
 }
Exemplo n.º 24
0
        public static void ApplyAttributesTo(BaseJewel jewelry, bool isRunicTool, int luckChance, int attributeCount, int min, int max)
        {
            m_IsRunicTool = isRunicTool;
            m_LuckChance  = luckChance;

            MagicalAttributes primary = jewelry.Attributes;
            ElementAttributes resists = jewelry.Resistances;
            SkillBonuses      skills  = jewelry.SkillBonuses;

            m_Props.SetAll(false);

            for (int i = 0; i < attributeCount; ++i)
            {
                int random = GetUniqueRandom(24);

                if (random == -1)
                {
                    break;
                }

                switch (random)
                {
                case 0: ApplyAttribute(resists, min, max, ElementAttribute.Physical, 1, 15); break;

                case 1: ApplyAttribute(resists, min, max, ElementAttribute.Fire, 1, 15); break;

                case 2: ApplyAttribute(resists, min, max, ElementAttribute.Cold, 1, 15); break;

                case 3: ApplyAttribute(resists, min, max, ElementAttribute.Poison, 1, 15); break;

                case 4: ApplyAttribute(resists, min, max, ElementAttribute.Energy, 1, 15); break;

                case 5: ApplyAttribute(primary, min, max, MagicalAttribute.WeaponDamage, 1, 25); break;

                case 6: ApplyAttribute(primary, min, max, MagicalAttribute.DefendChance, 1, 15); break;

                case 7: ApplyAttribute(primary, min, max, MagicalAttribute.AttackChance, 1, 15); break;

                case 8: ApplyAttribute(primary, min, max, MagicalAttribute.BonusStr, 1, 8); break;

                case 9: ApplyAttribute(primary, min, max, MagicalAttribute.BonusDex, 1, 8); break;

                case 10: ApplyAttribute(primary, min, max, MagicalAttribute.BonusInt, 1, 8); break;

                case 11: ApplyAttribute(primary, min, max, MagicalAttribute.EnhancePotions, 5, 25, 5); break;

                case 12: ApplyAttribute(primary, min, max, MagicalAttribute.CastSpeed, 1, 1); break;

                case 13: ApplyAttribute(primary, min, max, MagicalAttribute.CastRecovery, 1, 3); break;

                case 14: ApplyAttribute(primary, min, max, MagicalAttribute.LowerManaCost, 1, 8); break;

                case 15: ApplyAttribute(primary, min, max, MagicalAttribute.LowerRegCost, 1, 20); break;

                case 16: ApplyAttribute(primary, min, max, MagicalAttribute.Luck, 1, 100); break;

                case 17: ApplyAttribute(primary, min, max, MagicalAttribute.SpellDamage, 1, 12); break;

                case 18: ApplyAttribute(primary, min, max, MagicalAttribute.NightSight, 1, 1); break;

                case 19: ApplySkillBonus(skills, min, max, 0, 1, 15); break;

                case 20: ApplySkillBonus(skills, min, max, 1, 1, 15); break;

                case 21: ApplySkillBonus(skills, min, max, 2, 1, 15); break;

                case 22: ApplySkillBonus(skills, min, max, 3, 1, 15); break;

                case 23: ApplySkillBonus(skills, min, max, 4, 1, 15); break;
                }
            }
        }
Exemplo n.º 25
0
 public Link(string relType, string href)
 {
     ElementAttributes.ChainSet("rel", relType).ChainAdd("href", href);
 }
Exemplo n.º 26
0
        public static void ApplyAttributesTo(BaseHat hat, bool isRunicTool, int luckChance, int attributeCount, int min, int max)
        {
            m_IsRunicTool = isRunicTool;
            m_LuckChance  = luckChance;

            MagicalAttributes primary   = hat.Attributes;
            ArmorAttributes   secondary = hat.ClothingAttributes;
            ElementAttributes resists   = hat.Resistances;

            m_Props.SetAll(false);

            for (int i = 0; i < attributeCount; ++i)
            {
                int random = GetUniqueRandom(19);

                if (random == -1)
                {
                    break;
                }

                switch (random)
                {
                case 0: ApplyAttribute(secondary, min, max, ArmorAttribute.LowerStatReq, 10, 100, 10); break;

                case 1: ApplyAttribute(secondary, min, max, ArmorAttribute.SelfRepair, 1, 5); break;

                case 2: ApplyAttribute(secondary, min, max, ArmorAttribute.DurabilityBonus, 10, 100, 10); break;

                case 3: ApplyAttribute(primary, min, max, MagicalAttribute.ReflectPhysical, 1, 15); break;

                case 4: ApplyAttribute(primary, min, max, MagicalAttribute.RegenHits, 1, 2); break;

                case 5: ApplyAttribute(primary, min, max, MagicalAttribute.RegenStam, 1, 3); break;

                case 6: ApplyAttribute(primary, min, max, MagicalAttribute.RegenMana, 1, 2); break;

                case 7: ApplyAttribute(primary, min, max, MagicalAttribute.NightSight, 1, 1); break;

                case 8: ApplyAttribute(primary, min, max, MagicalAttribute.BonusHits, 1, 5); break;

                case 9: ApplyAttribute(primary, min, max, MagicalAttribute.BonusStam, 1, 8); break;

                case 10: ApplyAttribute(primary, min, max, MagicalAttribute.BonusMana, 1, 8); break;

                case 11: ApplyAttribute(primary, min, max, MagicalAttribute.LowerManaCost, 1, 8); break;

                case 12: ApplyAttribute(primary, min, max, MagicalAttribute.LowerRegCost, 1, 20); break;

                case 13: ApplyAttribute(primary, min, max, MagicalAttribute.Luck, 1, 100); break;

                case 14: ApplyAttribute(resists, min, max, ElementAttribute.Physical, 1, 15); break;

                case 15: ApplyAttribute(resists, min, max, ElementAttribute.Fire, 1, 15); break;

                case 16: ApplyAttribute(resists, min, max, ElementAttribute.Cold, 1, 15); break;

                case 17: ApplyAttribute(resists, min, max, ElementAttribute.Poison, 1, 15); break;

                case 18: ApplyAttribute(resists, min, max, ElementAttribute.Energy, 1, 15); break;
                }
            }
        }
Exemplo n.º 27
0
        public static void ApplyAttributesTo(BaseArmor armor, bool isRunicTool, int luckChance, int attributeCount, int min, int max)
        {
            m_IsRunicTool = isRunicTool;
            m_LuckChance  = luckChance;

            MagicalAttributes primary     = armor.Attributes;
            ArmorAttributes   secondary   = armor.ArmorAttributes;
            ElementAttributes resistances = armor.Resistances;

            m_Props.SetAll(false);

            bool isShield   = (armor is BaseShield);
            int  baseCount  = (isShield ? 8 : 20);
            int  baseOffset = (isShield ? 0 : 4);

            if (!isShield && armor.Meditable)
            {
                m_Props.Set(4, true);                   // remove mage armor from possible properties
            }
            if (armor.PlayerConstructed)
            {
                m_Props.Set(2, true);                   // remove durability bonus from crafted armor
            }
            if (armor.MaterialType == ArmorMaterialType.Leather)
            {
                m_Props.Set(0, true);                   // remove lower stat requiments from leather armor
            }
            for (int i = 0; i < attributeCount; ++i)
            {
                int random = GetUniqueRandom(baseCount);

                if (random == -1)
                {
                    break;
                }

                random += baseOffset;

                switch (random)
                {
                /* Begin Shields */
                case 0: ApplyAttribute(primary, min, max, MagicalAttribute.SpellChanneling, 1, 1); break;

                case 1: ApplyAttribute(primary, min, max, MagicalAttribute.DefendChance, 1, 15); break;

                case 2: ApplyAttribute(primary, min, max, MagicalAttribute.AttackChance, 1, 15); break;

                case 3: ApplyAttribute(primary, min, max, MagicalAttribute.CastSpeed, 1, 1); break;

                /* Begin Armor */
                case 4: ApplyAttribute(secondary, min, max, ArmorAttribute.LowerStatReq, 10, 100, 10); break;

                case 5: ApplyAttribute(secondary, min, max, ArmorAttribute.SelfRepair, 1, 5); break;

                case 6: ApplyAttribute(secondary, min, max, ArmorAttribute.DurabilityBonus, 10, 100, 10); break;

                case 7: ApplyAttribute(primary, min, max, MagicalAttribute.ReflectPhysical, 1, 15); break;

                /* End Shields */
                case 8: ApplyAttribute(secondary, min, max, ArmorAttribute.MageArmor, 1, 1); break;

                case 9: ApplyAttribute(primary, min, max, MagicalAttribute.RegenHits, 1, 2); break;

                case 10: ApplyAttribute(primary, min, max, MagicalAttribute.RegenStam, 1, 3); break;

                case 11: ApplyAttribute(primary, min, max, MagicalAttribute.RegenMana, 1, 2); break;

                case 12: ApplyAttribute(primary, min, max, MagicalAttribute.NightSight, 1, 1); break;

                case 13: ApplyAttribute(primary, min, max, MagicalAttribute.BonusHits, 1, 5); break;

                case 14: ApplyAttribute(primary, min, max, MagicalAttribute.BonusStam, 1, 8); break;

                case 15: ApplyAttribute(primary, min, max, MagicalAttribute.BonusMana, 1, 8); break;

                case 16: ApplyAttribute(primary, min, max, MagicalAttribute.LowerManaCost, 1, 8); break;

                case 17: ApplyAttribute(primary, min, max, MagicalAttribute.LowerRegCost, 1, 20); break;

                case 18: ApplyAttribute(primary, min, max, MagicalAttribute.Luck, 1, 100); break;

                case 19:
                {
                    ApplyAttribute(resistances, min, max, ElementAttribute.Physical, 1, 15, armor.PhysicalBonus);
                    armor.PhysicalBonus = 0;
                    break;
                }

                case 20:
                {
                    ApplyAttribute(resistances, min, max, ElementAttribute.Fire, 1, 15, armor.FireBonus);
                    armor.FireBonus = 0;
                    break;
                }

                case 21:
                {
                    ApplyAttribute(resistances, min, max, ElementAttribute.Cold, 1, 15, armor.ColdBonus);
                    armor.ColdBonus = 0;
                    break;
                }

                case 22:
                {
                    ApplyAttribute(resistances, min, max, ElementAttribute.Poison, 1, 15, armor.PoisonBonus);
                    armor.PoisonBonus = 0;
                    break;
                }

                case 23:
                {
                    ApplyAttribute(resistances, min, max, ElementAttribute.Energy, 1, 15, armor.EnergyBonus);
                    armor.EnergyBonus = 0;
                    break;
                }
                    /* End Armor */
                }
            }
        }
Exemplo n.º 28
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 8:
            {
                m_Exceptional       = reader.ReadBool();
                m_PlayerConstructed = reader.ReadBool();
                m_Crafter           = reader.ReadMobile();

                goto case 7;
            }

            case 7:
            {
                m_AbsorptionAttributes = new AbsorptionAttributes(this, reader);

                m_TimesImbued = reader.ReadEncodedInt();

                m_MaxHitPoints = reader.ReadEncodedInt();
                m_HitPoints    = reader.ReadEncodedInt();

                m_Resource = (CraftResource)reader.ReadEncodedInt();
                m_GemType  = (GemType)reader.ReadEncodedInt();

                m_MagicalAttributes = new MagicalAttributes(this, reader);
                m_AosResistances    = new ElementAttributes(this, reader);
                m_SkillBonuses      = new SkillBonuses(this, reader);

                if (Parent is Mobile)
                {
                    m_SkillBonuses.AddTo((Mobile)Parent);
                }

                break;
            }
            }

            int strBonus = m_MagicalAttributes.BonusStr;
            int dexBonus = m_MagicalAttributes.BonusDex;
            int intBonus = m_MagicalAttributes.BonusInt;

            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();
            }
        }
Exemplo n.º 29
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 4:
                    {
                        m_MaxHitPoints = reader.ReadEncodedInt();
                        m_HitPoints = reader.ReadEncodedInt();

                        goto case 3;
                    }
                case 3:
                    {
                        m_Slayer = (SlayerName) reader.ReadInt();
                        m_Slayer2 = (SlayerName) reader.ReadInt();

                        goto case 2;
                    }
                case 2:
                    {
                        m_Ownable = (bool) reader.ReadBool();
                        m_Owner = (Mobile) reader.ReadMobile();
                        m_CraftBonusRegular = (CraftList) reader.ReadInt();
                        m_CraftBonusRegularValue = reader.ReadInt();
                        m_CraftBonusExcep = (CraftList) reader.ReadInt();
                        m_CraftBonusExcepValue = reader.ReadInt();
                        m_ProtectionEntry = (NPC_Name) reader.ReadInt();
                        m_ProtectionValue = reader.ReadInt();
                        m_KillersEntry = (NPC_Name) reader.ReadInt();
                        m_KillersValue = reader.ReadInt();
                        m_TalisSlayer = (TalisSlayerName) reader.ReadInt();
                        m_TalismanType = (TalismanType) reader.ReadInt();
                        m_Charges = reader.ReadInt();

                        goto case 1;
                    }
                case 1:
                    {
                        m_MagicalAttributes = new MagicalAttributes( this, reader );
                        m_AosResistances = new ElementAttributes( this, reader );
                        m_SkillBonuses = new SkillBonuses( this, reader );

                        if ( Parent is Mobile )
                        {
                            //-------- Charged Time Left -----------

                            m_isequiped = true;
                            InvalidateProperties();

                            //------ FIN Charged Time Left ---------
                            m_SkillBonuses.AddTo( (Mobile) Parent );
                        }

                        int strBonus = m_MagicalAttributes.BonusStr;
                        int dexBonus = m_MagicalAttributes.BonusDex;
                        int intBonus = m_MagicalAttributes.BonusInt;

                        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();

                        break;
                    }
                case 0:
                    {
                        if ( Parent is Mobile )
                        {
                            //-------- Charged Time Left -----------

                            m_isequiped = true;
                            InvalidateProperties();

                            //------ FIN Charged Time Left ---------
                            m_SkillBonuses.AddTo( (Mobile) Parent );
                        }
                        m_MagicalAttributes = new MagicalAttributes( this );
                        m_AosResistances = new ElementAttributes( this );
                        m_SkillBonuses = new SkillBonuses( this );

                        break;
                    }
            }

            if ( version < 2 )
            {
                m_Ownable = (bool) reader.ReadBool();
                m_Owner = (Mobile) reader.ReadMobile();
                m_CraftBonusRegular = (CraftList) reader.ReadInt();
                m_CraftBonusRegularValue = reader.ReadInt();
                m_CraftBonusExcep = (CraftList) reader.ReadInt();
                m_CraftBonusExcepValue = reader.ReadInt();
                m_ProtectionEntry = (NPC_Name) reader.ReadInt();
                m_ProtectionValue = reader.ReadInt();
                m_KillersEntry = (NPC_Name) reader.ReadInt();
                m_KillersValue = reader.ReadInt();
                m_TalisSlayer = (TalisSlayerName) reader.ReadInt();
                m_TalismanType = (TalismanType) reader.ReadInt();
                m_Charges = reader.ReadInt();
            }
        }
Exemplo n.º 30
0
        public T Attribute(string key, string value)
        {
            ElementAttributes.Set(key, value);

            return((T)this);
        }
Exemplo n.º 31
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 4:
            {
                m_MaxHitPoints = reader.ReadEncodedInt();
                m_HitPoints    = reader.ReadEncodedInt();

                goto case 3;
            }

            case 3:
            {
                m_Slayer  = (SlayerName)reader.ReadInt();
                m_Slayer2 = (SlayerName)reader.ReadInt();

                goto case 2;
            }

            case 2:
            {
                m_Ownable                = (bool)reader.ReadBool();
                m_Owner                  = (Mobile)reader.ReadMobile();
                m_CraftBonusRegular      = (CraftList)reader.ReadInt();
                m_CraftBonusRegularValue = reader.ReadInt();
                m_CraftBonusExcep        = (CraftList)reader.ReadInt();
                m_CraftBonusExcepValue   = reader.ReadInt();
                m_ProtectionEntry        = (NPC_Name)reader.ReadInt();
                m_ProtectionValue        = reader.ReadInt();
                m_KillersEntry           = (NPC_Name)reader.ReadInt();
                m_KillersValue           = reader.ReadInt();
                m_TalisSlayer            = (TalisSlayerName)reader.ReadInt();
                m_TalismanType           = (TalismanType)reader.ReadInt();
                m_Charges                = reader.ReadInt();

                goto case 1;
            }

            case 1:
            {
                m_MagicalAttributes = new MagicalAttributes(this, reader);
                m_AosResistances    = new ElementAttributes(this, reader);
                m_SkillBonuses      = new SkillBonuses(this, reader);

                if (Parent is Mobile)
                {
                    //-------- Charged Time Left -----------

                    m_isequiped = true;
                    InvalidateProperties();

                    //------ FIN Charged Time Left ---------
                    m_SkillBonuses.AddTo((Mobile)Parent);
                }

                int strBonus = m_MagicalAttributes.BonusStr;
                int dexBonus = m_MagicalAttributes.BonusDex;
                int intBonus = m_MagicalAttributes.BonusInt;

                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();
                }

                break;
            }

            case 0:
            {
                if (Parent is Mobile)
                {
                    //-------- Charged Time Left -----------

                    m_isequiped = true;
                    InvalidateProperties();

                    //------ FIN Charged Time Left ---------
                    m_SkillBonuses.AddTo((Mobile)Parent);
                }
                m_MagicalAttributes = new MagicalAttributes(this);
                m_AosResistances    = new ElementAttributes(this);
                m_SkillBonuses      = new SkillBonuses(this);

                break;
            }
            }

            if (version < 2)
            {
                m_Ownable                = (bool)reader.ReadBool();
                m_Owner                  = (Mobile)reader.ReadMobile();
                m_CraftBonusRegular      = (CraftList)reader.ReadInt();
                m_CraftBonusRegularValue = reader.ReadInt();
                m_CraftBonusExcep        = (CraftList)reader.ReadInt();
                m_CraftBonusExcepValue   = reader.ReadInt();
                m_ProtectionEntry        = (NPC_Name)reader.ReadInt();
                m_ProtectionValue        = reader.ReadInt();
                m_KillersEntry           = (NPC_Name)reader.ReadInt();
                m_KillersValue           = reader.ReadInt();
                m_TalisSlayer            = (TalisSlayerName)reader.ReadInt();
                m_TalismanType           = (TalismanType)reader.ReadInt();
                m_Charges                = reader.ReadInt();
            }
        }
Exemplo n.º 32
0
 private static void ApplyAttribute(ElementAttributes attrs, int min, int max, ElementAttribute attr, int low, int high)
 {
     ApplyAttribute(attrs, min, max, attr, low, high, 0);
 }
Exemplo n.º 33
0
 internal Item SetFlag(ElementAttributes attr)
 {
     _attr |= attr;
     return(this);
 }
Exemplo n.º 34
0
 private static void ApplyAttribute(ElementAttributes attrs, int min, int max, ElementAttribute attr, int low, int high, int offset)
 {
     attrs[attr] = Scale(min, max, low + offset, high + offset);
 }
Exemplo n.º 35
0
        public BaseTalisman( int ItemID )
            : base(ItemID)
        {
            Layer = Layer.Talisman;

            m_MagicalAttributes = new MagicalAttributes( this );
            m_AosResistances = new ElementAttributes( this );
            m_SkillBonuses = new SkillBonuses( this );

            // 1% chance to spawn with the "Owned by no one" property.
            m_Ownable = ( 0.01 > Utility.RandomDouble() );

            m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax( InitMinHits, InitMaxHits );
        }
Exemplo n.º 36
0
        public static void ApplyAttributesTo(BaseWeapon weapon, bool isRunicTool, int luckChance, int attributeCount, int min, int max)
        {
            m_IsRunicTool = isRunicTool;
            m_LuckChance  = luckChance;

            MagicalAttributes primary     = weapon.Attributes;
            WeaponAttributes  secondary   = weapon.WeaponAttributes;
            ElementAttributes resistances = weapon.Resistances;

            m_Props.SetAll(false);

            if (weapon is BaseRanged || weapon is BaseThrowing)
            {
                m_Props.Set(2, true);                   // ranged weapons cannot be ubws or mageweapon
            }

            if (!(weapon is BaseRanged))
            {
                m_Props.Set(28, true);                   // Solo los arcos pueden llevar la propiedad Balanced
                m_Props.Set(29, true);                   // Solo los arcos pueden llevar la propiedad Velocity
            }

            if (isRunicTool)
            {
                m_Props.Set(16, true);                   // Lower requirements don't spawn from runic tools
            }
            bool isRunicToolRanged = isRunicTool && weapon is BaseRanged;

            for (int i = 0; i < attributeCount; ++i)
            {
                int random = GetUniqueRandom(30);

                if (random == -1)
                {
                    break;
                }

                switch (random)
                {
                case 0:
                {
                    switch (Utility.Random(5))
                    {
                    case 0: ApplyAttribute(secondary, min, max, WeaponAttribute.HitPhysicalArea, 2, 50, 2); break;

                    case 1: ApplyAttribute(secondary, min, max, WeaponAttribute.HitFireArea, 2, 50, 2); break;

                    case 2: ApplyAttribute(secondary, min, max, WeaponAttribute.HitColdArea, 2, 50, 2); break;

                    case 3: ApplyAttribute(secondary, min, max, WeaponAttribute.HitPoisonArea, 2, 50, 2); break;

                    case 4: ApplyAttribute(secondary, min, max, WeaponAttribute.HitEnergyArea, 2, 50, 2); break;
                    }

                    break;
                }

                case 1:
                {
                    switch (Utility.Random(4))
                    {
                    case 0: ApplyAttribute(secondary, min, max, WeaponAttribute.HitMagicArrow, 2, 50, 2); break;

                    case 1: ApplyAttribute(secondary, min, max, WeaponAttribute.HitHarm, 2, 50, 2); break;

                    case 2: ApplyAttribute(secondary, min, max, WeaponAttribute.HitFireball, 2, 50, 2); break;

                    case 3: ApplyAttribute(secondary, min, max, WeaponAttribute.HitLightning, 2, 50, 2); break;
                    }

                    break;
                }

                case 2:
                {
                    switch (Utility.Random(2))
                    {
                    case 0: ApplyAttribute(secondary, min, max, WeaponAttribute.UseBestSkill, 1, 1); break;

                    case 1: ApplyAttribute(secondary, min, max, WeaponAttribute.MageWeapon, 1, 10); break;
                    }

                    break;
                }

                case 3:
                {
                    MagicalAttribute attr = MagicalAttribute.WeaponDamage;
                    int oldValue          = primary[attr];

                    ApplyAttribute(primary, min, max, attr, 1, 50);

                    if (oldValue >= primary[attr])
                    {
                        primary[attr] = oldValue;
                        i--;
                    }

                    break;
                }

                case 4: ApplyAttribute(primary, min, max, MagicalAttribute.DefendChance, 1, isRunicToolRanged ? 25 : 15); break;

                case 5: ApplyAttribute(primary, min, max, MagicalAttribute.CastSpeed, 1, 1); break;

                case 6: ApplyAttribute(primary, min, max, MagicalAttribute.AttackChance, 1, isRunicToolRanged ? 25 : 15); break;

                case 7: ApplyAttribute(primary, min, max, MagicalAttribute.Luck, 1, isRunicToolRanged ? 120 : 100); break;

                case 8: ApplyAttribute(primary, min, max, MagicalAttribute.WeaponSpeed, 5, 30, 5); break;

                case 9: ApplyAttribute(primary, min, max, MagicalAttribute.SpellChanneling, 1, 1); break;

                case 10: ApplyAttribute(secondary, min, max, WeaponAttribute.HitDispel, 2, 50, 2); break;

                case 11: ApplyAttribute(secondary, min, max, WeaponAttribute.HitLeechHits, 2, 50, 2); break;

                case 12: ApplyAttribute(secondary, min, max, WeaponAttribute.HitLowerAttack, 2, 50, 2); break;

                case 13: ApplyAttribute(secondary, min, max, WeaponAttribute.HitLowerDefend, 2, 50, 2); break;

                case 14: ApplyAttribute(secondary, min, max, WeaponAttribute.HitLeechMana, 2, 50, 2); break;

                case 15: ApplyAttribute(secondary, min, max, WeaponAttribute.HitLeechStam, 2, 50, 2); break;

                case 16: ApplyAttribute(secondary, min, max, WeaponAttribute.LowerStatReq, 10, 100, 10); break;

                case 17: ApplyAttribute(resistances, min, max, ElementAttribute.Physical, 1, 15); break;

                case 18: ApplyAttribute(resistances, min, max, ElementAttribute.Fire, 1, 15); break;

                case 19: ApplyAttribute(resistances, min, max, ElementAttribute.Cold, 1, 15); break;

                case 20: ApplyAttribute(resistances, min, max, ElementAttribute.Poison, 1, 15); break;

                case 21: ApplyAttribute(resistances, min, max, ElementAttribute.Energy, 1, 15); break;

                case 22: ApplyAttribute(secondary, min, max, WeaponAttribute.DurabilityBonus, 10, 100, 10); i--; break;

                case 23: SlayerName slayer = GetRandomSlayer();
                    if (weapon.Slayer == SlayerName.None)
                    {
                        weapon.Slayer = slayer;
                    }
                    else
                    {
                        weapon.Slayer2 = slayer;
                    }
                    break;

                case 24: AssignElementalDamage(weapon, ElementAttribute.Fire); i--; break;

                case 25: AssignElementalDamage(weapon, ElementAttribute.Cold); i--; break;

                case 26: AssignElementalDamage(weapon, ElementAttribute.Poison); i--; break;

                case 27: AssignElementalDamage(weapon, ElementAttribute.Energy); i--; break;

                case 28: ApplyAttribute(secondary, min, max, WeaponAttribute.Balanced, 1, 1); break;

                case 29: ApplyAttribute(secondary, min, max, WeaponAttribute.Velocity, 10, 50, 1); break;
                }
            }
        }
Exemplo n.º 37
0
 public Image(string src, string alt = null)
 {
     ElementAttributes.ChainSet("src", src).ChainSet("alt", alt);
 }
Exemplo n.º 38
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 8:
                    {
                        m_Exceptional = reader.ReadBool();
                        m_PlayerConstructed = reader.ReadBool();
                        m_Crafter = reader.ReadMobile();

                        goto case 7;
                    }
                case 7:
                    {
                        m_AbsorptionAttributes = new AbsorptionAttributes( this, reader );

                        m_TimesImbued = reader.ReadEncodedInt();

                        m_MaxHitPoints = reader.ReadEncodedInt();
                        m_HitPoints = reader.ReadEncodedInt();

                        m_Resource = (CraftResource) reader.ReadEncodedInt();
                        m_GemType = (GemType) reader.ReadEncodedInt();

                        m_MagicalAttributes = new MagicalAttributes( this, reader );
                        m_AosResistances = new ElementAttributes( this, reader );
                        m_SkillBonuses = new SkillBonuses( this, reader );

                        if ( Parent is Mobile )
                            m_SkillBonuses.AddTo( (Mobile) Parent );

                        break;
                    }
            }

            int strBonus = m_MagicalAttributes.BonusStr;
            int dexBonus = m_MagicalAttributes.BonusDex;
            int intBonus = m_MagicalAttributes.BonusInt;

            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();
        }