[Groundspawns] Fix issue where groundspawns appear floating high off the ground (#2930)

This commit is contained in:
Chris Miles 2023-02-15 10:52:03 -06:00 committed by GitHub
parent 90a01f7c53
commit fafa33e190
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -71,6 +71,8 @@ Object::Object(uint32 id, uint32 type, uint32 icon, const Object_Struct& object,
m_data.size = object.size;
m_data.tilt_x = object.tilt_x;
m_data.tilt_y = object.tilt_y;
FixZ();
}
//creating a re-ocurring ground spawn.
@ -100,6 +102,8 @@ Object::Object(const EQ::ItemInstance* inst, char* name,float max_x,float min_x,
strcpy(m_data.object_name, name);
RandomSpawn(false);
FixZ();
// Hardcoded portion for unknown members
m_data.unknown024 = 0x7f001194;
m_data.unknown076 = 0x0000d5fe;
@ -167,6 +171,8 @@ Object::Object(Client* client, const EQ::ItemInstance* inst)
strcpy(m_data.object_name, DEFAULT_OBJECT_NAME);
}
}
FixZ();
}
Object::Object(const EQ::ItemInstance *inst, float x, float y, float z, float heading, uint32 decay_time)
@ -223,6 +229,8 @@ Object::Object(const EQ::ItemInstance *inst, float x, float y, float z, float he
strcpy(m_data.object_name, DEFAULT_OBJECT_NAME);
}
}
FixZ();
}
Object::Object(const char *model, float x, float y, float z, float heading, uint8 type, uint32 decay_time)
@ -247,6 +255,8 @@ Object::Object(const char *model, float x, float y, float z, float heading, uint
m_data.z = z;
m_data.zone_id = zone->GetZoneID();
FixZ();
if (decay_time)
decay_timer.Start();
@ -1172,3 +1182,15 @@ void Object::SetEntityVariable(std::string variable_name, std::string variable_v
o_EntityVariables[variable_name] = variable_value;
}
void Object::FixZ()
{
float best_z = BEST_Z_INVALID;
if (zone->zonemap != nullptr) {
auto dest = glm::vec3(m_data.x, m_data.y, m_data.z + 5);
best_z = zone->zonemap->FindBestZ(dest, nullptr);
if (best_z != BEST_Z_INVALID) {
m_data.z = best_z;
}
}
}

View File

@ -204,6 +204,7 @@ protected:
Timer respawn_timer;
Timer decay_timer;
void FixZ();
};
#endif