Example #1
0
        private static void ProcessDiscordance(DiscordanceInfo info)
        {
            Mobile from = info.m_From;
            Mobile targ = info.m_Target;
            bool   ends = false;

            if (info.m_PVP && info.m_Expires < DateTime.UtcNow)
            {
                DiscordanceInfo.RemoveDiscord(info);
            }
            else
            {
                // According to uoherald bard must remain alive, visible, and
                // within range of the target or the effect ends in 15 seconds.
                if (!targ.Alive || targ.Deleted || targ.IsDeadBondedPet || !from.Alive || from.Hidden || targ.Hidden || from.IsDeadBondedPet)
                {
                    ends = true;
                }
                else
                {
                    int  maxRange = BaseInstrument.GetBardRange(from, SkillName.Discordance);
                    bool inRange  = targ.InRange((IPoint3D)from, maxRange);

                    Map targetMap = targ.Map;

                    if (targ is BaseMount mount && mount.Rider != null)
                    {
                        Mobile rider = mount.Rider;

                        inRange   = rider.InRange((IPoint3D)from, maxRange);
                        targetMap = rider.Map;
                    }

                    if (from.Map != targetMap || !inRange)
                    {
                        ends = true;
                    }
                }

                if (ends && info.m_Ending && info.m_EndTime < DateTime.UtcNow)
                {
                    DiscordanceInfo.RemoveDiscord(info);
                }
                else
                {
                    if (ends && !info.m_Ending)
                    {
                        info.m_Ending  = true;
                        info.m_EndTime = DateTime.UtcNow + TimeSpan.FromSeconds(15);
                    }
                    else if (!ends)
                    {
                        info.m_Ending  = false;
                        info.m_EndTime = DateTime.UtcNow;
                    }

                    targ.FixedEffect(0x376A, 1, 32);
                }
            }
        }
Example #2
0
        private static void ProcessDiscordance(DiscordanceInfo info)
        {
            Mobile from = info.m_From;
            Mobile targ = info.m_Creature;
            bool   ends = false;

            // According to uoherald bard must remain alive, visible, and
            // within range of the target or the effect ends in 15 seconds.
            if (!targ.Alive || targ.Deleted || !from.Alive || from.Hidden)
            {
                ends = true;
            }
            else
            {
                int range     = (int)targ.GetDistanceToSqrt(from);
                int maxRange  = BaseInstrument.GetBardRange(from, SkillName.Discordance);
                Map targetMap = targ.Map;

                if (targ is BaseMount && ((BaseMount)targ).Rider != null)
                {
                    Mobile rider = ((BaseMount)targ).Rider;

                    range     = (int)rider.GetDistanceToSqrt(from);
                    targetMap = rider.Map;
                }

                if (from.Map != targetMap || range > maxRange)
                {
                    ends = true;
                }
            }

            if (ends && info.m_Ending && info.m_EndTime < DateTime.UtcNow)
            {
                if (info.m_Timer != null)
                {
                    info.m_Timer.Stop();
                }

                info.Clear();
                m_Table.Remove(targ);
            }
            else
            {
                if (ends && !info.m_Ending)
                {
                    info.m_Ending  = true;
                    info.m_EndTime = DateTime.UtcNow + TimeSpan.FromSeconds(15);
                }
                else if (!ends)
                {
                    info.m_Ending  = false;
                    info.m_EndTime = DateTime.UtcNow;
                }

                targ.FixedEffect(0x376A, 1, 32);
            }
        }
Example #3
0
        public static bool GetEffect(Mobile targ, ref int effect, bool pvp)
        {
            if (!m_Table.ContainsKey(targ) || m_Table[targ].m_PVP != pvp)
            {
                return(false);
            }

            DiscordanceInfo info = m_Table[targ];

            effect = info.m_Effect;
            return(true);
        }
        public static bool GetScalar(Mobile targ, ref double scalar)
        {
            DiscordanceInfo info = m_Table[targ] as DiscordanceInfo;

            if (info == null)
            {
                return(false);
            }

            scalar = info.m_Scalar;
            return(true);
        }
