mirror of https://github.com/AxioDL/metaforce.git
CScriptSpecialFunction: Brace conditionals where applicable
This commit is contained in:
parent
568e8c0d88
commit
750e0a8643
|
@ -48,15 +48,18 @@ CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, std::string_view n
|
||||||
, x1bc_areaSaveId(aId1)
|
, x1bc_areaSaveId(aId1)
|
||||||
, x1c0_layerIdx(aId2)
|
, x1c0_layerIdx(aId2)
|
||||||
, x1c4_item(itemType) {
|
, x1c4_item(itemType) {
|
||||||
if (xe8_function == ESpecialFunction::HUDTarget)
|
if (xe8_function == ESpecialFunction::HUDTarget) {
|
||||||
x1c8_touchBounds = {-1.f, 1.f};
|
x1c8_touchBounds = {-1.f, 1.f};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
void CScriptSpecialFunction::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||||
|
|
||||||
void CScriptSpecialFunction::Think(float dt, CStateManager& mgr) {
|
void CScriptSpecialFunction::Think(float dt, CStateManager& mgr) {
|
||||||
if (!GetActive())
|
if (!GetActive()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (xe8_function) {
|
switch (xe8_function) {
|
||||||
case ESpecialFunction::PlayerFollowLocator:
|
case ESpecialFunction::PlayerFollowLocator:
|
||||||
ThinkPlayerFollowLocator(dt, mgr);
|
ThinkPlayerFollowLocator(dt, mgr);
|
||||||
|
@ -125,25 +128,29 @@ constexpr std::array fxTranslation{
|
||||||
void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
||||||
if (GetActive() && msg == EScriptObjectMessage::Deactivate && xe8_function == ESpecialFunction::Billboard) {
|
if (GetActive() && msg == EScriptObjectMessage::Deactivate && xe8_function == ESpecialFunction::Billboard) {
|
||||||
mgr.SetPendingOnScreenTex(CAssetId(), zeus::CVector2i(), zeus::CVector2i());
|
mgr.SetPendingOnScreenTex(CAssetId(), zeus::CVector2i(), zeus::CVector2i());
|
||||||
if (x1e8_)
|
if (x1e8_) {
|
||||||
x1e8_ = TLockedToken<CTexture>();
|
x1e8_ = TLockedToken<CTexture>();
|
||||||
|
}
|
||||||
x1e5_26_displayBillboard = false;
|
x1e5_26_displayBillboard = false;
|
||||||
}
|
}
|
||||||
CActor::AcceptScriptMsg(msg, uid, mgr);
|
CActor::AcceptScriptMsg(msg, uid, mgr);
|
||||||
|
|
||||||
if (xe8_function == ESpecialFunction::ChaffTarget && msg == EScriptObjectMessage::InitializedInArea)
|
if (xe8_function == ESpecialFunction::ChaffTarget && msg == EScriptObjectMessage::InitializedInArea) {
|
||||||
AddMaterial(EMaterialTypes::Target, mgr);
|
AddMaterial(EMaterialTypes::Target, mgr);
|
||||||
|
}
|
||||||
|
|
||||||
if (GetActive()) {
|
if (GetActive()) {
|
||||||
switch (xe8_function) {
|
switch (xe8_function) {
|
||||||
case ESpecialFunction::HUDFadeIn: {
|
case ESpecialFunction::HUDFadeIn: {
|
||||||
if (msg == EScriptObjectMessage::Action)
|
if (msg == EScriptObjectMessage::Action) {
|
||||||
mgr.Player()->SetHudDisable(xfc_float1, 0.f, 0.5f);
|
mgr.Player()->SetHudDisable(xfc_float1, 0.f, 0.5f);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::EscapeSequence: {
|
case ESpecialFunction::EscapeSequence: {
|
||||||
if (msg == EScriptObjectMessage::Action && xfc_float1 >= 0.f)
|
if (msg == EScriptObjectMessage::Action && xfc_float1 >= 0.f) {
|
||||||
mgr.ResetEscapeSequenceTimer(xfc_float1);
|
mgr.ResetEscapeSequenceTimer(xfc_float1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::SpinnerController: {
|
case ESpecialFunction::SpinnerController: {
|
||||||
|
@ -211,9 +218,9 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
case ESpecialFunction::SaveStation: {
|
case ESpecialFunction::SaveStation: {
|
||||||
if (msg == EScriptObjectMessage::Action) {
|
if (msg == EScriptObjectMessage::Action) {
|
||||||
g_GameState->GetPlayerState()->IncrPickup(CPlayerState::EItemType::EnergyTanks, 1);
|
g_GameState->GetPlayerState()->IncrPickup(CPlayerState::EItemType::EnergyTanks, 1);
|
||||||
if (g_GameState->GetCardSerial() == 0)
|
if (g_GameState->GetCardSerial() == 0) {
|
||||||
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
|
||||||
else {
|
} else {
|
||||||
mgr.DeferStateTransition(EStateManagerTransition::SaveGame);
|
mgr.DeferStateTransition(EStateManagerTransition::SaveGame);
|
||||||
x1e5_24_doSave = true;
|
x1e5_24_doSave = true;
|
||||||
}
|
}
|
||||||
|
@ -224,15 +231,17 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
if (x1a8_ringState != ERingState::Breakup) {
|
if (x1a8_ringState != ERingState::Breakup) {
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case EScriptObjectMessage::Play: {
|
case EScriptObjectMessage::Play: {
|
||||||
if (x1a8_ringState != ERingState::Scramble)
|
if (x1a8_ringState != ERingState::Scramble) {
|
||||||
RingScramble(mgr);
|
RingScramble(mgr);
|
||||||
|
}
|
||||||
|
|
||||||
for (SRingController& cont : x198_ringControllers) {
|
for (SRingController& cont : x198_ringControllers) {
|
||||||
if (TCastToPtr<CActor> act = mgr.ObjectById(cont.x0_id))
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(cont.x0_id)) {
|
||||||
cont.xc_ = act->GetTransform().frontVector();
|
cont.xc_ = act->GetTransform().frontVector();
|
||||||
else
|
} else {
|
||||||
cont.xc_ = zeus::skForward;
|
cont.xc_ = zeus::skForward;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
x1a8_ringState = ERingState::Breakup;
|
x1a8_ringState = ERingState::Breakup;
|
||||||
break;
|
break;
|
||||||
|
@ -251,12 +260,13 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
case EScriptObjectMessage::InitializedInArea: {
|
case EScriptObjectMessage::InitializedInArea: {
|
||||||
x198_ringControllers.reserve(3);
|
x198_ringControllers.reserve(3);
|
||||||
for (const SConnection& conn : x20_conns) {
|
for (const SConnection& conn : x20_conns) {
|
||||||
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate)
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
||||||
for (auto it = search.first; it != search.second; ++it) {
|
for (auto it = search.first; it != search.second; ++it) {
|
||||||
if (TCastToPtr<CActor> act = mgr.ObjectById(it->second)) {
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(it->second)) {
|
||||||
x198_ringControllers.emplace_back(it->second, 0.f, false);
|
x198_ringControllers.emplace_back(it->second, 0.f, false);
|
||||||
act->RemoveMaterial(EMaterialTypes::Occluder, mgr);
|
act->RemoveMaterial(EMaterialTypes::Occluder, mgr);
|
||||||
}
|
}
|
||||||
|
@ -265,10 +275,11 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
|
|
||||||
std::sort(x198_ringControllers.begin(), x198_ringControllers.end(),
|
std::sort(x198_ringControllers.begin(), x198_ringControllers.end(),
|
||||||
[&mgr](const SRingController& a, const SRingController& b) {
|
[&mgr](const SRingController& a, const SRingController& b) {
|
||||||
TCastToConstPtr<CActor> actA(mgr.GetObjectById(a.x0_id));
|
const TCastToConstPtr<CActor> actA(mgr.GetObjectById(a.x0_id));
|
||||||
TCastToConstPtr<CActor> actB(mgr.GetObjectById(b.x0_id));
|
const TCastToConstPtr<CActor> actB(mgr.GetObjectById(b.x0_id));
|
||||||
if (actA && actB)
|
if (actA && actB) {
|
||||||
return actA->GetTranslation().z() < actB->GetTranslation().z();
|
return actA->GetTranslation().z() < actB->GetTranslation().z();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -294,10 +305,11 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::BossEnergyBar: {
|
case ESpecialFunction::BossEnergyBar: {
|
||||||
if (msg == EScriptObjectMessage::Increment)
|
if (msg == EScriptObjectMessage::Increment) {
|
||||||
mgr.SetBossParams(uid, xfc_float1, u32(x100_float2) + 86);
|
mgr.SetBossParams(uid, xfc_float1, u32(x100_float2) + 86);
|
||||||
else if (msg == EScriptObjectMessage::Decrement)
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
||||||
mgr.SetBossParams(kInvalidUniqueId, 0.f, 0);
|
mgr.SetBossParams(kInvalidUniqueId, 0.f, 0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::EndGame: {
|
case ESpecialFunction::EndGame: {
|
||||||
|
@ -319,8 +331,9 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
}
|
}
|
||||||
case ESpecialFunction::CinematicSkip: {
|
case ESpecialFunction::CinematicSkip: {
|
||||||
if (msg == EScriptObjectMessage::Increment) {
|
if (msg == EScriptObjectMessage::Increment) {
|
||||||
if (ShouldSkipCinematic(mgr))
|
if (ShouldSkipCinematic(mgr)) {
|
||||||
mgr.SetSkipCinematicSpecialFunction(GetUniqueId());
|
mgr.SetSkipCinematicSpecialFunction(GetUniqueId());
|
||||||
|
}
|
||||||
} else if (msg == EScriptObjectMessage::Decrement) {
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
||||||
mgr.SetSkipCinematicSpecialFunction(kInvalidUniqueId);
|
mgr.SetSkipCinematicSpecialFunction(kInvalidUniqueId);
|
||||||
g_GameState->SystemOptions().SetCinematicState(mgr.GetWorld()->GetWorldAssetId(), GetEditorId(), true);
|
g_GameState->SystemOptions().SetCinematicState(mgr.GetWorld()->GetWorldAssetId(), GetEditorId(), true);
|
||||||
|
@ -332,20 +345,21 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
if (x1bc_areaSaveId != -1 && x1c0_layerIdx != -1) {
|
if (x1bc_areaSaveId != -1 && x1c0_layerIdx != -1) {
|
||||||
TAreaId aId = mgr.GetWorld()->GetAreaIdForSaveId(x1bc_areaSaveId);
|
TAreaId aId = mgr.GetWorld()->GetAreaIdForSaveId(x1bc_areaSaveId);
|
||||||
std::shared_ptr<CWorldLayerState> worldLayerState;
|
std::shared_ptr<CWorldLayerState> worldLayerState;
|
||||||
if (aId != kInvalidAreaId)
|
if (aId != kInvalidAreaId) {
|
||||||
worldLayerState = mgr.WorldLayerState();
|
worldLayerState = mgr.WorldLayerState();
|
||||||
else {
|
} else {
|
||||||
std::pair<CAssetId, TAreaId> worldAreaPair = g_MemoryCardSys->GetAreaAndWorldIdForSaveId(x1bc_areaSaveId);
|
const std::pair<CAssetId, TAreaId> worldAreaPair = g_MemoryCardSys->GetAreaAndWorldIdForSaveId(x1bc_areaSaveId);
|
||||||
if (worldAreaPair.first.IsValid()) {
|
if (worldAreaPair.first.IsValid()) {
|
||||||
worldLayerState = g_GameState->StateForWorld(worldAreaPair.first).GetLayerState();
|
worldLayerState = g_GameState->StateForWorld(worldAreaPair.first).GetLayerState();
|
||||||
aId = worldAreaPair.second;
|
aId = worldAreaPair.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aId != kInvalidAreaId)
|
if (aId != kInvalidAreaId) {
|
||||||
worldLayerState->SetLayerActive(aId, x1c0_layerIdx, msg == EScriptObjectMessage::Increment);
|
worldLayerState->SetLayerActive(aId, x1c0_layerIdx, msg == EScriptObjectMessage::Increment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -354,30 +368,34 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
We won't do that though
|
We won't do that though
|
||||||
*/
|
*/
|
||||||
case ESpecialFunction::EnvFxDensityController: {
|
case ESpecialFunction::EnvFxDensityController: {
|
||||||
if (msg == EScriptObjectMessage::Action)
|
if (msg == EScriptObjectMessage::Action) {
|
||||||
mgr.GetEnvFxManager()->SetFxDensity(s32(x100_float2), xfc_float1);
|
mgr.GetEnvFxManager()->SetFxDensity(s32(x100_float2), xfc_float1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::RumbleEffect:
|
case ESpecialFunction::RumbleEffect:
|
||||||
if (msg == EScriptObjectMessage::Action) {
|
if (msg == EScriptObjectMessage::Action) {
|
||||||
s32 rumbFx = s32(x100_float2);
|
const s32 rumbFx = s32(x100_float2);
|
||||||
/* Retro originally did not check the upper bounds, this could potentially cause a crash
|
|
||||||
* with some runtimes, so let's make sure we're not out of bounds in either direction
|
// Retro originally did not check the upper bounds, this could potentially cause a crash
|
||||||
*/
|
// with some runtimes, so let's make sure we're not out of bounds in either direction.
|
||||||
if (rumbFx < 0 || rumbFx >= 6)
|
if (rumbFx < 0 || rumbFx >= 6) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
mgr.GetRumbleManager().Rumble(mgr, fxTranslation[rumbFx], 1.f, ERumblePriority::One);
|
mgr.GetRumbleManager().Rumble(mgr, fxTranslation[rumbFx], 1.f, ERumblePriority::One);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ESpecialFunction::InventoryActivator: {
|
case ESpecialFunction::InventoryActivator: {
|
||||||
if (msg == EScriptObjectMessage::Action && mgr.GetPlayerState()->HasPowerUp(x1c4_item))
|
if (msg == EScriptObjectMessage::Action && mgr.GetPlayerState()->HasPowerUp(x1c4_item)) {
|
||||||
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::FusionRelay: {
|
case ESpecialFunction::FusionRelay: {
|
||||||
if (msg == EScriptObjectMessage::Action && mgr.GetPlayerState()->IsFusionEnabled())
|
if (msg == EScriptObjectMessage::Action && mgr.GetPlayerState()->IsFusionEnabled()) {
|
||||||
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::AreaDamage: {
|
case ESpecialFunction::AreaDamage: {
|
||||||
|
@ -390,11 +408,12 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
}
|
}
|
||||||
case ESpecialFunction::DropBomb: {
|
case ESpecialFunction::DropBomb: {
|
||||||
if (msg == EScriptObjectMessage::Action) {
|
if (msg == EScriptObjectMessage::Action) {
|
||||||
if (xfc_float1 >= 1.f)
|
if (xfc_float1 >= 1.f) {
|
||||||
mgr.GetPlayer().GetPlayerGun()->DropBomb(CPlayerGun::EBWeapon::PowerBomb, mgr);
|
mgr.GetPlayer().GetPlayerGun()->DropBomb(CPlayerGun::EBWeapon::PowerBomb, mgr);
|
||||||
else
|
} else {
|
||||||
mgr.GetPlayer().GetPlayerGun()->DropBomb(CPlayerGun::EBWeapon::Bomb, mgr);
|
mgr.GetPlayer().GetPlayerGun()->DropBomb(CPlayerGun::EBWeapon::Bomb, mgr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::RedundantHintSystem: {
|
case ESpecialFunction::RedundantHintSystem: {
|
||||||
|
@ -411,7 +430,7 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
case ESpecialFunction::Billboard: {
|
case ESpecialFunction::Billboard: {
|
||||||
if (msg == EScriptObjectMessage::Increment) {
|
if (msg == EScriptObjectMessage::Increment) {
|
||||||
const SObjectTag* objectTag = g_ResFactory->GetResourceIdByName(xec_locatorName);
|
const SObjectTag* objectTag = g_ResFactory->GetResourceIdByName(xec_locatorName);
|
||||||
CAssetId assetId = objectTag ? objectTag->id : CAssetId();
|
const CAssetId assetId = objectTag ? objectTag->id : CAssetId();
|
||||||
|
|
||||||
mgr.SetPendingOnScreenTex(assetId, {int(x104_float3), int(x108_float4)}, {int(xfc_float1), int(x100_float2)});
|
mgr.SetPendingOnScreenTex(assetId, {int(x104_float3), int(x108_float4)}, {int(xfc_float1), int(x100_float2)});
|
||||||
if (objectTag) {
|
if (objectTag) {
|
||||||
|
@ -434,27 +453,31 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::HUDTarget: {
|
case ESpecialFunction::HUDTarget: {
|
||||||
if (msg == EScriptObjectMessage::Increment)
|
if (msg == EScriptObjectMessage::Increment) {
|
||||||
AddMaterial(EMaterialTypes::Target, EMaterialTypes::RadarObject, mgr);
|
AddMaterial(EMaterialTypes::Target, EMaterialTypes::RadarObject, mgr);
|
||||||
else if (msg == EScriptObjectMessage::Decrement)
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
||||||
RemoveMaterial(EMaterialTypes::Target, EMaterialTypes::RadarObject, mgr);
|
RemoveMaterial(EMaterialTypes::Target, EMaterialTypes::RadarObject, mgr);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::FogFader: {
|
case ESpecialFunction::FogFader: {
|
||||||
if (msg == EScriptObjectMessage::Increment)
|
if (msg == EScriptObjectMessage::Increment) {
|
||||||
mgr.GetCameraManager()->SetFogDensity(x100_float2, xfc_float1);
|
mgr.GetCameraManager()->SetFogDensity(x100_float2, xfc_float1);
|
||||||
else if (msg == EScriptObjectMessage::Decrement)
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
||||||
mgr.GetCameraManager()->SetFogDensity(x100_float2, 1.f);
|
mgr.GetCameraManager()->SetFogDensity(x100_float2, 1.f);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::EnterLogbook: {
|
case ESpecialFunction::EnterLogbook: {
|
||||||
if (msg == EScriptObjectMessage::Action)
|
if (msg == EScriptObjectMessage::Action) {
|
||||||
mgr.DeferStateTransition(EStateManagerTransition::LogBook);
|
mgr.DeferStateTransition(EStateManagerTransition::LogBook);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESpecialFunction::Ending: {
|
case ESpecialFunction::Ending: {
|
||||||
if (msg == EScriptObjectMessage::Action && GetSpecialEnding(mgr) == u32(xfc_float1))
|
if (msg == EScriptObjectMessage::Action && GetSpecialEnding(mgr) == u32(xfc_float1)) {
|
||||||
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -464,10 +487,12 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::PreRender(CStateManager&, const zeus::CFrustum& frustum) {
|
void CScriptSpecialFunction::PreRender(CStateManager&, const zeus::CFrustum& frustum) {
|
||||||
if (xe8_function != ESpecialFunction::FogVolume && xe8_function != ESpecialFunction::ViewFrustumTester)
|
if (xe8_function != ESpecialFunction::FogVolume && xe8_function != ESpecialFunction::ViewFrustumTester) {
|
||||||
return;
|
return;
|
||||||
if (!GetActive())
|
}
|
||||||
|
if (!GetActive()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bool val;
|
bool val;
|
||||||
if (xe8_function == ESpecialFunction::FogVolume) {
|
if (xe8_function == ESpecialFunction::FogVolume) {
|
||||||
|
@ -476,13 +501,15 @@ void CScriptSpecialFunction::PreRender(CStateManager&, const zeus::CFrustum& fru
|
||||||
val = frustum.pointFrustumTest(GetTranslation());
|
val = frustum.pointFrustumTest(GetTranslation());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x1e4_30_ == val)
|
if (x1e4_30_ == val) {
|
||||||
return;
|
return;
|
||||||
if (!val)
|
}
|
||||||
|
if (!val) {
|
||||||
x1e4_29_frustumExited = true;
|
x1e4_29_frustumExited = true;
|
||||||
else
|
} else {
|
||||||
x1e4_28_frustumEntered = true;
|
x1e4_28_frustumEntered = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::AddToRenderer(const zeus::CFrustum&, CStateManager& mgr) {
|
void CScriptSpecialFunction::AddToRenderer(const zeus::CFrustum&, CStateManager& mgr) {
|
||||||
if (!GetActive()) {
|
if (!GetActive()) {
|
||||||
|
@ -496,19 +523,19 @@ void CScriptSpecialFunction::AddToRenderer(const zeus::CFrustum&, CStateManager&
|
||||||
|
|
||||||
void CScriptSpecialFunction::Render(CStateManager& mgr) {
|
void CScriptSpecialFunction::Render(CStateManager& mgr) {
|
||||||
if (xe8_function == ESpecialFunction::FogVolume) {
|
if (xe8_function == ESpecialFunction::FogVolume) {
|
||||||
float z = mgr.IntegrateVisorFog(xfc_float1 * std::sin(CGraphics::GetSecondsMod900()));
|
const float z = mgr.IntegrateVisorFog(xfc_float1 * std::sin(CGraphics::GetSecondsMod900()));
|
||||||
if (z > 0.f) {
|
if (z > 0.f) {
|
||||||
zeus::CVector3f max = GetTranslation() + x10c_vector3f;
|
zeus::CVector3f max = GetTranslation() + x10c_vector3f;
|
||||||
max.z() += z;
|
max.z() += z;
|
||||||
zeus::CAABox box(GetTranslation() - x10c_vector3f, max);
|
const zeus::CAABox box(GetTranslation() - x10c_vector3f, max);
|
||||||
zeus::CTransform modelMtx = zeus::CTransform::Translate(box.center()) * zeus::CTransform::Scale(box.extents());
|
const zeus::CTransform modelMtx = zeus::CTransform::Translate(box.center()) * zeus::CTransform::Scale(box.extents());
|
||||||
g_Renderer->SetModelMatrix(modelMtx);
|
g_Renderer->SetModelMatrix(modelMtx);
|
||||||
g_Renderer->RenderFogVolume(x118_color, zeus::CAABox(-1.f, 1.f), nullptr, nullptr);
|
g_Renderer->RenderFogVolume(x118_color, zeus::CAABox(-1.f, 1.f), nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
} else
|
|
||||||
CActor::Render(mgr);
|
CActor::Render(mgr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::SkipCinematic(CStateManager& stateMgr) {
|
void CScriptSpecialFunction::SkipCinematic(CStateManager& stateMgr) {
|
||||||
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
||||||
|
@ -530,7 +557,7 @@ void CScriptSpecialFunction::RingScramble(CStateManager& mgr) {
|
||||||
void CScriptSpecialFunction::ThinkIntroBossRingController(float dt, CStateManager& mgr) {
|
void CScriptSpecialFunction::ThinkIntroBossRingController(float dt, CStateManager& mgr) {
|
||||||
if (x1a8_ringState != ERingState::Breakup) {
|
if (x1a8_ringState != ERingState::Breakup) {
|
||||||
for (const auto& rc : x198_ringControllers) {
|
for (const auto& rc : x198_ringControllers) {
|
||||||
if (TCastToPtr<CActor> act = mgr.ObjectById(rc.x0_id)) {
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(rc.x0_id)) {
|
||||||
zeus::CTransform newXf = act->GetTransform();
|
zeus::CTransform newXf = act->GetTransform();
|
||||||
newXf.rotateLocalZ(zeus::degToRad(rc.x4_rotateSpeed * dt));
|
newXf.rotateLocalZ(zeus::degToRad(rc.x4_rotateSpeed * dt));
|
||||||
act->SetTransform(newXf);
|
act->SetTransform(newXf);
|
||||||
|
@ -541,7 +568,7 @@ void CScriptSpecialFunction::ThinkIntroBossRingController(float dt, CStateManage
|
||||||
case ERingState::Breakup: {
|
case ERingState::Breakup: {
|
||||||
float minMag = 0.f;
|
float minMag = 0.f;
|
||||||
for (const auto& rc : x198_ringControllers) {
|
for (const auto& rc : x198_ringControllers) {
|
||||||
if (TCastToPtr<CActor> act = mgr.ObjectById(rc.x0_id)) {
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(rc.x0_id)) {
|
||||||
act->SetTranslation(act->GetTransform().basis[1] * 50.f * dt + act->GetTranslation());
|
act->SetTranslation(act->GetTransform().basis[1] * 50.f * dt + act->GetTranslation());
|
||||||
minMag = std::min(act->GetTranslation().magnitude(), minMag);
|
minMag = std::min(act->GetTranslation().magnitude(), minMag);
|
||||||
}
|
}
|
||||||
|
@ -550,9 +577,10 @@ void CScriptSpecialFunction::ThinkIntroBossRingController(float dt, CStateManage
|
||||||
if (minMag != 0.f) {
|
if (minMag != 0.f) {
|
||||||
/* Never actually happens */
|
/* Never actually happens */
|
||||||
for (const auto& rc : x198_ringControllers) {
|
for (const auto& rc : x198_ringControllers) {
|
||||||
if (CEntity* ent = mgr.ObjectById(rc.x0_id))
|
if (CEntity* ent = mgr.ObjectById(rc.x0_id)) {
|
||||||
ent->SetActive(false);
|
ent->SetActive(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
SetActive(false);
|
SetActive(false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -563,7 +591,7 @@ void CScriptSpecialFunction::ThinkIntroBossRingController(float dt, CStateManage
|
||||||
.transform(x1ac_ringRotateTarget);
|
.transform(x1ac_ringRotateTarget);
|
||||||
bool allReachedTarget = true;
|
bool allReachedTarget = true;
|
||||||
for (auto& rc : x198_ringControllers) {
|
for (auto& rc : x198_ringControllers) {
|
||||||
if (TCastToPtr<CActor> act = mgr.ObjectById(rc.x0_id)) {
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(rc.x0_id)) {
|
||||||
zeus::CVector3f lookDirFlat = act->GetTransform().basis[1];
|
zeus::CVector3f lookDirFlat = act->GetTransform().basis[1];
|
||||||
lookDirFlat.z() = 0.f;
|
lookDirFlat.z() = 0.f;
|
||||||
lookDirFlat.normalize();
|
lookDirFlat.normalize();
|
||||||
|
@ -583,9 +611,10 @@ void CScriptSpecialFunction::ThinkIntroBossRingController(float dt, CStateManage
|
||||||
if (allReachedTarget) {
|
if (allReachedTarget) {
|
||||||
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
||||||
x1a8_ringState = ERingState::Stopped;
|
x1a8_ringState = ERingState::Stopped;
|
||||||
for (auto& rc : x198_ringControllers)
|
for (auto& rc : x198_ringControllers) {
|
||||||
rc.x8_reachedTarget = false;
|
rc.x8_reachedTarget = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -595,11 +624,14 @@ void CScriptSpecialFunction::ThinkIntroBossRingController(float dt, CStateManage
|
||||||
|
|
||||||
void CScriptSpecialFunction::ThinkPlayerFollowLocator(float, CStateManager& mgr) {
|
void CScriptSpecialFunction::ThinkPlayerFollowLocator(float, CStateManager& mgr) {
|
||||||
for (const SConnection& conn : GetConnectionList()) {
|
for (const SConnection& conn : GetConnectionList()) {
|
||||||
if (conn.x0_state == EScriptObjectState::Play && conn.x4_msg == EScriptObjectMessage::Activate) {
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate) {
|
||||||
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto search = mgr.GetIdListForScript(conn.x8_objId);
|
||||||
for (auto it = search.first; it != search.second; ++it) {
|
for (auto it = search.first; it != search.second; ++it) {
|
||||||
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(it->second)) {
|
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(it->second)) {
|
||||||
zeus::CTransform xf = act->GetTransform() * act->GetLocatorTransform(xec_locatorName);
|
const zeus::CTransform xf = act->GetTransform() * act->GetLocatorTransform(xec_locatorName);
|
||||||
CPlayer& pl = mgr.GetPlayer();
|
CPlayer& pl = mgr.GetPlayer();
|
||||||
pl.SetTransform(xf);
|
pl.SetTransform(xf);
|
||||||
pl.SetVelocityWR({});
|
pl.SetVelocityWR({});
|
||||||
|
@ -610,21 +642,21 @@ void CScriptSpecialFunction::ThinkPlayerFollowLocator(float, CStateManager& mgr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr, ESpinnerControllerMode mode) {
|
void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr, ESpinnerControllerMode mode) {
|
||||||
bool allowWrap = xec_locatorName.find("AllowWrap") != std::string::npos;
|
const bool allowWrap = xec_locatorName.find("AllowWrap") != std::string::npos;
|
||||||
bool noBackward = xec_locatorName.find("NoBackward") != std::string::npos;
|
const bool noBackward = xec_locatorName.find("NoBackward") != std::string::npos;
|
||||||
float pointOneByDt = 0.1f * dt;
|
const float pointOneByDt = 0.1f * dt;
|
||||||
float twoByDt = 2.f * dt;
|
const float twoByDt = 2.f * dt;
|
||||||
|
|
||||||
for (const SConnection& conn : x20_conns) {
|
for (const SConnection& conn : x20_conns) {
|
||||||
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate)
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
const auto search = mgr.GetIdListForScript(conn.x8_objId);
|
||||||
for (auto it = search.first; it != search.second; ++it) {
|
for (auto it = search.first; it != search.second; ++it) {
|
||||||
if (TCastToPtr<CScriptPlatform> plat = mgr.ObjectById((*it).second)) {
|
if (const TCastToPtr<CScriptPlatform> plat = mgr.ObjectById((*it).second)) {
|
||||||
if (plat->HasModelData() && plat->GetModelData()->HasAnimData()) {
|
if (plat->HasModelData() && plat->GetModelData()->HasAnimData()) {
|
||||||
plat->SetControlledAnimation(true);
|
plat->SetControlledAnimation(true);
|
||||||
if (!x1e4_24_) {
|
if (!x1e4_24_) {
|
||||||
|
@ -633,26 +665,29 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
}
|
}
|
||||||
|
|
||||||
float f28 = x138_;
|
float f28 = x138_;
|
||||||
float f29 = pointOneByDt * x100_float2;
|
const float f29 = pointOneByDt * x100_float2;
|
||||||
|
|
||||||
if (mode == ESpinnerControllerMode::Zero) {
|
if (mode == ESpinnerControllerMode::Zero) {
|
||||||
if (x1e4_25_spinnerCanMove) {
|
if (x1e4_25_spinnerCanMove) {
|
||||||
CPlayer& pl = mgr.GetPlayer();
|
const CPlayer& pl = mgr.GetPlayer();
|
||||||
zeus::CVector3f angVel = pl.GetAngularVelocityOR().getVector();
|
const zeus::CVector3f angVel = pl.GetAngularVelocityOR().getVector();
|
||||||
float mag = 0.f;
|
float mag = 0.f;
|
||||||
if (angVel.canBeNormalized())
|
if (angVel.canBeNormalized()) {
|
||||||
mag = angVel.magnitude();
|
mag = angVel.magnitude();
|
||||||
|
}
|
||||||
|
|
||||||
float spinImpulse =
|
const float spinImpulse =
|
||||||
(pl.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed ? 0.025f * mag : 0.f);
|
(pl.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed ? 0.025f * mag : 0.f);
|
||||||
if (spinImpulse >= x180_)
|
if (spinImpulse >= x180_) {
|
||||||
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
||||||
|
}
|
||||||
|
|
||||||
x180_ = spinImpulse;
|
x180_ = spinImpulse;
|
||||||
x138_ += 0.01f * spinImpulse * xfc_float1;
|
x138_ += 0.01f * spinImpulse * xfc_float1;
|
||||||
|
|
||||||
if (!noBackward)
|
if (!noBackward) {
|
||||||
x138_ -= f29;
|
x138_ -= f29;
|
||||||
|
}
|
||||||
} else if (!noBackward) {
|
} else if (!noBackward) {
|
||||||
x138_ = f28 - twoByDt;
|
x138_ = f28 - twoByDt;
|
||||||
}
|
}
|
||||||
|
@ -662,17 +697,19 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
if (!noBackward) {
|
if (!noBackward) {
|
||||||
x138_ -= f29;
|
x138_ -= f29;
|
||||||
|
|
||||||
if (std::fabs(x16c_) < dt)
|
if (std::fabs(x16c_) < dt) {
|
||||||
x16c_ = 0.f;
|
x16c_ = 0.f;
|
||||||
else
|
} else {
|
||||||
x16c_ -= (dt * (x16c_ <= 0.f ? -1.f : 1.f));
|
x16c_ -= (dt * (x16c_ <= 0.f ? -1.f : 1.f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (allowWrap) {
|
if (allowWrap) {
|
||||||
x138_ = std::fmod(x138_, 1.f);
|
x138_ = std::fmod(x138_, 1.f);
|
||||||
if (x138_ < 0.f)
|
if (x138_ < 0.f) {
|
||||||
x138_ += 1.f;
|
x138_ += 1.f;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
x138_ = zeus::clamp(0.f, x138_, 1.f);
|
x138_ = zeus::clamp(0.f, x138_, 1.f);
|
||||||
}
|
}
|
||||||
|
@ -681,29 +718,33 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
f28 = x138_ - f28;
|
f28 = x138_ - f28;
|
||||||
if (zeus::close_enough(x138_, 1.f, FLT_EPSILON)) {
|
if (zeus::close_enough(x138_, 1.f, FLT_EPSILON)) {
|
||||||
if (!x1e4_27_sfx3Played) {
|
if (!x1e4_27_sfx3Played) {
|
||||||
if (x174_sfx3 != 0xFFFF)
|
if (x174_sfx3 != 0xFFFF) {
|
||||||
CSfxManager::AddEmitter(x174_sfx3, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
CSfxManager::AddEmitter(x174_sfx3, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
||||||
|
}
|
||||||
|
|
||||||
x1e4_27_sfx3Played = true;
|
x1e4_27_sfx3Played = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
||||||
r23 = false;
|
r23 = false;
|
||||||
} else
|
} else {
|
||||||
x1e4_27_sfx3Played = false;
|
x1e4_27_sfx3Played = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (zeus::close_enough(x138_, 0.f, FLT_EPSILON)) {
|
if (zeus::close_enough(x138_, 0.f, FLT_EPSILON)) {
|
||||||
if (!x1e4_26_sfx2Played) {
|
if (!x1e4_26_sfx2Played) {
|
||||||
if (x172_sfx2 != 0xFFFF)
|
if (x172_sfx2 != 0xFFFF) {
|
||||||
CSfxManager::AddEmitter(x172_sfx2, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
CSfxManager::AddEmitter(x172_sfx2, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
||||||
|
}
|
||||||
|
|
||||||
x1e4_26_sfx2Played = true;
|
x1e4_26_sfx2Played = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
||||||
r23 = false;
|
r23 = false;
|
||||||
} else
|
} else {
|
||||||
x1e4_26_sfx2Played = false;
|
x1e4_26_sfx2Played = false;
|
||||||
|
}
|
||||||
|
|
||||||
// local_1ac = x184_.GetAverage();
|
// local_1ac = x184_.GetAverage();
|
||||||
if (r23) {
|
if (r23) {
|
||||||
|
@ -713,7 +754,7 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
} else {
|
} else {
|
||||||
x184_.AddValue(0.f);
|
x184_.AddValue(0.f);
|
||||||
}
|
}
|
||||||
const std::optional<float>& avg = x184_.GetAverage();
|
const std::optional<float> avg = x184_.GetAverage();
|
||||||
AddOrUpdateEmitter(0.f <= f28 ? x108_float4 : 1.f, x178_sfxHandle, x170_sfx1, GetTranslation(),
|
AddOrUpdateEmitter(0.f <= f28 ? x108_float4 : 1.f, x178_sfxHandle, x170_sfx1, GetTranslation(),
|
||||||
avg.value());
|
avg.value());
|
||||||
}
|
}
|
||||||
|
@ -722,7 +763,7 @@ void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimData* animData = plat->GetModelData()->GetAnimationData();
|
CAnimData* animData = plat->GetModelData()->GetAnimationData();
|
||||||
float dur = animData->GetAnimationDuration(animData->GetDefaultAnimation()) * x138_;
|
const float dur = animData->GetAnimationDuration(animData->GetDefaultAnimation()) * x138_;
|
||||||
animData->SetPhase(0.f);
|
animData->SetPhase(0.f);
|
||||||
animData->SetPlaybackRate(1.f);
|
animData->SetPlaybackRate(1.f);
|
||||||
const SAdvancementDeltas& deltas = plat->UpdateAnimation(dur, mgr, true);
|
const SAdvancementDeltas& deltas = plat->UpdateAnimation(dur, mgr, true);
|
||||||
|
@ -738,12 +779,13 @@ void CScriptSpecialFunction::ThinkObjectFollowLocator(float, CStateManager& mgr)
|
||||||
TUniqueId followedAct = kInvalidUniqueId;
|
TUniqueId followedAct = kInvalidUniqueId;
|
||||||
for (const SConnection& conn : x20_conns) {
|
for (const SConnection& conn : x20_conns) {
|
||||||
if (conn.x0_state != EScriptObjectState::Play ||
|
if (conn.x0_state != EScriptObjectState::Play ||
|
||||||
(conn.x4_msg != EScriptObjectMessage::Activate && conn.x4_msg != EScriptObjectMessage::Deactivate))
|
(conn.x4_msg != EScriptObjectMessage::Activate && conn.x4_msg != EScriptObjectMessage::Deactivate)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
const auto search = mgr.GetIdListForScript(conn.x8_objId);
|
||||||
for (auto it = search.first; it != search.second; ++it) {
|
for (auto it = search.first; it != search.second; ++it) {
|
||||||
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(it->second)) {
|
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(it->second)) {
|
||||||
if (conn.x4_msg == EScriptObjectMessage::Activate &&
|
if (conn.x4_msg == EScriptObjectMessage::Activate &&
|
||||||
(act->HasModelData() && act->GetModelData()->HasAnimData()) && act->GetActive()) {
|
(act->HasModelData() && act->GetModelData()->HasAnimData()) && act->GetActive()) {
|
||||||
followedAct = it->second;
|
followedAct = it->second;
|
||||||
|
@ -754,11 +796,12 @@ void CScriptSpecialFunction::ThinkObjectFollowLocator(float, CStateManager& mgr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (followerAct == kInvalidUniqueId || followedAct == kInvalidUniqueId)
|
if (followerAct == kInvalidUniqueId || followedAct == kInvalidUniqueId) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TCastToConstPtr<CActor> fromAct = mgr.GetObjectById(followedAct);
|
const TCastToConstPtr<CActor> fromAct = mgr.GetObjectById(followedAct);
|
||||||
TCastToPtr<CActor> toAct = mgr.ObjectById(followerAct);
|
const TCastToPtr<CActor> toAct = mgr.ObjectById(followerAct);
|
||||||
toAct->SetTransform(fromAct->GetTransform() * fromAct->GetScaledLocatorTransform(xec_locatorName));
|
toAct->SetTransform(fromAct->GetTransform() * fromAct->GetScaledLocatorTransform(xec_locatorName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -767,12 +810,13 @@ void CScriptSpecialFunction::ThinkObjectFollowObject(float, CStateManager& mgr)
|
||||||
TUniqueId followedAct = kInvalidUniqueId;
|
TUniqueId followedAct = kInvalidUniqueId;
|
||||||
for (const SConnection& conn : x20_conns) {
|
for (const SConnection& conn : x20_conns) {
|
||||||
if (conn.x0_state != EScriptObjectState::Play ||
|
if (conn.x0_state != EScriptObjectState::Play ||
|
||||||
(conn.x4_msg != EScriptObjectMessage::Activate && conn.x4_msg != EScriptObjectMessage::Deactivate))
|
(conn.x4_msg != EScriptObjectMessage::Activate && conn.x4_msg != EScriptObjectMessage::Deactivate)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
const auto search = mgr.GetIdListForScript(conn.x8_objId);
|
||||||
for (auto it = search.first; it != search.second; ++it) {
|
for (auto it = search.first; it != search.second; ++it) {
|
||||||
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(it->second)) {
|
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(it->second)) {
|
||||||
if (conn.x4_msg == EScriptObjectMessage::Activate && act->GetActive()) {
|
if (conn.x4_msg == EScriptObjectMessage::Activate && act->GetActive()) {
|
||||||
followedAct = it->second;
|
followedAct = it->second;
|
||||||
} else if (conn.x4_msg == EScriptObjectMessage::Deactivate) {
|
} else if (conn.x4_msg == EScriptObjectMessage::Deactivate) {
|
||||||
|
@ -782,20 +826,21 @@ void CScriptSpecialFunction::ThinkObjectFollowObject(float, CStateManager& mgr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TCastToConstPtr<CActor> followed = mgr.GetObjectById(followedAct);
|
const TCastToConstPtr<CActor> followed = mgr.GetObjectById(followedAct);
|
||||||
TCastToPtr<CActor> follower = mgr.ObjectById(followerAct);
|
const TCastToPtr<CActor> follower = mgr.ObjectById(followerAct);
|
||||||
if (followed && follower)
|
if (followed && follower) {
|
||||||
follower->SetTransform(followed->GetTransform());
|
follower->SetTransform(followed->GetTransform());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::ThinkChaffTarget(float dt, CStateManager& mgr) {
|
void CScriptSpecialFunction::ThinkChaffTarget(float dt, CStateManager& mgr) {
|
||||||
zeus::CAABox box(5.f - GetTranslation(), 5.f + GetTranslation());
|
const zeus::CAABox box(5.f - GetTranslation(), 5.f + GetTranslation());
|
||||||
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
rstl::reserved_vector<TUniqueId, 1024> nearList;
|
||||||
mgr.BuildNearList(nearList, box, CMaterialFilter::MakeInclude({EMaterialTypes::Projectile}), nullptr);
|
mgr.BuildNearList(nearList, box, CMaterialFilter::MakeInclude({EMaterialTypes::Projectile}), nullptr);
|
||||||
CCameraFilterPassPoly& filter = mgr.GetCameraFilterPass(7);
|
CCameraFilterPassPoly& filter = mgr.GetCameraFilterPass(7);
|
||||||
|
|
||||||
for (TUniqueId uid : nearList) {
|
for (const TUniqueId uid : nearList) {
|
||||||
if (TCastToPtr<CEnergyProjectile> proj = mgr.ObjectById(uid)) {
|
if (const TCastToPtr<CEnergyProjectile> proj = mgr.ObjectById(uid)) {
|
||||||
if (proj->GetHomingTargetId() == GetUniqueId()) {
|
if (proj->GetHomingTargetId() == GetUniqueId()) {
|
||||||
proj->Set3d0_26(true);
|
proj->Set3d0_26(true);
|
||||||
if (mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {
|
if (mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {
|
||||||
|
@ -810,33 +855,38 @@ void CScriptSpecialFunction::ThinkChaffTarget(float dt, CStateManager& mgr) {
|
||||||
x194_ = zeus::max(0.f, x194_ - dt);
|
x194_ = zeus::max(0.f, x194_ - dt);
|
||||||
if (x194_ != 0.f && mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {
|
if (x194_ != 0.f && mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {
|
||||||
float intfMag = x104_float3 * (0.5f + ((0.5f + x194_) / xfc_float1));
|
float intfMag = x104_float3 * (0.5f + ((0.5f + x194_) / xfc_float1));
|
||||||
if (x194_ < 1.f)
|
if (x194_ < 1.f) {
|
||||||
intfMag *= x194_;
|
intfMag *= x194_;
|
||||||
|
}
|
||||||
|
|
||||||
mgr.GetPlayerState()->GetStaticInterference().AddSource(GetUniqueId(), intfMag, .5f);
|
mgr.GetPlayerState()->GetStaticInterference().AddSource(GetUniqueId(), intfMag, .5f);
|
||||||
|
|
||||||
if (mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Scan)
|
if (mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Scan) {
|
||||||
mgr.GetPlayer().AddOrbitDisableSource(mgr, GetUniqueId());
|
mgr.GetPlayer().AddOrbitDisableSource(mgr, GetUniqueId());
|
||||||
else
|
} else {
|
||||||
mgr.GetPlayer().RemoveOrbitDisableSource(GetUniqueId());
|
mgr.GetPlayer().RemoveOrbitDisableSource(GetUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::ThinkActorScale(float dt, CStateManager& mgr) {
|
void CScriptSpecialFunction::ThinkActorScale(float dt, CStateManager& mgr) {
|
||||||
float deltaScale = dt * xfc_float1;
|
const float deltaScale = dt * xfc_float1;
|
||||||
|
|
||||||
for (const SConnection& conn : x20_conns) {
|
for (const SConnection& conn : x20_conns) {
|
||||||
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate)
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate) {
|
||||||
continue;
|
continue;
|
||||||
if (TCastToPtr<CActor> act = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) {
|
}
|
||||||
|
|
||||||
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) {
|
||||||
CModelData* mData = act->GetModelData();
|
CModelData* mData = act->GetModelData();
|
||||||
if (mData && (mData->HasAnimData() || mData->HasNormalModel())) {
|
if (mData && (mData->HasAnimData() || mData->HasNormalModel())) {
|
||||||
zeus::CVector3f scale = mData->GetScale();
|
zeus::CVector3f scale = mData->GetScale();
|
||||||
|
|
||||||
if (deltaScale > 0.f)
|
if (deltaScale > 0.f) {
|
||||||
scale = zeus::min(zeus::CVector3f(deltaScale) + scale, zeus::CVector3f(x100_float2));
|
scale = zeus::min(zeus::CVector3f(deltaScale) + scale, zeus::CVector3f(x100_float2));
|
||||||
else
|
} else {
|
||||||
scale = zeus::max(zeus::CVector3f(deltaScale) + scale, zeus::CVector3f(x100_float2));
|
scale = zeus::max(zeus::CVector3f(deltaScale) + scale, zeus::CVector3f(x100_float2));
|
||||||
|
}
|
||||||
|
|
||||||
mData->SetScale(scale);
|
mData->SetScale(scale);
|
||||||
}
|
}
|
||||||
|
@ -845,25 +895,30 @@ void CScriptSpecialFunction::ThinkActorScale(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::ThinkSaveStation(float, CStateManager& mgr) {
|
void CScriptSpecialFunction::ThinkSaveStation(float, CStateManager& mgr) {
|
||||||
if (x1e5_24_doSave && mgr.GetDeferredStateTransition() != EStateManagerTransition::SaveGame) {
|
if (!x1e5_24_doSave || mgr.GetDeferredStateTransition() == EStateManagerTransition::SaveGame) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x1e5_24_doSave = false;
|
x1e5_24_doSave = false;
|
||||||
if (mgr.GetInSaveUI())
|
if (mgr.GetInSaveUI()) {
|
||||||
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
||||||
else
|
} else {
|
||||||
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::ThinkRainSimulator(float, CStateManager& mgr) {
|
void CScriptSpecialFunction::ThinkRainSimulator(float, CStateManager& mgr) {
|
||||||
if ((float(mgr.GetInputFrameIdx()) / 3600.f) < 0.5f)
|
if ((float(mgr.GetInputFrameIdx()) / 3600.f) < 0.5f) {
|
||||||
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
||||||
else
|
} else {
|
||||||
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::ThinkAreaDamage(float dt, CStateManager& mgr) {
|
void CScriptSpecialFunction::ThinkAreaDamage(float dt, CStateManager& mgr) {
|
||||||
const auto& playerState = mgr.GetPlayerState();
|
const auto& playerState = mgr.GetPlayerState();
|
||||||
CPlayer& player = mgr.GetPlayer();
|
CPlayer& player = mgr.GetPlayer();
|
||||||
|
|
||||||
/* The following check is a URDE addition */
|
/* The following check is a URDE addition */
|
||||||
if (!playerState->CanTakeDamage()) {
|
if (!playerState->CanTakeDamage()) {
|
||||||
/* Make sure we're not currently set to take damage, if so reset our state to be as if we're not */
|
/* Make sure we're not currently set to take damage, if so reset our state to be as if we're not */
|
||||||
|
@ -879,8 +934,9 @@ void CScriptSpecialFunction::ThinkAreaDamage(float dt, CStateManager& mgr) {
|
||||||
|
|
||||||
if (!x1e4_31_inAreaDamage) {
|
if (!x1e4_31_inAreaDamage) {
|
||||||
if (mgr.GetPlayer().GetAreaIdAlways() != GetAreaIdAlways() ||
|
if (mgr.GetPlayer().GetAreaIdAlways() != GetAreaIdAlways() ||
|
||||||
playerState->GetCurrentSuitRaw() != CPlayerState::EPlayerSuit::Power)
|
playerState->GetCurrentSuitRaw() != CPlayerState::EPlayerSuit::Power) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
x1e4_31_inAreaDamage = true;
|
x1e4_31_inAreaDamage = true;
|
||||||
player.IncrementEnvironmentDamage();
|
player.IncrementEnvironmentDamage();
|
||||||
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
|
||||||
|
@ -902,8 +958,9 @@ void CScriptSpecialFunction::ThinkAreaDamage(float dt, CStateManager& mgr) {
|
||||||
|
|
||||||
void CScriptSpecialFunction::ThinkPlayerInArea(float dt, CStateManager& mgr) {
|
void CScriptSpecialFunction::ThinkPlayerInArea(float dt, CStateManager& mgr) {
|
||||||
if (mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {
|
if (mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {
|
||||||
if (x1e5_25_playerInArea)
|
if (x1e5_25_playerInArea) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x1e5_25_playerInArea = true;
|
x1e5_25_playerInArea = true;
|
||||||
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
|
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
|
||||||
|
@ -914,22 +971,28 @@ void CScriptSpecialFunction::ThinkPlayerInArea(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScriptSpecialFunction::ShouldSkipCinematic(CStateManager& stateMgr) const {
|
bool CScriptSpecialFunction::ShouldSkipCinematic(CStateManager& stateMgr) const {
|
||||||
if (hecl::com_developer->toBoolean())
|
if (hecl::com_developer->toBoolean()) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return g_GameState->SystemOptions().GetCinematicState(stateMgr.GetWorld()->IGetWorldAssetId(), GetEditorId());
|
return g_GameState->SystemOptions().GetCinematicState(stateMgr.GetWorld()->IGetWorldAssetId(), GetEditorId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptSpecialFunction::DeleteEmitter(const CSfxHandle& handle) {
|
void CScriptSpecialFunction::DeleteEmitter(const CSfxHandle& handle) {
|
||||||
if (handle)
|
if (!handle) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CSfxManager::RemoveEmitter(handle);
|
CSfxManager::RemoveEmitter(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CScriptSpecialFunction::GetSpecialEnding(const CStateManager& mgr) const {
|
u32 CScriptSpecialFunction::GetSpecialEnding(const CStateManager& mgr) const {
|
||||||
const u32 rate = (mgr.GetPlayerState()->CalculateItemCollectionRate() * 100) / mgr.GetPlayerState()->GetPickupTotal();
|
const u32 rate = (mgr.GetPlayerState()->CalculateItemCollectionRate() * 100) / mgr.GetPlayerState()->GetPickupTotal();
|
||||||
if (rate < 75)
|
if (rate < 75) {
|
||||||
return 0;
|
return 0;
|
||||||
else if (rate < 100)
|
}
|
||||||
|
if (rate < 100) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue