mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-22 05:20:05 +00:00
fixed unexpected randomization of barkers
This commit is contained in:
parent
cd265af8e0
commit
3e6bfea3fe
@ -94,20 +94,34 @@ void NPCManager::sendToViewable(Entity *npc, void *buf, uint32_t type, size_t si
|
|||||||
static void npcBarkHandler(CNSocket* sock, CNPacketData* data) {
|
static void npcBarkHandler(CNSocket* sock, CNPacketData* data) {
|
||||||
sP_CL2FE_REQ_BARKER* req = (sP_CL2FE_REQ_BARKER*)data->buf;
|
sP_CL2FE_REQ_BARKER* req = (sP_CL2FE_REQ_BARKER*)data->buf;
|
||||||
|
|
||||||
// get bark IDs from task data
|
int taskID = req->iMissionTaskID;
|
||||||
TaskData* td = Missions::Tasks[req->iMissionTaskID];
|
int npcID = req->iNPC_ID;
|
||||||
std::vector<int> barks;
|
|
||||||
for (int i = 0; i < 4; i++) {
|
if (Missions::Tasks.find(taskID) == Missions::Tasks.end()) {
|
||||||
if (td->task["m_iHBarkerTextID"][i] != 0) // non-zeroes only
|
std::cout << "mission task not found: " << taskID << std::endl;
|
||||||
barks.push_back(td->task["m_iHBarkerTextID"][i]);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (barks.empty())
|
if (npcID < 0 || npcID >= NPCData.size()) {
|
||||||
|
std::cout << "npc not found: " << npcID << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get bark IDs from task data
|
||||||
|
TaskData* td = Missions::Tasks[taskID];
|
||||||
|
auto& barks = td->task["m_iHBarkerTextID"];
|
||||||
|
|
||||||
|
int barkType = NPCData[npcID]["m_iBarkerType"];
|
||||||
|
if (barkType < 1 || barkType > 4)
|
||||||
|
return; // no barks
|
||||||
|
|
||||||
|
int barkID = barks[barkType - 1];
|
||||||
|
if (barkID == 0)
|
||||||
return; // no barks
|
return; // no barks
|
||||||
|
|
||||||
INITSTRUCT(sP_FE2CL_REP_BARKER, resp);
|
INITSTRUCT(sP_FE2CL_REP_BARKER, resp);
|
||||||
resp.iNPC_ID = req->iNPC_ID;
|
resp.iNPC_ID = npcID;
|
||||||
resp.iMissionStringID = barks[Rand::rand(barks.size())];
|
resp.iMissionStringID = barkID;
|
||||||
sock->sendPacket(resp, P_FE2CL_REP_BARKER);
|
sock->sendPacket(resp, P_FE2CL_REP_BARKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user