Пример #1
0
        /// <summary>
        /// Get quest instance from quest.
        /// </summary>
        /// <param name="q">The quest.</param>
        /// <returns>Quest instance.</returns>
        public static QuestInstance GetQuestInstance(Quest q)
        {
            QuestInstance ObjInstance = new QuestInstance()
            {
                Id           = q.Id,
                Status       = "assigned",
                Scale        = q.Questbasescale,
                Timer        = q.Timer,
                Giveregion   = q.GiveRegion,
                Returnregion = q.ReturnRegion,
                Active       = ((q.Questtype == QuestTypes.CapitolCity) || (q.Questtype == QuestTypes.Global)) ? "true" : "false",
                Objective    = new ModelQuestinstanceObjective()
                {
                    Id = q.Objectives.Id, Type = "And", MustFailAll = q.Objectives.Mustfailall, Objective = QuestHelper.ConvertQuestObjectiveValues(q.Objectives.Values)
                },
                Secondaryobjectives = QuestHelper.ConvertQuestSecondaryobjectivesValues(q)
            };

            return(ObjInstance);
        }
Пример #2
0
        public BehaviorQuestPickup(uint questId, WoWPoint loc, int npcEntryId, bool completeQuest = false, int rewardIndex = -1)
            : base(loc, npcEntryId)
        {
            QuestID        = questId;
            _completeQuest = completeQuest;
            _rewardIndex   = rewardIndex;

            if (!completeQuest)
            {
                RunCondition += () => _questActionFinished || !QuestHelper.QuestLogFull && !QuestHelper.QuestContainedInQuestLog(QuestID);
            }

            Criteria += (() => (_completeQuest ||
                                (!_questActionFinished && !QuestHelper.QuestLogFull && !QuestHelper.QuestContainedInQuestLog(QuestID))));
        }
Пример #3
0
        public static void Gain(Mobile from, Skill skill, int toGain)
        {
            if (from.Region.IsPartOf <Jail>())
            {
                return;
            }

            if (from is BaseCreature && ((BaseCreature)from).IsDeadPet)
            {
                return;
            }

            if (skill.SkillName == SkillName.Focus && from is BaseCreature && !((BaseCreature)from).Controlled)
            {
                return;
            }

            if (skill.Base < skill.Cap && skill.Lock == SkillLock.Up)
            {
                Skills skills = from.Skills;

                if (from is PlayerMobile && Siege.SiegeShard)
                {
                    int minsPerGain = Siege.MinutesPerGain(from, skill);

                    if (minsPerGain > 0)
                    {
                        if (Siege.CheckSkillGain((PlayerMobile)from, minsPerGain, skill))
                        {
                            CheckReduceSkill(skills, toGain, skill);

                            if (skills.Total + toGain <= skills.Cap)
                            {
                                skill.BaseFixedPoint += toGain;
                            }
                        }

                        return;
                    }
                }

                if (toGain == 1 && skill.Base <= 10.0)
                {
                    toGain = Utility.Random(4) + 1;
                }

                #region Mondain's Legacy
                if (from is PlayerMobile && QuestHelper.EnhancedSkill((PlayerMobile)from, skill))
                {
                    toGain *= Utility.RandomMinMax(2, 4);
                }
                #endregion

                #region Scroll of Alacrity
                if (from is PlayerMobile && skill.SkillName == ((PlayerMobile)from).AcceleratedSkill &&
                    ((PlayerMobile)from).AcceleratedStart > DateTime.UtcNow)
                {
                    // You are infused with intense energy. You are under the effects of an accelerated skillgain scroll.
                    ((PlayerMobile)from).SendLocalizedMessage(1077956);

                    toGain = Utility.RandomMinMax(2, 5);
                }
                #endregion

                #region Skill Masteries
                else if (from is BaseCreature && !(from is Engines.Despise.DespiseCreature) && (((BaseCreature)from).Controlled || ((BaseCreature)from).Summoned))
                {
                    Mobile master = ((BaseCreature)from).GetMaster();

                    if (master != null)
                    {
                        WhisperingSpell spell = SkillMasterySpell.GetSpell(master, typeof(WhisperingSpell)) as WhisperingSpell;

                        if (spell != null && master.InRange(from.Location, spell.PartyRange) && master.Map == from.Map &&
                            spell.EnhancedGainChance >= Utility.Random(100))
                        {
                            toGain = Utility.RandomMinMax(2, 5);
                        }
                    }
                }
                #endregion

                if (from is PlayerMobile)
                {
                    CheckReduceSkill(skills, toGain, skill);
                }

                if (!from.Player || (skills.Total + toGain <= skills.Cap))
                {
                    skill.BaseFixedPoint = Math.Min(skill.CapFixedPoint, skill.BaseFixedPoint + toGain);

                    EventSink.InvokeSkillGain(new SkillGainEventArgs(from, skill, toGain));

                    if (from is PlayerMobile)
                    {
                        UpdateGGS(from, skill);
                    }
                }
            }

            if (from is PlayerMobile)
            {
                QuestHelper.CheckSkill((PlayerMobile)from, skill);
            }

            if (skill.Lock == SkillLock.Up && (!Siege.SiegeShard || !(from is PlayerMobile) || Siege.CanGainStat((PlayerMobile)from)))
            {
                TryStatGain(skill.Info, from);
            }
        }
Пример #4
0
        protected override void DoExecute(WowPlayer player)
        {
            try
            {
                if (q.State == _start_state)
                {
                    obj = QuestHelper.FindQuestGameObj(req, q, lfs);
                }
                else if (q.State == _end_state)
                {
                    Finish(player);
                }
                else
                {
                    switch (q.State)
                    {
                    case QuestStates.OBJ_FOUND:
                        Vector3D dest = NpcHelper.GetGameObjCoord(obj, lfs);

                        // Switch to Travel State
                        string msg = "Moving to quest " +
                                     req.NpcDestText + " " + obj.Name;
                        Log(lfs, msg + " ...");
                        NavigationState ns = new NavigationState(dest, lfs, msg);

                        ns.Finished += SetQuestStateReached;
                        CallChangeStateEvent(player, ns, true, false);

                        q.State = QuestStates.MOVING_TO_OBJ;
                        break;

                    case QuestStates.MOVING_TO_OBJ:
                        // Do nothing
                        break;

                    // Keep it for now but works for NPC only
                    case QuestStates.OBJ_REACHED:
                        // Target game object
                        NpcHelper.TargetGameObj(obj, lfs);
                        q.State = QuestStates.OBJ_TARGETED;
                        break;

                    case QuestStates.OBJ_TARGETED:
                        QuestHelper.SelectGameObjQuest(req, obj, q, lfs);
                        break;

                    case QuestStates.SELECTED:
                        QuestHelper.DoActionEx(req, q, lfs);
                        break;

                    default:
                        throw new QuestSkipException("Unknown quest state: " +
                                                     Enum.GetName(typeof(QuestStates), q.State));
                    }
                }
            }
            catch // For now skip quest on any exception
            {
                SkipQuest(player);
            }
        }
