mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-26 15:00:06 +00:00
[refactor] Remove redundant coord args from most entity constructors
Mobs and CombatNPCs still need theirs in order to properly set their roaming and spawn coords. Assignment of the latter has been moved to the CombatNPC constructor, where it should have already been.
This commit is contained in:
parent
0a8ef2ebbd
commit
520efd6dd5
@ -310,8 +310,7 @@ void Chunking::createInstance(uint64_t instanceID) {
|
|||||||
NPCManager::updateNPCPosition(newMob->id, baseNPC->x, baseNPC->y, baseNPC->z,
|
NPCManager::updateNPCPosition(newMob->id, baseNPC->x, baseNPC->y, baseNPC->z,
|
||||||
instanceID, baseNPC->angle);
|
instanceID, baseNPC->angle);
|
||||||
} else {
|
} else {
|
||||||
BaseNPC* newNPC = new BaseNPC(baseNPC->x, baseNPC->y, baseNPC->z, baseNPC->angle,
|
BaseNPC* newNPC = new BaseNPC(baseNPC->angle, instanceID, baseNPC->type, NPCManager::nextId--);
|
||||||
instanceID, baseNPC->type, NPCManager::nextId--);
|
|
||||||
NPCManager::NPCs[newNPC->id] = newNPC;
|
NPCManager::NPCs[newNPC->id] = newNPC;
|
||||||
NPCManager::updateNPCPosition(newNPC->id, baseNPC->x, baseNPC->y, baseNPC->z,
|
NPCManager::updateNPCPosition(newNPC->id, baseNPC->x, baseNPC->y, baseNPC->z,
|
||||||
instanceID, baseNPC->angle);
|
instanceID, baseNPC->angle);
|
||||||
|
@ -532,7 +532,7 @@ static void eggCommand(std::string full, std::vector<std::string>& args, CNSocke
|
|||||||
int addX = 0; //-500.0f * sin(plr->angle / 180.0f * M_PI);
|
int addX = 0; //-500.0f * sin(plr->angle / 180.0f * M_PI);
|
||||||
int addY = 0; //-500.0f * cos(plr->angle / 180.0f * M_PI);
|
int addY = 0; //-500.0f * cos(plr->angle / 180.0f * M_PI);
|
||||||
|
|
||||||
Egg* egg = new Egg(plr->x + addX, plr->y + addY, plr->z, plr->instanceID, eggType, id, false); // change last arg to true after gruntwork
|
Egg* egg = new Egg(plr->instanceID, eggType, id, false); // change last arg to true after gruntwork
|
||||||
NPCManager::NPCs[id] = egg;
|
NPCManager::NPCs[id] = egg;
|
||||||
NPCManager::updateNPCPosition(id, plr->x + addX, plr->y + addY, plr->z, plr->instanceID, plr->angle);
|
NPCManager::updateNPCPosition(id, plr->x + addX, plr->y + addY, plr->z, plr->instanceID, plr->angle);
|
||||||
|
|
||||||
@ -977,7 +977,13 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
|||||||
|
|
||||||
// add first point at NPC's current location
|
// add first point at NPC's current location
|
||||||
std::vector<BaseNPC*> pathPoints;
|
std::vector<BaseNPC*> pathPoints;
|
||||||
BaseNPC* marker = new BaseNPC(npc->x, npc->y, npc->z, 0, plr->instanceID, 1386, NPCManager::nextId--);
|
BaseNPC* marker = new BaseNPC(0, plr->instanceID, 1386, NPCManager::nextId--);
|
||||||
|
|
||||||
|
// assign coords manually, since we aren't actually adding markers to the world
|
||||||
|
marker->x = npc->x;
|
||||||
|
marker->y = npc->y;
|
||||||
|
marker->z = npc->z;
|
||||||
|
|
||||||
pathPoints.push_back(marker);
|
pathPoints.push_back(marker);
|
||||||
// map from player
|
// map from player
|
||||||
TableData::RunningNPCPaths[plr->iID] = std::make_pair(npc, pathPoints);
|
TableData::RunningNPCPaths[plr->iID] = std::make_pair(npc, pathPoints);
|
||||||
@ -998,7 +1004,12 @@ static void pathCommand(std::string full, std::vector<std::string>& args, CNSock
|
|||||||
|
|
||||||
// /path kf
|
// /path kf
|
||||||
if (args[1] == "kf") {
|
if (args[1] == "kf") {
|
||||||
BaseNPC* marker = new BaseNPC(npc->x, npc->y, npc->z, 0, plr->instanceID, 1386, NPCManager::nextId--);
|
BaseNPC* marker = new BaseNPC(0, plr->instanceID, 1386, NPCManager::nextId--);
|
||||||
|
|
||||||
|
marker->x = npc->x;
|
||||||
|
marker->y = npc->y;
|
||||||
|
marker->z = npc->z;
|
||||||
|
|
||||||
entry->second.push_back(marker);
|
entry->second.push_back(marker);
|
||||||
Chat::sendServerMessage(sock, "[PATH] Added keyframe");
|
Chat::sendServerMessage(sock, "[PATH] Added keyframe");
|
||||||
updatePathMarkers(sock);
|
updatePathMarkers(sock);
|
||||||
|
@ -82,10 +82,7 @@ public:
|
|||||||
int barkerType;
|
int barkerType;
|
||||||
bool loopingPath = false;
|
bool loopingPath = false;
|
||||||
|
|
||||||
BaseNPC(int _X, int _Y, int _Z, int _A, uint64_t iID, int t, int _id) { // XXX
|
BaseNPC(int _A, uint64_t iID, int t, int _id) {
|
||||||
x = _X;
|
|
||||||
y = _Y;
|
|
||||||
z = _Z;
|
|
||||||
type = t;
|
type = t;
|
||||||
hp = 400;
|
hp = 400;
|
||||||
angle = _A;
|
angle = _A;
|
||||||
@ -111,10 +108,12 @@ struct CombatNPC : public BaseNPC {
|
|||||||
|
|
||||||
void (*_stepAI)(CombatNPC*, time_t) = nullptr;
|
void (*_stepAI)(CombatNPC*, time_t) = nullptr;
|
||||||
|
|
||||||
// XXX
|
CombatNPC(int x, int y, int z, int angle, uint64_t iID, int t, int id, int maxHP)
|
||||||
CombatNPC(int x, int y, int z, int angle, uint64_t iID, int t, int id, int maxHP) :
|
: BaseNPC(angle, iID, t, id), maxHealth(maxHP) {
|
||||||
BaseNPC(x, y, z, angle, iID, t, id),
|
spawnX = x;
|
||||||
maxHealth(maxHP) {}
|
spawnY = y;
|
||||||
|
spawnZ = z;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void stepAI(time_t currTime) {
|
virtual void stepAI(time_t currTime) {
|
||||||
if (_stepAI != nullptr)
|
if (_stepAI != nullptr)
|
||||||
@ -132,8 +131,8 @@ struct Egg : public BaseNPC {
|
|||||||
bool dead = false;
|
bool dead = false;
|
||||||
time_t deadUntil;
|
time_t deadUntil;
|
||||||
|
|
||||||
Egg(int x, int y, int z, uint64_t iID, int t, int32_t id, bool summon)
|
Egg(uint64_t iID, int t, int32_t id, bool summon)
|
||||||
: BaseNPC(x, y, z, 0, iID, t, id) {
|
: BaseNPC(0, iID, t, id) {
|
||||||
summoned = summon;
|
summoned = summon;
|
||||||
kind = EntityType::EGG;
|
kind = EntityType::EGG;
|
||||||
}
|
}
|
||||||
@ -146,8 +145,8 @@ struct Egg : public BaseNPC {
|
|||||||
|
|
||||||
// TODO: decouple from BaseNPC
|
// TODO: decouple from BaseNPC
|
||||||
struct Bus : public BaseNPC {
|
struct Bus : public BaseNPC {
|
||||||
Bus(int x, int y, int z, int angle, uint64_t iID, int t, int id) :
|
Bus(int angle, uint64_t iID, int t, int id) :
|
||||||
BaseNPC(x, y, z, angle, iID, t, id) {
|
BaseNPC(angle, iID, t, id) {
|
||||||
kind = EntityType::BUS;
|
kind = EntityType::BUS;
|
||||||
loopingPath = true;
|
loopingPath = true;
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,9 @@ struct Mob : public CombatNPC {
|
|||||||
idleRange = (int)data["m_iIdleRange"];
|
idleRange = (int)data["m_iIdleRange"];
|
||||||
level = data["m_iNpcLevel"];
|
level = data["m_iNpcLevel"];
|
||||||
|
|
||||||
roamX = spawnX = x;
|
roamX = x;
|
||||||
roamY = spawnY = y;
|
roamY = y;
|
||||||
roamZ = spawnZ = z;
|
roamZ = z;
|
||||||
|
|
||||||
offsetX = 0;
|
offsetX = 0;
|
||||||
offsetY = 0;
|
offsetY = 0;
|
||||||
|
@ -122,7 +122,6 @@ static void npcUnsummonHandler(CNSocket* sock, CNPacketData* data) {
|
|||||||
// type must already be checked and updateNPCPosition() must be called on the result
|
// type must already be checked and updateNPCPosition() must be called on the result
|
||||||
BaseNPC *NPCManager::summonNPC(int x, int y, int z, uint64_t instance, int type, bool respawn, bool baseInstance) {
|
BaseNPC *NPCManager::summonNPC(int x, int y, int z, uint64_t instance, int type, bool respawn, bool baseInstance) {
|
||||||
uint64_t inst = baseInstance ? MAPNUM(instance) : instance;
|
uint64_t inst = baseInstance ? MAPNUM(instance) : instance;
|
||||||
#define EXTRA_HEIGHT 0
|
|
||||||
|
|
||||||
//assert(nextId < INT32_MAX);
|
//assert(nextId < INT32_MAX);
|
||||||
int id = nextId--;
|
int id = nextId--;
|
||||||
@ -130,12 +129,12 @@ BaseNPC *NPCManager::summonNPC(int x, int y, int z, uint64_t instance, int type,
|
|||||||
BaseNPC *npc = nullptr;
|
BaseNPC *npc = nullptr;
|
||||||
|
|
||||||
if (team == 2) {
|
if (team == 2) {
|
||||||
npc = new Mob(x, y, z + EXTRA_HEIGHT, inst, type, NPCData[type], id);
|
npc = new Mob(x, y, z, inst, type, NPCData[type], id);
|
||||||
|
|
||||||
// re-enable respawning, if desired
|
// re-enable respawning, if desired
|
||||||
((Mob*)npc)->summoned = !respawn;
|
((Mob*)npc)->summoned = !respawn;
|
||||||
} else
|
} else
|
||||||
npc = new BaseNPC(x, y, z + EXTRA_HEIGHT, 0, inst, type, id);
|
npc = new BaseNPC(0, inst, type, id);
|
||||||
|
|
||||||
NPCs[id] = npc;
|
NPCs[id] = npc;
|
||||||
|
|
||||||
|
@ -298,9 +298,9 @@ static void loadPaths(json& pathData, int32_t* nextId) {
|
|||||||
if (passedDistance >= SLIDER_GAP_SIZE) { // space them out uniformaly
|
if (passedDistance >= SLIDER_GAP_SIZE) { // space them out uniformaly
|
||||||
passedDistance -= SLIDER_GAP_SIZE; // step down
|
passedDistance -= SLIDER_GAP_SIZE; // step down
|
||||||
// spawn a slider
|
// spawn a slider
|
||||||
Bus* slider = new Bus(point.x, point.y, point.z, 0, INSTANCE_OVERWORLD, 1, (*nextId)--);
|
Bus* slider = new Bus(0, INSTANCE_OVERWORLD, 1, (*nextId)--);
|
||||||
NPCManager::NPCs[slider->id] = slider;
|
NPCManager::NPCs[slider->id] = slider;
|
||||||
NPCManager::updateNPCPosition(slider->id, slider->x, slider->y, slider->z, INSTANCE_OVERWORLD, 0);
|
NPCManager::updateNPCPosition(slider->id, point.x, point.y, point.z, INSTANCE_OVERWORLD, 0);
|
||||||
Transport::NPCQueues[slider->id] = route;
|
Transport::NPCQueues[slider->id] = route;
|
||||||
}
|
}
|
||||||
// rotate
|
// rotate
|
||||||
@ -643,7 +643,7 @@ static void loadEggs(json& eggData, int32_t* nextId) {
|
|||||||
int id = (*nextId)--;
|
int id = (*nextId)--;
|
||||||
uint64_t instanceID = egg.find("iMapNum") == egg.end() ? INSTANCE_OVERWORLD : (int)egg["iMapNum"];
|
uint64_t instanceID = egg.find("iMapNum") == egg.end() ? INSTANCE_OVERWORLD : (int)egg["iMapNum"];
|
||||||
|
|
||||||
Egg* addEgg = new Egg((int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, (int)egg["iType"], id, false);
|
Egg* addEgg = new Egg(instanceID, (int)egg["iType"], id, false);
|
||||||
NPCManager::NPCs[id] = addEgg;
|
NPCManager::NPCs[id] = addEgg;
|
||||||
eggCount++;
|
eggCount++;
|
||||||
NPCManager::updateNPCPosition(id, (int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, 0);
|
NPCManager::updateNPCPosition(id, (int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, 0);
|
||||||
@ -771,7 +771,7 @@ static void loadGruntworkPost(json& gruntwork, int32_t* nextId) {
|
|||||||
// re-enable respawning
|
// re-enable respawning
|
||||||
((Mob*)npc)->summoned = false;
|
((Mob*)npc)->summoned = false;
|
||||||
} else {
|
} else {
|
||||||
npc = new BaseNPC(mob["iX"], mob["iY"], mob["iZ"], mob["iAngle"], instanceID, mob["iNPCType"], id);
|
npc = new BaseNPC(mob["iAngle"], instanceID, mob["iNPCType"], id);
|
||||||
}
|
}
|
||||||
|
|
||||||
NPCManager::NPCs[npc->id] = npc;
|
NPCManager::NPCs[npc->id] = npc;
|
||||||
@ -833,7 +833,7 @@ static void loadGruntworkPost(json& gruntwork, int32_t* nextId) {
|
|||||||
int id = (*nextId)--;
|
int id = (*nextId)--;
|
||||||
uint64_t instanceID = egg.find("iMapNum") == egg.end() ? INSTANCE_OVERWORLD : (int)egg["iMapNum"];
|
uint64_t instanceID = egg.find("iMapNum") == egg.end() ? INSTANCE_OVERWORLD : (int)egg["iMapNum"];
|
||||||
|
|
||||||
Egg* addEgg = new Egg((int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, (int)egg["iType"], id, false);
|
Egg* addEgg = new Egg(instanceID, (int)egg["iType"], id, false);
|
||||||
NPCManager::NPCs[id] = addEgg;
|
NPCManager::NPCs[id] = addEgg;
|
||||||
NPCManager::updateNPCPosition(id, (int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, 0);
|
NPCManager::updateNPCPosition(id, (int)egg["iX"], (int)egg["iY"], (int)egg["iZ"], instanceID, 0);
|
||||||
RunningEggs[id] = addEgg;
|
RunningEggs[id] = addEgg;
|
||||||
@ -868,7 +868,7 @@ static void loadNPCs(json& npcData) {
|
|||||||
if (npc["iX"] > 512000 && npc["iY"] < 256000)
|
if (npc["iX"] > 512000 && npc["iY"] < 256000)
|
||||||
continue;
|
continue;
|
||||||
#endif
|
#endif
|
||||||
BaseNPC* tmp = new BaseNPC(npc["iX"], npc["iY"], npc["iZ"], npc["iAngle"], instanceID, type, npcID);
|
BaseNPC* tmp = new BaseNPC(npc["iAngle"], instanceID, type, npcID);
|
||||||
|
|
||||||
NPCManager::NPCs[npcID] = tmp;
|
NPCManager::NPCs[npcID] = tmp;
|
||||||
NPCManager::updateNPCPosition(npcID, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
NPCManager::updateNPCPosition(npcID, npc["iX"], npc["iY"], npc["iZ"], instanceID, npc["iAngle"]);
|
||||||
|
Loading…
Reference in New Issue
Block a user