protected override void OnTarget(Mobile from, object target)
            {
                m_Squire.RevealingAction();
                m_Squire.NextSkillTime = Core.TickCount + 1000;

                if (!m_Instrument.IsChildOf(m_Squire.Backpack))
                {
                    if (m_Squire.m_SquireBeQuiet == false)
                    {
                        SquireDialog.DoSquireDialog(from, m_Squire, SquireDialogTree.WheredMyInstrumentGo, null, null);
                    }
                }
                else if (target is Mobile)
                {
                    Mobile targ = (Mobile)target;

                    if (targ == m_Squire || targ == from || (targ is BaseCreature && (((BaseCreature)targ).BardImmune || !m_Squire.CanBeHarmful(targ, false)) && ((BaseCreature)targ).ControlMaster != from))
                    {
                        if (m_Squire.m_SquireBeQuiet == false)
                        {
                            SquireDialog.DoSquireDialog(from, m_Squire, SquireDialogTree.CantDiscord, null, null);
                        }
                    }
                    else if (Discordance.m_Table.Contains(targ))
                    {
                        if (m_Squire.m_SquireBeQuiet == false)
                        {
                            SquireDialog.DoSquireDialog(from, m_Squire, SquireDialogTree.AlreadyDiscord, null, null);
                        }
                    }
                    else if (!targ.Player)
                    {
                        double diff = m_Instrument.GetDifficultyFor(targ) - 10.0;
                        double music = m_Squire.Skills[SkillName.Musicianship].Value;

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

                        if (!BaseInstrument.CheckMusicianship(m_Squire))
                        {
                            if (m_Squire.m_SquireBeQuiet == false)
                            {
                                SquireDialog.DoSquireDialog(from, m_Squire, SquireDialogTree.BadPerformance, null, null);
                            }
                            m_Instrument.PlayInstrumentBadly(m_Squire);
                            m_Instrument.ConsumeUse(m_Squire);
                        }
                        else if (m_Squire.CheckTargetSkill(SkillName.Discordance, target, diff - 25.0, diff + 25.0))
                        {
                            if (m_Squire.m_SquireBeQuiet == false)
                            {
                                SquireDialog.DoSquireDialog(from, m_Squire, SquireDialogTree.GoodPerformanceDiscord, null, null);
                            }
                            m_Instrument.PlayInstrumentWell(m_Squire);
                            m_Instrument.ConsumeUse(m_Squire);

                            ArrayList mods = new ArrayList();
                            int effect;
                            double scalar;

                            if (Core.AOS)
                            {
                                double discord = m_Squire.Skills[SkillName.Discordance].Value;

                                if (discord > 100.0)
                                    effect = -20 + (int)((discord - 100.0) / -2.5);
                                else
                                    effect = (int)(discord / -5.0);

                                if (Core.SE && BaseInstrument.GetBaseDifficulty(targ) >= 160.0)
                                    effect /= 2;

                                scalar = effect * 0.01;

                                mods.Add(new ResistanceMod(ResistanceType.Physical, effect));
                                mods.Add(new ResistanceMod(ResistanceType.Fire, effect));
                                mods.Add(new ResistanceMod(ResistanceType.Cold, effect));
                                mods.Add(new ResistanceMod(ResistanceType.Poison, effect));
                                mods.Add(new ResistanceMod(ResistanceType.Energy, effect));

                                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));
                                }
                            }
                            else
                            {
                                effect = (int)(m_Squire.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));
                                }
                            }

                            Discordance.DiscordanceInfo info = new Discordance.DiscordanceInfo(m_Squire, targ, Math.Abs(effect), mods);
                            info.m_Timer = Timer.DelayCall<Discordance.DiscordanceInfo>(TimeSpan.Zero, TimeSpan.FromSeconds(1.25), new TimerStateCallback<Discordance.DiscordanceInfo>(Discordance.ProcessDiscordance), info);

                            Discordance.m_Table[targ] = info;
                        }
                        else
                        {
                            if (m_Squire.m_SquireBeQuiet == false)
                            {
                                SquireDialog.DoSquireDialog(from, m_Squire, SquireDialogTree.FailedPerformanceDiscord, null, null);
                            }
                            m_Instrument.PlayInstrumentBadly(m_Squire);
                            m_Instrument.ConsumeUse(m_Squire);
                        }

                        m_Squire.NextSkillTime = Core.TickCount + 12000;
                    }
                    else
                    {
                        m_Instrument.PlayInstrumentBadly(m_Squire);
                    }
                }
                else
                {
                    if (m_Squire.m_SquireBeQuiet == false)
                    {
                        SquireDialog.DoSquireDialog(from, m_Squire, SquireDialogTree.CantDiscord, null, null);
                    }
                }
            }
Ejemplo n.º 2
0
        public void DoDiscordance()
        {
            DebugSay( "I Discord!" );

            TimeSpan len = TimeSpan.FromSeconds( this.Skills[SkillName.Discordance].Value * 2 );

            double diff = BaseInstrument.GetBaseDifficulty( Combatant ) - 10.0;
            double music = this.Skills[SkillName.Musicianship].Value;

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

            if ( this.CheckTargetSkill( SkillName.Discordance, Combatant, diff - 25.0, diff + 25.0 ) )
            {
                DebugSay( "Discord success!" );

                ArrayList mods = new ArrayList();
                int effect;
                double scalar;

                double discord = this.Skills[SkillName.Discordance].Value;

                if ( discord > 100.0 )
                    effect = -20 + (int) ( ( discord - 100.0 ) / -2.5 );
                else
                    effect = (int) ( discord / -5.0 );

                if ( BaseInstrument.GetBaseDifficulty( Combatant ) >= 160.0 )
                    effect /= 2;

                scalar = effect * 0.01;

                mods.Add( new ResistanceMod( ResistanceType.Physical, effect ) );
                mods.Add( new ResistanceMod( ResistanceType.Fire, effect ) );
                mods.Add( new ResistanceMod( ResistanceType.Cold, effect ) );
                mods.Add( new ResistanceMod( ResistanceType.Poison, effect ) );
                mods.Add( new ResistanceMod( ResistanceType.Energy, effect ) );

                for ( int i = 0; i < Combatant.Skills.Length; ++i )
                {
                    if ( Combatant.Skills[i].Value > 0 )
                        mods.Add( new DefaultSkillMod( (SkillName) i, true, Combatant.Skills[i].Value * scalar ) );
                }

                Discordance.DiscordanceInfo info = new Discordance.DiscordanceInfo( this, Combatant, len, Math.Abs( effect ), mods );
                info.m_Timer = Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromSeconds( 1.25 ), new TimerStateCallback( ProcessDiscordance ), info );

                Discordance.m_Table[Combatant] = info;

                this.PlaySound( SuccessSound );
            }
            else
            {
                DebugSay( "Discord failure :(" );
                this.PlaySound( FailureSound );
            }
        }