Example #1
1
		public void Target( Mobile m )
		{
			if ( CheckHSequence( m ) )
			{
				SpellHelper.Turn( Caster, m );

				/* Transmogrifies the flesh of the target creature or player to resemble rotted corpse flesh,
				 * making them more vulnerable to Fire and Poison damage,
				 * but increasing their resistance to Physical and Cold damage.
				 * 
				 * The effect lasts for ((Spirit Speak skill level - target's Resist Magic skill level) / 25 ) + 40 seconds.
				 * 
				 * NOTE: Algorithm above is fixed point, should be:
				 * ((ss-mr)/2.5) + 40
				 * 
				 * NOTE: Resistance is not checked if targeting yourself
				 */

				ExpireTimer timer = (ExpireTimer)m_Table[m];

				if ( timer != null )
					timer.DoExpire();
				else
					m.SendLocalizedMessage( 1061689 ); // Your skin turns dry and corpselike.

				 if ( m.Spell != null )
					m.Spell.OnCasterHurt();
				
				m.FixedParticles( 0x373A, 1, 15, 9913, 67, 7, EffectLayer.Head );
				m.PlaySound( 0x1BB );

				double ss = GetDamageSkill( Caster );
				double mr = ( Caster == m ? 0.0 : GetResistSkill( m ) );
				m.CheckSkill( SkillName.MagicResist, 0.0, 120.0 );	//Skill check for gain

				TimeSpan duration = TimeSpan.FromSeconds( ((ss - mr) / 2.5) + 40.0 );

				ResistanceMod[] mods = new ResistanceMod[4]
					{
						new ResistanceMod( ResistanceType.Fire, -15 ),
						new ResistanceMod( ResistanceType.Poison, -15 ),
						new ResistanceMod( ResistanceType.Cold, +10 ),
						new ResistanceMod( ResistanceType.Physical, +10 )
					};

				timer = new ExpireTimer( m, mods, duration );
				timer.Start();

				BuffInfo.AddBuff( m, new BuffInfo( BuffIcon.CorpseSkin, 1075663, duration, m ) );

				m_Table[m] = timer;

				for ( int i = 0; i < mods.Length; ++i )
					m.AddResistanceMod( mods[i] );

				HarmfulSpell( m );
			}

			FinishSequence();
		}
        public void PowerTarget(Mobile from, object obj)
        {
            if (!(obj is IronBeetleBody))
            {
                m_From.SendMessage("Cela ne servirait à rien sur cet objet");
                return;
            }

            IronBeetleBody targ = (IronBeetleBody)obj;

            if (targ.SummonScalar != 0)
            {
                from.SendMessage("Ce corps est déjà été imprégné d'une âme");
                return;
            }
            from.SendMessage("L'esprit contenu dans le Crystal se dissipe sur la carapace");
            targ.SummonScalar = m_Crystal.Completion / 100;

            if (!from.CheckSkill(SkillName.Mysticism, 60))
            {
                from.SendMessage("Le crystal se brise pendant le transfert");
                m_Crystal.Delete();
            }

            m_Crystal.Completion = 0;
            return;
        }
Example #3
0
        public override void OnDoubleClick( Mobile from )
        {
            if ( !IsChildOf( from.Backpack ) )
            {
                from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it.
            }
            else if ( from.CheckSkill( SkillName.Camping, 0.0, 100.0 ) )
            {
                Point3D loc;

                if ( Parent == null )
                    loc = Location;
                else
                    loc = from.Location;

                Consume();
                new Campfire().MoveToWorld( loc, from.Map );
            }
            else
            {
                from.SendLocalizedMessage( 501696 ); // You fail to ignite the campfire.
                if ( Utility.RandomBool() )
                {
                    from.SendMessage( "You lost some kindling." );
                    Consume();
                }
            }
        }
Example #4
0
        public override void OnDoubleClick(Mobile from)
        {
            if (!this.VerifyMove(from))
                return;

            if (!from.InRange(this.GetWorldLocation(), 2))
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
                return;
            }

            Point3D fireLocation = this.GetFireLocation(from);

            if (fireLocation == Point3D.Zero)
            {
                from.SendLocalizedMessage(501695); // There is not a spot nearby to place your campfire.
            }
            else if (!from.CheckSkill(SkillName.Camping, 0.0, 100.0))
            {
                from.SendLocalizedMessage(501696); // You fail to ignite the campfire.
            }
            else
            {
                this.Consume();

                if (!this.Deleted && this.Parent == null)
                    from.PlaceInBackpack(this);

                new Campfire().MoveToWorld(fireLocation, from.Map);
            }
        }
Example #5
0
		public void Target( Mobile m )
		{
			if ( HasMindRotScalar( m ) )
			{
				Caster.SendLocalizedMessage( 1005559 ); // This spell is already in effect.
			}
			else if ( CheckHSequence( m ) )
			{
				SpellHelper.Turn( Caster, m );

				/* Attempts to place a curse on the Target that increases the mana cost of any spells they cast,
				 * for a duration based off a comparison between the Caster's Spirit Speak skill and the Target's Resisting Spells skill.
				 * The effect lasts for ((Spirit Speak skill level - target's Resist Magic skill level) / 50 ) + 20 seconds.
				 */

				 if ( m.Spell != null )
					m.Spell.OnCasterHurt();
				
				m.PlaySound( 0x1FB );
				m.PlaySound( 0x258 );
				m.FixedParticles( 0x373A, 1, 17, 9903, 15, 4, EffectLayer.Head );

				TimeSpan duration = TimeSpan.FromSeconds( (((GetDamageSkill( Caster ) - GetResistSkill( m )) / 5.0) + 20.0) * (m.Player ? 1.0 : 2.0 ) );
				m.CheckSkill( SkillName.MagicResist, 0.0, 120.0 );	//Skill check for gain

				if ( m.Player )
					SetMindRotScalar( Caster, m, 1.25, duration );
				else
					SetMindRotScalar( Caster, m, 2.00, duration );

				HarmfulSpell( m );
			}

			FinishSequence();
		}
		public static TimeSpan OnUse( Mobile m )
		{
			if ( !m.Hidden )
			{
				m.SendLocalizedMessage( 502725 ); // You must hide first
			}
			else if ( m.Skills[SkillName.Hiding].Base < 80.0 )
			{
				m.SendLocalizedMessage( 502726 ); // You are not hidden well enough.  Become better at hiding.
			}
			else if ( m.CheckSkill( SkillName.Stealth, 0.0, 100.0 ) )
			{
				int steps = (int)(m.Skills[SkillName.Stealth].Value / (Core.AOS ? 100.0 : 5.0));

				if ( steps < 1 )
					steps = 1;

				m.AllowedStealthSteps = steps;

				m.SendLocalizedMessage( 502730 ); // You begin to move quietly.

				return TimeSpan.FromSeconds( 10.0 );
			}
			else
			{
				m.SendLocalizedMessage( 502731 ); // You fail in your attempt to move unnoticed.
				m.RevealingAction();
			}

			return TimeSpan.FromSeconds( 10.0 );
		}
Example #7
0
		public static TimeSpan OnUse( Mobile m )
		{
			if ( !m.Hidden )
			{
				m.SendLocalizedMessage( 502725 ); // You must hide first
			}
			else if ( m.Skills[SkillName.Hiding].Base < HidingRequirement )
			{
				m.SendLocalizedMessage( 502726 ); // You are not hidden well enough.  Become better at hiding.
				m.RevealingAction();
			}
			else if( !m.CanBeginAction( typeof( Stealth ) ) )
			{
				m.SendLocalizedMessage( 1063086 ); // You cannot use this skill right now.
				m.RevealingAction();
			}
			else
			{
				int armorRating = GetArmorRating( m );

				if( armorRating >= (Core.AOS ? 42 : 26) ) //I have a hunch '42' was chosen cause someone's a fan of DNA
				{
					m.SendLocalizedMessage( 502727 ); // You could not hope to move quietly wearing this much armor.
					m.RevealingAction();
				}
				else if( m.CheckSkill( SkillName.Stealth, -20.0 + (armorRating * 2), (Core.AOS ? 60.0 : 80.0) + (armorRating * 2) ) )
				{
					int steps = (int)(m.Skills[SkillName.Stealth].Value / (Core.AOS ? 5.0 : 10.0));

					if( steps < 1 )
						steps = 1;

					m.AllowedStealthSteps = steps;

// ------ NERUN's DISTRO - Orc Scout bug fix -----
					if ( m is PlayerMobile )
					{
						PlayerMobile pm = m as PlayerMobile; // IsStealthing should be moved to Server.Mobiles
						pm.IsStealthing = true;
					}
/*
					PlayerMobile pm = m as PlayerMobile; // IsStealthing should be moved to Server.Mobiles

					if( pm != null )
    						pm.IsStealthing = true;
*/
// ------ END
					m.SendLocalizedMessage( 502730 ); // You begin to move quietly.

					return TimeSpan.FromSeconds( 10.0 );
				}
				else
				{
					m.SendLocalizedMessage( 502731 ); // You fail in your attempt to move unnoticed.
					m.RevealingAction();
				}
			}

			return TimeSpan.FromSeconds( 10.0 );
		}
Example #8
0
        public override void OnDoubleClick(Mobile from)
        {
            if (SummonScalar == 0)
            {
                base.OnDoubleClick(from);
            }
            else
            {
                if (!from.CheckSkill(SkillName.Mysticism, 0, 35))
                {
                    from.SendMessage("Le mécanisme, sous vos mains non initiées en magie, s'abime");
                    Durability--;
                }
                else
                {
                    from.SendMessage("La bestiole prend vie");

                    IronBeetle beetle = new IronBeetle();
                    beetle.SummonScalar = this.SummonScalar;
                    beetle.Controlled = true;
                    beetle.ControlMaster = from;
                    beetle.Crafted = true;
                    beetle.MoveToWorld(from.Location, from.Map);
                    this.Delete();
                }
                if (Durability == 0)
                {
                    from.SendMessage("Vous détruisez la carapace");
                    Delete();
                }
            }
            base.OnDoubleClick(from);
        }
Example #9
0
			private bool CheckRepairDifficulty( Mobile mob, SkillName skill, int curHits, int maxHits )
			{
				double difficulty = GetRepairDifficulty( curHits, maxHits ) * 0.1;


				if( m_Deed != null )
				{
					double value = m_Deed.SkillLevel;
					double minSkill = difficulty - 25.0;
					double maxSkill = difficulty + 25;

					if( value < minSkill )
						return false; // Too difficult
					else if( value >= maxSkill )
						return true; // No challenge

					double chance = (value - minSkill) / (maxSkill - minSkill);

					return (chance >= Utility.RandomDouble());
				}
				else
				{
					return mob.CheckSkill( skill, difficulty - 25.0, difficulty + 25.0 );
				}
			}
Example #10
0
		public static TimeSpan OnUse( Mobile m )
		{
			m.RevealingAction();

			if ( m.CheckSkill( SkillName.SpiritSpeak, 0, 100 ) )
			{	
				if ( !m.CanHearGhosts )
				{
					Timer t = new SpiritSpeakTimer( m );
					double secs = m.Skills[SkillName.SpiritSpeak].Base / 50;
					secs *= 90;
					if ( secs < 15 )
						secs = 15;

					t.Delay = TimeSpan.FromSeconds( secs );//15seconds to 3 minutes
					t.Start();
					m.CanHearGhosts = true;
				}

				m.PlaySound( 0x24A );
				m.SendLocalizedMessage( 502444 );//You contact the neitherworld.
			}
			else
			{
				m.SendLocalizedMessage( 502443 );//You fail to contact the neitherworld.
				m.CanHearGhosts = false;
			}

			return TimeSpan.FromSeconds( 1.0 );
		}
Example #11
0
		public void Target( Mobile m )
		{
			if ( Caster == m || !(m is PlayerMobile || m is BaseCreature) ) // only PlayerMobile and BaseCreature implement blood oath checking
			{
				Caster.SendLocalizedMessage( 1060508 ); // You can't curse that.
			}
			else if ( m_OathTable.Contains( Caster ) )
			{
				Caster.SendLocalizedMessage( 1061607 ); // You are already bonded in a Blood Oath.
			}
			else if ( m_OathTable.Contains( m ) )
			{
				if ( m.Player )
					Caster.SendLocalizedMessage( 1061608 ); // That player is already bonded in a Blood Oath.
				else
					Caster.SendLocalizedMessage( 1061609 ); // That creature is already bonded in a Blood Oath.
			}
			else if ( CheckHSequence( m ) )
			{
				SpellHelper.Turn( Caster, m );

				/* Temporarily creates a dark pact between the caster and the target.
				 * Any damage dealt by the target to the caster is increased, but the target receives the same amount of damage.
				 * The effect lasts for ((Spirit Speak skill level - target's Resist Magic skill level) / 80 ) + 8 seconds.
				 * 
				 * NOTE: The above algorithm must be fixed point, it should be:
				 * ((ss-rm)/8)+8
				 */

				ExpireTimer timer = (ExpireTimer)m_Table[m];
				if ( timer != null )
				timer.DoExpire();

				m_OathTable[Caster] = Caster;
				m_OathTable[m] = Caster;

				Caster.PlaySound( 0x175 );

				Caster.FixedParticles( 0x375A, 1, 17, 9919, 33, 7, EffectLayer.Waist );
				Caster.FixedParticles( 0x3728, 1, 13, 9502, 33, 7, (EffectLayer)255 );

				m.FixedParticles( 0x375A, 1, 17, 9919, 33, 7, EffectLayer.Waist );
				m.FixedParticles( 0x3728, 1, 13, 9502, 33, 7, (EffectLayer)255 );

				TimeSpan duration = TimeSpan.FromSeconds( ((GetDamageSkill( Caster ) - GetResistSkill( m )) / 8) + 8 );
				m.CheckSkill( SkillName.MagicResist, 0.0, 120.0 );	//Skill check for gain

				timer = new ExpireTimer ( Caster, m, duration );
				timer.Start ();

				BuffInfo.AddBuff ( Caster, new BuffInfo ( BuffIcon.BloodOathCaster, 1075659, duration, Caster, m.Name.ToString () ) );
				BuffInfo.AddBuff ( m, new BuffInfo ( BuffIcon.BloodOathCurse, 1075661, duration, m, Caster.Name.ToString () ) );

				m_Table[m] = timer;

			}

			FinishSequence();
		}
Example #12
0
        public static TimeSpan OnUse( Mobile m )
        {
            m.RevealingAction();

            if ( m.Target != null )
            {
                m.SendLocalizedMessage( 501845 ); // You are busy doing something else and cannot focus.

                return TimeSpan.FromSeconds( 5.0 );
            }
            else if ( m.Hits < (m.HitsMax / 10) ) // Less than 10% health
            {
                m.SendLocalizedMessage( 501849 ); // The mind is strong but the body is weak.

                return TimeSpan.FromSeconds( 5.0 );
            }
            else if ( m.Mana >= m.ManaMax )
            {
                m.SendLocalizedMessage( 501846 ); // You are at peace.

                return TimeSpan.FromSeconds( 5.0 );
            }
            else
            {
                Item oneHanded = m.FindItemOnLayer( Layer.OneHanded );
                Item twoHanded = m.FindItemOnLayer( Layer.TwoHanded );

                if ( Core.AOS )
                {
                    if ( !CheckOkayHolding( oneHanded ) )
                        m.AddToBackpack( oneHanded );

                    if ( !CheckOkayHolding( twoHanded ) )
                        m.AddToBackpack( twoHanded );
                }
                else if ( !CheckOkayHolding( oneHanded ) || !CheckOkayHolding( twoHanded ) )
                {
                    m.SendLocalizedMessage( 502626 ); // Your hands must be free to cast spells or meditate.

                    return TimeSpan.FromSeconds( 2.5 );
                }

                if ( m.CheckSkill( SkillName.Meditation, 0, 100 ) )
                {
                    m.SendLocalizedMessage( 501851 ); // You enter a meditative trance.
                    m.Meditating = true;

                    if ( m.Player || m.Body.IsHuman )
                        m.PlaySound( 0xF9 );
                }
                else
                {
                    m.SendLocalizedMessage( 501850 ); // You cannot focus your concentration.
                }

                return TimeSpan.FromSeconds( 10.0 );
            }
        }
Example #13
0
		public void Use( Mobile from, BaseWeapon weapon )
		{
			BeginSwing();

			from.Direction = from.GetDirectionTo( GetWorldLocation() );
			weapon.PlaySwingAnimation( from );

			from.CheckSkill( weapon.Skill, m_MinSkill, m_MaxSkill );
		}