Пример #5
0
        public void Run()
        {
            //L.b.gameOptions["fog"].SetValue("false");
            //add player
            int    pid = S.Players().CreatePlayer(System.Environment.UserName, "forger");
            Player p   = S.Player(pid);

            p.elements.elements.Add("shadow");

            //and unit
            S.Unit().Create(pid, "shadow", new NVector(14, 10, 0));

            //win
            Quest q = QuestHelper.Win();

            q.desc = TextHelper.RichText("To win this tutorial, you need to develop the earth element. Follow the other quests.", QuestHelper.Version("0.24"));
            q.AddReq("element", "earth");
            p.quests.Add(q);

            q      = new Quest("foundTown", "Found your town", "foundTown");
            q.desc = TextHelper.RichText(
                "Welcome to the underground.", "As the element says, you now begin under the shadow. But the shadow element can easily switch between levels and even float through deep walls. Find a suitable place for your first city and found it.",
                "If a place is blocked by a deep wall, you can use terraform to transform it.",
                TextHelper.Header("Task"), TextHelper.IconLabel("foundTown", "Find a good place and found your town."));
            q.AddReq("building", ">1:shall1");
            q.main = true;
            p.quests.Add(q);

            var worker   = L.b.units["sworker"];
            var explorer = L.b.units["sexplorer"];

            q      = new Quest("unit", $"{worker.Name()} & {explorer.Name()}", "train");
            q.desc = TextHelper.RichText(
                "First you'll need units again.", "The Explorer can go through walls, explore the area and claim unknown fields.", "The worker can construct buildings, remove the wall and collect resources, so train both of them now.",
                TextHelper.Header("Tasks"), TextHelper.IconLabel(worker.Icon, $"Train a {worker.Name()}"), TextHelper.IconLabel(explorer.Icon, $"Train a {explorer.Name()}"));
            q.AddReq("unit", ">1:" + worker.id);
            q.AddReq("unit", ">1:" + explorer.id);
            q.AddReq("questFinish", "foundTown");
            q.main = true;
            p.quests.Add(q);

            //build buildings
            var sfarm  = L.b.buildings["sfarm"];
            var sdirt  = L.b.buildings["sdirt"];
            var quarry = L.b.buildings["quarry"];
            var fisher = L.b.buildings["fisher"];
            var sandG  = L.b.buildings["sandG"];
            var tent   = L.b.buildings["tent"];

            q      = new Quest("building", "Build the town", "build");
            q.desc = TextHelper.RichText(
                "As with the element of light, you first need construction material and food.", $"Sand from {sandG.Name()} and stone from {quarry.Name()} are used for construction materials.",
                $"Food is available from the {fisher.Name()} or the {sfarm.Name()}. But the {sfarm.Name()} needs dirt from {sdirt.Name()}.", $"The workers live in {tent.Name()} again.", $"If the fields are too far away from the town hall, they must be taken into occupation first. The {explorer.Name()} can do this via claim.",
                TextHelper.Header("Tasks"), TextHelper.IconLabel(quarry.Icon, $"Build a {quarry.Name()}"), TextHelper.IconLabel(sdirt.Icon, $"Build a {sdirt.Name()}"),
                TextHelper.IconLabel(sfarm.Icon, $"Build a {sfarm.Name()}"), TextHelper.IconLabel(tent.Icon, $"Build a {tent.Name()}"));
            q.AddReq("building", ">1:" + quarry.id);
            q.AddReq("building", ">1:" + sdirt.id);
            q.AddReq("building", ">1:" + sfarm.id);
            q.AddReq("building", ">1:" + tent.id);
            q.AddReq("questFinish", "unit");
            q.main = true;
            p.quests.Add(q);

            // level 2
            DataBuilding shall2 = L.b.buildings["shall2"];

            q      = new Quest("shall2", "Upgrade to " + shall2.Name(), shall2.Icon);
            q.desc = TextHelper.RichText(
                "Unlike light, shadow knows no research. That's why you can upgrade the town hall right now.",
                TextHelper.Header("Tasks"), TextHelper.IconLabel(shall2.Icon, "Upgrade the town hall to " + shall2.Name()));
            q.AddReq("questFinish", "building");
            q.AddReq("building", ">1:" + shall2.id + ":true");
            q.main = true;
            p.quests.Add(q);

            // usage Town
            DataBuilding sshrine = L.b.buildings["sshrine"];

            q      = new Quest("need", "Find the needs", p.Coat().flag);
            q.desc = TextHelper.RichText(
                "A city can only grow if its inhabitants have fulfilled necessary usages. Depending on the level of the city, the inhabitants have different requirements. Since the city has now increased one level, there are new requirements.",
                "Open the menu and check the usages. Build the appropriate building.",
                TextHelper.Header("Tasks"), TextHelper.IconLabel(p.Coat().flag, "Open Kingdom overview"), TextHelper.IconLabel("foundTown", "Open your town"), TextHelper.IconLabel("usage", "Find the usages"), TextHelper.IconLabel("build", "Build appropriate the building"));
            q.AddReq("questFinish", "shall2");
            q.AddReq("building", ">1:" + sshrine.id);
            q.main = true;
            p.quests.Add(q);

            // development
            var earth = L.b.elements["earth"];

            q      = new Quest("earth", "Evolve to a new element", "religion");
            q.desc = TextHelper.RichText(
                "Once the shrine is built, the gods can be worshipped and the nation can develop.",
                TextHelper.Header("Tasks"), TextHelper.IconLabel("religion", "Evolve to a new element"));
            q.AddReq("questFinish", "need");
            q.AddReq("element", "earth");
            q.main = true;
            p.quests.Add(q);
        }
