Ejemplo n.º 1
0
 public void SetStep(SagaDB.Quest.Step s)
 {
     this.PutUInt(s.ID, 8);
     this.PutByte(2, 12);
     this.PutUInt(s.nextStep, 13);
     this.PutByte(s.Status, 17);
 }
Ejemplo n.º 2
0
 public static byte GetQuestStepStatus(ActorPC pc, uint id, uint step)
 {
     if (id == 0 || step == 0)
     {
         return(0);
     }
     if (pc.QuestTable.ContainsKey(id) == false)
     {
         if (!pc.PersonalQuestTable.ContainsKey(id))
         {
             return(0);
         }
         else
         {
             SagaDB.Quest.Quest quest2 = pc.PersonalQuestTable[id];
             if (quest2.Steps.ContainsKey(step) == false)
             {
                 return(0);
             }
             SagaDB.Quest.Step step3 = quest2.Steps[step];
             return(step3.Status);
         }
     }
     SagaDB.Quest.Quest quest = pc.QuestTable[id];
     if (quest.Steps.ContainsKey(step) == false)
     {
         return(0);
     }
     SagaDB.Quest.Step step2 = quest.Steps[step];
     return(step2.Status);
 }
Ejemplo n.º 3
0
        private void LoadQuest(ref ActorPC aChar)
        {
            string            sqlstr;
            int               i;
            DataRowCollection result = null;

            sqlstr = "SELECT * FROM  quest  WHERE charID=" + aChar.charID + "";
            try
            {
                result = db.GetDataTable(sqlstr).Rows;
            }
            catch (Exception ex)
            {
                Logger.ShowError(" can't get quests from database" + ex.Message, null);
                Logger.ShowError(ex, null);
            }
            aChar.QuestTable         = new Dictionary <uint, SagaDB.Quest.Quest>();
            aChar.PersonalQuestTable = new Dictionary <uint, SagaDB.Quest.Quest>();
            for (i = 0; i < result.Count; i++)
            {
                try
                {
                    Quest.Quest sc = new SagaDB.Quest.Quest();
                    string[]    tmp;
                    tmp = result[i]["step"].ToString().Split(',');
                    for (int j = 0; j < (tmp.Length / 4); j++)
                    {
                        Quest.Step step = new SagaDB.Quest.Step();
                        step.step     = Convert.ToByte(tmp[j * 4]);
                        step.ID       = Convert.ToUInt32(tmp[j * 4 + 1]);
                        step.Status   = Convert.ToByte(tmp[j * 4 + 2]);
                        step.nextStep = Convert.ToUInt32(tmp[j * 4 + 3]);
                        sc.Steps.Add(step.ID, step);
                    }
                    sc.ID = (uint)(int)result[i]["questID"];
                    switch ((byte)result[i]["type"])
                    {
                    case 0:

                        aChar.QuestTable.Add(sc.ID, sc);
                        break;

                    case 1:
                        aChar.PersonalQuestTable.Add(sc.ID, sc);
                        break;
                    }
                }
                catch (Exception)
                {
                }
            }
        }
Ejemplo n.º 4
0
 public static void SetQuestStepStatus(ActorPC pc, uint id, uint step, byte status)
 {
     SagaDB.Quest.QuestType type;
     if (id == 0 || step == 0)
     {
         return;
     }
     SagaDB.Quest.Quest quest;
     if (pc.QuestTable.ContainsKey(id))
     {
         quest = pc.QuestTable[id];
         type  = SagaDB.Quest.QuestType.OfficialQuest;
     }
     else
     {
         if (pc.PersonalQuestTable.ContainsKey(id))
         {
             quest = pc.PersonalQuestTable[id];
             type  = SagaDB.Quest.QuestType.PersonalQuest;
         }
         else
         {
             return;
         }
     }
     if (quest.Steps.ContainsKey(step) == false)
     {
         return;
     }
     SagaDB.Quest.Step step2 = quest.Steps[step];
     step2.Status = status;
     if (status == 2 && step2.nextStep != 0)
     {
         quest.Steps[step2.nextStep].Status = 1;
     }
     MapServer.charDB.UpdateQuest(pc, type, quest);
     Packets.Server.UpdateQuest p = new SagaMap.Packets.Server.UpdateQuest();
     p.SetQuestID(id);
     p.SetStep(step2);
     ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e;
     eh.C.netIO.SendPacket(p, eh.C.SessionID);
 }
