Ejemplo n.º 1
0
 public static void BuildQuestComplete(PacketOut Out, Quest Q, bool Particular)
 {
     Out.WritePascalString(Q.Name);
     Out.WriteUInt16((UInt16)Q.OnCompletionQuest.Length);
     Out.WriteStringBytes(Q.OnCompletionQuest);
     if (Particular)
     {
         Out.WriteUInt16((UInt16)Q.Particular.Length);
         Out.WriteStringBytes(Q.Particular);
     }
     Out.WriteByte(1);
     Out.WriteUInt32(Q.Gold);
     Out.WriteUInt32(Q.Xp);
 }
Ejemplo n.º 2
0
        public static void GenerateObjectif(Quest_Objectives Obj, Quest Q)
        {
            switch ((Objective_Type)Obj.ObjType)
            {
                case Objective_Type.QUEST_KILL_PLAYERS:
                    {
                        if(Obj.Description.Length < 1)
                            Obj.Description = "Enemy Players";
                    }break;

                case Objective_Type.QUEST_SPEACK_TO:
                    goto case Objective_Type.QUEST_KILL_MOB;

                case Objective_Type.QUEST_KILL_MOB:
                    {
                        uint ObjID = 0;
                        uint.TryParse(Obj.ObjID, out ObjID);

                        if(ObjID != 0)
                            Obj.Creature = GetCreatureProto(ObjID);

                        if (Obj.Description.Length < 1 && Obj.Creature != null)
                            Obj.Description = Obj.Creature.Name;
                    } break;

                case Objective_Type.QUEST_GET_ITEM:
                    {
                        uint ObjID = 0;
                        uint.TryParse(Obj.ObjID, out ObjID);

                        if (ObjID != 0)
                            Obj.Item = GetItem_Info(ObjID);
                    }
                    break;
            };
        }
Ejemplo n.º 3
0
        static public Dictionary<Item_Info,uint> GenerateRewards(Quest Q, Player Plr)
        {
            Dictionary<Item_Info,uint> Rewards = new Dictionary<Item_Info,uint>();

            foreach (KeyValuePair<Item_Info, uint> Kp in Q.Rewards)
                if (ItemsInterface.CanUse(Kp.Key, Plr, true, false, false, false, false))
                    Rewards.Add(Kp.Key, Kp.Value);

            return Rewards;
        }
Ejemplo n.º 4
0
        public void SendQuestState(Quest Quest,QuestCompletion State)
        {
            PacketOut Out = new PacketOut((byte)Opcodes.F_QUEST_LIST_UPDATE);
            Out.WriteUInt16(Quest.Entry);

            if (State == QuestCompletion.QUESTCOMPLETION_ABANDONED || State == QuestCompletion.QUESTCOMPLETION_DONE)
                Out.WriteByte(0);
            else
                Out.WriteByte(1);

            Out.WriteByte((byte)(State == QuestCompletion.QUESTCOMPLETION_DONE ? 1 : 0));

            Out.WriteUInt32(0x0000FFFF);
            Out.WritePascalString(Quest.Name);
            Out.WriteByte(0);
            GetPlayer().SendPacket(Out);
        }
Ejemplo n.º 5
0
 public void BuildQuest(PacketOut Out, Quest Q)
 {
     Out.WriteByte(Q.ChoiceCount);
     Out.WriteByte(0);
 }
Ejemplo n.º 6
0
        static public void BuildQuestRewards(PacketOut Out, Player Plr, Quest Q)
        {
            Dictionary<Item_Info, uint> Choices = GenerateRewards(Q, Plr);

            Out.WriteByte(Math.Min(Q.ChoiceCount,(byte)Choices.Count));
            Out.WriteByte(0);
            Out.WriteByte((byte)Choices.Count);

            foreach (KeyValuePair<Item_Info, uint> Kp in Choices)
                Item.BuildItem(ref Out, null, Kp.Key, 0, (ushort)Kp.Value);
        }
Ejemplo n.º 7
0
        static public void BuildQuestInProgress(PacketOut Out, Quest Q, bool Particular)
        {
            Out.WritePascalString(Q.Name);

            if (Q.ProgressText.Length > 0)
            {
                Out.WriteUInt16((UInt16)Q.ProgressText.Length);
                Out.WriteStringBytes(Q.ProgressText);
            }
            else
            {
                Out.WriteUInt16((UInt16)Q.Particular.Length);
                Out.WriteStringBytes(Q.Particular);
            }

            Out.WriteByte(1);
        }
Ejemplo n.º 8
0
        static public void BuildQuestHeader(PacketOut Out, Quest Q, bool Particular)
        {
            Out.WritePascalString(Q.Name);
            Out.WriteUInt16((UInt16)Q.Description.Length);
            Out.WriteStringBytes(Q.Description);
            if (Particular)
            {
                Out.WriteUInt16((UInt16)Q.Particular.Length);
                Out.WriteStringBytes(Q.Particular);
            }
            Out.WriteByte(1);
            Out.WriteUInt32(Q.Gold);
            Out.WriteUInt32(Q.Xp);

        }
Ejemplo n.º 9
0
        static public void BuildQuestInfo(PacketOut Out, Player Plr, Quest Q)
        {
            BuildQuestHeader(Out, Q, true);

            BuildQuestRewards(Out, Plr, Q);

            BuildObjectives(Out, Q.Objectives);

            Out.WriteByte(0);
        }
Ejemplo n.º 10
0
        public void FinishQuest(Quest Quest)
        {
            if (Quest == null)
                return;

            if (!HasFinishQuest(Quest.Entry))
                return;
        }