Пример #6
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (!(targeted is Mobile))
                {
                    from.SendLocalizedMessage(1049528); // You cannot calm that!
                }
                else if (!m_Instrument.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1062488); // The instrument you are trying to play is no longer in your backpack!
                }
                else
                {
                    m_SetSkillTime = false;

                    int masteryBonus = 0;

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

                    if (targeted == from)
                    {
                        // Standard mode : reset combatants for everyone in the area
                        if (from.Player && !BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendLocalizedMessage(500612); // You play poorly, and there is no effect.
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                        }
                        else if (!from.CheckSkill(SkillName.Peacemaking, 0.0, 120.0))
                        {
                            from.SendLocalizedMessage(500613); // You attempt to calm everyone, but fail.
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);

                            from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                        }
                        else
                        {
                            from.NextSkillTime = Core.TickCount + 5000;
                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);

                            Map map = from.Map;

                            if (map != null)
                            {
                                int range = BaseInstrument.GetBardRange(from, SkillName.Peacemaking);

                                bool calmed             = false;
                                IPooledEnumerable eable = from.GetMobilesInRange(range);

                                foreach (Mobile m in eable)
                                {
                                    if ((m is BaseCreature && ((BaseCreature)m).Uncalmable) ||
                                        (m is BaseCreature && ((BaseCreature)m).AreaPeaceImmune) || m == from || !from.CanBeHarmful(m, false, false, true))
                                    {
                                        continue;
                                    }

                                    calmed = true;

                                    m.SendLocalizedMessage(500616); // You hear lovely music, and forget to continue battling!
                                    m.Combatant = null;
                                    m.Warmode   = false;

                                    if (m is BaseCreature && !((BaseCreature)m).BardPacified)
                                    {
                                        ((BaseCreature)m).Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(1.0));
                                    }
                                }
                                eable.Free();

                                if (!calmed)
                                {
                                    from.SendLocalizedMessage(1049648); // You play hypnotic music, but there is nothing in range for you to calm.
                                }
                                else
                                {
                                    from.SendLocalizedMessage(500615); // You play your hypnotic music, stopping the battle.
                                }
                            }
                        }
                    }
                    else
                    {
                        // Target mode : pacify a single target for a longer duration
                        Mobile targ = (Mobile)targeted;

                        if (!from.CanBeHarmful(targ, false, false, true))
                        {
                            from.SendLocalizedMessage(1049528);
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).Uncalmable)
                        {
                            from.SendLocalizedMessage(1049526); // You have no chance of calming that creature.
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).BardPacified)
                        {
                            from.SendLocalizedMessage(1049527); // That creature is already being calmed.
                            m_SetSkillTime = true;
                        }
                        else if (from.Player && !BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendLocalizedMessage(500612); // You play poorly, and there is no effect.
                            from.NextSkillTime = Core.TickCount + 5000;
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                        else
                        {
                            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 (masteryBonus > 0)
                            {
                                diff -= (diff * ((double)masteryBonus / 100));
                            }

                            if (!from.CheckTargetSkill(SkillName.Peacemaking, targ, diff - 25.0, diff + 25.0))
                            {
                                from.SendLocalizedMessage(1049531); // You attempt to calm your target, but fail.
                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);

                                from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                            }
                            else
                            {
                                m_Instrument.PlayInstrumentWell(from);
                                m_Instrument.ConsumeUse(from);

                                from.NextSkillTime = Core.TickCount + (5000 - ((masteryBonus / 5) * 1000));

                                if (targ is BaseCreature)
                                {
                                    BaseCreature bc = (BaseCreature)targ;

                                    from.SendLocalizedMessage(1049532); // You play hypnotic music, calming your target.

                                    targ.Combatant = null;
                                    targ.Warmode   = false;

                                    double seconds = 100 - (diff / 1.5);

                                    if (seconds > 120)
                                    {
                                        seconds = 120;
                                    }
                                    else if (seconds < 10)
                                    {
                                        seconds = 10;
                                    }

                                    bc.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(seconds));

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

                                        if (quest != null)
                                        {
                                            foreach (BaseObjective objective in quest.Objectives)
                                            {
                                                objective.Update(bc);
                                            }
                                        }
                                    }
                                    #endregion
                                }
                                else
                                {
                                    from.SendLocalizedMessage(1049532); // You play hypnotic music, calming your target.

                                    targ.SendLocalizedMessage(500616);  // You hear lovely music, and forget to continue battling!
                                    targ.Combatant = null;
                                    targ.Warmode   = false;
                                }
                            }
                        }
                    }
                }
            }
    private static void HandleInteract(GameSession session, PacketReader packet)
    {
        string id = packet.ReadString();

        session.FieldManager.State.InteractObjects.TryGetValue(id, out InteractObject interactObject);
        if (interactObject == null)
        {
            return;
        }

        InteractObjectMetadata metadata = InteractObjectMetadataStorage.GetInteractObjectMetadata(interactObject.InteractId);

        switch (interactObject.Type)
        {
        case InteractObjectType.Binoculars:
            session.Send(InteractObjectPacket.Use(interactObject));
            QuestHelper.UpdateExplorationQuest(session, interactObject.InteractId.ToString(), "interact_object_rep");
            break;

        case InteractObjectType.Ui:
            session.Send(InteractObjectPacket.Use(interactObject));
            break;

        case InteractObjectType.RankBoard:
            session.Send(WebOpenPacket.Open(metadata.Web.Url));
            break;

        case InteractObjectType.AdBalloon:
            session.Send(PlayerHostPacket.AdBalloonWindow((AdBalloon)interactObject));
            break;

        case InteractObjectType.Gathering:
            GatheringHelper.HandleGathering(session, metadata.Gathering.RecipeId, out int numDrop);
            session.Send(InteractObjectPacket.Use(interactObject, (short)(numDrop > 0 ? 0 : 1), numDrop));
            break;

        case InteractObjectType.Common:
            foreach ((int questId, QuestState state) in metadata.Quests)
            {
                if (!session.Player.QuestData.TryGetValue(questId, out QuestStatus questStatus) || questStatus.State != state)
                {
                    continue;
                }

                QuestHelper.UpdateQuest(session, interactObject.InteractId.ToString(), "interact_object");
            }

            // Unsure if all interact objects need to be set as disabled.
            interactObject.State = InteractObjectState.Disable;

            session.Send(InteractObjectPacket.Update(interactObject));
            session.Send(InteractObjectPacket.Interact(interactObject));

            foreach (int boxId in metadata.Drop.IndividualDropBoxId)
            {
                ItemDropMetadata itemDropMetadataStorage = ItemDropMetadataStorage.GetItemDropMetadata(boxId);
                if (itemDropMetadataStorage is null)
                {
                    continue;
                }

                foreach (DropGroup dropGroup in itemDropMetadataStorage.DropGroups)
                {
                    foreach (DropGroupContent dropGroupContent in dropGroup.Contents)
                    {
                        foreach (int itemId in dropGroupContent.ItemIds)
                        {
                            Item item = new(itemId)
                            {
                                Amount = RandomProvider.Get().Next((int)dropGroupContent.MinAmount, (int)dropGroupContent.MaxAmount),
                                Rarity = dropGroupContent.Rarity
                            };

                            session.FieldManager.AddItem(session, item);
                        }
                    }
                }
            }

            foreach (int boxId in metadata.Drop.GlobalDropBoxId)
            {
                ItemDropMetadata itemDropMetadataStorage = ItemDropMetadataStorage.GetItemDropMetadata(boxId);
                if (itemDropMetadataStorage is null)
                {
                    continue;
                }

                foreach (DropGroup dropGroup in itemDropMetadataStorage.DropGroups)
                {
                    foreach (DropGroupContent dropGroupContent in dropGroup.Contents)
                    {
                        foreach (int itemId in dropGroupContent.ItemIds)
                        {
                            Item item = new(itemId)
                            {
                                Amount = RandomProvider.Get().Next((int)dropGroupContent.MinAmount, (int)dropGroupContent.MaxAmount),
                                Rarity = dropGroupContent.Rarity
                            };

                            session.FieldManager.AddItem(session, item);
                        }
                    }
                }
            }

            if (interactObject is MapChest)
            {
                // Unsure if setting as activated is specific of map chests
                interactObject.State = InteractObjectState.Activated;

                // Delayed removal of the chest
                Task.Run(async() =>
                {
                    await Task.Delay(TimeSpan.FromSeconds(10));
                    session.FieldManager.State.RemoveInteractObject(interactObject.Id);

                    session.FieldManager.BroadcastPacket(InteractObjectPacket.Update(interactObject));
                    session.FieldManager.BroadcastPacket(InteractObjectPacket.Remove(interactObject));
                });
            }
            return;
        }

        session.Send(InteractObjectPacket.Interact(interactObject));
    }
}
Пример #8
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (targeted is BaseCreature)
                {
                    BaseCreature creature = (BaseCreature)targeted;

                    if (!m_Instrument.IsChildOf(from.Backpack))
                    {
                        from.SendLocalizedMessage(1062488);                           // The instrument you are trying to play is no longer in your backpack!
                    }
                    else if (m_Creature.Unprovokable || creature.Unprovokable)
                    {
                        from.SendLocalizedMessage(1049446);                           // You have no chance of provoking those creatures.
                    }
                    else if (m_Creature.Map != creature.Map || !m_Creature.InRange(creature, BaseInstrument.GetBardRange(from, SkillName.Provocation)))
                    {
                        from.SendLocalizedMessage(1049450);                           // The creatures you are trying to provoke are too far away from each other for your music to have an effect.
                    }
                    else if (m_Creature != creature)
                    {
                        from.NextSkillTime = DateTime.UtcNow + BaseInstrument.GetBardSkillTimeout(SkillName.Provocation, from);

                        double diff  = ((m_Instrument.GetDifficultyFor(m_Creature) + m_Instrument.GetDifficultyFor(creature)) * 0.5) - 5.0;
                        double music = from.Skills[SkillName.Musicianship].Value;

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

                        if (from.CanBeHarmful(m_Creature, true) && from.CanBeHarmful(creature, true))
                        {
                            if (!BaseInstrument.CheckMusicianship(from))
                            {
                                from.SendLocalizedMessage(500612);                                   // You play poorly, and there is no effect.
                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);
                            }
                            else
                            {
                                //from.DoHarmful( m_Creature );
                                //from.DoHarmful( creature );

                                if (!BaseInstrument.CheckBardSkillChance(from, SkillName.Provocation, creature, diff - 25.0, diff + 25.0))
                                {
                                    from.SendLocalizedMessage(501599);                                       // Your music fails to incite enough anger.
                                    m_Instrument.PlayInstrumentBadly(from);
                                    m_Instrument.ConsumeUse(from);
                                }
                                else
                                {
                                    from.SendLocalizedMessage(501602);                                       // Your music succeeds, as you start a fight.
                                    m_Instrument.PlayInstrumentWell(from);
                                    m_Instrument.ConsumeUse(from);
                                    m_Creature.Provoke(from, creature, true);

                                    PlayerMobile pm = from as PlayerMobile;

                                    if (pm != null)
                                    {
                                        QuestHelper.OnProvoked(pm, m_Creature, creature);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(501593);                           // You can't tell someone to attack themselves!
                    }
                }
                else
                {
                    from.SendLocalizedMessage(501589);                       // You can't incite that!
                }
            }
 public GamePage(ApplicationService applicationService, NavigationService navigationService, LogHelper logHelper, QuestHelper questHelper, InMemoryContextHelper inMemoryContextHelper)
 {
     InitializeComponent();
     playerStats = new PlayerStats();
     _StatsGoHere.Children.Add(new StatBlock(new StatBlockViewModel(playerStats)));
     this.Loaded          += new RoutedEventHandler(this.Page_Loaded);
     _applicationService   = applicationService;
     _navigationService    = navigationService;
     LogHelper             = logHelper;
     QuestHelper           = questHelper;
     InMemoryContextHelper = inMemoryContextHelper;
 }
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }
            if (IsDone)
            {
                return(false);
            }

            if (!QuestHelper.QuestContainedInQuestLog(QuestID) || QuestHelper.GetQuestFromQuestLog(QuestID).IsCompleted)
            {
                return(false);
            }

            if (Building.WorkOrder == null || Building.WorkOrder.TotalWorkorderStartups() == 0)
            {
                return(false);
            }

            if (await StartMovement.MoveTo())
            {
                return(true);
            }

            if (GossipHelper.IsOpen)
            {
                GossipFrame.Instance.SelectGossipOption(0);
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                return(true);
            }

            if (LuaCommands.IsGarrisonCapacitiveDisplayFrame())
            {
                if (!LuaCommands.ClickStartOrderButtonEnabled())
                {
                    Building.CheckedWorkOrderStartUp = true;
                    GarrisonBase.Log("Order Button Disabled!");
                    return(false);
                }


                LuaCommands.ClickStartOrderButton();
                await CommonCoroutines.SleepForRandomUiInteractionTime();

                await CommonCoroutines.SleepForLagDuration();

                return(true);
            }

            if (InteractionObject != null && InteractionObject.IsValid)
            {
                if (InteractionObject.WithinInteractRange)
                {
                    TreeRoot.StatusText = String.Format("Behavior {0} Quest NPC Interact", Type.ToString());
                    InteractionObject.Interact();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }

                if (_npcMovement == null)
                {
                    _npcMovement = new Movement(InteractionObject.Location, InteractionObject.InteractRange - 0.25f);
                }

                await _npcMovement.ClickToMove(false);

                return(true);
            }

            return(false);
        }
        private static void HandleUse(GameSession session, PacketReader packet)
        {
            string uuid = packet.ReadMapleString();
            IFieldObject <InteractObject> interactObject = session.FieldManager.State.InteractObjects[uuid];

            if (interactObject == null)
            {
                return;
            }

            MapInteractObject mapObject = MapEntityStorage.GetInteractObject(session.Player.MapId).FirstOrDefault(x => x.Uuid == uuid);
            int numDrop = 0;

            switch (interactObject.Value.Type)
            {
            case InteractObjectType.Binoculars:
                QuestHelper.UpdateExplorationQuest(session, mapObject.InteractId.ToString(), "interact_object_rep");
                break;

            case InteractObjectType.Gathering:
                RecipeMetadata    recipe         = RecipeMetadataStorage.GetRecipe(mapObject.RecipeId);
                long              requireMastery = int.Parse(recipe.RequireMastery);
                Enums.MasteryType type           = (Enums.MasteryType) int.Parse(recipe.MasteryType);

                session.Player.Levels.GainMasteryExp(type, 0);
                long currentMastery = session.Player.Levels.MasteryExp.FirstOrDefault(x => x.Type == type).CurrentExp;
                if (currentMastery < requireMastery)
                {
                    return;
                }

                session.Player.IncrementGatheringCount(mapObject.RecipeId, 0);
                int numCount = session.Player.GatheringCount[mapObject.RecipeId].Current;

                List <RecipeItem> items = RecipeMetadataStorage.GetResult(recipe);
                Random            rand  = new Random();
                int masteryDiffFactor   = numCount switch
                {
                    int n when n < recipe.HighPropLimitCount => MasteryFactorMetadataStorage.GetFactor(0),
                    int n when n < recipe.NormalPropLimitCount => MasteryFactorMetadataStorage.GetFactor(1),
                    int n when n < (int)(recipe.NormalPropLimitCount * 1.3) => MasteryFactorMetadataStorage.GetFactor(2),
                    _ => MasteryFactorMetadataStorage.GetFactor(3),
                };

                foreach (RecipeItem item in items)
                {
                    int prob = (int)(RarityChance[item.Rarity] * masteryDiffFactor) / 10000;
                    if (rand.Next(100) >= prob)
                    {
                        continue;
                    }
                    for (int i = 0; i < item.Amount; i++)
                    {
                        session.FieldManager.AddItem(session, new Item(item.Id));
                    }
                    numDrop += item.Amount;
                }
                if (numDrop > 0)
                {
                    session.Player.IncrementGatheringCount(mapObject.RecipeId, numDrop);
                    session.Player.Levels.GainMasteryExp(type, recipe.RewardMastery);
                }
                break;

            case InteractObjectType.AdBalloon:
                session.Send(PlayerHostPacket.AdBalloonWindow(interactObject));
                return;
            }
            session.Send(InteractObjectPacket.UseObject(mapObject, (short)(numDrop > 0 ? 0 : 1), numDrop));
            session.Send(InteractObjectPacket.Extra(mapObject));
        }