Ejemplo n.º 5
0
        private void ProcessTest(MapClient client, string args)
        {
            string[] arg = args.Split(' ');

            Packets.Server.QuestInfo p = new SagaMap.Packets.Server.QuestInfo();
            SagaDB.Quest.Quest quest = new SagaDB.Quest.Quest();
            quest.ID = uint.Parse(arg[0]);
            Dictionary<uint, SagaDB.Quest.Step> steps = new Dictionary<uint, SagaDB.Quest.Step>();
            for (int i = 1; i < arg.Length; i++)
            {
                SagaDB.Quest.Step step = new SagaDB.Quest.Step();
                step.ID = uint.Parse(arg[i]);
                step.step = (byte)i;
                step.Status = 1;
                steps.Add(uint.Parse(arg[i]), step);
            }
            quest.Steps = steps;
            List<SagaDB.Quest.Quest> lists = new List<SagaDB.Quest.Quest>();
            lists.Add(quest);
            p.SetQuestInfo(lists);
            client.netIO.SendPacket(p, client.SessionID);
        }
Ejemplo n.º 6
0
        private void LoadQuest( ref ActorPC aChar )
        {
            string sqlstr;
            int i;
            DataRowCollection result = null;
            sqlstr = "SELECT * FROM  quest  WHERE charID=" + aChar.charID + "";
            try
            {
                result = db.GetDataTable(sqlstr).Rows;
            }
            catch (Exception ex)
            {
                Logger.ShowError( " can't get quests from database" + ex.Message, null );
                Logger.ShowError( ex, null );
            }
            aChar.QuestTable = new Dictionary<uint, SagaDB.Quest.Quest>();
            aChar.PersonalQuestTable = new Dictionary<uint, SagaDB.Quest.Quest>();
            for( i = 0; i < result.Count; i++ )
            {
                try
                {
                    Quest.Quest sc = new SagaDB.Quest.Quest();
                    string[] tmp;
                    tmp = result[i]["step"].ToString().Split(',');
                    for (int j = 0; j < (tmp.Length / 4); j++)
                    {
                        Quest.Step step = new SagaDB.Quest.Step();
                        step.step = Convert.ToByte(tmp[j * 4]);
                        step.ID = Convert.ToUInt32(tmp[j * 4 + 1]);
                        step.Status = Convert.ToByte(tmp[j * 4 + 2]);
                        step.nextStep = Convert.ToUInt32(tmp[j * 4 + 3]);
                        sc.Steps.Add(step.ID, step);
                    }
                    sc.ID = (uint)(int)result[i]["questID"];
                    switch ((byte)result[i]["type"])
                    {
                        case 0:

                            aChar.QuestTable.Add(sc.ID, sc);
                            break;
                        case 1:
                            aChar.PersonalQuestTable.Add(sc.ID, sc);
                            break;
                    }
                }
                catch (Exception)
                {

                }
            }
        }
