Пример #1
0
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();
                var entity = target as IEntity;

                if (XmlScript.HasTrigger(entity, TriggerName.onTargeted) &&
                    UberScriptTriggers.Trigger(
                        entity,
                        from,
                        TriggerName.onTargeted,
                        null,
                        null,
                        null,
                        0,
                        null,
                        SkillName.Discordance,
                        from.Skills[SkillName.Discordance].Value))
                {
                    return;
                }

                from.NextSkillTime = DateTime.UtcNow + 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)
                {
                    var targ = (Mobile)target;

                    if (targ == from ||
                        (targ is BaseCreature && (((BaseCreature)targ).BardImmune || !from.CanBeHarmful(targ, false)) &&
                         ((BaseCreature)targ).ControlMaster != null))
                    {
                        from.SendLocalizedMessage(1049535);                 // A song of discord would have no effect on that.
                    }
                    else if (m_Table.ContainsKey(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 jarring music, suppressing your target's strength.
                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);

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

                            if (m_Instrument.EraAOS)
                            {
                                double discord = from.Skills[SkillName.Discordance].Value;

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

                                if (m_Instrument.EraSE && BaseInstrument.GetBaseDifficulty(targ) >= 160.0)
                                {
                                    effect /= 2;
                                }

                                scalar = effect * 0.01;

                                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 if (m_Instrument.EraUOR)
                            {
                                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));
                                    }
                                }
                            }
                            else
                            {
                                // HACK: Convert to T2A mechanics.

                                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));
                                    }
                                }
                            }

                            if (targ.IsControlled() && targ is BaseCreature)
                            {
                                var owner = ((BaseCreature)targ).ControlMaster;
                                from.DoHarmful(targ);
                                from.DoHarmful(owner);
                            }

                            var info = new DiscordanceInfo(from, targ, Math.Abs(effect), mods);
                            info.Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1.25), 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.UtcNow + TimeSpan.FromSeconds(6.0);
                    }
                    else
                    {
                        m_Instrument.PlayInstrumentBadly(from);
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1049535);                     // A song of discord would have no effect on that.
                }
            }
Пример #2
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                IEntity entity = targeted as IEntity; if (XmlScript.HasTrigger(entity, TriggerName.onTargeted) && UberScriptTriggers.Trigger(entity, from, TriggerName.onTargeted, null, null, null, 0, null, SkillName.EvalInt, from.Skills[SkillName.EvalInt].Value))

                {
                    return;
                }

                if (from == targeted)
                {
                    from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500910);                       // Hmm, that person looks really silly.
                }
                else if (targeted is TownCrier)
                {
                    ((TownCrier)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500907, from.NetState);                       // He looks smart enough to remember the news.  Ask him about it.
                }
                else if (targeted is BaseVendor /*&& ((BaseVendor)targeted).IsInvulnerable*/)
                {
                    ((BaseVendor)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, 500909, from.NetState);                       // That person could probably calculate the cost of what you buy from them.
                }
                else if (targeted is BaseGuard)
                {
                    ((BaseGuard)targeted).PrivateOverheadMessage(MessageType.Regular, 0x3B2, false, "That person looks smart enough to find criminals and apprehend them.", from.NetState);
                }
                else if (targeted is Mobile)
                {
                    Mobile targ = (Mobile)targeted;

                    if (targ.AccessLevel > AccessLevel.Player)
                    {
                        targ.PrivateOverheadMessage(MessageType.Regular, 0x3B2, false, "That entity is more powerful than mortal minds can comprehend.", from.NetState);
                    }
                    else
                    {
                        int marginOfError = Math.Max(0, 20 - (int)(from.Skills[SkillName.EvalInt].Value / 5));

                        int intel   = targ.Int + Utility.RandomMinMax(-marginOfError, +marginOfError);
                        int curmana = targ.Mana;
                        if (targ.ManaMax == 0)                           //Mongbats
                        {
                            curmana = 1;
                        }

                        int mana = ((curmana * 100) / Math.Max(targ.ManaMax, 1)) + Utility.RandomMinMax(-marginOfError, +marginOfError);

                        int intMod = intel / 10;
                        int mnMod  = mana / 10;

                        if (intMod > 10)
                        {
                            intMod = 10;
                        }
                        else if (intMod < 0)
                        {
                            intMod = 0;
                        }

                        if (mnMod > 10)
                        {
                            mnMod = 10;
                        }
                        else if (mnMod < 0)
                        {
                            mnMod = 0;
                        }

                        int body;

                        if (targ.Body.IsHuman)
                        {
                            body = targ.Female ? 11 : 0;
                        }
                        else
                        {
                            body = 22;
                        }

                        if (from.CheckTargetSkill(SkillName.EvalInt, targ, 0.0, 120.0))
                        {
                            targ.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1038169 + intMod + body, from.NetState);                               // He/She/It looks [slighly less intelligent than a rock.]  [Of Average intellect] [etc...]

                            if (from.Skills[SkillName.EvalInt].Base >= 76.0)
                            {
                                targ.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1038202 + mnMod, from.NetState);                                   // That being is at [10,20,...] percent mental strength.
                            }
                        }
                        else
                        {
                            targ.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1038166 + (body / 11), from.NetState);                               // You cannot judge his/her/its mental abilities.
                        }
                    }
                }
                else if (targeted is Item)
                {
                    ((Item)targeted).SendLocalizedMessageTo(from, 500908, "");                       // It looks smarter than a rock, but dumber than a piece of wood.
                }
            }