Mission Handling Fixes

- Q. Item count glitches are dealt with
- Warping out now correctly rewinds missions.
This commit is contained in:
Jade 2020-12-16 02:25:52 +00:00 committed by Gent S
parent 322e354f5b
commit 8d1bc94b7e
2 changed files with 8 additions and 7 deletions

View File

@ -76,13 +76,18 @@ void MissionManager::taskStart(CNSocket* sock, CNPacketData* data) {
TaskData& task = *Tasks[missionData->iTaskNum]; TaskData& task = *Tasks[missionData->iTaskNum];
// Give player their delivery items at the start, or reset them to 0 at the start.
for (int i = 0; i < 3; i++)
if (task["m_iSTItemID"][i] != 0)
dropQuestItem(sock, missionData->iTaskNum, task["m_iSTItemNumNeeded"][i], task["m_iSTItemID"][i], 0);
std::cout << "Mission requested task: " << missionData->iTaskNum << std::endl;
response.iTaskNum = missionData->iTaskNum; response.iTaskNum = missionData->iTaskNum;
response.iRemainTime = task["m_iSTGrantTimer"]; response.iRemainTime = task["m_iSTGrantTimer"];
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_START_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_START_SUCC)); sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_START_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_START_SUCC));
// HACK: auto-succeed escort task // HACK: auto-succeed escort task
if (task["m_iHTaskType"] == 6) { if (task["m_iHTaskType"] == 6) {
std::cout << "Sending Eduardo success packet" << std::endl; std::cout << "Skipping escort mission" << std::endl;
INITSTRUCT(sP_FE2CL_REP_PC_TASK_END_SUCC, response); INITSTRUCT(sP_FE2CL_REP_PC_TASK_END_SUCC, response);
endTask(sock, missionData->iTaskNum); endTask(sock, missionData->iTaskNum);
@ -90,11 +95,6 @@ void MissionManager::taskStart(CNSocket* sock, CNPacketData* data) {
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_END_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_END_SUCC)); sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_END_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_END_SUCC));
} }
// Give player their delivery items at the start.
for (int i = 0; i < 3; i++)
if (task["m_iSTItemID"][i] != 0 && task["m_iSTItemNumNeeded"][i] > 0)
dropQuestItem(sock, missionData->iTaskNum, task["m_iSTItemNumNeeded"][i], task["m_iSTItemID"][i], 0);
} }
void MissionManager::taskEnd(CNSocket* sock, CNPacketData* data) { void MissionManager::taskEnd(CNSocket* sock, CNPacketData* data) {
@ -273,7 +273,7 @@ void MissionManager::quitTask(CNSocket* sock, int32_t taskNum, bool manual) {
* slot later items will be placed in. * slot later items will be placed in.
*/ */
for (int j = 0; j < AQINVEN_COUNT; j++) for (int j = 0; j < AQINVEN_COUNT; j++)
if (plr->QInven[j].iID == task["m_iSUItem"][i] || plr->QInven[j].iID == task["m_iCSUItemID"][i]) if (plr->QInven[j].iID == task["m_iSUItem"][i] || plr->QInven[j].iID == task["m_iCSUItemID"][i] || plr->QInven[j].iID == task["m_iSTItemID"][i])
memset(&plr->QInven[j], 0, sizeof(sItemBase)); memset(&plr->QInven[j], 0, sizeof(sItemBase));
} }

View File

@ -570,6 +570,7 @@ void NPCManager::handleWarp(CNSocket* sock, int32_t warpId) {
resp.iCandy = plr->money; resp.iCandy = plr->money;
resp.eIL = 4; // do not take away any items resp.eIL = 4; // do not take away any items
plr->instanceID = INSTANCE_OVERWORLD; plr->instanceID = INSTANCE_OVERWORLD;
MissionManager::failInstancedMissions(sock); // fail any instanced missions
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC)); sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_WARP_USE_NPC_SUCC, sizeof(sP_FE2CL_REP_PC_WARP_USE_NPC_SUCC));
ChunkManager::updatePlayerChunk(sock, plr->chunkPos, std::make_tuple(0, 0, 0)); // force player to reload chunks ChunkManager::updatePlayerChunk(sock, plr->chunkPos, std::make_tuple(0, 0, 0)); // force player to reload chunks
PlayerManager::updatePlayerPosition(sock, resp.iX, resp.iY, resp.iZ, INSTANCE_OVERWORLD, plr->angle); PlayerManager::updatePlayerPosition(sock, resp.iX, resp.iY, resp.iZ, INSTANCE_OVERWORLD, plr->angle);