Example #5
0
        public static bool GetEffect(Mobile targ, ref int effect)
        {
            DiscordanceInfo info = m_Table[targ] as DiscordanceInfo;

            if (info == null)
            {
                return(false);
            }

            effect = info.m_Effect;
            return(true);
        }
Example #6
0
            public static void RemoveDiscord(DiscordanceInfo info)
            {
                if (info.m_Timer != null)
                {
                    info.m_Timer.Stop();
                }

                var targ = info.m_Target;

                info.Clear();

                Discordance.RemoveEffects(targ);
            }
Example #7
0
		private static void ProcessDiscordance(DiscordanceInfo info)
		{
			Mobile from = info.m_From;
			Mobile targ = info.m_Creature;
			bool ends = false;

			// According to uoherald bard must remain alive, visible, and 
			// within range of the target or the effect ends in 15 seconds.
			if (!targ.Alive || targ.Deleted || !from.Alive || from.Hidden)
			{
				ends = true;
			}
			else
			{
				int range = (int)targ.GetDistanceToSqrt(from);
				int maxRange = BaseInstrument.GetBardRange(from, SkillName.Discordance);

				if (from.Map != targ.Map || range > maxRange)
				{
					ends = true;
				}
			}

			if (ends && info.m_Ending && info.m_EndTime < DateTime.UtcNow)
			{
				if (info.m_Timer != null)
				{
					info.m_Timer.Stop();
				}

				info.Clear();
				m_Table.Remove(targ);
			}
			else
			{
				if (ends && !info.m_Ending)
				{
					info.m_Ending = true;
					info.m_EndTime = DateTime.UtcNow + TimeSpan.FromSeconds(15);
				}
				else if (!ends)
				{
					info.m_Ending = false;
					info.m_EndTime = DateTime.UtcNow;
				}

				targ.FixedEffect(0x376A, 1, 32);
			}
		}
Example #8
0
        private static void ProcessDiscordance(object state)
        {
            DiscordanceInfo info = (DiscordanceInfo)state;
            Mobile          from = info.m_From;
            Mobile          targ = info.m_Creature;

            if (DateTime.Now >= info.m_EndTime || targ.Deleted || from.Map != targ.Map || targ.GetDistanceToSqrt(from) > 16)
            {
                info.Clear();
                m_Table.Remove(targ);
            }
            else
            {
                targ.FixedEffect(0x376A, 1, 32);
            }
        }
        public static void InsertDiscordanceInfo(Mobile target, DiscordanceInfo info)
        {
            if (m_Table.Contains(target))
            {
                var targetInfo = m_Table[target] as DiscordanceInfo;

                if (targetInfo != null)
                {
                    targetInfo.m_EndTime = DateTime.UtcNow + targetInfo.m_Duration;
                }

                info.m_Timer.Stop();
            }

            else
            {
                m_Table[target] = info;
            }
        }
        public static void ProcessDiscordance(DiscordanceInfo info)
        {
            Mobile from = info.m_From;
            Mobile targ = info.m_Creature;

            bool ends = false;

            if (!targ.Alive || targ.Deleted || !from.Alive || from.Hidden)
            {
                ends = true;
            }

            else
            {
                int range    = (int)targ.GetDistanceToSqrt(from);
                int maxRange = 24;

                if (from.Map != targ.Map || range > maxRange)
                {
                    ends = true;
                }
            }

            if (ends || info.m_Ending || info.m_EndTime < DateTime.UtcNow)
            {
                if (info.m_Timer != null)
                {
                    info.m_Timer.Stop();
                }

                m_Table.Remove(targ);
            }

            else
            {
                targ.FixedEffect(0x376A, 1, 32);
            }
        }
