mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Tasks] Implement Task Goal Match List (#2097)
* [Tasks] Implement Task Goal Match List * Migration * Add npc_type_id to match types for npc kill * Flip str_tolower
This commit is contained in:
+1
-1
@@ -2445,7 +2445,7 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
give_exp_client->GetCleanName(),
|
||||
GetNPCTypeID()
|
||||
);
|
||||
task_manager->HandleUpdateTasksOnKill(give_exp_client, GetNPCTypeID());
|
||||
task_manager->HandleUpdateTasksOnKill(give_exp_client, GetNPCTypeID(), GetCleanName());
|
||||
}
|
||||
|
||||
if (kr) {
|
||||
|
||||
@@ -644,6 +644,9 @@ bool ClientTaskState::UpdateTasksByNPC(Client *client, TaskActivityType activity
|
||||
if (!task_manager->m_goal_list_manager.IsInList(
|
||||
activity_info->goal_id,
|
||||
npc_type_id
|
||||
) && !TaskGoalListManager::IsInMatchList(
|
||||
activity_info->goal_match_list,
|
||||
std::to_string(npc_type_id)
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
@@ -827,6 +830,9 @@ void ClientTaskState::UpdateTasksForItem(Client *client, TaskActivityType activi
|
||||
if (!task_manager->m_goal_list_manager.IsInList(
|
||||
activity_info->goal_id,
|
||||
item_id
|
||||
) && !TaskGoalListManager::IsInMatchList(
|
||||
activity_info->goal_match_list,
|
||||
std::to_string(item_id)
|
||||
)) { continue; }
|
||||
break;
|
||||
|
||||
@@ -896,6 +902,9 @@ void ClientTaskState::UpdateTasksOnExplore(Client *client, int explore_id)
|
||||
if (!task_manager->m_goal_list_manager.IsInList(
|
||||
activity_info->goal_id,
|
||||
explore_id
|
||||
) && !TaskGoalListManager::IsInMatchList(
|
||||
activity_info->goal_match_list,
|
||||
std::to_string(explore_id)
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
@@ -999,7 +1008,11 @@ bool ClientTaskState::UpdateTasksOnDeliver(
|
||||
case METHODLIST:
|
||||
if (!task_manager->m_goal_list_manager.IsInList(
|
||||
activity_info->goal_id,
|
||||
item->GetID())) {
|
||||
item->GetID()
|
||||
) && !TaskGoalListManager::IsInMatchList(
|
||||
activity_info->goal_match_list,
|
||||
std::to_string(item->GetID())
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
@@ -2227,7 +2240,7 @@ void ClientTaskState::RemoveTaskByTaskID(Client *client, uint32 task_id)
|
||||
}
|
||||
case TaskType::Quest: {
|
||||
for (int active_quest = 0; active_quest < MAXACTIVEQUESTS; active_quest++) {
|
||||
if (m_active_quests[active_quest].task_id == task_id) {
|
||||
if (m_active_quests[active_quest].task_id == task_id) {
|
||||
LogTasks("[UPDATE] RemoveTaskByTaskID found Quest [{}] at index [{}]", task_id, active_quest);
|
||||
CancelTask(client, active_quest, TaskType::Quest, true);
|
||||
}
|
||||
|
||||
@@ -147,3 +147,26 @@ bool TaskGoalListManager::IsInList(int list_id, int entry)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskGoalListManager::IsInMatchList(const std::string& match_list, const std::string& entry)
|
||||
{
|
||||
for (auto &s: SplitString(match_list, '|')) {
|
||||
if (s == entry) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TaskGoalListManager::IsInMatchListPartial(const std::string &match_list, const std::string &entry)
|
||||
{
|
||||
std::string entry_match = str_tolower(entry);
|
||||
for (auto &s: SplitString(match_list, '|')) {
|
||||
if (entry_match.find(str_tolower(s)) != std::string::npos) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ public:
|
||||
bool IsInList(int list_id, int entry);
|
||||
int GetFirstEntry(int list_id);
|
||||
std::vector<int> GetListContents(int list_index);
|
||||
static bool IsInMatchList(const std::string& match_list, const std::string& entry);
|
||||
static bool IsInMatchListPartial(const std::string& match_list, const std::string& entry);
|
||||
|
||||
private:
|
||||
std::vector<TaskGoalList_Struct> m_task_goal_lists;
|
||||
|
||||
@@ -233,6 +233,7 @@ bool TaskManager::LoadTasks(int single_task)
|
||||
activity_data->description_override = task_activity.description_override;
|
||||
activity_data->goal_id = task_activity.goalid;
|
||||
activity_data->goal_method = (TaskMethodType) task_activity.goalmethod;
|
||||
activity_data->goal_match_list = task_activity.goal_match_list;
|
||||
activity_data->goal_count = task_activity.goalcount;
|
||||
activity_data->deliver_to_npc = task_activity.delivertonpc;
|
||||
|
||||
@@ -1815,7 +1816,7 @@ void TaskManager::SyncClientSharedTaskStateToLocal(
|
||||
}
|
||||
}
|
||||
|
||||
void TaskManager::HandleUpdateTasksOnKill(Client *client, uint32 npc_type_id)
|
||||
void TaskManager::HandleUpdateTasksOnKill(Client *client, uint32 npc_type_id, std::string npc_name)
|
||||
{
|
||||
for (auto &c: client->GetPartyMembers()) {
|
||||
if (!c->ClientDataLoaded() || !c->HasTaskState()) {
|
||||
@@ -1876,6 +1877,12 @@ void TaskManager::HandleUpdateTasksOnKill(Client *client, uint32 npc_type_id)
|
||||
if (!m_goal_list_manager.IsInList(
|
||||
activity_info->goal_id,
|
||||
(int) npc_type_id
|
||||
) && !TaskGoalListManager::IsInMatchList(
|
||||
activity_info->goal_match_list,
|
||||
std::to_string(npc_type_id)
|
||||
) && !TaskGoalListManager::IsInMatchListPartial(
|
||||
activity_info->goal_match_list,
|
||||
npc_name
|
||||
)) {
|
||||
LogTasksDetail("[HandleUpdateTasksOnKill] Matched list goal");
|
||||
continue;
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ public:
|
||||
// shared tasks
|
||||
void SyncClientSharedTaskState(Client *c, ClientTaskState *cts);
|
||||
|
||||
void HandleUpdateTasksOnKill(Client *client, uint32 npc_type_id);
|
||||
void HandleUpdateTasksOnKill(Client *client, uint32 npc_type_id, std::string npc_name);
|
||||
|
||||
private:
|
||||
TaskGoalListManager m_goal_list_manager;
|
||||
|
||||
Reference in New Issue
Block a user