Various Ridley fixes

This commit is contained in:
Phillip Stephens 2020-05-13 06:20:40 -07:00
parent e9ea73ec98
commit a432a79cd4
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
8 changed files with 202 additions and 167 deletions

View File

@ -228,7 +228,7 @@ void CBurrower::Active(CStateManager& mgr, EStateMsg msg, float dt) {
x6ac_24_doFacePlayer = true;
x32c_animState = EAnimState::Ready;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 0);
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerateNoXf, 0);
} else if (msg == EStateMsg::Deactivate) {
x6ac_24_doFacePlayer = false;
x6ac_25_inAir = true;
@ -267,7 +267,7 @@ void CBurrower::Retreat(CStateManager& mgr, EStateMsg msg, float dt) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 1);
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerateNoXf, 1);
} else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady;
if (x678_trailParticle) {

View File

@ -405,7 +405,7 @@ void CChozoGhost::Deactivate(CStateManager& mgr, EStateMsg msg, float) {
x32c_animState = EAnimState::Ready;
x665_24_ = true;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 1);
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerateNoXf, 1);
if (x32c_animState == EAnimState::Repeat)
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Relaxed);
} else if (msg == EStateMsg::Deactivate) {

View File

@ -350,7 +350,7 @@ void CMagdolite::Generate(CStateManager& mgr, EStateMsg msg, float arg) {
x32c_animState = EAnimState::Ready;
x754_24_retreat = false;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerateNoXf, 0);
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 0);
if (x32c_animState == EAnimState::Repeat) {
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Relaxed);
}
@ -552,7 +552,7 @@ void CMagdolite::Retreat(CStateManager& mgr, EStateMsg msg, float arg) {
GetBodyController()->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::NextState));
x754_28_alert = true;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 1);
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerateNoXf, 1);
if (x32c_animState == EAnimState::Repeat) {
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Internal7);
}

View File