Example #11
0
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();
                from.NextSkillTime = Core.TickCount + 1000;

                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 || !from.CanBeHarmful(targ, false) ||
                        (targ is BaseCreature && ((BaseCreature)targ).BardImmune && ((BaseCreature)targ).ControlMaster != from))
                    {
                        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 || (from is BaseCreature && ((BaseCreature)from).CanDiscord) || (targ.Player && from.Player && CanDiscordPVP(from)))
                    {
                        double diff  = m_Instrument.GetDifficultyFor(targ) - 10.0;
                        double music = from.Skills[SkillName.Musicianship].Value;

                        if (from is BaseCreature)
                        {
                            music = 120.0;
                        }

                        int masteryBonus = 0;

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

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

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

                        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

                            if (targ.Player)
                            {
                                targ.SendLocalizedMessage(1072061); // You hear jarring music, suppressing your strength.
                            }
                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);

                            DiscordanceInfo info;

                            if (targ.Player && from.Player)
                            {
                                info = new DiscordanceInfo(from, targ, 0, null, true, from.Skills.CurrentMastery == SkillName.Discordance ? 6 : 4);
                                from.DoHarmful(targ);
                            }
                            else
                            {
                                ArrayList mods = new ArrayList();
                                int       effect;
                                double    scalar;

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

                                effect = (int)Math.Max(-28.0, (discord / -4.0));

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

                                scalar = (double)effect / 100;

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

                                info = new DiscordanceInfo(from, targ, Math.Abs(effect), mods);

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

                                    if (quest != null)
                                    {
                                        foreach (BaseObjective objective in quest.Objectives)
                                        {
                                            objective.Update(targ);
                                        }
                                    }
                                }
                                #endregion
                            }

                            info.m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1.25), ProcessDiscordance, info);

                            m_Table[targ]      = info;
                            from.NextSkillTime = Core.TickCount + (8000 - ((masteryBonus / 5) * 1000));
                        }
                        else
                        {
                            if (from is BaseCreature && PetTrainingHelper.Enabled)
                            {
                                from.CheckSkill(SkillName.Discordance, 0, from.Skills[SkillName.Discordance].Cap);
                            }

                            from.SendLocalizedMessage(1049540);                             // You attempt to disrupt your target, but fail.

                            if (targ.Player)
                            {
                                targ.SendLocalizedMessage(1072064); // You hear jarring music, but it fails to disrupt you.
                            }
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + 5000;
                        }
                    }
                    else
                    {
                        m_Instrument.PlayInstrumentBadly(from);
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1049535);                     // A song of discord would have no effect on that.
                }
            }
