Rename coord args in summonNPC() and constructors to clarify purpose

This makes it clearer that the real coords aren't set until the first
call to updateNPCPosition().
This commit is contained in:
dongresource 2023-09-10 19:47:42 +02:00 committed by gsemaj
parent ba20f5a401
commit 2924a27eb4
No known key found for this signature in database
GPG Key ID: 24B96BAA40497929
3 changed files with 11 additions and 12 deletions

View File

@ -106,11 +106,11 @@ struct CombatNPC : public BaseNPC, public ICombatant {
std::unordered_map<int, Buff*> buffs = {};
CombatNPC(int x, int y, int z, int angle, uint64_t iID, int t, int id, int maxHP)
CombatNPC(int spawnX, int spawnY, int spawnZ, int angle, uint64_t iID, int t, int id, int maxHP)
: BaseNPC(angle, iID, t, id), maxHealth(maxHP) {
spawnX = x;
spawnY = y;
spawnZ = z;
this->spawnX = spawnX;
this->spawnY = spawnY;
this->spawnZ = spawnZ;
kind = EntityKind::COMBAT_NPC;

View File

@ -50,8 +50,8 @@ struct Mob : public CombatNPC {
// temporary; until we're sure what's what
nlohmann::json data = {};
Mob(int x, int y, int z, int angle, uint64_t iID, int t, nlohmann::json d, int32_t id)
: CombatNPC(x, y, z, angle, iID, t, id, d["m_iHP"]),
Mob(int spawnX, int spawnY, int spawnZ, int angle, uint64_t iID, int t, nlohmann::json d, int32_t id)
: CombatNPC(spawnX, spawnY, spawnZ, angle, iID, t, id, d["m_iHP"]),
sightRange(d["m_iSightRange"]) {
state = AIState::ROAMING;
@ -62,9 +62,9 @@ struct Mob : public CombatNPC {
idleRange = (int)data["m_iIdleRange"];
level = data["m_iNpcLevel"];
roamX = x;
roamY = y;
roamZ = z;
roamX = spawnX;
roamY = spawnY;
roamZ = spawnZ;
offsetX = 0;
offsetY = 0;

View File

@ -122,16 +122,15 @@ static void npcUnsummonHandler(CNSocket* sock, CNPacketData* data) {
}
// 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 spawnX, int spawnY, int spawnZ, uint64_t instance, int type, bool respawn, bool baseInstance) {
uint64_t inst = baseInstance ? MAPNUM(instance) : instance;
//assert(nextId < INT32_MAX);
int id = nextId--;
int team = NPCData[type]["m_iTeam"];
BaseNPC *npc = nullptr;
if (team == 2) {
npc = new Mob(x, y, z, inst, type, NPCData[type], id);
npc = new Mob(spawnX, spawnY, spawnZ, inst, type, NPCData[type], id);
// re-enable respawning, if desired
((Mob*)npc)->summoned = !respawn;