@ -132,30 +132,11 @@ constexpr std::array skWingBones{
};
constexpr std::array skWingEffects{
"WingSmokeSmall1"sv,
"WingSmokeSmall2"sv,
"WingSmokeSmall3"sv,
"WingSmokeSmall4"sv,
"WingSmokeSmall5"sv,
"WingSmokeSmall6"sv,
"WingSmokeSmall7"sv,
"WingSmokeSmall8"sv,
"WingFire1"sv,
"WingFire2"sv,
"WingFire3"sv,
"WingFire4"sv,
"WingFire5"sv,
"WingFire6"sv,
"WingFire7"sv,
"WingFire8"sv,
"WingSparks1"sv,
"WingSparks2"sv,
"WingSparks3"sv,
"WingSparks4"sv,
"WingSparks5"sv,
"WingSparks6"sv,
"WingSparks7"sv,
"WingSparks8"sv,
"WingSmokeSmall1"sv, "WingSmokeSmall2"sv, "WingSmokeSmall3"sv, "WingSmokeSmall4"sv, "WingSmokeSmall5"sv,
"WingSmokeSmall6"sv, "WingSmokeSmall7"sv, "WingSmokeSmall8"sv, "WingFire1"sv, "WingFire2"sv,
"WingFire3"sv, "WingFire4"sv, "WingFire5"sv, "WingFire6"sv, "WingFire7"sv,
"WingFire8"sv, "WingSparks1"sv, "WingSparks2"sv, "WingSparks3"sv, "WingSparks4"sv,
"WingSparks5"sv, "WingSparks6"sv, "WingSparks7"sv, "WingSparks8"sv,
};
constexpr std::array<SOBBRadiiJointInfo, 4> skTail{{
@ -292,8 +273,9 @@ CRidley::CRidley(TUniqueId uid, std::string_view name, const CEntityInfo& info,
xc14_.Token().Lock();
xc3c_.Token().Lock();
if (xce0_)
if (xce0_) {
xce0_->SetParticleEmission(false);
}
const auto& animData = GetModelData()->GetAnimationData();
for (const auto& wingBone : skWingBones) {
@ -347,7 +329,6 @@ void CRidley::SetupCollisionActorManager(urde::CStateManager& mgr) {
include.Remove(EMaterialTypes::Platform);
SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(include, exclude));
AddMaterial(EMaterialTypes::ProjectilePassthrough);
// mgr.SendScriptMsg(this, GetUniqueId(), EScriptObjectMessage::Reset);
}
void CRidley::SetupCollisionActors(CStateManager& mgr) {
@ -419,8 +400,9 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
}
case EScriptObjectMessage::InitializedInArea: {
TUniqueId wpId = GetWaypointForState(mgr, EScriptObjectState::Patrol, EScriptObjectMessage::Follow);
if (wpId == kInvalidUniqueId)
if (wpId == kInvalidUniqueId) {
break;
}
if (TCastToConstPtr<CScriptWaypoint> wp = mgr.GetObjectById(wpId)) {
xa84_ = wp->GetTransform();
@ -444,14 +426,29 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
colAct->HealthInfo(mgr)->SetHP(1000.f);
bool dontKnockback = false;
if (xc64_aiStage == 2) {
if (xa33_28_) {
dontKnockback = true;
} else {
if (!xa33_28_) {
bool r26 = false;
xb10_ -= lowHealth;
xb24_ = 0.33f;
x430_damageColor = zeus::CColor(0.5f, 0.f, 0.f);
if (xb10_ <= 0.f) {
if (xb10_ > 0.f) {
if (xb10_ >= xcbc_) {
if (xa33_26_ && !xa31_31_ && lowHealth > x568_data.x3f4_) {
dontKnockback = true;
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Zero));
}
} else {
xa32_27_ = true;
dontKnockback = true;
xcb0_ += 1;
xcb0_ = xcb0_ < 5 ? xcb0_ : 4;
r26 = true;
xcbc_ = .2f * (5 - (xcb0_ + 1)) * xcb8_;
xcb4_ = 0;
xcc8_ = 2.f * 0.33f;
}
} else {
xc64_aiStage = 3;
xa31_25_ = false;
sub80257650(mgr);
@ -464,78 +461,67 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
xcc8_ = 2.f * 0.33f;
xb10_ = 0.f;
} else {
if (xb10_ < xcbc_) {
xa32_27_ = true;
dontKnockback = true;
xcb0_ += 1;
xcb0_ = xcb0_ < 5 ? xcb0_ : 4;
r26 = true;
xcbc_ = .2f * (5 - (xcb0_ + 1)) * xcb8_;
xcb4_ = 0;
xcc8_ = 2.f * 0.33f;
} else if (xa33_26_ && !xa31_31_ && lowHealth > x568_data.x3f4_) {
dontKnockback = true;
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Zero));
}
}
sub80256914(2.f * 0.33f, r26);
} else {
dontKnockback = true;
}
} else if (xc64_aiStage == 3) {
if (xa32_29_) {
zeus::CTransform xf = GetLctrTransform(xb90_headSegId);
if (xf.basis[1].dot(mgr.GetPlayer().GetTranslation() - xf.origin) < 0.5f) {
dontKnockback = true;
} else {
TakeDamage(zeus::skForward, 1.f);
xb20_ = 0.33f;
if (xa32_29_) {
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(colAct->GetLastTouchedObject())) {
CWeaponMode wMode = proj->GetDamageInfo().GetWeaponMode();
if (!wMode.IsCharged() && !wMode.IsComboed() && wMode.GetType() == EWeaponType::Missile)
xb14_ = 0.f;
xb14_ -= lowHealth;
xb24_ = 0.33f;
x430_damageColor = zeus::CColor(0.5f, 0.f, 0.f);
if (xb10_ <= 0.f) {
xa32_29_ = false;
dontKnockback = true;
xa32_28_shotAt = true;
xb14_ = x568_data.x38_;
}
}
} else if (xa31_27_) {
x430_damageColor = zeus::CColor(0.5f, 0.f, 0.f);
if (xb18_ > 0.f) {
xb18_ -= lowHealth;
if (xb18_ <= 0.f) {
xa31_26_ = true;
dontKnockback = true;
xb18_ = 0.f;
xcbc_ = 0.6667 * x568_data.x40_;
} else if (xb18_ < xcbc_) {
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Six));
xcbc_ -= (0.333f * x568_data.x3c_);
}
}
} else {
xb1c_ -= lowHealth;
if (xb1c_ <= 0.f) {
x401_30_pendingDeath = true;
mgr.GetPlayer().SetIsOverrideRadarRadius(false);
xb1c_ = 0.f;
} else if (xb1c_ < xcbc_) {
dontKnockback = true;
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Six));
xcbc_ -= (0.333f * x568_data.x40_);
}
if ((mgr.GetPlayer().GetTranslation() - xf.origin).dot(xf.frontVector()) < 0.5f) {
HealthInfo(mgr)->SetHP(xb1c_ + xb10_ + xb18_);
break;
}
}
TakeDamage(zeus::skForward, 1.f);
xb20_ = 0.33f;
if (xa32_29_) {
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(colAct->GetLastTouchedObject())) {
CWeaponMode wMode = proj->GetDamageInfo().GetWeaponMode();
if (!wMode.IsCharged() && !wMode.IsComboed() && wMode.GetType() == EWeaponType::Missile)
xb14_ = 0.f;
xb14_ -= lowHealth;
xb24_ = 0.33f;
x430_damageColor = zeus::CColor(0.5f, 0.f, 0.f);
if (xb10_ <= 0.f) {
xa32_29_ = false;
dontKnockback = true;
xa32_28_shotAt = true;
xb14_ = x568_data.x38_;
}
}
} else if (xa31_27_) {
x430_damageColor = zeus::CColor(0.5f, 0.f, 0.f);
if (xb18_ > 0.f) {
xb18_ -= lowHealth;
if (xb18_ <= 0.f) {
xa31_26_ = true;
dontKnockback = true;
xb18_ = 0.f;
xcbc_ = 0.6667f * x568_data.x40_;
} else if (xb18_ < xcbc_) {
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Six));
xcbc_ -= (0.333f * x568_data.x3c_);
}
}
} else {
xb1c_ -= lowHealth;
if (xb1c_ <= 0.f) {
x401_30_pendingDeath = true;
mgr.GetPlayer().SetIsOverrideRadarRadius(false);
xb1c_ = 0.f;
} else if (xb1c_ < xcbc_) {
dontKnockback = true;
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Six));
xcbc_ -= (0.333f * x568_data.x40_);
}
}
}
HealthInfo(mgr)->SetHP(xb1c_ + xb10_ + xb18_);
if (!dontKnockback) {
@ -549,29 +535,27 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
}
case EScriptObjectMessage::InvulnDamage: {
/* This code never executes, should have a `TCastTo<CCollisionActor>` followed by `GetLastTouchedObject` */
if (TCastToConstPtr<CCollisionActor> colAct = mgr.GetObjectById(uid)) {
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(colAct->GetLastTouchedObject())) {
TUniqueId tmpId = kInvalidUniqueId;
bool doDamage = false;
if (xc64_aiStage == 3) {
if (!xa32_29_ && xa31_27_) {
tmpId = x98a_breastPlateId;
doDamage = true;
} else {
tmpId = x988_headId;
doDamage = true;
}
} else if (xc64_aiStage == 2 && !xa31_31_) {
if (TCastToConstPtr<CGameProjectile> proj = mgr.GetObjectById(uid)) {
TUniqueId tmpId = kInvalidUniqueId;
bool doDamage = false;
if (xc64_aiStage == 3) {
if (!xa32_29_ && xa31_27_) {
tmpId = x98a_breastPlateId;
doDamage = true;
} else {
tmpId = x988_headId;
doDamage = true;
}
} else if (xc64_aiStage == 2 && !xa31_31_) {
tmpId = x98a_breastPlateId;
doDamage = true;
}
if (doDamage) {
CDamageInfo info = proj->GetDamageInfo();
info.SetRadius(0.f);
mgr.ApplyDamage(uid, tmpId, proj->GetOwnerId(), info,
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
}
if (doDamage) {
CDamageInfo info = proj->GetDamageInfo();
info.SetRadius(0.f);
mgr.ApplyDamage(uid, tmpId, proj->GetOwnerId(), info,
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
}
}
break;
@ -597,7 +581,7 @@ void CRidley::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateMan
default:
break;
}
}
} // namespace urde::MP1
void CRidley::Think(float dt, CStateManager& mgr) {
if (!GetActive())
@ -615,6 +599,7 @@ void CRidley::Think(float dt, CStateManager& mgr) {
sub80256624(dt, mgr);
xb2c_.Update(dt);
}
void CRidley::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
CPatterned::PreRender(mgr, frustum);
xb2c_.PreRender(mgr, *GetModelData()->GetAnimationData(), x34_transform, GetModelData()->GetScale(),
@ -656,7 +641,7 @@ void CRidley::Render(CStateManager& mgr) {
if (xb24_ > 0.f) {
multiplyColor = zeus::CColor::lerp(zeus::skWhite, x430_damageColor, xb24_ / 0.33f);
}
g_Renderer->SetWorldLightMultiplyColor(multiplyColor);
g_Renderer->SetGXRegister1Color(multiplyColor);
const zeus::CTransform xf = GetLctrTransform(xa30_breastPlateSegId);
@ -685,6 +670,7 @@ void CRidley::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) {
g_Renderer->AddParticleGen(*xce0_);
}
}
void CRidley::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) {
switch (type) {
case EUserEventType::Projectile: {
@ -717,7 +703,7 @@ void CRidley::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUs
break;
}
if (!mgr.CanCreateProjectile(GetUniqueId(), EWeaponType::AI, 6))
if (!mgr.CanCreateProjectile(GetUniqueId(), EWeaponType::AI, 8))
break;
zeus::CVector3f vec =
@ -783,7 +769,7 @@ void CRidley::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUs
}
xbfc_ = xbf0_;
xbe4_ = xa84_.origin - xabc_ * xbf0_;
xbe4_ *= zeus::CVector3f((mgr.GetPlayer().GetTranslation() - xa84_.origin).dot(xa84_.basis[1]));
xbe4_ += (mgr.GetPlayer().GetTranslation() - xa84_.origin).dot(xa84_.frontVector()) * xa84_.frontVector();
break;
}
case EUserEventType::EndAction: {
@ -1018,28 +1004,26 @@ void CRidley::Patrol(CStateManager& mgr, EStateMsg msg, float arg) {
xa32_27_ = false;
xa33_26_ = true;
}
void CRidley::Dead(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg != EStateMsg::Activate)
return;
mgr.SetBossParams(kInvalidUniqueId, 0.f, 0);
}
void CRidley::Generate(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg != EStateMsg::Activate)
return;
xa34_26_ = false;
zeus::CVector3f vec;
vec.x() = 0.f;
vec.y() = xabc_;
vec.z() = xac0_ - xadc_;
SetTranslation(xa84_ * vec);
SetTranslation(xa84_ * zeus::CVector3f{0.f, xabc_, xac0_ - xadc_});
x450_bodyController->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::NextState));
}
void CRidley::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
xbe4_ = (GetTranslation() + zeus::skUp) - (8.f * GetTransform().basis[0]);
xbfc_ = xbf0_ = GetTransform().basis[0];
xbe4_ = (GetTranslation() + zeus::skUp) - (8.f * GetTransform().rightVector());
xbfc_ = xbf0_ = GetTransform().rightVector();
xc08_ = xc0c_ = 0.f;
xc10_ = 240.f;
x32c_animState = EAnimState::Ready;
@ -1115,7 +1099,7 @@ void CRidley::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) {
xbe4_ += (90.f * arg) * xbf0_;
}
if (xa32_24_ && xcac_ != 0) {
if (xa32_24_ && xcac_) {
CSfxManager::UpdateEmitter(xca8_, GetTranslation(), {}, 127);
}
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Step)
@ -1125,17 +1109,21 @@ void CRidley::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) {
zeus::CVector3f local_54 = xbc4_ - GetTranslation();
float mag = local_54.magnitude();
if (mag <= 2.f || local_54.dot(xbc4_ - x2ec_reflectedDestPos) <= 0.f) {
pas::EStepDirection dir = pas::EStepDirection::Right;
if (xa32_31_)
auto dir = pas::EStepDirection::Right;
if (xa32_31_) {
dir = pas::EStepDirection::Left;
if (xcc0_ == 3)
dir = pas::EStepDirection::Up;
else if (xcc0_ == 2)
dir = pas::EStepDirection::Forward;
}
pas::EStepType type = pas::EStepType::Normal;
if (xa33_24_)
if (xcc0_ == 3) {
dir = pas::EStepDirection::Up;
} else if (xcc0_ == 2) {
dir = pas::EStepDirection::Forward;
}
auto type = pas::EStepType::Normal;
if (xa33_24_) {
type = pas::EStepType::BreakDodge;
}
x450_bodyController->GetCommandMgr().DeliverCmd(CBCStepCmd(dir, type));
xa31_30_ = true;
} else {
@ -1150,7 +1138,7 @@ void CRidley::LoopedAttack(CStateManager& mgr, EStateMsg msg, float arg) {
} else if (msg == EStateMsg::Deactivate) {
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
if (xa32_25_) {
ResetPlasmaProjectile(mgr, 1);
ResetPlasmaProjectile(mgr, true);
}
if (xa32_24_) {
@ -1209,7 +1197,7 @@ void CRidley::JumpBack(CStateManager& mgr, EStateMsg msg, float arg) {
xc78_ = 0.f;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 4);
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerateNoXf, 4);
if (x32c_animState == EAnimState::Repeat) {
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Relaxed);
@ -1245,9 +1233,11 @@ void CRidley::DoubleSnap(CStateManager& mgr, EStateMsg msg, float arg) {
} else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady;
x402_28_isMakingBigStrike = false;
x504_damageDur = 0.f;
xc8c_ = GetContactDamage();
}
}
void CRidley::CoverAttack(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
@ -1280,6 +1270,7 @@ void CRidley::Crouch(urde::CStateManager& mgr, urde::EStateMsg msg, float arg) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd(zeus::skZero3f, faceDir, 1.f));
}
}
void CRidley::FadeOut(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
@ -1291,12 +1282,13 @@ void CRidley::FadeOut(CStateManager& mgr, EStateMsg msg, float arg) {
xb68_.SetDamage(x568_data.x3fc_);
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::KnockBack, &CPatterned::TryKnockBack, 5);
TryCommand(mgr, pas::EAnimationState::KnockBack, &CPatterned::TryKnockBack_Front, 5);
} else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady;
xcbc_ = 0.6667f * x568_data.x3c_;
}
}
void CRidley::Taunt(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
@ -1307,6 +1299,7 @@ void CRidley::Taunt(CStateManager& mgr, EStateMsg msg, float arg) {
x32c_animState = EAnimState::NotReady;
}
}
void CRidley::Flee(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
zeus::CVector3f destPos =
@ -1318,6 +1311,7 @@ void CRidley::Flee(CStateManager& mgr, EStateMsg msg, float arg) {
x450_bodyController->FaceDirection((x2e0_destPos - GetTranslation()).normalized(), arg);
}
}
void CRidley::Lurk(urde::CStateManager& mgr, urde::EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
if (!xa33_25_) {
@ -1350,6 +1344,7 @@ void CRidley::Lurk(urde::CStateManager& mgr, urde::EStateMsg msg, float arg) {
FacePlayer(10.f * arg, mgr);
}
}
void CRidley::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
@ -1364,24 +1359,26 @@ void CRidley::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float arg) {
xa33_31_ = false;
}
}
void CRidley::Flinch(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
sub80257744(mgr);
x32c_animState = EAnimState::Ready;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::KnockBack, &CPatterned::TryKnockBack, 3);
TryCommand(mgr, pas::EAnimationState::KnockBack, &CPatterned::TryKnockBack_Front, 3);
} else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady;
sub80257650(mgr);
xa32_28_shotAt = false;
}
}
void CRidley::Hurled(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg != EStateMsg::Activate)
return;
sub80257650(mgr);
x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockBackCmd(GetTransform().basis[1], pas::ESeverity::Four));
x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockBackCmd(GetTransform().frontVector(), pas::ESeverity::Four));
}
void CRidley::TelegraphAttack(CStateManager& mgr, EStateMsg msg, float arg) {
@ -1399,17 +1396,20 @@ void CRidley::TelegraphAttack(CStateManager& mgr, EStateMsg msg, float arg) {
xa32_25_ = false;
}
}
void CRidley::Jump(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
xc88_ = (mgr.GetPlayer().GetTranslation() - GetTranslation()).magnitude() <= xae4_ ? 4 : 5;
x402_28_isMakingBigStrike = x568_data.x3ac_ > 0.f;
x504_damageDur = x568_data.x3ac_;
xc8c_ = x568_data.x390_;
sub80256580();
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, xc88_);
if (x330_stateMachineState.GetTime() < 1.75f)
if (x330_stateMachineState.GetTime() < 1.75f) {
FacePlayer(arg, mgr);
}
} else if (msg == EStateMsg::Deactivate) {
AddMaterial(EMaterialTypes::Orbit, EMaterialTypes::Target, mgr);
x402_28_isMakingBigStrike = false;
@ -1419,24 +1419,27 @@ void CRidley::Jump(CStateManager& mgr, EStateMsg msg, float arg) {
xa34_25_ = false;
}
}
void CRidley::Explode(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
xa32_27_ = false;
x32c_animState = EAnimState::Ready;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::KnockBack, &CPatterned::TryKnockBack, 2);
TryCommand(mgr, pas::EAnimationState::KnockBack, &CPatterned::TryKnockBack_Front, 2);
} else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady;
}
}
void CRidley::Dodge(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
const zeus::CVector3f vec = zeus::CVector3f{GetTranslation().toVec2f() - xa84_.origin.toVec2f()}.normalized();
float dist = zeus::clamp(0.f, 2.f * vec.dot(xa84_.rightVector()) + 1.f, 1.f);
xc84_ = 2;
float dist = zeus::clamp(
0.f, zeus::CVector3f(GetTranslation().toVec2f() - xa84_.origin.toVec2f()).normalized().dot(xa84_.basis[0]),
1.f);
if (dist < mgr.GetActiveRandom()->Float())
if (dist < mgr.GetActiveRandom()->Float()) {
xc84_ = 3;
}
x32c_animState = EAnimState::Ready;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryDodge, xc84_);
@ -1445,31 +1448,34 @@ void CRidley::Dodge(CStateManager& mgr, EStateMsg msg, float arg) {
zeus::CVector3f someVec(((xa84_.origin.x() + xabc_) * vec.x()) - GetTranslation().x(),
((xa84_.origin.y() + xabc_) * vec.y()) - GetTranslation().y(),
((xa84_.origin.z() + xac0_) - GetTranslation().z()));
if (someVec.magnitude() > 1.f)
if (someVec.magnitude() > 1.f) {
someVec.normalize();
}
sub80255fe8(10.f, arg, someVec);
} else {
x450_bodyController->FaceDirection((xa84_.origin - GetTranslation()).normalized(), arg);
}
x450_bodyController->FaceDirection((xa84_.origin - GetTranslation()).normalized(), arg);
} else if (msg == EStateMsg::Deactivate) {
x32c_animState = EAnimState::NotReady;
}
}
void CRidley::Retreat(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
x32c_animState = EAnimState::Ready;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryDodge, 5);
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryDodge, 5); // Down
} else {
x32c_animState = EAnimState::NotReady;
}
}
void CRidley::Approach(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
zeus::CVector3f direction = (GetTranslation() - xa84_.origin).normalized();
zeus::CVector3f destPos(xa84_.origin.x() + xab4_ * direction.x(), xa84_.origin.y() + xab4_ * direction.y(),
(xae8_ + xa84_.origin.z()) - 1.f);
zeus::CVector3f destPos = xa84_.origin.toVec2f() + xab4_ * direction.toVec2f();
destPos.z() = (xae8_ + xa84_.origin.z()) - 1.f;
SetDestPos(destPos);
xa33_26_ = false;
if (xc64_aiStage == 3 && !xa34_24_) {
@ -1509,6 +1515,7 @@ void CRidley::SpecialAttack(CStateManager& mgr, EStateMsg msg, float arg) {
x32c_animState = EAnimState::NotReady;
}
}
void CRidley::Land(CStateManager& mgr, EStateMsg msg, float arg) {
if (msg == EStateMsg::Activate) {
zeus::CVector3f diff = zeus::CVector3f(mgr.GetPlayer().GetTranslation().x() - xa84_.origin.x(),
@ -1528,7 +1535,7 @@ void CRidley::Land(CStateManager& mgr, EStateMsg msg, float arg) {
x402_28_isMakingBigStrike = x568_data.x38c_ > 0.f;
x504_damageDur = x568_data.x38c_;
} else if (msg == EStateMsg::Update) {
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, 8);
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack_TargetPos, 8);
if (x32c_animState == EAnimState::Repeat) {
x450_bodyController->SetLocomotionType(pas::ELocomotionType::Combat);
@ -1549,6 +1556,7 @@ void CRidley::Land(CStateManager& mgr, EStateMsg msg, float arg) {
}
}
bool CRidley::Attacked(CStateManager& mgr, float arg) { return xa31_24_ && xa31_26_; }
bool CRidley::TooClose(CStateManager& mgr, float arg) {
if (xb0c_ == 4)
return true;
@ -1564,24 +1572,32 @@ bool CRidley::TooClose(CStateManager& mgr, float arg) {
return false;
}
bool CRidley::InRange(CStateManager& mgr, float arg) {
float mag = (GetTranslation() - x2e0_destPos).magnitude();
return mag < 2.f;
}
bool CRidley::InRange(CStateManager& mgr, float arg) { return (GetTranslation() - x2e0_destPos).magnitude() < 2.f; }
bool CRidley::ShouldAttack(CStateManager& mgr, float arg) {
return (xc64_aiStage == 3 && xb0c_ == 2) || (xc64_aiStage == 2 && xb04_ == 0);
}
bool CRidley::ShouldDoubleSnap(CStateManager& mgr, float arg) { return xa33_30_; }
bool CRidley::ShouldTurn(CStateManager& mgr, float arg) { return xb04_ == 5; }
bool CRidley::HitSomething(CStateManager& mgr, float arg) { return xa32_27_ || xc64_aiStage == 3; }
bool CRidley::AttackOver(CStateManager& mgr, float arg) { return xcc4_ == 0; }
bool CRidley::ShouldTaunt(CStateManager& mgr, float arg) {
return (xc64_aiStage == 3 && xb0c_ == 1) || (xc64_aiStage == 2 && xb04_ == 4);
}
bool CRidley::ShouldFire(CStateManager& mgr, float arg) { return xc64_aiStage == 2 && xb04_ == 2; }
bool CRidley::ShouldDodge(CStateManager& mgr, float arg) { return xb04_ == 3; }
bool CRidley::ShouldRetreat(CStateManager& mgr, float arg) { return xa34_26_; }
bool CRidley::ShouldCrouch(CStateManager& mgr, float arg) { return xb04_ == 1; }
bool CRidley::ShouldMove(urde::CStateManager& mgr, float arg) {
if (xb0c_ == 5) {
xa34_25_ = true;
@ -1599,12 +1615,16 @@ bool CRidley::ShouldMove(urde::CStateManager& mgr, float arg) {
return false;
}
bool CRidley::ShotAt(CStateManager& mgr, float arg) { return xa32_28_shotAt; }
bool CRidley::SetAIStage(CStateManager& mgr, float arg) {
xc64_aiStage = arg;
return true;
}
bool CRidley::AIStage(CStateManager& mgr, float arg) { return xc64_aiStage >= arg; }
bool CRidley::ShouldStrafe(CStateManager& mgr, float arg) { return xa33_29_doStrafe; }
bool CRidley::IsDizzy(CStateManager& mgr, float arg) {
if (xb0c_ == 3)
return true;
@ -1619,13 +1639,15 @@ bool CRidley::IsDizzy(CStateManager& mgr, float arg) {
return false;
}
void CRidley::sub80255fe8(float f1, float f2, const zeus::CVector3f& vec) {
xaf8_ = (0.2f * (f1 * f1)) * vec;
xaf8_ = (f1 * (0.2f * f1)) * vec;
xaec_ += f2 * xaf8_;
if (xaec_.magnitude() > f1) {
xaec_ = f1 * xaec_.normalized();
}
}
void CRidley::sub80255e5c(CStateManager& mgr) {
zeus::CVector3f posDiff = mgr.GetPlayer().GetTranslation() - GetTranslation();
if (posDiff.magnitude() < 8.f) {
@ -1634,6 +1656,7 @@ void CRidley::sub80255e5c(CStateManager& mgr) {
mgr.GetPlayer().ApplyImpulseWR(impulse, {});
}
}
void CRidley::FacePlayer(float arg, CStateManager& mgr) {
x450_bodyController->FaceDirection((mgr.GetPlayer().GetTranslation() - GetTranslation()).normalized(), arg);
}

View File

@ -105,11 +105,11 @@ class CRidley : public CPatterned {
float xab4_ = 20.f;
float xab8_ = 12.f;
float xabc_ = 40.f;
float xac0_ = 10;
float xac0_ = 10.f;
zeus::CAABox xac4_ = zeus::skInvertedBox;
float xadc_;
float xae0_;
u32 xae4_;
float xae4_;
float xae8_;
zeus::CVector3f xaec_;
zeus::CVector3f xaf8_;
@ -195,7 +195,8 @@ class CRidley : public CPatterned {
void sub80253710(CStateManager& mgr);
bool sub80253960() {
return (GetTranslation() + (1.75f * GetTransform().basis[1]) - xa84_.origin).magnitude() < 1.75f * (xab4_ + xabc_);
const float mag = ((GetTranslation() + ((0.5f * xae4_) * GetTransform().frontVector())) - xa84_.origin).magnitude();
return mag < 0.5f * (xab4_ + xabc_);
}
public:

View File

@ -196,7 +196,7 @@ void CSeedling::Generate(CStateManager& mgr, EStateMsg msg, float) {
if (msg == EStateMsg::Activate)
x32c_animState = EAnimState::Ready;
else if (msg == EStateMsg::Update)
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerateNoXf, 0);
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 0);
}
bool CSeedling::ShouldAttack(CStateManager& mgr, float) {

View File

@ -881,15 +881,20 @@ void CPatterned::TryLoopReaction(CStateManager& mgr, int arg) {
void CPatterned::TryProjectileAttack(CStateManager&, int arg) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCProjectileAttackCmd(pas::ESeverity(arg), x2e0_destPos, false));
}
void CPatterned::TryMeleeAttack_TargetPos(CStateManager& mgr, int arg) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(pas::ESeverity(arg), x2e0_destPos));
}
void CPatterned::TryMeleeAttack(CStateManager& mgr, int arg) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCMeleeAttackCmd(pas::ESeverity(arg)));
}
void CPatterned::TryGenerate(CStateManager& mgr, int arg) {
void CPatterned::TryGenerateNoXf(CStateManager& mgr, int arg) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType(arg), x2e0_destPos, false));
}
void CPatterned::TryGenerateNoXf(CStateManager& mgr, int arg) {
void CPatterned::TryGenerate(CStateManager& mgr, int arg) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType::Zero, x2e0_destPos, true));
}
@ -941,6 +946,10 @@ void CPatterned::TryKnockBack(CStateManager& mgr, int arg) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockBackCmd(GetTranslation(), pas::ESeverity(arg)));
}
void CPatterned::TryKnockBack_Front(CStateManager& mgr, int arg) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCKnockBackCmd(GetTransform().frontVector(), pas::ESeverity(arg)));
}
void CPatterned::TryGenerateDeactivate(urde::CStateManager& mgr, int arg) {
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(pas::EGenerateType(arg), zeus::skZero3f));
}

View File

@ -320,9 +320,10 @@ public:
void TryCommand(CStateManager& mgr, pas::EAnimationState state, CPatternedTryFunc func, int arg);
void TryLoopReaction(CStateManager& mgr, int arg);
void TryProjectileAttack(CStateManager& mgr, int arg);
void TryMeleeAttack_TargetPos(CStateManager& mgr, int arg);
void TryMeleeAttack(CStateManager& mgr, int arg);
void TryGenerate(CStateManager& mgr, int arg);
void TryGenerateNoXf(CStateManager& mgr, int arg);
void TryGenerate(CStateManager& mgr, int arg);
void TryJump(CStateManager& mgr, int arg);
void TryTurn(CStateManager& mgr, int arg);
void TryGetUp(CStateManager& mgr, int arg);
@ -334,6 +335,7 @@ public:
void TryCover(CStateManager& mgr, int arg);
void TryWallHang(CStateManager& mgr, int arg);
void TryKnockBack(CStateManager& mgr, int arg);
void TryKnockBack_Front(CStateManager& mgr, int arg);
void TryGenerateDeactivate(CStateManager& mgr, int arg);
void TryStep(CStateManager& mgr, int arg);