Example #12
0
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();
                from.NextSkillTime = Core.TickCount + 1000;

                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 || (from is BaseCreature) && ((BaseCreature)from).CanDiscord)
                    {
                        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 (!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;

                            if (Core.AOS)
                            {
                                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 (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)(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(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 = Core.TickCount + 12000;
                    }
                    else
                    {
                        m_Instrument.PlayInstrumentBadly(from);
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1049535);                     // A song of discord would have no effect on that.
                }
            }
Example #13
0
            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 || [email protected](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.
                }
            }
Example #14
0
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();

                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 BaseCreature)
                {
                    BaseCreature bc_Target = target as BaseCreature;

                    if (from.CanBeHarmful(bc_Target, true))
                    {
                        if (bc_Target.NextBardingEffectAllowed > DateTime.UtcNow)
                        {
                            string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, bc_Target.NextBardingEffectAllowed, false, true, true, true, true);

                            from.SendMessage("That target is not vulnerable to barding attempts for another " + timeRemaining + ".");
                            return;
                        }

                        if (!BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendMessage("You struggle with basic musicianship and your song has no effect.");
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + (int)(SkillCooldown.DiscordanceFailureCooldown * 1000);

                            return;
                        }

                        double creatureDifficulty = bc_Target.InitialDifficulty;
                        double effectiveBardSkill = from.Skills[SkillName.Discordance].Value + BaseInstrument.GetBardBonusSkill(from, bc_Target, m_Instrument);

                        double   successChance  = BaseInstrument.GetBardSuccessChance(effectiveBardSkill, creatureDifficulty);
                        TimeSpan effectDuration = BaseInstrument.GetBardDuration(bc_Target, creatureDifficulty);

                        if (BaseInstrument.CheckSkillGain(successChance))
                        {
                            from.CheckSkill(SkillName.Discordance, 0.0, 120.0, 1.0);
                        }

                        if (from.AccessLevel > AccessLevel.Player)
                        {
                            from.SendMessage("Chance of success was: " + Math.Round(successChance * 100, 3).ToString() + "%");
                        }

                        if (Utility.RandomDouble() <= successChance)
                        {
                            from.DoHarmful(bc_Target, true);

                            from.SendMessage("You play successfully, disrupting your opponent's skills and weakening them significantly.");
                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);

                            double discordanceModifier = BaseInstrument.DiscordanceModifier;

                            DungeonArmor.PlayerDungeonArmorProfile bardDungeonArmor = new DungeonArmor.PlayerDungeonArmorProfile(from, null);

                            if (bardDungeonArmor.MatchingSet && !bardDungeonArmor.InPlayerCombat)
                            {
                                discordanceModifier += bardDungeonArmor.DungeonArmorDetail.DiscordanceEffectBonus;
                            }

                            DiscordanceInfo info = new DiscordanceInfo(from, bc_Target, discordanceModifier);

                            //TEST
                            from.Say("Discord Duration: " + effectDuration.ToString());

                            info.m_Duration = effectDuration;
                            info.m_EndTime  = DateTime.UtcNow + effectDuration;
                            info.m_Timer    = Timer.DelayCall <DiscordanceInfo>(TimeSpan.Zero, TimeSpan.FromSeconds(1), new TimerStateCallback <DiscordanceInfo>(ProcessDiscordance), info);

                            Discordance.InsertDiscordanceInfo(bc_Target, info);

                            from.NextSkillTime = Core.TickCount + (int)(SkillCooldown.DiscordanceSuccessCooldown * 1000);

                            bc_Target.NextBardingEffectAllowed = DateTime.UtcNow + bc_Target.BardingEffectCooldown;
                        }

                        else
                        {
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + (int)(SkillCooldown.DiscordanceFailureCooldown * 1000);

                            string failureMessage = BaseInstrument.GetFailureMessage(successChance, SkillName.Discordance);

                            from.SendMessage(failureMessage);
                        }
                    }

                    else
                    {
                        return;
                    }
                }

                else
                {
                    from.SendLocalizedMessage(1049535); // A song of discord would have no effect on that.
                }
            }
Example #15
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.
				}
			}
