Esempio n. 1
0
        private static void CheckItem( Item item, Map oldMap )
        {
            if ( item.Map == null || item.Map == Map.Internal )
                return;

            if ( !m_Timers.ContainsKey( item ) )
            {
                MoonbindTimer timer = new MoonbindTimer( item );
                timer.Start();

                m_Timers.Add( item, timer );
            }

            Mobile parent = item.Parent as Mobile;

            if ( parent != null )
            {
                bool sendMessage = oldMap != null && oldMap != Map.Internal && ( oldMap == Map.Felucca || item.Map == Map.Felucca );

                if ( sendMessage )
                {
                    if ( item.IsEphemeral() )
                        parent.SendLocalizedMessage( 1153088 ); // The power of the moon Felucca no longer strengthens your Faction gear.
                    else
                        parent.SendLocalizedMessage( 1153087 ); // The power of the moon Felucca strengthens your Faction gear.
                }
            }

            item.InvalidateProperties();
        }
		private void RemoveVendorItem( Item item )
		{
			VendorItem vi = GetVendorItem( item );

			if ( vi != null )
			{
				vi.Invalidate();
				m_SellItems.Remove( item );

				foreach ( Item subItem in item.Items )
				{
					RemoveVendorItem( subItem );
				}

				item.InvalidateProperties();
			}
		}
		private VendorItem SetVendorItem( Item item, int price, string description, DateTime created )
		{
			RemoveVendorItem( item );

			VendorItem vi = new VendorItem( item, price, description, created );
			m_SellItems[item] = vi;

			item.InvalidateProperties();

			return vi;
		}
Esempio n. 4
0
        public void SetValue(int bitmask, int value)
        {
            if ((bitmask == (int)AosWeaponAttribute.DurabilityBonus) && (this is AosWeaponAttributes))
            {
                if (m_Owner is BaseWeapon)
                {
                    ((BaseWeapon)m_Owner).UnscaleDurability();
                }
            }
            else if ((bitmask == (int)AosArmorAttribute.DurabilityBonus) && (this is AosArmorAttributes))
            {
                if (m_Owner is BaseArmor)
                {
                    ((BaseArmor)m_Owner).UnscaleDurability();
                }
                else if (m_Owner is BaseClothing)
                {
                    ((BaseClothing)m_Owner).UnscaleDurability();
                }
            }

            uint mask = (uint)bitmask;

            if (value != 0)
            {
                if ((m_Names & mask) != 0)
                {
                    int index = GetIndex(mask);

                    if (index >= 0 && index < m_Values.Length)
                    {
                        m_Values[index] = value;
                    }
                }
                else
                {
                    int index = GetIndex(mask);

                    if (index >= 0 && index <= m_Values.Length)
                    {
                        int[] old = m_Values;
                        m_Values = new int[old.Length + 1];

                        for (int i = 0; i < index; ++i)
                        {
                            m_Values[i] = old[i];
                        }

                        m_Values[index] = value;

                        for (int i = index; i < old.Length; ++i)
                        {
                            m_Values[i + 1] = old[i];
                        }

                        m_Names |= mask;
                    }
                }
            }
            else if ((m_Names & mask) != 0)
            {
                int index = GetIndex(mask);

                if (index >= 0 && index < m_Values.Length)
                {
                    m_Names &= ~mask;

                    if (m_Values.Length == 1)
                    {
                        m_Values = m_Empty;
                    }
                    else
                    {
                        int[] old = m_Values;
                        m_Values = new int[old.Length - 1];

                        for (int i = 0; i < index; ++i)
                        {
                            m_Values[i] = old[i];
                        }

                        for (int i = index + 1; i < old.Length; ++i)
                        {
                            m_Values[i - 1] = old[i];
                        }
                    }
                }
            }

            if ((bitmask == (int)AosWeaponAttribute.DurabilityBonus) && (this is AosWeaponAttributes))
            {
                if (m_Owner is BaseWeapon)
                {
                    ((BaseWeapon)m_Owner).ScaleDurability();
                }
            }
            else if ((bitmask == (int)AosArmorAttribute.DurabilityBonus) && (this is AosArmorAttributes))
            {
                if (m_Owner is BaseArmor)
                {
                    ((BaseArmor)m_Owner).ScaleDurability();
                }
                else if (m_Owner is BaseClothing)
                {
                    ((BaseClothing)m_Owner).ScaleDurability();
                }
            }

            if (m_Owner.Parent is Mobile)
            {
                Mobile m = (Mobile)m_Owner.Parent;

                m.CheckStatTimers();
                m.UpdateResistances();
                m.Delta(MobileDelta.Stat | MobileDelta.WeaponDamage | MobileDelta.Hits | MobileDelta.Stam | MobileDelta.Mana);

                if (this is AosSkillBonuses)
                {
                    ((AosSkillBonuses)this).Remove();
                    ((AosSkillBonuses)this).AddTo(m);
                }
            }

            m_Owner.InvalidateProperties();
        }
