2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/GuiSys/CCompoundTargetReticle.hpp"
|
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
#include <cstdlib>
|
2019-12-22 20:04:07 +00:00
|
|
|
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/Camera/CGameCamera.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
|
|
|
#include "Runtime/World/CScriptGrapplePoint.hpp"
|
|
|
|
#include "Runtime/World/CWorld.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2017-02-13 21:29:00 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2019-09-12 09:45:51 +00:00
|
|
|
namespace {
|
2019-09-12 10:38:01 +00:00
|
|
|
constexpr char skCrosshairsReticleAssetName[] = "CMDL_Crosshairs";
|
|
|
|
[[maybe_unused]] constexpr char skOrbitZoneReticleAssetName[] = "CMDL_OrbitZone";
|
|
|
|
constexpr char skSeekerAssetName[] = "CMDL_Seeker";
|
|
|
|
constexpr char skLockConfirmAssetName[] = "CMDL_LockConfirm";
|
|
|
|
constexpr char skTargetFlowerAssetName[] = "CMDL_TargetFlower";
|
|
|
|
constexpr char skMissileBracketAssetName[] = "CMDL_MissileBracket";
|
|
|
|
constexpr char skChargeGaugeAssetName[] = "CMDL_ChargeGauge";
|
|
|
|
constexpr char skChargeBeamTickAssetName[] = "CMDL_ChargeTickFirst";
|
|
|
|
constexpr char skOuterBeamIconSquareNameBase[] = "CMDL_BeamSquare";
|
|
|
|
constexpr char skInnerBeamIconName[] = "CMDL_InnerBeamIcon";
|
2019-09-12 10:40:50 +00:00
|
|
|
constexpr char skLockFireAssetName[] = "CMDL_LockFire";
|
2019-09-12 10:38:01 +00:00
|
|
|
constexpr char skLockDaggerAssetName[] = "CMDL_LockDagger0";
|
|
|
|
constexpr char skGrappleReticleAssetName[] = "CMDL_Grapple";
|
|
|
|
constexpr char skXRayRingModelName[] = "CMDL_XRayRetRing";
|
|
|
|
constexpr char skThermalReticleAssetName[] = "CMDL_ThermalRet";
|
2019-09-12 09:45:51 +00:00
|
|
|
|
|
|
|
float offshoot_func(float f1, float f2, float f3) { return (f1 * 0.5f) + std::sin((f3 - 0.5f) * f2); }
|
2017-02-13 21:29:00 +00:00
|
|
|
|
2019-09-12 09:45:51 +00:00
|
|
|
float calculate_premultiplied_overshoot_offset(float f1) { return 2.f * (M_PIF - std::asin(1.f / f1)); }
|
|
|
|
} // Anonymous namespace
|
2017-02-21 03:29:28 +00:00
|
|
|
|
2020-04-12 08:19:48 +00:00
|
|
|
constexpr CTargetReticleRenderState CTargetReticleRenderState::skZeroRenderState(kInvalidUniqueId, 1.f, zeus::skZero3f,
|
|
|
|
0.f, 1.f, true);
|
2017-02-21 03:29:28 +00:00
|
|
|
|
2019-07-20 04:27:21 +00:00
|
|
|
CCompoundTargetReticle::SOuterItemInfo::SOuterItemInfo(std::string_view res) : x0_model(g_SimplePool->GetObj(res)) {}
|
2017-02-21 03:29:28 +00:00
|
|
|
|
|
|
|
CCompoundTargetReticle::CCompoundTargetReticle(const CStateManager& mgr)
|
2017-10-29 06:21:52 +00:00
|
|
|
: x0_leadingOrientation(mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTransform().buildMatrix3f())
|
|
|
|
, x10_laggingOrientation(mgr.GetCameraManager()->GetCurrentCamera(mgr)->GetTransform().buildMatrix3f())
|
2017-10-30 03:37:20 +00:00
|
|
|
, x2c_overshootOffsetHalf(0.5f * g_tweakTargeting->GetChargeGaugeOvershootOffset())
|
|
|
|
, x30_premultOvershootOffset(
|
2018-12-08 05:30:43 +00:00
|
|
|
calculate_premultiplied_overshoot_offset(g_tweakTargeting->GetChargeGaugeOvershootOffset()))
|
2017-02-21 03:29:28 +00:00
|
|
|
, x34_crosshairs(g_SimplePool->GetObj(skCrosshairsReticleAssetName))
|
|
|
|
, x40_seeker(g_SimplePool->GetObj(skSeekerAssetName))
|
|
|
|
, x4c_lockConfirm(g_SimplePool->GetObj(skLockConfirmAssetName))
|
|
|
|
, x58_targetFlower(g_SimplePool->GetObj(skTargetFlowerAssetName))
|
|
|
|
, x64_missileBracket(g_SimplePool->GetObj(skMissileBracketAssetName))
|
|
|
|
, x70_innerBeamIcon(g_SimplePool->GetObj(skInnerBeamIconName))
|
|
|
|
, x7c_lockFire(g_SimplePool->GetObj(skLockFireAssetName))
|
|
|
|
, x88_lockDagger(g_SimplePool->GetObj(skLockDaggerAssetName))
|
|
|
|
, x94_grapple(g_SimplePool->GetObj(skGrappleReticleAssetName))
|
|
|
|
, xa0_chargeTickFirst(g_SimplePool->GetObj(skChargeBeamTickAssetName))
|
|
|
|
, xac_xrayRetRing(g_SimplePool->GetObj(skXRayRingModelName))
|
|
|
|
, xb8_thermalReticle(g_SimplePool->GetObj(skThermalReticleAssetName))
|
|
|
|
, xc4_chargeGauge(skChargeGaugeAssetName)
|
2017-10-29 06:21:52 +00:00
|
|
|
, xf4_targetPos(CalculateOrbitZoneReticlePosition(mgr, false))
|
|
|
|
, x100_laggingTargetPos(CalculateOrbitZoneReticlePosition(mgr, true))
|
2018-12-08 05:30:43 +00:00
|
|
|
, x208_lockonTimer(g_tweakTargeting->GetLockonDuration()) {
|
|
|
|
xe0_outerBeamIconSquares.reserve(9);
|
2020-04-13 20:51:59 +00:00
|
|
|
for (size_t i = 0; i < xe0_outerBeamIconSquares.capacity(); ++i) {
|
2020-04-11 22:51:39 +00:00
|
|
|
xe0_outerBeamIconSquares.emplace_back(fmt::format(FMT_STRING("{}{}"), skOuterBeamIconSquareNameBase, i));
|
2020-04-13 20:51:59 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
x34_crosshairs.Lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
CCompoundTargetReticle::SScanReticuleRenderer::SScanReticuleRenderer() {
|
|
|
|
CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
|
2020-04-13 20:44:39 +00:00
|
|
|
for (size_t i = 0; i < m_lineRenderers.size(); ++i) {
|
2018-12-08 05:30:43 +00:00
|
|
|
m_lineRenderers[i].emplace(ctx, CLineRenderer::EPrimitiveMode::Lines, 8, nullptr, true, true);
|
2020-04-13 20:44:39 +00:00
|
|
|
for (auto& stripRenderer : m_stripRenderers[i]) {
|
|
|
|
stripRenderer.emplace(ctx, CLineRenderer::EPrimitiveMode::LineStrip, 4, nullptr, true, true);
|
|
|
|
}
|
2017-02-21 03:29:28 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
|
|
|
} BooTrace);
|
2017-02-21 03:29:28 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CCompoundTargetReticle::EReticleState CCompoundTargetReticle::GetDesiredReticleState(const CStateManager& mgr) const {
|
|
|
|
switch (mgr.GetPlayerState()->GetCurrentVisor()) {
|
|
|
|
case CPlayerState::EPlayerVisor::Scan:
|
|
|
|
return EReticleState::Scan;
|
|
|
|
case CPlayerState::EPlayerVisor::XRay:
|
|
|
|
return EReticleState::XRay;
|
|
|
|
case CPlayerState::EPlayerVisor::Combat:
|
|
|
|
default:
|
|
|
|
return EReticleState::Combat;
|
|
|
|
case CPlayerState::EPlayerVisor::Thermal:
|
|
|
|
return EReticleState::Thermal;
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CCompoundTargetReticle::Update(float dt, const CStateManager& mgr) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const float angle = x10_laggingOrientation.angleFrom(x0_leadingOrientation).asDegrees();
|
2018-12-08 05:30:43 +00:00
|
|
|
float t;
|
2020-04-13 21:03:38 +00:00
|
|
|
if (angle < 0.1f || angle > 45.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
t = 1.f;
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
t = std::min(1.f, g_tweakTargeting->GetAngularLagSpeed() * dt / angle);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
x10_laggingOrientation =
|
|
|
|
t == 1.f ? x0_leadingOrientation : zeus::CQuaternion::slerp(x10_laggingOrientation, x0_leadingOrientation, t);
|
|
|
|
xf4_targetPos = CalculateOrbitZoneReticlePosition(mgr, false);
|
|
|
|
x100_laggingTargetPos = CalculateOrbitZoneReticlePosition(mgr, true);
|
|
|
|
UpdateCurrLockOnGroup(dt, mgr);
|
|
|
|
UpdateNextLockOnGroup(dt, mgr);
|
|
|
|
UpdateOrbitZoneGroup(dt, mgr);
|
2020-04-13 21:03:38 +00:00
|
|
|
const EReticleState desiredState = GetDesiredReticleState(mgr);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (desiredState != x20_prevState && x20_prevState == x24_nextState) {
|
|
|
|
x24_nextState = desiredState;
|
|
|
|
x28_noDrawTicks = 2;
|
|
|
|
}
|
|
|
|
if (x20_prevState != x24_nextState && x28_noDrawTicks <= 0) {
|
|
|
|
x20_prevState = x24_nextState;
|
2020-04-13 20:54:40 +00:00
|
|
|
bool combat = false;
|
|
|
|
bool scan = false;
|
|
|
|
bool xray = false;
|
|
|
|
bool thermal = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (x24_nextState) {
|
|
|
|
case EReticleState::Combat:
|
|
|
|
combat = true;
|
|
|
|
break;
|
|
|
|
case EReticleState::Scan:
|
|
|
|
scan = true;
|
|
|
|
break;
|
|
|
|
case EReticleState::XRay:
|
|
|
|
xray = true;
|
|
|
|
break;
|
|
|
|
case EReticleState::Thermal:
|
|
|
|
thermal = true;
|
|
|
|
break;
|
2017-10-29 06:21:52 +00:00
|
|
|
default:
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x40_seeker.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x40_seeker.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x4c_lockConfirm.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x4c_lockConfirm.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x58_targetFlower.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x58_targetFlower.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x64_missileBracket.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x64_missileBracket.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x70_innerBeamIcon.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x70_innerBeamIcon.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x7c_lockFire.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x7c_lockFire.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x88_lockDagger.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x88_lockDagger.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xa0_chargeTickFirst.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
xa0_chargeTickFirst.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (xray) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xac_xrayRetRing.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
xac_xrayRetRing.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (thermal) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xb8_thermalReticle.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
xb8_thermalReticle.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xc4_chargeGauge.x0_model.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
xc4_chargeGauge.x0_model.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (!scan) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x94_grapple.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x94_grapple.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
for (SOuterItemInfo& info : xe0_outerBeamIconSquares) {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (combat) {
|
2018-12-08 05:30:43 +00:00
|
|
|
info.x0_model.Lock();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
info.x0_model.Unlock();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
const CPlayerGun* gun = mgr.GetPlayer().GetPlayerGun();
|
|
|
|
const bool fullyCharged = (gun->IsCharging() ? gun->GetChargeBeamFactor() : 0.f) >= 1.f;
|
|
|
|
if (fullyCharged != x21a_fullyCharged) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x21a_fullyCharged = fullyCharged;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (x21a_fullyCharged) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x214_fullChargeFadeTimer = std::min(dt / g_tweakTargeting->GetFullChargeFadeDuration() + x214_fullChargeFadeTimer,
|
|
|
|
g_tweakTargeting->GetFullChargeFadeDuration());
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x214_fullChargeFadeTimer =
|
|
|
|
std::max(x214_fullChargeFadeTimer - dt / g_tweakTargeting->GetFullChargeFadeDuration(), 0.f);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-19 04:26:53 +00:00
|
|
|
const bool missileActive = gun->GetMissleMode() == CPlayerGun::EMissileMode::Active;
|
2018-12-08 05:30:43 +00:00
|
|
|
if (missileActive != x1f4_missileActive) {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (x1f8_missileBracketTimer != 0.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1f8_missileBracketTimer = FLT_EPSILON - x1f8_missileBracketTimer;
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1f8_missileBracketTimer = FLT_EPSILON;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
x1f4_missileActive = missileActive;
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
const CPlayerState::EBeamId beam = gun->GetCurrentBeam();
|
2018-12-08 05:30:43 +00:00
|
|
|
if (beam != x200_beam) {
|
|
|
|
x204_chargeGaugeOvershootTimer = g_tweakTargeting->GetChargeGaugeOvershootDuration();
|
2020-04-13 21:03:38 +00:00
|
|
|
for (size_t i = 0; i < xe0_outerBeamIconSquares.size(); ++i) {
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CRelAngle baseAngle = g_tweakTargeting->GetOuterBeamSquareAngles(int(beam))[i];
|
2018-12-17 03:52:51 +00:00
|
|
|
baseAngle.makeRel();
|
2018-12-08 05:30:43 +00:00
|
|
|
SOuterItemInfo& icon = xe0_outerBeamIconSquares[i];
|
|
|
|
zeus::CRelAngle offshootAngleDelta = baseAngle.asRadians() - icon.x10_rotAng;
|
2020-04-13 21:03:38 +00:00
|
|
|
if ((i & 0x1) == 1) {
|
2018-12-08 05:30:43 +00:00
|
|
|
offshootAngleDelta =
|
|
|
|
(baseAngle > 0.f) ? zeus::CRelAngle(-2.f * M_PIF - baseAngle) : zeus::CRelAngle(2.f * M_PIF + baseAngle);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
icon.xc_offshootBaseAngle = icon.x10_rotAng;
|
|
|
|
icon.x18_offshootAngleDelta = offshootAngleDelta;
|
|
|
|
icon.x14_baseAngle = baseAngle;
|
|
|
|
}
|
|
|
|
zeus::CRelAngle baseAngle = g_tweakTargeting->GetChargeGaugeAngle(int(beam));
|
2018-12-17 03:52:51 +00:00
|
|
|
baseAngle.makeRel();
|
2018-12-08 05:30:43 +00:00
|
|
|
float offshootAngleDelta = baseAngle.asRadians() - xc4_chargeGauge.x10_rotAng;
|
2020-04-13 21:03:38 +00:00
|
|
|
if ((rand() & 0x1) == 1) {
|
2018-12-08 05:30:43 +00:00
|
|
|
offshootAngleDelta =
|
|
|
|
(offshootAngleDelta > 0.f) ? -2.f * M_PIF - offshootAngleDelta : 2.f * M_PIF + offshootAngleDelta;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
xc4_chargeGauge.xc_offshootBaseAngle = xc4_chargeGauge.x10_rotAng;
|
|
|
|
xc4_chargeGauge.x18_offshootAngleDelta = offshootAngleDelta;
|
|
|
|
xc4_chargeGauge.x14_baseAngle = baseAngle;
|
|
|
|
x200_beam = beam;
|
|
|
|
x208_lockonTimer = 0.f;
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
if ((gun->GetLastFireButtonStates() & 0x1) != 0) {
|
|
|
|
if (!x218_beamShot) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x210_lockFireTimer = g_tweakTargeting->GetLockFireDuration();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
x218_beamShot = true;
|
|
|
|
} else {
|
|
|
|
x218_beamShot = false;
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
if ((gun->GetLastFireButtonStates() & 0x2) != 0) {
|
|
|
|
if (!x219_missileShot) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1fc_missileBracketScaleTimer = g_tweakTargeting->GetMissileBracketScaleDuration();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
x219_missileShot = true;
|
|
|
|
} else {
|
|
|
|
x219_missileShot = false;
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
if (const TCastToConstPtr<CScriptGrapplePoint> point = mgr.GetObjectById(xf2_nextTargetId)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (point->GetUniqueId() != x1dc_grapplePoint0) {
|
|
|
|
float tmp;
|
2020-04-13 21:03:38 +00:00
|
|
|
if (point->GetUniqueId() == x1de_grapplePoint1) {
|
2018-12-08 05:30:43 +00:00
|
|
|
tmp = std::max(FLT_EPSILON, x1e4_grapplePoint1T);
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
tmp = FLT_EPSILON;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
x1de_grapplePoint1 = x1dc_grapplePoint0;
|
|
|
|
x1e4_grapplePoint1T = x1e0_grapplePoint0T;
|
|
|
|
x1e0_grapplePoint0T = tmp;
|
|
|
|
x1dc_grapplePoint0 = point->GetUniqueId();
|
|
|
|
}
|
|
|
|
} else if (x1dc_grapplePoint0 != kInvalidUniqueId) {
|
|
|
|
x1de_grapplePoint1 = x1dc_grapplePoint0;
|
|
|
|
x1e4_grapplePoint1T = x1e0_grapplePoint0T;
|
|
|
|
x1e0_grapplePoint0T = 0.f;
|
|
|
|
x1dc_grapplePoint0 = kInvalidUniqueId;
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
if (x1e0_grapplePoint0T > 0.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1e0_grapplePoint0T = std::min(dt / 0.5f + x1e0_grapplePoint0T, 1.f);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x1e4_grapplePoint1T > 0.f) {
|
|
|
|
x1e4_grapplePoint1T = std::max(0.f, x1e4_grapplePoint1T - dt / 0.5f);
|
2020-04-13 21:03:38 +00:00
|
|
|
if (x1e4_grapplePoint1T == 0.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1de_grapplePoint1 = kInvalidUniqueId;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x1f0_xrayRetAngle =
|
2018-12-17 03:52:51 +00:00
|
|
|
zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetXRayRetAngleSpeed() * dt) + x1f0_xrayRetAngle).asRel();
|
|
|
|
x1ec_seekerAngle = zeus::CRelAngle(zeus::degToRad(g_tweakTargeting->GetSeekerAngleSpeed() * dt) + x1ec_seekerAngle).
|
|
|
|
asRel();
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CTargetReticleRenderState::InterpolateWithClamp(const CTargetReticleRenderState& a, CTargetReticleRenderState& out,
|
|
|
|
const CTargetReticleRenderState& b, float t) {
|
|
|
|
t = zeus::clamp(0.f, t, 1.f);
|
2020-04-13 21:03:38 +00:00
|
|
|
const float omt = 1.f - t;
|
2018-12-08 05:30:43 +00:00
|
|
|
out.x4_radiusWorld = omt * a.x4_radiusWorld + t * b.x4_radiusWorld;
|
|
|
|
out.x14_factor = omt * a.x14_factor + t * b.x14_factor;
|
|
|
|
out.x18_minVpClampScale = omt * a.x18_minVpClampScale + t * b.x18_minVpClampScale;
|
|
|
|
out.x8_positionWorld = zeus::CVector3f::lerp(a.x8_positionWorld, b.x8_positionWorld, t);
|
|
|
|
|
2020-04-13 21:03:38 +00:00
|
|
|
if (t == 1.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
out.x0_target = b.x0_target;
|
2020-04-13 21:03:38 +00:00
|
|
|
} else if (t == 0.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
out.x0_target = a.x0_target;
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
out.x0_target = kInvalidUniqueId;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2017-10-30 03:37:20 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static bool IsDamageOrbit(CPlayer::EPlayerOrbitRequest req) {
|
|
|
|
switch (req) {
|
|
|
|
case CPlayer::EPlayerOrbitRequest::Five:
|
|
|
|
case CPlayer::EPlayerOrbitRequest::ActivateOrbitSource:
|
|
|
|
case CPlayer::EPlayerOrbitRequest::ProjectileCollide:
|
|
|
|
case CPlayer::EPlayerOrbitRequest::Freeze:
|
|
|
|
case CPlayer::EPlayerOrbitRequest::DamageOnGrapple:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2017-10-30 03:37:20 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CCompoundTargetReticle::UpdateCurrLockOnGroup(float dt, const CStateManager& mgr) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const TUniqueId targetId = mgr.GetPlayer().GetOrbitTargetId();
|
2018-12-08 05:30:43 +00:00
|
|
|
if (targetId != xf0_targetId) {
|
|
|
|
if (targetId != kInvalidUniqueId) {
|
2020-05-10 02:26:44 +00:00
|
|
|
if (TCastToConstPtr<CScriptGrapplePoint>(mgr.GetObjectById(targetId))) {
|
2018-12-08 05:30:43 +00:00
|
|
|
CSfxManager::SfxStart(SFXui_lockon_grapple, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
CSfxManager::SfxStart(SFXui_lockon_poi, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (targetId == kInvalidUniqueId) {
|
|
|
|
x12c_currGroupA = x10c_currGroupInterp;
|
|
|
|
x14c_currGroupB.SetFactor(0.f);
|
|
|
|
x16c_currGroupDur =
|
|
|
|
IsDamageOrbit(mgr.GetPlayer().GetOrbitRequest()) ? 0.65f : g_tweakTargeting->GetCurrLockOnEnterDuration();
|
|
|
|
} else {
|
|
|
|
x12c_currGroupA = x10c_currGroupInterp;
|
2020-04-13 21:03:38 +00:00
|
|
|
if (xf0_targetId == kInvalidUniqueId) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x12c_currGroupA.SetTargetId(targetId);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
x14c_currGroupB = CTargetReticleRenderState(
|
2019-02-24 07:15:54 +00:00
|
|
|
targetId, 1.f, zeus::skZero3f, 1.f,
|
2018-12-08 05:30:43 +00:00
|
|
|
IsGrappleTarget(targetId, mgr) ? g_tweakTargeting->GetGrappleMinClampScale() : 1.f, false);
|
|
|
|
x16c_currGroupDur = xf0_targetId == kInvalidUniqueId ? g_tweakTargeting->GetCurrLockOnExitDuration()
|
|
|
|
: g_tweakTargeting->GetCurrLockOnSwitchDuration();
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x170_currGroupTimer = x16c_currGroupDur;
|
|
|
|
xf0_targetId = targetId;
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x170_currGroupTimer > 0.f) {
|
|
|
|
UpdateTargetParameters(x12c_currGroupA, mgr);
|
|
|
|
UpdateTargetParameters(x14c_currGroupB, mgr);
|
|
|
|
x170_currGroupTimer = std::max(0.f, x170_currGroupTimer - dt);
|
|
|
|
CTargetReticleRenderState::InterpolateWithClamp(x12c_currGroupA, x10c_currGroupInterp, x14c_currGroupB,
|
|
|
|
1.f - x170_currGroupTimer / x16c_currGroupDur);
|
|
|
|
} else {
|
|
|
|
UpdateTargetParameters(x10c_currGroupInterp, mgr);
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x1f8_missileBracketTimer != 0.f && x1f8_missileBracketTimer < g_tweakTargeting->GetMissileBracketDuration()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (x1f8_missileBracketTimer < 0.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1f8_missileBracketTimer = std::min(0.f, x1f8_missileBracketTimer + dt);
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1f8_missileBracketTimer = std::min(g_tweakTargeting->GetMissileBracketDuration(), x1f8_missileBracketTimer + dt);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x204_chargeGaugeOvershootTimer > 0.f) {
|
|
|
|
x204_chargeGaugeOvershootTimer = std::max(0.f, x204_chargeGaugeOvershootTimer - dt);
|
|
|
|
if (x204_chargeGaugeOvershootTimer == 0.f) {
|
2020-04-13 21:03:38 +00:00
|
|
|
for (auto& iconSquare : xe0_outerBeamIconSquares) {
|
|
|
|
iconSquare.x10_rotAng = iconSquare.x14_baseAngle;
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
xc4_chargeGauge.x10_rotAng = xc4_chargeGauge.x14_baseAngle;
|
|
|
|
x208_lockonTimer = FLT_EPSILON;
|
|
|
|
} else {
|
2020-04-13 21:03:38 +00:00
|
|
|
const float offshoot =
|
2018-12-08 05:30:43 +00:00
|
|
|
offshoot_func(x2c_overshootOffsetHalf, x30_premultOvershootOffset,
|
|
|
|
1.f - x204_chargeGaugeOvershootTimer / g_tweakTargeting->GetChargeGaugeOvershootDuration());
|
2020-04-13 21:03:38 +00:00
|
|
|
for (auto& item : xe0_outerBeamIconSquares) {
|
|
|
|
item.x10_rotAng = zeus::CRelAngle(item.x18_offshootAngleDelta * offshoot + item.xc_offshootBaseAngle).asRel();
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
xc4_chargeGauge.x10_rotAng =
|
2018-12-17 03:52:51 +00:00
|
|
|
zeus::CRelAngle(xc4_chargeGauge.x18_offshootAngleDelta * offshoot + xc4_chargeGauge.xc_offshootBaseAngle).
|
|
|
|
asRel();
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
if (x208_lockonTimer > 0.f && x208_lockonTimer < g_tweakTargeting->GetLockonDuration()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x208_lockonTimer = std::min(g_tweakTargeting->GetLockonDuration(), x208_lockonTimer + dt);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (x210_lockFireTimer > 0.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x210_lockFireTimer = std::max(0.f, x210_lockFireTimer - dt);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (x1fc_missileBracketScaleTimer > 0.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1fc_missileBracketScaleTimer = std::max(0.f, x1fc_missileBracketScaleTimer - dt);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CCompoundTargetReticle::UpdateNextLockOnGroup(float dt, const CStateManager& mgr) {
|
|
|
|
TUniqueId nextTargetId = mgr.GetPlayer().GetOrbitNextTargetId();
|
|
|
|
if (mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan &&
|
2020-04-13 21:03:38 +00:00
|
|
|
mgr.GetPlayer().GetOrbitTargetId() != kInvalidUniqueId) {
|
2018-12-08 05:30:43 +00:00
|
|
|
nextTargetId = mgr.GetPlayer().GetOrbitTargetId();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (nextTargetId != xf2_nextTargetId) {
|
|
|
|
if (nextTargetId == kInvalidUniqueId) {
|
|
|
|
x194_nextGroupA = x174_nextGroupInterp;
|
|
|
|
x1b4_nextGroupB = CTargetReticleRenderState(
|
|
|
|
kInvalidUniqueId, 1.f,
|
|
|
|
(x20_prevState == EReticleState::XRay || x20_prevState == EReticleState::Thermal) ? x100_laggingTargetPos
|
|
|
|
: xf4_targetPos,
|
|
|
|
0.f, 1.f, true);
|
|
|
|
x1d4_nextGroupDur = x1d8_nextGroupTimer = g_tweakTargeting->GetNextLockOnExitDuration();
|
|
|
|
xf2_nextTargetId = nextTargetId;
|
|
|
|
} else {
|
|
|
|
x194_nextGroupA = x174_nextGroupInterp;
|
|
|
|
x1b4_nextGroupB = CTargetReticleRenderState(
|
2019-02-24 07:15:54 +00:00
|
|
|
nextTargetId, 1.f, zeus::skZero3f, 1.f,
|
2018-12-08 05:30:43 +00:00
|
|
|
IsGrappleTarget(nextTargetId, mgr) ? g_tweakTargeting->GetGrappleMinClampScale() : 1.f, true);
|
|
|
|
x1d4_nextGroupDur = x1d8_nextGroupTimer = xf2_nextTargetId == kInvalidUniqueId
|
|
|
|
? g_tweakTargeting->GetNextLockOnEnterDuration()
|
|
|
|
: g_tweakTargeting->GetNextLockOnSwitchDuration();
|
|
|
|
xf2_nextTargetId = nextTargetId;
|
|
|
|
}
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x1d8_nextGroupTimer > 0.f) {
|
|
|
|
UpdateTargetParameters(x194_nextGroupA, mgr);
|
|
|
|
UpdateTargetParameters(x1b4_nextGroupB, mgr);
|
|
|
|
x1d8_nextGroupTimer = std::max(0.f, x1d8_nextGroupTimer - dt);
|
|
|
|
CTargetReticleRenderState::InterpolateWithClamp(x194_nextGroupA, x174_nextGroupInterp, x1b4_nextGroupB,
|
|
|
|
1.f - x1d8_nextGroupTimer / x1d4_nextGroupDur);
|
|
|
|
} else {
|
|
|
|
UpdateTargetParameters(x174_nextGroupInterp, mgr);
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CCompoundTargetReticle::UpdateOrbitZoneGroup(float dt, const CStateManager& mgr) {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (xf0_targetId == kInvalidUniqueId && xf2_nextTargetId != kInvalidUniqueId) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x20c_ = std::min(1.f, 2.f * dt + x20c_);
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x20c_ = std::max(0.f, x20c_ - 2.f * dt);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (mgr.GetPlayer().IsShowingCrosshairs() &&
|
2020-04-13 21:03:38 +00:00
|
|
|
mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Scan) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1e8_crosshairsScale = std::min(1.f, dt / g_tweakTargeting->GetCrosshairsScaleDuration() + x1e8_crosshairsScale);
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1e8_crosshairsScale = std::max(0.f, x1e8_crosshairsScale - dt / g_tweakTargeting->GetCrosshairsScaleDuration());
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2020-04-10 01:28:50 +00:00
|
|
|
void CCompoundTargetReticle::Draw(const CStateManager& mgr, bool hideLockon) {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (mgr.GetPlayer().GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Unmorphed &&
|
|
|
|
!mgr.GetCameraManager()->IsInCinematicCamera()) {
|
2019-07-21 08:42:52 +00:00
|
|
|
SCOPED_GRAPHICS_DEBUG_GROUP("CCompoundTargetReticle::Draw", zeus::skCyan);
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetViewPointMatrix(camXf);
|
|
|
|
if (!hideLockon) {
|
|
|
|
DrawCurrLockOnGroup(camXf.basis, mgr);
|
|
|
|
DrawNextLockOnGroup(camXf.basis, mgr);
|
|
|
|
DrawOrbitZoneGroup(camXf.basis, mgr);
|
|
|
|
}
|
|
|
|
DrawGrappleGroup(camXf.basis, mgr, hideLockon);
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
if (x28_noDrawTicks > 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
--x28_noDrawTicks;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCompoundTargetReticle::DrawGrapplePoint(const CScriptGrapplePoint& point, float t, const CStateManager& mgr,
|
2018-12-08 05:30:43 +00:00
|
|
|
const zeus::CMatrix3f& rot, bool zEqual) const {
|
|
|
|
zeus::CVector3f orbitPos = point.GetOrbitPosition(mgr);
|
|
|
|
zeus::CColor color;
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
if (point.GetGrappleParameters().GetLockSwingTurn()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
color = g_tweakTargeting->GetLockedGrapplePointSelectColor();
|
2020-04-13 21:03:38 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
color = g_tweakTargeting->GetGrapplePointSelectColor();
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
color = zeus::CColor::lerp(g_tweakTargeting->GetGrapplePointColor(), color, t);
|
|
|
|
zeus::CMatrix3f scale(
|
|
|
|
CalculateClampedScale(orbitPos, 1.f, g_tweakTargeting->GetGrappleClampMin(),
|
|
|
|
g_tweakTargeting->GetGrappleClampMax(), mgr) *
|
|
|
|
((1.f - t) * g_tweakTargeting->GetGrappleScale() + t * g_tweakTargeting->GetGrappleSelectScale()));
|
|
|
|
zeus::CTransform modelXf(rot * scale, orbitPos);
|
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
CModelFlags flags(7, 0, 0, color);
|
|
|
|
x94_grapple->Draw(flags);
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CCompoundTargetReticle::DrawGrappleGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr,
|
|
|
|
bool hideLockon) const {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (x28_noDrawTicks > 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GrappleBeam) && x94_grapple.IsLoaded() &&
|
|
|
|
x20_prevState != EReticleState::Scan) {
|
|
|
|
if (hideLockon) {
|
|
|
|
for (const CEntity* ent : mgr.GetAllObjectList()) {
|
|
|
|
if (TCastToConstPtr<CScriptGrapplePoint> point = ent) {
|
|
|
|
if (point->GetActive()) {
|
|
|
|
if (point->GetAreaIdAlways() != kInvalidAreaId) {
|
|
|
|
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(point->GetAreaIdAlways());
|
2020-04-13 21:03:38 +00:00
|
|
|
const auto occState =
|
2018-12-08 05:30:43 +00:00
|
|
|
area->IsPostConstructed() ? area->GetOcclusionState() : CGameArea::EOcclusionState::Occluded;
|
2020-04-13 21:03:38 +00:00
|
|
|
if (occState != CGameArea::EOcclusionState::Visible) {
|
2018-12-08 05:30:43 +00:00
|
|
|
continue;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
float t = 0.f;
|
2020-04-13 21:03:38 +00:00
|
|
|
if (point->GetUniqueId() == x1dc_grapplePoint0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
t = x1e0_grapplePoint0T;
|
2020-04-13 21:03:38 +00:00
|
|
|
} else if (point->GetUniqueId() == x1de_grapplePoint1) {
|
2018-12-08 05:30:43 +00:00
|
|
|
t = x1e4_grapplePoint1T;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (std::fabs(t) < 0.00001f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DrawGrapplePoint(*point, t, mgr, rot, true);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-04-13 21:03:38 +00:00
|
|
|
const TCastToConstPtr<CScriptGrapplePoint> point0 = mgr.GetObjectById(x1dc_grapplePoint0);
|
|
|
|
const TCastToConstPtr<CScriptGrapplePoint> point1 = mgr.GetObjectById(x1de_grapplePoint1);
|
2018-12-08 05:30:43 +00:00
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
const CScriptGrapplePoint* point = i == 0 ? point0.GetPtr() : point1.GetPtr();
|
2020-04-13 21:03:38 +00:00
|
|
|
const float t = i == 0 ? x1e0_grapplePoint0T : x1e4_grapplePoint1T;
|
|
|
|
if (point) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DrawGrapplePoint(*point, t, mgr, rot, false);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CCompoundTargetReticle::DrawCurrLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (x28_noDrawTicks > 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
if (x1e0_grapplePoint0T + x1e4_grapplePoint1T > 0 || x10c_currGroupInterp.GetFactor() == 0.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
float lockBreakAlpha = x10c_currGroupInterp.GetFactor();
|
|
|
|
float visorFactor = mgr.GetPlayerState()->GetVisorTransitionFactor();
|
|
|
|
bool lockConfirm = false;
|
|
|
|
bool lockReticule = false;
|
|
|
|
switch (x20_prevState) {
|
|
|
|
case EReticleState::Combat:
|
|
|
|
lockConfirm = true;
|
|
|
|
lockReticule = true;
|
|
|
|
break;
|
|
|
|
case EReticleState::Scan:
|
|
|
|
lockConfirm = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CMatrix3f lockBreakXf;
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CColor lockBreakColor = zeus::skClear;
|
2018-12-08 05:30:43 +00:00
|
|
|
if (IsDamageOrbit(mgr.GetPlayer().GetOrbitRequest()) && x14c_currGroupB.GetFactor() == 0.f) {
|
|
|
|
zeus::CMatrix3f lockBreakRM;
|
|
|
|
for (int i = 0; i < 4; ++i) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const int a = rand() % 9;
|
|
|
|
const auto b = std::div(a, 3);
|
2018-12-08 05:30:43 +00:00
|
|
|
lockBreakRM[b.rem][b.quot] += rand() / float(RAND_MAX) - 0.5f;
|
|
|
|
}
|
|
|
|
lockBreakXf = lockBreakRM.transposed();
|
2020-04-13 21:03:38 +00:00
|
|
|
if (x10c_currGroupInterp.GetFactor() > 0.8f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
lockBreakColor = zeus::CColor(1.f, (x10c_currGroupInterp.GetFactor() - 0.8f) * 0.3f / 0.2f);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
lockBreakAlpha = x10c_currGroupInterp.GetFactor() > 0.75f
|
|
|
|
? 1.f
|
|
|
|
: std::max(0.f, (x10c_currGroupInterp.GetFactor() - 0.55f) / 0.2f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lockConfirm && x4c_lockConfirm.IsLoaded()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
|
|
|
|
x10c_currGroupInterp.GetRadiusWorld(),
|
|
|
|
x10c_currGroupInterp.GetMinViewportClampScale() *
|
|
|
|
g_tweakTargeting->GetLockConfirmClampMin(),
|
|
|
|
g_tweakTargeting->GetLockConfirmClampMax(), mgr) *
|
|
|
|
g_tweakTargeting->GetLockConfirmScale() / x10c_currGroupInterp.GetFactor());
|
|
|
|
const zeus::CTransform modelXf(lockBreakXf * (rot * zeus::CMatrix3f::RotateY(x1ec_seekerAngle) * scale),
|
|
|
|
x10c_currGroupInterp.GetTargetPositionWorld());
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
zeus::CColor color = g_tweakTargeting->GetLockConfirmColor();
|
|
|
|
color.a() *= lockBreakAlpha;
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, lockBreakColor + color);
|
2018-12-08 05:30:43 +00:00
|
|
|
x4c_lockConfirm->Draw(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lockReticule) {
|
|
|
|
if (x58_targetFlower.IsLoaded()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
|
|
|
|
x10c_currGroupInterp.GetRadiusWorld(),
|
|
|
|
x10c_currGroupInterp.GetMinViewportClampScale() *
|
|
|
|
g_tweakTargeting->GetTargetFlowerClampMin(),
|
|
|
|
g_tweakTargeting->GetTargetFlowerClampMax(), mgr) *
|
|
|
|
g_tweakTargeting->GetTargetFlowerScale() / lockBreakAlpha);
|
|
|
|
const zeus::CTransform modelXf(lockBreakXf * (rot * zeus::CMatrix3f::RotateY(x1f0_xrayRetAngle) * scale),
|
|
|
|
x10c_currGroupInterp.GetTargetPositionWorld());
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
zeus::CColor color = g_tweakTargeting->GetTargetFlowerColor();
|
|
|
|
color.a() *= lockBreakAlpha * visorFactor;
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, lockBreakColor + color);
|
2018-12-08 05:30:43 +00:00
|
|
|
x58_targetFlower->Draw(flags);
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x1f8_missileBracketTimer != 0.f && x64_missileBracket.IsLoaded()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const float t =
|
|
|
|
std::fabs((x1fc_missileBracketScaleTimer - 0.5f * g_tweakTargeting->GetMissileBracketScaleDuration()) / 0.5f *
|
|
|
|
g_tweakTargeting->GetMissileBracketScaleDuration());
|
|
|
|
const float tscale = ((1.f - t) * g_tweakTargeting->GetMissileBracketScaleEnd() +
|
|
|
|
t * g_tweakTargeting->GetMissileBracketScaleStart());
|
|
|
|
const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
|
|
|
|
x10c_currGroupInterp.GetRadiusWorld(),
|
|
|
|
x10c_currGroupInterp.GetMinViewportClampScale() *
|
|
|
|
g_tweakTargeting->GetMissileBracketClampMin(),
|
|
|
|
g_tweakTargeting->GetMissileBracketClampMax(), mgr) *
|
|
|
|
std::fabs(x1f8_missileBracketTimer) / g_tweakTargeting->GetMissileBracketDuration() *
|
|
|
|
tscale / x10c_currGroupInterp.GetFactor());
|
2018-12-08 05:30:43 +00:00
|
|
|
for (int i = 0; i < 4; ++i) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CTransform modelXf(
|
2018-12-08 05:30:43 +00:00
|
|
|
lockBreakXf * rot * zeus::CMatrix3f(zeus::CVector3f{i < 2 ? 1.f : -1.f, 1.f, i & 0x1 ? 1.f : -1.f}) * scale,
|
|
|
|
x10c_currGroupInterp.GetTargetPositionWorld());
|
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
zeus::CColor color = g_tweakTargeting->GetMissileBracketColor();
|
|
|
|
color.a() *= lockBreakAlpha * visorFactor;
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, lockBreakColor + color);
|
2018-12-08 05:30:43 +00:00
|
|
|
x64_missileBracket->Draw(flags);
|
|
|
|
}
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
|
|
|
|
x10c_currGroupInterp.GetRadiusWorld(),
|
|
|
|
x10c_currGroupInterp.GetMinViewportClampScale() *
|
|
|
|
g_tweakTargeting->GetChargeGaugeClampMin(),
|
|
|
|
g_tweakTargeting->GetChargeGaugeClampMax(), mgr) *
|
|
|
|
1.f / x10c_currGroupInterp.GetFactor() * g_tweakTargeting->GetOuterBeamSquaresScale());
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CMatrix3f outerBeamXf = rot * scale;
|
|
|
|
for (int i = 0; i < 9; ++i) {
|
|
|
|
const SOuterItemInfo& info = xe0_outerBeamIconSquares[i];
|
|
|
|
if (info.x0_model.IsLoaded()) {
|
|
|
|
zeus::CTransform modelXf(lockBreakXf * outerBeamXf * zeus::CMatrix3f::RotateY(info.x10_rotAng),
|
2017-10-30 03:37:20 +00:00
|
|
|
x10c_currGroupInterp.GetTargetPositionWorld());
|
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CColor color = g_tweakTargeting->GetOuterBeamSquareColor();
|
|
|
|
color.a() *= lockBreakAlpha * visorFactor;
|
2017-10-30 03:37:20 +00:00
|
|
|
CModelFlags flags(7, 0, 0, lockBreakColor + color);
|
2018-12-08 05:30:43 +00:00
|
|
|
info.x0_model->Draw(flags);
|
|
|
|
}
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (xc4_chargeGauge.x0_model.IsLoaded()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
|
|
|
|
x10c_currGroupInterp.GetRadiusWorld(),
|
|
|
|
x10c_currGroupInterp.GetMinViewportClampScale() *
|
|
|
|
g_tweakTargeting->GetChargeGaugeClampMin(),
|
|
|
|
g_tweakTargeting->GetChargeGaugeClampMax(), mgr) *
|
|
|
|
g_tweakTargeting->GetChargeGaugeScale() / x10c_currGroupInterp.GetFactor());
|
|
|
|
const zeus::CMatrix3f chargeGaugeXf = rot * scale * zeus::CMatrix3f::RotateY(xc4_chargeGauge.x10_rotAng);
|
|
|
|
const float pulseT =
|
|
|
|
std::fabs(std::fmod(CGraphics::GetSecondsMod900(), g_tweakTargeting->GetChargeGaugePulsePeriod()));
|
|
|
|
const zeus::CColor gaugeColor =
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CColor::lerp(g_tweakTargeting->GetChargeGaugeNonFullColor(),
|
|
|
|
zeus::CColor::lerp(g_tweakTargeting->GetChargeGaugePulseColorHigh(),
|
|
|
|
g_tweakTargeting->GetChargeGaugePulseColorLow(),
|
|
|
|
pulseT < 0.5f * g_tweakTargeting->GetChargeGaugePulsePeriod()
|
|
|
|
? pulseT / (0.5f * g_tweakTargeting->GetChargeGaugePulsePeriod())
|
|
|
|
: (g_tweakTargeting->GetChargeGaugePulsePeriod() - pulseT) /
|
|
|
|
(0.5f * g_tweakTargeting->GetChargeGaugePulsePeriod())),
|
|
|
|
x214_fullChargeFadeTimer / g_tweakTargeting->GetFullChargeFadeDuration());
|
|
|
|
zeus::CTransform modelXf(lockBreakXf * chargeGaugeXf, x10c_currGroupInterp.GetTargetPositionWorld());
|
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
zeus::CColor color = gaugeColor;
|
|
|
|
color.a() *= lockBreakAlpha * visorFactor;
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, lockBreakColor + color);
|
2018-12-08 05:30:43 +00:00
|
|
|
xc4_chargeGauge.x0_model->Draw(flags);
|
|
|
|
|
|
|
|
if (xa0_chargeTickFirst.IsLoaded()) {
|
|
|
|
const CPlayerGun* gun = mgr.GetPlayer().GetPlayerGun();
|
2020-04-13 21:03:38 +00:00
|
|
|
const int numTicks =
|
2018-12-08 05:30:43 +00:00
|
|
|
int(g_tweakTargeting->GetChargeTickCount() * (gun->IsCharging() ? gun->GetChargeBeamFactor() : 0.f));
|
|
|
|
for (int i = 0; i < numTicks; ++i) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags tickFlags(7, 0, 0, lockBreakColor + color);
|
|
|
|
xa0_chargeTickFirst->Draw(tickFlags);
|
2018-12-08 05:30:43 +00:00
|
|
|
modelXf.rotateLocalY(g_tweakTargeting->GetChargeTickAnglePitch());
|
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
2017-10-30 03:37:20 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-10-30 03:37:20 +00:00
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x208_lockonTimer > 0.f && x70_innerBeamIcon.IsLoaded()) {
|
|
|
|
const zeus::CColor* iconColor;
|
|
|
|
switch (x200_beam) {
|
|
|
|
case CPlayerState::EBeamId::Power:
|
|
|
|
iconColor = &g_tweakTargeting->GetInnerBeamColorPower();
|
2017-10-29 06:21:52 +00:00
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
case CPlayerState::EBeamId::Ice:
|
|
|
|
iconColor = &g_tweakTargeting->GetInnerBeamColorIce();
|
2017-10-29 06:21:52 +00:00
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
case CPlayerState::EBeamId::Wave:
|
|
|
|
iconColor = &g_tweakTargeting->GetInnerBeamColorWave();
|
2017-10-29 06:21:52 +00:00
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
default:
|
|
|
|
iconColor = &g_tweakTargeting->GetInnerBeamColorPlasma();
|
2017-10-29 06:21:52 +00:00
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
|
|
|
const zeus::CMatrix3f scale(
|
2018-12-08 05:30:43 +00:00
|
|
|
CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), x10c_currGroupInterp.GetRadiusWorld(),
|
|
|
|
x10c_currGroupInterp.GetMinViewportClampScale() *
|
|
|
|
g_tweakTargeting->GetInnerBeamClampMin(),
|
|
|
|
g_tweakTargeting->GetInnerBeamClampMax(), mgr) *
|
|
|
|
g_tweakTargeting->GetInnerBeamScale() * (x208_lockonTimer / g_tweakTargeting->GetLockonDuration()) /
|
|
|
|
x10c_currGroupInterp.GetFactor());
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CTransform modelXf(lockBreakXf * rot * scale, x10c_currGroupInterp.GetTargetPositionWorld());
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
zeus::CColor color = *iconColor;
|
|
|
|
color.a() *= lockBreakAlpha * visorFactor;
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, lockBreakColor + color);
|
2018-12-08 05:30:43 +00:00
|
|
|
x70_innerBeamIcon->Draw(flags);
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x210_lockFireTimer > 0.f && x7c_lockFire.IsLoaded()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CMatrix3f scale(CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(),
|
|
|
|
x10c_currGroupInterp.GetRadiusWorld(),
|
|
|
|
x10c_currGroupInterp.GetMinViewportClampScale() *
|
|
|
|
g_tweakTargeting->GetLockFireClampMin(),
|
|
|
|
g_tweakTargeting->GetLockFireClampMax(), mgr) *
|
|
|
|
g_tweakTargeting->GetLockFireScale() / x10c_currGroupInterp.GetFactor());
|
|
|
|
const zeus::CTransform modelXf(lockBreakXf * rot * scale * zeus::CMatrix3f::RotateY(x1f0_xrayRetAngle),
|
|
|
|
x10c_currGroupInterp.GetTargetPositionWorld());
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
zeus::CColor color = g_tweakTargeting->GetLockFireColor();
|
|
|
|
color.a() *= visorFactor * lockBreakAlpha * (x210_lockFireTimer / g_tweakTargeting->GetLockFireDuration());
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, lockBreakColor + color);
|
2018-12-08 05:30:43 +00:00
|
|
|
x7c_lockFire->Draw(flags);
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x208_lockonTimer > 0.f && x88_lockDagger.IsLoaded()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const float t = std::fabs((x210_lockFireTimer - 0.5f * g_tweakTargeting->GetLockFireDuration()) / 0.5f *
|
|
|
|
g_tweakTargeting->GetLockFireDuration());
|
|
|
|
const float tscale =
|
2018-12-08 05:30:43 +00:00
|
|
|
((1.f - t) * g_tweakTargeting->GetLockDaggerScaleEnd() + t * g_tweakTargeting->GetLockDaggerScaleStart());
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CMatrix3f scale(
|
2018-12-08 05:30:43 +00:00
|
|
|
CalculateClampedScale(x10c_currGroupInterp.GetTargetPositionWorld(), x10c_currGroupInterp.GetRadiusWorld(),
|
|
|
|
x10c_currGroupInterp.GetMinViewportClampScale() *
|
|
|
|
g_tweakTargeting->GetLockDaggerClampMin(),
|
|
|
|
g_tweakTargeting->GetLockDaggerClampMax(), mgr) *
|
|
|
|
tscale * (x208_lockonTimer / g_tweakTargeting->GetLockonDuration()) / x10c_currGroupInterp.GetFactor());
|
|
|
|
zeus::CMatrix3f lockDaggerXf = rot * scale;
|
|
|
|
for (int i = 0; i < 3; ++i) {
|
|
|
|
float ang;
|
|
|
|
switch (i) {
|
|
|
|
case 0:
|
|
|
|
ang = g_tweakTargeting->GetLockDaggerAngle0();
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ang = g_tweakTargeting->GetLockDaggerAngle1();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ang = g_tweakTargeting->GetLockDaggerAngle2();
|
|
|
|
break;
|
|
|
|
}
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CTransform modelXf(lockBreakXf * lockDaggerXf * zeus::CMatrix3f::RotateY(ang),
|
|
|
|
x10c_currGroupInterp.GetTargetPositionWorld());
|
2017-10-29 06:21:52 +00:00
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CColor color = g_tweakTargeting->GetLockDaggerColor();
|
|
|
|
color.a() *= visorFactor * lockBreakAlpha;
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, lockBreakColor + color);
|
2018-12-08 05:30:43 +00:00
|
|
|
x88_lockDagger->Draw(flags);
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
|
2020-04-10 01:28:50 +00:00
|
|
|
void CCompoundTargetReticle::DrawNextLockOnGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) {
|
|
|
|
if (x28_noDrawTicks > 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-04-10 01:28:50 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
zeus::CVector3f position = x174_nextGroupInterp.GetTargetPositionWorld();
|
|
|
|
float visorFactor = mgr.GetPlayerState()->GetVisorTransitionFactor();
|
|
|
|
|
|
|
|
bool scanRet = false;
|
|
|
|
bool xrayRet = false;
|
|
|
|
bool thermalRet = false;
|
|
|
|
switch (x20_prevState) {
|
|
|
|
case EReticleState::Scan:
|
|
|
|
scanRet = true;
|
|
|
|
break;
|
|
|
|
case EReticleState::XRay:
|
|
|
|
xrayRet = true;
|
|
|
|
break;
|
|
|
|
case EReticleState::Thermal:
|
|
|
|
thermalRet = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!xrayRet && x174_nextGroupInterp.GetFactor() > 0.f && x40_seeker.IsLoaded()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CMatrix3f scale(
|
2018-12-08 05:30:43 +00:00
|
|
|
CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(),
|
|
|
|
x174_nextGroupInterp.GetMinViewportClampScale() * g_tweakTargeting->GetSeekerClampMin(),
|
|
|
|
g_tweakTargeting->GetSeekerClampMax(), mgr) *
|
|
|
|
g_tweakTargeting->GetSeekerScale());
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CTransform modelXf(rot * zeus::CMatrix3f::RotateY(x1ec_seekerAngle) * scale,
|
|
|
|
x174_nextGroupInterp.GetTargetPositionWorld());
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
zeus::CColor color = g_tweakTargeting->GetSeekerColor();
|
|
|
|
color.a() *= x174_nextGroupInterp.GetFactor();
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, color);
|
2018-12-08 05:30:43 +00:00
|
|
|
x40_seeker->Draw(flags);
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (xrayRet && xac_xrayRetRing.IsLoaded()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CMatrix3f scale(
|
2018-12-08 05:30:43 +00:00
|
|
|
CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(),
|
|
|
|
x174_nextGroupInterp.GetMinViewportClampScale() * g_tweakTargeting->GetReticuleClampMin(),
|
|
|
|
g_tweakTargeting->GetReticuleClampMax(), mgr) *
|
|
|
|
g_tweakTargeting->GetReticuleScale());
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CTransform modelXf(rot * scale * zeus::CMatrix3f::RotateY(x1f0_xrayRetAngle),
|
|
|
|
x174_nextGroupInterp.GetTargetPositionWorld());
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
zeus::CColor color = g_tweakTargeting->GetXRayRetRingColor();
|
|
|
|
color.a() *= visorFactor;
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, color);
|
2018-12-08 05:30:43 +00:00
|
|
|
xac_xrayRetRing->Draw(flags);
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (thermalRet && xb8_thermalReticle.IsLoaded()) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CMatrix3f scale(
|
2018-12-08 05:30:43 +00:00
|
|
|
CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(),
|
|
|
|
x174_nextGroupInterp.GetMinViewportClampScale() * g_tweakTargeting->GetReticuleClampMin(),
|
|
|
|
g_tweakTargeting->GetReticuleClampMax(), mgr) *
|
|
|
|
g_tweakTargeting->GetReticuleScale());
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CTransform modelXf(rot * scale, x174_nextGroupInterp.GetTargetPositionWorld());
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
zeus::CColor color = g_tweakTargeting->GetThermalReticuleColor();
|
|
|
|
color.a() *= visorFactor;
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, color);
|
2018-12-08 05:30:43 +00:00
|
|
|
xb8_thermalReticle->Draw(flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scanRet && visorFactor > 0.f) {
|
|
|
|
float factor = visorFactor * x174_nextGroupInterp.GetFactor();
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CMatrix3f scale(CalculateClampedScale(position, x174_nextGroupInterp.GetRadiusWorld(),
|
|
|
|
x174_nextGroupInterp.GetMinViewportClampScale() *
|
|
|
|
g_tweakTargeting->GetScanTargetClampMin(),
|
|
|
|
g_tweakTargeting->GetScanTargetClampMax(), mgr) *
|
|
|
|
(1.f / factor));
|
|
|
|
const zeus::CTransform modelXf(rot * scale, x174_nextGroupInterp.GetTargetPositionWorld());
|
2018-12-08 05:30:43 +00:00
|
|
|
CGraphics::SetModelMatrix(modelXf);
|
|
|
|
// compare, GX_LESS, no update
|
|
|
|
float alpha = 0.5f * factor;
|
|
|
|
zeus::CColor color = g_tweakGuiColors->GetScanReticuleColor();
|
|
|
|
color.a() *= alpha;
|
2020-04-13 20:44:39 +00:00
|
|
|
for (size_t i = 0; i < m_scanRetRenderer.m_lineRenderers.size(); ++i) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const float lineWidth = i != 0 ? 2.5f : 1.f;
|
2018-12-08 05:30:43 +00:00
|
|
|
auto& rend = *m_scanRetRenderer.m_lineRenderers[i];
|
|
|
|
rend.Reset();
|
|
|
|
rend.AddVertex({-0.5f, 0.f, 0.f}, color, lineWidth);
|
|
|
|
rend.AddVertex({-20.5f, 0.f, 0.f}, color, lineWidth);
|
|
|
|
rend.AddVertex({0.5f, 0.f, 0.f}, color, lineWidth);
|
|
|
|
rend.AddVertex({20.5f, 0.f, 0.f}, color, lineWidth);
|
|
|
|
rend.AddVertex({0.f, 0.f, -0.5f}, color, lineWidth);
|
|
|
|
rend.AddVertex({0.f, 0.f, -20.5f}, color, lineWidth);
|
|
|
|
rend.AddVertex({0.f, 0.f, 0.5f}, color, lineWidth);
|
|
|
|
rend.AddVertex({0.f, 0.f, 20.5f}, color, lineWidth);
|
|
|
|
rend.Render();
|
|
|
|
|
2020-04-13 20:44:39 +00:00
|
|
|
for (size_t j = 0; j < m_scanRetRenderer.m_stripRenderers[i].size(); ++j) {
|
2020-04-13 21:03:38 +00:00
|
|
|
const float xSign = j < 2 ? -1.f : 1.f;
|
|
|
|
const float zSign = (j & 0x1) != 0 ? -1.f : 1.f;
|
2018-12-08 05:30:43 +00:00
|
|
|
// begin line strip
|
2020-04-13 20:44:39 +00:00
|
|
|
auto& stripRend = *m_scanRetRenderer.m_stripRenderers[i][j];
|
|
|
|
stripRend.Reset();
|
|
|
|
stripRend.AddVertex({0.5f * xSign, 0.f, 0.1f * zSign}, color, lineWidth);
|
|
|
|
stripRend.AddVertex({0.5f * xSign, 0.f, 0.35f * zSign}, color, lineWidth);
|
|
|
|
stripRend.AddVertex({0.35f * xSign, 0.f, 0.5f * zSign}, color, lineWidth);
|
|
|
|
stripRend.AddVertex({0.1f * xSign, 0.f, 0.5f * zSign}, color, lineWidth);
|
|
|
|
stripRend.Render();
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CCompoundTargetReticle::DrawOrbitZoneGroup(const zeus::CMatrix3f& rot, const CStateManager& mgr) const {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (x28_noDrawTicks > 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x1e8_crosshairsScale > 0.f && x34_crosshairs.IsLoaded()) {
|
|
|
|
CGraphics::SetModelMatrix(zeus::CTransform(rot, xf4_targetPos) * zeus::CTransform::Scale(x1e8_crosshairsScale));
|
|
|
|
zeus::CColor color = g_tweakTargeting->GetCrosshairsColor();
|
|
|
|
color.a() *= x1e8_crosshairsScale;
|
2020-04-13 21:03:38 +00:00
|
|
|
const CModelFlags flags(7, 0, 0, color);
|
2018-12-08 05:30:43 +00:00
|
|
|
x34_crosshairs->Draw(flags);
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CCompoundTargetReticle::UpdateTargetParameters(CTargetReticleRenderState& state, const CStateManager& mgr) {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (const auto act = TCastToConstPtr<CActor>(mgr.GetAllObjectList().GetObjectById(state.GetTargetId()))) {
|
2018-12-08 05:30:43 +00:00
|
|
|
state.SetRadiusWorld(CalculateRadiusWorld(*act, mgr));
|
|
|
|
state.SetTargetPositionWorld(CalculatePositionWorld(*act, mgr));
|
|
|
|
} else if (state.GetIsOrbitZoneIdlePosition()) {
|
|
|
|
state.SetRadiusWorld(1.f);
|
|
|
|
state.SetTargetPositionWorld((x20_prevState == EReticleState::XRay || x20_prevState == EReticleState::Thermal)
|
|
|
|
? x100_laggingTargetPos
|
|
|
|
: xf4_targetPos);
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
float CCompoundTargetReticle::CalculateRadiusWorld(const CActor& act, const CStateManager& mgr) const {
|
2020-04-13 21:03:38 +00:00
|
|
|
const auto tb = act.GetTouchBounds();
|
|
|
|
const zeus::CAABox aabb = tb ? *tb : zeus::CAABox(act.GetAimPosition(mgr, 0.f), act.GetAimPosition(mgr, 0.f));
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
float radius;
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CVector3f delta = aabb.max - aabb.min;
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (g_tweakTargeting->GetTargetRadiusMode()) {
|
|
|
|
case 0: {
|
|
|
|
radius = std::min(delta.x(), std::min(delta.y(), delta.z())) * 0.5f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1: {
|
|
|
|
radius = std::max(delta.x(), std::max(delta.y(), delta.z())) * 0.5f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
radius = (delta.x() + delta.y() + delta.z()) / 6.f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return radius > 0.f ? radius : 1.f;
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f CCompoundTargetReticle::CalculatePositionWorld(const CActor& act, const CStateManager& mgr) const {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (x20_prevState == EReticleState::Scan) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return act.GetOrbitPosition(mgr);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
return act.GetAimPosition(mgr, 0.f);
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f CCompoundTargetReticle::CalculateOrbitZoneReticlePosition(const CStateManager& mgr, bool lag) const {
|
|
|
|
const CGameCamera* curCam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
|
2020-04-13 21:03:38 +00:00
|
|
|
const float distMul =
|
2018-12-08 05:30:43 +00:00
|
|
|
224.f / float(g_tweakPlayer->GetOrbitScreenBoxHalfExtentY(0)) / std::tan(zeus::degToRad(0.5f * curCam->GetFov()));
|
2020-04-13 21:03:38 +00:00
|
|
|
const zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f lookDir = camXf.basis[1];
|
2020-04-13 21:03:38 +00:00
|
|
|
if (lag) {
|
2018-12-08 05:30:43 +00:00
|
|
|
lookDir = x10_laggingOrientation.transform(lookDir);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
return lookDir * distMul + camXf.origin;
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CCompoundTargetReticle::IsGrappleTarget(TUniqueId uid, const CStateManager& mgr) const {
|
|
|
|
return TCastToConstPtr<CScriptGrapplePoint>(mgr.GetAllObjectList().GetObjectById(uid)).operator bool();
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
2017-05-30 03:45:31 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
float CCompoundTargetReticle::CalculateClampedScale(const zeus::CVector3f& pos, float scale, float clampMin,
|
|
|
|
float clampMax, const CStateManager& mgr) {
|
|
|
|
const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
|
|
|
|
mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
|
|
|
|
zeus::CVector3f viewPos = cam->GetTransform().transposeRotate(pos - cam->GetTransform().origin);
|
|
|
|
viewPos = zeus::CVector3f(viewPos.x(), viewPos.z(), -viewPos.y());
|
2020-04-13 21:03:38 +00:00
|
|
|
const float realX = cam->GetPerspectiveMatrix().multiplyOneOverW(viewPos).x();
|
|
|
|
const float offsetX = cam->GetPerspectiveMatrix().multiplyOneOverW(viewPos + zeus::CVector3f(scale, 0.f, 0.f)).x();
|
|
|
|
const float unclampedX = (offsetX - realX) * 640;
|
2018-12-08 05:30:43 +00:00
|
|
|
return zeus::clamp(clampMin, unclampedX, clampMax) / unclampedX * scale;
|
2017-05-30 03:45:31 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CCompoundTargetReticle::Touch() {
|
2020-04-13 21:03:38 +00:00
|
|
|
if (x34_crosshairs.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x34_crosshairs->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x40_seeker.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x40_seeker->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x4c_lockConfirm.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x4c_lockConfirm->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x58_targetFlower.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x58_targetFlower->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x64_missileBracket.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x64_missileBracket->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x70_innerBeamIcon.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x70_innerBeamIcon->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x7c_lockFire.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x7c_lockFire->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x88_lockDagger.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x88_lockDagger->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (x94_grapple.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x94_grapple->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xa0_chargeTickFirst.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xa0_chargeTickFirst->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xac_xrayRetRing.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xac_xrayRetRing->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xb8_thermalReticle.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xb8_thermalReticle->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xc4_chargeGauge.x0_model.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
xc4_chargeGauge.x0_model->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (SOuterItemInfo& info : xe0_outerBeamIconSquares) {
|
|
|
|
if (info.x0_model.IsLoaded()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
info.x0_model->Touch(0);
|
2020-04-13 21:03:38 +00:00
|
|
|
}
|
|
|
|
}
|
2017-10-29 06:21:52 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|