Make instance missions reset upon warping out

This commit is contained in:
Gent 2020-10-12 19:29:00 -04:00
parent d4aed0abf4
commit b87f20e2dc

View File

@ -2,6 +2,7 @@
#include "ItemManager.hpp" #include "ItemManager.hpp"
#include "settings.hpp" #include "settings.hpp"
#include "MobManager.hpp" #include "MobManager.hpp"
#include "MissionManager.hpp"
#include <cmath> #include <cmath>
#include <algorithm> #include <algorithm>
@ -588,6 +589,21 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
if (Warps.find(warpId) == Warps.end()) if (Warps.find(warpId) == Warps.end())
return; return;
// loop through all tasks; if the required instance is being left, "fail" the task
for (int taskNum : plrv.plr->tasks) {
if (MissionManager::Tasks.find(taskNum) == MissionManager::Tasks.end())
continue; // sanity check
TaskData* task = MissionManager::Tasks[taskNum];
if ((plrv.plr->instanceID & 0xffffffff) == (int)(task->task["m_iRequireInstanceID"])) { // instance ID matches
int failTaskID = task->task["m_iFOutgoingTask"];
if (failTaskID != 0) {
MissionManager::quitTask(sock, taskNum);
// TODO: start fail task
}
}
}
// std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl; // std::cerr << "Warped to Map Num:" << Warps[warpId].instanceID << " NPC ID " << Warps[warpId].npcID << std::endl;
if (Warps[warpId].isInstance) if (Warps[warpId].isInstance)
{ {