Example #14
0
        public static void OnPickedInstrument(Mobile from, BaseInstrument instrument)
        {
            from.RevealingAction();
            if (!BaseInstrument.CheckMusicianship(from))
            {
                from.SendLocalizedMessage(500612); // You play poorly, and there is no effect.
                instrument.PlayInstrumentBadly(from);
                instrument.ConsumeUse(from);
            }
            else if (!from.CheckSkill(SkillName.Peacemaking, 0.0, 100.0))
            {
                from.SendLocalizedMessage(500613); // You attempt to calm everyone, but fail.
                instrument.PlayInstrumentBadly(from);
                instrument.ConsumeUse(from);
            }
            else
            {
                instrument.PlayInstrumentWell(from);
                instrument.ConsumeUse(from);

                Map map = from.Map;

                if (map != null)
                {
                    int range = BaseInstrument.GetBardRange(from, SkillName.Peacemaking);

                    bool calmed = false;

                    foreach (Mobile m in from.GetMobilesInRange(range))
                    {
                        #region Dueling
                        if (m.Region is Engines.ConPVP.SafeZone)
                            continue;
                        #endregion

                        BaseCreature bc = m as BaseCreature;
                        if ((bc != null && bc.Uncalmable) || m == from || !m.Alive)
                            continue;

                        calmed = true;

                        m.SendLocalizedMessage(500616); // You hear lovely music, and forget to continue battling!
                        m.Combatant = null;
                        if (!m.Player)
                            m.Warmode = false;

                        if (bc != null && !bc.BardPacified)
                            bc.Pacify(from, DateTime.Now + TimeSpan.FromSeconds(2.5));
                    }

                    if (!calmed)
                        from.SendLocalizedMessage(1049648); // You play hypnotic music, but there is nothing in range for you to calm.
                    else
                        from.SendLocalizedMessage(500615); // You play your hypnotic music, stopping the battle.
                }
            }
        }
Example #15
0
        public static TimeSpan OnUse( Mobile m )
        {
            m.RevealingAction();

            if ( m.Target != null )
            {
                m.SendLocalizedMessage( 501845 ); // You are busy doing something else and cannot focus.

                return TimeSpan.FromSeconds( 5.0 );
            }
            else if ( m.Mana >= m.ManaMax )
            {
                m.SendLocalizedMessage( 501846 ); // You are at peace.

                return TimeSpan.FromSeconds( 10.0 );
            }
            else if ( !RegenRates.AllowMeditation( m ) )
            {
                m.SendLocalizedMessage( 500135 ); // Regenative forces cannot penetrate your armor!

                return TimeSpan.FromSeconds( 10.0 );
            }
            else
            {
                Item oneHanded = m.FindItemOnLayer( Layer.OneHanded );
                Item twoHanded = m.FindItemOnLayer( Layer.TwoHanded );

                if ( !CheckOkayHolding( oneHanded ) )
                    m.AddToBackpack( oneHanded );

                if ( !CheckOkayHolding( twoHanded ) )
                    m.AddToBackpack( twoHanded );

                double skillVal = m.Skills[SkillName.Meditation].Value;
                double chance = ( 75.0 + ( ( skillVal - ( m.ManaMax - m.Mana ) ) * 2 ) ) / 100;

                if ( chance > Utility.RandomDouble() )
                {
                    m.CheckSkill( SkillName.Meditation, 0.0, 100.0 );

                    m.SendLocalizedMessage( 501851 ); // You enter a meditative trance.
                    m.Meditating = true;

                    BuffInfo.AddBuff( m, new BuffInfo( BuffIcon.ActiveMeditation, 1075657 ) );

                    if ( m.IsPlayer || m.Body.IsHuman )
                        m.PlaySound( 0xF9 );
                }
                else
                {
                    m.SendLocalizedMessage( 501850 ); // You cannot focus your concentration.
                }

                return TimeSpan.FromSeconds( 10.0 );
            }
        }
Example #16
0
		public static TimeSpan OnUse( Mobile m )
		{
			m.RevealingAction();

			if ( m.Target != null )
			{
				m.SendLocalizedMessage( 501845 ); // You are busy doing something else and cannot focus.

				return TimeSpan.FromSeconds( 5.0 );
			} 
			else if ( m.Hits < (m.HitsMax / 10) ) // Less than 10% health
			{
				m.SendLocalizedMessage( 501849 ); // The mind is strong but the body is weak.

				return TimeSpan.FromSeconds( 5.0 );
			}
			else if ( m.Mana >= m.ManaMax )
			{
				m.SendLocalizedMessage( 501846 ); // You are at peace.

				return TimeSpan.FromSeconds( 5.0 );
			}
			else 
			{
				Item oneHanded = m.FindItemOnLayer( Layer.OneHanded );
				Item twoHanded = m.FindItemOnLayer( Layer.TwoHanded );

				if ( !CheckOkayHolding( oneHanded ) || !CheckOkayHolding( twoHanded ) )
				{
					m.SendLocalizedMessage( 502626 ); // Your hands must be free to cast spells or meditate.

					return TimeSpan.FromSeconds( 2.5 );
				}

				double skillVal = m.Skills[SkillName.Meditation].Value;
				double chance = (50.0 + (( skillVal - ( m.ManaMax - m.Mana ) ) * 2)) / 100;

				if ( chance > Utility.RandomDouble() )
				{
					m.CheckSkill( SkillName.Meditation, 0.0, 100.0 );

					m.SendLocalizedMessage( 501851 ); // You enter a meditative trance.
					m.Meditating = true;
					BuffInfo.AddBuff( m, new BuffInfo( BuffIcon.ActiveMeditation, 1075657 ) );

					if ( m.Player || m.Body.IsHuman )
						m.PlaySound( 0xF9 );
				} 
				else 
				{
					m.SendLocalizedMessage( 501850 ); // You cannot focus your concentration.
				}

				return TimeSpan.FromSeconds( 10.0 );
			}
		}
Example #17
0
        public override double GetResistSkill(Mobile m)
        {
            int maxSkill = (1 + (int)this.Circle) * 10;
            maxSkill += (1 + ((int)this.Circle / 6)) * 25;

            if (m.Skills[SkillName.MagicResist].Value < maxSkill)
                m.CheckSkill(SkillName.MagicResist, 0.0, m.Skills[SkillName.MagicResist].Cap);

            return m.Skills[SkillName.MagicResist].Value;
        }
Example #18
0
			protected override void OnTarget( Mobile src, object targ )
			{
				bool foundAnyone = false;

				Point3D p;
				if ( targ is Mobile )
					p = ((Mobile)targ).Location;
				else if ( targ is Item )
					p = ((Item)targ).Location;
				else if ( targ is IPoint3D )
					p = new Point3D( (IPoint3D)targ );
				else 
					p = src.Location;

				double srcSkill = src.Skills[SkillName.DetectHidden].Value;
				int range = (int)(srcSkill / 10.0);

				if ( !src.CheckSkill( SkillName.DetectHidden, 0.0, 100.0 ) )
					range /= 2;

				BaseHouse house = BaseHouse.FindHouseAt( p, src.Map, 16 );

				bool inHouse = ( house != null && house.IsFriend( src ) );

				if ( inHouse )
					range = 22;

				if ( range > 0 )
				{
					IPooledEnumerable inRange = src.Map.GetMobilesInRange( p, range );

					foreach ( Mobile trg in inRange )
					{
						if ( trg.Hidden && src != trg )
						{
							double ss = srcSkill + Utility.Random( 21 ) - 10;
							double ts = trg.Skills[SkillName.Hiding].Value + Utility.Random( 21 ) - 10;

							if ( src.AccessLevel >= trg.AccessLevel && ( ss >= ts || ( inHouse && house.IsInside( trg ) ) ) )
							{
								trg.RevealingAction();
								trg.SendLocalizedMessage( 500814 ); // You have been revealed!
								foundAnyone = true;
							}
						}
					}

					inRange.Free();
				}

				if ( !foundAnyone )
				{
					src.SendLocalizedMessage( 500817 ); // You can see nothing hidden there.
				}
			}
Example #19
0
		public void Target( Mobile m )
		{
			if ( CheckHSequence( m ) )
			{
				SpellHelper.Turn( Caster, m );

				//SpellHelper.CheckReflect( (int)this.Circle, Caster, ref m ); //Irrelevent asfter AoS

				/* Temporarily causes intense physical pain to the target, dealing direct damage.
				 * After 10 seconds the spell wears off, and if the target is still alive, 
				 * some of the Hit Points lost through Pain Spike are restored.
				 */

				m.FixedParticles( 0x37C4, 1, 8, 9916, 39, 3, EffectLayer.Head );
				m.FixedParticles( 0x37C4, 1, 8, 9502, 39, 4, EffectLayer.Head );
				m.PlaySound( 0x210 );

				double damage = ((GetDamageSkill( Caster ) - GetResistSkill( m )) / 10) + (m.Player ? 18 : 30);
				m.CheckSkill( SkillName.MagicResist, 0.0, 120.0 );	//Skill check for gain

				if ( damage < 1 )
					damage = 1;

				TimeSpan buffTime = TimeSpan.FromSeconds( 10.0 );

				if( m_Table.Contains( m ) )
				{
					damage = Utility.RandomMinMax( 3, 7 );
					Timer t = m_Table[m] as Timer;

					if( t != null )
					{
						t.Delay += TimeSpan.FromSeconds( 2.0 );

						buffTime = t.Next - DateTime.UtcNow;
					}
				}
				else
				{
					new InternalTimer( m, damage ).Start();
				}

				BuffInfo.AddBuff( m, new BuffInfo( BuffIcon.PainSpike, 1075667, buffTime, m, Convert.ToString( (int)damage ) ) );

				Misc.WeightOverloading.DFA = Misc.DFAlgorithm.PainSpike;
				m.Damage( (int) damage, Caster );
				SpellHelper.DoLeech( (int)damage, Caster, m );
				Misc.WeightOverloading.DFA = Misc.DFAlgorithm.Standard;

				//SpellHelper.Damage( this, m, damage, 100, 0, 0, 0, 0, Misc.DFAlgorithm.PainSpike );
				HarmfulSpell( m );
			}

			FinishSequence();
		}
Example #20
0
		public override double GetResistSkill(Mobile m)
		{
			int maxSkill = ((1 + (int)Circle) * 10) + ((1 + ((int)Circle / 6)) * 25);

			if (m.Skills[SkillName.MagicResist].Value < maxSkill)
			{
				m.CheckSkill(SkillName.MagicResist, 0.0, m.Skills[SkillName.MagicResist].Cap);
			}

			return m.Skills[SkillName.MagicResist].Value;
		}
Example #21
0
        public static TimeSpan OnUse( Mobile m )
        {
            bool ok;
            if ( CheckCombat( m, (int)(13 - m.Skills[SkillName.Hiding].Value / 10 )) )
                ok = m.CheckSkill( SkillName.Hiding, 90, 140 );
            else
                ok =  m.CheckSkill( SkillName.Hiding, 0, 100 );

            if ( !ok )
            {
                m.RevealingAction();
                m.LocalOverheadMessage( MessageType.Regular, 0x22, true, "You can't seem to hide here." );
            }
            else
            {
                m.Hidden = true;
                m.LocalOverheadMessage( MessageType.Regular, 0x1F4, true, "You have hidden yourself well." );
            }
            return TimeSpan.FromSeconds( 10.0 );
        }
Example #22
0
        public override void OnCarve(Mobile from, Items.Corpse corpse, Item with)
        {
            if (corpse.Carved)
                base.OnCarve(from, corpse, with);

            if (from.CheckSkill(SkillName.Forensics, 10, 40))
            {
                corpse.DropItem(new BullFrogLard());
            }
            base.OnCarve(from, corpse, with);
        }
Example #23
0
		public override double GetResistSkill( Mobile m )
		{
            //int maxSkill = (1 + (int)Circle) * 10;
            //maxSkill += (1 + ((int)Circle / 6)) * 25;

            //if ( m.Skills[SkillName.MagicResist].Value < maxSkill )
            //    m.CheckSkill( SkillName.MagicResist, 0.0, 120.0 );

            m.CheckSkill(SkillName.MagicResist, 0.0, 30.0); //All offensive spells have same resist change as Fire Field

			return m.Skills[SkillName.MagicResist].Value;
		}
Example #24
0
		public static TimeSpan OnUse( Mobile m )
		{
			if ( !m.Hidden )
			{
				m.SendLocalizedMessage( 502725 ); // You must hide first
			}
			else if ( m.Skills[SkillName.Hiding].Base < HidingRequirement )
			{
				m.SendLocalizedMessage( 502726 ); // You are not hidden well enough.  Become better at hiding.
				m.RevealingAction();
			}
			else if( !m.CanBeginAction( typeof( Stealth ) ) )
			{
				m.SendLocalizedMessage( 1063086 ); // You cannot use this skill right now.
				m.RevealingAction();
			}
			else
			{
				int armorRating = GetArmorRating( m );

				if( armorRating >= 26 )
				{
					m.SendLocalizedMessage( 502727 ); // You could not hope to move quietly wearing this much armor.
					m.RevealingAction();
				}
				else if( m.CheckSkill( SkillName.Stealth, -20.0 + (armorRating * 2), 80.0 + (armorRating * 2) ) )
				{
					int steps = (int)(m.Skills[SkillName.Stealth].Value / 10.0);

					if( steps < 1 )
						steps = 1;

					m.AllowedStealthSteps = steps;

					PlayerMobile pm = m as PlayerMobile; // IsStealthing should be moved to Server.Mobiles

					if( pm != null )
						pm.IsStealthing = true;

					m.SendLocalizedMessage( 502730 ); // You begin to move quietly.

					return TimeSpan.FromSeconds( 10.0 );
				}
				else
				{
					m.SendLocalizedMessage( 502731 ); // You fail in your attempt to move unnoticed.
					m.RevealingAction();
				}
			}

			return TimeSpan.FromSeconds( 10.0 );
		}
		public static void OnPickedInstrument( Mobile from, BaseInstrument instrument )
		{
			from.RevealingAction();

      if ( !BaseInstrument.CheckMusicianship( from ) )
      { 
        from.SendLocalizedMessage( 500612 ); // You play poorly, and there is no effect.
        instrument.PlayInstrumentBadly( from );
        instrument.ConsumeUse( from );
      }
      else if ( !from.CheckSkill( SkillName.Peacemaking, 0.0, 100.0 ) )
      {
        from.SendLocalizedMessage( 500613 ); // You attempt to calm everyone, but fail.
        instrument.PlayInstrumentBadly( from );
        instrument.ConsumeUse( from );
      }
      else
      {
        instrument.PlayInstrumentWell( from );
        instrument.ConsumeUse( from );

        Map map = from.Map;

        if ( map != null )
        {
          int range = BaseInstrument.GetBardRange( from, SkillName.Peacemaking );

          bool calmed = false;

          foreach ( Mobile m in from.GetMobilesInRange( range ) )
          {
            if ( (m is BaseCreature && ((BaseCreature)m).Uncalmable) || m == from || !from.CanBeHarmful( m, false ) )
              continue;

            calmed = true;

            m.SendLocalizedMessage( 500616 ); // You hear lovely music, and forget to continue battling!
            m.Combatant = null;
            m.Warmode = false;

            if ( m is BaseCreature && !((BaseCreature)m).BardPacified )
              ((BaseCreature)m).Pacify( from, DateTime.Now + TimeSpan.FromSeconds( 1.0 ) );
          }

          if ( !calmed )
            from.SendLocalizedMessage( 1049648 ); // You play hypnotic music, but there is nothing in range...
          else
            from.SendLocalizedMessage( 500615 ); // You play your hypnotic music, stopping the battle.
            
        }
      }
		}
Example #26
0
        private static void CheckBonusSkill(Mobile m, int cur, int max, SkillName skill)
        {
            if (!m.Alive)
                return;

            double n = (double)cur / max;
            double v = Math.Sqrt(m.Skills[skill].Value * 0.005);

            n *= (1.0 - v);
            n += v;

            m.CheckSkill(skill, n);
        }
