mirror of
https://github.com/EQEmu/Server.git
synced 2026-03-02 18:32:25 +00:00
Shared task kill update fix
This commit is contained in:
parent
30c7ed7e45
commit
91c451b6c5
@ -2739,110 +2739,128 @@ void ClientTaskState::SyncSharedTaskZoneClientDoneCountState(
|
|||||||
|
|
||||||
void ClientTaskState::HandleUpdateTasksOnKill(Client *client, uint32 npc_type_id)
|
void ClientTaskState::HandleUpdateTasksOnKill(Client *client, uint32 npc_type_id)
|
||||||
{
|
{
|
||||||
if (!HasActiveTasks()) {
|
|
||||||
return;
|
// get clients to update
|
||||||
|
std::vector<Client *> clients_to_update = {};
|
||||||
|
|
||||||
|
// raid
|
||||||
|
Raid *raid = entity_list.GetRaidByClient(client);
|
||||||
|
if (raid) {
|
||||||
|
for (auto &e : raid->members) {
|
||||||
|
if (e.member && e.member->IsClient()) {
|
||||||
|
clients_to_update.push_back(e.member->CastToClient());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop over the union of tasks and quests
|
// group
|
||||||
for (auto &active_task : m_active_tasks) {
|
if (!clients_to_update.empty()) {
|
||||||
auto current_task = &active_task;
|
Group *group = entity_list.GetGroupByClient(client);
|
||||||
if (current_task->task_id == TASKSLOTEMPTY) {
|
if (group) {
|
||||||
|
for (auto &m : group->members) {
|
||||||
|
if (m && m->IsClient()) {
|
||||||
|
clients_to_update.push_back(m->CastToClient());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// solo
|
||||||
|
if (!clients_to_update.empty()) {
|
||||||
|
clients_to_update.push_back(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &c: clients_to_update) {
|
||||||
|
if (c->ClientDataLoaded()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if there are any active kill activities for this p_task_data
|
LogTasksDetail("[HandleUpdateTasksOnKill] Looping through client [{}]", c->GetCleanName());
|
||||||
auto p_task_data = task_manager->m_task_data[current_task->task_id];
|
|
||||||
if (p_task_data == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) {
|
// loop over the union of tasks and quests
|
||||||
ClientActivityInformation *client_activity = ¤t_task->activity[activity_id];
|
for (auto &active_task : c->GetTaskState()->m_active_tasks) {
|
||||||
ActivityInformation *activity_info = &p_task_data->activity_information[activity_id];
|
auto current_task = &active_task;
|
||||||
|
if (current_task->task_id == TASKSLOTEMPTY) {
|
||||||
// We are not interested in completed or hidden activities
|
|
||||||
if (client_activity->activity_state != ActivityActive) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We are only interested in Kill activities
|
// Check if there are any active kill activities for this p_task_data
|
||||||
if (activity_info->activity_type != TaskActivityType::Kill) {
|
auto p_task_data = task_manager->m_task_data[current_task->task_id];
|
||||||
continue;
|
if (p_task_data == nullptr) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is there a zone restriction on the activity_information ?
|
for (int activity_id = 0; activity_id < p_task_data->activity_count; activity_id++) {
|
||||||
if (!activity_info->CheckZone(zone->GetZoneID())) {
|
ClientActivityInformation *client_activity = ¤t_task->activity[activity_id];
|
||||||
LogTasks(
|
ActivityInformation *activity_info = &p_task_data->activity_information[activity_id];
|
||||||
"[HandleUpdateTasksOnKill] character [{}] task_id [{}] activity_id [{}] activity_type [{}] for NPC [{}] failed zone check",
|
|
||||||
client->GetName(),
|
|
||||||
current_task->task_id,
|
|
||||||
activity_id,
|
|
||||||
static_cast<int32_t>(TaskActivityType::Kill),
|
|
||||||
npc_type_id
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Is the activity_information to kill this type of NPC ?
|
|
||||||
switch (activity_info->goal_method) {
|
|
||||||
case METHODSINGLEID:
|
|
||||||
if (activity_info->goal_id != npc_type_id) {
|
|
||||||
LogTasksDetail("[HandleUpdateTasksOnKill] Matched single goal");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case METHODLIST:
|
// We are not interested in completed or hidden activities
|
||||||
if (!task_manager->m_goal_list_manager.IsInList(
|
if (client_activity->activity_state != ActivityActive) {
|
||||||
activity_info->goal_id,
|
|
||||||
(int) npc_type_id
|
|
||||||
)) {
|
|
||||||
LogTasksDetail("[HandleUpdateTasksOnKill] Matched list goal");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// If METHODQUEST, don't updated the activity_information here
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogTasksDetail("[HandleUpdateTasksOnKill] passed checks");
|
// We are only interested in Kill activities
|
||||||
|
if (activity_info->activity_type != TaskActivityType::Kill) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// handle actual update
|
// Is there a zone restriction on the activity_information ?
|
||||||
// legacy eqemu task update logic loops through group on kill of npc to update a single task
|
if (!activity_info->CheckZone(zone->GetZoneID())) {
|
||||||
if (p_task_data->type != TaskType::Shared) {
|
LogTasks(
|
||||||
LogTasksDetail("[HandleUpdateTasksOnKill] Non-Shared Update");
|
"[HandleUpdateTasksOnKill] character [{}] task_id [{}] activity_id [{}] activity_type [{}] for NPC [{}] failed zone check",
|
||||||
|
client->GetName(),
|
||||||
Raid *raid = entity_list.GetRaidByClient(client);
|
current_task->task_id,
|
||||||
if (raid) {
|
activity_id,
|
||||||
for (auto &e : raid->members) {
|
static_cast<int32_t>(TaskActivityType::Kill),
|
||||||
if (e.member && e.member->IsClient()) {
|
npc_type_id
|
||||||
Client *c = e.member->CastToClient();
|
);
|
||||||
c->UpdateTasksOnKill(npc_type_id);
|
continue;
|
||||||
|
}
|
||||||
|
// Is the activity_information to kill this type of NPC ?
|
||||||
|
switch (activity_info->goal_method) {
|
||||||
|
case METHODSINGLEID:
|
||||||
|
if (activity_info->goal_id != npc_type_id) {
|
||||||
|
LogTasksDetail("[HandleUpdateTasksOnKill] Matched single goal");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
case METHODLIST:
|
||||||
|
if (!task_manager->m_goal_list_manager.IsInList(
|
||||||
|
activity_info->goal_id,
|
||||||
|
(int) npc_type_id
|
||||||
|
)) {
|
||||||
|
LogTasksDetail("[HandleUpdateTasksOnKill] Matched list goal");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// If METHODQUEST, don't updated the activity_information here
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
LogTasksDetail("[HandleUpdateTasksOnKill] passed checks");
|
||||||
|
|
||||||
|
// handle actual update
|
||||||
|
// legacy eqemu task update logic loops through group on kill of npc to update a single task
|
||||||
|
if (p_task_data->type != TaskType::Shared) {
|
||||||
|
LogTasksDetail("[HandleUpdateTasksOnKill] Non-Shared Update");
|
||||||
|
IncrementDoneCount(c, p_task_data, current_task->slot, activity_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Group *group = entity_list.GetGroupByClient(client);
|
LogTasksDetail("[HandleUpdateTasksOnKill] Shared update");
|
||||||
if (group) {
|
|
||||||
for (auto &m : group->members) {
|
// shared tasks only require one client to receive an update to propagate
|
||||||
if (m && m->IsClient()) {
|
if (c == client) {
|
||||||
Client *c = m->CastToClient();
|
IncrementDoneCount(c, p_task_data, current_task->slot, activity_id);
|
||||||
c->UpdateTasksOnKill(npc_type_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogTasksDetail("[HandleUpdateTasksOnKill] Shared update");
|
|
||||||
|
|
||||||
// shared tasks only require one client to receive an update to propagate
|
|
||||||
client->UpdateTasksOnKill(npc_type_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClientTaskState::HasActiveTasks()
|
bool ClientTaskState::HasActiveTasks()
|
||||||
{
|
{
|
||||||
if (!task_manager) {
|
if (!task_manager) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user