[Tasks] Use dz switch id for task touch events (#2344)

This changes task touch elements to use the dz_switch_id as the goal id
instead of checking if a player zoned. It will remove the need to script
door clicks or modify task element zone field since task packet data can
just be imported.
This commit is contained in:
hg 2022-07-30 22:14:22 -04:00 committed by GitHub
parent 676467cbdc
commit 5e7e255d72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 18 deletions

View File

@ -163,7 +163,7 @@ struct ActivityInformation {
out.WriteInt32(zone_ids.empty() ? 0 : zone_ids.front());
}
out.WriteInt32(0); // unknown id
out.WriteInt32(activity_type == TaskActivityType::Touch ? goal_id : 0); // dz_switch_id (maybe add separate field)
out.WriteString(description_override);
out.WriteInt32(done_count);
out.WriteInt8(1); // unknown

View File

@ -1178,6 +1178,10 @@ public:
}
else { return false; }
}
void UpdateTasksOnTouchSwitch(int dz_switch_id)
{
if (task_state) { task_state->UpdateTasksOnTouch(this, dz_switch_id); }
}
inline void TaskSetSelector(Mob *mob, int task_set_id)
{
if (task_manager) {

View File

@ -210,7 +210,7 @@ void Doors::HandleClick(Client* sender, uint8 trigger) {
if (m_dz_switch_id != 0)
{
// todo: update task touch task events with matching dz switch id
sender->UpdateTasksOnTouchSwitch(m_dz_switch_id);
if (sender->TryMovePCDynamicZoneSwitch(m_dz_switch_id))
{
safe_delete(outapp);

View File

@ -22,7 +22,6 @@ ClientTaskState::ClientTaskState()
{
m_active_task_count = 0;
m_last_completed_task_loaded = 0;
m_checked_touch_activities = false;
for (int i = 0; i < MAXACTIVEQUESTS; i++) {
m_active_quests[i].slot = i;
@ -1039,11 +1038,11 @@ bool ClientTaskState::UpdateTasksOnDeliver(
return is_updated;
}
void ClientTaskState::UpdateTasksOnTouch(Client *client, int zone_id, uint16 version)
void ClientTaskState::UpdateTasksOnTouch(Client *client, int dz_switch_id)
{
// If the client has no tasks, there is nothing further to check.
LogTasks("[UpdateTasksOnTouch] [{}] ", zone_id);
LogTasks("[UpdateTasksOnTouch] [{}] ", dz_switch_id);
if (!HasActiveTasks()) {
return;
@ -1077,14 +1076,16 @@ void ClientTaskState::UpdateTasksOnTouch(Client *client, int zone_id, uint16 ver
if (activity_info->goal_method != METHODSINGLEID) {
continue;
}
if (!activity_info->CheckZone(zone_id, version)) {
if (!activity_info->CheckZone(zone->GetZoneID(), zone->GetInstanceVersion())) {
LogTasks(
"[UpdateTasksOnTouch] character [{}] Touch activity_information failed zone check",
client->GetName()
);
continue;
}
if (activity_info->goal_id != dz_switch_id) {
continue;
}
// We found an active task to zone into this zone, so set done count to goal count
// (Only a goal count of 1 makes sense for touch activities?)
LogTasks("[UpdateTasksOnTouch] Increment on Touch");
@ -1922,15 +1923,6 @@ void ClientTaskState::TaskPeriodicChecks(Client *client)
break;
}
}
// Check for activities that require zoning into a specific zone.
// This is done in this method because it gives an extra few seconds for the client screen to display
// the zone before we send the 'Task activity_information Completed' message.
//
if (!m_checked_touch_activities) {
UpdateTasksOnTouch(client, zone->GetZoneID(), zone->GetInstanceVersion());
m_checked_touch_activities = true;
}
}
bool ClientTaskState::IsTaskActivityCompleted(TaskType task_type, int index, int activity_id)

View File

@ -38,7 +38,7 @@ public:
void UpdateTasksOnExplore(Client *client, int explore_id);
bool UpdateTasksOnSpeakWith(Client *client, int npc_type_id);
bool UpdateTasksOnDeliver(Client *client, std::list<EQ::ItemInstance *> &items, int cash, int npc_type_id);
void UpdateTasksOnTouch(Client *client, int zone_id, uint16 version);
void UpdateTasksOnTouch(Client *client, int dz_switch_id);
void ProcessTaskProximities(Client *client, float x, float y, float z);
bool TaskOutOfTime(TaskType task_type, int index);
void TaskPeriodicChecks(Client *client);
@ -130,7 +130,6 @@ private:
std::vector<int> m_enabled_tasks;
std::vector<CompletedTaskInformation> m_completed_tasks;
int m_last_completed_task_loaded;
bool m_checked_touch_activities;
static void ShowClientTaskInfoMessage(ClientTaskInformation *task, Client *c);