2020-09-09 17:06:22 +00:00
|
|
|
#include "TableData.hpp"
|
|
|
|
#include "NPCManager.hpp"
|
2020-09-13 20:26:16 +00:00
|
|
|
#include "TransportManager.hpp"
|
2020-09-13 22:54:47 +00:00
|
|
|
#include "ItemManager.hpp"
|
2020-09-09 17:06:22 +00:00
|
|
|
#include "settings.hpp"
|
2020-09-09 19:09:01 +00:00
|
|
|
#include "MissionManager.hpp"
|
2020-09-16 23:43:48 +00:00
|
|
|
#include "MobManager.hpp"
|
2020-09-17 22:45:43 +00:00
|
|
|
#include "ChunkManager.hpp"
|
2020-09-25 05:35:27 +00:00
|
|
|
#include "NanoManager.hpp"
|
2020-09-09 19:09:01 +00:00
|
|
|
|
2020-09-09 17:06:22 +00:00
|
|
|
#include "contrib/JSON.hpp"
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
2020-09-09 19:09:01 +00:00
|
|
|
void TableData::init() {
|
2020-09-24 22:36:25 +00:00
|
|
|
int32_t nextId = 0;
|
2020-09-09 17:06:22 +00:00
|
|
|
|
|
|
|
// load NPCs from NPC.json
|
|
|
|
try {
|
|
|
|
std::ifstream inFile(settings::NPCJSON);
|
|
|
|
nlohmann::json npcData;
|
|
|
|
|
|
|
|
// read file into json
|
|
|
|
inFile >> npcData;
|
|
|
|
|
2020-09-16 23:43:48 +00:00
|
|
|
for (nlohmann::json::iterator _npc = npcData.begin(); _npc != npcData.end(); _npc++) {
|
|
|
|
auto npc = _npc.value();
|
2020-10-01 01:44:37 +00:00
|
|
|
BaseNPC *tmp = new BaseNPC(npc["x"], npc["y"], npc["z"], INSTANCE_OVERWORLD, npc["id"], nextId);
|
2020-09-14 13:53:48 +00:00
|
|
|
|
2020-09-24 22:36:25 +00:00
|
|
|
NPCManager::NPCs[nextId] = tmp;
|
2020-09-25 01:58:20 +00:00
|
|
|
NPCManager::updateNPCPosition(nextId, npc["x"], npc["y"], npc["z"]);
|
2020-09-24 22:36:25 +00:00
|
|
|
nextId++;
|
2020-09-09 17:06:22 +00:00
|
|
|
|
2020-09-16 23:43:48 +00:00
|
|
|
if (npc["id"] == 641 || npc["id"] == 642)
|
|
|
|
NPCManager::RespawnPoints.push_back({ npc["x"], npc["y"], ((int)npc["z"]) + RESURRECT_HEIGHT });
|
2020-09-09 17:06:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (const std::exception& err) {
|
|
|
|
std::cerr << "[WARN] Malformed NPCs.json file! Reason:" << err.what() << std::endl;
|
|
|
|
}
|
|
|
|
|
2020-09-25 18:42:31 +00:00
|
|
|
loadPaths(&nextId); // load paths
|
2020-09-17 02:27:21 +00:00
|
|
|
|
2020-09-09 17:06:22 +00:00
|
|
|
// load everything else from xdttable
|
2020-09-09 22:31:09 +00:00
|
|
|
std::cout << "[INFO] Parsing xdt.json..." << std::endl;
|
2020-09-09 19:09:01 +00:00
|
|
|
std::ifstream infile(settings::XDTJSON);
|
|
|
|
nlohmann::json xdtData;
|
2020-09-09 17:06:22 +00:00
|
|
|
|
2020-09-09 19:09:01 +00:00
|
|
|
// read file into json
|
|
|
|
infile >> xdtData;
|
2020-09-09 17:06:22 +00:00
|
|
|
|
2020-09-24 22:36:25 +00:00
|
|
|
// data we'll need for summoned mobs
|
|
|
|
NPCManager::NPCData = xdtData["m_pNpcTable"]["m_pNpcData"];
|
|
|
|
|
2020-09-09 19:09:01 +00:00
|
|
|
try {
|
2020-09-09 22:31:09 +00:00
|
|
|
// load warps
|
2020-09-09 17:06:22 +00:00
|
|
|
nlohmann::json warpData = xdtData["m_pInstanceTable"]["m_pWarpData"];
|
|
|
|
|
2020-09-16 23:43:48 +00:00
|
|
|
for (nlohmann::json::iterator _warp = warpData.begin(); _warp != warpData.end(); _warp++) {
|
|
|
|
auto warp = _warp.value();
|
|
|
|
WarpLocation warpLoc = { warp["m_iToX"], warp["m_iToY"], warp["m_iToZ"] };
|
|
|
|
int warpID = warp["m_iWarpNumber"];
|
2020-09-09 17:06:22 +00:00
|
|
|
NPCManager::Warps[warpID] = warpLoc;
|
|
|
|
}
|
|
|
|
|
2020-09-10 16:40:38 +00:00
|
|
|
std::cout << "[INFO] Populated " << NPCManager::Warps.size() << " Warps" << std::endl;
|
2020-09-09 19:09:01 +00:00
|
|
|
|
2020-09-13 20:26:16 +00:00
|
|
|
// load transport routes and locations
|
|
|
|
nlohmann::json transRouteData = xdtData["m_pTransportationTable"]["m_pTransportationData"];
|
|
|
|
nlohmann::json transLocData = xdtData["m_pTransportationTable"]["m_pTransportationWarpLocation"];
|
|
|
|
|
2020-09-16 23:43:48 +00:00
|
|
|
for (nlohmann::json::iterator _tLoc = transLocData.begin(); _tLoc != transLocData.end(); _tLoc++) {
|
|
|
|
auto tLoc = _tLoc.value();
|
|
|
|
TransportLocation transLoc = { tLoc["m_iNPCID"], tLoc["m_iXpos"], tLoc["m_iYpos"], tLoc["m_iZpos"] };
|
|
|
|
TransportManager::Locations[tLoc["m_iLocationID"]] = transLoc;
|
2020-09-13 20:26:16 +00:00
|
|
|
}
|
2020-09-24 22:36:25 +00:00
|
|
|
std::cout << "[INFO] Loaded " << TransportManager::Locations.size() << " S.C.A.M.P.E.R. locations" << std::endl;
|
2020-09-13 20:26:16 +00:00
|
|
|
|
2020-09-16 23:43:48 +00:00
|
|
|
for (nlohmann::json::iterator _tRoute = transRouteData.begin(); _tRoute != transRouteData.end(); _tRoute++) {
|
|
|
|
auto tRoute = _tRoute.value();
|
|
|
|
TransportRoute transRoute = { tRoute["m_iMoveType"], tRoute["m_iStartLocation"], tRoute["m_iEndLocation"],
|
|
|
|
tRoute["m_iCost"] , tRoute["m_iSpeed"], tRoute["m_iRouteNum"] };
|
|
|
|
TransportManager::Routes[tRoute["m_iVehicleID"]] = transRoute;
|
2020-09-13 20:26:16 +00:00
|
|
|
}
|
|
|
|
std::cout << "[INFO] Loaded " << TransportManager::Routes.size() << " transportation routes" << std::endl;
|
|
|
|
|
2020-09-10 13:01:35 +00:00
|
|
|
// load mission-related data
|
2020-09-09 19:09:01 +00:00
|
|
|
nlohmann::json tasks = xdtData["m_pMissionTable"]["m_pMissionData"];
|
|
|
|
|
|
|
|
for (auto _task = tasks.begin(); _task != tasks.end(); _task++) {
|
|
|
|
auto task = _task.value();
|
|
|
|
|
|
|
|
// rewards
|
|
|
|
if (task["m_iSUReward"] != 0) {
|
2020-09-10 16:40:38 +00:00
|
|
|
auto _rew = xdtData["m_pMissionTable"]["m_pRewardData"][(int)task["m_iSUReward"]];
|
|
|
|
Reward *rew = new Reward(_rew["m_iMissionRewardID"], _rew["m_iMissionRewarItemType"],
|
|
|
|
_rew["m_iMissionRewardItemID"], _rew["m_iCash"], _rew["m_iFusionMatter"]);
|
2020-09-09 19:09:01 +00:00
|
|
|
|
|
|
|
MissionManager::Rewards[task["m_iHTaskID"]] = rew;
|
|
|
|
}
|
2020-09-09 22:31:09 +00:00
|
|
|
|
2020-09-10 16:40:38 +00:00
|
|
|
// everything else lol. see TaskData comment.
|
|
|
|
MissionManager::Tasks[task["m_iHTaskID"]] = new TaskData(task);
|
2020-09-09 19:09:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "[INFO] Loaded mission-related data" << std::endl;
|
2020-09-13 22:54:47 +00:00
|
|
|
|
2020-09-14 04:25:14 +00:00
|
|
|
// load all item data. i'm sorry. it has to be done
|
2020-09-14 05:27:20 +00:00
|
|
|
const char* setNames[12] = { "m_pBackItemTable", "m_pFaceItemTable", "m_pGlassItemTable", "m_pHatItemTable",
|
2020-09-14 04:25:14 +00:00
|
|
|
"m_pHeadItemTable", "m_pPantsItemTable", "m_pShirtsItemTable", "m_pShoesItemTable", "m_pWeaponItemTable",
|
2020-09-14 05:27:20 +00:00
|
|
|
"m_pVehicleItemTable", "m_pGeneralItemTable", "m_pChestItemTable" };
|
2020-09-14 04:25:14 +00:00
|
|
|
nlohmann::json itemSet;
|
2020-09-14 05:27:20 +00:00
|
|
|
for (int i = 0; i < 12; i++) {
|
2020-09-14 04:25:14 +00:00
|
|
|
itemSet = xdtData[setNames[i]]["m_pItemData"];
|
2020-09-16 23:43:48 +00:00
|
|
|
for (nlohmann::json::iterator _item = itemSet.begin(); _item != itemSet.end(); _item++) {
|
|
|
|
auto item = _item.value();
|
2020-09-19 20:22:28 +00:00
|
|
|
int typeOverride = getItemType(i); // used for special cases where iEquipLoc doesn't indicate item type
|
2020-09-17 16:59:30 +00:00
|
|
|
ItemManager::ItemData[std::pair<int32_t, int32_t>(item["m_iItemNumber"], typeOverride != -1 ? typeOverride : (int)item["m_iEquipLoc"])]
|
2020-09-27 01:53:03 +00:00
|
|
|
= { item["m_iTradeAble"] == 1, item["m_iSellAble"] == 1, item["m_iItemPrice"], item["m_iItemSellPrice"], item["m_iStackNumber"], i > 9 ? 0 : (int)item["m_iMinReqLev"], i > 9 ? 1 : (int)item["m_iRarity"], i > 9 ? 0 : (int)item["m_iPointRat"], i > 9 ? 0 : (int)item["m_iGroupRat"], i > 9 ? 0 : (int)item["m_iDefenseRat"] };
|
2020-09-16 23:43:48 +00:00
|
|
|
}
|
2020-09-14 04:25:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "[INFO] Loaded " << ItemManager::ItemData.size() << " items" << std::endl;
|
|
|
|
|
2020-09-23 19:44:27 +00:00
|
|
|
// load player limits from m_pAvatarTable.m_pAvatarGrowData
|
|
|
|
|
|
|
|
nlohmann::json growth = xdtData["m_pAvatarTable"]["m_pAvatarGrowData"];
|
|
|
|
|
2020-09-26 01:48:45 +00:00
|
|
|
for (int i = 0; i < 37; i++) {
|
2020-09-23 19:44:27 +00:00
|
|
|
MissionManager::AvatarGrowth[i] = growth[i];
|
|
|
|
}
|
|
|
|
|
2020-09-13 22:54:47 +00:00
|
|
|
// load vendor listings
|
|
|
|
nlohmann::json listings = xdtData["m_pVendorTable"]["m_pItemData"];
|
|
|
|
|
2020-09-16 23:43:48 +00:00
|
|
|
for (nlohmann::json::iterator _lst = listings.begin(); _lst != listings.end(); _lst++) {
|
|
|
|
auto lst = _lst.value();
|
|
|
|
VendorListing vListing = { lst["m_iSortNumber"], lst["m_iItemType"], lst["m_iitemID"] };
|
|
|
|
ItemManager::VendorTables[lst["m_iNpcNumber"]].push_back(vListing);
|
2020-09-13 22:54:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "[INFO] Loaded " << ItemManager::VendorTables.size() << " vendor tables" << std::endl;
|
2020-09-16 00:30:01 +00:00
|
|
|
|
|
|
|
// load crocpot entries
|
|
|
|
nlohmann::json crocs = xdtData["m_pCombiningTable"]["m_pCombiningData"];
|
|
|
|
|
|
|
|
for (nlohmann::json::iterator croc = crocs.begin(); croc != crocs.end(); croc++) {
|
|
|
|
CrocPotEntry crocEntry = { croc.value()["m_iStatConstant"], croc.value()["m_iLookConstant"], croc.value()["m_fLevelGapStandard"],
|
|
|
|
croc.value()["m_fSameGrade"], croc.value()["m_fOneGrade"], croc.value()["m_fTwoGrade"], croc.value()["m_fThreeGrade"] };
|
|
|
|
ItemManager::CrocPotTable[croc.value()["m_iLevelGap"]] = crocEntry;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "[INFO] Loaded " << ItemManager::CrocPotTable.size() << " croc pot value sets" << std::endl;
|
2020-09-25 05:35:27 +00:00
|
|
|
|
|
|
|
//load nano info
|
|
|
|
nlohmann::json nanoInfo = xdtData["m_pNanoTable"]["m_pNanoData"];
|
|
|
|
for (nlohmann::json::iterator _nano = nanoInfo.begin(); _nano != nanoInfo.end(); _nano++) {
|
|
|
|
auto nano = _nano.value();
|
|
|
|
NanoData nanoData;
|
|
|
|
nanoData.style = nano["m_iStyle"];
|
|
|
|
NanoManager::NanoTable[nano["m_iNanoNumber"]] = nanoData;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "[INFO] Loaded " << NanoManager::NanoTable.size() << " nanos" << std::endl;
|
2020-09-09 17:06:22 +00:00
|
|
|
}
|
|
|
|
catch (const std::exception& err) {
|
|
|
|
std::cerr << "[WARN] Malformed xdt.json file! Reason:" << err.what() << std::endl;
|
|
|
|
}
|
2020-09-16 23:43:48 +00:00
|
|
|
|
|
|
|
// load temporary mob dump
|
|
|
|
try {
|
|
|
|
std::ifstream inFile(settings::MOBJSON);
|
|
|
|
nlohmann::json npcData;
|
|
|
|
|
|
|
|
// read file into json
|
|
|
|
inFile >> npcData;
|
|
|
|
|
|
|
|
for (nlohmann::json::iterator _npc = npcData.begin(); _npc != npcData.end(); _npc++) {
|
|
|
|
auto npc = _npc.value();
|
2020-09-24 22:36:25 +00:00
|
|
|
auto td = NPCManager::NPCData[(int)npc["iNPCType"]];
|
2020-10-01 01:44:37 +00:00
|
|
|
Mob *tmp = new Mob(npc["iX"], npc["iY"], npc["iZ"], INSTANCE_OVERWORLD, npc["iNPCType"], npc["iHP"], npc["iAngle"], td, nextId);
|
2020-09-16 23:43:48 +00:00
|
|
|
|
2020-09-24 22:36:25 +00:00
|
|
|
NPCManager::NPCs[nextId] = tmp;
|
|
|
|
MobManager::Mobs[nextId] = (Mob*)NPCManager::NPCs[nextId];
|
2020-09-25 01:58:20 +00:00
|
|
|
NPCManager::updateNPCPosition(nextId, npc["iX"], npc["iY"], npc["iZ"]);
|
2020-09-16 23:43:48 +00:00
|
|
|
|
2020-09-24 22:36:25 +00:00
|
|
|
nextId++;
|
2020-09-16 23:43:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "[INFO] Populated " << NPCManager::NPCs.size() << " NPCs" << std::endl;
|
|
|
|
}
|
|
|
|
catch (const std::exception& err) {
|
|
|
|
std::cerr << "[WARN] Malformed mobs.json file! Reason:" << err.what() << std::endl;
|
|
|
|
}
|
2020-09-24 22:36:25 +00:00
|
|
|
|
|
|
|
NPCManager::nextId = nextId;
|
2020-09-09 19:09:01 +00:00
|
|
|
}
|
|
|
|
|
2020-09-19 20:22:28 +00:00
|
|
|
/*
|
2020-09-25 21:05:36 +00:00
|
|
|
* Some item categories either don't possess iEquipLoc or use a different value for item type.
|
|
|
|
*/
|
2020-09-17 16:59:30 +00:00
|
|
|
int TableData::getItemType(int itemSet) {
|
|
|
|
int overriden;
|
|
|
|
switch (itemSet)
|
|
|
|
{
|
2020-09-19 20:22:28 +00:00
|
|
|
case 11: // Chest items don't have iEquipLoc and are type 9.
|
2020-09-17 16:59:30 +00:00
|
|
|
overriden = 9;
|
|
|
|
break;
|
2020-09-19 20:22:28 +00:00
|
|
|
case 10: // General items don't have iEquipLoc and are type 7.
|
2020-09-17 16:59:30 +00:00
|
|
|
overriden = 7;
|
|
|
|
break;
|
2020-09-19 20:22:28 +00:00
|
|
|
case 9: // Vehicles have iEquipLoc 8, but type 10.
|
2020-09-17 16:59:30 +00:00
|
|
|
overriden = 10;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
overriden = -1;
|
|
|
|
}
|
|
|
|
return overriden;
|
|
|
|
}
|
2020-09-17 09:04:00 +00:00
|
|
|
|
2020-09-22 01:03:48 +00:00
|
|
|
/*
|
|
|
|
* Load paths from paths JSON.
|
|
|
|
*/
|
2020-09-25 18:42:31 +00:00
|
|
|
void TableData::loadPaths(int* nextId) {
|
2020-09-22 01:03:48 +00:00
|
|
|
try {
|
|
|
|
std::ifstream inFile(settings::PATHJSON);
|
|
|
|
nlohmann::json pathData;
|
|
|
|
|
|
|
|
// read file into json
|
|
|
|
inFile >> pathData;
|
|
|
|
|
|
|
|
// skyway paths
|
|
|
|
nlohmann::json pathDataSkyway = pathData["skyway"];
|
|
|
|
for (nlohmann::json::iterator skywayPath = pathDataSkyway.begin(); skywayPath != pathDataSkyway.end(); skywayPath++) {
|
2020-09-24 14:14:37 +00:00
|
|
|
constructPathSkyway(skywayPath);
|
2020-09-22 01:03:48 +00:00
|
|
|
}
|
|
|
|
std::cout << "[INFO] Loaded " << TransportManager::SkywayPaths.size() << " skyway paths" << std::endl;
|
2020-09-24 14:14:37 +00:00
|
|
|
|
2020-09-25 18:42:31 +00:00
|
|
|
// slider circuit
|
2020-09-26 22:45:19 +00:00
|
|
|
int sliders = 0;
|
2020-09-25 18:42:31 +00:00
|
|
|
nlohmann::json pathDataSlider = pathData["slider"];
|
|
|
|
for (nlohmann::json::iterator _sliderPoint = pathDataSlider.begin(); _sliderPoint != pathDataSlider.end(); _sliderPoint++) {
|
|
|
|
auto sliderPoint = _sliderPoint.value();
|
2020-09-26 22:45:19 +00:00
|
|
|
if (sliderPoint["stop"] && sliders % 2 == 0) { // check if this point in the circuit is a stop
|
2020-09-25 18:42:31 +00:00
|
|
|
// spawn a slider
|
|
|
|
BaseNPC* slider = new BaseNPC(sliderPoint["iX"], sliderPoint["iY"], sliderPoint["iZ"], 1, (*nextId)++, NPC_BUS);
|
|
|
|
NPCManager::NPCs[slider->appearanceData.iNPC_ID] = slider;
|
|
|
|
NPCManager::updateNPCPosition(slider->appearanceData.iNPC_ID, slider->appearanceData.iX, slider->appearanceData.iY, slider->appearanceData.iZ);
|
|
|
|
// set slider path to a rotation of the circuit
|
|
|
|
constructPathSlider(pathDataSlider, 0, slider->appearanceData.iNPC_ID);
|
2020-09-26 22:45:19 +00:00
|
|
|
sliders++;
|
2020-09-25 18:42:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-24 14:14:37 +00:00
|
|
|
// npc paths
|
|
|
|
nlohmann::json pathDataNPC = pathData["npc"];
|
|
|
|
for (nlohmann::json::iterator npcPath = pathDataNPC.begin(); npcPath != pathDataNPC.end(); npcPath++) {
|
|
|
|
constructPathNPC(npcPath);
|
|
|
|
}
|
|
|
|
std::cout << "[INFO] Loaded " << TransportManager::NPCQueues.size() << " NPC paths" << std::endl;
|
2020-09-22 01:03:48 +00:00
|
|
|
}
|
|
|
|
catch (const std::exception& err) {
|
|
|
|
std::cerr << "[WARN] Malformed paths.json file! Reason:" << err.what() << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2020-09-24 14:14:37 +00:00
|
|
|
* Create a full and properly-paced path by interpolating between keyframes.
|
2020-09-22 01:03:48 +00:00
|
|
|
*/
|
2020-09-24 14:14:37 +00:00
|
|
|
void TableData::constructPathSkyway(nlohmann::json::iterator _pathData) {
|
2020-09-22 01:03:48 +00:00
|
|
|
auto pathData = _pathData.value();
|
2020-09-17 09:04:00 +00:00
|
|
|
// Interpolate
|
2020-09-22 01:03:48 +00:00
|
|
|
nlohmann::json pathPoints = pathData["points"];
|
2020-09-17 09:04:00 +00:00
|
|
|
std::queue<WarpLocation> points;
|
2020-09-22 01:03:48 +00:00
|
|
|
nlohmann::json::iterator _point = pathPoints.begin();
|
|
|
|
auto point = _point.value();
|
|
|
|
WarpLocation last = { point["iX"] , point["iY"] , point["iZ"] }; // start pos
|
|
|
|
// use some for loop trickery; start position should not be a point
|
|
|
|
for (_point++; _point != pathPoints.end(); _point++) {
|
|
|
|
point = _point.value();
|
|
|
|
WarpLocation coords = { point["iX"] , point["iY"] , point["iZ"] };
|
2020-09-23 14:53:06 +00:00
|
|
|
TransportManager::lerp(&points, last, coords, pathData["iMonkeySpeed"]);
|
2020-09-22 01:03:48 +00:00
|
|
|
points.push(coords); // add keyframe to the queue
|
2020-09-17 09:04:00 +00:00
|
|
|
last = coords; // update start pos
|
|
|
|
}
|
2020-09-22 01:03:48 +00:00
|
|
|
TransportManager::SkywayPaths[pathData["iRouteID"]] = points;
|
2020-09-17 09:04:00 +00:00
|
|
|
}
|
2020-09-24 14:14:37 +00:00
|
|
|
|
2020-09-25 18:42:31 +00:00
|
|
|
void TableData::constructPathSlider(nlohmann::json points, int rotations, int sliderID) {
|
|
|
|
|
|
|
|
std::queue<WarpLocation> route;
|
|
|
|
std::rotate(points.begin(), points.begin() + rotations, points.end()); // rotate points
|
|
|
|
nlohmann::json::iterator _point = points.begin(); // iterator
|
|
|
|
auto point = _point.value();
|
|
|
|
WarpLocation from = { point["iX"] , point["iY"] , point["iZ"] }; // point A coords
|
|
|
|
int stopTime = point["stop"] ? SLIDER_STOP_TICKS : 0; // arbitrary stop length
|
|
|
|
for (_point++; _point != points.end(); _point++) { // loop through all point Bs
|
|
|
|
point = _point.value();
|
|
|
|
for (int i = 0; i < stopTime + 1; i++) // repeat point if it's a stop
|
|
|
|
route.push(from); // add point A to the queue
|
|
|
|
WarpLocation to = { point["iX"] , point["iY"] , point["iZ"] }; // point B coords
|
2020-09-26 22:45:19 +00:00
|
|
|
float curve = 1;
|
|
|
|
if (stopTime > 0) { // point A is a stop
|
|
|
|
curve = 2.0f;
|
|
|
|
} else if (point["stop"]) { // point B is a stop
|
|
|
|
curve = 0.35f;
|
|
|
|
}
|
|
|
|
TransportManager::lerp(&route, from, to, SLIDER_SPEED, curve); // lerp from A to B (arbitrary speed)
|
2020-09-25 18:42:31 +00:00
|
|
|
from = to; // update point A
|
|
|
|
stopTime = point["stop"] ? SLIDER_STOP_TICKS : 0;
|
|
|
|
}
|
|
|
|
std::rotate(points.rbegin(), points.rbegin() + rotations, points.rend()); // undo rotation
|
|
|
|
TransportManager::NPCQueues[sliderID] = route;
|
|
|
|
}
|
|
|
|
|
2020-09-24 14:14:37 +00:00
|
|
|
void TableData::constructPathNPC(nlohmann::json::iterator _pathData) {
|
|
|
|
auto pathData = _pathData.value();
|
|
|
|
// Interpolate
|
|
|
|
nlohmann::json pathPoints = pathData["points"];
|
|
|
|
std::queue<WarpLocation> points;
|
|
|
|
nlohmann::json::iterator _point = pathPoints.begin();
|
|
|
|
auto point = _point.value();
|
|
|
|
WarpLocation from = { point["iX"] , point["iY"] , point["iZ"] }; // point A coords
|
|
|
|
int stopTime = point["stop"];
|
|
|
|
for (_point++; _point != pathPoints.end(); _point++) { // loop through all point Bs
|
|
|
|
point = _point.value();
|
|
|
|
for(int i = 0; i < stopTime + 1; i++) // repeat point if it's a stop
|
|
|
|
points.push(from); // add point A to the queue
|
|
|
|
WarpLocation to = { point["iX"] , point["iY"] , point["iZ"] }; // point B coords
|
|
|
|
TransportManager::lerp(&points, from, to, pathData["iBaseSpeed"]); // lerp from A to B
|
|
|
|
from = to; // update point A
|
|
|
|
stopTime = point["stop"];
|
|
|
|
}
|
|
|
|
TransportManager::NPCQueues[pathData["iNPCID"]] = points;
|
|
|
|
}
|