Example #27
0
        public virtual void Resource_OnTarget(Mobile from, object targ)
        {
            SkillName brewSkill = SkillName.Alchemy;
            SkillName herbSkill = SkillName.Cooking;

            if (this.grindable)
            {
                if (targ is MortarPestle)
                {
                    Container pack = from.Backpack;
                    if (!(pack == null || pack.Deleted))
                        Grind(this, from,
                            from.CheckSkill(herbSkill, 0.0, 100.0)
                                ? Utility.RandomBool()
                                    ? HarvestSuccessRating.PartialSuccess
                                    : HarvestSuccessRating.Success
                                : HarvestSuccessRating.Failure, grindResult, pack);
                }
                else
                    from.SendMessage("Try using this on a mortar and pestle.");
            }
            else if (this.cookable)
            {
                if (IsHeatSource(targ))
                {
                    Container pack = from.Backpack;
                    if (!(pack == null || pack.Deleted))
                        Cook(this, from,
                            from.CheckSkill(brewSkill, 0.0, 100.0)
                                ? Utility.RandomBool()
                                    ? HarvestSuccessRating.PartialSuccess
                                    : HarvestSuccessRating.Success
                                : HarvestSuccessRating.Failure, grindResult, pack);
                }
                else
                    from.SendMessage("Try using this on a heat source.");
            }
        }
Example #28
0
		public override void OnDoubleClick( Mobile from )
		{
            if (from.BeginAction(typeof(IAction)))
            {
                bool releaseLock = true;

                if (from.InRange(GetWorldLocation(), 2) && from.InLOS(this))
                {
			        if ( !VerifyMove( from ) )
				        return;

			        Point3D fireLocation = GetFireLocation( from );

			        if ( fireLocation == Point3D.Zero )
			        {
				        from.SendLocalizedMessage( 501695 ); // There is not a spot nearby to place your campfire.
                        return;
			        }

                    else
                    {
                        new InternalTimer(from).Start();
                        releaseLock = false;

                        if (!from.CheckSkill(SkillName.Camping, 0.0, 100.0))
                        {
                            from.SendLocalizedMessage(501696); // You fail to ignite the campfire.
                        }
                        else
                        {
                            Consume();

                            if (!Deleted && Parent == null)
                                from.PlaceInBackpack(this);

                            new Campfire().MoveToWorld(fireLocation, from.Map);
                        }
                    }
                }
                else
				    from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.

                if (releaseLock && from is PlayerMobile)
                {
                    ((PlayerMobile)from).EndPlayerAction();
                }
            }
            else
                from.SendAsciiMessage("You must wait to perform another action.");
		}
Example #29
0
        public static TimeSpan OnUse( Mobile m )
        {
            if ( !m.Hidden )
            {
                m.SendLocalizedMessage( 502725 ); // You must hide first
            }
            else if ( m.Skills[SkillName.Hiding].Base < ((Core.SE) ? 50.0 : 80.0) )
            {
                m.SendLocalizedMessage( 502726 ); // You are not hidden well enough.  Become better at hiding.
                m.RevealingAction();
            }
            else if( m is PlayerMobile )
            {
                PlayerMobile pm = m as PlayerMobile;

                if( pm.HeavyPenalty > 0 || ((pm.Feats.GetFeatLevel(FeatList.ArmouredStealth) * 3) < pm.TotalPenalty) ||
                   (pm.Feats.GetFeatLevel(FeatList.ArmouredStealth) < 1 && (pm.MediumPieces > 0 || pm.LightPieces > 0)) )
                {
                    m.SendLocalizedMessage( 502727 ); // You could not hope to move quietly wearing this much armor.
                    m.RevealingAction();
                }
                else if ( m.CheckSkill( SkillName.Stealth, -20.0 + (pm.TotalPenalty * 3), (Core.AOS ? 60.0 : 80.0) + (pm.TotalPenalty * 3) ) )
                {
                    int steps = (int)(m.Skills[SkillName.Stealth].Value / (Core.AOS ? 5.0 : 10.0));

                    if ( steps < 1 )
                        steps = 1;

                    m.AllowedStealthSteps = steps;

                    foreach( Mobile mob in m.GetMobilesInRange( 3 ) )
                        if( mob.Hidden && (mob is Wolf || mob is Dog) && ((BaseCreature)mob).ControlMaster == m )
                            mob.AllowedStealthSteps = steps;

                    //m.SendLocalizedMessage( 502730 ); // You begin to move quietly.

                    return TimeSpan.FromSeconds( 10.0 );
                }
                else
                {
                    m.SendLocalizedMessage( 502731 ); // You fail in your attempt to move unnoticed.
                    m.RevealingAction();
                }
            }

            return TimeSpan.FromSeconds( 10.0 );
        }
Example #30
0
        public static TimeSpan OnUse( Mobile m )
        {
            EventSink.InvokeSkillUsed(new SkillUsedEventArgs(m, m.Skills[SkillName.SpiritSpeak]));

            if( Core.AOS )
            {
                Spell spell = new SpiritSpeakSpell(m);

                spell.Cast();

                if( spell.IsCasting )
                    return TimeSpan.FromSeconds(5.0);

                return TimeSpan.Zero;
            }

            m.RevealingAction();

            if( m.CheckSkill(SkillName.SpiritSpeak, 0, 100) )
            {
                if( !m.CanHearGhosts )
                {
                    Timer t = new SpiritSpeakTimer(m);
                    double secs = m.Skills[SkillName.SpiritSpeak].Base / 50;
                    secs *= 90;
                    if( secs < 15 )
                        secs = 15;

                    t.Delay = TimeSpan.FromSeconds(secs);//15seconds to 3 minutes
                    t.Start();
                    m.CanHearGhosts = true;
                }

                m.PlaySound(0x24A);
                m.SendLocalizedMessage(502444);//You contact the neitherworld.
            }
            else
            {
                m.SendLocalizedMessage(502443);//You fail to contact the neitherworld.
                m.CanHearGhosts = false;
            }

            return TimeSpan.FromSeconds(1.0);
        }
Example #31
0
		public double GetSuccessChance(
			Mobile from, Type typeRes, CraftSystem craftSystem, bool gainSkills, ref bool allRequiredSkills)
		{
			double minMainSkill = 0.0;
			double maxMainSkill = 0.0;
			double valMainSkill = 0.0;

			allRequiredSkills = true;

			for (int i = 0; i < m_arCraftSkill.Count; i++)
			{
				CraftSkill craftSkill = m_arCraftSkill.GetAt(i);

				double minSkill = craftSkill.MinSkill - MinSkillOffset;
				double maxSkill = craftSkill.MaxSkill;
				double valSkill = from.Skills[craftSkill.SkillToMake].Value;

				if (valSkill < minSkill)
				{
					allRequiredSkills = false;
				}

				if (craftSkill.SkillToMake == craftSystem.MainSkill)
				{
					minMainSkill = minSkill;
					maxMainSkill = maxSkill;
					valMainSkill = valSkill;
				}

				if (gainSkills) // This is a passive check. Success chance is entirely dependant on the main skill
				{
					from.CheckSkill(craftSkill.SkillToMake, minSkill, maxSkill);
				}
			}

			double chance;

			if (allRequiredSkills)
			{
				chance = craftSystem.GetChanceAtMin(this) +
						 ((valMainSkill - minMainSkill) / (maxMainSkill - minMainSkill) * (1.0 - craftSystem.GetChanceAtMin(this)));
			}
			else
			{
				chance = 0.0;
			}

			if (allRequiredSkills && from.Talisman is BaseTalisman)
			{
				BaseTalisman talisman = (BaseTalisman)from.Talisman;

				if (talisman.Skill == craftSystem.MainSkill)
				{
					chance += talisman.SuccessBonus / 100.0;
				}
			}

			if (allRequiredSkills && valMainSkill == maxMainSkill)
			{
				chance = 1.0;
			}

			return chance;
		}
Example #32
0
                protected override void OnTick()
                {
                    if (m_Item.Deleted)
                    {
                        return;
                    }

                    if (!m_Item.Visible)
                    {
                        if (m_InLOS && m_CanFit)
                        {
                            m_Item.Visible = true;
                        }
                        else
                        {
                            m_Item.Delete();
                        }

                        if (!m_Item.Deleted)
                        {
                            m_Item.ProcessDelta();
                            Effects.SendLocationParticles(EffectItem.Create(m_Item.Location, m_Item.Map, EffectItem.DefaultDuration), 0x376A, 9, 10, 5029);
                        }
                    }
                    else if (DateTime.UtcNow > m_Item.m_End)
                    {
                        m_Item.Delete();
                        Stop();
                    }
                    else
                    {
                        Map    map    = m_Item.Map;
                        Mobile caster = m_Item.m_Caster;

                        if (map != null && caster != null)
                        {
                            foreach (Mobile m in m_Item.GetMobilesInRange(0))
                            {
                                if ((m.Z + 16) > m_Item.Z && (m_Item.Z + 12) > m.Z && (!Core.AOS || m != caster) && SpellHelper.ValidIndirectTarget(caster, m) && caster.CanBeHarmful(m, false))
                                {
                                    m_Queue.Enqueue(m);
                                }
                            }

                            while (m_Queue.Count > 0)
                            {
                                int damage = m_Item.m_Damage;
                                if (damage > 0)
                                {
                                    Mobile m = (Mobile)m_Queue.Dequeue();

                                    if (SpellHelper.CanRevealCaster(m))
                                    {
                                        caster.RevealingAction();
                                    }

                                    caster.DoHarmful(m);


                                    if (!Core.AOS && m.CheckSkill(SkillName.MagicResist, 0.0, 30.0))
                                    {
                                        damage = 1;

                                        m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy.
                                    }

                                    AOS.Damage(m, caster, damage, 0, 100, 0, 0, 0);
                                    m.PlaySound(0x208);

                                    if (m is BaseCreature)
                                    {
                                        ((BaseCreature)m).OnHarmfulSpell(caster);
                                    }
                                }
                            }
                        }
                    }
                }
Example #33
0
 public override void CheckGain(Mobile m)
 {
     m.CheckSkill(MoveSkill, RequiredSkill - 12.5, RequiredSkill + 37.5);    //Per five on friday 02/16/07
 }
Example #34
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (!(targeted is Mobile))
                {
                    from.SendLocalizedMessage(1049528);                     // You cannot calm that!
                }
                else if (!m_Instrument.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1062488);                     // The instrument you are trying to play is no longer in your backpack!
                }
                else
                {
                    m_SetSkillTime = false;

                    int masteryBonus = 0;

                    if (from is PlayerMobile)
                    {
                        masteryBonus = Spells.SkillMasteries.BardSpell.GetMasteryBonus((PlayerMobile)from, SkillName.Peacemaking);
                    }

                    if (targeted == from)
                    {
                        // Standard mode : reset combatants for everyone in the area
                        if (!BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendLocalizedMessage(500612);                             // You play poorly, and there is no effect.
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                        }
                        else if (!from.CheckSkill(SkillName.Peacemaking, 0.0, 120.0))
                        {
                            from.SendLocalizedMessage(500613);                             // You attempt to calm everyone, but fail.
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                        }
                        else
                        {
                            from.NextSkillTime = Core.TickCount + 5000;
                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);

                            Map map = from.Map;

                            if (map != null)
                            {
                                int range = BaseInstrument.GetBardRange(from, SkillName.Peacemaking);

                                bool calmed             = false;
                                IPooledEnumerable eable = from.GetMobilesInRange(range);

                                foreach (Mobile m in eable)
                                {
                                    if ((m is BaseCreature && ((BaseCreature)m).Uncalmable) ||
                                        (m is BaseCreature && ((BaseCreature)m).AreaPeaceImmune) || m == from || !from.CanBeHarmful(m, false))
                                    {
                                        continue;
                                    }

                                    calmed = true;

                                    m.SendLocalizedMessage(500616);                                     // You hear lovely music, and forget to continue battling!
                                    m.Combatant = null;
                                    m.Warmode   = false;

                                    if (m is BaseCreature && !((BaseCreature)m).BardPacified)
                                    {
                                        ((BaseCreature)m).Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(1.0));
                                    }
                                }
                                eable.Free();

                                if (!calmed)
                                {
                                    from.SendLocalizedMessage(1049648);                                     // You play hypnotic music, but there is nothing in range for you to calm.
                                }
                                else
                                {
                                    from.SendLocalizedMessage(500615);                                     // You play your hypnotic music, stopping the battle.
                                }
                            }
                        }
                    }
                    else
                    {
                        // Target mode : pacify a single target for a longer duration
                        Mobile targ = (Mobile)targeted;

                        if (!from.CanBeHarmful(targ, false))
                        {
                            from.SendLocalizedMessage(1049528);
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).Uncalmable)
                        {
                            from.SendLocalizedMessage(1049526);                             // You have no chance of calming that creature.
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).BardPacified)
                        {
                            from.SendLocalizedMessage(1049527);                             // That creature is already being calmed.
                            m_SetSkillTime = true;
                        }
                        else if (!BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendLocalizedMessage(500612);                             // You play poorly, and there is no effect.
                            from.NextSkillTime = Core.TickCount + 5000;
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                        else
                        {
                            double diff  = m_Instrument.GetDifficultyFor(targ) - 10.0;
                            double music = from.Skills[SkillName.Musicianship].Value;

                            diff += XmlMobFactions.GetScaledFaction(from, targ, -25, 25, -0.001);

                            if (music > 100.0)
                            {
                                diff -= (music - 100.0) * 0.5;
                            }

                            if (masteryBonus > 0)
                            {
                                diff -= (diff * ((double)masteryBonus / 100));
                            }

                            if (!from.CheckTargetSkill(SkillName.Peacemaking, targ, diff - 25.0, diff + 25.0))
                            {
                                from.SendLocalizedMessage(1049531);                                 // You attempt to calm your target, but fail.
                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);

                                from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                            }
                            else
                            {
                                m_Instrument.PlayInstrumentWell(from);
                                m_Instrument.ConsumeUse(from);

                                from.NextSkillTime = Core.TickCount + (5000 - ((masteryBonus / 5) * 1000));

                                if (targ is BaseCreature)
                                {
                                    BaseCreature bc = (BaseCreature)targ;

                                    from.SendLocalizedMessage(1049532);                                     // You play hypnotic music, calming your target.

                                    targ.Combatant = null;
                                    targ.Warmode   = false;

                                    double seconds = 100 - (diff / 1.5);

                                    if (seconds > 120)
                                    {
                                        seconds = 120;
                                    }
                                    else if (seconds < 10)
                                    {
                                        seconds = 10;
                                    }

                                    bc.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(seconds));

                                    #region Bard Mastery Quest
                                    if (from is PlayerMobile)
                                    {
                                        BaseQuest quest = QuestHelper.GetQuest((PlayerMobile)from, typeof(TheBeaconOfHarmonyQuest));

                                        if (quest != null)
                                        {
                                            foreach (BaseObjective objective in quest.Objectives)
                                            {
                                                objective.Update(bc);
                                            }
                                        }
                                    }
                                    #endregion
                                }
                                else
                                {
                                    from.SendLocalizedMessage(1049532);                                    // You play hypnotic music, calming your target.

                                    targ.SendLocalizedMessage(500616);                                     // You hear lovely music, and forget to continue battling!
                                    targ.Combatant = null;
                                    targ.Warmode   = false;
                                }
                            }
                        }
                    }
                }
            }