Esempio n. 5
0
		public static void Remove( Mobile from, SetItem setID, Item item )
		{						
			if ( item is ISetItem )
			{
				ISetItem setItem = (ISetItem) item;
				
				if ( setItem.IsSetItem && setItem.SetID == setID )
				{				
					if ( setItem.LastEquipped )
					{
						if ( from != null )
							RemoveStatBonuses( from, item );
						
						setItem.SetSkillBonuses.Remove();					
					}
										
					int temp = item.Hue;
					item.Hue = setItem.SetHue;
					setItem.SetHue = temp;
					
					setItem.SetEquipped = false;
					setItem.LastEquipped = false;		
					item.InvalidateProperties();
				}
			}
		}
Esempio n. 6
0
        private VendorItem AddInfo( Item item, Item target )
        {
            int defPrice = 999;
            VendorItem vi;

            if ( item is BaseBook || ( item is Container && item.Items.Count == 0 ) || item is KeyRing )
            {
                defPrice = 0;
            }
            else if ( target != null )
            {
                vi = (VendorItem)m_SellItems[target];

                if ( vi != null && vi.Price > 0 )
                    defPrice = 0;
            }

            vi = new VendorItem( item, defPrice, "" );
            m_SellItems[item] = vi;

            if ( defPrice == 0 )
            {
                for (int i=0;i<item.Items.Count;i++)
                    AddInfo( (Item)item.Items[i], null );
            }

            item.InvalidateProperties();

            return vi;
        }
Esempio n. 7
0
        public void RemoveInfo( Item item )
        {
            m_SellItems.Remove( item );
            for (int i=0;i<item.Items.Count;i++)
                RemoveInfo( (Item)item.Items[i] );

            item.InvalidateProperties();
        }
