Exemple #1
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++;
                    }
                }
            }
        }
 public override void OnSkillDamage(SkillArg arg, SkillAttackResult result, int dmg, int bonusCount)
 {
     if (arg.Caster.ActorType == ActorType.PC && ((DateTime.Now - attackStamp).TotalMinutes > 5 || firstAttacker == null || (firstAttacker?.DistanceToActor(npc) > 200)))
     {
         firstAttacker = arg.Caster as ActorPC;
         attackStamp   = DateTime.Now;
     }
     AI.OnDamage(arg, dmg);
 }