Example #35
0
 protected override void OnTarget(Mobile from, object targ)
 {
     if (targ is FarmCow)
     {
         FarmCow c = (FarmCow)targ;
         if (c.Owner == from || c.Owner == null)
         {
             bool CanUse = from.CheckSkill(SkillName.AnimalLore, 20, 50);
             if (CanUse)
             {
                 if (c.Milk > 0)
                 {
                     if (t_mb.Quantity < 10)
                     {
                         c.PlaySound(c.GetIdleSound());
                         from.SendMessage("You milk the cow.");
                         if (t_mb.Quantity < 1)
                         {
                             t_mb.Age = DateTime.UtcNow;
                         }
                         int tofill = 10 - t_mb.Quantity;
                         if (c.Milk > tofill)
                         {
                             t_mb.Quantity = 10;
                             c.Milk       -= tofill;
                             if (t_mb.MilkType != TypeOfMilk.Cow && t_mb.MilkType != TypeOfMilk.None)
                             {
                                 t_mb.MilkType = TypeOfMilk.Mixed;
                             }
                             else
                             {
                                 t_mb.MilkType = TypeOfMilk.Cow;
                             }
                         }
                         else
                         {
                             t_mb.Quantity += c.Milk;
                             c.Milk         = 0;
                             if (t_mb.MilkType != TypeOfMilk.Cow && t_mb.MilkType != TypeOfMilk.None)
                             {
                                 t_mb.MilkType = TypeOfMilk.Mixed;
                             }
                             else
                             {
                                 t_mb.MilkType = TypeOfMilk.Cow;
                             }
                         }
                         t_mb.InvalidateProperties();
                         t_mb.UpdateName();
                     }
                     else
                     {
                         from.SendMessage("Your milk bucket is full!");
                     }
                 }
                 else
                 {
                     from.SendMessage("That animal is out of milk.");
                 }
             }
             else
             {
                 c.PlaySound(c.GetIdleSound());
                 from.SendMessage("You fail to milk the cow!");
             }
         }
         else
         {
             from.SendMessage("You don't own that animal.");
         }
     }
     else if (targ is FarmSheep)
     {
         FarmSheep c = (FarmSheep)targ;
         if (c.Owner == from || c.Owner == null)
         {
             bool CanUse = from.CheckSkill(SkillName.AnimalLore, 20, 50);
             if (CanUse)
             {
                 if (c.Milk > 0)
                 {
                     if (t_mb.Quantity < 10)
                     {
                         c.PlaySound(c.GetIdleSound());
                         from.SendMessage("You milk the sheep.");
                         if (t_mb.Quantity < 1)
                         {
                             t_mb.Age = DateTime.UtcNow;
                         }
                         int tofill = 10 - t_mb.Quantity;
                         if (c.Milk > tofill)
                         {
                             t_mb.Quantity = 10;
                             c.Milk       -= tofill;
                             if (t_mb.MilkType != TypeOfMilk.Sheep && t_mb.MilkType != TypeOfMilk.None)
                             {
                                 t_mb.MilkType = TypeOfMilk.Mixed;
                             }
                             else
                             {
                                 t_mb.MilkType = TypeOfMilk.Sheep;
                             }
                         }
                         else
                         {
                             t_mb.Quantity += c.Milk;
                             c.Milk         = 0;
                             if (t_mb.MilkType != TypeOfMilk.Sheep && t_mb.MilkType != TypeOfMilk.None)
                             {
                                 t_mb.MilkType = TypeOfMilk.Mixed;
                             }
                             else
                             {
                                 t_mb.MilkType = TypeOfMilk.Sheep;
                             }
                         }
                         t_mb.InvalidateProperties();
                         t_mb.UpdateName();
                     }
                     else
                     {
                         from.SendMessage("Your milk bucket is full!");
                     }
                 }
                 else
                 {
                     from.SendMessage("That animal is out of milk.");
                 }
             }
             else
             {
                 c.PlaySound(c.GetIdleSound());
                 from.SendMessage("You fail to milk the sheep!");
             }
         }
         else
         {
             from.SendMessage("You don't own that animal.");
         }
     }
     else if (targ is FarmGoat)
     {
         FarmGoat c = (FarmGoat)targ;
         if (c.Owner == from || c.Owner == null)
         {
             bool CanUse = from.CheckSkill(SkillName.AnimalLore, 20, 50);
             if (CanUse)
             {
                 if (c.Milk > 0)
                 {
                     if (t_mb.Quantity < 10)
                     {
                         c.PlaySound(c.GetIdleSound());
                         from.SendMessage("You milk the goat.");
                         if (t_mb.Quantity < 1)
                         {
                             t_mb.Age = DateTime.UtcNow;
                         }
                         int tofill = 10 - t_mb.Quantity;
                         if (c.Milk > tofill)
                         {
                             t_mb.Quantity = 10;
                             c.Milk       -= tofill;
                             if (t_mb.MilkType != TypeOfMilk.Goat && t_mb.MilkType != TypeOfMilk.None)
                             {
                                 t_mb.MilkType = TypeOfMilk.Mixed;
                             }
                             else
                             {
                                 t_mb.MilkType = TypeOfMilk.Goat;
                             }
                         }
                         else
                         {
                             t_mb.Quantity += c.Milk;
                             c.Milk         = 0;
                             if (t_mb.MilkType != TypeOfMilk.Goat && t_mb.MilkType != TypeOfMilk.None)
                             {
                                 t_mb.MilkType = TypeOfMilk.Mixed;
                             }
                             else
                             {
                                 t_mb.MilkType = TypeOfMilk.Goat;
                             }
                         }
                         t_mb.InvalidateProperties();
                         t_mb.UpdateName();
                     }
                     else
                     {
                         from.SendMessage("Your milk bucket is full!");
                     }
                 }
                 else
                 {
                     from.SendMessage("That animal is out of milk.");
                 }
             }
             else
             {
                 c.PlaySound(c.GetIdleSound());
                 from.SendMessage("You fail to milk the goat!");
             }
         }
         else
         {
             from.SendMessage("You don't own that animal.");
         }
     }
     else if (targ is Pitcher)
     {
         Pitcher bev = (Pitcher)targ;
         if (bev.Content == BeverageType.Milk || bev.Quantity < 1)
         {
             bev.Content = BeverageType.Milk;
             if (t_mb.Quantity > (bev.MaxQuantity - bev.Quantity))
             {
                 t_mb.Quantity -= (bev.MaxQuantity - bev.Quantity);
                 bev.Quantity   = bev.MaxQuantity;
             }
             else
             {
                 bev.Quantity += t_mb.Quantity;
                 t_mb.Quantity = 0;
             }
             t_mb.InvalidateProperties();
             t_mb.UpdateName();
             from.PlaySound(0x4E);
         }
         else
         {
             from.SendMessage("You shouldn't mix beverages.");
         }
     }
     else if (targ is MilkKeg)
     {
         MilkKeg bev = (MilkKeg)targ;
         if (bev.Quantity < 100)
         {
             if (bev.MilkType == t_mb.MilkType || bev.Quantity < 1)
             {
                 bev.MilkType = t_mb.MilkType;
                 if (bev.Quantity < 1)
                 {
                     bev.Age = t_mb.Age;
                 }
                 if (bev.Age > t_mb.Age)
                 {
                     bev.Age = t_mb.Age;
                 }
                 if (t_mb.Quantity > (100 - bev.Quantity))
                 {
                     t_mb.Quantity -= (100 - bev.Quantity);
                     bev.Quantity   = 100;
                 }
                 else
                 {
                     bev.Quantity += t_mb.Quantity;
                     t_mb.Quantity = 0;
                 }
                 t_mb.InvalidateProperties();
                 t_mb.UpdateName();
                 bev.InvalidateProperties();
                 bev.UpdateName();
                 from.PlaySound(0x4E);
                 from.SendMessage("You pour the milk into the keg.");
             }
             else
             {
                 bev.MilkType = TypeOfMilk.Mixed;
                 if (bev.Quantity < 1)
                 {
                     bev.Age = t_mb.Age;
                 }
                 if (bev.Age > t_mb.Age)
                 {
                     bev.Age = t_mb.Age;
                 }
                 if (t_mb.Quantity > (100 - bev.Quantity))
                 {
                     t_mb.Quantity -= (100 - bev.Quantity);
                     bev.Quantity   = 100;
                 }
                 else
                 {
                     bev.Quantity += t_mb.Quantity;
                     t_mb.Quantity = 0;
                 }
                 t_mb.InvalidateProperties();
                 t_mb.UpdateName();
                 bev.InvalidateProperties();
                 bev.UpdateName();
                 from.PlaySound(0x4E);
                 from.SendMessage("You pour the milk into the keg.");
             }
         }
         else
         {
             from.SendMessage("That is full!");
         }
     }
     else if (targ is MeasuringCup)
     {
         if (t_mb.Quantity > 0)
         {
             from.AddToBackpack(new Milk());
             from.PlaySound(0x240);
             from.SendMessage("You measure out one cup of milk.");
             t_mb.Quantity -= 1;
             t_mb.InvalidateProperties();
             t_mb.UpdateName();
         }
         else
         {
             from.SendMessage("The bucket is empty!");
         }
     }
     else
     {
         from.SendMessage("You can't do that.");
     }
 }
Example #36
0
        public void EndHeal()
        {
            StopHeal();

            int  healerNumber = -1, patientNumber = -1;
            bool playSound   = true;
            bool checkSkills = false;

            SkillName primarySkill   = GetPrimarySkill(m_Patient);
            SkillName secondarySkill = GetSecondarySkill(m_Patient);

            BaseCreature petPatient = m_Patient as BaseCreature;

            if (!m_Healer.Alive)
            {
                healerNumber  = 500962; // You were unable to finish your work before you died.
                patientNumber = -1;
                playSound     = false;
            }
            else if (!m_Healer.InRange(m_Patient, Bandage.Range))
            {
                healerNumber  = 500963; // You did not stay close enough to heal your target.
                patientNumber = -1;
                playSound     = false;
            }
            else if (!m_Patient.Alive || (petPatient != null && petPatient.IsDeadPet))
            {
                double healing = m_Healer.Skills[primarySkill].Value;
                double anatomy = m_Healer.Skills[secondarySkill].Value;
                double chance  = ((healing - 68.0) / 50.0) - (m_Slips * 0.02);

                if (((checkSkills = (healing >= 80.0 && anatomy >= 80.0)) && chance > Utility.RandomDouble()) ||
                    (Core.SE && petPatient is FactionWarHorse && petPatient.ControlMaster == m_Healer))
                //TODO: Dbl check doesn't check for faction of the horse here?
                {
                    if (m_Patient.Map == null || !m_Patient.Map.CanFit(m_Patient.Location, 16, false, false))
                    {
                        healerNumber  = 501042; // Target can not be resurrected at that location.
                        patientNumber = 502391; // Thou can not be resurrected there!
                    }
                    else if (m_Patient.Region != null && m_Patient.Region.IsPartOf("Khaldun"))
                    {
                        healerNumber  = 1010395; // The veil of death in this area is too strong and resists thy efforts to restore life.
                        patientNumber = -1;
                    }
                    else
                    {
                        healerNumber  = 500965; // You are able to resurrect your patient.
                        patientNumber = -1;

                        m_Patient.PlaySound(0x214);
                        m_Patient.FixedEffect(0x376A, 10, 16);

                        if (petPatient != null && petPatient.IsDeadPet)
                        {
                            Mobile master = petPatient.ControlMaster;

                            if (master != null && m_Healer == master)
                            {
                                petPatient.ResurrectPet();

                                for (int i = 0; i < petPatient.Skills.Length; ++i)
                                {
                                    petPatient.Skills[i].Base -= 0.1;
                                }
                            }
                            else if (master != null && master.InRange(petPatient, 3))
                            {
                                healerNumber = 503255; // You are able to resurrect the creature.

                                master.CloseGump(typeof(PetResurrectGump));
                                master.SendGump(new PetResurrectGump(m_Healer, petPatient));
                            }
                            else
                            {
                                bool found = false;

                                var friends = petPatient.Friends;

                                for (int i = 0; friends != null && i < friends.Count; ++i)
                                {
                                    Mobile friend = friends[i];

                                    if (friend.InRange(petPatient, 3))
                                    {
                                        healerNumber = 503255; // You are able to resurrect the creature.

                                        friend.CloseGump(typeof(PetResurrectGump));
                                        friend.SendGump(new PetResurrectGump(m_Healer, petPatient));

                                        found = true;
                                        break;
                                    }
                                }

                                if (!found)
                                {
                                    healerNumber = 1049670; // The pet's owner must be nearby to attempt resurrection.
                                }
                            }
                        }
                        else
                        {
                            m_Patient.CloseGump(typeof(ResurrectGump));
                            m_Patient.SendGump(new ResurrectGump(m_Patient, m_Healer));
                        }
                    }
                }
                else
                {
                    if (petPatient != null && petPatient.IsDeadPet)
                    {
                        healerNumber = 503256; // You fail to resurrect the creature.
                    }
                    else
                    {
                        healerNumber = 500966; // You are unable to resurrect your patient.
                    }

                    patientNumber = -1;
                }
            }
            else if (m_Patient.Poisoned)
            {
                m_Healer.SendLocalizedMessage(500969); // You finish applying the bandages.

                double healing = m_Healer.Skills[primarySkill].Value;
                double anatomy = m_Healer.Skills[secondarySkill].Value;
                double chance  = ((healing - 30.0) / 50.0) - (m_Patient.Poison.RealLevel * 0.1) - (m_Slips * 0.02);

                if ((checkSkills = (healing >= 60.0 && anatomy >= 60.0)) && chance > Utility.RandomDouble())
                {
                    if (m_Patient.CurePoison(m_Healer))
                    {
                        healerNumber  = (m_Healer == m_Patient) ? -1 : 1010058; // You have cured the target of all poisons.
                        patientNumber = 1010059;                                // You have been cured of all poisons.
                    }
                    else
                    {
                        healerNumber  = -1;
                        patientNumber = -1;
                    }
                }
                else
                {
                    healerNumber  = 1010060; // You have failed to cure your target!
                    patientNumber = -1;
                }
            }
            else if (BleedAttack.IsBleeding(m_Patient))
            {
                healerNumber  = 1060088; // You bind the wound and stop the bleeding
                patientNumber = 1060167; // The bleeding wounds have healed, you are no longer bleeding!

                BleedAttack.EndBleed(m_Patient, false);
            }
            else if (SplinteringWeaponContext.IsBleeding(m_Patient))
            {
                healerNumber  = 1060088; // You bind the wound and stop the bleeding
                patientNumber = 1060167; // The bleeding wounds have healed, you are no longer bleeding!

                SplinteringWeaponContext.EndBleeding(m_Patient);
            }
            else if (MortalStrike.IsWounded(m_Patient))
            {
                healerNumber  = (m_Healer == m_Patient ? 1005000 : 1010398);
                patientNumber = -1;
                playSound     = false;
            }
            else if (m_Patient.Hits == m_Patient.HitsMax)
            {
                healerNumber  = 500967; // You heal what little damage your patient had.
                patientNumber = -1;
            }
            else
            {
                checkSkills   = true;
                patientNumber = -1;

                double healing = m_Healer.Skills[primarySkill].Value;
                double anatomy = m_Healer.Skills[secondarySkill].Value;
                double chance  = ((healing + 10.0) / 100.0) - (m_Slips * 0.02);

                #region Heritage Items
                healing += EnhancedBandage.HealingBonus;
                #endregion

                #region Exodus Items
                Item item = m_Healer.FindItemOnLayer(Layer.TwoHanded);

                if (item is Asclepius || item is GargishAsclepius)
                {
                    healing += 15;
                }
                #endregion

                if (chance > Utility.RandomDouble())
                {
                    healerNumber = 500969; // You finish applying the bandages.

                    double min, max;

                    if (Core.AOS)
                    {
                        min = (anatomy / 8.0) + (healing / 5.0) + 4.0;
                        max = (anatomy / 6.0) + (healing / 2.5) + 4.0;
                    }
                    else
                    {
                        min = (anatomy / 5.0) + (healing / 5.0) + 3.0;
                        max = (anatomy / 5.0) + (healing / 2.0) + 10.0;
                    }

                    double toHeal = min + (Utility.RandomDouble() * (max - min));

                    if (m_Patient.Body.IsMonster || m_Patient.Body.IsAnimal)
                    {
                        toHeal += m_Patient.HitsMax / 100;
                    }

                    if (Core.AOS)
                    {
                        toHeal -= toHeal * m_Slips * 0.35; // TODO: Verify algorithm
                    }
                    else
                    {
                        toHeal -= m_Slips * 4;
                    }

                    #region City Loyalty
                    if (Server.Engines.CityLoyalty.CityLoyaltySystem.HasTradeDeal(m_Healer, Server.Engines.CityLoyalty.TradeDeal.GuildOfHealers))
                    {
                        toHeal += (int)Math.Ceiling(toHeal * 0.05);
                    }
                    #endregion

                    if (m_HealedPoisonOrBleed > 0)
                    {
                        toHeal /= m_HealedPoisonOrBleed;
                    }

                    if (toHeal < 1)
                    {
                        toHeal       = 1;
                        healerNumber = 500968; // You apply the bandages, but they barely help.
                    }
                    else if (m_Patient != m_Healer && m_Patient is PlayerMobile && m_Healer is PlayerMobile)
                    {
                        SpiritualityVirtue.OnHeal(m_Healer, (int)toHeal);
                    }

                    m_Patient.Heal((int)toHeal, m_Healer, false);
                }
                else
                {
                    healerNumber = 500968; // You apply the bandages, but they barely help.
                    playSound    = false;
                }
            }

            if (healerNumber != -1)
            {
                m_Healer.SendLocalizedMessage(healerNumber);
            }

            if (patientNumber != -1)
            {
                m_Patient.SendLocalizedMessage(patientNumber);
            }

            if (playSound)
            {
                m_Patient.PlaySound(0x57);
            }

            if (checkSkills)
            {
                m_Healer.CheckSkill(secondarySkill, 0.0, 120.0);
                m_Healer.CheckSkill(primarySkill, 0.0, 120.0);
            }

            if (m_Patient is PlayerMobile)
            {
                BuffInfo.RemoveBuff(m_Healer, BuffIcon.Healing);
            }
            else
            {
                BuffInfo.RemoveBuff(m_Healer, BuffIcon.Veterinary);
            }
        }
