mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Quest API] Add apis to end shared tasks (#2521)
This required some minor shared task refactoring - Shared task expiration handling was moved to world. Previously this was handled by zone and had clients self remove when a shared task expired. This resulted in wrong messages when a task ended. - FailTask is now implemented for shared tasks which previously only made the client quit the shared task. It now fails the task for all members by ending the shared task. The `Client::EndSharedTask` api will end the client's current shared task (removing all members). This is similiar to the `FailTask` api except it doesn't require a `task_id` and the red task fail banner is optional (live doesn't use it for shared tasks). The global `end_dz_task` api was added for when a client context isn't available. This will end a shared task if the current zone is a dynamic zone for a shared task mission. Currently only shared tasks use dynamic zones but this api can be expanded if support is added for tasks/quests. The global `get_dz_task_id` was added to conveniently get the task id for the current dynamic zone if it's used for a mission. Note this is a database hit since that information is not available at zone level.
This commit is contained in:
+10
-21
@@ -1122,16 +1122,12 @@ void ClientTaskState::FailTask(Client *client, int task_id)
|
||||
return;
|
||||
}
|
||||
|
||||
// type: Shared Task
|
||||
// type: Shared Task (failed via world for all members)
|
||||
if (m_active_shared_task.task_id == task_id) {
|
||||
client->SendTaskFailed(task_id, TASKSLOTSHAREDTASK, TaskType::Shared);
|
||||
// Remove the task from the client
|
||||
client->CancelTask(TASKSLOTSHAREDTASK, TaskType::Shared);
|
||||
task_manager->EndSharedTask(*client, task_id, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: shared tasks
|
||||
|
||||
if (m_active_task_count == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -1146,7 +1142,6 @@ void ClientTaskState::FailTask(Client *client, int task_id)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Shared tasks
|
||||
bool ClientTaskState::IsTaskActivityActive(int task_id, int activity_id)
|
||||
{
|
||||
LogTasks("[IsTaskActivityActive] task_id [{}] activity_id [{}]", task_id, activity_id);
|
||||
@@ -1566,6 +1561,7 @@ bool ClientTaskState::TaskOutOfTime(TaskType task_type, int index)
|
||||
|
||||
void ClientTaskState::TaskPeriodicChecks(Client *client)
|
||||
{
|
||||
// shared task expiration is handled by world
|
||||
|
||||
// type "task"
|
||||
if (m_active_task.task_id != TASKSLOTEMPTY) {
|
||||
@@ -1581,20 +1577,6 @@ void ClientTaskState::TaskPeriodicChecks(Client *client)
|
||||
}
|
||||
}
|
||||
|
||||
// type "shared"
|
||||
if (m_active_shared_task.task_id != TASKSLOTEMPTY) {
|
||||
if (TaskOutOfTime(TaskType::Shared, TASKSLOTSHAREDTASK)) {
|
||||
// Send Red Task Failed Message
|
||||
client->SendTaskFailed(m_active_shared_task.task_id, TASKSLOTSHAREDTASK, TaskType::Shared);
|
||||
// Remove the task from the client
|
||||
client->CancelTask(TASKSLOTSHAREDTASK, TaskType::Shared);
|
||||
// It is a conscious decision to only fail one task per call to this method,
|
||||
// otherwise the player will not see all the failed messages where multiple
|
||||
// tasks fail at the same time.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_active_task_count == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -2434,6 +2416,13 @@ void ClientTaskState::LockSharedTask(Client* client, bool lock)
|
||||
}
|
||||
}
|
||||
|
||||
void ClientTaskState::EndSharedTask(Client* client, bool send_fail)
|
||||
{
|
||||
if (task_manager && m_active_shared_task.task_id != TASKSLOTEMPTY)
|
||||
{
|
||||
task_manager->EndSharedTask(*client, m_active_shared_task.task_id, send_fail);
|
||||
}
|
||||
}
|
||||
bool ClientTaskState::CanAcceptNewTask(Client* client, int task_id, int npc_entity_id) const
|
||||
{
|
||||
auto it = std::find_if(m_last_offers.begin(), m_last_offers.end(),
|
||||
|
||||
Reference in New Issue
Block a user