Example #16
0
                protected override void OnTick()
                {
                    m_Count++;

                    DamageEntry de           = m_Creature.FindMostRecentDamageEntry(false);
                    bool        alreadyOwned = m_Creature.Owners.Contains(m_Tamer);

                    if (!m_Tamer.InRange(m_Creature, m_Creature.EraAOS ? 7 : 6))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502795, m_Tamer.NetState);
                        // You are too far away to continue taming.
                        Stop();
                    }
                    else if (!m_Tamer.CheckAlive())
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502796, m_Tamer.NetState);
                        // You are dead, and cannot continue taming.
                        Stop();
                    }
                    else if (!m_Tamer.CanSee(m_Creature) || !m_Tamer.InLOS(m_Creature) || !CanPath())
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Tamer.SendLocalizedMessage(1049654);
                        // You do not have a clear path to the animal you are taming, and must cease your attempt.
                        Stop();
                    }
                    else if (!m_Creature.Tamable)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1049655, m_Tamer.NetState);
                        // That creature cannot be tamed.
                        Stop();
                    }
                    else if (m_Creature.Controlled)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502804, m_Tamer.NetState);
                        // That animal looks tame already.
                        Stop();
                    }
                    else if (m_Creature.Owners.Count >= BaseCreature.MaxOwners && !m_Creature.Owners.Contains(m_Tamer))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1005615, m_Tamer.NetState);
                        // This animal has had too many owners and is too upset for you to tame.
                        Stop();
                    }
                    else if (MustBeSubdued(m_Creature))
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1054025, m_Tamer.NetState);
                        // You must subdue this creature before you can tame it!
                        Stop();
                    }
                    else if (de != null && de.LastDamage > m_StartTime)
                    {
                        m_BeingTamed.Remove(m_Creature);
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502794, m_Tamer.NetState);
                        // The animal is too angry to continue taming.
                        Stop();
                    }
                    else if (m_Count < m_MaxCount)
                    {
                        m_Tamer.RevealingAction();

                        switch (Utility.Random(3))
                        {
                        case 0:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(502790, 4));
                            break;

                        case 1:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1005608, 6));
                            break;

                        case 2:
                            m_Tamer.PublicOverheadMessage(MessageType.Regular, 0x3B2, Utility.Random(1010593, 4));
                            break;
                        }

                        if (!alreadyOwned)                         // Passively check animal lore for gain
                        {
                            m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0);
                        }

                        if (m_Creature.Paralyzed)
                        {
                            m_Paralyzed = true;
                        }
                    }
                    else
                    {
                        Skill tskill = m_Tamer.Skills[SkillName.AnimalLore];
                        Conquests.CheckProgress <SkillConquest>(m_Tamer as PlayerMobile, tskill);

                        tskill = m_Tamer.Skills[SkillName.AnimalTaming];
                        Conquests.CheckProgress <SkillConquest>(m_Tamer as PlayerMobile, tskill);

                        m_Tamer.RevealingAction();
                        m_Tamer.NextSkillTime = DateTime.UtcNow;
                        m_BeingTamed.Remove(m_Creature);

                        if (m_Creature.Paralyzed)
                        {
                            m_Paralyzed = true;
                        }

                        if (!alreadyOwned)                         // Passively check animal lore for gain
                        {
                            m_Tamer.CheckTargetSkill(SkillName.AnimalLore, m_Creature, 0.0, 120.0);
                        }

                        double minSkill = m_Creature.MinTameSkill + (m_Creature.Owners.Count * 6.0);

                        if (minSkill > -24.9 && CheckMastery(m_Tamer, m_Creature))
                        {
                            minSkill = -24.9;                             // 50% at 0.0?
                        }

                        minSkill += 24.9;

                        if (CheckMastery(m_Tamer, m_Creature) || alreadyOwned ||
                            m_Tamer.CheckTargetSkill(SkillName.AnimalTaming, m_Creature, minSkill - 25.0, minSkill + 25.0))
                        {
                            if (m_Creature.Owners.Count == 0)                             // First tame
                            {
                                if (m_Creature is GreaterDragon)
                                {
                                    ScaleSkills(m_Creature, 0.72, 0.90);                                     // 72% of original skills trainable to 90%
                                    m_Creature.Skills[SkillName.Magery].Base = m_Creature.Skills[SkillName.Magery].Cap;
                                    // Greater dragons have a 90% cap reduction and 90% skill reduction on magery
                                }
                                else if (m_Paralyzed)
                                {
                                    ScaleSkills(m_Creature, 0.86);                                     // 86% of original skills if they were paralyzed during the taming
                                }
                                else
                                {
                                    ScaleSkills(m_Creature, 0.90);                                     // 90% of original skills
                                }

                                if (m_Creature.StatLossAfterTame)
                                {
                                    ScaleStats(m_Creature, 0.50);
                                }
                            }

                            if (alreadyOwned)
                            {
                                m_Tamer.SendLocalizedMessage(502797);                                 // That wasn't even challenging.
                            }
                            else
                            {
                                m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502799, m_Tamer.NetState);
                                // It seems to accept you as master.
                                m_Creature.Owners.Add(m_Tamer);
                            }

                            m_Creature.SetControlMaster(m_Tamer);
                            m_Creature.IsBonded  = false;
                            m_Creature.Combatant = null;
                            m_Creature.Warmode   = false;

                            if (!alreadyOwned)
                            {
                                Conquests.CheckProgress <CreatureTamingConquest>(m_Tamer as PlayerMobile, m_Creature);
                            }

                            Conquests.CheckProgress <ObtainConquest>(m_Tamer as PlayerMobile, m_Creature);

                            m_Creature.ControlOrder  = OrderType.Follow;
                            m_Creature.ControlTarget = m_Tamer;

                            DiscordanceInfo info = Discordance.GetDiscord(m_Creature);
                            if (info != null && info.From == m_Tamer)
                            {
                                info.Ending  = true;
                                info.EndTime = DateTime.UtcNow + TimeSpan.FromSeconds(15);
                            }
                        }
                        else
                        {
                            m_Creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502798, m_Tamer.NetState);
                            // You fail to tame the creature.
                        }
                    }
                }
