mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2026-02-11 14:50:03 +00:00
[WIP] Replace appearance data with individual fields
Storing certain things in appearance data and others in their own fields was gross. Now everything is stored on the same level and functions have been added to generate appearance data when it's needed by the client.
This commit is contained in:
@@ -243,20 +243,20 @@ static void summonWCommand(std::string full, std::vector<std::string>& args, CNS
|
||||
BaseNPC *npc = NPCManager::summonNPC(plr->x, plr->y, plr->z, plr->instanceID, type, true);
|
||||
|
||||
// update angle
|
||||
npc->appearanceData.iAngle = (plr->angle + 180) % 360;
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, plr->x, plr->y, plr->z, plr->instanceID, npc->appearanceData.iAngle);
|
||||
npc->angle = (plr->angle + 180) % 360;
|
||||
NPCManager::updateNPCPosition(npc->id, plr->x, plr->y, plr->z, plr->instanceID, npc->angle);
|
||||
|
||||
// if we're in a lair, we need to spawn the NPC in both the private instance and the template
|
||||
if (PLAYERID(plr->instanceID) != 0) {
|
||||
npc = NPCManager::summonNPC(plr->x, plr->y, plr->z, plr->instanceID, type, true, true);
|
||||
|
||||
npc->appearanceData.iAngle = (plr->angle + 180) % 360;
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, plr->x, plr->y, plr->z, npc->instanceID, npc->appearanceData.iAngle);
|
||||
npc->angle = (plr->angle + 180) % 360;
|
||||
NPCManager::updateNPCPosition(npc->id, plr->x, plr->y, plr->z, npc->instanceID, npc->angle);
|
||||
}
|
||||
|
||||
Chat::sendServerMessage(sock, "/summonW: placed mob with type: " + std::to_string(type) +
|
||||
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||
TableData::RunningMobs[npc->appearanceData.iNPC_ID] = npc; // only record the one in the template
|
||||
", id: " + std::to_string(npc->id));
|
||||
TableData::RunningMobs[npc->id] = npc; // only record the one in the template
|
||||
}
|
||||
|
||||
static void unsummonWCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||
@@ -269,21 +269,21 @@ static void unsummonWCommand(std::string full, std::vector<std::string>& args, C
|
||||
return;
|
||||
}
|
||||
|
||||
if (TableData::RunningEggs.find(npc->appearanceData.iNPC_ID) != TableData::RunningEggs.end()) {
|
||||
Chat::sendServerMessage(sock, "/unsummonW: removed egg with type: " + std::to_string(npc->appearanceData.iNPCType) +
|
||||
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||
TableData::RunningEggs.erase(npc->appearanceData.iNPC_ID);
|
||||
NPCManager::destroyNPC(npc->appearanceData.iNPC_ID);
|
||||
if (TableData::RunningEggs.find(npc->id) != TableData::RunningEggs.end()) {
|
||||
Chat::sendServerMessage(sock, "/unsummonW: removed egg with type: " + std::to_string(npc->type) +
|
||||
", id: " + std::to_string(npc->id));
|
||||
TableData::RunningEggs.erase(npc->id);
|
||||
NPCManager::destroyNPC(npc->id);
|
||||
return;
|
||||
}
|
||||
|
||||
if (TableData::RunningMobs.find(npc->appearanceData.iNPC_ID) == TableData::RunningMobs.end()
|
||||
&& TableData::RunningGroups.find(npc->appearanceData.iNPC_ID) == TableData::RunningGroups.end()) {
|
||||
if (TableData::RunningMobs.find(npc->id) == TableData::RunningMobs.end()
|
||||
&& TableData::RunningGroups.find(npc->id) == TableData::RunningGroups.end()) {
|
||||
Chat::sendServerMessage(sock, "/unsummonW: Closest NPC is not a gruntwork mob.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (NPCManager::NPCs.find(npc->appearanceData.iNPC_ID) != NPCManager::NPCs.end() && NPCManager::NPCs[npc->appearanceData.iNPC_ID]->kind == EntityType::MOB) {
|
||||
if (NPCManager::NPCs.find(npc->id) != NPCManager::NPCs.end() && NPCManager::NPCs[npc->id]->kind == EntityType::MOB) {
|
||||
int leadId = ((Mob*)npc)->groupLeader;
|
||||
if (leadId != 0) {
|
||||
if (NPCManager::NPCs.find(leadId) == NPCManager::NPCs.end() || NPCManager::NPCs[leadId]->kind != EntityType::MOB) {
|
||||
@@ -308,12 +308,12 @@ static void unsummonWCommand(std::string full, std::vector<std::string>& args, C
|
||||
}
|
||||
}
|
||||
|
||||
Chat::sendServerMessage(sock, "/unsummonW: removed mob with type: " + std::to_string(npc->appearanceData.iNPCType) +
|
||||
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||
Chat::sendServerMessage(sock, "/unsummonW: removed mob with type: " + std::to_string(npc->type) +
|
||||
", id: " + std::to_string(npc->id));
|
||||
|
||||
TableData::RunningMobs.erase(npc->appearanceData.iNPC_ID);
|
||||
TableData::RunningMobs.erase(npc->id);
|
||||
|
||||
NPCManager::destroyNPC(npc->appearanceData.iNPC_ID);
|
||||
NPCManager::destroyNPC(npc->id);
|
||||
}
|
||||
|
||||
static void toggleAiCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||
@@ -356,24 +356,24 @@ static void npcRotateCommand(std::string full, std::vector<std::string>& args, C
|
||||
}
|
||||
|
||||
int angle = (plr->angle + 180) % 360;
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, npc->x, npc->y, npc->z, npc->instanceID, angle);
|
||||
NPCManager::updateNPCPosition(npc->id, npc->x, npc->y, npc->z, npc->instanceID, angle);
|
||||
|
||||
// if it's a gruntwork NPC, rotate in-place
|
||||
if (TableData::RunningMobs.find(npc->appearanceData.iNPC_ID) != TableData::RunningMobs.end()) {
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, npc->x, npc->y, npc->z, npc->instanceID, angle);
|
||||
if (TableData::RunningMobs.find(npc->id) != TableData::RunningMobs.end()) {
|
||||
NPCManager::updateNPCPosition(npc->id, npc->x, npc->y, npc->z, npc->instanceID, angle);
|
||||
|
||||
Chat::sendServerMessage(sock, "[NPCR] Successfully set angle to " + std::to_string(angle) + " for gruntwork NPC "
|
||||
+ std::to_string(npc->appearanceData.iNPC_ID));
|
||||
+ std::to_string(npc->id));
|
||||
} else {
|
||||
TableData::RunningNPCRotations[npc->appearanceData.iNPC_ID] = angle;
|
||||
TableData::RunningNPCRotations[npc->id] = angle;
|
||||
|
||||
Chat::sendServerMessage(sock, "[NPCR] Successfully set angle to " + std::to_string(angle) + " for NPC "
|
||||
+ std::to_string(npc->appearanceData.iNPC_ID));
|
||||
+ std::to_string(npc->id));
|
||||
}
|
||||
|
||||
// update rotation clientside
|
||||
INITSTRUCT(sP_FE2CL_NPC_ENTER, pkt);
|
||||
pkt.NPCAppearanceData = npc->appearanceData;
|
||||
pkt.NPCAppearanceData = npc->getAppearanceData();
|
||||
sock->sendPacket(pkt, P_FE2CL_NPC_ENTER);
|
||||
}
|
||||
|
||||
@@ -443,9 +443,9 @@ static void npcInstanceCommand(std::string full, std::vector<std::string>& args,
|
||||
return;
|
||||
}
|
||||
|
||||
Chat::sendServerMessage(sock, "[NPCI] Moving NPC with ID " + std::to_string(npc->appearanceData.iNPC_ID) + " to instance " + std::to_string(instance));
|
||||
TableData::RunningNPCMapNumbers[npc->appearanceData.iNPC_ID] = instance;
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, npc->x, npc->y, npc->z, instance, npc->appearanceData.iAngle);
|
||||
Chat::sendServerMessage(sock, "[NPCI] Moving NPC with ID " + std::to_string(npc->id) + " to instance " + std::to_string(instance));
|
||||
TableData::RunningNPCMapNumbers[npc->id] = instance;
|
||||
NPCManager::updateNPCPosition(npc->id, npc->x, npc->y, npc->z, instance, npc->angle);
|
||||
}
|
||||
|
||||
static void minfoCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||
@@ -610,39 +610,39 @@ 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 && npc->kind == EntityType::MOB) {
|
||||
leadNpc->groupMember[i-1] = npc->appearanceData.iNPC_ID;
|
||||
Mob* mob = (Mob*)NPCManager::NPCs[npc->appearanceData.iNPC_ID];
|
||||
mob->groupLeader = leadNpc->appearanceData.iNPC_ID;
|
||||
leadNpc->groupMember[i-1] = npc->id;
|
||||
Mob* mob = (Mob*)NPCManager::NPCs[npc->id];
|
||||
mob->groupLeader = leadNpc->id;
|
||||
mob->offsetX = x - plr->x;
|
||||
mob->offsetY = y - plr->y;
|
||||
}
|
||||
|
||||
npc->appearanceData.iAngle = (plr->angle + 180) % 360;
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, x, y, z, plr->instanceID, npc->appearanceData.iAngle);
|
||||
npc->angle = (plr->angle + 180) % 360;
|
||||
NPCManager::updateNPCPosition(npc->id, x, y, z, plr->instanceID, npc->angle);
|
||||
|
||||
// if we're in a lair, we need to spawn the NPC in both the private instance and the template
|
||||
if (PLAYERID(plr->instanceID) != 0) {
|
||||
npc = NPCManager::summonNPC(plr->x, plr->y, plr->z, plr->instanceID, type, wCommand, true);
|
||||
|
||||
if (team == 2 && i > 0 && npc->kind == EntityType::MOB) {
|
||||
leadNpc->groupMember[i-1] = npc->appearanceData.iNPC_ID;
|
||||
Mob* mob = (Mob*)NPCManager::NPCs[npc->appearanceData.iNPC_ID];
|
||||
mob->groupLeader = leadNpc->appearanceData.iNPC_ID;
|
||||
leadNpc->groupMember[i-1] = npc->id;
|
||||
Mob* mob = (Mob*)NPCManager::NPCs[npc->id];
|
||||
mob->groupLeader = leadNpc->id;
|
||||
mob->offsetX = x - plr->x;
|
||||
mob->offsetY = y - plr->y;
|
||||
}
|
||||
|
||||
npc->appearanceData.iAngle = (plr->angle + 180) % 360;
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, x, y, z, plr->instanceID, npc->appearanceData.iAngle);
|
||||
npc->angle = (plr->angle + 180) % 360;
|
||||
NPCManager::updateNPCPosition(npc->id, x, y, z, plr->instanceID, npc->angle);
|
||||
}
|
||||
|
||||
Chat::sendServerMessage(sock, "/summonGroup(W): placed mob with type: " + std::to_string(type) +
|
||||
", id: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||
", id: " + std::to_string(npc->id));
|
||||
|
||||
if (i == 0 && team == 2 && npc->kind == EntityType::MOB) {
|
||||
type = type2;
|
||||
leadNpc = (Mob*)NPCManager::NPCs[npc->appearanceData.iNPC_ID];
|
||||
leadNpc->groupLeader = leadNpc->appearanceData.iNPC_ID;
|
||||
leadNpc = (Mob*)NPCManager::NPCs[npc->id];
|
||||
leadNpc->groupLeader = leadNpc->id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -654,7 +654,7 @@ static void summonGroupCommand(std::string full, std::vector<std::string>& args,
|
||||
return;
|
||||
}
|
||||
|
||||
TableData::RunningGroups[leadNpc->appearanceData.iNPC_ID] = leadNpc; // only record the leader
|
||||
TableData::RunningGroups[leadNpc->id] = leadNpc; // only record the leader
|
||||
}
|
||||
|
||||
static void flushCommand(std::string full, std::vector<std::string>& args, CNSocket* sock) {
|
||||
@@ -671,15 +671,15 @@ static void whoisCommand(std::string full, std::vector<std::string>& args, CNSoc
|
||||
return;
|
||||
}
|
||||
|
||||
Chat::sendServerMessage(sock, "[WHOIS] ID: " + std::to_string(npc->appearanceData.iNPC_ID));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] Type: " + std::to_string(npc->appearanceData.iNPCType));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] HP: " + std::to_string(npc->appearanceData.iHP));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] CBF: " + std::to_string(npc->appearanceData.iConditionBitFlag));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] ID: " + std::to_string(npc->id));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] Type: " + std::to_string(npc->type));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] HP: " + std::to_string(npc->hp));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] CBF: " + std::to_string(npc->cbf));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] EntityType: " + std::to_string((int)npc->kind));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] X: " + std::to_string(npc->x));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] Y: " + std::to_string(npc->y));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] Z: " + std::to_string(npc->z));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] Angle: " + std::to_string(npc->appearanceData.iAngle));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] Angle: " + std::to_string(npc->angle));
|
||||
std::string chunkPosition = std::to_string(std::get<0>(npc->chunkPos)) + ", " + std::to_string(std::get<1>(npc->chunkPos)) + ", " + std::to_string(std::get<2>(npc->chunkPos));
|
||||
Chat::sendServerMessage(sock, "[WHOIS] Chunk: {" + chunkPosition + "}");
|
||||
Chat::sendServerMessage(sock, "[WHOIS] MapNum: " + std::to_string(MAPNUM(npc->instanceID)));
|
||||
@@ -705,7 +705,7 @@ static void lairUnlockCommand(std::string full, std::vector<std::string>& args,
|
||||
continue;
|
||||
|
||||
for (auto it = NPCManager::Warps.begin(); it != NPCManager::Warps.end(); it++) {
|
||||
if (it->second.npcID == npc->appearanceData.iNPCType) {
|
||||
if (it->second.npcID == npc->type) {
|
||||
taskID = it->second.limitTaskID;
|
||||
missionID = Missions::Tasks[taskID]->task["m_iHMissionID"];
|
||||
lastDist = dist;
|
||||
@@ -981,7 +981,7 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
pathPoints.push_back(marker);
|
||||
// map from player
|
||||
TableData::RunningNPCPaths[plr->iID] = std::make_pair(npc, pathPoints);
|
||||
Chat::sendServerMessage(sock, "[PATH] NPC " + std::to_string(npc->appearanceData.iNPC_ID) + " is now following you");
|
||||
Chat::sendServerMessage(sock, "[PATH] NPC " + std::to_string(npc->id) + " is now following you");
|
||||
updatePathMarkers(sock);
|
||||
return;
|
||||
}
|
||||
@@ -1008,8 +1008,8 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
// /path here
|
||||
if (args[1] == "here") {
|
||||
// bring the NPC to where the player is standing
|
||||
Transport::NPCQueues.erase(npc->appearanceData.iNPC_ID); // delete transport queue
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, plr->x, plr->y, plr->z, npc->instanceID, 0);
|
||||
Transport::NPCQueues.erase(npc->id); // delete transport queue
|
||||
NPCManager::updateNPCPosition(npc->id, plr->x, plr->y, plr->z, npc->instanceID, 0);
|
||||
npc->disappearFromViewOf(sock);
|
||||
npc->enterIntoViewOf(sock);
|
||||
Chat::sendServerMessage(sock, "[PATH] Come here");
|
||||
@@ -1047,9 +1047,9 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
speed = speedArg;
|
||||
}
|
||||
// return NPC to home
|
||||
Transport::NPCQueues.erase(npc->appearanceData.iNPC_ID); // delete transport queue
|
||||
Transport::NPCQueues.erase(npc->id); // delete transport queue
|
||||
BaseNPC* home = entry->second[0];
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, home->x, home->y, home->z, npc->instanceID, 0);
|
||||
NPCManager::updateNPCPosition(npc->id, home->x, home->y, home->z, npc->instanceID, 0);
|
||||
npc->disappearFromViewOf(sock);
|
||||
npc->enterIntoViewOf(sock);
|
||||
|
||||
@@ -1065,7 +1065,7 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
Transport::lerp(&keyframes, from, to, speed); // lerp from A to B
|
||||
from = to; // update point A
|
||||
}
|
||||
Transport::NPCQueues[npc->appearanceData.iNPC_ID] = keyframes;
|
||||
Transport::NPCQueues[npc->id] = keyframes;
|
||||
entry->second.pop_back(); // remove temp end point
|
||||
|
||||
Chat::sendServerMessage(sock, "[PATH] Testing NPC path");
|
||||
@@ -1075,9 +1075,9 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
// /path cancel
|
||||
if (args[1] == "cancel") {
|
||||
// return NPC to home
|
||||
Transport::NPCQueues.erase(npc->appearanceData.iNPC_ID); // delete transport queue
|
||||
Transport::NPCQueues.erase(npc->id); // delete transport queue
|
||||
BaseNPC* home = entry->second[0];
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, home->x, home->y, home->z, npc->instanceID, 0);
|
||||
NPCManager::updateNPCPosition(npc->id, home->x, home->y, home->z, npc->instanceID, 0);
|
||||
npc->disappearFromViewOf(sock);
|
||||
npc->enterIntoViewOf(sock);
|
||||
// deallocate markers
|
||||
@@ -1087,7 +1087,7 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
}
|
||||
// unmap
|
||||
TableData::RunningNPCPaths.erase(plr->iID);
|
||||
Chat::sendServerMessage(sock, "[PATH] NPC " + std::to_string(npc->appearanceData.iNPC_ID) + " is no longer following you");
|
||||
Chat::sendServerMessage(sock, "[PATH] NPC " + std::to_string(npc->id) + " is no longer following you");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1115,9 +1115,9 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
}
|
||||
|
||||
// return NPC to home and set path to repeat
|
||||
Transport::NPCQueues.erase(npc->appearanceData.iNPC_ID); // delete transport queue
|
||||
Transport::NPCQueues.erase(npc->id); // delete transport queue
|
||||
BaseNPC* home = entry->second[0];
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, home->x, home->y, home->z, npc->instanceID, 0);
|
||||
NPCManager::updateNPCPosition(npc->id, home->x, home->y, home->z, npc->instanceID, 0);
|
||||
npc->disappearFromViewOf(sock);
|
||||
npc->enterIntoViewOf(sock);
|
||||
npc->loopingPath = true;
|
||||
@@ -1134,7 +1134,7 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
Transport::lerp(&keyframes, from, to, speed); // lerp from A to B
|
||||
from = to; // update point A
|
||||
}
|
||||
Transport::NPCQueues[npc->appearanceData.iNPC_ID] = keyframes;
|
||||
Transport::NPCQueues[npc->id] = keyframes;
|
||||
entry->second.pop_back(); // remove temp end point
|
||||
|
||||
// save to gruntwork
|
||||
@@ -1161,7 +1161,7 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
finishedPath.isLoop = true;
|
||||
finishedPath.speed = speed;
|
||||
finishedPath.points = finalPoints;
|
||||
finishedPath.targetIDs.push_back(npc->appearanceData.iNPC_ID);
|
||||
finishedPath.targetIDs.push_back(npc->id);
|
||||
|
||||
TableData::FinishedNPCPaths.push_back(finishedPath);
|
||||
|
||||
@@ -1173,7 +1173,7 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
||||
// unmap
|
||||
TableData::RunningNPCPaths.erase(plr->iID);
|
||||
|
||||
Chat::sendServerMessage(sock, "[PATH] NPC " + std::to_string(npc->appearanceData.iNPC_ID) + " is no longer following you");
|
||||
Chat::sendServerMessage(sock, "[PATH] NPC " + std::to_string(npc->id) + " is no longer following you");
|
||||
|
||||
TableData::flush();
|
||||
Chat::sendServerMessage(sock, "[PATH] Path saved to gruntwork");
|
||||
|
||||
Reference in New Issue
Block a user