mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-17 03:20:06 +00:00
EntityType -> EntityKind
This commit is contained in:
parent
595dcda1b7
commit
f6094fde58
@ -142,7 +142,7 @@ bool doDebuff(CNSocket *sock, sSkillResult_Buff *respdata, int i, int32_t target
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::NPCs[targetID];
|
BaseNPC* npc = NPCManager::NPCs[targetID];
|
||||||
if (npc->kind != EntityType::MOB) {
|
if (npc->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] doDebuff: NPC is not a mob" << std::endl;
|
std::cout << "[WARN] doDebuff: NPC is not a mob" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ bool doDamageNDebuff(CNSocket *sock, sSkillResult_Damage_N_Debuff *respdata, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::NPCs[targetID];
|
BaseNPC* npc = NPCManager::NPCs[targetID];
|
||||||
if (npc->kind != EntityType::MOB) {
|
if (npc->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] doDamageNDebuff: NPC is not a mob" << std::endl;
|
std::cout << "[WARN] doDamageNDebuff: NPC is not a mob" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ bool doDamage(CNSocket *sock, sSkillResult_Damage *respdata, int i, int32_t targ
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::NPCs[targetID];
|
BaseNPC* npc = NPCManager::NPCs[targetID];
|
||||||
if (npc->kind != EntityType::MOB) {
|
if (npc->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] doDamage: NPC is not a mob" << std::endl;
|
std::cout << "[WARN] doDamage: NPC is not a mob" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -337,7 +337,7 @@ bool doLeech(CNSocket *sock, sSkillResult_Heal_HP *healdata, int i, int32_t targ
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::NPCs[targetID];
|
BaseNPC* npc = NPCManager::NPCs[targetID];
|
||||||
if (npc->kind != EntityType::MOB) {
|
if (npc->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] doLeech: NPC is not a mob" << std::endl;
|
std::cout << "[WARN] doLeech: NPC is not a mob" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ bool doHeal(Mob* mob, sSkillResult_Heal_HP* respdata, int i, int32_t targetID, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::NPCs[targetID];
|
BaseNPC* npc = NPCManager::NPCs[targetID];
|
||||||
if (npc->kind != EntityType::MOB) {
|
if (npc->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] doHeal: NPC is not a mob" << std::endl;
|
std::cout << "[WARN] doHeal: NPC is not a mob" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ void Chunking::trackEntity(ChunkPos chunkPos, const EntityRef& ref) {
|
|||||||
|
|
||||||
chunks[chunkPos]->entities.insert(ref);
|
chunks[chunkPos]->entities.insert(ref);
|
||||||
|
|
||||||
if (ref.type == EntityType::PLAYER)
|
if (ref.kind == EntityKind::PLAYER)
|
||||||
chunks[chunkPos]->nplayers++;
|
chunks[chunkPos]->nplayers++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ void Chunking::untrackEntity(ChunkPos chunkPos, const EntityRef& ref) {
|
|||||||
|
|
||||||
chunk->entities.erase(ref); // gone
|
chunk->entities.erase(ref); // gone
|
||||||
|
|
||||||
if (ref.type == EntityType::PLAYER)
|
if (ref.kind == EntityKind::PLAYER)
|
||||||
chunks[chunkPos]->nplayers--;
|
chunks[chunkPos]->nplayers--;
|
||||||
assert(chunks[chunkPos]->nplayers >= 0);
|
assert(chunks[chunkPos]->nplayers >= 0);
|
||||||
|
|
||||||
@ -89,19 +89,19 @@ void Chunking::addEntityToChunks(std::set<Chunk*> chnks, const EntityRef& ref) {
|
|||||||
Entity *other = otherRef.getEntity();
|
Entity *other = otherRef.getEntity();
|
||||||
|
|
||||||
// notify all visible players of the existence of this Entity
|
// notify all visible players of the existence of this Entity
|
||||||
if (alive && otherRef.type == EntityType::PLAYER) {
|
if (alive && otherRef.kind == EntityKind::PLAYER) {
|
||||||
ent->enterIntoViewOf(otherRef.sock);
|
ent->enterIntoViewOf(otherRef.sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify this *player* of the existence of all visible Entities
|
// notify this *player* of the existence of all visible Entities
|
||||||
if (ref.type == EntityType::PLAYER && other->isExtant()) {
|
if (ref.kind == EntityKind::PLAYER && other->isExtant()) {
|
||||||
other->enterIntoViewOf(ref.sock);
|
other->enterIntoViewOf(ref.sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for mobs, increment playersInView
|
// for mobs, increment playersInView
|
||||||
if (ref.type == EntityType::MOB && otherRef.type == EntityType::PLAYER)
|
if (ref.kind == EntityKind::MOB && otherRef.kind == EntityKind::PLAYER)
|
||||||
((Mob*)ent)->playersInView++;
|
((Mob*)ent)->playersInView++;
|
||||||
if (otherRef.type == EntityType::MOB && ref.type == EntityType::PLAYER)
|
if (otherRef.kind == EntityKind::MOB && ref.kind == EntityKind::PLAYER)
|
||||||
((Mob*)other)->playersInView++;
|
((Mob*)other)->playersInView++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,19 +121,19 @@ void Chunking::removeEntityFromChunks(std::set<Chunk*> chnks, const EntityRef& r
|
|||||||
Entity *other = otherRef.getEntity();
|
Entity *other = otherRef.getEntity();
|
||||||
|
|
||||||
// notify all visible players of the departure of this Entity
|
// notify all visible players of the departure of this Entity
|
||||||
if (alive && otherRef.type == EntityType::PLAYER) {
|
if (alive && otherRef.kind == EntityKind::PLAYER) {
|
||||||
ent->disappearFromViewOf(otherRef.sock);
|
ent->disappearFromViewOf(otherRef.sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify this *player* of the departure of all visible Entities
|
// notify this *player* of the departure of all visible Entities
|
||||||
if (ref.type == EntityType::PLAYER && other->isExtant()) {
|
if (ref.kind == EntityKind::PLAYER && other->isExtant()) {
|
||||||
other->disappearFromViewOf(ref.sock);
|
other->disappearFromViewOf(ref.sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// for mobs, decrement playersInView
|
// for mobs, decrement playersInView
|
||||||
if (ref.type == EntityType::MOB && otherRef.type == EntityType::PLAYER)
|
if (ref.kind == EntityKind::MOB && otherRef.kind == EntityKind::PLAYER)
|
||||||
((Mob*)ent)->playersInView--;
|
((Mob*)ent)->playersInView--;
|
||||||
if (otherRef.type == EntityType::MOB && ref.type == EntityType::PLAYER)
|
if (otherRef.kind == EntityKind::MOB && ref.kind == EntityKind::PLAYER)
|
||||||
((Mob*)other)->playersInView--;
|
((Mob*)other)->playersInView--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ static void emptyChunk(ChunkPos chunkPos) {
|
|||||||
// unspawn all of the mobs/npcs
|
// unspawn all of the mobs/npcs
|
||||||
std::set refs(chunk->entities);
|
std::set refs(chunk->entities);
|
||||||
for (const EntityRef& ref : refs) {
|
for (const EntityRef& ref : refs) {
|
||||||
if (ref.type == EntityType::PLAYER)
|
if (ref.kind == EntityKind::PLAYER)
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
||||||
// every call of this will check if the chunk is empty and delete it if so
|
// every call of this will check if the chunk is empty and delete it if so
|
||||||
@ -268,14 +268,14 @@ void Chunking::createInstance(uint64_t instanceID) {
|
|||||||
std::cout << "Creating instance " << instanceID << std::endl;
|
std::cout << "Creating instance " << instanceID << std::endl;
|
||||||
for (ChunkPos &coords : templateChunks) {
|
for (ChunkPos &coords : templateChunks) {
|
||||||
for (const EntityRef& ref : chunks[coords]->entities) {
|
for (const EntityRef& ref : chunks[coords]->entities) {
|
||||||
if (ref.type == EntityType::PLAYER)
|
if (ref.kind == EntityKind::PLAYER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int npcID = ref.id;
|
int npcID = ref.id;
|
||||||
BaseNPC* baseNPC = (BaseNPC*)ref.getEntity();
|
BaseNPC* baseNPC = (BaseNPC*)ref.getEntity();
|
||||||
|
|
||||||
// make a copy of each NPC in the template chunks and put them in the new instance
|
// make a copy of each NPC in the template chunks and put them in the new instance
|
||||||
if (baseNPC->kind == EntityType::MOB) {
|
if (baseNPC->kind == EntityKind::MOB) {
|
||||||
if (((Mob*)baseNPC)->groupLeader != 0 && ((Mob*)baseNPC)->groupLeader != npcID)
|
if (((Mob*)baseNPC)->groupLeader != 0 && ((Mob*)baseNPC)->groupLeader != npcID)
|
||||||
continue; // follower; don't copy individually
|
continue; // follower; don't copy individually
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ int CombatNPC::takeDamage(EntityRef src, int amt) {
|
|||||||
return 0; // don't hurt a mob casting corruption
|
return 0; // don't hurt a mob casting corruption
|
||||||
|
|
||||||
if (mob->state == AIState::ROAMING) {
|
if (mob->state == AIState::ROAMING) {
|
||||||
assert(mob->target == nullptr && src.type == EntityType::PLAYER); // players only for now
|
assert(mob->target == nullptr && src.kind == EntityKind::PLAYER); // players only for now
|
||||||
mob->transition(AIState::COMBAT, src);
|
mob->transition(AIState::COMBAT, src);
|
||||||
|
|
||||||
if (mob->groupLeader != 0)
|
if (mob->groupLeader != 0)
|
||||||
@ -256,7 +256,7 @@ static void pcAttackNpcs(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::NPCs[targets[i]];
|
BaseNPC* npc = NPCManager::NPCs[targets[i]];
|
||||||
if (npc->kind != EntityType::MOB) {
|
if (npc->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] pcAttackNpcs: NPC is not a mob" << std::endl;
|
std::cout << "[WARN] pcAttackNpcs: NPC is not a mob" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -450,7 +450,7 @@ static void pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t *pktdata = (int32_t*)((uint8_t*)data->buf + sizeof(sP_CL2FE_REQ_PC_ATTACK_CHARs));
|
sGM_PVPTarget* pktdata = (sGM_PVPTarget*)((uint8_t*)data->buf + sizeof(sP_CL2FE_REQ_PC_ATTACK_CHARs));
|
||||||
|
|
||||||
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_ATTACK_CHARs_SUCC), pkt->iTargetCnt, sizeof(sAttackResult))) {
|
if (!validOutVarPacket(sizeof(sP_FE2CL_PC_ATTACK_CHARs_SUCC), pkt->iTargetCnt, sizeof(sAttackResult))) {
|
||||||
std::cout << "[WARN] bad sP_FE2CL_PC_ATTACK_CHARs_SUCC packet size\n";
|
std::cout << "[WARN] bad sP_FE2CL_PC_ATTACK_CHARs_SUCC packet size\n";
|
||||||
@ -471,7 +471,6 @@ static void pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
|||||||
for (int i = 0; i < pkt->iTargetCnt; i++) {
|
for (int i = 0; i < pkt->iTargetCnt; i++) {
|
||||||
|
|
||||||
ICombatant* target = nullptr;
|
ICombatant* target = nullptr;
|
||||||
sGM_PVPTarget* targdata = (sGM_PVPTarget*)(pktdata + i * 2);
|
|
||||||
std::pair<int, int> damage;
|
std::pair<int, int> damage;
|
||||||
|
|
||||||
if (pkt->iTargetCnt > 1)
|
if (pkt->iTargetCnt > 1)
|
||||||
@ -479,10 +478,10 @@ static void pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
|||||||
else
|
else
|
||||||
damage.first = plr->pointDamage;
|
damage.first = plr->pointDamage;
|
||||||
|
|
||||||
if (targdata->eCT == 1) { // eCT == 1; attack player
|
if (pktdata[i].eCT == 1) { // eCT == 1; attack player
|
||||||
|
|
||||||
for (auto& pair : PlayerManager::players) {
|
for (auto& pair : PlayerManager::players) {
|
||||||
if (pair.second->iID == targdata->iID) {
|
if (pair.second->iID == pktdata[i].iID) {
|
||||||
target = pair.second;
|
target = pair.second;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -498,14 +497,14 @@ static void pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
} else { // eCT == 4; attack mob
|
} else { // eCT == 4; attack mob
|
||||||
|
|
||||||
if (NPCManager::NPCs.find(targdata->iID) == NPCManager::NPCs.end()) {
|
if (NPCManager::NPCs.find(pktdata[i].iID) == NPCManager::NPCs.end()) {
|
||||||
// not sure how to best handle this
|
// not sure how to best handle this
|
||||||
std::cout << "[WARN] pcAttackChars: NPC ID not found" << std::endl;
|
std::cout << "[WARN] pcAttackChars: NPC ID not found" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::NPCs[targdata->iID];
|
BaseNPC* npc = NPCManager::NPCs[pktdata[i].iID];
|
||||||
if (npc->kind != EntityType::MOB) {
|
if (npc->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] pcAttackChars: NPC is not a mob" << std::endl;
|
std::cout << "[WARN] pcAttackChars: NPC is not a mob" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -524,7 +523,7 @@ static void pcAttackChars(CNSocket *sock, CNPacketData *data) {
|
|||||||
|
|
||||||
damage.first = target->takeDamage(sock, damage.first);
|
damage.first = target->takeDamage(sock, damage.first);
|
||||||
|
|
||||||
respdata[i].eCT = targdata->eCT;
|
respdata[i].eCT = pktdata[i].eCT;
|
||||||
respdata[i].iID = target->getID();
|
respdata[i].iID = target->getID();
|
||||||
respdata[i].iDamage = damage.first;
|
respdata[i].iDamage = damage.first;
|
||||||
respdata[i].iHP = target->getCurrentHP();
|
respdata[i].iHP = target->getCurrentHP();
|
||||||
@ -707,7 +706,7 @@ static void projectileHit(CNSocket* sock, CNPacketData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseNPC* npc = NPCManager::NPCs[pktdata[i]];
|
BaseNPC* npc = NPCManager::NPCs[pktdata[i]];
|
||||||
if (npc->kind != EntityType::MOB) {
|
if (npc->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] projectileHit: NPC is not a mob" << std::endl;
|
std::cout << "[WARN] projectileHit: NPC is not a mob" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -283,10 +283,10 @@ static void unsummonWCommand(std::string full, std::vector<std::string>& args, C
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NPCManager::NPCs.find(npc->id) != NPCManager::NPCs.end() && NPCManager::NPCs[npc->id]->kind == EntityType::MOB) {
|
if (NPCManager::NPCs.find(npc->id) != NPCManager::NPCs.end() && NPCManager::NPCs[npc->id]->kind == EntityKind::MOB) {
|
||||||
int leadId = ((Mob*)npc)->groupLeader;
|
int leadId = ((Mob*)npc)->groupLeader;
|
||||||
if (leadId != 0) {
|
if (leadId != 0) {
|
||||||
if (NPCManager::NPCs.find(leadId) == NPCManager::NPCs.end() || NPCManager::NPCs[leadId]->kind != EntityType::MOB) {
|
if (NPCManager::NPCs.find(leadId) == NPCManager::NPCs.end() || NPCManager::NPCs[leadId]->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] unsummonW: leader not found!" << std::endl;
|
std::cout << "[WARN] unsummonW: leader not found!" << std::endl;
|
||||||
}
|
}
|
||||||
Mob* leadNpc = (Mob*)NPCManager::NPCs[leadId];
|
Mob* leadNpc = (Mob*)NPCManager::NPCs[leadId];
|
||||||
@ -294,7 +294,7 @@ static void unsummonWCommand(std::string full, std::vector<std::string>& args, C
|
|||||||
if (leadNpc->groupMember[i] == 0)
|
if (leadNpc->groupMember[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (NPCManager::NPCs.find(leadNpc->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadNpc->groupMember[i]]->kind != EntityType::MOB) {
|
if (NPCManager::NPCs.find(leadNpc->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadNpc->groupMember[i]]->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] unsommonW: leader can't find a group member!" << std::endl;
|
std::cout << "[WARN] unsommonW: leader can't find a group member!" << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ static void toggleAiCommand(std::string full, std::vector<std::string>& args, CN
|
|||||||
|
|
||||||
// return all mobs to their spawn points
|
// return all mobs to their spawn points
|
||||||
for (auto& pair : NPCManager::NPCs) {
|
for (auto& pair : NPCManager::NPCs) {
|
||||||
if (pair.second->kind != EntityType::MOB)
|
if (pair.second->kind != EntityKind::MOB)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Mob* mob = (Mob*)pair.second;
|
Mob* mob = (Mob*)pair.second;
|
||||||
@ -609,7 +609,7 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
BaseNPC *npc = NPCManager::summonNPC(x, y, z, plr->instanceID, type, wCommand);
|
BaseNPC *npc = NPCManager::summonNPC(x, y, z, plr->instanceID, type, wCommand);
|
||||||
if (team == 2 && i > 0 && npc->kind == EntityType::MOB) {
|
if (team == 2 && i > 0 && npc->kind == EntityKind::MOB) {
|
||||||
leadNpc->groupMember[i-1] = npc->id;
|
leadNpc->groupMember[i-1] = npc->id;
|
||||||
Mob* mob = (Mob*)NPCManager::NPCs[npc->id];
|
Mob* mob = (Mob*)NPCManager::NPCs[npc->id];
|
||||||
mob->groupLeader = leadNpc->id;
|
mob->groupLeader = leadNpc->id;
|
||||||
@ -624,7 +624,7 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
|
|||||||
if (PLAYERID(plr->instanceID) != 0) {
|
if (PLAYERID(plr->instanceID) != 0) {
|
||||||
npc = NPCManager::summonNPC(plr->x, plr->y, plr->z, plr->instanceID, type, wCommand, true);
|
npc = NPCManager::summonNPC(plr->x, plr->y, plr->z, plr->instanceID, type, wCommand, true);
|
||||||
|
|
||||||
if (team == 2 && i > 0 && npc->kind == EntityType::MOB) {
|
if (team == 2 && i > 0 && npc->kind == EntityKind::MOB) {
|
||||||
leadNpc->groupMember[i-1] = npc->id;
|
leadNpc->groupMember[i-1] = npc->id;
|
||||||
Mob* mob = (Mob*)NPCManager::NPCs[npc->id];
|
Mob* mob = (Mob*)NPCManager::NPCs[npc->id];
|
||||||
mob->groupLeader = leadNpc->id;
|
mob->groupLeader = leadNpc->id;
|
||||||
@ -639,7 +639,7 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
|
|||||||
Chat::sendServerMessage(sock, "/summonGroup(W): placed mob with type: " + std::to_string(type) +
|
Chat::sendServerMessage(sock, "/summonGroup(W): placed mob with type: " + std::to_string(type) +
|
||||||
", id: " + std::to_string(npc->id));
|
", id: " + std::to_string(npc->id));
|
||||||
|
|
||||||
if (i == 0 && team == 2 && npc->kind == EntityType::MOB) {
|
if (i == 0 && team == 2 && npc->kind == EntityKind::MOB) {
|
||||||
type = type2;
|
type = type2;
|
||||||
leadNpc = (Mob*)NPCManager::NPCs[npc->id];
|
leadNpc = (Mob*)NPCManager::NPCs[npc->id];
|
||||||
leadNpc->groupLeader = leadNpc->id;
|
leadNpc->groupLeader = leadNpc->id;
|
||||||
@ -694,7 +694,7 @@ static void lairUnlockCommand(std::string full, std::vector<std::string>& args,
|
|||||||
int lastDist = INT_MAX;
|
int lastDist = INT_MAX;
|
||||||
for (Chunk *chnk : Chunking::getViewableChunks(plr->chunkPos)) {
|
for (Chunk *chnk : Chunking::getViewableChunks(plr->chunkPos)) {
|
||||||
for (const EntityRef& ref : chnk->entities) {
|
for (const EntityRef& ref : chnk->entities) {
|
||||||
if (ref.type == EntityType::PLAYER)
|
if (ref.kind == EntityKind::PLAYER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BaseNPC* npc = (BaseNPC*)ref.getEntity();
|
BaseNPC* npc = (BaseNPC*)ref.getEntity();
|
||||||
|
@ -124,7 +124,7 @@ static void eggStep(CNServer* serv, time_t currTime) {
|
|||||||
|
|
||||||
// check dead eggs and eggs in inactive chunks
|
// check dead eggs and eggs in inactive chunks
|
||||||
for (auto npc : NPCManager::NPCs) {
|
for (auto npc : NPCManager::NPCs) {
|
||||||
if (npc.second->kind != EntityType::EGG)
|
if (npc.second->kind != EntityKind::EGG)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto egg = (Egg*)npc.second;
|
auto egg = (Egg*)npc.second;
|
||||||
@ -163,7 +163,7 @@ static void eggPickup(CNSocket* sock, CNPacketData* data) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto egg = (Egg*)eggRef.getEntity();
|
auto egg = (Egg*)eggRef.getEntity();
|
||||||
if (egg->kind != EntityType::EGG) {
|
if (egg->kind != EntityKind::EGG) {
|
||||||
std::cout << "[WARN] Player tried to open something other than an?!" << std::endl;
|
std::cout << "[WARN] Player tried to open something other than an?!" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ static_assert(std::is_standard_layout<EntityRef>::value);
|
|||||||
static_assert(std::is_trivially_copyable<EntityRef>::value);
|
static_assert(std::is_trivially_copyable<EntityRef>::value);
|
||||||
|
|
||||||
EntityRef::EntityRef(CNSocket *s) {
|
EntityRef::EntityRef(CNSocket *s) {
|
||||||
type = EntityType::PLAYER;
|
kind = EntityKind::PLAYER;
|
||||||
sock = s;
|
sock = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,11 +20,11 @@ EntityRef::EntityRef(int32_t i) {
|
|||||||
id = i;
|
id = i;
|
||||||
|
|
||||||
assert(NPCManager::NPCs.find(id) != NPCManager::NPCs.end());
|
assert(NPCManager::NPCs.find(id) != NPCManager::NPCs.end());
|
||||||
type = NPCManager::NPCs[id]->kind;
|
kind = NPCManager::NPCs[id]->kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityRef::isValid() const {
|
bool EntityRef::isValid() const {
|
||||||
if (type == EntityType::PLAYER)
|
if (kind == EntityKind::PLAYER)
|
||||||
return PlayerManager::players.find(sock) != PlayerManager::players.end();
|
return PlayerManager::players.find(sock) != PlayerManager::players.end();
|
||||||
|
|
||||||
return NPCManager::NPCs.find(id) != NPCManager::NPCs.end();
|
return NPCManager::NPCs.find(id) != NPCManager::NPCs.end();
|
||||||
@ -33,7 +33,7 @@ bool EntityRef::isValid() const {
|
|||||||
Entity *EntityRef::getEntity() const {
|
Entity *EntityRef::getEntity() const {
|
||||||
assert(isValid());
|
assert(isValid());
|
||||||
|
|
||||||
if (type == EntityType::PLAYER)
|
if (kind == EntityKind::PLAYER)
|
||||||
return PlayerManager::getPlayer(sock);
|
return PlayerManager::getPlayer(sock);
|
||||||
|
|
||||||
return NPCManager::NPCs[id];
|
return NPCManager::NPCs[id];
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
enum class EntityType : uint8_t {
|
enum class EntityKind : uint8_t {
|
||||||
INVALID,
|
INVALID,
|
||||||
PLAYER,
|
PLAYER,
|
||||||
SIMPLE_NPC,
|
SIMPLE_NPC,
|
||||||
@ -27,7 +27,7 @@ enum class AIState {
|
|||||||
class Chunk;
|
class Chunk;
|
||||||
|
|
||||||
struct Entity {
|
struct Entity {
|
||||||
EntityType kind = EntityType::INVALID;
|
EntityKind kind = EntityKind::INVALID;
|
||||||
int x = 0, y = 0, z = 0;
|
int x = 0, y = 0, z = 0;
|
||||||
uint64_t instanceID = 0;
|
uint64_t instanceID = 0;
|
||||||
ChunkPos chunkPos = {};
|
ChunkPos chunkPos = {};
|
||||||
@ -44,7 +44,7 @@ struct Entity {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct EntityRef {
|
struct EntityRef {
|
||||||
EntityType type;
|
EntityKind kind;
|
||||||
union {
|
union {
|
||||||
CNSocket *sock;
|
CNSocket *sock;
|
||||||
int32_t id;
|
int32_t id;
|
||||||
@ -57,10 +57,10 @@ struct EntityRef {
|
|||||||
Entity *getEntity() const;
|
Entity *getEntity() const;
|
||||||
|
|
||||||
bool operator==(const EntityRef& other) const {
|
bool operator==(const EntityRef& other) const {
|
||||||
if (type != other.type)
|
if (kind != other.kind)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (type == EntityType::PLAYER)
|
if (kind == EntityKind::PLAYER)
|
||||||
return sock == other.sock;
|
return sock == other.sock;
|
||||||
|
|
||||||
return id == other.id;
|
return id == other.id;
|
||||||
@ -68,21 +68,20 @@ struct EntityRef {
|
|||||||
|
|
||||||
// arbitrary ordering
|
// arbitrary ordering
|
||||||
bool operator<(const EntityRef& other) const {
|
bool operator<(const EntityRef& other) const {
|
||||||
if (type == other.type) {
|
if (kind == other.kind) {
|
||||||
if (type == EntityType::PLAYER)
|
if (kind == EntityKind::PLAYER)
|
||||||
return sock < other.sock;
|
return sock < other.sock;
|
||||||
else
|
else
|
||||||
return id < other.id;
|
return id < other.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return type < other.type;
|
return kind < other.kind;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interfaces
|
* Interfaces
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class ICombatant {
|
class ICombatant {
|
||||||
public:
|
public:
|
||||||
ICombatant() {}
|
ICombatant() {}
|
||||||
@ -173,7 +172,7 @@ struct Egg : public BaseNPC {
|
|||||||
Egg(uint64_t iID, int t, int32_t id, bool summon)
|
Egg(uint64_t iID, int t, int32_t id, bool summon)
|
||||||
: BaseNPC(0, iID, t, id) {
|
: BaseNPC(0, iID, t, id) {
|
||||||
summoned = summon;
|
summoned = summon;
|
||||||
kind = EntityType::EGG;
|
kind = EntityKind::EGG;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isExtant() override { return !dead; }
|
virtual bool isExtant() override { return !dead; }
|
||||||
@ -185,7 +184,7 @@ struct Egg : public BaseNPC {
|
|||||||
struct Bus : public BaseNPC {
|
struct Bus : public BaseNPC {
|
||||||
Bus(int angle, uint64_t iID, int t, int id) :
|
Bus(int angle, uint64_t iID, int t, int id) :
|
||||||
BaseNPC(angle, iID, t, id) {
|
BaseNPC(angle, iID, t, id) {
|
||||||
kind = EntityType::BUS;
|
kind = EntityKind::BUS;
|
||||||
loopingPath = true;
|
loopingPath = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ static void taskStart(CNSocket* sock, CNPacketData* data) {
|
|||||||
for (ChunkPos& chunkPos : Chunking::getChunksInMap(plr->instanceID)) { // check all NPCs in the instance
|
for (ChunkPos& chunkPos : Chunking::getChunksInMap(plr->instanceID)) { // check all NPCs in the instance
|
||||||
Chunk* chunk = Chunking::chunks[chunkPos];
|
Chunk* chunk = Chunking::chunks[chunkPos];
|
||||||
for (EntityRef ref : chunk->entities) {
|
for (EntityRef ref : chunk->entities) {
|
||||||
if (ref.type != EntityType::PLAYER) {
|
if (ref.kind != EntityKind::PLAYER) {
|
||||||
BaseNPC* npc = (BaseNPC*)ref.getEntity();
|
BaseNPC* npc = (BaseNPC*)ref.getEntity();
|
||||||
NPCPath* path = Transport::findApplicablePath(npc->id, npc->type, missionData->iTaskNum);
|
NPCPath* path = Transport::findApplicablePath(npc->id, npc->type, missionData->iTaskNum);
|
||||||
if (path != nullptr) {
|
if (path != nullptr) {
|
||||||
|
@ -58,13 +58,13 @@ void MobAI::clearDebuff(Mob *mob) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MobAI::followToCombat(Mob *mob) {
|
void MobAI::followToCombat(Mob *mob) {
|
||||||
if (NPCManager::NPCs.find(mob->groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[mob->groupLeader]->kind == EntityType::MOB) {
|
if (NPCManager::NPCs.find(mob->groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[mob->groupLeader]->kind == EntityKind::MOB) {
|
||||||
Mob* leadMob = (Mob*)NPCManager::NPCs[mob->groupLeader];
|
Mob* leadMob = (Mob*)NPCManager::NPCs[mob->groupLeader];
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
if (leadMob->groupMember[i] == 0)
|
if (leadMob->groupMember[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->kind != EntityType::MOB) {
|
if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl;
|
std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ void MobAI::followToCombat(Mob *mob) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MobAI::groupRetreat(Mob *mob) {
|
void MobAI::groupRetreat(Mob *mob) {
|
||||||
if (NPCManager::NPCs.find(mob->groupLeader) == NPCManager::NPCs.end() || NPCManager::NPCs[mob->groupLeader]->kind != EntityType::MOB)
|
if (NPCManager::NPCs.find(mob->groupLeader) == NPCManager::NPCs.end() || NPCManager::NPCs[mob->groupLeader]->kind != EntityKind::MOB)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Mob* leadMob = (Mob*)NPCManager::NPCs[mob->groupLeader];
|
Mob* leadMob = (Mob*)NPCManager::NPCs[mob->groupLeader];
|
||||||
@ -92,7 +92,7 @@ void MobAI::groupRetreat(Mob *mob) {
|
|||||||
if (leadMob->groupMember[i] == 0)
|
if (leadMob->groupMember[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->kind != EntityType::MOB) {
|
if (NPCManager::NPCs.find(leadMob->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[leadMob->groupMember[i]]->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl;
|
std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ bool MobAI::aggroCheck(Mob *mob, time_t currTime) {
|
|||||||
Chunk* chunk = *it;
|
Chunk* chunk = *it;
|
||||||
for (const EntityRef& ref : chunk->entities) {
|
for (const EntityRef& ref : chunk->entities) {
|
||||||
// TODO: support targetting other CombatNPCs
|
// TODO: support targetting other CombatNPCs
|
||||||
if (ref.type != EntityType::PLAYER)
|
if (ref.kind != EntityKind::PLAYER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CNSocket *s = ref.sock;
|
CNSocket *s = ref.sock;
|
||||||
@ -304,7 +304,7 @@ static void useAbilities(Mob *mob, time_t currTime) {
|
|||||||
Chunk* chunk = *it;
|
Chunk* chunk = *it;
|
||||||
for (const EntityRef& ref : chunk->entities) {
|
for (const EntityRef& ref : chunk->entities) {
|
||||||
// TODO: see aggroCheck()
|
// TODO: see aggroCheck()
|
||||||
if (ref.type != EntityType::PLAYER)
|
if (ref.kind != EntityKind::PLAYER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CNSocket *s= ref.sock;
|
CNSocket *s= ref.sock;
|
||||||
@ -452,7 +452,7 @@ void Mob::deadStep(time_t currTime) {
|
|||||||
|
|
||||||
// if mob is a group leader/follower, spawn where the group is.
|
// if mob is a group leader/follower, spawn where the group is.
|
||||||
if (groupLeader != 0) {
|
if (groupLeader != 0) {
|
||||||
if (NPCManager::NPCs.find(groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[groupLeader]->kind == EntityType::MOB) {
|
if (NPCManager::NPCs.find(groupLeader) != NPCManager::NPCs.end() && NPCManager::NPCs[groupLeader]->kind == EntityKind::MOB) {
|
||||||
Mob* leaderMob = (Mob*)NPCManager::NPCs[groupLeader];
|
Mob* leaderMob = (Mob*)NPCManager::NPCs[groupLeader];
|
||||||
x = leaderMob->x + offsetX;
|
x = leaderMob->x + offsetX;
|
||||||
y = leaderMob->y + offsetY;
|
y = leaderMob->y + offsetY;
|
||||||
@ -675,7 +675,7 @@ void Mob::roamingStep(time_t currTime) {
|
|||||||
if (groupMember[i] == 0)
|
if (groupMember[i] == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (NPCManager::NPCs.find(groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[groupMember[i]]->kind != EntityType::MOB) {
|
if (NPCManager::NPCs.find(groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[groupMember[i]]->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl;
|
std::cout << "[WARN] roamingStep: leader can't find a group member!" << std::endl;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -743,7 +743,7 @@ void Mob::onRoamStart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mob::onCombatStart(EntityRef src) {
|
void Mob::onCombatStart(EntityRef src) {
|
||||||
assert(src.type == EntityType::PLAYER);
|
assert(src.kind == EntityKind::PLAYER);
|
||||||
target = src.sock;
|
target = src.sock;
|
||||||
nextMovement = getTime();
|
nextMovement = getTime();
|
||||||
nextAttack = 0;
|
nextAttack = 0;
|
||||||
@ -774,7 +774,7 @@ void Mob::onDeath(EntityRef src) {
|
|||||||
killedTime = getTime(); // XXX: maybe introduce a shard-global time for each step?
|
killedTime = getTime(); // XXX: maybe introduce a shard-global time for each step?
|
||||||
|
|
||||||
// check for the edge case where hitting the mob did not aggro it
|
// check for the edge case where hitting the mob did not aggro it
|
||||||
if (src.type == EntityType::PLAYER && src.isValid()) {
|
if (src.kind == EntityKind::PLAYER && src.isValid()) {
|
||||||
Player* plr = PlayerManager::getPlayer(src.sock);
|
Player* plr = PlayerManager::getPlayer(src.sock);
|
||||||
|
|
||||||
Items::DropRoll rolled;
|
Items::DropRoll rolled;
|
||||||
|
@ -60,7 +60,7 @@ struct Mob : public CombatNPC {
|
|||||||
// NOTE: there appear to be discrepancies in the dump
|
// NOTE: there appear to be discrepancies in the dump
|
||||||
hp = maxHealth;
|
hp = maxHealth;
|
||||||
|
|
||||||
kind = EntityType::MOB;
|
kind = EntityKind::MOB;
|
||||||
}
|
}
|
||||||
|
|
||||||
// constructor for /summon
|
// constructor for /summon
|
||||||
|
@ -83,7 +83,7 @@ void NPCManager::sendToViewable(BaseNPC *npc, void *buf, uint32_t type, size_t s
|
|||||||
for (auto it = npc->viewableChunks.begin(); it != npc->viewableChunks.end(); it++) {
|
for (auto it = npc->viewableChunks.begin(); it != npc->viewableChunks.end(); it++) {
|
||||||
Chunk* chunk = *it;
|
Chunk* chunk = *it;
|
||||||
for (const EntityRef& ref : chunk->entities) {
|
for (const EntityRef& ref : chunk->entities) {
|
||||||
if (ref.type == EntityType::PLAYER)
|
if (ref.kind == EntityKind::PLAYER)
|
||||||
ref.sock->sendPacket(buf, type, size);
|
ref.sock->sendPacket(buf, type, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,7 +275,7 @@ BaseNPC* NPCManager::getNearestNPC(std::set<Chunk*>* chunks, int X, int Y, int Z
|
|||||||
for (auto c = chunks->begin(); c != chunks->end(); c++) { // haha get it
|
for (auto c = chunks->begin(); c != chunks->end(); c++) { // haha get it
|
||||||
Chunk* chunk = *c;
|
Chunk* chunk = *c;
|
||||||
for (auto ent = chunk->entities.begin(); ent != chunk->entities.end(); ent++) {
|
for (auto ent = chunk->entities.begin(); ent != chunk->entities.end(); ent++) {
|
||||||
if (ent->type == EntityType::PLAYER)
|
if (ent->kind == EntityKind::PLAYER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BaseNPC* npcTemp = (BaseNPC*)ent->getEntity();
|
BaseNPC* npcTemp = (BaseNPC*)ent->getEntity();
|
||||||
@ -351,7 +351,7 @@ void NPCManager::queueNPCRemoval(int32_t id) {
|
|||||||
|
|
||||||
static void step(CNServer *serv, time_t currTime) {
|
static void step(CNServer *serv, time_t currTime) {
|
||||||
for (auto& pair : NPCs) {
|
for (auto& pair : NPCs) {
|
||||||
if (pair.second->kind != EntityType::COMBAT_NPC && pair.second->kind != EntityType::MOB)
|
if (pair.second->kind != EntityKind::COMBAT_NPC && pair.second->kind != EntityKind::MOB)
|
||||||
continue;
|
continue;
|
||||||
auto npc = (CombatNPC*)pair.second;
|
auto npc = (CombatNPC*)pair.second;
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ struct Player : public Entity, public ICombatant {
|
|||||||
time_t lastShot = 0;
|
time_t lastShot = 0;
|
||||||
std::vector<sItemBase> buyback = {};
|
std::vector<sItemBase> buyback = {};
|
||||||
|
|
||||||
Player() { kind = EntityType::PLAYER; }
|
Player() { kind = EntityKind::PLAYER; }
|
||||||
|
|
||||||
virtual void enterIntoViewOf(CNSocket *sock) override;
|
virtual void enterIntoViewOf(CNSocket *sock) override;
|
||||||
virtual void disappearFromViewOf(CNSocket *sock) override;
|
virtual void disappearFromViewOf(CNSocket *sock) override;
|
||||||
|
@ -353,7 +353,7 @@ void PlayerManager::sendToViewable(CNSocket* sock, void* buf, uint32_t type, siz
|
|||||||
for (auto it = plr->viewableChunks.begin(); it != plr->viewableChunks.end(); it++) {
|
for (auto it = plr->viewableChunks.begin(); it != plr->viewableChunks.end(); it++) {
|
||||||
Chunk* chunk = *it;
|
Chunk* chunk = *it;
|
||||||
for (const EntityRef& ref : chunk->entities) {
|
for (const EntityRef& ref : chunk->entities) {
|
||||||
if (ref.type != EntityType::PLAYER || ref.sock == sock)
|
if (ref.kind != EntityKind::PLAYER || ref.sock == sock)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ref.sock->sendPacket(buf, type, size);
|
ref.sock->sendPacket(buf, type, size);
|
||||||
|
@ -43,7 +43,7 @@ namespace PlayerManager {
|
|||||||
for (auto it = plr->viewableChunks.begin(); it != plr->viewableChunks.end(); it++) {
|
for (auto it = plr->viewableChunks.begin(); it != plr->viewableChunks.end(); it++) {
|
||||||
Chunk* chunk = *it;
|
Chunk* chunk = *it;
|
||||||
for (const EntityRef& ref : chunk->entities) {
|
for (const EntityRef& ref : chunk->entities) {
|
||||||
if (ref.type != EntityType::PLAYER || ref.sock == sock)
|
if (ref.kind != EntityKind::PLAYER || ref.sock == sock)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ref.sock->sendPacket(pkt, type);
|
ref.sock->sendPacket(pkt, type);
|
||||||
|
@ -1226,7 +1226,7 @@ void TableData::flush() {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
if (npc->kind == EntityType::MOB) {
|
if (npc->kind == EntityKind::MOB) {
|
||||||
Mob *m = (Mob*)npc;
|
Mob *m = (Mob*)npc;
|
||||||
x = m->spawnX;
|
x = m->spawnX;
|
||||||
y = m->spawnY;
|
y = m->spawnY;
|
||||||
@ -1259,7 +1259,7 @@ void TableData::flush() {
|
|||||||
|
|
||||||
int x, y, z;
|
int x, y, z;
|
||||||
std::vector<Mob*> followers;
|
std::vector<Mob*> followers;
|
||||||
if (npc->kind == EntityType::MOB) {
|
if (npc->kind == EntityKind::MOB) {
|
||||||
Mob* m = (Mob*)npc;
|
Mob* m = (Mob*)npc;
|
||||||
x = m->spawnX;
|
x = m->spawnX;
|
||||||
y = m->spawnY;
|
y = m->spawnY;
|
||||||
@ -1271,7 +1271,7 @@ void TableData::flush() {
|
|||||||
|
|
||||||
// add follower data to vector; go until OOB or until follower ID is 0
|
// 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++) {
|
for (int i = 0; i < 4 && m->groupMember[i] > 0; i++) {
|
||||||
if (NPCManager::NPCs.find(m->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[m->groupMember[i]]->kind != EntityType::MOB) {
|
if (NPCManager::NPCs.find(m->groupMember[i]) == NPCManager::NPCs.end() || NPCManager::NPCs[m->groupMember[i]]->kind != EntityKind::MOB) {
|
||||||
std::cout << "[WARN] Follower with ID " << m->groupMember[i] << " not found; skipping\n";
|
std::cout << "[WARN] Follower with ID " << m->groupMember[i] << " not found; skipping\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -257,13 +257,13 @@ static void stepNPCPathing() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip if not simulating mobs
|
// skip if not simulating mobs
|
||||||
if (npc->kind == EntityType::MOB && !MobAI::simulateMobs) {
|
if (npc->kind == EntityKind::MOB && !MobAI::simulateMobs) {
|
||||||
it++;
|
it++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// do not roam if not roaming
|
// do not roam if not roaming
|
||||||
if (npc->kind == EntityType::MOB && ((Mob*)npc)->state != AIState::ROAMING) {
|
if (npc->kind == EntityKind::MOB && ((Mob*)npc)->state != AIState::ROAMING) {
|
||||||
it++;
|
it++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -280,7 +280,7 @@ static void stepNPCPathing() {
|
|||||||
|
|
||||||
// TODO: move walking logic into Entity stack
|
// TODO: move walking logic into Entity stack
|
||||||
switch (npc->kind) {
|
switch (npc->kind) {
|
||||||
case EntityType::BUS:
|
case EntityKind::BUS:
|
||||||
INITSTRUCT(sP_FE2CL_TRANSPORTATION_MOVE, busMove);
|
INITSTRUCT(sP_FE2CL_TRANSPORTATION_MOVE, busMove);
|
||||||
|
|
||||||
busMove.eTT = 3;
|
busMove.eTT = 3;
|
||||||
@ -293,7 +293,7 @@ static void stepNPCPathing() {
|
|||||||
|
|
||||||
NPCManager::sendToViewable(npc, &busMove, P_FE2CL_TRANSPORTATION_MOVE, sizeof(sP_FE2CL_TRANSPORTATION_MOVE));
|
NPCManager::sendToViewable(npc, &busMove, P_FE2CL_TRANSPORTATION_MOVE, sizeof(sP_FE2CL_TRANSPORTATION_MOVE));
|
||||||
break;
|
break;
|
||||||
case EntityType::MOB:
|
case EntityKind::MOB:
|
||||||
MobAI::incNextMovement((Mob*)npc);
|
MobAI::incNextMovement((Mob*)npc);
|
||||||
/* fallthrough */
|
/* fallthrough */
|
||||||
default:
|
default:
|
||||||
@ -385,7 +385,7 @@ NPCPath* Transport::findApplicablePath(int32_t id, int32_t type, int taskID) {
|
|||||||
|
|
||||||
void Transport::constructPathNPC(int32_t id, NPCPath* path) {
|
void Transport::constructPathNPC(int32_t id, NPCPath* path) {
|
||||||
BaseNPC* npc = NPCManager::NPCs[id];
|
BaseNPC* npc = NPCManager::NPCs[id];
|
||||||
if (npc->kind == EntityType::MOB)
|
if (npc->kind == EntityKind::MOB)
|
||||||
((Mob*)(npc))->staticPath = true;
|
((Mob*)(npc))->staticPath = true;
|
||||||
npc->loopingPath = path->isLoop;
|
npc->loopingPath = path->isLoop;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user