Example #17
0
            protected override void OnTarget( Mobile from, object target )
            {
                from.RevealingAction();

                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 BaseVendor || ( targ is BaseCreature && ( ( (BaseCreature) targ ).BardImmune || !from.CanBeHarmful( targ, false ) ) ) )
                    {
                        from.SendLocalizedMessage( 1049535 ); // A song of discord would have no effect on that.
                    }
                    else if ( !targ.IsPlayer )
                    {
                        from.NextSkillTime = DateTime.Now + BaseInstrument.GetBardSkillTimeout( SkillName.Discordance, from );

                        TimeSpan len = TimeSpan.FromSeconds( from.Skills[SkillName.Discordance].Value * 2 );
                        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 ( m_Table.Contains( targ ) )
                        {
                            from.SendLocalizedMessage( 1049537 ); // Your target is already in discord.
                            from.NextSkillTime = DateTime.Now;
                        }
                        else if ( BaseInstrument.CheckBardSkillChance( from, SkillName.Discordance, target, diff - 25.0, diff + 25.0 ) )
                        {
                            if ( !m_Table.Contains( targ ) )
                            {
                                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 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 ( BaseInstrument.GetBaseDifficulty( targ ) >= 160.0 )
                                    effect /= 2;

                                if ( AltarPeerless.IsPeerlessBoss( targ ) )
                                {
                                    from.SendLocalizedMessage( 1075212 ); // Your target shrugs off some of the effects of your song.
                                    effect /= 10;
                                }

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

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

                                m_Table[targ] = info;

                                PlayerMobile pm = from as PlayerMobile;

                                if ( pm != null )
                                    QuestHelper.OnDiscorded( pm, targ );
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage( 1049540 ); // You fail to disrupt your target
                            m_Instrument.PlayInstrumentBadly( from );
                            m_Instrument.ConsumeUse( from );
                        }
                    }
                    else
                    {
                        m_Instrument.PlayInstrumentBadly( from );
                    }
                }
                else
                {
                    from.SendLocalizedMessage( 1049535 ); // A song of discord would have no effect on that.
                }
            }
        public static DiscordanceInfo GetInfo(Mobile target)
        {
            DiscordanceInfo info = m_Table[target] as DiscordanceInfo;

            return(info);
        }
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();

                if (target is Mobile)
                {
                    Mobile targ = (Mobile)target;

                    //Pixie - 11/10/04 - added this so discordance is an aggressive action.
                    from.DoHarmful(targ);

                    if (targ is BaseCreature && ((BaseCreature)targ).BardImmune)
                    {
                        from.SendLocalizedMessage(1049535);                         // A song of discord would have no effect on that.
                    }
                    else if (!targ.Player)
                    {
                        TimeSpan len   = TimeSpan.FromSeconds(from.Skills[SkillName.Discordance].Value * 2);
                        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))
                        {
                            if (!m_Table.Contains(targ))
                            {
                                from.SendLocalizedMessage(1049539);                                 // You play the song surpressing your targets strength
                                m_Instrument.PlayInstrumentWell(from);
                                m_Instrument.ConsumeUse(from);

                                ArrayList mods = new ArrayList();
                                double    scalar;

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

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

                                    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
                                {
                                    scalar = (from.Skills[SkillName.Discordance].Value / -5.0) / 100.0;

                                    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, len, scalar, mods);
                                info.m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1.25), new TimerStateCallback(ProcessDiscordance), info);

                                m_Table[targ] = info;
                            }
                            else
                            {
                                from.SendLocalizedMessage(1049537);                                // Your target is already in discord.
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage(1049540);                            // You fail to disrupt your target
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                    }
                    else
                    {
                        m_Instrument.PlayInstrumentBadly(from);
                    }
                }
            }
