Server.Items.BaseInstrument.GetDifficultyFor C# (CSharp) Method

GetDifficultyFor() public method

public GetDifficultyFor ( Mobile targ ) : double
targ Mobile
return double
		public double GetDifficultyFor( Mobile targ )
		{
			double val = GetBaseDifficulty( targ );

			if ( m_Quality == InstrumentQuality.Exceptional )
				val -= 5.0; // 10%

			if ( m_Slayer != SlayerName.None )
			{
				SlayerEntry entry = SlayerGroup.GetEntryByName( m_Slayer );

				if ( entry != null )
				{
					if ( entry.Slays( targ ) )
						val -= 10.0; // 20%
					else if ( entry.Group.OppositionSuperSlays( targ ) )
						val += 10.0; // -20%
				}
			}

			if ( m_Slayer2 != SlayerName.None )
			{
				SlayerEntry entry = SlayerGroup.GetEntryByName( m_Slayer2 );

				if ( entry != null )
				{
					if ( entry.Slays( targ ) )
						val -= 10.0; // 20%
					else if ( entry.Group.OppositionSuperSlays( targ ) )
						val += 10.0; // -20%
				}
			}

			return val;
		}

Usage Example

Ejemplo n.º 1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (!(targeted is Mobile))
                {
                    from.SendLocalizedMessage(1049528);                     // You cannot calm that!
                }
                else
                {
                    Mobile targ = (Mobile)targeted;
                    int    success = 0, fail = 0;

                    for (int ix = 0; ix < 100; ix++)
                    {
                        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))
                        {
                            fail++;
                        }
                        else
                        {
                            success++;
                        }
                    }

                    from.SendMessage(String.Format("{0} successes {1} failures", success, fail));
                }
            }