Ejemplo n.º 11
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;
        }
Ejemplo n.º 12
0
        public bool CanEndQuest(Quest Quest)
        {
            if (GetPlayer() == null)
                return false;

            if (Quest == null)
                return false;

            if (!HasQuest(Quest.Entry) || !HasFinishQuest(Quest.Entry) || HasDoneQuest(Quest.Entry))
                return false;

            return true;
        }
Ejemplo n.º 13
0
        public bool CanStartQuest(Quest Quest)
        {
            if(GetPlayer() == null)
                return false;

            if (Quest == null)
                return false;

            // TODO : Fixe Starting Quests
            if (HasQuest(Quest.Entry) || Quest.Level > (GetPlayer().Level+1) || (Quest.PrevQuest != 0 && !HasDoneQuest(Quest.PrevQuest)))
                return false;

            return true;
        }
Ejemplo n.º 14
0
        public bool CanStartQuest(Quest Quest)
        {
            if(GetPlayer() == null)
                return false;

            if (Quest == null)
                return false;

            if (HasQuest(Quest.Entry) || Quest.Level > GetPlayer().Level || (Quest.PrevQuest != 0 && !HasDoneQuest(Quest.PrevQuest)))
                return false;

            return true;
        }
Ejemplo n.º 15
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;
        }
Ejemplo n.º 16
0
        static public void GenerateObjectif(Quest_Objectives Obj, Quest Q)
        {
            switch ((Objective_Type)Obj.ObjType)
            {
                case Objective_Type.QUEST_KILL_PLAYERS:
                    {
                        if(Obj.Description.Length < 1)
                            Obj.Description = "Enemy Players";
                    }break;

                case Objective_Type.QUEST_SPEACK_TO:
                    {
                        uint ObjID = 0;
                        uint.TryParse(Obj.ObjID, out ObjID);
 
                        if(ObjID != 0)
                            Obj.Creature = GetCreatureProto(ObjID);

                        if (Obj.Creature == null)
                        {
                            Obj.Description = "Invalid Npc,plz report to GM. QuestID " + Obj.Entry + ",ObjId=" + Obj.ObjID;
                        }
                        else
                        {
                            if (Obj.Description == null || Obj.Description.Length <= Obj.Creature.Name.Length)
                                Obj.Description = "Speak to " + Obj.Creature.Name;
                        }

                    } break;

                case Objective_Type.QUEST_USE_GO:
                    {
                        uint ObjID = 0;
                        uint.TryParse(Obj.ObjID, out ObjID);

                        if (ObjID != 0)
                            Obj.GameObject = GetGameObjectProto(ObjID);

                        if (Obj.GameObject == null)
                        {
                            Obj.Description = "Invalid Go,plz report to GM. QuestID " + Obj.Entry + ",ObjId=" + Obj.ObjID;
                        }
                        else
                        {
                            if (Obj.Description == null || Obj.Description.Length <= Obj.GameObject.Name.Length)
                                Obj.Description = "Find " + Obj.GameObject.Name;
                        }

                    } break;

                case Objective_Type.QUEST_KILL_MOB:
                    {
                        uint ObjID = 0;
                        uint.TryParse(Obj.ObjID, out ObjID);

                        if(ObjID != 0)
                            Obj.Creature = GetCreatureProto(ObjID);

                        if (Obj.Creature == null)
                        {
                            Obj.Description = "Invalid Creature,plz report to GM. QuestID " + Obj.Entry + ",ObjId=" + Obj.ObjID;
                        }
                        else
                        {
                            if (Obj.Description == null || Obj.Description.Length <= Obj.Creature.Name.Length)
                                Obj.Description = "Kill " + Obj.Creature.Name;
                        }

                    } break;

                case Objective_Type.QUEST_GET_ITEM:
                    {
                        uint ObjID = 0;
                        uint.TryParse(Obj.ObjID, out ObjID);

                        if (ObjID != 0)
                        {
                            Obj.Item = GetItem_Info(ObjID);
                            if (Obj.Item == null)
                            {
                                int a =Obj.Quest.Particular.ToLower().IndexOf("kill the ");
                                if (a >= 0)
                                {
                                    string[] RestWords = Obj.Quest.Particular.Substring(a + 9).Split(' ');
                                    string Name = RestWords[0] + " " + RestWords[1];
                                    Creature_proto Proto = GetCreatureProtoByName(Name);
                                    if (Proto == null)
                                        Proto = GetCreatureProtoByName(RestWords[0]);
                                    if (Proto != null)
                                    {
                                        Obj.Item = new Item_Info();
                                        Obj.Item.Entry = ObjID;
                                        Obj.Item.Name = Obj.Description;
                                        Obj.Item.MaxStack = 20;
                                        Obj.Item.ModelId = 531;
                                        _Item_Info.Add(Obj.Item.Entry, Obj.Item);

                                        Log.Info("WorldMgr", "Creating Quest(" + Obj.Entry + ") Item : " + Obj.Item.Entry + ",  " + Obj.Item.Name + "| Adding Loot to : " + Proto.Name);
                                        Creature_loot loot = new Creature_loot();
                                        loot.Entry = Proto.Entry;
                                        loot.ItemId = Obj.Item.Entry;
                                        loot.Info = Obj.Item;
                                        loot.Pct = 0;
                                        GetLoots(Proto.Entry).Add(loot);
                                    }
                                }
                            }
                        }
                    }
                    break;
            };
        }