Пример #12
0
        public static void CheckBlab_Callback()
        {
            List <Mobile> regPlayers1 = null;
            List <Mobile> regPlayers2 = null;
            List <Mobile> regPlayers3 = null;

            if (m_Region1 != null)
            {
                regPlayers1 = m_Region1.GetPlayers();
            }

            if (m_Region2 != null)
            {
                regPlayers2 = m_Region2.GetPlayers();
            }

            if (TokunoDocksRegion.Instance != null)
            {
                regPlayers2 = TokunoDocksRegion.Instance.GetPlayers();
            }
            //TODO: Quest Check
            if (regPlayers1 != null)
            {
                for (int i = 0; i < regPlayers1.Count; i++)
                {
                    Mobile player = regPlayers1[i];

                    if (player != null && player.Alive && player is PlayerMobile && QuestHelper.GetQuest((PlayerMobile)player, typeof(ProfessionalBountyQuest)) != null)
                    {
                        IPooledEnumerable eable = player.GetMobilesInRange(4);
                        foreach (Mobile mob in eable)
                        {
                            if (mob is BaseVendor || mob is MondainQuester || mob is GalleonPilot)
                            {
                                TryPirateBlab(player, mob);
                                break;
                            }
                        }
                        eable.Free();
                    }
                }
            }

            if (regPlayers2 != null)
            {
                for (int i = 0; i < regPlayers2.Count; i++)
                {
                    Mobile player = regPlayers2[i];

                    if (player != null && player.Alive && player is PlayerMobile && QuestHelper.GetQuest((PlayerMobile)player, typeof(ProfessionalBountyQuest)) != null)
                    {
                        IPooledEnumerable eable = player.GetMobilesInRange(4);
                        foreach (Mobile mob in eable)
                        {
                            if (mob is BaseVendor || mob is MondainQuester)
                            {
                                TryPirateBlab(player, mob);
                                break;
                            }
                        }
                        eable.Free();
                    }
                }
            }

            if (regPlayers3 != null)
            {
                for (int i = 0; i < regPlayers3.Count; i++)
                {
                    Mobile player = regPlayers3[i];

                    if (player != null && player.Alive && player is PlayerMobile && QuestHelper.GetQuest((PlayerMobile)player, typeof(ProfessionalBountyQuest)) != null)
                    {
                        IPooledEnumerable eable = player.GetMobilesInRange(4);
                        foreach (Mobile mob in eable)
                        {
                            if (mob is BaseVendor || mob is MondainQuester)
                            {
                                TryPirateBlab(player, mob);
                                break;
                            }
                        }
                        eable.Free();
                    }
                }
            }
        }
