[Tasks] Add pre-task update event (#2512)

This adds the player EVENT_TASK_BEFORE_UPDATE event which will allow
quests to prevent a source controlled task update by returning non-zero.
This commit is contained in:
hg
2022-10-29 20:46:08 -04:00
committed by GitHub
parent 43ec9dc815
commit 444a4f6744
5 changed files with 16 additions and 1 deletions
+9
View File
@@ -564,6 +564,15 @@ int ClientTaskState::UpdateTasks(Client* client, const TaskUpdateFilter& filter,
if (CanUpdate(client, filter, client_task.task_id, activity, client_activity))
{
auto args = fmt::format("{} {} {}", count, client_activity.activity_id, client_task.task_id);
if (parse->EventPlayer(EVENT_TASK_BEFORE_UPDATE, client, args, 0) != 0)
{
LogTasks("[UpdateTasks] client [{}] task [{}]-[{}] update prevented by quest",
client->GetName(), client_task.task_id, client_activity.activity_id);
continue;
}
LogTasks("[UpdateTasks] client [{}] task [{}] activity [{}] increment [{}]",
client->GetName(), client_task.task_id, client_activity.activity_id, count);