Example #20
0
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();

                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 BaseVendor || (targ is BaseCreature && (((BaseCreature)targ).BardImmune || !from.CanBeHarmful(targ, false))))
                    {
                        from.SendLocalizedMessage(1049535);                           // A song of discord would have no effect on that.
                    }
                    else if (!targ.IsPlayer)
                    {
                        from.NextSkillTime = DateTime.Now + BaseInstrument.GetBardSkillTimeout(SkillName.Discordance, from);

                        TimeSpan len   = TimeSpan.FromSeconds(from.Skills[SkillName.Discordance].Value * 2);
                        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 (m_Table.Contains(targ))
                        {
                            from.SendLocalizedMessage(1049537);                               // Your target is already in discord.
                            from.NextSkillTime = DateTime.Now;
                        }
                        else if (BaseInstrument.CheckBardSkillChance(from, SkillName.Discordance, target, diff - 25.0, diff + 25.0))
                        {
                            if (!m_Table.Contains(targ))
                            {
                                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 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 (BaseInstrument.GetBaseDifficulty(targ) >= 160.0)
                                {
                                    effect /= 2;
                                }

                                if (AltarPeerless.IsPeerlessBoss(targ))
                                {
                                    from.SendLocalizedMessage(1075212);                                       // Your target shrugs off some of the effects of your song.
                                    effect /= 10;
                                }

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

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

                                m_Table[targ] = info;

                                PlayerMobile pm = from as PlayerMobile;

                                if (pm != null)
                                {
                                    QuestHelper.OnDiscorded(pm, targ);
                                }
                            }
                        }
                        else
                        {
                            from.SendLocalizedMessage(1049540);                               // You fail to disrupt your target
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                    }
                    else
                    {
                        m_Instrument.PlayInstrumentBadly(from);
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1049535);                       // A song of discord would have no effect on that.
                }
            }
            protected override void OnTarget(Mobile from, object target)
            {
                from.RevealingAction();

                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 BaseCreature)
                {
                    BaseCreature bc_Target = target as BaseCreature;

                    if (from.CanBeHarmful(bc_Target, true))
                    {
                        if (bc_Target.NextBardingEffectAllowed > DateTime.UtcNow)
                        {
                            string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, bc_Target.NextBardingEffectAllowed, false, true, true, true, true);

                            from.SendMessage("That target is not vulnerable to barding attempts for another " + timeRemaining + ".");
                            return;
                        }

                        if (!BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendMessage("You struggle with basic musicianship and your song has no effect.");
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + (int)(SkillCooldown.DiscordanceFailureCooldown * 1000);

                            return;
                        }

                        double creatureDifficulty = bc_Target.InitialDifficulty;
                        double effectiveBardSkill = from.Skills[SkillName.Discordance].Value + BaseInstrument.GetBardBonusSkill(from, bc_Target, m_Instrument);

                        AspectArmorProfile aspectArmorProfile = AspectGear.GetAspectArmorProfile(from);

                        if (aspectArmorProfile != null)
                        {
                            if (aspectArmorProfile.m_Aspect == AspectEnum.Lyric)
                            {
                                effectiveBardSkill += AspectGear.LyricEffectiveBardingSkillBonus * (AspectGear.LyricEffectiveBardingSkillBonusPerTier * (double)aspectArmorProfile.m_TierLevel);
                            }
                        }

                        double successChance = BaseInstrument.GetBardSuccessChance(effectiveBardSkill, creatureDifficulty);

                        TimeSpan effectDuration = BaseInstrument.GetBardDuration(bc_Target, creatureDifficulty);

                        if (BaseInstrument.CheckSkillGain(successChance))
                        {
                            from.CheckSkill(SkillName.Discordance, 0.0, 120.0, 1.0);
                        }

                        if (from.AccessLevel > AccessLevel.Player)
                        {
                            from.SendMessage("Chance of success was: " + Math.Round(successChance * 100, 3).ToString() + "%");
                        }

                        if (Utility.RandomDouble() <= successChance)
                        {
                            from.DoHarmful(bc_Target, true);

                            from.SendMessage("You play successfully, disrupting your opponent's skills and weakening them significantly.");
                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);

                            double discordanceModifier = BaseInstrument.DiscordanceModifier;

                            DiscordanceInfo info = new DiscordanceInfo(from, bc_Target, discordanceModifier);

                            info.m_Duration = effectDuration;
                            info.m_EndTime  = DateTime.UtcNow + effectDuration;
                            info.m_Timer    = Timer.DelayCall <DiscordanceInfo>(TimeSpan.Zero, TimeSpan.FromSeconds(1), new TimerStateCallback <DiscordanceInfo>(ProcessDiscordance), info);

                            Discordance.InsertDiscordanceInfo(bc_Target, info);

                            from.NextSkillTime = Core.TickCount + (int)(SkillCooldown.DiscordanceSuccessCooldown * 1000);

                            bc_Target.NextBardingEffectAllowed = DateTime.UtcNow + bc_Target.BardingEffectCooldown;
                        }

                        else
                        {
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + (int)(SkillCooldown.DiscordanceFailureCooldown * 1000);

                            string failureMessage = BaseInstrument.GetFailureMessage(successChance, SkillName.Discordance);

                            from.SendMessage(failureMessage);

                            if (aspectArmorProfile != null && from is PlayerMobile)
                            {
                                if (aspectArmorProfile.m_Aspect == AspectEnum.Lyric)
                                {
                                    double failedBardingAttemptDamageReduction = AspectGear.LyricDamageReceivedReductionFromFailedBardingTarget * (AspectGear.LyricDamageReceivedReductionFromFailedBardingTargetPerTier * (double)aspectArmorProfile.m_TierLevel);

                                    failedBardingAttemptDamageReduction *= (from.Skills.Discordance.Value / 120);

                                    PlayerMobile player = from as PlayerMobile;

                                    player.m_LyricAspectFailedBardingAttemptExpiration = DateTime.UtcNow + AspectGear.LyricDamageReceivedReductionFromFailedBardingDuration;

                                    player.m_LyricAspectFailedBardingAttemptTargets.Clear();
                                    player.m_LyricAspectFailedBardingAttemptTargets.Add(bc_Target);
                                    player.m_LyricAspectFailedBardingAttemptDamageReduction = failedBardingAttemptDamageReduction;
                                }
                            }
                        }
                    }

                    else
                    {
                        return;
                    }
                }

                else
                {
                    from.SendLocalizedMessage(1049535); // A song of discord would have no effect on that.
                }
            }