Пример #13
0
 public override void OnDoubleClick(Mobile from)
 {
     if (from is PlayerMobile player)
     {
         if (QuestHelper.GetQuest(player, typeof(BlackOrderBadgesQuest)) != null || QuestHelper.GetQuest(player, typeof(EvidenceQuest)) != null)
         {
             BaseCreature.TeleportPets(player, new Point3D(107, 1883, 0), Map.Malas);
             player.MoveToWorld(new Point3D(107, 1883, 0), Map.Malas);
         }
         else
         {
             player.SendLocalizedMessage(1074278); // You realize that your eyes are playing tricks on you. That crate isn't really shimmering.
         }
     }
 }
Пример #14
0
 public override void OnDoubleClick(Mobile from)
 {
     if (from is PlayerMobile mobile && mobile.InRange(GetWorldLocation(), 2) && mobile.InLOS(this) && (QuestHelper.GetQuest(mobile, typeof(PrideOfTheAmbushQuest)) is PrideOfTheAmbushQuest))
     {
         mobile.SendGump(new LockingMechanismGump(mobile, this));
     }
 }
Пример #15
0
 public override bool CanOffer()
 {
     return(!QuestHelper.HasQuest <GoingGumshoeQuest2>(Owner) &&
            !QuestHelper.HasQuest <GoingGumshoeQuest3>(Owner) &&
            !QuestHelper.HasQuest <GoingGumshoeQuest4>(Owner));
 }
Пример #16
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.Player)
                    {
                        from.NextSkillTime = DateTime.UtcNow + 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.UtcNow;
                        }
                        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.
                }
            }
Пример #17
0
 public static bool UnderMysteriousPotionEffects(Mobile m, bool checkQuest = false)
 {
     return
         (MysteriousPotionEffects != null && MysteriousPotionEffects.ContainsKey(m) && MysteriousPotionEffects[m] > DateTime.UtcNow &&
          (!checkQuest || (m is PlayerMobile && QuestHelper.HasQuest <AForcedSacraficeQuest2>((PlayerMobile)m))));
 }
Пример #18
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            PlayerMobile pm = e.Mobile as PlayerMobile;

            if (pm.AbyssEntry)
            {
                pm.SendLocalizedMessage(1112697);  //You enter a state of peaceful contemplation, focusing on the meaning of Singularity.
            }
            else if (!e.Handled && pm.InRange(Location, 2) && e.Speech.ToLower().Trim() == "unorus" && QuestHelper.CheckDoneOnce(pm, typeof(TheArisenQuest), null, false))
            {
                e.Handled = true;
                e.Mobile.PlaySound(0xF9);

                var quest = QuestHelper.GetQuest <QuestOfSingularity>(pm);

                if (HasDelay(pm) && pm.AccessLevel == AccessLevel.Player)
                {
                    pm.PublicOverheadMessage(MessageType.Regular, 0x47E, 1112685); // You need more time to contemplate the Book of Circles before trying again.
                }
                else if (quest == null)
                {
                    quest = new QuestOfSingularity
                    {
                        Owner   = pm,
                        Quester = this
                    };

                    pm.SendGump(new MondainQuestGump(quest));
                }
                else if (quest.Completed)
                {
                    pm.SendGump(new MondainQuestGump(quest, MondainQuestGump.Section.Complete, false, true));
                }
                else if (!pm.HasGump(typeof(QAndAGump)))
                {
                    pm.SendGump(new QAndAGump(pm, quest));
                }
            }
        }
Пример #19
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (targeted is BaseCreature || (from is BaseCreature && ((BaseCreature)from).CanProvoke))
                {
                    BaseCreature creature = targeted as BaseCreature;
                    Mobile       target   = targeted as Mobile;

                    bool questTargets = QuestTargets(creature, from);

                    if (!m_Instrument.IsChildOf(from.Backpack))
                    {
                        from.SendLocalizedMessage(1062488); // The instrument you are trying to play is no longer in your backpack!
                    }
                    else if (m_Creature.Unprovokable)
                    {
                        from.SendLocalizedMessage(1049446); // You have no chance of provoking those creatures.
                    }
                    else if (creature != null && creature.Unprovokable && !(creature is DemonKnight) && !questTargets)
                    {
                        from.SendLocalizedMessage(1049446); // You have no chance of provoking those creatures.
                    }
                    else if (m_Creature.Map != target.Map ||
                             !m_Creature.InRange(target, BaseInstrument.GetBardRange(from, SkillName.Provocation)))
                    {
                        from.SendLocalizedMessage(1049450);
                        // The creatures you are trying to provoke are too far away from each other for your music to have an effect.
                    }
                    else if (m_Creature != target)
                    {
                        from.NextSkillTime = Core.TickCount + 10000;

                        double diff         = ((m_Instrument.GetDifficultyFor(m_Creature) + m_Instrument.GetDifficultyFor(target)) * 0.5) - 5.0;
                        double music        = from.Skills[SkillName.Musicianship].Value;
                        double peace        = from.Skills[SkillName.Peacemaking].Value;
                        double disco        = from.Skills[SkillName.Discordance].Value;
                        int    masteryBonus = 0;

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

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

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

                        if (questTargets || (from.CanBeHarmful(m_Creature, true) && from.CanBeHarmful(target, true)))
                        {
                            if (from.Player && !BaseInstrument.CheckMusicianship(from))
                            {
                                from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                                from.SendLocalizedMessage(500612); // You play poorly, and there is no effect.
                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);
                            }
                            else
                            {
                                //from.DoHarmful( m_Creature );
                                //from.DoHarmful( creature );
                                if (!from.CheckTargetSkill(SkillName.Provocation, target, diff - 25.0, diff + 25.0))
                                {
                                    from.NextSkillTime = Core.TickCount + (10000 - ((masteryBonus / 5) * 1000));
                                    from.SendLocalizedMessage(501599); // Your music fails to incite enough anger.
                                    m_Instrument.PlayInstrumentBadly(from);
                                    m_Instrument.ConsumeUse(from);
                                }
                                else
                                {
                                    from.SendLocalizedMessage(501602); // Your music succeeds, as you start a fight.
                                    m_Instrument.PlayInstrumentWell(from);
                                    m_Instrument.ConsumeUse(from);
                                    m_Creature.Provoke(from, target, true);

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

                                        if (quest != null)
                                        {
                                            foreach (BaseObjective objective in quest.Objectives)
                                            {
                                                objective.Update(creature);
                                            }
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(501593); // You can't tell someone to attack themselves!
                    }
                }
                else
                {
                    from.SendLocalizedMessage(501589); // You can't incite that!
                }
            }
Пример #20
0
        public override void OnDoubleClick(Mobile from)
        {
            if (from.NetState == null || !from.NetState.SupportsExpansion(Expansion.ML))
            {
                from.SendLocalizedMessage(1072608); // You must upgrade to the Mondain's Legacy expansion in order to enter here.
                return;
            }
            else if (!MondainsLegacy.Citadel && (int)from.AccessLevel < (int)AccessLevel.GameMaster)
            {
                from.SendLocalizedMessage(1042753, "The Citadel"); // ~1_SOMETHING~ has been temporarily disabled.
                return;
            }

            if (from is PlayerMobile)
            {
                PlayerMobile player = (PlayerMobile)from;

                if (QuestHelper.GetQuest(player, typeof(BlackOrderBadgesQuest)) != null || QuestHelper.GetQuest(player, typeof(EvidenceQuest)) != null)
                {
                    BaseCreature.TeleportPets(player, new Point3D(107, 1883, 0), Map.Malas);
                    player.MoveToWorld(new Point3D(107, 1883, 0), Map.Malas);
                }
                else
                {
                    player.SendLocalizedMessage(1074278); // You realize that your eyes are playing tricks on you. That crate isn't really shimmering.
                }
            }
        }
Пример #21
0
        public virtual bool CheckAtDestination()
        {
            if (Quest != null)
            {
                EscortObjective escort = GetObjective();

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

                Mobile escorter = GetEscorter();

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

                if (escort.Region != null && escort.Region.Contains(Location))
                {
                    Say(1042809, escorter.Name); // We have arrived! I thank thee, ~1_PLAYER_NAME~! I have no further need of thy services. Here is thy pay.

                    escort.Complete();

                    if (Quest.Completed)
                    {
                        escorter.SendLocalizedMessage(1046258, null, 0x23); // Your quest is complete.

                        if (QuestHelper.AnyRewards(Quest))
                        {
                            escorter.SendGump(new MondainQuestGump(Quest, MondainQuestGump.Section.Rewards, false, true));
                        }
                        else
                        {
                            Quest.GiveRewards();
                        }

                        escorter.PlaySound(Quest.CompleteSound);

                        StopFollow();
                        m_EscortTable.Remove(escorter);
                        m_DeleteTimer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerCallback(Delete));

                        // fame
                        Misc.Titles.AwardFame(escorter, escort.Fame, true);

                        // compassion
                        bool gainedPath = false;

                        PlayerMobile pm = escorter as PlayerMobile;

                        if (pm != null)
                        {
                            if (pm.CompassionGains > 0 && DateTime.UtcNow > pm.NextCompassionDay)
                            {
                                pm.NextCompassionDay = DateTime.MinValue;
                                pm.CompassionGains   = 0;
                            }

                            if (pm.CompassionGains >= 5)          // have already gained 5 times in one day, can gain no more
                            {
                                pm.SendLocalizedMessage(1053004); // You must wait about a day before you can gain in compassion again.
                            }
                            else if (VirtueHelper.Award(pm, VirtueName.Compassion, escort.Compassion, ref gainedPath))
                            {
                                pm.SendLocalizedMessage(1074949, null, 0x2A);  // You have demonstrated your compassion!  Your kind actions have been noted.

                                if (gainedPath)
                                {
                                    pm.SendLocalizedMessage(1053005); // You have achieved a path in compassion!
                                }
                                else
                                {
                                    pm.SendLocalizedMessage(1053002);                            // You have gained in compassion.
                                }
                                pm.NextCompassionDay = DateTime.UtcNow + TimeSpan.FromDays(1.0); // in one day CompassionGains gets reset to 0
                                ++pm.CompassionGains;
                            }
                            else
                            {
                                pm.SendLocalizedMessage(1053003); // You have achieved the highest path of compassion and can no longer gain any further.
                            }
                        }
                    }
                    else
                    {
                        escorter.PlaySound(Quest.UpdateSound);
                    }

                    return(true);
                }
            }
            else if (!m_Checked)
            {
                Region region = GetDestination();

                if (region != null && region.Contains(Location))
                {
                    m_DeleteTimer = Timer.DelayCall(TimeSpan.FromSeconds(5.0), new TimerCallback(Delete));
                    m_Checked     = true;
                }
            }

            return(false);
        }
Пример #22
0
        public void Run()
        {
            int pid = S.Players().CreatePlayer(System.Environment.UserName, "forger");

            S.Player(pid).quests.Add(QuestHelper.Win().AddReq("building", ">1:temple"));
        }
Пример #23
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;
                        int    masteryBonus = 0;

                        diff += XmlMobFactions.GetScaledFaction(from, targ, -25, 25, -0.001);

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

                            #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

                            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.
                }
            }
