Implement temporary NPC rotations

This commit is contained in:
Gent 2020-10-06 17:59:12 -04:00
parent 4873eba160
commit 5009fe1994
2 changed files with 22 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include <fstream> #include <fstream>
std::map<int32_t, std::vector<WarpLocation>> TableData::RunningSkywayRoutes; std::map<int32_t, std::vector<WarpLocation>> TableData::RunningSkywayRoutes;
std::map<int32_t, int> TableData::RunningNPCRotations;
void TableData::init() { void TableData::init() {
int32_t nextId = 0; int32_t nextId = 0;
@ -364,6 +365,17 @@ void TableData::loadGruntwork() {
RunningSkywayRoutes[(int)route["iRouteID"]] = points; RunningSkywayRoutes[(int)route["iRouteID"]] = points;
} }
// npc rotations
auto npcRot = gruntwork["rotations"];
for (auto _rot = npcRot.begin(); _rot != npcRot.end(); _rot++) {
int32_t npcID = _rot.value()["iNPCID"];
int angle = _rot.value()["iAngle"];
if (NPCManager::NPCs.find(npcID) == NPCManager::NPCs.end())
continue; // NPC not found
BaseNPC* npc = NPCManager::NPCs[npcID];
npc->appearanceData.iAngle = angle;
}
std::cout << "[INFO] Loaded gruntwork.json" << std::endl; std::cout << "[INFO] Loaded gruntwork.json" << std::endl;
} }
catch (const std::exception& err) { catch (const std::exception& err) {
@ -396,5 +408,14 @@ void TableData::flush() {
gruntwork["skyway"].push_back(route); gruntwork["skyway"].push_back(route);
} }
for (auto& pair : RunningNPCRotations) {
nlohmann::json rotation;
rotation["iNPCID"] = (int)pair.first;
rotation["iAngle"] = pair.second;
gruntwork["rotations"].push_back(rotation);
}
file << gruntwork << std::endl; file << gruntwork << std::endl;
} }

View File

@ -6,6 +6,7 @@
namespace TableData { namespace TableData {
extern std::map<int32_t, std::vector<WarpLocation>> RunningSkywayRoutes; extern std::map<int32_t, std::vector<WarpLocation>> RunningSkywayRoutes;
extern std::map<int32_t, int> RunningNPCRotations;
void init(); void init();
void cleanup(); void cleanup();