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.Count = 0; CObj.Objective = QObj; CObj.ObjectiveID = QObj.Guid; CQuest._Objectives.Add(CObj); } _Quests.Add(Quest.Entry, CQuest); CharMgr.Database.AddObject(CQuest); SendQuestState(Quest, QuestCompletion.QUESTCOMPLETION_OFFER); return(true); }
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); }
public bool AcceptQuest(Quest quest) { if (quest == null) { return(false); } if (!CanStartQuest(quest)) { return(false); } int activeQuestCount = Quests.Values.Count(q => !q.Done); if (activeQuestCount >= MAX_ACTIVE_QUESTS) { GetPlayer().SendClientMessage("Too many quests", ChatLogFilters.CHATLOGFILTERS_C_ABILITY_ERROR); GetPlayer().SendClientMessage("You have too many quests. Please abandon some of them first."); 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.OnAcceptQuest, _Owner, cQuest); return(true); }
public void SendQuestUpdate(Character_quest Quest, Character_Objectives Obj) { 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(Obj.Objective.num); Out.WriteByte((byte)Obj.Count); Out.WriteUInt16(0); GetPlayer().SendPacket(Out); }
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); }
public void HandleEvent(Objective_Type type, uint entry, int count, bool suppressGroupBroadcast = false) { Player player = _Owner as Player; if (!suppressGroupBroadcast) { if (player?.PriorityGroup != null) { Group currentGroup = player.PriorityGroup; foreach (Player member in currentGroup.GetPlayersCloseTo(player, 150)) { if (member != player) { member.QtsInterface.HandleEvent(type, entry, count, true); } } } } if (_Owner is Pet && _Owner.GetPet().Owner != null) { _Owner.GetPet().Owner.QtsInterface.HandleEvent(type, entry, count, true); } // Check every quest a player has... foreach (KeyValuePair <ushort, Character_quest> questKp in Quests) { // For each objective in every quest... foreach (Character_Objectives objective in questKp.Value._Objectives) { if (objective.Objective == null) { continue; } // RB 7/4/2016 Allow objectives to be completed in an order if (objective.Objective.PreviousObj > 0) { Character_Objectives previousObjective = questKp.Value._Objectives.FirstOrDefault(o => o.Objective.Guid == objective.Objective.PreviousObj); if (previousObjective != null && !previousObjective.IsDone()) { continue; } } if (objective.Objective.ObjType == (uint)type && !objective.IsDone()) { if (objective.Objective.PQArea > 0) { bool skip = true; if (player.CurrentKeep != null && player.CurrentKeep.Realm == player.Realm && player.CurrentKeep.Info.PQuest != null && player.CurrentKeep.Info.PQuest.Entry == objective.Objective.PQArea) { skip = false; } else if (PublicQuest != null && PublicQuest.Info.Entry == objective.Objective.PQArea) { skip = false; } if (skip) { continue; } } if (!string.IsNullOrEmpty(objective.Objective.inZones)) { string[] temp = objective.Objective.inZones.Split(','); if (temp != null && (player.Zone == null || !temp.Contains("" + player.Zone.ZoneId))) { continue; } } bool canAdd = false; int newCount = objective.Count; switch (type) { case Objective_Type.QUEST_SPEAK_TO: case Objective_Type.QUEST_KILL_MOB: case Objective_Type.QUEST_PROTECT_UNIT: if (objective.Objective.Creature != null && entry == objective.Objective.Creature.Entry) { canAdd = true; newCount += count; } break; case Objective_Type.QUEST_KILL_GO: if (objective.Objective.GameObject != null && entry == objective.Objective.GameObject.Entry) { canAdd = true; newCount += count; } break; case Objective_Type.QUEST_KILL_PLAYERS: if (objective.Objective != null) { int result; if (int.TryParse(objective.Objective.ObjID, out result)) { if (result == 0 || ((result >> ((byte)entry - 1)) & 1) == 1) { canAdd = true; newCount += count; } } } break; case Objective_Type.QUEST_GET_ITEM: case Objective_Type.QUEST_USE_ITEM: if (objective.Objective.Item != null && entry == objective.Objective.Item.Entry) { canAdd = true; newCount = _Owner.GetPlayer().ItmInterface.GetItemCount(entry); } break; case Objective_Type.QUEST_USE_GO: if (objective.Objective.GameObject != null && entry == objective.Objective.GameObject.Entry) { // This will turn off Interactable flag on clicked GO, some more work can be // done with GO despawning and UNKs[3] unk modification // Default respawn time: 60 seconds Object target = player.CbtInterface.GetCurrentTarget(); if (target != null) { GameObject go = target.GetGameObject(); if (go != null && go.IsGameObject()) { if (go.Spawn.AllowVfxUpdate == 1) { go.VfxState = 1; } go.Interactable = false; go.EvtInterface.AddEvent(MakeGOInteractable, 60000, 1, target); } } canAdd = true; newCount += count; } break; case Objective_Type.QUEST_WIN_SCENARIO: if (objective.Objective.Scenario != null && entry == objective.Objective.Scenario.ScenarioId) { canAdd = true; newCount += count; } break; case Objective_Type.QUEST_CAPTURE_BO: if (objective.Objective.BattleFrontObjective != null && entry == objective.Objective.BattleFrontObjective.Entry) { canAdd = true; newCount += count; } break; case Objective_Type.QUEST_CAPTURE_KEEP: if (objective.Objective.Keep != null && entry == objective.Objective.Keep.KeepId) { canAdd = true; newCount += count; } break; default: if (objective.Objective.Guid == entry) { canAdd = true; newCount += count; } break; } 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.ObjectsInRange) { if (obj.IsCreature()) { finisher = obj.GetCreature(); if (QuestService.HasQuestToFinish(finisher.Entry, questKp.Value.Quest.Entry)) { finisher.SendMeTo(_Owner.GetPlayer()); } } } } } } } } }