Load NPC angles from NPCs.json.

This commit is contained in:
dongresource 2020-10-14 02:30:54 +02:00
parent 3586b76888
commit 6ee5e6d1ae
5 changed files with 11 additions and 11 deletions

View File

@ -45,8 +45,8 @@ struct Mob : public BaseNPC {
// temporary; until we're sure what's what // temporary; until we're sure what's what
nlohmann::json data; nlohmann::json data;
Mob(int x, int y, int z, int iID, int type, int hp, int angle, nlohmann::json d, int32_t id) Mob(int x, int y, int z, int angle, int iID, int type, int hp, nlohmann::json d, int32_t id)
: BaseNPC(x, y, z, iID, type, id), maxHealth(hp) { : BaseNPC(x, y, z, angle, iID, type, id), maxHealth(hp) {
state = MobState::ROAMING; state = MobState::ROAMING;
data = d; data = d;
@ -72,7 +72,7 @@ struct Mob : public BaseNPC {
// constructor for /summon // constructor for /summon
Mob(int x, int y, int z, int iID, int type, nlohmann::json d, int32_t id) Mob(int x, int y, int z, int iID, int type, nlohmann::json d, int32_t id)
: Mob(x, y, z, iID, type, 0, 0, d, id) { : Mob(x, y, z, 0, iID, type, 0, d, id) {
summoned = true; // will be despawned and deallocated when killed summoned = true; // will be despawned and deallocated when killed
appearanceData.iHP = maxHealth = d["m_iHP"]; appearanceData.iHP = maxHealth = d["m_iHP"];
} }

View File

@ -12,13 +12,13 @@ public:
std::vector<Chunk*> currentChunks; std::vector<Chunk*> currentChunks;
BaseNPC() {}; BaseNPC() {};
BaseNPC(int x, int y, int z, int iID, int type, int id) { BaseNPC(int x, int y, int z, int angle, int iID, int type, int id) {
appearanceData.iX = x; appearanceData.iX = x;
appearanceData.iY = y; appearanceData.iY = y;
appearanceData.iZ = z; appearanceData.iZ = z;
appearanceData.iNPCType = type; appearanceData.iNPCType = type;
appearanceData.iHP = 400; appearanceData.iHP = 400;
appearanceData.iAngle = 0; appearanceData.iAngle = angle;
appearanceData.iConditionBitFlag = 0; appearanceData.iConditionBitFlag = 0;
appearanceData.iBarkerType = 0; appearanceData.iBarkerType = 0;
appearanceData.iNPC_ID = id; appearanceData.iNPC_ID = id;
@ -27,7 +27,7 @@ public:
chunkPos = std::make_tuple(0, 0, instanceID); chunkPos = std::make_tuple(0, 0, instanceID);
}; };
BaseNPC(int x, int y, int z, int iID, int type, int id, NPCClass classType) : BaseNPC(x, y, z, iID, type, id) { BaseNPC(int x, int y, int z, int angle, int iID, int type, int id, NPCClass classType) : BaseNPC(x, y, z, angle, iID, type, id) {
npcClass = classType; npcClass = classType;
} }
}; };

View File

@ -548,7 +548,7 @@ void NPCManager::npcSummonHandler(CNSocket* sock, CNPacketData* data) {
NPCs[id] = new Mob(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, NPCData[req->iNPCType], id); NPCs[id] = new Mob(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, NPCData[req->iNPCType], id);
MobManager::Mobs[id] = (Mob*)NPCs[id]; MobManager::Mobs[id] = (Mob*)NPCs[id];
} else } else
NPCs[id] = new BaseNPC(plr->x, plr->y, plr->z, plr->instanceID, req->iNPCType, id); NPCs[id] = new BaseNPC(plr->x, plr->y, plr->z, 0, plr->instanceID, req->iNPCType, id);
updateNPCPosition(id, plr->x, plr->y, plr->z); updateNPCPosition(id, plr->x, plr->y, plr->z);
} }

