mirror of https://github.com/AxioDL/metaforce.git
CMagdolite: Minor cleanup
This commit is contained in:
parent
0c96380897
commit
5f66ab2219
|
@ -64,10 +64,11 @@ CMagdolite::CMagdolite(TUniqueId uid, std::string_view name, const CEntityInfo&
|
||||||
, x74c_(f9) {
|
, x74c_(f9) {
|
||||||
x460_knockBackController.SetAutoResetImpulse(false);
|
x460_knockBackController.SetAutoResetImpulse(false);
|
||||||
x460_knockBackController.SetEnableBurn(false);
|
x460_knockBackController.SetEnableBurn(false);
|
||||||
|
// redundant
|
||||||
|
// x690_headlessModel->SetLayoutInfo(GetModelData()->GetAnimationData()->GetModelData()->GetLayoutInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMagdolite::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
void CMagdolite::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
||||||
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case EScriptObjectMessage::Touched:
|
case EScriptObjectMessage::Touched:
|
||||||
ApplyContactDamage(uid, mgr);
|
ApplyContactDamage(uid, mgr);
|
||||||
|
@ -92,8 +93,9 @@ void CMagdolite::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CState
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case EScriptObjectMessage::SuspendedMove: {
|
case EScriptObjectMessage::SuspendedMove: {
|
||||||
if (x580_collisionManager)
|
if (x580_collisionManager) {
|
||||||
x580_collisionManager->SetMovable(mgr, false);
|
x580_collisionManager->SetMovable(mgr, false);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EScriptObjectMessage::Registered: {
|
case EScriptObjectMessage::Registered: {
|
||||||
|
@ -158,7 +160,8 @@ void CMagdolite::SetupCollisionActors(CStateManager& mgr) {
|
||||||
animData->GetLocatorSegId(info.from), animData->GetLocatorSegId(info.to), info.bounds,
|
animData->GetLocatorSegId(info.from), animData->GetLocatorSegId(info.to), info.bounds,
|
||||||
CJointCollisionDescription::EOrientationType::One, info.to, 200.f));
|
CJointCollisionDescription::EOrientationType::One, info.to, 200.f));
|
||||||
}
|
}
|
||||||
x580_collisionManager.reset(new CCollisionActorManager(mgr, GetUniqueId(), GetAreaIdAlways(), joints, GetActive()));
|
x580_collisionManager =
|
||||||
|
std::make_unique<CCollisionActorManager>(mgr, GetUniqueId(), GetAreaIdAlways(), joints, GetActive());
|
||||||
|
|
||||||
for (int i = 0; i < x580_collisionManager->GetNumCollisionActors(); ++i) {
|
for (int i = 0; i < x580_collisionManager->GetNumCollisionActors(); ++i) {
|
||||||
const auto& desc = x580_collisionManager->GetCollisionDescFromIndex(i);
|
const auto& desc = x580_collisionManager->GetCollisionDescFromIndex(i);
|
||||||
|
@ -179,8 +182,9 @@ void CMagdolite::SetupCollisionActors(CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMagdolite::CreateFlameThrower(CStateManager& mgr) {
|
void CMagdolite::CreateFlameThrower(CStateManager& mgr) {
|
||||||
if (x6c8_flameThrowerId != kInvalidUniqueId)
|
if (x6c8_flameThrowerId != kInvalidUniqueId) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x6c8_flameThrowerId = mgr.AllocateUniqueId();
|
x6c8_flameThrowerId = mgr.AllocateUniqueId();
|
||||||
mgr.AddObject(new CFlameThrower(x6cc_, "Magdolite_Flame"sv, EWeaponType::Plasma, x6a8_, {},
|
mgr.AddObject(new CFlameThrower(x6cc_, "Magdolite_Flame"sv, EWeaponType::Plasma, x6a8_, {},
|
||||||
|
@ -190,11 +194,12 @@ void CMagdolite::CreateFlameThrower(CStateManager& mgr) {
|
||||||
|
|
||||||
void CMagdolite::LaunchFlameThrower(CStateManager& mgr, bool fire) {
|
void CMagdolite::LaunchFlameThrower(CStateManager& mgr, bool fire) {
|
||||||
if ((!fire || x754_30_inProjectileAttack) && IsAlive()) {
|
if ((!fire || x754_30_inProjectileAttack) && IsAlive()) {
|
||||||
if (CFlameThrower* fl = static_cast<CFlameThrower*>(mgr.ObjectById(x6c8_flameThrowerId))) {
|
if (auto* fl = static_cast<CFlameThrower*>(mgr.ObjectById(x6c8_flameThrowerId))) {
|
||||||
if (!fire)
|
if (!fire) {
|
||||||
fl->Reset(mgr, false);
|
fl->Reset(mgr, false);
|
||||||
else
|
} else {
|
||||||
fl->Fire(GetTransform(), mgr, false);
|
fl->Fire(GetTransform(), mgr, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
x754_27_flameThrowerActive = fire;
|
x754_27_flameThrowerActive = fire;
|
||||||
}
|
}
|
||||||
|
@ -202,8 +207,9 @@ void CMagdolite::LaunchFlameThrower(CStateManager& mgr, bool fire) {
|
||||||
|
|
||||||
void CMagdolite::Think(float dt, CStateManager& mgr) {
|
void CMagdolite::Think(float dt, CStateManager& mgr) {
|
||||||
CPatterned::Think(dt, mgr);
|
CPatterned::Think(dt, mgr);
|
||||||
if (!GetActive())
|
if (!GetActive()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x758_ += dt;
|
x758_ += dt;
|
||||||
if (GetBodyController()->GetPercentageFrozen() > 0.f && x754_27_flameThrowerActive) {
|
if (GetBodyController()->GetPercentageFrozen() > 0.f && x754_27_flameThrowerActive) {
|
||||||
|
@ -211,7 +217,7 @@ void CMagdolite::Think(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsAlive()) {
|
if (!IsAlive()) {
|
||||||
if (CFlameThrower* fl = static_cast<CFlameThrower*>(mgr.ObjectById(x6c8_flameThrowerId))) {
|
if (auto* fl = static_cast<CFlameThrower*>(mgr.ObjectById(x6c8_flameThrowerId))) {
|
||||||
fl->SetTransform(GetLctrTransform("LCTR_MAGMOUTH"sv), dt);
|
fl->SetTransform(GetLctrTransform("LCTR_MAGMOUTH"sv), dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +243,7 @@ void CMagdolite::Think(float dt, CStateManager& mgr) {
|
||||||
x584_boneTracker.PreRender(mgr, *GetModelData()->GetAnimationData(), GetTransform(), GetModelData()->GetScale(),
|
x584_boneTracker.PreRender(mgr, *GetModelData()->GetAnimationData(), GetTransform(), GetModelData()->GetScale(),
|
||||||
*GetBodyController());
|
*GetBodyController());
|
||||||
|
|
||||||
if (CFlameThrower* fl = static_cast<CFlameThrower*>(mgr.ObjectById(x6c8_flameThrowerId))) {
|
if (auto* fl = static_cast<CFlameThrower*>(mgr.ObjectById(x6c8_flameThrowerId))) {
|
||||||
fl->SetTransform(GetLctrTransform("LCTR_MAGMOUTH"sv), dt);
|
fl->SetTransform(GetLctrTransform("LCTR_MAGMOUTH"sv), dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,10 +254,11 @@ void CMagdolite::Think(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x750_aiStage == 2) {
|
if (x750_aiStage == 2) {
|
||||||
if (x738_ * 0.5f <= x734_)
|
if (x738_ * 0.5f <= x734_) {
|
||||||
x740_ -= x73c_ * dt;
|
x740_ -= x73c_ * dt;
|
||||||
else
|
} else {
|
||||||
x740_ += x73c_ * dt;
|
x740_ += x73c_ * dt;
|
||||||
|
}
|
||||||
x734_ += x740_ * dt;
|
x734_ += x740_ * dt;
|
||||||
SetTranslation(GetTranslation() - zeus::CVector3f{0.f, 0.f, x740_ * dt});
|
SetTranslation(GetTranslation() - zeus::CVector3f{0.f, 0.f, x740_ * dt});
|
||||||
if (GetTranslation().z() < x728_cachedTarget.z()) {
|
if (GetTranslation().z() < x728_cachedTarget.z()) {
|
||||||
|
@ -272,8 +279,8 @@ void CMagdolite::Think(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void CMagdolite::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) {
|
|
||||||
|
|
||||||
|
void CMagdolite::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type, float dt) {
|
||||||
if (type == EUserEventType::DamageOff) {
|
if (type == EUserEventType::DamageOff) {
|
||||||
LaunchFlameThrower(mgr, false);
|
LaunchFlameThrower(mgr, false);
|
||||||
} else if (type == EUserEventType::DamageOn) {
|
} else if (type == EUserEventType::DamageOn) {
|
||||||
|
@ -285,9 +292,11 @@ void CMagdolite::DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node,
|
||||||
}
|
}
|
||||||
CPatterned::DoUserAnimEvent(mgr, node, type, dt);
|
CPatterned::DoUserAnimEvent(mgr, node, type, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMagdolite::Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) {
|
void CMagdolite::Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state) {
|
||||||
if (!IsAlive())
|
if (!IsAlive()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
zeus::CTransform tmpXf = GetTransform();
|
zeus::CTransform tmpXf = GetTransform();
|
||||||
SetTransform(GetLctrTransform("head"sv));
|
SetTransform(GetLctrTransform("head"sv));
|
||||||
SendScriptMsgs(EScriptObjectState::MassiveDeath, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::MassiveDeath, mgr, EScriptObjectMessage::None);
|
||||||
|
@ -296,11 +305,11 @@ void CMagdolite::Death(CStateManager& mgr, const zeus::CVector3f& direction, ESc
|
||||||
GetModelData()->GetAnimationData()->SubstituteModelData(x690_headlessModel);
|
GetModelData()->GetAnimationData()->SubstituteModelData(x690_headlessModel);
|
||||||
x460_knockBackController.SetEnableFreeze(false);
|
x460_knockBackController.SetEnableFreeze(false);
|
||||||
GetBodyController()->UnFreeze();
|
GetBodyController()->UnFreeze();
|
||||||
if (!x754_26_lostMyHead)
|
if (!x754_26_lostMyHead) {
|
||||||
x460_knockBackController.SetSeverity(pas::ESeverity::Two);
|
x460_knockBackController.SetSeverity(pas::ESeverity::Two);
|
||||||
else
|
} else {
|
||||||
GetModelData()->GetAnimationData()->SubstituteModelData(x690_headlessModel);
|
GetModelData()->GetAnimationData()->SubstituteModelData(x690_headlessModel);
|
||||||
|
}
|
||||||
CPatterned::Death(mgr, direction, state);
|
CPatterned::Death(mgr, direction, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,18 +337,21 @@ void CMagdolite::SelectTarget(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
UpdateOrientation(mgr);
|
UpdateOrientation(mgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMagdolite::Generate(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CMagdolite::Generate(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
x32c_animState = EAnimState::Ready;
|
x32c_animState = EAnimState::Ready;
|
||||||
x754_24_retreat = false;
|
x754_24_retreat = false;
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerateNoXf, 0);
|
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerateNoXf, 0);
|
||||||
if (x32c_animState == EAnimState::Repeat)
|
if (x32c_animState == EAnimState::Repeat) {
|
||||||
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Relaxed);
|
||||||
|
}
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
x32c_animState = EAnimState::NotReady;
|
x32c_animState = EAnimState::NotReady;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMagdolite::Deactivate(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CMagdolite::Deactivate(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
x32c_animState = EAnimState::Ready;
|
x32c_animState = EAnimState::Ready;
|
||||||
|
@ -347,12 +359,14 @@ void CMagdolite::Deactivate(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
x584_boneTracker.SetActive(false);
|
x584_boneTracker.SetActive(false);
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryStep, int(pas::EStepDirection::Down));
|
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryStep, int(pas::EStepDirection::Down));
|
||||||
if (x32c_animState == EAnimState::Repeat)
|
if (x32c_animState == EAnimState::Repeat) {
|
||||||
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Internal7);
|
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Internal7);
|
||||||
|
}
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
x32c_animState = EAnimState::NotReady;
|
x32c_animState = EAnimState::NotReady;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMagdolite::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CMagdolite::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
x32c_animState = EAnimState::Ready;
|
x32c_animState = EAnimState::Ready;
|
||||||
|
@ -365,25 +379,28 @@ void CMagdolite::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
float fVar2 = 0.f;
|
float fVar2 = 0.f;
|
||||||
if (fVar1 >= 0.f) {
|
if (fVar1 >= 0.f) {
|
||||||
fVar2 = fVar1;
|
fVar2 = fVar1;
|
||||||
if (x748_ < fVar1)
|
if (x748_ < fVar1) {
|
||||||
fVar2 = x748_;
|
fVar2 = x748_;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
x728_cachedTarget = x71c_attackTarget - zeus::CVector3f(0.f, 0.f, fVar1 - fVar2);
|
x728_cachedTarget = x71c_attackTarget - zeus::CVector3f(0.f, 0.f, fVar1 - fVar2);
|
||||||
x740_ = 0.f;
|
x740_ = 0.f;
|
||||||
x734_ = 0.f;
|
x734_ = 0.f;
|
||||||
x738_ = fVar2;
|
x738_ = fVar2;
|
||||||
x73c_ = (2.f * x738_) / (x744_ * x744_);
|
x73c_ = (2.f * x738_) / (x744_ * x744_);
|
||||||
if (GetTranslation().z() <= x728_cachedTarget.z())
|
if (GetTranslation().z() <= x728_cachedTarget.z()) {
|
||||||
x750_aiStage = 1;
|
x750_aiStage = 1;
|
||||||
else
|
} else {
|
||||||
x750_aiStage = 2;
|
x750_aiStage = 2;
|
||||||
|
}
|
||||||
x754_30_inProjectileAttack = true;
|
x754_30_inProjectileAttack = true;
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, 1);
|
TryCommand(mgr, pas::EAnimationState::MeleeAttack, &CPatterned::TryMeleeAttack, 1);
|
||||||
zeus::CVector3f direction = (mgr.GetPlayer().GetTranslation().toVec2f() - GetTranslation().toVec2f()).normalized();
|
zeus::CVector3f direction = (mgr.GetPlayer().GetTranslation().toVec2f() - GetTranslation().toVec2f()).normalized();
|
||||||
float angle = zeus::CVector3f::getAngleDiff(GetTransform().basis[1], direction);
|
float angle = zeus::CVector3f::getAngleDiff(GetTransform().basis[1], direction);
|
||||||
if (GetTransform().basis[0].dot(direction) > 0.f)
|
if (GetTransform().basis[0].dot(direction) > 0.f) {
|
||||||
angle *= -1.f;
|
angle *= -1.f;
|
||||||
|
}
|
||||||
|
|
||||||
if ((57.29f * angle) <= x3b8_turnSpeed && (57.29f * angle) < -x3b8_turnSpeed) {
|
if ((57.29f * angle) <= x3b8_turnSpeed && (57.29f * angle) < -x3b8_turnSpeed) {
|
||||||
angle = zeus::degToRad(-x3b8_turnSpeed);
|
angle = zeus::degToRad(-x3b8_turnSpeed);
|
||||||
|
@ -404,6 +421,7 @@ void CMagdolite::Attack(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
x754_30_inProjectileAttack = false;
|
x754_30_inProjectileAttack = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMagdolite::Active(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CMagdolite::Active(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Lurk);
|
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Lurk);
|
||||||
|
@ -416,8 +434,9 @@ void CMagdolite::Active(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
zeus::CVector3f posDiff = (mgr.GetPlayer().GetTranslation().toVec2f() - GetTranslation().toVec2f());
|
zeus::CVector3f posDiff = (mgr.GetPlayer().GetTranslation().toVec2f() - GetTranslation().toVec2f());
|
||||||
if (posDiff.canBeNormalized()) {
|
if (posDiff.canBeNormalized()) {
|
||||||
posDiff.normalize();
|
posDiff.normalize();
|
||||||
if (GetTransform().basis[1].dot(posDiff) < x578_losMaxDistance)
|
if (GetTransform().basis[1].dot(posDiff) < x578_losMaxDistance) {
|
||||||
GetBodyController()->GetCommandMgr().DeliverCmd(CBCLocomotionCmd({}, posDiff, 1.f));
|
GetBodyController()->GetCommandMgr().DeliverCmd(CBCLocomotionCmd({}, posDiff, 1.f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
x330_stateMachineState.SetDelay(((x570_maxDelay - x56c_minDelay) * mgr.GetActiveRandom()->Float()) + x56c_minDelay);
|
x330_stateMachineState.SetDelay(((x570_maxDelay - x56c_minDelay) * mgr.GetActiveRandom()->Float()) + x56c_minDelay);
|
||||||
|
@ -436,6 +455,7 @@ void CMagdolite::InActive(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
xe7_27_enableRender = true;
|
xe7_27_enableRender = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMagdolite::GetUp(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CMagdolite::GetUp(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
x32c_animState = EAnimState::Ready;
|
x32c_animState = EAnimState::Ready;
|
||||||
|
@ -443,12 +463,14 @@ void CMagdolite::GetUp(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
x754_28_alert = true;
|
x754_28_alert = true;
|
||||||
AddMaterial(EMaterialTypes::Orbit, EMaterialTypes::Target, mgr);
|
AddMaterial(EMaterialTypes::Orbit, EMaterialTypes::Target, mgr);
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
if (!x754_25_up)
|
if (!x754_25_up) {
|
||||||
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryStep, int(pas::EStepDirection::Forward));
|
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryStep, int(pas::EStepDirection::Forward));
|
||||||
else
|
} else {
|
||||||
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryStep, int(pas::EStepDirection::Up));
|
TryCommand(mgr, pas::EAnimationState::Step, &CPatterned::TryStep, int(pas::EStepDirection::Up));
|
||||||
if (x32c_animState == EAnimState::Repeat)
|
}
|
||||||
|
if (x32c_animState == EAnimState::Repeat) {
|
||||||
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Lurk);
|
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Lurk);
|
||||||
|
}
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
x32c_animState = EAnimState::NotReady;
|
x32c_animState = EAnimState::NotReady;
|
||||||
x754_28_alert = false;
|
x754_28_alert = false;
|
||||||
|
@ -477,6 +499,7 @@ void CMagdolite::Lurk(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
x754_25_up = true;
|
x754_25_up = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMagdolite::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float arg) {
|
void CMagdolite::ProjectileAttack(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
if (msg == EStateMsg::Activate) {
|
if (msg == EStateMsg::Activate) {
|
||||||
x32c_animState = EAnimState::Ready;
|
x32c_animState = EAnimState::Ready;
|
||||||
|
@ -523,8 +546,9 @@ void CMagdolite::Retreat(CStateManager& mgr, EStateMsg msg, float arg) {
|
||||||
x754_28_alert = true;
|
x754_28_alert = true;
|
||||||
} else if (msg == EStateMsg::Update) {
|
} else if (msg == EStateMsg::Update) {
|
||||||
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 1);
|
TryCommand(mgr, pas::EAnimationState::Generate, &CPatterned::TryGenerate, 1);
|
||||||
if (x32c_animState == EAnimState::Repeat)
|
if (x32c_animState == EAnimState::Repeat) {
|
||||||
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Internal7);
|
GetBodyController()->SetLocomotionType(pas::ELocomotionType::Internal7);
|
||||||
|
}
|
||||||
} else if (msg == EStateMsg::Deactivate) {
|
} else if (msg == EStateMsg::Deactivate) {
|
||||||
x754_28_alert = false;
|
x754_28_alert = false;
|
||||||
x32c_animState = EAnimState::NotReady;
|
x32c_animState = EAnimState::NotReady;
|
||||||
|
@ -535,8 +559,9 @@ bool CMagdolite::InAttackPosition(CStateManager& mgr, float arg) {
|
||||||
zeus::CTransform xf = GetLctrTransform("head"sv);
|
zeus::CTransform xf = GetLctrTransform("head"sv);
|
||||||
zeus::CVector3f plAimPos = mgr.GetPlayer().GetAimPosition(mgr, 0.f);
|
zeus::CVector3f plAimPos = mgr.GetPlayer().GetAimPosition(mgr, 0.f);
|
||||||
zeus::CVector3f diff = (plAimPos - GetTranslation());
|
zeus::CVector3f diff = (plAimPos - GetTranslation());
|
||||||
if (GetTranslation().z() < plAimPos.z() && plAimPos.z() < xf.origin.z())
|
if (GetTranslation().z() < plAimPos.z() && plAimPos.z() < xf.origin.z()) {
|
||||||
diff.z() = 0.f;
|
diff.z() = 0.f;
|
||||||
|
}
|
||||||
|
|
||||||
if (std::fabs(diff.magnitude()) >= FLT_EPSILON) {
|
if (std::fabs(diff.magnitude()) >= FLT_EPSILON) {
|
||||||
return ((1.f / diff.magnitude()) * diff).dot(GetTransform().basis[1]) < x578_losMaxDistance;
|
return ((1.f / diff.magnitude()) * diff).dot(GetTransform().basis[1]) < x578_losMaxDistance;
|
||||||
|
@ -555,13 +580,15 @@ bool CMagdolite::HasAttackPattern(CStateManager& mgr, float arg) {
|
||||||
bool ret = FindSuitableTarget(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow) != kInvalidUniqueId;
|
bool ret = FindSuitableTarget(mgr, EScriptObjectState::Attack, EScriptObjectMessage::Follow) != kInvalidUniqueId;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMagdolite::LineOfSight(CStateManager& mgr, float arg) {
|
bool CMagdolite::LineOfSight(CStateManager& mgr, float arg) {
|
||||||
zeus::CTransform mouthXf = GetLctrTransform("LCTR_MAGMOUTH"sv);
|
zeus::CTransform mouthXf = GetLctrTransform("LCTR_MAGMOUTH"sv);
|
||||||
zeus::CVector3f diff = x710_attackOffset - mouthXf.origin;
|
zeus::CVector3f diff = x710_attackOffset - mouthXf.origin;
|
||||||
if (diff.canBeNormalized()) {
|
if (diff.canBeNormalized()) {
|
||||||
diff.normalize();
|
diff.normalize();
|
||||||
if (diff.dot(GetTransform().basis[1]) < x578_losMaxDistance)
|
if (diff.dot(GetTransform().basis[1]) < x578_losMaxDistance) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = mgr.RayCollideWorld(
|
bool ret = mgr.RayCollideWorld(
|
||||||
|
@ -571,15 +598,16 @@ bool CMagdolite::LineOfSight(CStateManager& mgr, float arg) {
|
||||||
this);
|
this);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
bool CMagdolite::ShouldRetreat(CStateManager& mgr, float arg) {
|
|
||||||
return x754_24_retreat;
|
bool CMagdolite::ShouldRetreat(CStateManager& mgr, float arg) { return x754_24_retreat; }
|
||||||
}
|
|
||||||
void CMagdolite::UpdateOrientation(CStateManager& mgr) {
|
void CMagdolite::UpdateOrientation(CStateManager& mgr) {
|
||||||
zeus::CVector3f plDiff = (mgr.GetPlayer().GetTranslation().toVec2f() - GetTranslation().toVec2f());
|
zeus::CVector3f plDiff = (mgr.GetPlayer().GetTranslation().toVec2f() - GetTranslation().toVec2f());
|
||||||
plDiff = plDiff.normalized();
|
plDiff = plDiff.normalized();
|
||||||
float angle = zeus::CVector3f::getAngleDiff(GetTransform().basis[1], plDiff);
|
float angle = zeus::CVector3f::getAngleDiff(GetTransform().basis[1], plDiff);
|
||||||
if (GetTransform().basis[0].dot(plDiff) > 0.f)
|
if (GetTransform().basis[0].dot(plDiff) > 0.f) {
|
||||||
angle *= -1.f;
|
angle *= -1.f;
|
||||||
|
}
|
||||||
zeus::CQuaternion q = GetTransform().basis;
|
zeus::CQuaternion q = GetTransform().basis;
|
||||||
q.rotateZ(angle);
|
q.rotateZ(angle);
|
||||||
SetTransform(q.toTransform(GetTranslation()));
|
SetTransform(q.toTransform(GetTranslation()));
|
||||||
|
@ -593,12 +621,14 @@ TUniqueId CMagdolite::FindSuitableTarget(CStateManager& mgr, EScriptObjectState
|
||||||
|
|
||||||
TUniqueId tmpId = kInvalidUniqueId;
|
TUniqueId tmpId = kInvalidUniqueId;
|
||||||
for (const auto& conn : x20_conns) {
|
for (const auto& conn : x20_conns) {
|
||||||
if (conn.x0_state != state || conn.x4_msg != msg)
|
if (conn.x0_state != state || conn.x4_msg != msg) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
TUniqueId uid = mgr.GetIdForScript(conn.x8_objId);
|
TUniqueId uid = mgr.GetIdForScript(conn.x8_objId);
|
||||||
if (const CEntity* ent = mgr.GetObjectById(uid)) {
|
if (const CEntity* ent = mgr.GetObjectById(uid)) {
|
||||||
if (!ent->GetActive())
|
if (!ent->GetActive()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (TCastToConstPtr<CScriptWaypoint> wp = ent) {
|
if (TCastToConstPtr<CScriptWaypoint> wp = ent) {
|
||||||
++wpCount;
|
++wpCount;
|
||||||
|
@ -617,17 +647,20 @@ TUniqueId CMagdolite::FindSuitableTarget(CStateManager& mgr, EScriptObjectState
|
||||||
int skipCount = mgr.GetActiveRandom()->Next();
|
int skipCount = mgr.GetActiveRandom()->Next();
|
||||||
skipCount = skipCount - (skipCount / wpCount) * wpCount;
|
skipCount = skipCount - (skipCount / wpCount) * wpCount;
|
||||||
for (const auto& conn : x20_conns) {
|
for (const auto& conn : x20_conns) {
|
||||||
if (conn.x0_state != state || conn.x4_msg != msg)
|
if (conn.x0_state != state || conn.x4_msg != msg) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
TUniqueId uid = mgr.GetIdForScript(conn.x8_objId);
|
TUniqueId uid = mgr.GetIdForScript(conn.x8_objId);
|
||||||
if (const CEntity* ent = mgr.GetObjectById(uid)) {
|
if (const CEntity* ent = mgr.GetObjectById(uid)) {
|
||||||
if (!ent->GetActive())
|
if (!ent->GetActive()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (TCastToConstPtr<CScriptWaypoint>(ent)) {
|
if (TCastToConstPtr<CScriptWaypoint>(ent)) {
|
||||||
tmpId = uid;
|
tmpId = uid;
|
||||||
if (skipCount == 0)
|
if (skipCount == 0) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
--skipCount;
|
--skipCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,9 @@ namespace urde {
|
||||||
class CCollisionActorManager;
|
class CCollisionActorManager;
|
||||||
class CSkinnedModel;
|
class CSkinnedModel;
|
||||||
class CWeaponDescription;
|
class CWeaponDescription;
|
||||||
|
|
||||||
namespace MP1 {
|
namespace MP1 {
|
||||||
class CMagdolite : public CPatterned {
|
class CMagdolite : public CPatterned {
|
||||||
public:
|
|
||||||
class CMagdoliteData {
|
|
||||||
u32 x0_propertyCount;
|
|
||||||
u32 x4_;
|
|
||||||
CAssetId x8_;
|
|
||||||
u32 xc_;
|
|
||||||
float x10_;
|
|
||||||
float x18_;
|
|
||||||
float x1c_;
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit CMagdoliteData(CInputStream&);
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float x568_initialDelay;
|
float x568_initialDelay;
|
||||||
float x56c_minDelay;
|
float x56c_minDelay;
|
||||||
|
@ -35,15 +22,15 @@ private:
|
||||||
CBoneTracking x584_boneTracker;
|
CBoneTracking x584_boneTracker;
|
||||||
CDamageVulnerability x5bc_;
|
CDamageVulnerability x5bc_;
|
||||||
CDamageVulnerability x624_;
|
CDamageVulnerability x624_;
|
||||||
/* x68c_ */
|
// CRefData* x68c_;
|
||||||
TLockedToken<CSkinnedModel> x690_headlessModel;
|
TLockedToken<CSkinnedModel> x690_headlessModel;
|
||||||
rstl::reserved_vector<TUniqueId, 5> x69c_;
|
rstl::reserved_vector<TUniqueId, 4> x69c_;
|
||||||
CFlameInfo x6a8_;
|
CFlameInfo x6a8_;
|
||||||
TUniqueId x6c8_flameThrowerId = kInvalidUniqueId;
|
TUniqueId x6c8_flameThrowerId = kInvalidUniqueId;
|
||||||
TLockedToken<CWeaponDescription> x6cc_;
|
TLockedToken<CWeaponDescription> x6cc_; // was TToken<CWeaponDescription>
|
||||||
CDamageInfo x6d4_;
|
CDamageInfo x6d4_;
|
||||||
CDamageInfo x6f0_;
|
CDamageInfo x6f0_;
|
||||||
float x70c_curHealth;
|
float x70c_curHealth = 0.f; // not init in ctr
|
||||||
zeus::CVector3f x710_attackOffset;
|
zeus::CVector3f x710_attackOffset;
|
||||||
zeus::CVector3f x71c_attackTarget;
|
zeus::CVector3f x71c_attackTarget;
|
||||||
zeus::CVector3f x728_cachedTarget;
|
zeus::CVector3f x728_cachedTarget;
|
||||||
|
@ -70,20 +57,22 @@ private:
|
||||||
void LaunchFlameThrower(CStateManager& mgr, bool fire);
|
void LaunchFlameThrower(CStateManager& mgr, bool fire);
|
||||||
void UpdateOrientation(CStateManager& mgr);
|
void UpdateOrientation(CStateManager& mgr);
|
||||||
TUniqueId FindSuitableTarget(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg);
|
TUniqueId FindSuitableTarget(CStateManager& mgr, EScriptObjectState state, EScriptObjectMessage msg);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DEFINE_PATTERNED(Magdolite)
|
DEFINE_PATTERNED(Magdolite)
|
||||||
CMagdolite(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
|
|
||||||
const CPatternedInfo&, const CActorParameters&, float, float, const CDamageInfo&, const CDamageInfo&,
|
|
||||||
const CDamageVulnerability&, const CDamageVulnerability&, CAssetId, CAssetId, float, float, float, float,
|
|
||||||
const CFlameInfo& flameInfo, float, float, float);
|
|
||||||
|
|
||||||
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
|
CMagdolite(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
||||||
|
CModelData&& mData, const CPatternedInfo& pInfo, const CActorParameters& actParms, float f1, float f2,
|
||||||
|
const CDamageInfo& dInfo1, const CDamageInfo& dInfo2, const CDamageVulnerability& dVuln1,
|
||||||
|
const CDamageVulnerability& dVuln2, CAssetId modelId, CAssetId skinId, float f3, float f4, float f5,
|
||||||
|
float f6, const CFlameInfo& magData, float f7, float f8, float f9);
|
||||||
|
|
||||||
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
||||||
void Think(float dt, CStateManager& mgr) override;
|
void Think(float dt, CStateManager& mgr) override;
|
||||||
void Touch(CActor&, CStateManager&) override {};
|
void Touch(CActor& actor, CStateManager& mgr) override{};
|
||||||
const CDamageVulnerability* GetDamageVulnerability() const override {
|
const CDamageVulnerability* GetDamageVulnerability() const override {
|
||||||
return x400_25_alive ? CAi::GetDamageVulnerability() : &CDamageVulnerability::ImmuneVulnerabilty();
|
return x400_25_alive ? CAi::GetDamageVulnerability() : &CDamageVulnerability::ImmuneVulnerabilty();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&,
|
const CDamageVulnerability* GetDamageVulnerability(const zeus::CVector3f&, const zeus::CVector3f&,
|
||||||
const CDamageInfo&) const override {
|
const CDamageInfo&) const override {
|
||||||
return GetDamageVulnerability();
|
return GetDamageVulnerability();
|
||||||
|
|
|
@ -11,6 +11,7 @@ class CFlameInfo {
|
||||||
CAssetId x8_flameFxId;
|
CAssetId x8_flameFxId;
|
||||||
s32 xc_length;
|
s32 xc_length;
|
||||||
float x10_;
|
float x10_;
|
||||||
|
// float x14_;
|
||||||
float x18_;
|
float x18_;
|
||||||
float x1c_;
|
float x1c_;
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ void CStateMachineState::Update(CStateManager& mgr, CAi& ai, float delta) {
|
||||||
if (x4_state) {
|
if (x4_state) {
|
||||||
x8_time += delta;
|
x8_time += delta;
|
||||||
x4_state->CallFunc(mgr, ai, EStateMsg::Update, delta);
|
x4_state->CallFunc(mgr, ai, EStateMsg::Update, delta);
|
||||||
fmt::print(fmt("Update: {} {} {} - {} {}\n"), ai.GetUniqueId(), ai.GetEditorId(), ai.GetName(),
|
fmt::print(FMT_STRING("Update: {} {} {} - {} {}\n"), ai.GetUniqueId(), ai.GetEditorId(), ai.GetName(),
|
||||||
x4_state->xc_name, int(x4_state - x0_machine->GetStateVector().data()));
|
x4_state->xc_name, int(x4_state - x0_machine->GetStateVector().data()));
|
||||||
for (int i = 0; i < x4_state->GetNumTriggers(); ++i) {
|
for (int i = 0; i < x4_state->GetNumTriggers(); ++i) {
|
||||||
CAiTrigger* trig = x4_state->GetTrig(i);
|
CAiTrigger* trig = x4_state->GetTrig(i);
|
||||||
|
|
|
@ -2998,14 +2998,16 @@ CEntity* ScriptLoader::LoadMagdolite(CStateManager& mgr, CInputStream& in, int p
|
||||||
SScaledActorHead actorHead = LoadScaledActorHead(in, mgr);
|
SScaledActorHead actorHead = LoadScaledActorHead(in, mgr);
|
||||||
|
|
||||||
auto pair = CPatternedInfo::HasCorrectParameterCount(in);
|
auto pair = CPatternedInfo::HasCorrectParameterCount(in);
|
||||||
if (!pair.first)
|
if (!pair.first) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
CPatternedInfo pInfo(in, pair.second);
|
CPatternedInfo pInfo(in, pair.second);
|
||||||
CActorParameters actorParameters = LoadActorParameters(in);
|
CActorParameters actorParameters = LoadActorParameters(in);
|
||||||
|
|
||||||
if (!pInfo.GetAnimationParameters().GetACSFile().IsValid())
|
if (!pInfo.GetAnimationParameters().GetACSFile().IsValid()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
float f1 = in.readFloatBig();
|
float f1 = in.readFloatBig();
|
||||||
float f2 = in.readFloatBig();
|
float f2 = in.readFloatBig();
|
||||||
|
|
Loading…
Reference in New Issue