Example #37
0
        public static bool CheckMusicianship(Mobile m)
        {
            m.CheckSkill(SkillName.Musicianship, 0.0, 120.0);

            return(m.Skills[SkillName.Musicianship].Value / 100 > Utility.RandomDouble());
        }
Example #38
0
        public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, IBaseTool tool, CraftItem craftItem, int resHue)
        {
            if (from.CheckSkill(SkillName.Tinkering, -5.0, 15.0))
            {
                from.SendLocalizedMessage(500636);                   // Your tinker skill was sufficient to make the item lockable.

                Key key = new Key(KeyType.Copper, Key.RandomValue());

                KeyValue = key.KeyValue;
                DropItem(key);

                double tinkering = from.Skills[SkillName.Tinkering].Value;
                int    level     = (int)(tinkering * 0.8);

                RequiredSkill = level - 4;
                LockLevel     = level - 14;
                MaxLockLevel  = level + 35;

                if (LockLevel == 0)
                {
                    LockLevel = -1;
                }
                else if (LockLevel > 95)
                {
                    LockLevel = 95;
                }

                if (RequiredSkill > 95)
                {
                    RequiredSkill = 95;
                }

                if (MaxLockLevel > 95)
                {
                    MaxLockLevel = 95;
                }

                // A tinker trapped box should not explode until it is armed with a key
                Armed = false;
            }
            else
            {
                from.SendLocalizedMessage(500637);                   // Your tinker skill was insufficient to make the item lockable.
            }

            // The lockable containers never took material color into account, so this fixes it
            Type resourceType = typeRes;

            if (resourceType == null)
            {
                resourceType = craftItem.Resources.GetAt(0).ItemType;
            }

            var resource = CraftResources.GetFromType(resourceType);

            CraftContext context = craftSystem.GetContext(from);

            if (context != null && context.DoNotColor)
            {
                Hue = 0;
            }
            else
            {
                Hue = CraftResources.GetHue(resource);
            }

            return(1);
        }
Example #39
0
        public static TimeSpan OnUse(Mobile m)
        {
            /*if ( m.Target != null || m.Spell != null )
             * {
             * m.SendAsciiMessage("You are busy doing something else and cannot hide.");
             *      //m.SendLocalizedMessage( 501238 ); // You are busy doing something else and cannot hide.
             *      return TimeSpan.FromSeconds( 1.0 );
             * }*/

            double bonus = 0.0;

            BaseHouse house = BaseHouse.FindHouseAt(m);

            if (house != null && house.IsFriend(m))
            {
                bonus = 100.0;
            }
            else if (!Core.AOS)
            {
                if (house == null)
                {
                    house = BaseHouse.FindHouseAt(new Point3D(m.X - 1, m.Y, 127), m.Map, 16);
                }

                if (house == null)
                {
                    house = BaseHouse.FindHouseAt(new Point3D(m.X + 1, m.Y, 127), m.Map, 16);
                }

                if (house == null)
                {
                    house = BaseHouse.FindHouseAt(new Point3D(m.X, m.Y - 1, 127), m.Map, 16);
                }

                if (house == null)
                {
                    house = BaseHouse.FindHouseAt(new Point3D(m.X, m.Y + 1, 127), m.Map, 16);
                }

                if (house != null)
                {
                    bonus = 50.0;
                }
            }

            //int range = 18 - (int)(m.Skills[SkillName.Hiding].Value / 10);
            int range = Math.Min((int)((100 - m.Skills[SkillName.Hiding].Value) / 2) + 8, 18);                  //Cap of 18 not OSI-exact, intentional difference

            bool badCombat = (!m_CombatOverride && m.Combatant != null && m.InRange(m.Combatant.Location, range) && m.Combatant.InLOS(m));
            bool ok        = (!badCombat /*&& m.CheckSkill( SkillName.Hiding, 0.0 - bonus, 100.0 - bonus )*/);

            if (ok)
            {
                if (!m_CombatOverride)
                {
                    foreach (Mobile check in m.GetMobilesInRange(range))
                    {
                        if (check.InLOS(m) && /*check.Combatant == m*/ m.Combatant == check)
                        {
                            badCombat = true;
                            ok        = false;
                            break;
                        }
                    }
                }

                ok = (!badCombat && m.CheckSkill(SkillName.Hiding, 0.0 - bonus, 100.0 - bonus));
            }

            if (badCombat)
            {
                m.RevealingAction();

                m.LocalOverheadMessage(MessageType.Regular, 0x22, true, "You can't seem to hide right now.");                   // You can't seem to hide right now.

                return(TimeSpan.FromSeconds(10.0));
            }
            else
            {
                if (ok)
                {
                    m.Hidden = true;
                    m.LocalOverheadMessage(MessageType.Regular, 0x1F4, true, "You have hidden yourself well.");                       // You have hidden yourself well.
                }
                else
                {
                    m.RevealingAction();

                    m.LocalOverheadMessage(MessageType.Regular, 0x22, true, "You can't seem to hide here.");                       // You can't seem to hide here.
                }

                return(TimeSpan.FromSeconds(10.0));
            }
        }
Example #40
0
        public void Fire(Mobile from)
        {
            BaseRanged bow = from.Weapon as BaseRanged;

            if (bow == null)
            {
                SendLocalizedMessageTo(from, 500593);                   // You must practice with ranged weapons on this.
                return;
            }

            if (DateTime.Now < (m_LastUse + UseDelay))
            {
                return;
            }

            Point3D worldLoc = GetWorldLocation();

            if (FacingEast ? from.X <= worldLoc.X : from.Y <= worldLoc.Y)
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500596);                   // You would do better to stand in front of the archery butte.
                return;
            }

            if (FacingEast ? from.Y != worldLoc.Y : from.X != worldLoc.X)
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500597);                   // You aren't properly lined up with the archery butte to get an accurate shot.
                return;
            }

            if (!from.InRange(worldLoc, 6))
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500598);                   // You are too far away from the archery butte to get an accurate shot.
                return;
            }
            else if (from.InRange(worldLoc, 4))
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500599);                   // You are too close to the target.
                return;
            }

            Container pack     = from.Backpack;
            Type      ammoType = bow.AmmoType;

            bool isArrow = (ammoType == typeof(Arrow));
            bool isBolt  = (ammoType == typeof(Bolt));
            bool isKnown = (isArrow || isBolt);

            if (pack == null || !pack.ConsumeTotal(ammoType, 1))
            {
                if (isArrow)
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500594);                       // You do not have any arrows with which to practice.
                }
                else if (isBolt)
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500595);                       // You do not have any crossbow bolts with which to practice.
                }
                else
                {
                    SendLocalizedMessageTo(from, 500593);                       // You must practice with ranged weapons on this.
                }
                return;
            }

            m_LastUse = DateTime.Now;

            from.Direction = from.GetDirectionTo(GetWorldLocation());
            bow.PlaySwingAnimation(from);
            from.MovingEffect(this, bow.EffectID, 18, 1, false, false);

            ScoreEntry se = GetEntryFor(from);

            if (!from.CheckSkill(bow.Skill, m_MinSkill, m_MaxSkill))
            {
                from.PlaySound(bow.MissSound);

                PublicOverheadMessage(MessageType.Regular, 0x3B2, 500604, from.Name);                   // You miss the target altogether.

                se.Record(0);

                if (se.Count == 1)
                {
                    PublicOverheadMessage(MessageType.Regular, 0x3B2, 1062719, se.Total.ToString());
                }
                else
                {
                    PublicOverheadMessage(MessageType.Regular, 0x3B2, 1042683, String.Format("{0}\t{1}", se.Total, se.Count));
                }

                return;
            }

            Effects.PlaySound(Location, Map, 0x2B1);

            double rand = Utility.RandomDouble();

            int area, score, splitScore;

            if (0.10 > rand)
            {
                area       = 0;           // bullseye
                score      = 50;
                splitScore = 100;
            }
            else if (0.25 > rand)
            {
                area       = 1;           // inner ring
                score      = 10;
                splitScore = 20;
            }
            else if (0.50 > rand)
            {
                area       = 2;           // middle ring
                score      = 5;
                splitScore = 15;
            }
            else
            {
                area       = 3;           // outer ring
                score      = 2;
                splitScore = 5;
            }

            bool split = (isKnown && ((m_Arrows + m_Bolts) * 0.02) > Utility.RandomDouble());

            if (split)
            {
                PublicOverheadMessage(MessageType.Regular, 0x3B2, 1010027 + (isArrow ? 0 : 4) + area, from.Name);
            }
            else
            {
                PublicOverheadMessage(MessageType.Regular, 0x3B2, 1010035 + area, from.Name);

                if (isArrow)
                {
                    ++m_Arrows;
                }
                else if (isBolt)
                {
                    ++m_Bolts;
                }
            }

            se.Record(split ? splitScore : score);

            if (se.Count == 1)
            {
                PublicOverheadMessage(MessageType.Regular, 0x3B2, 1062719, se.Total.ToString());
            }
            else
            {
                PublicOverheadMessage(MessageType.Regular, 0x3B2, 1042683, String.Format("{0}\t{1}", se.Total, se.Count));
            }
        }
Example #41
0
        public virtual int GetDamageFixed(Mobile m)
        {
            m.CheckSkill(DamageSkill, 0.0, 120.0);

            return(m.Skills[DamageSkill].Fixed);
        }
