Ejemplo n.º 1
0
 public void ProcessQuest(ActorPC pc, uint mapID, bool hasCoordinate = false)
 {
     foreach (ushort questID in pc.Quests.Keys)
     {
         Quest quest = pc.Quests[questID];
         if (items.ContainsKey(questID))
         {
             QuestDetail detail = items[questID];
             if (detail.Steps.ContainsKey(quest.NextStep))
             {
                 QuestStep s = detail.Steps[quest.NextStep];
                 foreach (QuestTarget t in s.Targets)
                 {
                     if (t.TargetType == StepTargetType.Map && t.TargetIDs.Contains(mapID) && ((hasCoordinate && t.HasCoordinate) || (!hasCoordinate && !t.HasCoordinate)))
                     {
                         ProcessQuestSub(pc, quest, s, detail);
                         QuestArgument arg = new QuestArgument()
                         {
                             Player = pc,
                             Quest  = quest,
                             Step   = quest.Step
                         };
                         pc.Client().Map.SendEventToAllActorsWhoCanSeeActor(MapEvents.QUEST_UPDATE, arg, pc, false);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void ProcessQuest(ActorPC pc, ushort questID, byte step, Quest quest)
 {
     if (items.ContainsKey(questID))
     {
         QuestDetail detail = items[questID];
         if (detail.Steps.ContainsKey(step))
         {
             QuestStep s = detail.Steps[step];
             foreach (QuestTarget t in s.Targets)
             {
                 if (t.TargetType == StepTargetType.None)
                 {
                     if (quest == null)
                     {
                         quest = new Quest()
                         {
                             QuestID = questID
                         };
                         if (pc.Quests.ContainsKey(questID))
                         {
                             return;
                         }
                         else
                         {
                             pc.Quests[questID] = quest;
                         }
                     }
                     ProcessQuestSub(pc, quest, s, detail);
                     QuestArgument arg = new QuestArgument()
                     {
                         Player = pc,
                         Quest  = quest,
                         Step   = quest.Step
                     };
                     pc.Client().Map.SendEventToAllActorsWhoCanSeeActor(MapEvents.QUEST_UPDATE, arg, pc, false);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        public void ProcessQuest(ActorPC pc, ActorMapObj obj)
        {
            ulong objID = obj.ToULong();

            if (mapObjectMapping.ContainsKey(objID))
            {
                foreach (uint questID in mapObjectMapping[objID].Keys)
                {
                    if (items.ContainsKey(questID))
                    {
                        QuestDetail detail = items[questID];
                        byte        step   = mapObjectMapping[objID][questID];
                        Quest       quest;
                        if (detail.Steps.ContainsKey(step))
                        {
                            QuestStep s     = detail.Steps[step];
                            byte      index = 0;
                            foreach (QuestTarget t in s.Targets)
                            {
                                if (t.TargetType == StepTargetType.MapObject && t.TargetIDs.Contains(obj.ObjectID) && t.TargetMapID == obj.MapID)
                                {
                                    if (s.DropItem > 0)
                                    {
                                        if (pc.HoldingItem != null && s.DropItem == pc.HoldingItem.ObjectID)
                                        {
                                            HoldItemCancel(pc, s.DropItem);
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }

                                    if (pc.Quests.ContainsKey((ushort)questID))
                                    {
                                        quest = pc.Quests[(ushort)questID];
                                    }
                                    else
                                    {
                                        continue;
                                    }

                                    bool finished = ProcessTarget(pc, quest, s, t, t.SpecifyIndex >= 0 ? t.SpecifyIndex : index);
                                    if (finished)
                                    {
                                        ProcessQuestSub(pc, quest, s, detail, 0);
                                    }
                                    else
                                    {
                                        UpdateQuest(pc, quest);
                                    }

                                    QuestArgument arg = new QuestArgument()
                                    {
                                        Player = pc,
                                        Quest  = quest,
                                        Step   = quest.Step
                                    };
                                    pc.Client().Map.SendEventToAllActorsWhoCanSeeActor(MapEvents.QUEST_UPDATE, arg, pc, false);
                                }
                                index++;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void ProcessQuest(ActorPC pc, ushort questID, byte step, Quest quest, ActorNPC npc, bool isLoot = false, bool isHunt = false, int selection = 0, bool party = false)
        {
            if (pc.Party != null && (isLoot || isHunt) && !party)
            {
                foreach (ActorPC i in pc.Party.Members)
                {
                    if (i != pc && !i.Offline && pc.MapInstanceID == i.MapInstanceID && pc.DistanceToActor(pc) < 200)
                    {
                        if (i.Quests.TryGetValue(questID, out Quest q))
                        {
                            ProcessQuest(i, questID, step, q, npc, isLoot, isHunt, selection, true);
                        }
                    }
                }
            }
            if (items.ContainsKey(questID))
            {
                QuestDetail detail = items[questID];
                if (pc.Quests.ContainsKey(questID) && detail.Steps.ContainsKey(pc.Quests[questID].NextStep))
                {
                    QuestStep s     = detail.Steps[pc.Quests[questID].NextStep];
                    byte      index = 0;
                    foreach (QuestTarget t in s.Targets)
                    {
                        if (((t.TargetType == StepTargetType.NPC && !isLoot) || (isLoot && t.TargetType == StepTargetType.Loot)) && t.TargetIDs.Contains(npc.NpcID))
                        {
                            if (s.DropItem > 0 && !isHunt && !isLoot)
                            {
                                if (pc.HoldingItem != null && s.DropItem == pc.HoldingItem.ObjectID)
                                {
                                    HoldItemCancel(pc, s.DropItem);
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            if (quest == null)
                            {
                                quest = new Quest()
                                {
                                    QuestID = questID
                                };
                                if (pc.Quests.ContainsKey(questID))
                                {
                                    return;
                                }
                                else
                                {
                                    pc.Quests[questID] = quest;
                                }
                            }
                            bool finished = ProcessTarget(pc, quest, s, t, t.SpecifyIndex >= 0 ? t.SpecifyIndex : index);

                            if (finished)
                            {
                                ProcessQuestSub(pc, quest, s, detail, selection);
                            }
                            else
                            {
                                UpdateQuest(pc, quest);
                            }

                            QuestArgument arg = new QuestArgument()
                            {
                                Player    = pc,
                                OriginNPC = npc.NpcID,
                                Quest     = quest,
                                Step      = quest.Step
                            };
                            pc.Client().Map.SendEventToAllActorsWhoCanSeeActor(MapEvents.QUEST_UPDATE, arg, pc, false);
                        }
                        index++;
                    }
                }
            }
        }