Esempio n. 8
0
        /// <summary>
        /// Imbues Item with selected mod
        /// </summary>
        /// <param name="from">Player Imbuing</param>
        /// <param name="i">Item to be imbued</param>
        /// <param name="mod">mod to be imbued, see m_Table</param>
        /// <param name="value">value for mod</param>
        public static void ImbueItem(Mobile from, Item i, int mod, int value)
        {
            if (!CheckSoulForge(from, 1))
                return;

            ImbuingContext context = Imbuing.GetContext(from);

            context.LastImbued = i;
            context.Imbue_Mod = mod;
            context.Imbue_ModInt = value;

            if (!Imbuing.Table.ContainsKey(mod))
                return;

            ImbuingDefinition def = Imbuing.Table[mod];
            Type gem = def.GemRes;
            Type primary = def.PrimaryRes;
            Type special = def.SpecialRes;
            context.Imbue_ModVal = def.Weight;

            int itemRef = ImbuingGump.GetItemRef(i);
            int gemAmount = GetGemAmount(i, mod, value);
            int primResAmount = GetPrimaryAmount(i, mod, value);
            int specResAmount = GetSpecialAmount(i, mod, value);

            if (from.AccessLevel == AccessLevel.Player &&
                (from.Backpack == null || from.Backpack.GetAmount(gem) < gemAmount ||
                from.Backpack.GetAmount(primary) < primResAmount ||
                from.Backpack.GetAmount(special) < specResAmount))
                from.SendLocalizedMessage(1079773); //You do not have enough resources to imbue this item.
            else
            {
                int maxWeight = GetMaxWeight(i);
                context.Imbue_IWmax = maxWeight;

                int totalItemWeight = GetTotalWeight(i, mod);
                int totalItemMods = GetTotalMods(i, mod);

                double propWeight = ((double)def.Weight / (double)def.MaxIntensity) * value;
                propWeight = Math.Round(propWeight);
                int propweight = Convert.ToInt32(propWeight);

                if ((totalItemWeight + propweight) > maxWeight)
                {
                    from.SendLocalizedMessage(1079772); // You cannot imbue this item with any more item properties.
                    from.CloseGump(typeof(ImbuingGumpC));
                    return;
                }

                double difficulty = 0;
                double success = GetSuccessChance(from, i, (int)totalItemWeight, propweight, out difficulty);

                from.CheckSkill(SkillName.Imbuing, difficulty - 50, difficulty + 50);

                success /= 100;

                from.Backpack.ConsumeTotal(primary, primResAmount);

                if (i is BaseWeapon) ((BaseWeapon)i).TimesImbued += 1;
                if (i is BaseArmor) ((BaseArmor)i).TimesImbued += 1;
                if (i is BaseJewel) ((BaseJewel)i).TimesImbued += 1;
                if (i is BaseClothing) ((BaseClothing)i).TimesImbued += 1;

                if (success >= Utility.RandomDouble() || mod < 0 || mod > 180)
                {
                    if(from.AccessLevel == AccessLevel.Player)
                        from.Backpack.ConsumeTotal(gem, gemAmount);

                    if(specResAmount > 0)
                        from.Backpack.ConsumeTotal(special, specResAmount);

                    from.SendLocalizedMessage(1079775); // You successfully imbue the item!

                    from.PlaySound(0x5D1);
                    Effects.SendLocationParticles(
                    EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), 0x373A,
                          10, 30, 0, 4, 0, 0);

                    object prop = GetAttribute(mod);

                    if (i is BaseWeapon)
                    {
                        BaseWeapon wep = i as BaseWeapon;
                        wep.WeaponAttributes.SelfRepair = 0;

                        if (prop is AosAttribute)
                        {
                            AosAttribute attr = (AosAttribute)prop;

                            if (attr == AosAttribute.SpellChanneling)
                            {
                                wep.Attributes.SpellChanneling = value;

                                if (wep.Attributes.CastSpeed >= 0)
                                    wep.Attributes.CastSpeed -= 1;
                            }
                            else if (attr == AosAttribute.WeaponDamage)
                            {
                                wep.Attributes.WeaponDamage = value;

                                if (!wep.DImodded)
                                    wep.DImodded = true;
                            }
                            else
                                wep.Attributes[attr] = value;
                        }

                        if (prop is AosWeaponAttribute)
                        {
                            if (mod >= 30 && mod <= 34)
                            {
                                wep.WeaponAttributes.HitPhysicalArea = 0;
                                wep.WeaponAttributes.HitFireArea = 0;
                                wep.WeaponAttributes.HitColdArea = 0;
                                wep.WeaponAttributes.HitPoisonArea = 0;
                                wep.WeaponAttributes.HitEnergyArea = 0;
                            }
                            else if (mod >= 35 && mod <= 39)
                            {
                                wep.WeaponAttributes.HitMagicArrow = 0;
                                wep.WeaponAttributes.HitHarm = 0;
                                wep.WeaponAttributes.HitFireball = 0;
                                wep.WeaponAttributes.HitLightning = 0;
                                wep.WeaponAttributes.HitDispel = 0;
                            }

                            wep.WeaponAttributes[(AosWeaponAttribute)prop] = value;
                        }

                        if (prop is SlayerName)
                            wep.Slayer = (SlayerName)prop;

                        if(prop is SAAbsorptionAttribute)
                            wep.AbsorptionAttributes[(SAAbsorptionAttribute)prop] = value;

                        if (prop is AosElementAttribute)
                        {
                            AosElementAttribute attr = (AosElementAttribute)prop;

                            switch (attr)
                            {
                                case AosElementAttribute.Physical: wep.WeaponAttributes.ResistPhysicalBonus = value; break;
                                case AosElementAttribute.Fire: wep.WeaponAttributes.ResistFireBonus = value; break;
                                case AosElementAttribute.Cold: wep.WeaponAttributes.ResistColdBonus = value; break;
                                case AosElementAttribute.Poison: wep.WeaponAttributes.ResistPoisonBonus = value; break;
                                case AosElementAttribute.Energy: wep.WeaponAttributes.ResistEnergyBonus = value; break;
                            }
                        }

                        if (prop is string)
                        {
                            string p = prop as string;

                            if (p == "BalancedWeapon" && wep is BaseRanged)
                                ((BaseRanged)wep).Balanced = true;
                            else if (p == "WeaponVelocity" && wep is BaseRanged)
                                ((BaseRanged)wep).Velocity = value;
                        }
                    }
                    else if (itemRef == 3)
                    {
                        BaseArmor arm = i as BaseArmor;
                        arm.ArmorAttributes.SelfRepair = 0;

                        if (prop is AosAttribute)
                        {
                            AosAttribute attr = (AosAttribute)prop;

                            if (attr == AosAttribute.SpellChanneling)
                            {
                                arm.Attributes.SpellChanneling = value;
                                arm.Attributes.CastSpeed -= 1;
                            }
                            else if (attr == AosAttribute.WeaponDamage)
                                arm.Attributes.WeaponDamage = value;
                            else
                                arm.Attributes[attr] = value;
                        }

                        if (prop is AosElementAttribute)
                        {
                            AosElementAttribute attr = (AosElementAttribute)prop;

                            switch (attr)
                            {
                                case AosElementAttribute.Physical: arm.PhysicalBonus = value; arm.PhysImbuing = 0; break;
                                case AosElementAttribute.Fire: arm.FireBonus = value; arm.FireImbuing = 0; break;
                                case AosElementAttribute.Cold: arm.ColdBonus = value; arm.ColdImbuing = 0; break;
                                case AosElementAttribute.Poison: arm.PoisonBonus = value; arm.PoisonImbuing = 0; break;
                                case AosElementAttribute.Energy: arm.EnergyBonus = value; arm.EnergyImbuing = 0; break;
                            }
                        }

                        if (prop is SAAbsorptionAttribute)
                            arm.AbsorptionAttributes[(SAAbsorptionAttribute)prop] = value;

                        if (prop is AosArmorAttribute)
                            arm.ArmorAttributes[(AosArmorAttribute)prop] = value;
                    }
                    else if (itemRef == 4)
                    {
                        BaseShield shield = i as BaseShield;
                        shield.ArmorAttributes.SelfRepair = 0;

                        if (prop is AosAttribute)
                        {
                            AosAttribute attr = (AosAttribute)prop;

                            if (attr == AosAttribute.SpellChanneling)
                            {
                                shield.Attributes.SpellChanneling = value;

                                if (shield.Attributes.CastSpeed >= 0)
                                    shield.Attributes.CastSpeed -= 1;
                            }
                            else
                                shield.Attributes[attr] = value;
                        }

                        if (prop is SAAbsorptionAttribute)
                            shield.AbsorptionAttributes[(SAAbsorptionAttribute)prop] = value;

                        if (prop is AosArmorAttribute)
                            shield.ArmorAttributes[(AosArmorAttribute)prop] = value;
                    }
                    else if (i is BaseHat)
                    {
                        BaseHat hat = i as BaseHat;

                        if (prop is AosAttribute)
                            hat.Attributes[(AosAttribute)prop] = value;

                        if (prop is SAAbsorptionAttribute)
                            hat.SAAbsorptionAttributes[(SAAbsorptionAttribute)prop] = value;

                        if (prop is AosElementAttribute)
                        {
                            AosElementAttribute attr = (AosElementAttribute)prop;

                            switch (attr)
                            {
                                case AosElementAttribute.Physical: hat.Resistances.Physical = value; hat.PhysImbuing = 0; break;
                                case AosElementAttribute.Fire: hat.Resistances.Fire = value; hat.FireImbuing = 0; break;
                                case AosElementAttribute.Cold: hat.Resistances.Cold = value; hat.ColdImbuing = 0; break;
                                case AosElementAttribute.Poison: hat.Resistances.Poison = value; hat.PoisonImbuing = 0; break;
                                case AosElementAttribute.Energy: hat.Resistances.Energy = value; hat.EnergyImbuing = 0; break;
                            }
                        }
                    }
                    else if (i is BaseJewel)
                    {
                        BaseJewel jewel = i as BaseJewel;

                        if (jewel.MaxHitPoints <= 0 && jewel.TimesImbued == 1)
                        {
                            jewel.MaxHitPoints = 255;
                            jewel.HitPoints = 255;
                        }

                        if (prop is AosAttribute)
                            jewel.Attributes[(AosAttribute)prop] = value;

                        if (prop is SAAbsorptionAttribute)
                            jewel.AbsorptionAttributes[(SAAbsorptionAttribute)prop] = value;

                        if (prop is AosElementAttribute)
                        {
                            AosElementAttribute attr = (AosElementAttribute)prop;

                            switch (attr)
                            {
                                case AosElementAttribute.Physical: jewel.Resistances.Physical = value; break;
                                case AosElementAttribute.Fire: jewel.Resistances.Fire = value; break;
                                case AosElementAttribute.Cold: jewel.Resistances.Cold = value; break;
                                case AosElementAttribute.Poison: jewel.Resistances.Poison = value; break;
                                case AosElementAttribute.Energy: jewel.Resistances.Energy = value; break;
                            }
                        }

                        if (prop is SkillName)
                        {
                            SkillName skill = (SkillName)prop;

                            //Removes skill bonus if jewel already exist
                            for (int j = 0; j < 5; j++)
                            {
                                if (jewel.SkillBonuses.GetSkill(j) == skill)
                                {
                                    jewel.SkillBonuses.SetBonus(j, 0.0);
                                    jewel.SkillBonuses.SetSkill(j, SkillName.Alchemy);
                                }
                            }

                            if (mod >= 151 && mod <= 155)
                                jewel.SkillBonuses.SetValues(0, skill, value);
                            else if (mod >= 156 && mod <= 160)
                                jewel.SkillBonuses.SetValues(1, skill, value);
                            else if (mod >= 161 && mod <= 166)
                                jewel.SkillBonuses.SetValues(2, skill, value);
                            else if (mod >= 167 && mod <= 173)
                                jewel.SkillBonuses.SetValues(3, skill, value);
                            else if (mod >= 174 && mod <= 180)
                                jewel.SkillBonuses.SetValues(4, skill, value);
                        }
                    }

                    i.InvalidateProperties();
                }
                // == FAILURE ==
                else
                {
                    from.SendLocalizedMessage(1079774); // Fail
                    from.PlaySound(0x5AC);
                }
            }
        }