Example #42
0
        public override void OnDoubleClick(Mobile from)
        {
            Container pack = from.Backpack;

            m_FromBonusSkill = (m_FromageQual + ((int)(from.Skills[SkillName.Cooking].Value) / 5));
            if (!from.InRange(this.GetWorldLocation(), 2))
            {
                from.LocalOverheadMessage(MessageType.Regular, 906, 1019045);
            }
            else
            {
                if ((Fermentation == false) && (MoulePlein == false) && (ContientUnFromton == false))
                {
                    from.Target = new OnRempliMouleFromton(this);
                    from.SendMessage(0x84C, "Vyber termosku s mlekem pro naplneni teto formy.");
                }
                else if ((MoulePlein == true) && (Fermentation == false) && (ContientUnFromton == false))
                {
                    new FromQuiFermente(this).Start();
                    Fermentation = true;
                    from.SendMessage("Odstartoval jsi proces fermentace.");
                    if (from.CheckSkill(SkillName.Cooking, 0, 100))
                    {
                        m_StadeFermentation = 5;
                    }
                    else
                    {
                        m_StadeFermentation = 0;
                    }
                }
                else if ((Fermentation == true) && (ContientUnFromton == false) && (MoulePlein == true))
                {
                    this.PublicOverheadMessage(MessageType.Regular, 1151, false, string.Format("Proces Fermentace: " + StadeFermentation.ToString() + " %"));
                }
                else if ((Fermentation == false) && (ContientUnFromton == true) && (MoulePlein == true))
                {
                    if (m_FromBonusSkill < 10)
                    {
                        this.PublicOverheadMessage(MessageType.Regular, 1152, false, string.Format("Fermentace se nepovedla a mleko je ztracene."));
                        m_ContientUnFromton = false;
                        m_MoulePlein        = false;
                        m_FromageQual       = 0;
                        m_FromAfaire        = 0;
                        this.Name           = "Cheese Form: Empty";
                    }
                    else if ((m_FromBonusSkill > 95) && Utility.RandomBool())
                    {
                        if (FromAfaire == 1)
                        {
                            from.SendMessage(0x84C, "Ziskal jsi uzasny Roquefort z formy.");
                            from.AddToBackpack(new FromageDeBrebisMagic());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                        else if (FromAfaire == 2)
                        {
                            from.SendMessage(0x84C, "Ziskal jsi uzasny crottin de Chavignol z form.");
                            from.AddToBackpack(new FromageDeChevreMagic());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                        else
                        {
                            from.SendMessage(0x84C, "Ziskal jsi uzasny Maroille z form.");
                            from.AddToBackpack(new FromageDeVacheMagic());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                    }
                    else
                    {
                        if (FromAfaire == 1)
                        {
                            from.SendMessage(0x84C, "Ziskal jsi uzasny ovci syr z form.");
                            from.AddToBackpack(new FromageDeBrebis());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                        else if (FromAfaire == 2)
                        {
                            from.SendMessage(0x84C, "Ziskal jsi uzasny kozy syr z form.");
                            from.AddToBackpack(new FromageDeChevre());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                        else
                        {
                            from.SendMessage(0x84C, "Ziskal jsi uzasny kravsky syr z form.");
                            from.AddToBackpack(new FromageDeVache());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                    }
                }
                else
                {
                    from.SendMessage(0x84C, "*gasp* A bug!");
                }
            }
        }
Example #43
0
        public static MorphResult Morph(Mobile m, int entryID)
        {
            if (entryID < 0 || entryID >= m_Entries.Length)
            {
                return(MorphResult.Fail);
            }

            AnimalFormEntry entry = m_Entries[entryID];

            m_LastAnimalForms[m] = entryID;     //On OSI, it's the last /attempted/ one not the last succeeded one

            if (m.Skills.Ninjitsu.Value < entry.ReqSkill)
            {
                string args = String.Format("{0}\t{1}\t ", entry.ReqSkill.ToString("F1"), SkillName.Ninjitsu);
                m.SendLocalizedMessage(1063013, args); // You need at least ~1_SKILL_REQUIREMENT~ ~2_SKILL_NAME~ skill to use that ability.
                return(MorphResult.NoSkill);
            }

            /*
             * if( !m.CheckSkill( SkillName.Ninjitsu, entry.ReqSkill, entry.ReqSkill + 37.5 ) )
             * return MorphResult.Fail;
             *
             * On OSI,it seems you can only gain starting at '0' using Animal form.
             */

            double ninjitsu = m.Skills.Ninjitsu.Value;

            if (ninjitsu < entry.ReqSkill + 37.5)
            {
                double chance = (ninjitsu - entry.ReqSkill) / 37.5;

                if (chance < Utility.RandomDouble())
                {
                    return(MorphResult.Fail);
                }
            }

            m.CheckSkill(SkillName.Ninjitsu, 0.0, 37.5);

            if (!BaseFormTalisman.EntryEnabled(m, entry.Type))
            {
                return(MorphResult.Success); // Still consumes mana, just no effect
            }
            BaseMount.Dismount(m);

            int bodyMod = entry.BodyMod;
            int hueMod  = entry.HueMod;

            m.BodyMod = bodyMod;
            m.HueMod  = hueMod;

            if (entry.SpeedBoost)
            {
                m.Send(SpeedControl.MountSpeed);
            }

            SkillMod mod = null;

            if (entry.StealthBonus)
            {
                mod         = new DefaultSkillMod(SkillName.Stealth, true, 20.0);
                mod.ObeyCap = true;
                m.AddSkillMod(mod);
            }

            SkillMod stealingMod = null;

            if (entry.StealingBonus)
            {
                stealingMod         = new DefaultSkillMod(SkillName.Stealing, true, 10.0);
                stealingMod.ObeyCap = true;
                m.AddSkillMod(stealingMod);
            }

            Timer timer = new AnimalFormTimer(m, bodyMod, hueMod);

            timer.Start();

            AddContext(m, new AnimalFormContext(timer, mod, entry.SpeedBoost, entry.Type, stealingMod));
            m.CheckStatTimers();
            return(MorphResult.Success);
        }
        public override void OnDoubleClick(Mobile from)
        {
            double minSkill = 75.0;

            if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
                return;
            }

            double necromancySkill = from.Skills[SkillName.Necromancy].Value;

            if (necromancySkill < 75.0)
            {
                from.SendMessage("You do not have the knowledge required to attempt this.");
                return;
            }
            else if ((from.Followers + 1) > from.FollowersMax)
            {
                from.SendLocalizedMessage(1049607);                   // You have too many followers to control that creature.
                return;
            }

            double scalar;

            if (necromancySkill >= 100.0)
            {
                scalar = 1.0;
            }
            else if (necromancySkill >= 90.0)
            {
                scalar = 0.8;
            }
            else if (necromancySkill >= 80.0)
            {
                scalar = 0.6;
            }
            else
            {
                scalar = 0.5;
            }

            double maxSkill = minSkill + 60.0;

            if (from.Mounted)
            {
                from.SendMessage("You cannot summon while mounted.");
                return;
            }

            from.Animate(17, 7, 1, true, false, 0);

            if (!from.CheckSkill(SkillName.Necromancy, minSkill, maxSkill))
            {
                from.PlaySound(0x24A);
                from.SendMessage("Your summoning has failed.");
                Delete();
                return;
            }
            else
            {
                NecroZombie m = new NecroZombie(true, scalar);

                if (m.SetControlMaster(from))
                {
                    Delete();

                    m.MoveToWorld(from.Location, from.Map);
                    from.PlaySound(0x24A);
                    from.SendMessage("You have summoned a zombie.");
                }
            }
        }
Example #45
0
        public static TimeSpan OnUse(Mobile m)
        {
            if (m.Spell != null)
            {
                m.SendLocalizedMessage(501238); // You are busy doing something else and cannot hide.
                return(TimeSpan.FromSeconds(1.0));
            }

            if (Core.ML && m.Target != null)
            {
                Target.Cancel(m);
            }

            double bonus = 0.0;

            BaseHouse house = BaseHouse.FindHouseAt(m);

            if (house?.IsFriend(m) == true)
            {
                bonus = 100.0;
            }
            else if (!Core.AOS)
            {
                house ??= BaseHouse.FindHouseAt(new Point3D(m.X - 1, m.Y, 127), m.Map, 16) ??
                BaseHouse.FindHouseAt(new Point3D(m.X + 1, m.Y, 127), m.Map, 16) ??
                BaseHouse.FindHouseAt(new Point3D(m.X, m.Y - 1, 127), m.Map, 16) ??
                BaseHouse.FindHouseAt(new Point3D(m.X, m.Y + 1, 127), m.Map, 16);

                if (house != null)
                {
                    bonus = 50.0;
                }
            }

            // int range = 18 - (int)(m.Skills.Hiding.Value / 10);
            int range = Math.Min((int)((100 - m.Skills.Hiding.Value) / 2) + 8,
                                 18); // Cap of 18 not OSI-exact, intentional difference

            bool badCombat = !CombatOverride && m.Combatant != null && m.InRange(m.Combatant.Location, range) &&
                             m.Combatant.InLOS(m);
            bool ok = !badCombat;

            if (ok)
            {
                if (!CombatOverride)
                {
                    if (m.GetMobilesInRange(range).Any(check => check.InLOS(m) && check.Combatant == m))
                    {
                        badCombat = true;
                    }
                }

                ok = !badCombat && m.CheckSkill(SkillName.Hiding, 0.0 - bonus, 100.0 - bonus);
            }

            if (badCombat)
            {
                m.RevealingAction();

                m.LocalOverheadMessage(MessageType.Regular, 0x22, 501237); // You can't seem to hide right now.

                return(TimeSpan.FromSeconds(1.0));
            }

            if (ok)
            {
                m.Hidden  = true;
                m.Warmode = false;
                m.LocalOverheadMessage(MessageType.Regular, 0x1F4, 501240); // You have hidden yourself well.
            }
            else
            {
                m.RevealingAction();

                m.LocalOverheadMessage(MessageType.Regular, 0x22, 501241); // You can't seem to hide here.
            }

            return(TimeSpan.FromSeconds(10.0));
        }
Example #46
0
            protected override void OnTarget(Mobile src, object targ)
            {
                bool foundAnyone = false;

                Point3D p;

                if (targ is Mobile mob)
                {
                    p = mob.Location;
                }
                else if (targ is Item item)
                {
                    p = item.Location;
                }
                else if (targ is IPoint3D point)
                {
                    p = new Point3D(point);
                }
                else
                {
                    p = src.Location;
                }

                double srcSkill = src.Skills[SkillName.DetectHidden].Value;
                int    range    = (int)(srcSkill / 10.0);

                if (!src.CheckSkill(SkillName.DetectHidden, 0.0, 100.0))
                {
                    range /= 2;
                }

                BaseHouse house = BaseHouse.FindHouseAt(p, src.Map, 16);

                bool inHouse = (house != null && house.IsFriend(src));

                if (inHouse)
                {
                    range = 22;
                }

                if (range > 0)
                {
                    IPooledEnumerable inRange = src.Map.GetMobilesInRange(p, range);

                    foreach (Mobile trg in inRange)
                    {
                        if (trg.Hidden && src != trg)
                        {
                            double ss = srcSkill + Utility.Random(21) - 10;
                            double ts = trg.Skills[SkillName.Hiding].Value + Utility.Random(21) - 10;

                            if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || (inHouse && house.IsInside(trg))))
                            {
                                if (trg is ShadowKnight && (trg.X != p.X || trg.Y != p.Y))
                                {
                                    continue;
                                }

                                trg.RevealingAction();
                                trg.SendLocalizedMessage(500814);                                 // You have been revealed!
                                foundAnyone = true;
                            }
                        }
                    }

                    inRange.Free();

                    if (Faction.Find(src) != null)
                    {
                        IPooledEnumerable itemsInRange = src.Map.GetItemsInRange(p, range);

                        foreach (Item item in itemsInRange)
                        {
                            if (item is BaseFactionTrap trap)
                            {
                                if (src.CheckTargetSkill(SkillName.DetectHidden, trap, 80.0, 100.0))
                                {
                                    src.SendLocalizedMessage(1042712, true, " " + (trap.Faction == null ? "" : trap.Faction.Definition.FriendlyName));                                     // You reveal a trap placed by a faction:

                                    trap.Visible = true;
                                    trap.BeginConceal();

                                    foundAnyone = true;
                                }
                            }
                        }

                        itemsInRange.Free();
                    }
                }

                if (!foundAnyone)
                {
                    src.SendLocalizedMessage(500817);                     // You can see nothing hidden there.
                }
            }
Example #47
0
 public override void CheckGain(Mobile m)
 {
     m.CheckSkill(MoveSkill, RequiredSkill - 12.5, RequiredSkill + 37.5);
 }
Example #48
0
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase  = from.Skills[def.Skill].Base;
            double skillValue = from.Skills[def.Skill].Value;

            Type type = null;

            if (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        //The whole harvest system is kludgy and I'm sure this is just adding to it.
                        if (item.Stackable)
                        {
                            int amount        = def.ConsumedPerHarvest;
                            int feluccaAmount = def.ConsumedPerFeluccaHarvest;

                            int racialAmount        = (int)Math.Ceiling(amount * 1.1);
                            int feluccaRacialAmount = (int)Math.Ceiling(feluccaAmount * 1.1);

                            bool eligableForRacialBonus = (def.RaceBonus && from.Race == Race.Human);
                            bool inFelucca = (map == Map.Felucca);

                            if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount)
                            {
                                item.Amount = feluccaRacialAmount;
                            }
                            else if (inFelucca && bank.Current >= feluccaAmount)
                            {
                                item.Amount = feluccaAmount;
                            }
                            else if (eligableForRacialBonus && bank.Current >= racialAmount)
                            {
                                item.Amount = racialAmount;
                            }
                            else
                            {
                                item.Amount = amount;
                            }
                        }

                        bank.Consume(item.Amount, from);

                        if (Give(from, item, def.PlaceAtFeetIfFull))
                        {
                            SendSuccessTo(from, item, resource);
                        }
                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }

                        BonusHarvestResource bonus = def.GetBonusResource();

                        if (bonus != null && bonus.Type != null && skillBase >= bonus.ReqSkill)
                        {
                            Item bonusItem = Construct(bonus.Type, from);

                            if (Give(from, bonusItem, true))                                    //Bonuses always allow placing at feet, even if pack is full irregrdless of def
                            {
                                bonus.SendSuccessTo(from);
                            }
                            else
                            {
                                item.Delete();
                            }
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if (toolWithUses.UsesRemaining > 0)
                            {
                                --toolWithUses.UsesRemaining;
                            }

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                // Genova: suporte ao UO:ML.
                                #region Mondain's Legacy
                                if (!(tool is JacobsPickaxe))
                                {
                                    tool.Delete();
                                    def.SendMessageTo(from, def.ToolBrokeMessage);
                                }
                                #endregion
                            }
                        }
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
Example #49
0
        protected override void AppliquerPoison(Mobile atk, Mobile def)
        {
            BaseWeapon weapon = Weapon(atk);
            Poison     poison = weapon.Poison;

            if (poison != null && weapon.PoisonCharges > 0)
            {
                if (!def.Poisoned || poison.Level > def.Poison.Level)
                {
                    --weapon.PoisonCharges;

                    double skill   = atk.Skills.Empoisonnement.Value;
                    bool   selfdmg = false;
                    double chance  = 0;
                    switch (poison.Level)
                    {       //peut probablement rendre ca plus compact en utilisant regularite.
                    case 0: //Lesser
                        if (skill > 30)
                        {
                            chance = 80;
                        }
                        else
                        {
                            chance = 20 + skill * 2;
                        }
                        break;

                    case 1:     //Regular
                        if (skill < 10)
                        {
                            selfdmg = true;
                            chance  = 10 - skill;
                        }
                        else if (skill < 30)
                        {
                            chance = 0;
                        }
                        else if (skill > 60)
                        {
                            chance = 80;
                        }
                        else
                        {
                            chance = 20 + (skill - 30) * 2;
                        }
                        break;

                    case 2:     //Greater
                        if (skill < 40)
                        {
                            selfdmg = true;
                            chance  = 40 - skill;
                        }
                        else if (skill < 60)
                        {
                            chance = 0;
                        }
                        else if (skill > 90)
                        {
                            chance = 80;
                        }
                        else
                        {
                            chance = 20 + (skill - 60) * 2;
                        }
                        break;

                    case 3:     //Deadly
                        if (skill < 70)
                        {
                            selfdmg = true;
                            chance  = 70 - skill;
                        }
                        else if (skill < 90)
                        {
                            chance = 0;
                        }
                        else if (skill > 100)
                        {
                            chance = 40;
                        }
                        else
                        {
                            chance = 20 + (skill - 90) * 2;
                        }
                        break;

                    case 4:     //Lethal
                        if (skill < 90)
                        {
                            selfdmg = true;
                            chance  = 90 - skill;
                        }
                        else if (skill <= 100)
                        {
                            chance = 0;
                        }
                        else
                        {
                            chance = 20 + (skill - 100) * 2;
                        }
                        break;
                    }
                    if (chance < 0)
                    {
                        chance = 0;
                    }
                    chance = chance / 100;
                    if (selfdmg)
                    {
                        if (Utility.RandomDouble() > chance)
                        {
                            atk.ApplyPoison(atk, poison);
                        }
                    }
                    else
                    if (atk.CheckSkill(SkillName.Empoisonnement, chance))
                    {
                        def.ApplyPoison(atk, poison);
                    }
                }
            }
        }
Example #50
0
        public void Target(Mobile m)
        {
            if (CheckHSequence(m))
            {
                SpellHelper.Turn(Caster, m);

                /* Transmogrifies the flesh of the target creature or player to resemble rotted corpse flesh,
                 * making them more vulnerable to Fire and Poison damage,
                 * but increasing their resistance to Physical and Cold damage.
                 *
                 * The effect lasts for ((Spirit Speak skill level - target's Resist Magic skill level) / 25 ) + 40 seconds.
                 *
                 * NOTE: Algorithm above is fixed point, should be:
                 * ((ss-mr)/2.5) + 40
                 *
                 * NOTE: Resistance is not checked if targeting yourself
                 */

                ExpireTimer timer = (ExpireTimer)m_Table[m];

                if (timer != null)
                {
                    timer.DoExpire();
                }
                else
                {
                    m.SendLocalizedMessage(1061689);                       // Your skin turns dry and corpselike.
                }
                if (m.Spell != null)
                {
                    m.Spell.OnCasterHurt();
                }

                m.Paralyzed = false;

                m.FixedParticles(0x373A, 1, 15, 9913, 67, 7, EffectLayer.Head);
                m.PlaySound(0x1BB);

                double ss = GetDamageSkill(Caster);
                double mr = (Caster == m ? 0.0 : GetResistSkill(m));
                m.CheckSkill(SkillName.MagicResist, 0.0, 120.0);                        //Skill check for gain

                TimeSpan duration = TimeSpan.FromSeconds(((ss - mr) / 2.5) + 40.0);

                ResistanceMod[] mods = new ResistanceMod[4]
                {
                    new ResistanceMod(ResistanceType.Fire, -15),
                    new ResistanceMod(ResistanceType.Poison, -15),
                    new ResistanceMod(ResistanceType.Cold, +10),
                    new ResistanceMod(ResistanceType.Physical, +10)
                };

                timer = new ExpireTimer(m, mods, duration);
                timer.Start();

                BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.CorpseSkin, 1075663, duration, m));

                m_Table[m] = timer;

                for (int i = 0; i < mods.Length; ++i)
                {
                    m.AddResistanceMod(mods[i]);
                }

                HarmfulSpell(m);
            }

            FinishSequence();
        }
Example #51
0
 public virtual void CheckGain(Mobile m)
 {
     m.CheckSkill(MoveSkill, RequiredSkill, RequiredSkill + 37.5);
 }
Example #52
0
            public bool TryRepairMobile(Mobile from, IRepairableMobile m, bool usingDeed, out bool toDelete)
            {
                int          damage = m.HitsMax - m.Hits;
                BaseCreature bc     = m as BaseCreature;

                toDelete = false;

                string name = bc != null ? bc.Name : "the creature";

                if (!from.InRange(m.Location, 2))
                {
                    from.SendLocalizedMessage(1113612, name); // You must move closer to attempt to repair ~1_CREATURE~.
                }
                else if (bc != null && bc.IsDeadBondedPet)
                {
                    from.SendLocalizedMessage(500426); // You can't repair that.
                }
                else if (damage <= 0)
                {
                    from.SendLocalizedMessage(1113613, name); // ~1_CREATURE~ doesn't appear to be damaged.
                }
                else
                {
                    double skillValue = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[SkillName.Tinkering].Value;
                    double required   = m is KotlAutomaton ? 80.0 : 0.1;

                    if (skillValue < required)
                    {
                        if (required == 80.0)
                        {
                            from.SendLocalizedMessage(1157049, name); // You must have at least 80 tinkering skill to attempt to repair ~1_CREATURE~.
                        }
                        else
                        {
                            from.SendLocalizedMessage(1113614, name); // You must have some tinkering skills to attempt to repair a ~1_CREATURE~.
                        }
                    }
                    else if (!from.CanBeginAction(typeof(IRepairableMobile)))
                    {
                        from.SendLocalizedMessage(1113611, name); // You must wait a moment before attempting to repair ~1_CREATURE~ again.
                    }
                    else if (bc != null && bc.GetMaster() != null && bc.GetMaster() != from && !bc.GetMaster().InRange(from.Location, 10))
                    {
                        from.SendLocalizedMessage(1157045); // The pet's owner must be nearby to attempt repair.
                    }
                    else if (!from.CanBeBeneficial(bc, false, false))
                    {
                        from.SendLocalizedMessage(1001017); // You cannot perform beneficial acts on your target.
                    }
                    else
                    {
                        if (damage > (int)(skillValue * 0.6))
                        {
                            damage = (int)(skillValue * 0.6);
                        }

                        if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                        {
                            damage /= 6;
                        }

                        Container pack = from.Backpack;

                        if (pack != null)
                        {
                            int v = pack.ConsumeUpTo(m.RepairResource, (damage + 4) / 5);

                            if (v <= 0 && m is Golem)
                            {
                                v = pack.ConsumeUpTo(typeof(BronzeIngot), (damage + 4) / 5);
                            }

                            if (v > 0)
                            {
                                m.Hits += damage;

                                if (damage > 1)
                                {
                                    from.SendLocalizedMessage(1113616, name); // You repair ~1_CREATURE~.
                                }
                                else
                                {
                                    from.SendLocalizedMessage(1157030, name); // You repair ~1_CREATURE~, but it barely helps.
                                }
                                toDelete = true;
                                double delay = 10 - (skillValue / 16.65);

                                from.BeginAction(typeof(IRepairableMobile));
                                Timer.DelayCall(TimeSpan.FromSeconds(delay), new TimerStateCallback(EndMobileRepair), from);

                                return(true);
                            }
                            else if (m is Golem)
                            {
                                from.SendLocalizedMessage(1113615, name); // You need some iron or bronze ingots to repair the ~1_CREATURE~.
                            }
                            else
                            {
                                from.SendLocalizedMessage(1044037); // You do not have sufficient metal to make that.
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage(1044037); // You do not have sufficient metal to make that.
                        }
                    }
                }

                return(false);
            }
Example #53
0
        public override void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            //Lava fishing needs to have its own set of rules.
            if (IsLavaHarvest(tool, toHarvest))
            {
                from.EndAction(locked);

                if (!CheckHarvest(from, tool))
                {
                    return;
                }

                int     tileID;
                Map     map;
                Point3D loc;

                if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
                {
                    OnBadHarvestTarget(from, tool, toHarvest);
                    return;
                }
                else if (!def.Validate(tileID) && !def.ValidateSpecial(tileID))
                {
                    OnBadHarvestTarget(from, tool, toHarvest);
                    return;
                }

                if (!CheckRange(from, tool, def, map, loc, true))
                {
                    return;
                }
                else if (!CheckResources(from, tool, def, map, loc, true))
                {
                    return;
                }
                else if (!CheckHarvest(from, tool, def, toHarvest))
                {
                    return;
                }

                HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

                if (bank == null)
                {
                    return;
                }

                HarvestVein vein = bank.Vein;

                if (vein == null)
                {
                    return;
                }

                Type type = null;

                HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, vein.PrimaryResource, vein.FallbackResource);

                if (from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
                {
                    //Special eye candy item
                    type = GetSpecialLavaItem(from, tool, map, loc, toHarvest);

                    //Special fish
                    if (type == null)
                    {
                        type = FishInfo.GetSpecialItem(from, tool, loc, IsLavaHarvest(tool, tileID));
                    }

                    if (type != null)
                    {
                        Item item = Construct(type, from, tool);

                        if (item == null)
                        {
                            type = null;
                        }
                        else
                        {
                            if (from.AccessLevel == AccessLevel.Player)
                            {
                                bank.Consume(Convert.ToInt32(map != null && map.Rules == MapRules.FeluccaRules ? Math.Ceiling(item.Amount / 2.0) : item.Amount), from);
                            }

                            if (Give(from, item, true))
                            {
                                SendSuccessTo(from, item, null);
                            }
                            else
                            {
                                SendPackFullTo(from, item, def, null);
                                item.Delete();
                            }
                        }
                    }
                }

                if (type == null)
                {
                    def.SendMessageTo(from, def.FailMessage);

                    double skill = (double)from.Skills[SkillName.Fishing].Value / 50;

                    if (0.5 / skill > Utility.RandomDouble())
                    {
                        OnToolUsed(from, tool, false);
                    }
                }
                else
                {
                    OnToolUsed(from, tool, true);
                }

                OnHarvestFinished(from, tool, def, vein, bank, null, null);
            }
            else
            {
                base.FinishHarvesting(from, tool, def, toHarvest, locked);
            }
        }
