Remove redundant Mob map

This commit is contained in:
gsemaj 2021-04-06 20:43:43 -04:00 committed by dongresource
parent 65462d01e3
commit fd965fbf03
8 changed files with 128 additions and 86 deletions

View File

@ -137,12 +137,18 @@ int Nanos::applyBuff(CNSocket* sock, int skillID, int eTBU, int eTBT, int32_t gr
namespace Nanos {
bool doDebuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
if (MobAI::Mobs.find(targetID) == MobAI::Mobs.end()) {
std::cout << "[WARN] doDebuff: mob ID not found" << std::endl;
if (NPCManager::NPCs.find(targetID) == NPCManager::NPCs.end()) {
std::cout << "[WARN] doDebuff: NPC ID not found" << std::endl;
return false;
}
Mob* mob = MobAI::Mobs[targetID];
BaseNPC* npc = NPCManager::NPCs[targetID];
if (npc->type != EntityType::MOB) {
std::cout << "[WARN] doDebuff: NPC is not a mob" << std::endl;
return false;
}
Mob* mob = (Mob*)npc;
Combat::hitMob(sock, mob, 0);
respdata[i].eCT = 4;
@ -201,13 +207,19 @@ bool doBuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t targetID
}
bool doDamageNDebuff(CNSocket *sock, sSkillResult_Damage_N_Debuff *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
if (MobAI::Mobs.find(targetID) == MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(targetID) == NPCManager::NPCs.end()) {
// not sure how to best handle this
std::cout << "[WARN] doDamageNDebuff: mob ID not found" << std::endl;
std::cout << "[WARN] doDamageNDebuff: NPC ID not found" << std::endl;
return false;
}
Mob* mob = MobAI::Mobs[targetID];
BaseNPC* npc = NPCManager::NPCs[targetID];
if (npc->type != EntityType::MOB) {
std::cout << "[WARN] doDamageNDebuff: NPC is not a mob" << std::endl;
return false;
}
Mob* mob = (Mob*)npc;
Combat::hitMob(sock, mob, 0); // just to gain aggro
@ -263,13 +275,19 @@ bool doHeal(CNSocket *sock, sSkillResult_Heal_HP *respdata, int i, int32_t targe
}
bool doDamage(CNSocket *sock, sSkillResult_Damage *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
if (MobAI::Mobs.find(targetID) == MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(targetID) == NPCManager::NPCs.end()) {
// not sure how to best handle this
std::cout << "[WARN] doDamage: mob ID not found" << std::endl;
std::cout << "[WARN] doDamage: NPC ID not found" << std::endl;
return false;
}
Mob* mob = MobAI::Mobs[targetID];
BaseNPC* npc = NPCManager::NPCs[targetID];
if (npc->type != EntityType::MOB) {
std::cout << "[WARN] doDamage: NPC is not a mob" << std::endl;
return false;
}
Mob* mob = (Mob*)npc;
Player *plr = PlayerManager::getPlayer(sock);
int damage = Combat::hitMob(sock, mob, std::max(PC_MAXHEALTH(plr->level) * amount / 1000, mob->maxHealth * amount / 1000));
@ -313,12 +331,19 @@ bool doLeech(CNSocket *sock, sSkillResult_Heal_HP *healdata, int i, int32_t targ
healdata->iHP = plr->HP;
healdata->iHealHP = healedAmount;
if (MobAI::Mobs.find(targetID) == MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(targetID) == NPCManager::NPCs.end()) {
// not sure how to best handle this
std::cout << "[WARN] doLeech: mob ID not found" << std::endl;
std::cout << "[WARN] doLeech: NPC ID not found" << std::endl;
return false;
}
Mob* mob = MobAI::Mobs[targetID];
BaseNPC* npc = NPCManager::NPCs[targetID];
if (npc->type != EntityType::MOB) {
std::cout << "[WARN] doLeech: NPC is not a mob" << std::endl;
return false;
}
Mob* mob = (Mob*)npc;
int damage = Combat::hitMob(sock, mob, amount * 2);
@ -540,12 +565,18 @@ bool doDamageNDebuff(Mob *mob, sSkillResult_Damage_N_Debuff *respdata, int i, in
}
bool doHeal(Mob *mob, sSkillResult_Heal_HP *respdata, int i, int32_t targetID, int32_t bitFlag, int16_t timeBuffID, int16_t duration, int16_t amount) {
if (MobAI::Mobs.find(targetID) == MobAI::Mobs.end()) {
std::cout << "[WARN] doDebuff: mob ID not found" << std::endl;
if (NPCManager::NPCs.find(targetID) == NPCManager::NPCs.end()) {
std::cout << "[WARN] doHeal: NPC ID not found" << std::endl;
return false;
}
Mob* targetMob = MobAI::Mobs[targetID];
BaseNPC* npc = NPCManager::NPCs[targetID];
if (npc->type != EntityType::MOB) {
std::cout << "[WARN] doHeal: NPC is not a mob" << std::endl;
return false;
}
Mob* targetMob = (Mob*)npc;
int healedAmount = amount * targetMob->maxHealth / 1000;
targetMob->appearanceData.iHP += healedAmount;

View File

@ -264,7 +264,6 @@ void Chunking::createInstance(uint64_t instanceID) {
Mob* newMob = new Mob(baseNPC->appearanceData.iX, baseNPC->appearanceData.iY, baseNPC->appearanceData.iZ, baseNPC->appearanceData.iAngle,
instanceID, baseNPC->appearanceData.iNPCType, NPCManager::NPCData[baseNPC->appearanceData.iNPCType], NPCManager::nextId++);
NPCManager::NPCs[newMob->appearanceData.iNPC_ID] = newMob;
MobAI::Mobs[newMob->appearanceData.iNPC_ID] = newMob;
// if in a group, copy over group members as well
if (((Mob*)baseNPC)->groupLeader != 0) {
@ -279,7 +278,6 @@ void Chunking::createInstance(uint64_t instanceID) {
instanceID, baseFollower->appearanceData.iNPCType, NPCManager::NPCData[baseFollower->appearanceData.iNPCType], followerID);
// add follower to NPC maps
NPCManager::NPCs[followerID] = newMobFollower;
MobAI::Mobs[followerID] = newMobFollower;
// set follower-specific properties
newMobFollower->groupLeader = newMob->appearanceData.iNPC_ID;
newMobFollower->offsetX = ((Mob*)baseFollower)->offsetX;

View File

@ -92,12 +92,20 @@ static void pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
resp->iNPCCnt = pkt->iNPCCnt;
for (int i = 0; i < data->trCnt; i++) {
if (MobAI::Mobs.find(targets[i]) == MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(targets[i]) == NPCManager::NPCs.end()) {
// not sure how to best handle this
std::cout << "[WARN] pcAttackNpcs: mob ID not found" << std::endl;
std::cout << "[WARN] pcAttackNpcs: NPC ID not found" << std::endl;
return;
}
Mob *mob = MobAI::Mobs[targets[i]];
BaseNPC* npc = NPCManager::NPCs[targets[i]];
if (npc->type != EntityType::MOB) {
std::cout << "[WARN] pcAttackNpcs: NPC is not a mob" << std::endl;
return;
}
Mob* mob = (Mob*)npc;
std::pair<int,int> damage;
@ -436,12 +444,19 @@ static void pcAttackChars(CNSocket *sock, CNPacketData *data) {
respdata[i].iHP = target->HP;
respdata[i].iHitFlag = damage.second; // hitscan, not a rocket or a grenade
} else { // eCT == 4; attack mob
if (MobAI::Mobs.find(pktdata[i*2]) == MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(pktdata[i*2]) == NPCManager::NPCs.end()) {
// not sure how to best handle this
std::cout << "[WARN] pcAttackNpcs: mob ID not found" << std::endl;
std::cout << "[WARN] pcAttackChars: NPC ID not found" << std::endl;
return;
}
Mob *mob = MobAI::Mobs[pktdata[i*2]];
BaseNPC* npc = NPCManager::NPCs[pktdata[i * 2]];
if (npc->type != EntityType::MOB) {
std::cout << "[WARN] pcAttackChars: NPC is not a mob" << std::endl;
return;
}
Mob* mob = (Mob*)npc;
std::pair<int,int> damage;
@ -636,13 +651,19 @@ static void projectileHit(CNSocket* sock, CNPacketData* data) {
Bullet* bullet = &Bullets[plr->iID][pkt->iBulletID];
for (int i = 0; i < pkt->iTargetCnt; i++) {
if (MobAI::Mobs.find(pktdata[i]) == MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(pktdata[i]) == NPCManager::NPCs.end()) {
// not sure how to best handle this
std::cout << "[WARN] projectileHit: mob ID not found" << std::endl;
std::cout << "[WARN] projectileHit: NPC ID not found" << std::endl;
return;
}
Mob* mob = MobAI::Mobs[pktdata[i]];
BaseNPC* npc = NPCManager::NPCs[pktdata[i]];
if (npc->type != EntityType::MOB) {
std::cout << "[WARN] projectileHit: NPC is not a mob" << std::endl;
return;
}
Mob* mob = (Mob*)npc;
std::pair<int, int> damage;
damage.first = pkt->iTargetCnt > 1 ? bullet->groupDamage : bullet->pointDamage;

View File

@ -270,18 +270,18 @@ static void unsummonWCommand(std::string full, std::vector<std::string>& args, C
return;
}
if (MobAI::Mobs.find(npc->appearanceData.iNPC_ID) != MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(npc->appearanceData.iNPC_ID) != NPCManager::NPCs.end() && NPCManager::NPCs[npc->appearanceData.iNPC_ID]->type == EntityType::MOB) {
int leadId = ((Mob*)npc)->groupLeader;
if (leadId != 0) {
if (MobAI::Mobs.find(leadId) == MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(leadId) == NPCManager::NPCs.end() || NPCManager::NPCs[leadId]->type != EntityType::MOB) {
std::cout << "[WARN] unsummonW: leader not found!" << std::endl;
}
Mob* leadNpc = MobAI::Mobs[leadId];
Mob* leadNpc = (Mob*)NPCManager::NPCs[leadId];
for (int i = 0; i < 4; i++) {
if (leadNpc->groupMember[i] == 0)
break;
if (MobAI::Mobs.find(leadNpc->groupMember[i]) == MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(leadNpc->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadNpc->groupMember[i]]->type != EntityType::MOB) {
std::cout << "[WARN] unsommonW: leader can't find a group member!" << std::endl;
continue;
}
@ -310,20 +310,24 @@ static void toggleAiCommand(std::string full, std::vector<std::string>& args, CN
return;
// return all mobs to their spawn points
for (auto& pair : MobAI::Mobs) {
pair.second->state = MobState::RETREAT;
pair.second->target = nullptr;
pair.second->nextMovement = getTime();
for (auto& pair : NPCManager::NPCs) {
if (pair.second->type != EntityType::MOB)
continue;
Mob* mob = (Mob*)pair.second;
mob->state = MobState::RETREAT;
mob->target = nullptr;
mob->nextMovement = getTime();
// mobs with static paths can chill where they are
if (pair.second->staticPath) {
pair.second->roamX = pair.second->appearanceData.iX;
pair.second->roamY = pair.second->appearanceData.iY;
pair.second->roamZ = pair.second->appearanceData.iZ;
if (mob->staticPath) {
mob->roamX = mob->appearanceData.iX;
mob->roamY = mob->appearanceData.iY;
mob->roamZ = mob->appearanceData.iZ;
} else {
pair.second->roamX = pair.second->spawnX;
pair.second->roamY = pair.second->spawnY;
pair.second->roamZ = pair.second->spawnZ;
mob->roamX = mob->spawnX;
mob->roamY = mob->spawnY;
mob->roamZ = mob->spawnZ;
}
}
}
@ -595,9 +599,9 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
}
BaseNPC *npc = NPCManager::summonNPC(x, y, z, plr->instanceID, type, wCommand);
if (team == 2 && i > 0) {
if (team == 2 && i > 0 && npc->type == EntityType::MOB) {
leadNpc->groupMember[i-1] = npc->appearanceData.iNPC_ID;
Mob* mob = MobAI::Mobs[npc->appearanceData.iNPC_ID];
Mob* mob = (Mob*)NPCManager::NPCs[npc->appearanceData.iNPC_ID];
mob->groupLeader = leadNpc->appearanceData.iNPC_ID;
mob->offsetX = x - plr->x;
mob->offsetY = y - plr->y;
@ -610,9 +614,9 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
if (PLAYERID(plr->instanceID) != 0) {
npc = NPCManager::summonNPC(plr->x, plr->y, plr->z, plr->instanceID, type, wCommand, true);
if (team == 2 && i > 0) {
if (team == 2 && i > 0 && npc->type == EntityType::MOB) {
leadNpc->groupMember[i-1] = npc->appearanceData.iNPC_ID;
Mob* mob = MobAI::Mobs[npc->appearanceData.iNPC_ID];
Mob* mob = (Mob*)NPCManager::NPCs[npc->appearanceData.iNPC_ID];
mob->groupLeader = leadNpc->appearanceData.iNPC_ID;
mob->offsetX = x - plr->x;
mob->offsetY = y - plr->y;
@ -625,9 +629,9 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
Chat::sendServerMessage(sock, "/summonGroup(W): placed mob with type: " + std::to_string(type) +
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
if (i == 0 && team == 2) {
if (i == 0 && team == 2 && npc->type == EntityType::MOB) {
type = type2;
leadNpc = MobAI::Mobs[npc->appearanceData.iNPC_ID];
leadNpc = (Mob*)NPCManager::NPCs[npc->appearanceData.iNPC_ID];
leadNpc->groupLeader = leadNpc->appearanceData.iNPC_ID;
}
}

View File

@ -11,8 +11,6 @@
using namespace MobAI;
std::map<int32_t, Mob*> MobAI::Mobs;
bool MobAI::simulateMobs = settings::SIMULATEMOBS;
static void roamingStep(Mob *mob, time_t currTime);
@ -59,17 +57,17 @@ void MobAI::clearDebuff(Mob *mob) {
}
void MobAI::followToCombat(Mob *mob) {
if (Mobs.find(mob->groupLeader) != Mobs.end()) {
Mob* leadMob = Mobs[mob->groupLeader];
if (NPCManager::NPCs.find(mob->groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[mob->groupLeader]->type == EntityType::MOB) {
Mob* leadMob = (Mob*)NPCManager::NPCs[mob->groupLeader];
for (int i = 0; i < 4; i++) {
if (leadMob->groupMember[i] == 0)
break;
if (Mobs.find(leadMob->groupMember[i]) == Mobs.end()) {
if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->type != EntityType::MOB) {
std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl;
continue;
}
Mob* followerMob = Mobs[leadMob->groupMember[i]];
Mob* followerMob = (Mob*)NPCManager::NPCs[leadMob->groupMember[i]];
if (followerMob->state != MobState::ROAMING) // only roaming mobs should transition to combat
continue;
@ -85,19 +83,19 @@ void MobAI::followToCombat(Mob *mob) {
}
void MobAI::groupRetreat(Mob *mob) {
if (Mobs.find(mob->groupLeader) == Mobs.end())
if (NPCManager::NPCs.find(mob->groupLeader) == NPCManager::NPCs.end() || NPCManager::NPCs[mob->groupLeader]->type != EntityType::MOB)
return;
Mob* leadMob = Mobs[mob->groupLeader];
Mob* leadMob = (Mob*)NPCManager::NPCs[mob->groupLeader];
for (int i = 0; i < 4; i++) {
if (leadMob->groupMember[i] == 0)
break;
if (Mobs.find(leadMob->groupMember[i]) == Mobs.end()) {
if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->type != EntityType::MOB) {
std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl;
continue;
}
Mob* followerMob = Mobs[leadMob->groupMember[i]];
Mob* followerMob = (Mob*)NPCManager::NPCs[leadMob->groupMember[i]];
followerMob->target = nullptr;
followerMob->state = MobState::RETREAT;
@ -474,8 +472,8 @@ static void deadStep(Mob *mob, time_t currTime) {
// if mob is a group leader/follower, spawn where the group is.
if (mob->groupLeader != 0) {
if (Mobs.find(mob->groupLeader) != Mobs.end()) {
Mob* leaderMob = Mobs[mob->groupLeader];
if (NPCManager::NPCs.find(mob->groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[mob->groupLeader]->type == EntityType::MOB) {
Mob* leaderMob = (Mob*)NPCManager::NPCs[mob->groupLeader];
mob->appearanceData.iX = leaderMob->appearanceData.iX + mob->offsetX;
mob->appearanceData.iY = leaderMob->appearanceData.iY + mob->offsetY;
mob->appearanceData.iZ = leaderMob->appearanceData.iZ;
@ -713,13 +711,13 @@ static void roamingStep(Mob *mob, time_t currTime) {
if (mob->groupMember[i] == 0)
break;
if (Mobs.find(mob->groupMember[i]) == Mobs.end()) {
if (NPCManager::NPCs.find(mob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[mob->groupMember[i]]->type != EntityType::MOB) {
std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl;
continue;
}
std::queue<WarpLocation> queue2;
Mob* followerMob = Mobs[mob->groupMember[i]];
Mob* followerMob = (Mob*)NPCManager::NPCs[mob->groupMember[i]];
from = { followerMob->appearanceData.iX, followerMob->appearanceData.iY, followerMob->appearanceData.iZ };
to = { farX + followerMob->offsetX, farY + followerMob->offsetY, followerMob->appearanceData.iZ };
Transport::lerp(&queue2, from, to, speed);

View File

@ -102,7 +102,6 @@ struct Mob : public CombatNPC {
namespace MobAI {
extern bool simulateMobs;
extern std::map<int32_t, Mob*> Mobs;
// TODO: make this internal later
void incNextMovement(Mob *mob, time_t currTime=0);

View File

@ -59,10 +59,6 @@ void NPCManager::destroyNPC(int32_t id) {
// remove from viewable chunks
Chunking::removeEntityFromChunks(Chunking::getViewableChunks(entity->chunkPos), ref);
// remove from mob manager
if (MobAI::Mobs.find(id) != MobAI::Mobs.end())
MobAI::Mobs.erase(id);
// finally, remove it from the map and free it
NPCs.erase(id);
delete entity;
@ -134,7 +130,6 @@ BaseNPC *NPCManager::summonNPC(int x, int y, int z, uint64_t instance, int type,
if (team == 2) {
npc = new Mob(x, y, z + EXTRA_HEIGHT, inst, type, NPCData[type], id);
MobAI::Mobs[id] = (Mob*)npc;
// re-enable respawning, if desired
((Mob*)npc)->summoned = !respawn;

View File

@ -150,7 +150,7 @@ static void loadPaths(int* nextId) {
lastPoint = point;
}
// npc paths
// npc paths (pending refactor)
nlohmann::json pathDataNPC = pathData["npc"];
/*
for (nlohmann::json::iterator npcPath = pathDataNPC.begin(); npcPath != pathDataNPC.end(); npcPath++) {
@ -161,19 +161,23 @@ static void loadPaths(int* nextId) {
// mob paths
pathDataNPC = pathData["mob"];
for (nlohmann::json::iterator npcPath = pathDataNPC.begin(); npcPath != pathDataNPC.end(); npcPath++) {
for (auto& pair : MobAI::Mobs) {
if (pair.second->appearanceData.iNPCType == npcPath.value()["iNPCType"]) {
std::cout << "[INFO] Using static path for mob " << pair.second->appearanceData.iNPCType << " with ID " << pair.first << std::endl;
for (auto& pair : NPCManager::NPCs) {
if (pair.second->type != EntityType::MOB)
continue;
Mob* mob = (Mob*)pair.second;
if (mob->appearanceData.iNPCType == npcPath.value()["iNPCType"]) {
std::cout << "[INFO] Using static path for mob " << mob->appearanceData.iNPCType << " with ID " << pair.first << std::endl;
auto firstPoint = npcPath.value()["points"][0];
if (firstPoint["iX"] != pair.second->spawnX || firstPoint["iY"] != pair.second->spawnY) {
if (firstPoint["iX"] != mob->spawnX || firstPoint["iY"] != mob->spawnY) {
std::cout << "[FATAL] The first point of the route for mob " << pair.first <<
" (type " << pair.second->appearanceData.iNPCType << ") does not correspond with its spawn point." << std::endl;
" (type " << mob->appearanceData.iNPCType << ") does not correspond with its spawn point." << std::endl;
exit(1);
}
constructPathNPC(npcPath, pair.first);
pair.second->staticPath = true;
mob->staticPath = true;
break; // only one NPC per path
}
}
@ -472,8 +476,6 @@ static void loadGruntwork(int32_t *nextId) {
// re-enable respawning
((Mob*)npc)->summoned = false;
MobAI::Mobs[npc->appearanceData.iNPC_ID] = (Mob*)npc;
} else {
npc = new BaseNPC(mob["iX"], mob["iY"], mob["iZ"], mob["iAngle"], instanceID, mob["iNPCType"], id);
}
@ -496,7 +498,6 @@ static void loadGruntwork(int32_t *nextId) {
((Mob*)tmp)->summoned = false;
NPCManager::NPCs[*nextId] = tmp;
MobAI::Mobs[*nextId] = (Mob*)NPCManager::NPCs[*nextId];
NPCManager::updateNPCPosition(*nextId, leader["iX"], leader["iY"], leader["iZ"], instanceID, leader["iAngle"]);
tmp->groupLeader = *nextId;
@ -515,7 +516,6 @@ static void loadGruntwork(int32_t *nextId) {
((Mob*)tmp)->summoned = false;
NPCManager::NPCs[*nextId] = tmpFol;
MobAI::Mobs[*nextId] = (Mob*)NPCManager::NPCs[*nextId];
NPCManager::updateNPCPosition(*nextId, (int)leader["iX"] + (int)follower["iOffsetX"], (int)leader["iY"] + (int)follower["iOffsetY"], leader["iZ"], instanceID, leader["iAngle"]);
tmpFol->offsetX = follower.find("iOffsetX") == follower.end() ? 0 : (int)follower["iOffsetX"];
@ -806,7 +806,6 @@ void TableData::init() {
Mob *tmp = new Mob(npc["iX"], npc["iY"], npc["iZ"], npc["iAngle"], instanceID, npc["iNPCType"], td, nextId);
NPCManager::NPCs[nextId] = tmp;
MobAI::Mobs[nextId] = (Mob*)NPCManager::NPCs[nextId];
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
nextId++;
@ -832,7 +831,6 @@ void TableData::init() {
Mob* tmp = new Mob(leader["iX"], leader["iY"], leader["iZ"], leader["iAngle"], instanceID, leader["iNPCType"], td, nextId);
NPCManager::NPCs[nextId] = tmp;
MobAI::Mobs[nextId] = (Mob*)NPCManager::NPCs[nextId];
NPCManager::updateNPCPosition(nextId, leader["iX"], leader["iY"], leader["iZ"], instanceID, leader["iAngle"]);
tmp->groupLeader = nextId;
@ -847,7 +845,6 @@ void TableData::init() {
Mob* tmpFol = new Mob((int)leader["iX"] + (int)follower["iOffsetX"], (int)leader["iY"] + (int)follower["iOffsetY"], leader["iZ"], leader["iAngle"], instanceID, follower["iNPCType"], tdFol, nextId);
NPCManager::NPCs[nextId] = tmpFol;
MobAI::Mobs[nextId] = (Mob*)NPCManager::NPCs[nextId];
NPCManager::updateNPCPosition(nextId, (int)leader["iX"] + (int)follower["iOffsetX"], (int)leader["iY"] + (int)follower["iOffsetY"], leader["iZ"], instanceID, leader["iAngle"]);
tmpFol->offsetX = follower.find("iOffsetX") == follower.end() ? 0 : (int)follower["iOffsetX"];
@ -884,10 +881,9 @@ void TableData::init() {
int team = NPCManager::NPCData[(int)npc["iNPCType"]]["m_iTeam"];
if (team == 2) {
if (team == 2)
NPCManager::NPCs[nextId] = new Mob(npc["iX"], npc["iY"], npc["iZ"], npc["iAngle"], instanceID, npc["iNPCType"], NPCManager::NPCData[(int)npc["iNPCType"]], nextId);
MobAI::Mobs[nextId] = (Mob*)NPCManager::NPCs[nextId];
} else
else
NPCManager::NPCs[nextId] = new BaseNPC(npc["iX"], npc["iY"], npc["iZ"], npc["iAngle"], instanceID, npc["iNPCType"], nextId);
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
@ -1010,11 +1006,11 @@ void TableData::flush() {
// add follower data to vector; go until OOB or until follower ID is 0
for (int i = 0; i < 4 && m->groupMember[i] > 0; i++) {
if (MobAI::Mobs.find(m->groupMember[i]) == MobAI::Mobs.end()) {
if (NPCManager::NPCs.find(m->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[m->groupMember[i]]->type != EntityType::MOB) {
std::cout << "[WARN] Follower with ID " << m->groupMember[i] << " not found; skipping\n";
continue;
}
followers.push_back(MobAI::Mobs[m->groupMember[i]]);
followers.push_back((Mob*)NPCManager::NPCs[m->groupMember[i]]);
}
}
else {