Esempio n. 9
0
		public override bool CheckTrade( Mobile to, Item item, SecureTradeContainer cont, bool message, bool checkItems, int plusItems, int plusWeight )
		{
			int msgNum = 0;

			if ( cont == null )
			{
				if ( to.Holding != null )
					msgNum = 1062727; // You cannot trade with someone who is dragging something.
				else if ( this.HasTrade )
					msgNum = 1062781; // You are already trading with someone else!
				else if ( to.HasTrade )
					msgNum = 1062779; // That person is already involved in a trade
			}

			if ( msgNum == 0 )
			{
				if ( cont != null )
				{
					plusItems += cont.TotalItems;
					plusWeight += cont.TotalWeight;
				}

				if ( this.Backpack == null || !this.Backpack.CheckHold( this, item, false, checkItems, plusItems, plusWeight ) )
					msgNum = 1004040; // You would not be able to hold this if the trade failed.
				else if ( to.Backpack == null || !to.Backpack.CheckHold( to, item, false, checkItems, plusItems, plusWeight ) )
					msgNum = 1004039; // The recipient of this trade would not be able to carry this.
				else
					msgNum = CheckContentForTrade( item );
			}

			if ( msgNum != 0 )
			{
				if ( message )
					this.SendLocalizedMessage( msgNum );

				return false;
			}
//added
			item.InvalidateProperties();
//end
			return true;
		}
