Example #1
0
        public void SendQuestUpdate(Character_quest Quest)
        {
            if (GetPlayer() == null)
                return;

            PacketOut Out = new PacketOut((byte)Opcodes.F_QUEST_UPDATE);
            Out.WriteUInt16(Quest.QuestID);
            Out.WriteByte(Convert.ToByte(Quest.IsDone()));
            Out.WriteByte((byte)Quest._Objectives.Count);
            foreach (Character_Objectives Obj in Quest._Objectives)
            {
                Out.WriteByte((byte)Obj.Count);
            }
            Out.WriteUInt16(0);
            GetPlayer().SendPacket(Out);
        }
Example #2
0
        public void SendQuest(Character_quest CQuest)
        {
            if (CQuest == null)
            {
                Log.Error("QuestsInterface", "SendQuest CQuest == null");
                return;
            }

            PacketOut Packet = new PacketOut((byte)Opcodes.F_QUEST_INFO);
            Packet.WriteUInt16(CQuest.QuestID);
            Packet.WriteByte(0);
            BuildQuestHeader(Packet, CQuest.Quest, true);

            Dictionary<Item_Info, uint> Rewards = GenerateRewards(CQuest.Quest, GetPlayer());

            Packet.WriteByte(CQuest.Quest.ChoiceCount);
            Packet.WriteByte(0);
            Packet.WriteByte((byte)Rewards.Count);

            foreach (KeyValuePair<Item_Info, uint> Kp in Rewards)
            {
                Item.BuildItem(ref Packet, null, Kp.Key, 0, (ushort)Kp.Value);
            }

            Packet.WriteByte(0);

            BuildObjectives(Packet, CQuest._Objectives);

            Packet.WriteByte(1);

            Packet.WritePascalString(CQuest.Quest.Name);
            Packet.WritePascalString("Return to your giver");

            Packet.WriteUInt16(0x006A);
            Packet.WriteUInt16(0x046D);
            Packet.WriteUInt16(0x4D9E);
            Packet.WriteUInt16(0xCB65);

            Packet.Fill(0, 18);

            GetPlayer().SendPacket(Packet);
        }
Example #3
0
        public void Load(Character_quest[] Quests)
        {
            if (Quests == null)
                return;

            foreach (Character_quest Quest in Quests)
            {
                Quest.Quest = WorldMgr.GetQuest(Quest.QuestID);
                if (Quest.Quest == null)
                    continue;

                foreach (Character_Objectives Obj in Quest._Objectives)
                    Obj.Objective = WorldMgr.GetQuestObjective(Obj.ObjectiveID);

                if (!_Quests.ContainsKey(Quest.QuestID))
                    _Quests.Add(Quest.QuestID, Quest);
            }
        }
Example #4
0
        public bool AcceptQuest(Quest Quest)
        {
            if (Quest == null)
                return false;

            if (!CanStartQuest(Quest))
                return false;

            Character_quest CQuest = new Character_quest();
            CQuest.QuestID = Quest.Entry;
            CQuest.Done = false;
            CQuest.CharacterId = GetPlayer().CharacterId;
            CQuest.Quest = Quest;

            foreach(Quest_Objectives QObj in Quest.Objectives)
            {
                Character_Objectives CObj = new Character_Objectives();
                CObj.Quest = CQuest;
                CObj._Count = 0;
                CObj.Objective = QObj;
                CObj.ObjectiveID = QObj.Guid;
                CQuest._Objectives.Add(CObj);
            }

            CharMgr.Database.AddObject(CQuest);
            _Quests.Add(Quest.Entry, CQuest);

            SendQuestState(Quest, QuestCompletion.QUESTCOMPLETION_OFFER);

            // This will make objects lootable if they contain a quest object.
            updateObjects();

            _Owner.EvtInterface.Notify(EventName.ON_ACCEPT_QUEST, _Owner, CQuest);
            return true;
        }
Example #5
0
        public bool AcceptQuest(Quest Quest)
        {
            if (Quest == null)
                return false;

            if (!CanStartQuest(Quest))
                return false;

            Character_quest CQuest = new Character_quest();
            CQuest.QuestID = Quest.Entry;
            CQuest.Done = false;
            CQuest.CharacterID = GetPlayer().CharacterId;
            CQuest.Quest = Quest;

            // F_QUEST_LIST Quests not done
            Character_quest_inprogress IQuest = new Character_quest_inprogress();
            IQuest.QuestID = Quest.Entry;
            IQuest.CharacterID = GetPlayer().CharacterId;
            IQuest.Quest = Quest;

            foreach(Quest_Objectives QObj in Quest.Objectives)
            {
                Character_Objectives CObj = new Character_Objectives();
                CObj.Count = 0;
                CObj.Objective = QObj;
                CObj.ObjectiveID = QObj.Guid;
                CQuest._Objectives.Add(CObj);

                // F_QUEST_LIST Quests not done.
                Character_InProgressObjectives IObj = new Character_InProgressObjectives();
                IObj.Count = 0;
                IObj.Objective = QObj;
                IObj.ObjectiveID = QObj.Guid;
                IQuest._InProgressObjectives.Add(IObj);
            }

            _Quests.Add(Quest.Entry, CQuest);
            CharMgr.Database.AddObject(CQuest);

            // Add Quests into character_quest_inprogress Table.
            _InProgressQuests.Add(Quest.Entry, IQuest);
            CharMgr.Database.AddObject(IQuest);

            SendQuestState(Quest, QuestCompletion.QUESTCOMPLETION_OFFER);
            return true;
        }