Assign paths with matching taskIDs to escort tasks on task start

This commit is contained in:
gsemaj 2021-05-05 21:41:17 -04:00 committed by Gent Semaj
parent 974b67d4b6
commit a90ba9ea08

View File

@ -3,6 +3,7 @@
#include "PlayerManager.hpp" #include "PlayerManager.hpp"
#include "Nanos.hpp" #include "Nanos.hpp"
#include "Items.hpp" #include "Items.hpp"
#include "Transport.hpp"
#include "string.h" #include "string.h"
@ -358,15 +359,19 @@ static void taskStart(CNSocket* sock, CNPacketData* data) {
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 // if escort task, assign matching paths to all nearby NPCs
if (task["m_iHTaskType"] == 6) { if (task["m_iHTaskType"] == 6) {
std::cout << "Skipping escort mission" << std::endl; for(Chunk* chunk : plr->viewableChunks) // check all NPCs in view
INITSTRUCT(sP_FE2CL_REP_PC_TASK_END_SUCC, response); for (EntityRef ref : chunk->entities) {
if (ref.type != EntityType::PLAYER) {
endTask(sock, missionData->iTaskNum); BaseNPC* npc = (BaseNPC*)ref.getEntity();
response.iTaskNum = missionData->iTaskNum; NPCPath* path = Transport::findApplicablePath(npc->appearanceData.iNPC_ID, npc->appearanceData.iNPCType, missionData->iTaskNum);
if (path != nullptr) {
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_END_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_END_SUCC)); Transport::constructPathNPC(npc->appearanceData.iNPC_ID, path);
return;
}
}
}
} }
} }