Esempio n. 10
0
		public void SetValue( int bitmask, int value )
		{
			if ( ( bitmask == (int) AosWeaponAttribute.DurabilityBonus ) && ( this is AosWeaponAttributes ) )
			{
				if ( Owner is IWeapon )
					( (IWeapon) Owner ).UnscaleDurability();
			}
			else if ( ( bitmask == (int) AosArmorAttribute.DurabilityBonus ) && ( this is AosArmorAttributes ) )
			{
				if ( Owner is IArmor )
					( (IArmor) Owner ).UnscaleDurability();
			}

			uint mask = (uint) bitmask;

			if ( value != 0 )
			{
				if ( ( Names & mask ) != 0 )
				{
					int index = GetIndex( mask );

					if ( index >= 0 && index < m_Values.Length )
						m_Values[index] = (short) value;
				}
				else
				{
					int index = GetIndex( mask );

					if ( index >= 0 && index <= m_Values.Length )
					{
						short[] old = m_Values;
						m_Values = new short[old.Length + 1];

						for ( int i = 0; i < index; ++i )
							m_Values[i] = old[i];

						m_Values[index] = (short) value;

						for ( int i = index; i < old.Length; ++i )
							m_Values[i + 1] = old[i];

						Names |= mask;
					}
				}
			}
			else if ( ( Names & mask ) != 0 )
			{
				int index = GetIndex( mask );

				if ( index >= 0 && index < m_Values.Length )
				{
					Names &= ~mask;

					if ( m_Values.Length == 1 )
					{
						m_Values = m_Empty;
					}
					else
					{
						short[] old = m_Values;
						m_Values = new short[old.Length - 1];

						for ( int i = 0; i < index; ++i )
							m_Values[i] = old[i];

						for ( int i = index + 1; i < old.Length; ++i )
							m_Values[i - 1] = old[i];
					}
				}
			}

			if ( ( bitmask == (int) AosWeaponAttribute.DurabilityBonus ) && ( this is AosWeaponAttributes ) )
			{
				if ( Owner is IWeapon )
					( (IWeapon) Owner ).ScaleDurability();
			}
			else if ( ( bitmask == (int) AosArmorAttribute.DurabilityBonus ) && ( this is AosArmorAttributes ) )
			{
				if ( Owner is IArmor )
					( (IArmor) Owner ).ScaleDurability();
			}

			if ( Owner is Item )
			{
				Item owner = (Item) Owner;

				if ( owner.Parent is Mobile )
				{
					Mobile m = (Mobile) owner.Parent;

					m.CheckStatTimers();
					m.UpdateResistances();
					m.Delta( MobileDelta.Stat | MobileDelta.WeaponDamage | MobileDelta.Hits | MobileDelta.Stam | MobileDelta.Mana );

					if ( this is SkillBonuses )
					{
						SkillBonuses sb = (SkillBonuses) this;

						sb.Remove();
						sb.AddTo( m );
					}
				}

				owner.InvalidateProperties();
			}
		}
Esempio n. 11
0
		public VendorItem SetVendorItem(Item item, int price, string description)
		{
			RemoveVendorItem(item);

			VendorItem vi = new VendorItem(item, price, description);
			m_SellItems[item] = vi;
			ProcessRestockCharge(RestockCharge.Record, vi);	// record this item for future restocking charges

			item.InvalidateProperties();

			return vi;
		}