Ejemplo n.º 7
0
 private static void UpdateQuestItemSub(ActorPC pc, SagaDB.Quest.Quest quest, bool maploaded)
 {
     ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e;
     if (quest == null)
     {
         return;
     }
     if (!QuestItem.ContainsKey(quest.ID))
     {
         return;
     }
     foreach (uint i in quest.Steps.Keys)
     {
         if (GetQuestStepStatus(pc, quest.ID, i) == 1)
         {
             if (!QuestItem[quest.ID].ContainsKey(i))
             {
                 return;
             }
             bool completed         = true;
             SagaDB.Quest.Step step = quest.Steps[i];
             foreach (questI q in QuestItem[quest.ID][i])
             {
                 List <SagaDB.Items.Item> l = pc.inv.GetInventoryList();
                 if (step.SubSteps == null)
                 {
                     step.SubSteps = new Dictionary <byte, byte>();
                 }
                 if (!step.SubSteps.ContainsKey(q.SubSID))
                 {
                     step.SubSteps.Add(q.SubSID, 0);
                 }
                 foreach (SagaDB.Items.Item j in l)
                 {
                     if (j.id == q.id)
                     {
                         if (step.SubSteps[q.SubSID] >= q.ammount)
                         {
                             if (maploaded)
                             {
                                 Packets.Server.UpdateQuestSubStep p2 = new SagaMap.Packets.Server.UpdateQuestSubStep();
                                 p2.SetQuestID(quest.ID);
                                 p2.SetStep(i);
                                 if (q.SubSID != 0)
                                 {
                                     p2.SetSubStep((byte)(q.SubSID - 1));
                                 }
                                 p2.SetAmmount(j.stack);
                                 eh.C.netIO.SendPacket(p2, eh.C.SessionID);
                             }
                             continue;
                         }
                         Packets.Server.UpdateQuestSubStep p1 = new SagaMap.Packets.Server.UpdateQuestSubStep();
                         p1.SetQuestID(quest.ID);
                         p1.SetStep(i);
                         if (q.SubSID != 0)
                         {
                             p1.SetSubStep((byte)(q.SubSID - 1));
                         }
                         p1.SetAmmount(j.stack);
                         eh.C.netIO.SendPacket(p1, eh.C.SessionID);
                         step.SubSteps[q.SubSID] = j.stack;
                     }
                 }
             }
             foreach (questI j in QuestItem[quest.ID][i])
             {
                 if (step.SubSteps[j.SubSID] < j.ammount)
                 {
                     completed = false;
                 }
             }
             if (completed)
             {
                 SetQuestStepStatus(pc, quest.ID, i, 2);
             }
         }
     }
 }
Ejemplo n.º 8
0
 private static void UpdateEnemyInfoSub(ActorPC pc, uint MobID, SagaDB.Quest.Quest quest, bool maploded)
 {
     ActorEventHandlers.PC_EventHandler eh = (SagaMap.ActorEventHandlers.PC_EventHandler)pc.e;
     if (quest == null)
     {
         return;
     }
     if (!Enemys.ContainsKey(quest.ID))
     {
         return;
     }
     foreach (uint i in quest.Steps.Keys)
     {
         if (GetQuestStepStatus(pc, quest.ID, i) == 1)
         {
             if (!Enemys[quest.ID].ContainsKey(i))
             {
                 return;
             }
             bool completed         = true;
             SagaDB.Quest.Step step = quest.Steps[i];
             foreach (EnemyInfo q in Enemys[quest.ID][i])
             {
                 if (step.SubSteps == null)
                 {
                     step.SubSteps = new Dictionary <byte, byte>();
                 }
                 if (!step.SubSteps.ContainsKey(q.SubSID))
                 {
                     step.SubSteps.Add(q.SubSID, 0);
                 }
                 if (q.id.Contains(MobID))
                 {
                     if (step.SubSteps[q.SubSID] >= q.ammount)
                     {
                         if (maploded)
                         {
                             Packets.Server.UpdateQuestSubStep p2 = new SagaMap.Packets.Server.UpdateQuestSubStep();
                             p2.SetQuestID(quest.ID);
                             p2.SetStep(i);
                             if (q.SubSID != 0)
                             {
                                 p2.SetSubStep((byte)(q.SubSID - 1));
                             }
                             p2.SetAmmount(step.SubSteps[q.SubSID]);
                             eh.C.netIO.SendPacket(p2, eh.C.SessionID);
                         }
                         continue;
                     }
                     step.SubSteps[q.SubSID]++;
                     Packets.Server.UpdateQuestSubStep p1 = new SagaMap.Packets.Server.UpdateQuestSubStep();
                     p1.SetQuestID(quest.ID);
                     p1.SetStep(i);
                     if (q.SubSID != 0)
                     {
                         p1.SetSubStep((byte)(q.SubSID - 1));
                     }
                     p1.SetAmmount(step.SubSteps[q.SubSID]);
                     eh.C.netIO.SendPacket(p1, eh.C.SessionID);
                 }
             }
             foreach (EnemyInfo j in Enemys[quest.ID][i])
             {
                 if (step.SubSteps[j.SubSID] < j.ammount)
                 {
                     completed = false;
                 }
             }
             if (completed)
             {
                 SetQuestStepStatus(pc, quest.ID, i, 2);
             }
         }
     }
 }