mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2025-12-24 12:50:05 +00:00
Added /summonW and /unsummonW gruntwork commands.
Also: * Filled in the battery fileds in the REWARD_ITEM packets in MissionManager. * Removed redundant NPC_ENTER in npcSummonHandler()
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
std::map<int32_t, std::vector<WarpLocation>> TableData::RunningSkywayRoutes;
|
||||
std::map<int32_t, int> TableData::RunningNPCRotations;
|
||||
std::map<int32_t, BaseNPC*> TableData::RunningMobs;
|
||||
|
||||
void TableData::init() {
|
||||
int32_t nextId = 0;
|
||||
@@ -197,7 +198,7 @@ void TableData::init() {
|
||||
std::cerr << "[WARN] Malformed mobs.json file! Reason:" << err.what() << std::endl;
|
||||
}
|
||||
|
||||
loadGruntwork();
|
||||
loadGruntwork(&nextId);
|
||||
|
||||
NPCManager::nextId = nextId;
|
||||
}
|
||||
@@ -340,7 +341,7 @@ void TableData::constructPathNPC(nlohmann::json::iterator _pathData) {
|
||||
}
|
||||
|
||||
// load gruntwork output; if it exists
|
||||
void TableData::loadGruntwork() {
|
||||
void TableData::loadGruntwork(int32_t *nextId) {
|
||||
try {
|
||||
std::ifstream inFile(settings::GRUNTWORKJSON);
|
||||
nlohmann::json gruntwork;
|
||||
@@ -376,6 +377,23 @@ void TableData::loadGruntwork() {
|
||||
npc->appearanceData.iAngle = angle;
|
||||
}
|
||||
|
||||
// mobs
|
||||
auto mobs = gruntwork["mobs"];
|
||||
for (auto _mob = mobs.begin(); _mob != mobs.end(); _mob++) {
|
||||
auto mob = _mob.value();
|
||||
|
||||
Mob *npc = new Mob(mob["iX"], mob["iY"], mob["iZ"], INSTANCE_OVERWORLD, mob["iNPCType"],
|
||||
NPCManager::NPCData[(int)mob["iNPCType"]], (*nextId)++);
|
||||
|
||||
NPCManager::NPCs[npc->appearanceData.iNPC_ID] = npc;
|
||||
MobManager::Mobs[npc->appearanceData.iNPC_ID] = npc;
|
||||
TableData::RunningMobs[npc->appearanceData.iNPC_ID] = npc;
|
||||
NPCManager::updateNPCPosition(npc->appearanceData.iNPC_ID, mob["iX"], mob["iY"], mob["iZ"]);
|
||||
|
||||
// re-enable respawning
|
||||
npc->summoned = false;
|
||||
}
|
||||
|
||||
std::cout << "[INFO] Loaded gruntwork.json" << std::endl;
|
||||
}
|
||||
catch (const std::exception& err) {
|
||||
@@ -417,5 +435,24 @@ void TableData::flush() {
|
||||
gruntwork["rotations"].push_back(rotation);
|
||||
}
|
||||
|
||||
for (auto& pair : RunningMobs) {
|
||||
nlohmann::json mob;
|
||||
Mob *m = (Mob*)pair.second; // we need spawnX, etc
|
||||
|
||||
if (NPCManager::NPCs.find(pair.first) == NPCManager::NPCs.end())
|
||||
continue;
|
||||
|
||||
// NOTE: this format deviates slightly from the one in mobs.json
|
||||
mob["iNPCType"] = (int)m->appearanceData.iNPCType;
|
||||
mob["iHP"] = (int)m->maxHealth;
|
||||
mob["iX"] = m->spawnX;
|
||||
mob["iY"] = m->spawnY;
|
||||
mob["iZ"] = m->spawnZ;
|
||||
// this is a bit imperfect, since this is a live angle, not a spawn angle so it'll change often, but eh
|
||||
mob["iAngle"] = m->appearanceData.iAngle;
|
||||
|
||||
gruntwork["mobs"].push_back(mob);
|
||||
}
|
||||
|
||||
file << gruntwork << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user