Пример #24
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 10)
            {
                return;
            }

            if (m_Question != 0)
            {
                switch (info.ButtonID)
                {
                case 0: Sky++; break;

                case 1: Flame++; break;

                case 2: Gale++; break;

                case 3: Stone++; break;

                case 4: Spring++; break;
                }
            }

            if (m_Question < 11)
            {
                if (sender.Mobile.HasGump(typeof(BlueMageQuestionsGump)))
                {
                    sender.Mobile.CloseGump(typeof(BlueMageQuestionsGump));
                }

                sender.Mobile.SendGump(new BlueMageQuestionsGump(sender.Mobile, m_Ben, m_Question + 1, m_Serpent));
            }
            else if (sender.Mobile is PlayerMobile)
            {
                PlayerMobile pm = (PlayerMobile)sender.Mobile;

                int[] highest = { -1, -1 };

                for (int i = 0; i < m_Serpent.Length; i++)
                {
                    if (m_Serpent[i] > highest[1])
                    {
                        highest[0] = i;
                        highest[1] = m_Serpent[i];
                    }
                }

                BaseQuest bq = null;

                switch (highest[0])
                {
                default: bq = new BlueMageSkySerpentQuest(pm); break;

                case 1: bq = new BlueMageFlameSerpentQuest(pm); break;

                case 2: bq = new BlueMageGaleSerpentQuest(pm); break;

                case 3: bq = new BlueMageStoneSerpentQuest(pm); break;

                case 4: bq = new BlueMageSpringSerpentQuest(pm); break;
                }

                if (bq == null)
                {
                    pm.SendMessage(33, "Error: Page a GM and tell him \"BM Questions failed to offer BM Serpent Quest\" immidately.");
                    return;
                }
                else
                {
                    bq.Owner   = pm;
                    bq.Quester = m_Ben;

                    if (!QuestHelper.CanOffer(pm, bq, true))
                    {
                        bq.StartingMobile.OnOfferFailed();
                        return;
                    }
                }

                pm.CloseGump(typeof(MondainQuestGump));
                pm.SendGump(new MondainQuestGump(bq));
            }
        }
