public void Increment() { if (ObjectiveProgress + 1 < World.instance.quests[Quest_ID].Objective_Target) { ++ObjectiveProgress; SendData.UpdateQuestLog(this); } else if (ObjectiveProgress + 1 >= World.instance.quests[Quest_ID].Objective_Target) { ++ObjectiveProgress; Status = QuestStatus.Finished; SendData.UpdateQuestLog(this); } }
private static void QuestInteract(ConnectionType type, int index, byte[] data) { ByteBuffer.ByteBuffer buffer = new ByteBuffer.ByteBuffer(); buffer.WriteBytes(data); ReadHeader(ref buffer); int Character_ID = buffer.ReadInteger(); int NPC_ID = buffer.ReadInteger(); if (MathF.Distance(World.instance.players[Character_ID], World.instance.GetNPCByEntityID(NPC_ID)) <= World.InteractionDistance) { World.instance.UpdateQuestLog(Character_ID); bool Create = false; QuestReturn qr = World.instance.GetQuestContentByNPCEntityID(Character_ID, NPC_ID, out Create); Quest_Log ql = null; ql = World.instance.GetQuestLog(Character_ID, qr.Quest_ID); if (qr.Null != true && ql != null) { switch (qr.Status) { case QuestStatus.None: break; case QuestStatus.InProgress: if (ql.ObjectiveProgress >= qr.Target) { World.instance.GetQuestLog(Character_ID, qr.Quest_ID).Status = QuestStatus.Finished; qr = World.instance.GetQuestContentByNPCEntityID(Character_ID, NPC_ID, out Create); SendData.QuestInteractConfirm(index, true, ql.Status, qr.NPC_ID, ql.Quest_ID); SendData.UpdateQuestLog(ql); } else { SendData.QuestInteractConfirm(index, false); } break; case QuestStatus.Complete: SendData.QuestInteractConfirm(index, false); break; case QuestStatus.Finished: World.instance.GetQuestLog(Character_ID, qr.Quest_ID).Status = QuestStatus.Complete; qr = World.instance.GetQuestContentByNPCEntityID(Character_ID, NPC_ID, out Create); SendData.QuestInteractConfirm(index, true, ql.Status, qr.NPC_ID, ql.Quest_ID); SendData.UpdateQuestLog(ql); if (World.instance.players.ContainsKey(Character_ID)) { World.instance.players[Character_ID].experience += World.instance.quests[ql.Quest_ID].Experience; } // Get the next quest in the series List <Quest> q = World.instance.GetAvailableQuests(Character_ID); if (q != null && q.Count > 0) { foreach (Quest qu in q) { // Create a new quest log for it Quest_Log newql = new Quest_Log(-1, Character_ID, qu.ID, QuestStatus.Available, 0); // Update the synchronization server SendData.CreateQuestLog(newql); // Notify the client that a new quest is available SendData.UpdateQuestLog(index, qu.ID, newql.Quest_Log_ID, World.instance.GetNPCEntityID(qu.NPC_Start_ID), newql.Status, newql.ObjectiveProgress, qu.Objective_Target); } } break; case QuestStatus.Available: if (qr.Target == -1) { World.instance.GetQuestLog(Character_ID, qr.Quest_ID).Status = QuestStatus.Finished; qr = World.instance.GetQuestContentByNPCEntityID(Character_ID, NPC_ID, out Create); World.instance.UpdateQuestLog(Character_ID); } else { World.instance.GetQuestLog(Character_ID, qr.Quest_ID).Status = QuestStatus.InProgress; qr = World.instance.GetQuestContentByNPCEntityID(Character_ID, NPC_ID, out Create); World.instance.UpdateQuestLog(Character_ID); } SendData.QuestInteractConfirm(index, true, ql.Status, qr.NPC_ID, ql.Quest_ID); SendData.UpdateQuestLog(ql); break; default: break; } } else { SendData.QuestInteractConfirm(index, false); } } else { SendData.QuestInteractConfirm(index, false); } World.instance.UpdateQuestLog(Character_ID); }