View File

@ -29,7 +29,7 @@ void TableData::init() {
for (nlohmann::json::iterator _npc = npcData.begin(); _npc != npcData.end(); _npc++) { for (nlohmann::json::iterator _npc = npcData.begin(); _npc != npcData.end(); _npc++) {
auto npc = _npc.value(); auto npc = _npc.value();
BaseNPC *tmp = new BaseNPC(npc["x"], npc["y"], npc["z"], INSTANCE_OVERWORLD, npc["id"], nextId); BaseNPC *tmp = new BaseNPC(npc["x"], npc["y"], npc["z"], npc["angle"], INSTANCE_OVERWORLD, npc["id"], nextId);
NPCManager::NPCs[nextId] = tmp; NPCManager::NPCs[nextId] = tmp;
NPCManager::updateNPCPosition(nextId, npc["x"], npc["y"], npc["z"]); NPCManager::updateNPCPosition(nextId, npc["x"], npc["y"], npc["z"]);
@ -181,7 +181,7 @@ void TableData::init() {
for (nlohmann::json::iterator _npc = npcData.begin(); _npc != npcData.end(); _npc++) { for (nlohmann::json::iterator _npc = npcData.begin(); _npc != npcData.end(); _npc++) {
auto npc = _npc.value(); auto npc = _npc.value();
auto td = NPCManager::NPCData[(int)npc["iNPCType"]]; auto td = NPCManager::NPCData[(int)npc["iNPCType"]];
Mob *tmp = new Mob(npc["iX"], npc["iY"], npc["iZ"], INSTANCE_OVERWORLD, npc["iNPCType"], npc["iHP"], npc["iAngle"], td, nextId); Mob *tmp = new Mob(npc["iX"], npc["iY"], npc["iZ"], npc["iAngle"], INSTANCE_OVERWORLD, npc["iNPCType"], npc["iHP"], td, nextId);
NPCManager::NPCs[nextId] = tmp; NPCManager::NPCs[nextId] = tmp;
MobManager::Mobs[nextId] = (Mob*)NPCManager::NPCs[nextId]; MobManager::Mobs[nextId] = (Mob*)NPCManager::NPCs[nextId];
@ -250,7 +250,7 @@ void TableData::loadPaths(int* nextId) {
auto sliderPoint = _sliderPoint.value(); auto sliderPoint = _sliderPoint.value();
if (sliderPoint["stop"] && sliders % 2 == 0) { // check if this point in the circuit is a stop if (sliderPoint["stop"] && sliders % 2 == 0) { // check if this point in the circuit is a stop
// spawn a slider // spawn a slider
BaseNPC* slider = new BaseNPC(sliderPoint["iX"], sliderPoint["iY"], sliderPoint["iZ"], INSTANCE_OVERWORLD, 1, (*nextId)++, NPC_BUS); BaseNPC* slider = new BaseNPC(sliderPoint["iX"], sliderPoint["iY"], sliderPoint["iZ"], 0, INSTANCE_OVERWORLD, 1, (*nextId)++, NPC_BUS);
NPCManager::NPCs[slider->appearanceData.iNPC_ID] = slider; NPCManager::NPCs[slider->appearanceData.iNPC_ID] = slider;
NPCManager::updateNPCPosition(slider->appearanceData.iNPC_ID, slider->appearanceData.iX, slider->appearanceData.iY, slider->appearanceData.iZ); NPCManager::updateNPCPosition(slider->appearanceData.iNPC_ID, slider->appearanceData.iX, slider->appearanceData.iY, slider->appearanceData.iZ);
// set slider path to a rotation of the circuit // set slider path to a rotation of the circuit

2
tdata

@ -1 +1 @@
Subproject commit f9430771644d21b2c7c350ab0cf46e27987e91f3 Subproject commit b9a74bd8145f093b7fa8aef8b74191ac672d3dd2