Пример #25
0
        internal static Behavior[] GetGarrisonBehaviors()
        {
            var retBehaviorList = new List <Behavior>
            {
                new BehaviorGetMail(),
                new BehaviorMissionComplete(),
                new BehaviorCache()
            };

            //Finalize Plots
            foreach (var b in Buildings.Values.Where(b => b.CanActivate))
            {
                retBehaviorList.Add(new BehaviorFinalizePlots(b));
            }

            #region Building First Quest Behaviors
            foreach (var b in Buildings.Values.Where(b => !b.FirstQuestCompleted && !b.IsBuilding && b.FirstQuestNpcId > -1 && b.FirstQuestId > -1))
            {
                retBehaviorList.Add(QuestHelper.GetGarrisonBuildingFirstQuestArray(b, Player.IsAlliance));
            }

            #endregion

            #region Herbing and Mining

            if (Buildings.Values.Any(b => b.Type == BuildingType.Mines))
            {
                var miningMoveTo = new BehaviorMove(MovementCache.MinePlot59SafePoint);
                miningMoveTo.Criteria += () => !GarrisonMineZoneIds.Contains(Player.ZoneId.Value);

                var miningArray = new BehaviorArray(new Behavior[]
                {
                    new BehaviorCustomAction(() =>
                    {
                        TargetManager.LootType = TargetManager.LootFlags.Units | TargetManager.LootFlags.Ore;
                    }),

                    miningMoveTo,
                    new BehaviorMine()
                });
                miningArray.Criteria += () => (!Buildings[BuildingType.Mines].IsBuilding &&
                                               !Buildings[BuildingType.Mines].CanActivate &&
                                               Buildings[BuildingType.Mines].FirstQuestCompleted &&
                                               LuaCommands.CheckForDailyReset(BaseSettings.CurrentSettings.LastCheckedMine) &&
                                               BaseSettings.CurrentSettings.BehaviorMineGather);
                miningArray.DisposalAction = () =>
                {
                    TargetManager.LootType = TargetManager.LootFlags.None;
                };

                retBehaviorList.Add(miningArray);
                retBehaviorList.Add(new BehaviorWorkOrderPickUp(Buildings[BuildingType.Mines]));
                retBehaviorList.Add(new BehaviorWorkOrderStartUp(Buildings[BuildingType.Mines]));
            }

            if (Buildings.Values.Any(b => b.Type == BuildingType.HerbGarden))
            {
                var herbingArray = new BehaviorArray(new Behavior[]
                {
                    new BehaviorCustomAction(() =>
                    {
                        TargetManager.LootType = TargetManager.LootFlags.Units | TargetManager.LootFlags.Herbs;
                    }),

                    new BehaviorMove(MovementCache.GardenPlot63SafePoint),
                    new BehaviorHerb()
                });
                herbingArray.Criteria += () => (!Buildings[BuildingType.HerbGarden].IsBuilding &&
                                                !Buildings[BuildingType.HerbGarden].CanActivate &&
                                                Buildings[BuildingType.HerbGarden].FirstQuestCompleted &&
                                                LuaCommands.CheckForDailyReset(BaseSettings.CurrentSettings.LastCheckedHerb) &&
                                                BaseSettings.CurrentSettings.BehaviorHerbGather);
                herbingArray.DisposalAction = () =>
                {
                    TargetManager.LootType = TargetManager.LootFlags.None;
                };

                retBehaviorList.Add(herbingArray);
                retBehaviorList.Add(new BehaviorWorkOrderPickUp(Buildings[BuildingType.HerbGarden]));
                retBehaviorList.Add(new BehaviorWorkOrderStartUp(Buildings[BuildingType.HerbGarden]));
            }

            #endregion

            #region Professions
            foreach (var profession in Player.Professions.ProfessionSkills.Values.Where(p => p.DailyCooldownSpellIds != null))
            {
                if (profession.Skill == SkillLine.Inscription)
                {
                    retBehaviorList.Add(new BehaviorMilling());
                }

                int[] spellIds = profession.DailyCooldownSpellIds;
                retBehaviorList.Add(new BehaviorCraftingProfession(profession.Skill, spellIds[1]));
                retBehaviorList.Add(new BehaviorCraftingProfession(profession.Skill, spellIds[0]));
            }
            #endregion

            #region Salvaging
            if (Buildings.Values.Any(b => b.Type == BuildingType.SalvageYard))
            {
                retBehaviorList.Add(new BehaviorSalvage());
            }
            #endregion

            #region Work Order Pickup && Startup
            foreach (var b in Buildings.Values.Where(b => b.FirstQuestId <= 0 || b.FirstQuestCompleted).OrderBy(b => b.Plot))
            {
                if (b.Type != BuildingType.Mines || b.Type != BuildingType.HerbGarden)
                {
                    if (b.WorkOrder != null)
                    {
                        retBehaviorList.Add(new BehaviorWorkOrderPickUp(b));

                        if (b.Type == BuildingType.EnchantersStudy)
                        {
                            retBehaviorList.Add(new BehaviorDisenchant()); //Disenchanting!
                        }
                        else if (b.Type == BuildingType.ScribesQuarters)
                        {
                            retBehaviorList.Add(new BehaviorMilling()); //Milling!
                        }
                        else if (b.Type == BuildingType.Barn)
                        {
                            if (Player.Inventory.Trap != null)
                            {
                                GarrisonBase.Log("Adding Trapping Behavior");

                                if (Player.Inventory.Trap.TrapRank > 1)
                                {
                                    retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Elites_Nagrand.Clone());
                                }

                                if (Player.IsAlliance)
                                {
                                    retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Leather_ShadowmoonVally.Clone());
                                    retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Fur_ShadowmoonValley.Clone());
                                }
                                else
                                {
                                    retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Leather_FrostfireRidge.Clone());
                                    retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Fur_Nagrand_Horde.Clone());
                                }

                                retBehaviorList.Add(BehaviorManager.BehaviorArray_Trapping_Boars_Gorgond.Clone());
                            }
                        }

                        retBehaviorList.Add(new BehaviorWorkOrderStartUp(b));

                        if (b.Type == BuildingType.WarMillDwarvenBunker && b.Level == 3)
                        {
                            var questid = Player.IsAlliance ? 38175 : 38188;
                            retBehaviorList.Add(QuestHelper.GetDailyQuestArray(Convert.ToUInt32(questid), Player.IsAlliance));
                        }
                        else if (b.Type == BuildingType.AlchemyLab && b.HasFollowerWorking)
                        {
                            retBehaviorList.Add(QuestHelper.GetDailyQuestArray(Convert.ToUInt32(37270), Player.IsAlliance));
                        }
                    }
                }
            }
            #endregion

            //Primal Spirit Exchange
            retBehaviorList.Add(new BehaviorPrimalTrader());

            var forceBagCheck = new BehaviorCustomAction(() =>
            {
                Common.ForceBagCheck = true;
            });
            retBehaviorList.Add(forceBagCheck);

            //Finally, start some new missions!
            retBehaviorList.Add(new BehaviorMissionStartup());

            //Optional follower behaviors (to unlock)
            retBehaviorList.Add(BehaviorArrayFollowers.Clone());

            return(retBehaviorList.ToArray());
        }
Пример #26
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                from.RevealingAction();

                if (!(targeted is Mobile))
                {
                    from.SendLocalizedMessage(1049528);                       // You cannot calm that!
                }
                else if (!m_Instrument.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1062488);                       // The instrument you are trying to play is no longer in your backpack!
                }
                else
                {
                    m_SetSkillTime     = false;
                    from.NextSkillTime = DateTime.UtcNow + BaseInstrument.GetBardSkillTimeout(SkillName.Peacemaking, from);

                    if (targeted == from)
                    {
                        // Standard mode : reset combatants for everyone in the area

                        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 (!BaseInstrument.CheckBardSkillChance(from, SkillName.Peacemaking, 0.0, 120.0))
                        {
                            from.SendLocalizedMessage(500613);                               // You attempt to calm everyone, but fail.
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                        else
                        {
                            m_Instrument.PlayInstrumentWell(from);
                            m_Instrument.ConsumeUse(from);

                            Map map = from.Map;

                            if (map != null)
                            {
                                int range = BaseInstrument.GetBardRange(from, SkillName.Peacemaking);

                                bool calmed = false;

                                foreach (Mobile m in from.GetMobilesInRange(range))
                                {
                                    if ((m is BaseCreature && ((BaseCreature)m).Uncalmable) || m == from || !from.CanBeHarmful(m, false))
                                    {
                                        continue;
                                    }

                                    calmed = true;

                                    m.SendLocalizedMessage(500616);                                       // You hear lovely music, and forget to continue battling!
                                    m.Combatant = null;
                                    m.Warmode   = false;

                                    if (m is BaseCreature && !((BaseCreature)m).BardPacified)
                                    {
                                        ((BaseCreature)m).Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(1.0));
                                    }
                                }

                                if (!calmed)
                                {
                                    from.SendLocalizedMessage(1049648);                                       // You play hypnotic music, but there is nothing in range for you to calm.
                                }
                                else
                                {
                                    from.SendLocalizedMessage(500615);                                       // You play your hypnotic music, stopping the battle.
                                }
                            }
                        }
                    }
                    else
                    {
                        // Target mode : pacify a single target for a longer duration

                        Mobile targ = (Mobile)targeted;

                        if (!from.CanBeHarmful(targ, false))
                        {
                            from.SendLocalizedMessage(1049528);
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).Uncalmable)
                        {
                            from.SendLocalizedMessage(1049526);                               // You have no chance of calming that creature.
                            m_SetSkillTime = true;
                        }
                        else if (targ is BaseCreature && ((BaseCreature)targ).BardPacified)
                        {
                            from.SendLocalizedMessage(1049527);                               // That creature is already being calmed.
                            m_SetSkillTime = true;
                        }
                        else if (!BaseInstrument.CheckMusicianship(from))
                        {
                            from.SendLocalizedMessage(500612);                               // You play poorly, and there is no effect.
                            m_Instrument.PlayInstrumentBadly(from);
                            m_Instrument.ConsumeUse(from);
                        }
                        else
                        {
                            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.CheckBardSkillChance(from, SkillName.Peacemaking, targ, diff - 25.0, diff + 25.0))
                            {
                                from.SendLocalizedMessage(1049531);                                   // You attempt to calm your target, but fail.
                                m_Instrument.PlayInstrumentBadly(from);
                                m_Instrument.ConsumeUse(from);
                            }
                            else
                            {
                                m_Instrument.PlayInstrumentWell(from);
                                m_Instrument.ConsumeUse(from);

                                if (targ is BaseCreature)
                                {
                                    BaseCreature bc = (BaseCreature)targ;

                                    from.SendLocalizedMessage(1049532);                                       // You play hypnotic music, calming your target.

                                    targ.Combatant = null;
                                    targ.Warmode   = false;

                                    double seconds = 100 - (diff / 1.5);
                                    Utility.FixMinMax(ref seconds, 10, 120);

                                    bc.Pacify(from, DateTime.UtcNow + TimeSpan.FromSeconds(seconds));

                                    PlayerMobile pm = from as PlayerMobile;

                                    if (pm != null)
                                    {
                                        QuestHelper.OnCalmed(pm, targ);
                                    }
                                }
                                else
                                {
                                    from.SendLocalizedMessage(1049532);                                      // You play hypnotic music, calming your target.

                                    targ.SendLocalizedMessage(500616);                                       // You hear lovely music, and forget to continue battling!
                                    targ.Combatant = null;
                                    targ.Warmode   = false;
                                }
                            }
                        }
                    }
                }
            }
 private QuestOfSingularity GetSingularityQuest(PlayerMobile pm)
 {
     return(QuestHelper.GetQuest(pm, typeof(QuestOfSingularity)) as QuestOfSingularity);
 }
