protected override void OnTarget( Mobile from, object target )
{
from.RevealingAction();
from.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds( 1.0 );
if ( !m_Instrument.IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1062488 ); // The instrument you are trying to play is no longer in your backpack!
}
else if ( target is Mobile )
{
Mobile targ = (Mobile)target;
if ( targ == from || (targ is BaseCreature && ( ((BaseCreature)targ).BardImmune || !from.CanBeHarmful( targ, false ) ) && ((BaseCreature)targ).ControlMaster != from) )
{
from.SendLocalizedMessage( 1049535 ); // A song of discord would have no effect on that.
}
else if ( m_Table.Contains( targ ) ) //Already discorded
{
from.SendLocalizedMessage( 1049537 );// Your target is already in discord.
}
else if ( !targ.Player )
{
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 ( !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.CheckTargetSkill( SkillName.Discordance, target, diff-25.0, diff+25.0 ) )
{
from.SendLocalizedMessage( 1049539 ); // You play the song surpressing your targets strength
m_Instrument.PlayInstrumentWell( from );
m_Instrument.ConsumeUse( from );
ArrayList mods = new ArrayList();
int effect;
double scalar;
effect = (int)( from.Skills[SkillName.Discordance].Value / -5.0 );
scalar = effect * 0.01;
mods.Add( new StatMod( StatType.Str, "DiscordanceStr", (int)(targ.RawStr * scalar), TimeSpan.Zero ) );
mods.Add( new StatMod( StatType.Int, "DiscordanceInt", (int)(targ.RawInt * scalar), TimeSpan.Zero ) );
mods.Add( new StatMod( StatType.Dex, "DiscordanceDex", (int)(targ.RawDex * scalar), TimeSpan.Zero ) );
for ( int i = 0; i < targ.Skills.Length; ++i )
{
if ( targ.Skills[i].Value > 0 )
mods.Add( new DefaultSkillMod( (SkillName)i, true, targ.Skills[i].Value * scalar ) );
}
DiscordanceInfo info = new DiscordanceInfo( from, targ, Math.Abs( effect ), mods );
info.m_Timer = Timer.DelayCall<DiscordanceInfo>( TimeSpan.Zero, TimeSpan.FromSeconds( 1.25 ), new TimerStateCallback<DiscordanceInfo>( ProcessDiscordance ), info );
m_Table[targ] = info;
}
else
{
from.SendLocalizedMessage( 1049540 );// You fail to disrupt your target
m_Instrument.PlayInstrumentBadly( from );
m_Instrument.ConsumeUse( from );
}
from.NextSkillTime = DateTime.Now + TimeSpan.FromSeconds( 12.0 );
}
else
{
m_Instrument.PlayInstrumentBadly( from );
}
}
else
{
from.SendLocalizedMessage( 1049535 ); // A song of discord would have no effect on that.
}
}
}