Fix issue where size 0 NPC's would hop in and out of the ground because FixZ calculates the offset wrong by adding a default race size

This commit is contained in:
Akkadius 2018-05-27 23:14:32 -05:00
parent a20615ea11
commit 7a7069959f
3 changed files with 164 additions and 105 deletions

View File

@ -6052,6 +6052,63 @@ void Mob::CommonBreakInvisible()
CancelSneakHide();
}
float Mob::GetDefaultRaceSize() const {
switch (race) {
case RACE_HUMAN_1:
return 6.0;
break;
case RACE_BARBARIAN_2:
return 7.0;
break;
case RACE_ERUDITE_3:
return 6.0;
break;
case RACE_WOOD_ELF_4:
return 5.0;
break;
case RACE_HIGH_ELF_5:
return 6.0;
break;
case RACE_DARK_ELF_6:
return 5.0;
break;
case RACE_HALF_ELF_7:
return 5.5;
break;
case RACE_DWARF_8:
return 4.0;
break;
case RACE_TROLL_9:
return 8.0;
break;
case RACE_OGRE_10:
return 9.0;
break;
case RACE_HALFLING_11:
return 3.5;
break;
case RACE_GNOME_12:
return 3.0;
break;
case RACE_IKSAR_128:
return 6.0;
break;
case RACE_VAH_SHIR_130:
return 7.0;
break;
case RACE_FROGLOK_330:
return 5.0;
break;
case RACE_DRAKKIN_522:
return 5.0;
break;
default:
return 6.0;
break;
}
}
#ifdef BOTS
bool Mob::JoinHealRotationTargetPool(std::shared_ptr<HealRotation>* heal_rotation)
{

View File

@ -537,7 +537,7 @@ public:
inline const float GetTarVZ() const { return m_TargetV.z; }
inline const float GetTarVector() const { return tar_vector; }
inline const uint8 GetTarNDX() const { return tar_ndx; }
inline const int8 GetFlyMode() const { return flymode; }
inline const int8 GetFlyMode() const { return static_cast<const int8>(flymode); }
bool IsBoat() const;
//Group
@ -986,6 +986,7 @@ public:
void SendTo(float new_x, float new_y, float new_z);
void SendToFixZ(float new_x, float new_y, float new_z);
float GetZOffset() const;
float GetDefaultRaceSize() const;
void FixZ(int32 z_find_offset = 5);
float GetFixedZ(glm::vec3 position, int32 z_find_offset = 5);

View File

@ -746,8 +746,7 @@ void Mob::SendToFixZ(float new_x, float new_y, float new_z) {
}
}
float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset)
{
float Mob::GetFixedZ(glm::vec3 dest, int32 z_find_offset) {
BenchTimer timer;
timer.reset();
float new_z = dest.z;
@ -806,110 +805,112 @@ void Mob::FixZ(int32 z_find_offset /*= 5*/) {
}
float Mob::GetZOffset() const {
float offset = 3.125f;
float offset = 3.125f;
switch (race) {
case 436:
offset = 0.577f;
break;
case 430:
offset = 0.5f;
break;
case 432:
offset = 1.9f;
break;
case 435:
offset = 0.93f;
break;
case 450:
offset = 0.938f;
break;
case 479:
offset = 0.8f;
break;
case 451:
offset = 0.816f;
break;
case 437:
offset = 0.527f;
break;
case 439:
offset = 1.536f;
break;
case 415:
offset = 1.0f;
break;
case 438:
offset = 0.776f;
break;
case 452:
offset = 0.776f;
break;
case 441:
offset = 0.816f;
break;
case 440:
offset = 0.938f;
break;
case 468:
offset = 1.0f;
break;
case 459:
offset = 1.0f;
break;
case 462:
offset = 1.5f;
break;
case 530:
offset = 1.2f;
break;
case 549:
offset = 0.5f;
break;
case 548:
offset = 0.5f;
break;
case 547:
offset = 0.5f;
break;
case 604:
offset = 1.2f;
break;
case 653:
offset = 5.9f;
break;
case 658:
offset = 4.0f;
break;
case 323:
offset = 5.0f;
break;
case 663:
offset = 5.0f;
break;
case 664:
offset = 4.0f;
break;
case 703:
offset = 9.0f;
break;
case 688:
offset = 5.0f;
break;
case 669:
offset = 7.0f;
break;
case 687:
offset = 2.0f;
break;
case 686:
offset = 2.0f;
break;
default:
offset = 3.125f;
}
switch (race) {
case RACE_BASILISK_436:
offset = 0.577f;
break;
case RACE_DRAKE_430:
offset = 0.5f;
break;
case RACE_DRAKE_432:
offset = 1.9f;
break;
case RACE_DRAGON_435:
offset = 0.93f;
break;
case RACE_LAVA_SPIDER_450:
offset = 0.938f;
break;
case RACE_ALLIGATOR_479:
offset = 0.8f;
break;
case RACE_LAVA_SPIDER_QUEEN_451:
offset = 0.816f;
break;
case RACE_DRAGON_437:
offset = 0.527f;
break;
case RACE_PUMA_439:
offset = 1.536f;
break;
case RACE_RAT_415:
offset = 1.0f;
break;
case RACE_DRAGON_438:
offset = 0.776f;
break;
case RACE_DRAGON_452:
offset = 0.776f;
break;
case RACE_SPIDER_QUEEN_441:
offset = 0.816f;
break;
case RACE_SPIDER_440:
offset = 0.938f;
break;
case RACE_SNAKE_468:
offset = 1.0f;
break;
case RACE_CORATHUS_459:
offset = 1.0f;
break;
case RACE_DRACHNID_COCOON_462:
offset = 1.5f;
break;
case RACE_DRAGON_530:
offset = 1.2f;
break;
case RACE_GOO_549:
offset = 0.5f;
break;
case RACE_GOO_548:
offset = 0.5f;
break;
case RACE_GOO_547:
offset = 0.5f;
break;
case RACE_DRACOLICH_604:
offset = 1.2f;
break;
case RACE_TELMIRA_653:
offset = 5.9f;
break;
case RACE_MORELL_THULE_658:
offset = 4.0f;
break;
case RACE_ARMOR_OF_MARR_323:
offset = 5.0f;
break;
case RACE_AMYGDALAN_663:
offset = 5.0f;
break;
case RACE_SANDMAN_664:
offset = 4.0f;
break;
case RACE_ALARAN_SENTRY_STONE_703:
offset = 9.0f;
break;
case RACE_RABBIT_668:
offset = 5.0f;
break;
case RACE_BLIND_DREAMER_669:
offset = 7.0f;
break;
case RACE_GORAL_687:
offset = 2.0f;
break;
case RACE_SELYRAH_686:
offset = 2.0f;
break;
default:
offset = 3.125f;
}
return 0.2 * GetSize() * offset;
float mob_size = (GetSize() > 0 ? GetSize() : GetDefaultRaceSize());
return static_cast<float>(0.2 * mob_size * offset);
}
// This function will try to move the mob along the relative angle a set distance