mirror of https://github.com/AxioDL/metaforce.git
CChozoGhost: Minor FindBestAnchor fixes
This commit is contained in:
parent
985daa3092
commit
155cd3759f
|
@ -660,9 +660,8 @@ void CChozoGhost::RemoveFromTeam(CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChozoGhost::FloatToLevel(float f1, float f2) {
|
void CChozoGhost::FloatToLevel(float f1, float f2) {
|
||||||
zeus::CVector3f pos = GetTranslation();
|
const zeus::CVector3f& pos = GetTranslation();
|
||||||
pos.z() = 4.f * (f1 - pos.z()) * f2 + pos.z();
|
SetTranslation({pos.x(), pos.y(), 4.f * (f1 - pos.z()) * f2 + pos.z()});
|
||||||
SetTranslation(pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CChozoGhost::CBehaveChance& CChozoGhost::ChooseBehaveChanceRange(CStateManager& mgr) {
|
const CChozoGhost::CBehaveChance& CChozoGhost::ChooseBehaveChanceRange(CStateManager& mgr) {
|
||||||
|
@ -676,31 +675,32 @@ const CChozoGhost::CBehaveChance& CChozoGhost::ChooseBehaveChanceRange(CStateMan
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChozoGhost::FindNearestSolid(CStateManager& mgr, const zeus::CVector3f& dir) {
|
void CChozoGhost::FindNearestSolid(CStateManager& mgr, const zeus::CVector3f& dir) {
|
||||||
CRayCastResult res = mgr.RayStaticIntersection(GetBoundingBox().center() + (dir * 8.f), -dir, 8.f,
|
const zeus::CVector3f& center = GetBoundingBox().center();
|
||||||
CMaterialFilter::MakeInclude({EMaterialTypes::Solid}));
|
const CRayCastResult& res =
|
||||||
|
mgr.RayStaticIntersection(center + (dir * 8.f), -dir, 8.f, CMaterialFilter::MakeInclude({EMaterialTypes::Solid}));
|
||||||
if (res.IsInvalid()) {
|
if (res.IsInvalid()) {
|
||||||
x6cc_ = GetBoundingBox().center() + dir;
|
x6cc_ = center + dir;
|
||||||
} else
|
} else {
|
||||||
x6cc_ = res.GetPoint();
|
x6cc_ = res.GetPoint();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CChozoGhost::FindBestAnchor(urde::CStateManager& mgr) {
|
void CChozoGhost::FindBestAnchor(CStateManager& mgr) {
|
||||||
x665_27_playerInLeashRange = false;
|
x665_27_playerInLeashRange = false;
|
||||||
u32 chance = mgr.GetActiveRandom()->Next() % 100;
|
u32 chance = mgr.GetActiveRandom()->Next() % 100;
|
||||||
chance = chance < x65c_nearChance ? 0 : (chance < (x65c_nearChance + x660_midChance)) + 2;
|
chance = chance < x65c_nearChance ? 0 : (chance < (x65c_nearChance + x660_midChance)) + 2;
|
||||||
float dVar10 = 10.f;
|
float dVar15 = 10.f * x658_;
|
||||||
float dVar15 = dVar10 * x658_;
|
|
||||||
float dVar14 = dVar15;
|
float dVar14 = dVar15;
|
||||||
float dVar13 = dVar15;
|
float dVar13 = dVar15;
|
||||||
if (chance == 0) {
|
if (chance == 0) {
|
||||||
dVar13 = dVar15 * dVar10;
|
dVar13 = dVar15 * 10.f;
|
||||||
dVar15 *= 5.f;
|
dVar14 = dVar15 * 5.f;
|
||||||
} else if (chance == 1) {
|
} else if (chance == 1) {
|
||||||
dVar13 = dVar15 * 5.f;
|
dVar13 = dVar15 * 5.f;
|
||||||
dVar15 *= dVar10;
|
dVar15 *= 10.f;
|
||||||
} else if (chance == 2) {
|
} else if (chance == 2) {
|
||||||
dVar14 = dVar15 * 5.f;
|
dVar14 = dVar15 * 5.f;
|
||||||
dVar15 *= dVar10;
|
dVar15 *= 10.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float prevDist = FLT_MAX;
|
float prevDist = FLT_MAX;
|
||||||
|
@ -711,29 +711,29 @@ void CChozoGhost::FindBestAnchor(urde::CStateManager& mgr) {
|
||||||
float fVar17 = (cover->GetTranslation() - GetTranslation()).magnitude();
|
float fVar17 = (cover->GetTranslation() - GetTranslation()).magnitude();
|
||||||
if (2.f * x66c_ <= fVar17) {
|
if (2.f * x66c_ <= fVar17) {
|
||||||
float dist = std::max(0.f, x654_ - fVar17);
|
float dist = std::max(0.f, x654_ - fVar17);
|
||||||
zeus::CVector3f diff = (cover->GetTranslation() - mgr.GetPlayer().GetTranslation());
|
zeus::CVector3f diff = cover->GetTranslation() - mgr.GetPlayer().GetTranslation();
|
||||||
fVar17 = diff.magnitude();
|
fVar17 = diff.magnitude();
|
||||||
if (x2fc_minAttackRange <= fVar17) {
|
if (x2fc_minAttackRange <= fVar17) {
|
||||||
if (std::fabs(diff.z()) / fVar17 < 0.2f) {
|
if (std::fabs(diff.z()) / fVar17 < 0.2f) {
|
||||||
dist = (20.f * x658_) * ((std::fabs(diff.z()) / fVar17) - 0.2f) + dist;
|
dist = (20.f * x658_) * ((std::fabs(diff.z()) / fVar17) - 0.2f) + dist;
|
||||||
}
|
}
|
||||||
if (x654_ <= dVar10) {
|
if (x654_ <= fVar17) {
|
||||||
if (x658_ <= dVar10) {
|
if (x658_ <= fVar17) {
|
||||||
dist = (dist + dVar13);
|
dist = (dist + dVar13);
|
||||||
} else {
|
} else {
|
||||||
dist = (dist + dVar14);
|
dist = (dist + dVar14);
|
||||||
if (dist < prevDist) {
|
if (dist < prevDist) {
|
||||||
fVar17 = 1.f / dVar10;
|
fVar17 = 1.f / fVar17;
|
||||||
diff = diff * fVar17;
|
diff = diff * fVar17;
|
||||||
dist += (10.f * x658_) * (1.f * mgr.GetPlayer().GetTransform().basis[1].dot(diff));
|
dist += (10.f * x658_) * (1.f - mgr.GetPlayer().GetTransform().basis[1].dot(diff));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dist += dVar15;
|
dist += dVar15;
|
||||||
if (dist < prevDist) {
|
if (dist < prevDist) {
|
||||||
fVar17 = 1.f / dVar10;
|
fVar17 = 1.f / fVar17;
|
||||||
diff = diff * fVar17;
|
diff = diff * fVar17;
|
||||||
dist += (10.f * x658_) * (1.f * mgr.GetPlayer().GetTransform().basis[1].dot(diff));
|
dist += (10.f * x658_) * (1.f - mgr.GetPlayer().GetTransform().basis[1].dot(diff));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dist < prevDist) {
|
if (dist < prevDist) {
|
||||||
|
@ -759,7 +759,7 @@ void CChozoGhost::FindBestAnchor(urde::CStateManager& mgr) {
|
||||||
x2dc_destObj = mgr.GetPlayer().GetUniqueId();
|
x2dc_destObj = mgr.GetPlayer().GetUniqueId();
|
||||||
zeus::CVector3f destPos =
|
zeus::CVector3f destPos =
|
||||||
mgr.GetPlayer().GetTranslation() - x654_ * (mgr.GetPlayer().GetTranslation() - GetTranslation()).normalized();
|
mgr.GetPlayer().GetTranslation() - x654_ * (mgr.GetPlayer().GetTranslation() - GetTranslation()).normalized();
|
||||||
CRayCastResult res =
|
const CRayCastResult& res =
|
||||||
mgr.RayStaticIntersection(destPos, zeus::skDown, 8.f, CMaterialFilter::MakeInclude(EMaterialTypes::Floor));
|
mgr.RayStaticIntersection(destPos, zeus::skDown, 8.f, CMaterialFilter::MakeInclude(EMaterialTypes::Floor));
|
||||||
if (res.IsValid())
|
if (res.IsValid())
|
||||||
destPos = res.GetPoint();
|
destPos = res.GetPoint();
|
||||||
|
|
Loading…
Reference in New Issue