Exemplo n.º 1
0
        public void HandleEvent(Objective_Type Type, uint Entry, int Count, bool Group = false)
        {
            if (!Group && _Owner.IsPlayer() && _Owner.GetPlayer().GetGroup() != null)
            {
                Group Current = _Owner.GetPlayer().GetGroup();

                lock (Current.Members)
                {
                    foreach (Player SubPlayer in Current.Members)
                    {
                        if (SubPlayer != _Owner && SubPlayer.GetDistance(_Owner) < 150)
                        {
                            SubPlayer.QtsInterface.HandleEvent(Type, Entry, Count, true);
                        }
                    }
                }
            }

            foreach (KeyValuePair <ushort, Character_quest> QuestKp in _Quests)
            {
                foreach (Character_Objectives Objective in QuestKp.Value._Objectives)
                {
                    if (Objective.Objective.ObjType == (uint)Type && !Objective.IsDone())
                    {
                        bool CanAdd   = false;
                        int  NewCount = Objective.Count;

                        if (Type == Objective_Type.QUEST_SPEACK_TO || Type == Objective_Type.QUEST_KILL_MOB || Type == Objective_Type.QUEST_PROTECT_UNIT)
                        {
                            if (Objective.Objective.Creature != null && Entry == Objective.Objective.Creature.Entry)
                            {
                                CanAdd    = true;
                                NewCount += Count;
                            }
                        }
                        else if (Type == Objective_Type.QUEST_GET_ITEM)
                        {
                            if (Objective.Objective.Item != null && Entry == Objective.Objective.Item.Entry)
                            {
                                CanAdd   = true;
                                NewCount = _Owner.GetPlayer().ItmInterface.GetItemCount(Entry);
                            }
                        }
                        else if (Type == Objective_Type.QUEST_USE_GO)
                        {
                            if (Objective.Objective.GameObject != null && Entry == Objective.Objective.GameObject.Entry)
                            {
                                CanAdd    = true;
                                NewCount += Count;
                            }
                        }
                        else if (Type == Objective_Type.QUEST_UNKNOWN)
                        {
                            if (Objective.Objective.Guid == Entry)
                            {
                                CanAdd    = true;
                                NewCount += Count;
                            }
                        }

                        if (CanAdd)
                        {
                            Objective.Count     = NewCount;
                            QuestKp.Value.Dirty = true;
                            SendQuestUpdate(QuestKp.Value);
                            CharMgr.Database.SaveObject(QuestKp.Value);

                            if (Objective.IsDone())
                            {
                                Creature Finisher;

                                foreach (Object Obj in _Owner._ObjectRanged)
                                {
                                    if (Obj.IsCreature())
                                    {
                                        Finisher = Obj.GetCreature();
                                        if (WorldMgr.HasQuestToFinish(Finisher.Entry, QuestKp.Value.Quest.Entry))
                                        {
                                            Finisher.SendMeTo(_Owner.GetPlayer());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void Awake()
 {
     _player = GetComponent <SubPlayer>();
 }