Example #22
0
			protected override void OnTarget( Mobile from, object target )
			{
				from.RevealingAction();

				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 ) )) )
					{
						from.SendLocalizedMessage( 1049535 ); // A song of discord would have no effect on that.
					}
					else if ( !targ.Player )
					{
						TimeSpan len = TimeSpan.FromSeconds( from.Skills[SkillName.Discordance].Value * 2 );
						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 ) )
						{
							if ( !m_Table.Contains( targ ) )
							{
								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;

								if ( Core.AOS )
								{
									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 ( 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)( 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, len, Math.Abs( effect ), mods );
								info.m_Timer = Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromSeconds( 1.25 ), new TimerStateCallback( ProcessDiscordance ), info );

								m_Table[targ] = info;
							}
							else
							{
								from.SendLocalizedMessage( 1049537 );// Your target is already in discord.
							}
						}
						else
						{
							from.SendLocalizedMessage( 1049540 );// You fail to disrupt your target
							m_Instrument.PlayInstrumentBadly( from );
							m_Instrument.ConsumeUse( from );
						}
					}
					else
					{
						m_Instrument.PlayInstrumentBadly( from );
					}
				}
				else
				{
					from.SendLocalizedMessage( 1049535 ); // A song of discord would have no effect on that.
				}
			}
Example #23
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.
                }
            }