mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 23:20:25 +00:00
[Tasks] Only update loot tasks for NPC corpses (#2513)
This fixes a bug that allowed looting items from a player's corpse to
increment a task if it didn't have an npc target defined. It looks
like this bug existed before the changes in 7482cfc0.
This also now passes count for task loot updates to handle item stacks.
Also fixes incorrectly casting Corpse to NPC on loot update
This commit is contained in:
+24
-13
@@ -522,10 +522,10 @@ bool ClientTaskState::CanUpdate(Client* client, const TaskUpdateFilter& filter,
|
||||
}
|
||||
|
||||
// npc filter supports both npc names and ids in match lists
|
||||
if (!activity.npc_match_list.empty() && (!filter.npc ||
|
||||
(!Tasks::IsInMatchListPartial(activity.npc_match_list, filter.npc->GetName()) &&
|
||||
!Tasks::IsInMatchListPartial(activity.npc_match_list, filter.npc->GetCleanName()) &&
|
||||
!Tasks::IsInMatchList(activity.npc_match_list, std::to_string(filter.npc->GetNPCTypeID())))))
|
||||
if (!activity.npc_match_list.empty() && (!filter.mob ||
|
||||
(!Tasks::IsInMatchListPartial(activity.npc_match_list, filter.mob->GetName()) &&
|
||||
!Tasks::IsInMatchListPartial(activity.npc_match_list, filter.mob->GetCleanName()) &&
|
||||
!Tasks::IsInMatchList(activity.npc_match_list, std::to_string(filter.mob->GetNPCTypeID())))))
|
||||
{
|
||||
LogTasks("[CanUpdate] client [{}] task [{}]-[{}] failed npc match filter", client->GetName(), task_id, client_activity.activity_id);
|
||||
return false;
|
||||
@@ -640,7 +640,7 @@ bool ClientTaskState::UpdateTasksByNPC(Client* client, TaskActivityType type, NP
|
||||
{
|
||||
TaskUpdateFilter filter{};
|
||||
filter.type = type;
|
||||
filter.npc = npc;
|
||||
filter.mob = npc;
|
||||
|
||||
return UpdateTasks(client, filter) > 0;
|
||||
}
|
||||
@@ -651,7 +651,7 @@ int ClientTaskState::ActiveSpeakTask(Client* client, NPC* npc)
|
||||
// active task found which has an active SpeakWith activity_information for this NPC.
|
||||
TaskUpdateFilter filter{};
|
||||
filter.type = TaskActivityType::SpeakWith;
|
||||
filter.npc = npc;
|
||||
filter.mob = npc;
|
||||
filter.method = METHODQUEST;
|
||||
|
||||
auto result = FindTask(client, filter);
|
||||
@@ -670,7 +670,7 @@ int ClientTaskState::ActiveSpeakActivity(Client* client, NPC* npc, int task_id)
|
||||
|
||||
TaskUpdateFilter filter{};
|
||||
filter.type = TaskActivityType::SpeakWith;
|
||||
filter.npc = npc;
|
||||
filter.mob = npc;
|
||||
filter.method = METHODQUEST;
|
||||
filter.task_id = task_id;
|
||||
|
||||
@@ -678,19 +678,30 @@ int ClientTaskState::ActiveSpeakActivity(Client* client, NPC* npc, int task_id)
|
||||
return result.first != 0 ? result.second : -1; // activity id
|
||||
}
|
||||
|
||||
void ClientTaskState::UpdateTasksForItem(Client* client, TaskActivityType type, NPC* npc, int item_id, int count)
|
||||
void ClientTaskState::UpdateTasksForItem(Client* client, TaskActivityType type, int item_id, int count)
|
||||
{
|
||||
|
||||
// This method updates the client's task activities of the specified type which relate
|
||||
// to the specified item.
|
||||
//
|
||||
// Type should be one of ActivityLoot, ActivityTradeSkill, ActivityFish or ActivityForage
|
||||
// Type should be one of ActivityTradeSkill, ActivityFish or ActivityForage
|
||||
|
||||
LogTasks("[UpdateTasksForItem] activity_type [{}] item_id [{}]", static_cast<int>(type), item_id);
|
||||
LogTasks("[UpdateTasksForItem] activity_type [{}] item_id [{}] count [{}]", static_cast<int>(type), item_id, count);
|
||||
|
||||
TaskUpdateFilter filter{};
|
||||
filter.type = type;
|
||||
filter.npc = npc; // looting may filter on npc id or name
|
||||
filter.item_id = item_id;
|
||||
|
||||
UpdateTasks(client, filter, count);
|
||||
}
|
||||
|
||||
void ClientTaskState::UpdateTasksOnLoot(Client* client, Corpse* corpse, int item_id, int count)
|
||||
{
|
||||
LogTasks("[UpdateTasksOnLoot] corpse [{}] item_id [{}] count [{}]", corpse->GetName(), item_id, count);
|
||||
|
||||
TaskUpdateFilter filter{};
|
||||
filter.type = TaskActivityType::Loot;
|
||||
filter.mob = corpse;
|
||||
filter.item_id = item_id;
|
||||
|
||||
UpdateTasks(client, filter, count);
|
||||
@@ -715,7 +726,7 @@ bool ClientTaskState::UpdateTasksOnDeliver(Client* client, std::vector<EQ::ItemI
|
||||
bool is_updated = false;
|
||||
|
||||
TaskUpdateFilter filter{};
|
||||
filter.npc = npc;
|
||||
filter.mob = npc;
|
||||
|
||||
int cash = trade.cp + (trade.sp * 10) + (trade.gp * 100) + (trade.pp * 1000);
|
||||
if (cash != 0)
|
||||
@@ -772,7 +783,7 @@ void ClientTaskState::UpdateTasksOnKill(Client* client, Client* exp_client, NPC*
|
||||
{
|
||||
TaskUpdateFilter filter{};
|
||||
filter.type = TaskActivityType::Kill;
|
||||
filter.npc = npc;
|
||||
filter.mob = npc;
|
||||
filter.pos = npc->GetPosition(); // or should areas be filtered by client position?
|
||||
filter.use_pos = true;
|
||||
filter.exp_client = exp_client;
|
||||
|
||||
Reference in New Issue
Block a user