Пример #28
0
        public override void OnDoubleClick(Mobile m)
        {
            if (m is PlayerMobile && m.InRange(Location, 5))
            {
                GoingGumshoeQuest quest = QuestHelper.GetQuest <GoingGumshoeQuest>((PlayerMobile)m);

                if (quest != null && quest.Completed)
                {
                    quest.GiveRewards();

                    BaseQuest newquest = QuestHelper.RandomQuest((PlayerMobile)m, new Type[] { typeof(GoingGumshoeQuest2) }, this);

                    if (newquest != null)
                    {
                        m.SendGump(new MondainQuestGump(newquest));
                    }
                }
                else
                {
                    GoingGumshoeQuest2 quest2 = QuestHelper.GetQuest <GoingGumshoeQuest2>((PlayerMobile)m);

                    if (quest2 != null)
                    {
                        if (quest2.IsComplete)
                        {
                            quest2.Objectives[0].CurProgress++;
                            quest2.GiveRewards(); // TODO: Does this quest end here?

                            BaseQuest newquest = QuestHelper.RandomQuest((PlayerMobile)m, new Type[] { typeof(GoingGumshoeQuest3) }, this);

                            if (newquest != null)
                            {
                                m.SendGump(new MondainQuestGump(newquest));
                            }
                        }
                        else
                        {
                            m.SendGump(new MondainQuestGump(quest2, MondainQuestGump.Section.InProgress, false));
                            quest2.InProgress();
                        }
                    }
                    else
                    {
                        GoingGumshoeQuest3 quest3 = QuestHelper.GetQuest <GoingGumshoeQuest3>((PlayerMobile)m);

                        if (quest3 != null)
                        {
                            if (quest3.IsComplete)
                            {
                                quest3.Objectives[0].CurProgress++;
                                quest3.GiveRewards(); // TODO: Does this quest end here?

                                BaseQuest newquest = QuestHelper.RandomQuest((PlayerMobile)m, new Type[] { typeof(GoingGumshoeQuest4) }, this);

                                if (newquest != null)
                                {
                                    m.SendGump(new MondainQuestGump(newquest));
                                }
                            }
                            else
                            {
                                m.SendGump(new MondainQuestGump(quest3, MondainQuestGump.Section.InProgress, false));
                                quest3.InProgress();
                            }
                        }
                        else
                        {
                            GoingGumshoeQuest4 quest4 = QuestHelper.GetQuest <GoingGumshoeQuest4>((PlayerMobile)m);

                            if (quest4 != null && !quest4.IsComplete)
                            {
                                m.SendGump(new MondainQuestGump(quest4, MondainQuestGump.Section.InProgress, false));
                                quest4.InProgress();
                            }
                            else if (quest4 == null)
                            {
                                SayTo(m, 1080107); // I'm sorry, I have nothing for you at this time.
                            }
                        }
                    }
                }
            }
        }
Пример #29
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)
                            {
                                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.
                }
            }
Пример #30
0
        private static void HandleRespond(GameSession session, PacketReader packet)
        {
            List <QuestStatus> npcQuests = new List <QuestStatus>();
            int objectId = packet.ReadInt();

            // Find if npc object id exists in field manager
            if (!session.FieldManager.State.Npcs.TryGetValue(objectId, out IFieldObject <Npc> npc))
            {
                return;
            }

            // Get all quests for this npc
            foreach (QuestStatus item in session.Player.QuestList.Where(x => !x.Completed))
            {
                if (npc.Value.Id == item.StartNpcId)
                {
                    npcQuests.Add(item);
                }
                if (item.Started && npc.Value.Id == item.CompleteNpcId && !npcQuests.Contains(item))
                {
                    npcQuests.Add(item);
                }
            }
            session.Player.NpcTalk = new NpcTalk(npc.Value, npcQuests);
            ScriptLoader scriptLoader = new ScriptLoader($"Npcs/{npc.Value.Id}", session);

            // If NPC is a shop, load and open the shop
            if (npc.Value.IsShop())
            {
                ShopHandler.HandleOpen(session, npc);
                return;
            }
            else if (npc.Value.IsBank())
            {
                session.Send(HomeBank.OpenBank());
                return;
            }
            else if (npc.Value.IsBeauty())
            {
                NpcMetadata npcTarget = NpcMetadataStorage.GetNpc(session.Player.NpcTalk.Npc.Id);
                if (npcTarget.ShopId == 507) // mirror
                {
                    session.Send(NpcTalkPacket.Respond(npc, NpcType.Default, DialogType.Beauty, 0));
                    HandleBeauty(session);
                    return;
                }

                session.Send(NpcTalkPacket.Respond(npc, NpcType.Default, DialogType.Beauty, 1));
                return;
            }

            // Check if npc has an exploration quest
            QuestHelper.UpdateExplorationQuest(session, npc.Value.Id.ToString(), "talk_in");

            // If npc has quests, send quests and talk option
            if (npcQuests.Count != 0)
            {
                session.Player.NpcTalk.ScriptId = 0;
                session.Send(QuestPacket.SendDialogQuest(objectId, npcQuests));
                session.Send(NpcTalkPacket.Respond(npc, NpcType.Unk2, DialogType.TalkOption, session.Player.NpcTalk.ScriptId));
                return;
            }

            ScriptMetadata scriptMetadata = ScriptMetadataStorage.GetNpcScriptMetadata(npc.Value.Id);

            if (!scriptMetadata.Options.Exists(x => x.Type == ScriptType.Script))
            {
                return;
            }

            int firstScriptId = GetFirstScriptId(scriptLoader, scriptMetadata);

            session.Player.NpcTalk.ScriptId = firstScriptId;

            Option option = scriptMetadata.Options.First(x => x.Id == firstScriptId);

            DialogType dialogType = DialogType.None;

            if (option.Contents[0].Distractor is null)
            {
                dialogType = DialogType.Close1;
            }
            else
            {
                dialogType = DialogType.CloseNextWithDistractor;
            }

            session.Send(NpcTalkPacket.Respond(npc, NpcType.Unk3, dialogType, firstScriptId));

            // If npc has buttonset roulette, send roulette id 13.
            // TODO: Send the correct roulette id
            if (scriptMetadata.Options.Any(x => x.ButtonSet == "roulette"))
            {
                session.Send(NpcTalkPacket.Action(ActionType.OpenWindow, "RouletteDialog", "13"));
            }
        }