Example #54
0
        public bool DoDisposeOre(int x, int y, int z, Map map, Mobile from)
        {
            if (!IsMiningTile(x, y, map))
            {
                this.Say("I can not mine here !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            HarvestBank bank = Mining.System.OreAndStone.GetBank(map, x, y);

            if (bank == null)
            {
                this.Say("I can not mine here !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            if (bank.Current <= 0)
            {
                this.Say("No Ore remains !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            HarvestVein vein = bank.DefaultVein;

            if (vein == null)
            {
                this.Say("I can not mine here !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            HarvestDefinition def = Mining.System.OreAndStone;
            HarvestResource   res = vein.PrimaryResource;
            BaseOre           ore = Mining.System.Construct(res.Types[0], null) as BaseOre;

            if (ore == null)
            {
                this.Say("I can not mine here !");
                m_Mine       = false;
                this.Hue     = 0;
                ControlOrder = OrderType.Follow;
                return(false);
            }

            if (ore.Resource > CraftResource.Iron)
            {
                double minskill  = 0.0;
                double minskill2 = 0.0;
                double maxskill  = 0.0;
                double skillbase = this.Skills.Mining.Base;

                switch (ore.Resource)
                {
                case CraftResource.Iron: { minskill = 00.0; minskill2 = 00.0; maxskill = 100.0; } break;

                case CraftResource.DullCopper: { minskill = 60.0; minskill2 = 25.0; maxskill = 105.0; } break;

                case CraftResource.ShadowIron: { minskill = 65.0; minskill2 = 30.0; maxskill = 110.0; } break;

                case CraftResource.Copper: { minskill = 70.0; minskill2 = 35.0; maxskill = 115.0; } break;

                case CraftResource.Gold: { minskill = 75.0; minskill2 = 40.0; maxskill = 120.0; } break;

                case CraftResource.Agapite: { minskill = 80.0; minskill2 = 45.0; maxskill = 120.0; } break;

                case CraftResource.Verite: { minskill = 85.0; minskill2 = 50.0; maxskill = 120.0; } break;

                case CraftResource.Valorite: { minskill = 90.0; minskill2 = 55.0; maxskill = 120.0; } break;
                }

                if (Utility.RandomDouble() <= 0.30 || skillbase < minskill)
                {
                    ore = new IronOre(); minskill = 00.0; minskill2 = 00.0; maxskill = 100.0;
                }
                if (!(from.CheckSkill(SkillName.Mining, minskill2, maxskill)))
                {
                    ore.Delete();
                    return(false);
                }
            }

            ore.Amount = (map == Map.Felucca ? 2 : 1);
            if (from != null)
            {
                from.AddToBackpack(ore);
            }
            else
            {
                ore.Delete();
            }
            bank.Consume(ore.Amount, this);
            this.Hue = ore.Hue;
            return(true);
        }
Example #55
0
        public override void OnDoubleClick(Mobile from)
        {
            Container pack = from.Backpack;

            m_FromBonusSkill = (m_FromageQual + ((int)(from.Skills[SkillName.Cooking].Value) / 5));
            if (!from.InRange(this.GetWorldLocation(), 2))
            {
                from.LocalOverheadMessage(MessageType.Regular, 906, 1019045);
            }
            else
            {
                if ((Fermentation == false) && (MoulePlein == false) && (ContientUnFromton == false))
                {
                    from.Target = new OnRempliMouleFromton(this);
                    from.SendMessage(0x84C, "Choose the milk bucket for filling the cheese form.");
                }
                else if ((MoulePlein == true) && (Fermentation == false) && (ContientUnFromton == false))
                {
                    new FromQuiFermente(this).Start();
                    Fermentation = true;
                    from.SendMessage("You start the fermentation process.");
                    if (from.CheckSkill(SkillName.Cooking, 0, 100))
                    {
                        m_StadeFermentation = 5;
                    }
                    else
                    {
                        m_StadeFermentation = 0;
                    }
                }
                else if ((Fermentation == true) && (ContientUnFromton == false) && (MoulePlein == true))
                {
                    this.PublicOverheadMessage(MessageType.Regular, 1151, false, string.Format("Fermentation process: " + StadeFermentation.ToString() + "%"));
                }
                else if ((Fermentation == false) && (ContientUnFromton == true) && (MoulePlein == true))
                {
                    if (m_FromBonusSkill < 10)
                    {
                        this.PublicOverheadMessage(MessageType.Regular, 1152, false, string.Format("Fermentation failed, the milk is lost."));
                        m_ContientUnFromton = false;
                        m_MoulePlein        = false;
                        m_FromageQual       = 0;
                        m_FromAfaire        = 0;
                        this.Name           = "Cheese Form: Empty";
                    }
                    else if ((m_FromBonusSkill > 95) && Utility.RandomBool())
                    {
                        if (FromAfaire == 1)
                        {
                            from.SendMessage(0x84C, "You obtain a wonderful Roquefort from the form.");
                            from.AddToBackpack(new FromageDeBrebisMagic());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                        else if (FromAfaire == 2)
                        {
                            from.SendMessage(0x84C, "You obtain a wonderful crottin de Chavignol from the form.");
                            from.AddToBackpack(new FromageDeChevreMagic());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                        else
                        {
                            from.SendMessage(0x84C, "You obtain a wonderful Maroille from the form.");
                            from.AddToBackpack(new FromageDeVacheMagic());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                    }
                    else
                    {
                        if (FromAfaire == 1)
                        {
                            from.SendMessage(0x84C, "You obtain a wonderful sheep cheese from the form.");
                            from.AddToBackpack(new FromageDeBrebis());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                        else if (FromAfaire == 2)
                        {
                            from.SendMessage(0x84C, "You obtain a wonderful goat cheese from the form.");
                            from.AddToBackpack(new FromageDeChevre());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                        else
                        {
                            from.SendMessage(0x84C, "You obtain a wonderful cow cheese from the form.");
                            from.AddToBackpack(new FromageDeVache());
                            m_ContientUnFromton = false;
                            m_MoulePlein        = false;
                            m_FromageQual       = 0;
                            m_FromAfaire        = 0;
                            this.Name           = "Cheese Form: Empty";
                        }
                    }
                }
                else
                {
                    from.SendMessage(0x84C, "*gasp* A bug!");
                }
            }
        }
Example #56
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (!(targeted is Mobile))
                {
                    from.SendLocalizedMessage(1049528);                       // You cannot calm that!
                }
                else if (from.Region.IsPartOf(typeof(Engines.ConPVP.SafeZone)))
                {
                    from.SendMessage("You may not peacemake here.");
                }
                else if (((Mobile)targeted).Region.IsPartOf(typeof(Engines.ConPVP.SafeZone)))
                {
                    from.SendMessage("You may not peacemake there.");
                }
                else if (!m_Instrument.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1062488);                       // The instrument you are trying to play is no longer in your backpack!
                }
                else
                {
                    m_SetSkillTime     = false;
                    from.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(10.0);

                    if (targeted == from)
                    {
                        // Standard mode : reset combatants for everyone in the area

                        if (!BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendLocalizedMessage(500612);                               // You play poorly, and there is no effect.
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                        else if (!from.CheckSkill(SkillName.Peacemaking, 0.0, 120.0))
                        {
                            from.SendLocalizedMessage(500613);                               // You attempt to calm everyone, but fail.
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                        else
                        {
                            from.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(5.0);
                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);

                            Map map = from.Map;

                            if (map != null)
                            {
                                int range = BaseInstrument.GetBardRange(from, SkillName.Peacemaking);

                                bool calmed = false;

                                foreach (Mobile m in from.GetMobilesInRange(range))
                                {
                                    if ((m is BaseCreature && ((BaseCreature)m).Uncalmable) || (m is BaseCreature && ((BaseCreature)m).AreaPeaceImmune) || m == from || !from.CanBeHarmful(m, false))
                                    {
                                        continue;
                                    }

                                    calmed = true;

                                    m.SendLocalizedMessage(500616);                                       // You hear lovely music, and forget to continue battling!
                                    m.Combatant = null;
                                    m.Warmode   = false;

                                    if (m is BaseCreature && !((BaseCreature)m).BardPacified)
                                    {
                                        ((BaseCreature)m).Pacify(from, DateTime.Now + TimeSpan.FromSeconds(1.0));
                                    }
                                }

                                if (!calmed)
                                {
                                    from.SendLocalizedMessage(1049648);                                       // You play hypnotic music, but there is nothing in range for you to calm.
                                }
                                else
                                {
                                    from.SendLocalizedMessage(500615);                                       // You play your hypnotic music, stopping the battle.
                                }
                            }
                        }
                    }
                    else
                    {
                        // Target mode : pacify a single target for a longer duration

                        Mobile targ = (Mobile)targeted;

                        if (!from.CanBeHarmful(targ, false))
                        {
                            from.SendLocalizedMessage(1049528);
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).Uncalmable)
                        {
                            from.SendLocalizedMessage(1049526);                               // You have no chance of calming that creature.
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).BardPacified)
                        {
                            from.SendLocalizedMessage(1049527);                               // That creature is already being calmed.
                            m_SetSkillTime = true;
                        }
                        else if (!BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendLocalizedMessage(500612);                               // You play poorly, and there is no effect.
                            from.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(5.0);
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                        else
                        {
                            double diff  = m_Instrument.GetDifficultyFor(targ) - 10.0;
                            double music = from.Skills[SkillName.Musicianship].Value;

                            if (music > 100.0)
                            {
                                diff -= (music - 100.0) * 0.5;
                            }

                            if (!from.CheckTargetSkill(SkillName.Peacemaking, targ, diff - 25.0, diff + 25.0))
                            {
                                from.SendLocalizedMessage(1049531);                                   // You attempt to calm your target, but fail.
                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);
                            }
                            else
                            {
                                m_Instrument.PlayInstrumentWell(from);
                                m_Instrument.ConsumeUse(from);

                                from.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds(5.0);
                                if (targ is BaseCreature)
                                {
                                    BaseCreature bc = (BaseCreature)targ;

                                    from.SendLocalizedMessage(1049532);                                       // You play hypnotic music, calming your target.

                                    targ.Combatant = null;
                                    targ.Warmode   = false;

                                    double seconds = 100 - (diff / 1.5);

                                    if (seconds > 120)
                                    {
                                        seconds = 120;
                                    }
                                    else if (seconds < 10)
                                    {
                                        seconds = 10;
                                    }

                                    bc.Pacify(from, DateTime.Now + TimeSpan.FromSeconds(seconds));
                                }
                                else
                                {
                                    from.SendLocalizedMessage(1049532);                                      // You play hypnotic music, calming your target.

                                    targ.SendLocalizedMessage(500616);                                       // You hear lovely music, and forget to continue battling!
                                    targ.Combatant = null;
                                    targ.Warmode   = false;
                                }
                            }
                        }
                    }
                }
            }
Example #57
0
 public override void CheckGain(Mobile m)
 {
     m.CheckSkill(MoveSkill, RequiredSkill, 120.0);
 }
Example #58
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                int number;

                if (!this.CheckDeed(from))
                {
                    return;
                }

                bool usingDeed = (this.m_Deed != null);
                bool toDelete  = false;

                // TODO: Make an IRepairable

                if (this.m_CraftSystem.CanCraft(from, this.m_Tool, targeted.GetType()) == 1044267)
                {
                    number = 1044282; // You must be near a forge and and anvil to repair items. * Yes, there are two and's *
                }
                else if (this.m_CraftSystem is DefTinkering && targeted is Golem)
                {
                    Golem g      = (Golem)targeted;
                    int   damage = g.HitsMax - g.Hits;

                    if (g.IsDeadBondedPet)
                    {
                        number = 500426; // You can't repair that.
                    }
                    else if (damage <= 0)
                    {
                        number = 500423; // That is already in full repair.
                    }
                    else
                    {
                        double skillValue = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[SkillName.Tinkering].Value;

                        if (skillValue < 60.0)
                        {
                            number = 1044153; // You don't have the required skills to attempt this item.	//TODO: How does OSI handle this with deeds with golems?
                        }
                        else if (!from.CanBeginAction(typeof(Golem)))
                        {
                            number = 501789; // You must wait before trying again.
                        }
                        else
                        {
                            if (damage > (int)(skillValue * 0.3))
                            {
                                damage = (int)(skillValue * 0.3);
                            }

                            damage += 30;

                            if (!from.CheckSkill(SkillName.Tinkering, 0.0, 100.0))
                            {
                                damage /= 2;
                            }

                            Container pack = from.Backpack;

                            if (pack != null)
                            {
                                int v = pack.ConsumeUpTo(typeof(IronIngot), (damage + 4) / 5);

                                if (v > 0)
                                {
                                    g.Hits += v * 5;

                                    number   = 1044279; // You repair the item.
                                    toDelete = true;

                                    from.BeginAction(typeof(Golem));
                                    Timer.DelayCall(TimeSpan.FromSeconds(12.0), new TimerStateCallback(EndGolemRepair), from);
                                }
                                else
                                {
                                    number = 1044037; // You do not have sufficient metal to make that.
                                }
                            }
                            else
                            {
                                number = 1044037; // You do not have sufficient metal to make that.
                            }
                        }
                    }
                }
                else if (targeted is BaseWeapon)
                {
                    BaseWeapon weapon   = (BaseWeapon)targeted;
                    SkillName  skill    = this.m_CraftSystem.MainSkill;
                    int        toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (this.m_CraftSystem.CraftItems.SearchForSubclass(weapon.GetType()) == null && !this.IsSpecialWeapon(weapon))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!weapon.IsChildOf(from.Backpack) && (!Core.ML || weapon.Parent != from))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (!Core.AOS && weapon.PoisonCharges != 0)
                    {
                        number = 1005012; // You cannot repair an item while a caustic substance is on it.
                    }
                    else if (weapon.MaxHitPoints <= 0 || weapon.HitPoints == weapon.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (weapon.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else if (weapon.BlockRepair)
                    {
                        number = 1044277; // That item cannot be repaired.
                    }
                    else
                    {
                        if (this.CheckWeaken(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            weapon.MaxHitPoints -= toWeaken;
                            weapon.HitPoints     = Math.Max(0, weapon.HitPoints - toWeaken);
                        }

                        if (this.CheckRepairDifficulty(from, skill, weapon.HitPoints, weapon.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            this.m_CraftSystem.PlayCraftEffect(from);
                            weapon.HitPoints = weapon.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            this.m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseArmor)
                {
                    BaseArmor armor    = (BaseArmor)targeted;
                    SkillName skill    = this.m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (this.m_CraftSystem.CraftItems.SearchForSubclass(armor.GetType()) == null && !this.IsSpecialArmor(armor))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!armor.IsChildOf(from.Backpack) && (!Core.ML || armor.Parent != from))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (armor.MaxHitPoints <= 0 || armor.HitPoints == armor.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (armor.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else if (armor.BlockRepair)
                    {
                        number = 1044277; // That item cannot be repaired.
                    }
                    else
                    {
                        if (this.CheckWeaken(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            armor.MaxHitPoints -= toWeaken;
                            armor.HitPoints     = Math.Max(0, armor.HitPoints - toWeaken);
                        }

                        if (this.CheckRepairDifficulty(from, skill, armor.HitPoints, armor.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            this.m_CraftSystem.PlayCraftEffect(from);
                            armor.HitPoints = armor.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            this.m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseJewel && ((BaseJewel)targeted).TimesImbued > 0)
                {
                    BaseJewel jewel    = (BaseJewel)targeted;
                    SkillName skill    = m_CraftSystem.MainSkill;
                    int       toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (m_CraftSystem.CraftItems.SearchForSubclass(jewel.GetType()) == null)
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!jewel.IsChildOf(from.Backpack))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (jewel.MaxHitPoints <= 0 || jewel.HitPoints == jewel.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (jewel.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278; // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else if (jewel.BlockRepair)
                    {
                        number = 1044277; // That item cannot be repaired.
                    }
                    else
                    {
                        if (CheckWeaken(from, skill, jewel.HitPoints, jewel.MaxHitPoints))
                        {
                            jewel.MaxHitPoints -= toWeaken;
                            jewel.HitPoints     = Math.Max(0, jewel.HitPoints - toWeaken);
                        }

                        if (CheckRepairDifficulty(from, skill, jewel.HitPoints, jewel.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            m_CraftSystem.PlayCraftEffect(from);
                            jewel.HitPoints = jewel.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (targeted is BaseClothing)
                {
                    BaseClothing clothing = (BaseClothing)targeted;
                    SkillName    skill    = this.m_CraftSystem.MainSkill;
                    int          toWeaken = 0;

                    if (Core.AOS)
                    {
                        toWeaken = 1;
                    }
                    else if (skill != SkillName.Tailoring)
                    {
                        double skillLevel = (usingDeed) ? this.m_Deed.SkillLevel : from.Skills[skill].Base;

                        if (skillLevel >= 90.0)
                        {
                            toWeaken = 1;
                        }
                        else if (skillLevel >= 70.0)
                        {
                            toWeaken = 2;
                        }
                        else
                        {
                            toWeaken = 3;
                        }
                    }

                    if (this.m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && !this.IsSpecialClothing(clothing) && !((targeted is TribalMask) || (targeted is HornedTribalMask)))
                    {
                        number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                    }
                    else if (!clothing.IsChildOf(from.Backpack) && (!Core.ML || clothing.Parent != from))
                    {
                        number = 1044275; // The item must be in your backpack to repair it.
                    }
                    else if (clothing.MaxHitPoints <= 0 || clothing.HitPoints == clothing.MaxHitPoints)
                    {
                        number = 1044281; // That item is in full repair
                    }
                    else if (clothing.MaxHitPoints <= toWeaken)
                    {
                        number = 1044278;          // That item has been repaired many times, and will break if repairs are attempted again.
                    }
                    else if (clothing.BlockRepair) // quick fix
                    {
                        number = 1044277;          // That item cannot be repaired.
                    }
                    else
                    {
                        if (this.CheckWeaken(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            clothing.MaxHitPoints -= toWeaken;
                            clothing.HitPoints     = Math.Max(0, clothing.HitPoints - toWeaken);
                        }

                        if (this.CheckRepairDifficulty(from, skill, clothing.HitPoints, clothing.MaxHitPoints))
                        {
                            number = 1044279; // You repair the item.
                            this.m_CraftSystem.PlayCraftEffect(from);
                            clothing.HitPoints = clothing.MaxHitPoints;
                        }
                        else
                        {
                            number = (usingDeed) ? 1061137 : 1044280; // You fail to repair the item. [And the contract is destroyed]
                            this.m_CraftSystem.PlayCraftEffect(from);
                        }

                        toDelete = true;
                    }
                }
                else if (!usingDeed && targeted is BlankScroll)
                {
                    SkillName skill = this.m_CraftSystem.MainSkill;

                    if (from.Skills[skill].Value >= 50.0)
                    {
                        ((BlankScroll)targeted).Consume(1);
                        RepairDeed deed = new RepairDeed(RepairDeed.GetTypeFor(this.m_CraftSystem), from.Skills[skill].Value, from);
                        from.AddToBackpack(deed);

                        number = 500442; // You create the item and put it in your backpack.
                    }
                    else
                    {
                        number = 1047005; // You must be at least apprentice level to create a repair service contract.
                    }
                }
                else if (targeted is Item)
                {
                    number = (usingDeed) ? 1061136 : 1044277; // That item cannot be repaired. // You cannot repair that item with this type of repair contract.
                }
                else
                {
                    number = 500426; // You can't repair that.
                }

                if (!usingDeed)
                {
                    CraftContext context = this.m_CraftSystem.GetContext(from);
                    from.SendGump(new CraftGump(from, this.m_CraftSystem, this.m_Tool, number));
                }
                else
                {
                    from.SendLocalizedMessage(number);

                    if (toDelete)
                    {
                        this.m_Deed.Delete();
                    }
                }
            }
        public virtual void FinishHarvesting(Mobile from, Item tool, HarvestDefinition def, object toHarvest, object locked)
        {
            from.EndAction(locked);

            if (!CheckHarvest(from, tool))
            {
                return;
            }

            int     tileID;
            Map     map;
            Point3D loc;

            if (!GetHarvestDetails(from, tool, toHarvest, out tileID, out map, out loc))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }
            else if (!def.Validate(tileID))
            {
                OnBadHarvestTarget(from, tool, toHarvest);
                return;
            }

            if (!CheckRange(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckResources(from, tool, def, map, loc, true))
            {
                return;
            }
            else if (!CheckHarvest(from, tool, def, toHarvest))
            {
                return;
            }

            if (SpecialHarvest(from, tool, def, map, loc))
            {
                return;
            }

            HarvestBank bank = def.GetBank(map, loc.X, loc.Y);

            if (bank == null)
            {
                return;
            }

            HarvestVein vein = bank.Vein;

            if (vein != null)
            {
                vein = MutateVein(from, tool, def, bank, toHarvest, vein);
            }

            if (vein == null)
            {
                return;
            }

            HarvestResource primary  = vein.PrimaryResource;
            HarvestResource fallback = vein.FallbackResource;
            HarvestResource resource = MutateResource(from, tool, def, map, loc, vein, primary, fallback);

            double skillBase = from.Skills[def.Skill].Base;

            Type type = null;

            if (skillBase >= resource.ReqSkill && from.CheckSkill(def.Skill, resource.MinSkill, resource.MaxSkill))
            {
                type = GetResourceType(from, tool, def, map, loc, resource);

                if (type != null)
                {
                    type = MutateType(type, from, tool, def, map, loc, resource);
                }

                if (type != null)
                {
                    Item item = Construct(type, from);

                    if (item == null)
                    {
                        type = null;
                    }
                    else
                    {
                        if (item.Stackable)
                        {
                            if (map == Map.Felucca && bank.Current >= def.ConsumedPerFeluccaHarvest)
                            {
                                item.Amount = def.ConsumedPerFeluccaHarvest;
                            }
                            else
                            {
                                item.Amount = def.ConsumedPerHarvest;
                            }
                        }

                        bank.Consume(def, item.Amount);

                        if (Give(from, item, def.PlaceAtFeetIfFull))
                        {
                            SendSuccessTo(from, item, resource);
                        }
                        else
                        {
                            SendPackFullTo(from, item, def, resource);
                            item.Delete();
                        }

                        if (tool is IUsesRemaining)
                        {
                            IUsesRemaining toolWithUses = (IUsesRemaining)tool;

                            toolWithUses.ShowUsesRemaining = true;

                            if (toolWithUses.UsesRemaining > 0)
                            {
                                --toolWithUses.UsesRemaining;
                            }

                            if (toolWithUses.UsesRemaining < 1)
                            {
                                tool.Delete();
                                def.SendMessageTo(from, def.ToolBrokeMessage);
                            }
                        }
                    }
                }
            }

            if (type == null)
            {
                def.SendMessageTo(from, def.FailMessage);
            }

            OnHarvestFinished(from, tool, def, vein, bank, resource, toHarvest);
        }
Example #60
0
        public void EndHeal()
        {
            StopHeal();

            int  healerNumber = -1, patientNumber = -1;
            bool playSound   = true;
            bool checkSkills = false;

            SkillName primarySkill   = GetPrimarySkill(m_Patient);
            SkillName secondarySkill = GetSecondarySkill(m_Patient);

            BaseCreature petPatient = m_Patient as BaseCreature;

            if (!m_Healer.Alive)
            {
                healerNumber  = 500962;                // You were unable to finish your work before you died.
                patientNumber = -1;
                playSound     = false;
            }
            else if (!m_Healer.InRange(m_Patient, Core.AOS ? 2 : 1))
            {
                healerNumber  = 500963;                // You did not stay close enough to heal your target.
                patientNumber = -1;
                playSound     = false;
            }
            else if (!m_Patient.Alive || (petPatient != null && petPatient.IsDeadPet))
            {
                double healing = m_Healer.Skills[primarySkill].Value;
                double anatomy = m_Healer.Skills[secondarySkill].Value;
                double chance  = ((healing - 68.0) / 50.0) - (m_Slips * 0.02);

                if (((checkSkills = (healing >= 80.0 && anatomy >= 80.0)) && chance > Utility.RandomDouble()) ||
                    (Core.SE && petPatient is Factions.FactionWarHorse && petPatient.ControlMaster == m_Healer))                        //TODO: Dbl check doesn't check for faction of the horse here?
                {
                    if (m_Patient.Map == null || !m_Patient.Map.CanFit(m_Patient.Location, 16, false, false))
                    {
                        healerNumber  = 501042;                        // Target can not be resurrected at that location.
                        patientNumber = 502391;                        // Thou can not be resurrected there!
                    }
                    else if (m_Patient.Region != null && m_Patient.Region.IsPartOf("Khaldun"))
                    {
                        healerNumber  = 1010395;                        // The veil of death in this area is too strong and resists thy efforts to restore life.
                        patientNumber = -1;
                    }
                    else
                    {
                        healerNumber  = 500965;                        // You are able to resurrect your patient.
                        patientNumber = -1;

                        m_Patient.PlaySound(0x214);
                        m_Patient.FixedEffect(0x376A, 10, 16);

                        if (petPatient != null && petPatient.IsDeadPet)
                        {
                            Mobile master = petPatient.ControlMaster;

                            if (master != null && master.InRange(petPatient, 3))
                            {
                                healerNumber = 503255;                                 // You are able to resurrect the creature.

                                master.CloseGump(typeof(PetResurrectGump));
                                master.SendGump(new PetResurrectGump(m_Healer, petPatient));
                            }
                            else
                            {
                                bool found = false;

                                List <Mobile> friends = petPatient.Friends;

                                for (int i = 0; friends != null && i < friends.Count; ++i)
                                {
                                    Mobile friend = friends[i];

                                    if (friend.InRange(petPatient, 3))
                                    {
                                        healerNumber = 503255;                                         // You are able to resurrect the creature.

                                        friend.CloseGump(typeof(PetResurrectGump));
                                        friend.SendGump(new PetResurrectGump(m_Healer, petPatient));

                                        found = true;
                                        break;
                                    }
                                }

                                if (!found)
                                {
                                    healerNumber = 1049670;                                     // The pet's owner must be nearby to attempt resurrection.
                                }
                            }
                        }
                        else
                        {
                            m_Patient.CloseGump(typeof(ResurrectGump));
                            m_Patient.SendGump(new ResurrectGump(m_Patient, m_Healer));
                        }
                    }
                }
                else
                {
                    if (petPatient != null && petPatient.IsDeadPet)
                    {
                        healerNumber = 503256;                         // You fail to resurrect the creature.
                    }
                    else
                    {
                        healerNumber = 500966;                         // You are unable to resurrect your patient.
                    }
                    patientNumber = -1;
                }
            }
            else if (m_Patient.Poisoned)
            {
                m_Healer.SendLocalizedMessage(500969);                   // You finish applying the BodyCasts.

                double healing = m_Healer.Skills[primarySkill].Value;
                double anatomy = m_Healer.Skills[secondarySkill].Value;
                double chance  = ((healing - 30.0) / 50.0) - (m_Patient.Poison.Level * 0.1) - (m_Slips * 0.02);

                if ((checkSkills = (healing >= 60.0 && anatomy >= 60.0)) && chance > Utility.RandomDouble())
                {
                    if (m_Patient.CurePoison(m_Healer))
                    {
                        healerNumber  = (m_Healer == m_Patient) ? -1 : 1010058; // You have cured the target of all poisons.
                        patientNumber = 1010059;                                // You have been cured of all poisons.
                    }
                    else
                    {
                        healerNumber  = -1;
                        patientNumber = -1;
                    }
                }
                else
                {
                    healerNumber  = 1010060;                    // You have failed to cure your target!
                    patientNumber = -1;
                }
            }
            else if (BleedAttack.IsBleeding(m_Patient))
            {
                healerNumber  = -1;
                patientNumber = 1060167;                 // The bleeding wounds have healed, you are no longer bleeding!

                BleedAttack.EndBleed(m_Patient, true);
            }
            else if (MortalStrike.IsWounded(m_Patient))
            {
                healerNumber  = (m_Healer == m_Patient ? 1005000 : 1010398);
                patientNumber = -1;
                playSound     = false;
            }
            else if (m_Patient.Hits == m_Patient.HitsMax)
            {
                healerNumber  = 500967;                // You heal what little damage your patient had.
                patientNumber = -1;
            }
            else
            {
                checkSkills   = true;
                patientNumber = -1;

                double healing = m_Healer.Skills[primarySkill].Value;
                double anatomy = m_Healer.Skills[secondarySkill].Value;
                double chance  = ((healing + 10.0) / 100.0) - (m_Slips * 0.02);

                if (chance > Utility.RandomDouble())
                {
                    healerNumber = 500969;                     // You finish applying the BodyCasts.

                    double min, max;

                    if (Core.AOS)
                    {
                        min = (anatomy / 2.0) + (healing / 2.0) + 2.0;
                        max = (anatomy / 1.5) + (healing / 1.5) + 1.0;
                    }
                    else
                    {
                        min = (anatomy / 3.0) + (healing / 2.0) + 3.0;
                        max = (anatomy / 2.0) + (healing / 2.0) + 10.0;
                    }

                    double toHeal = min + (Utility.RandomDouble() * (max - min));

                    if (m_Patient.Body.IsMonster || m_Patient.Body.IsAnimal)
                    {
                        toHeal += m_Patient.HitsMax / 500;
                    }

                    if (Core.AOS)
                    {
                        toHeal -= toHeal * m_Slips * 0.35;                         // TODO: Verify algorithm
                    }
                    else
                    {
                        toHeal -= m_Slips * 4;
                    }

                    if (toHeal < 1)
                    {
                        toHeal       = 1;
                        healerNumber = 500968;                         // You apply the BodyCasts, but they barely help.
                    }

                    m_Patient.Heal((int)toHeal, false);
                }
                else
                {
                    healerNumber = 500968;                     // You apply the BodyCasts, but they barely help.
                    playSound    = false;
                }
            }

            if (healerNumber != -1)
            {
                m_Healer.SendLocalizedMessage(healerNumber);
            }

            if (patientNumber != -1)
            {
                m_Patient.SendLocalizedMessage(patientNumber);
            }

            if (playSound)
            {
                m_Patient.PlaySound(0x57);
            }

            if (checkSkills)
            {
                m_Healer.CheckSkill(secondarySkill, 0.0, 120.0);
                m_Healer.CheckSkill(primarySkill, 0.0, 120.0);
            }
        }