mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-04 22:40:05 +00:00
Add academy.json loading to TableData
This is where the permanent Academy-exclusive NPCs and mobs will be loaded from. Resurrect 'Ems work now.
This commit is contained in:
parent
effbbd9a5e
commit
90191fd494
@ -41,6 +41,8 @@ xdtdata=tdata/xdt.json
|
||||
npcdata=tdata/NPCs.json
|
||||
# mob json
|
||||
mobdata=tdata/mobs.json
|
||||
# academy mobs & npcs json
|
||||
academydata=tdata/academy.json
|
||||
# path json
|
||||
pathdata=tdata/paths.json
|
||||
# drop json
|
||||
|
@ -319,6 +319,40 @@ void TableData::init() {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef ACADEMY
|
||||
// load Academy NPCs from academy.json
|
||||
try {
|
||||
std::ifstream inFile(settings::ACADEMYJSON);
|
||||
nlohmann::json npcData;
|
||||
|
||||
// read file into json
|
||||
inFile >> npcData;
|
||||
npcData = npcData["NPCs"];
|
||||
for (nlohmann::json::iterator _npc = npcData.begin(); _npc != npcData.end(); _npc++) {
|
||||
auto npc = _npc.value();
|
||||
int instanceID = npc.find("iMapNum") == npc.end() ? INSTANCE_OVERWORLD : (int)npc["iMapNum"];
|
||||
|
||||
int team = NPCManager::NPCData[(int)npc["iNPCType"]]["m_iTeam"];
|
||||
|
||||
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);
|
||||
MobManager::Mobs[nextId] = (Mob*)NPCManager::NPCs[nextId];
|
||||
} 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"]);
|
||||
nextId++;
|
||||
|
||||
if (npc["iNPCType"] == 641 || npc["iNPCType"] == 642)
|
||||
NPCManager::RespawnPoints.push_back({ npc["iX"], npc["iY"], ((int)npc["iZ"]) + RESURRECT_HEIGHT, instanceID });
|
||||
}
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
std::cerr << "[FATAL] Malformed academy.json file! Reason:" << err.what() << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
loadDrops();
|
||||
|
||||
loadEggs(&nextId);
|
||||
|
@ -31,6 +31,7 @@ int settings::SPAWN_ANGLE = 130;
|
||||
std::string settings::NPCJSON = "tdata/NPCs.json";
|
||||
std::string settings::XDTJSON = "tdata/xdt.json";
|
||||
std::string settings::MOBJSON = "tdata/mobs.json";
|
||||
std::string settings::ACADEMYJSON = "tdata/academy.json";
|
||||
std::string settings::PATHJSON = "tdata/paths.json";
|
||||
std::string settings::DROPSJSON = "tdata/drops.json";
|
||||
std::string settings::EGGSJSON = "tdata/eggs.json";
|
||||
@ -77,6 +78,7 @@ void settings::init() {
|
||||
NPCJSON = reader.Get("shard", "npcdata", NPCJSON);
|
||||
XDTJSON = reader.Get("shard", "xdtdata", XDTJSON);
|
||||
MOBJSON = reader.Get("shard", "mobdata", MOBJSON);
|
||||
ACADEMYJSON = reader.Get("shard", "academydata", ACADEMYJSON);
|
||||
DROPSJSON = reader.Get("shard", "dropdata", DROPSJSON);
|
||||
EGGSJSON = reader.Get("shard", "eggdata", EGGSJSON);
|
||||
PATHJSON = reader.Get("shard", "pathdata", PATHJSON);
|
||||
|
@ -19,6 +19,7 @@ namespace settings {
|
||||
extern std::string NPCJSON;
|
||||
extern std::string XDTJSON;
|
||||
extern std::string MOBJSON;
|
||||
extern std::string ACADEMYJSON;
|
||||
extern std::string PATHJSON;
|
||||
extern std::string DROPSJSON;
|
||||
extern std::string EGGSJSON;
|
||||
|
Loading…
Reference in New Issue
Block a user