2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CScriptSpecialFunction.hpp"
|
|
|
|
|
2020-04-12 15:58:05 +00:00
|
|
|
#include <array>
|
|
|
|
|
2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/CGameState.hpp"
|
|
|
|
#include "Runtime/CMemoryCardSys.hpp"
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/IMain.hpp"
|
|
|
|
#include "Runtime/Audio/CSfxManager.hpp"
|
|
|
|
#include "Runtime/Camera/CCameraManager.hpp"
|
|
|
|
#include "Runtime/Character/CModelData.hpp"
|
2022-02-25 07:45:25 +00:00
|
|
|
#include "Runtime/Graphics/CCubeRenderer.hpp"
|
2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/Graphics/CTexture.hpp"
|
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
#include "Runtime/World/CPlayer.hpp"
|
|
|
|
#include "Runtime/World/CScriptPlatform.hpp"
|
|
|
|
#include "Runtime/Weapon/CEnergyProjectile.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2018-11-19 05:00:33 +00:00
|
|
|
|
2022-02-21 02:28:07 +00:00
|
|
|
#include "ConsoleVariables/CVarManager.hpp"
|
2016-04-27 19:59:38 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-04-27 19:59:38 +00:00
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
2016-12-19 18:27:58 +00:00
|
|
|
const zeus::CTransform& xf, ESpecialFunction func,
|
2017-11-13 06:19:18 +00:00
|
|
|
std::string_view lcName, float f1, float f2, float f3, float f4,
|
2016-12-19 18:27:58 +00:00
|
|
|
const zeus::CVector3f& vec, const zeus::CColor& col, bool active,
|
2018-12-08 05:30:43 +00:00
|
|
|
const CDamageInfo& dInfo, s32 aId1, s32 aId2,
|
|
|
|
CPlayerState::EItemType itemType, s16 sId1, s16 sId2, s16 sId3)
|
2016-09-02 15:26:29 +00:00
|
|
|
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(),
|
|
|
|
kInvalidUniqueId)
|
2016-12-19 18:27:58 +00:00
|
|
|
, xe8_function(func)
|
|
|
|
, xec_locatorName(lcName)
|
2019-03-09 08:58:27 +00:00
|
|
|
, xfc_float1(f1)
|
|
|
|
, x100_float2(f2)
|
|
|
|
, x104_float3(f3)
|
|
|
|
, x108_float4(f4)
|
|
|
|
, x10c_vector3f(vec)
|
|
|
|
, x118_color(col)
|
2016-12-19 18:27:58 +00:00
|
|
|
, x11c_damageInfo(dInfo)
|
2019-03-09 08:58:27 +00:00
|
|
|
, x170_sfx1(CSfxManager::TranslateSFXID(sId1))
|
|
|
|
, x172_sfx2(CSfxManager::TranslateSFXID(sId2))
|
|
|
|
, x174_sfx3(CSfxManager::TranslateSFXID(sId3))
|
2020-03-03 08:31:49 +00:00
|
|
|
, x184_(0.f)
|
2018-06-08 21:00:18 +00:00
|
|
|
, x1bc_areaSaveId(aId1)
|
|
|
|
, x1c0_layerIdx(aId2)
|
2020-04-20 04:57:50 +00:00
|
|
|
, x1c4_item(itemType) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (xe8_function == ESpecialFunction::HUDTarget) {
|
2020-03-03 08:31:49 +00:00
|
|
|
x1c8_touchBounds = {-1.f, 1.f};
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2017-01-15 03:07:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSpecialFunction::Think(float dt, CStateManager& mgr) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (!GetActive()) {
|
2019-03-10 09:37:36 +00:00
|
|
|
return;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (xe8_function) {
|
|
|
|
case ESpecialFunction::PlayerFollowLocator:
|
|
|
|
ThinkPlayerFollowLocator(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::SpinnerController:
|
|
|
|
ThinkSpinnerController(dt, mgr, ESpinnerControllerMode::Zero);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::ShotSpinnerController:
|
|
|
|
ThinkSpinnerController(dt, mgr, ESpinnerControllerMode::One);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::ObjectFollowLocator:
|
|
|
|
ThinkObjectFollowLocator(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::ObjectFollowObject:
|
|
|
|
ThinkObjectFollowObject(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::ChaffTarget:
|
|
|
|
ThinkChaffTarget(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::ViewFrustumTester: {
|
|
|
|
if (x1e4_28_frustumEntered) {
|
|
|
|
x1e4_28_frustumEntered = false;
|
|
|
|
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
if (x1e4_29_frustumExited) {
|
|
|
|
x1e4_29_frustumExited = false;
|
|
|
|
SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::SaveStation:
|
|
|
|
ThinkSaveStation(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::IntroBossRingController:
|
|
|
|
ThinkIntroBossRingController(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::RainSimulator:
|
|
|
|
ThinkRainSimulator(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::AreaDamage:
|
|
|
|
ThinkAreaDamage(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::ScaleActor:
|
|
|
|
ThinkActorScale(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::PlayerInAreaRelay:
|
|
|
|
ThinkPlayerInArea(dt, mgr);
|
|
|
|
break;
|
|
|
|
case ESpecialFunction::Billboard: {
|
|
|
|
if (x1e8_ && x1e5_26_displayBillboard) {
|
|
|
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
|
|
|
x1e5_26_displayBillboard = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-04-12 15:58:05 +00:00
|
|
|
|
|
|
|
constexpr std::array fxTranslation{
|
|
|
|
ERumbleFxId::Twenty, ERumbleFxId::One, ERumbleFxId::TwentyOne,
|
|
|
|
ERumbleFxId::TwentyTwo, ERumbleFxId::TwentyThree, ERumbleFxId::Zero,
|
|
|
|
};
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
|
|
|
if (GetActive() && msg == EScriptObjectMessage::Deactivate && xe8_function == ESpecialFunction::Billboard) {
|
|
|
|
mgr.SetPendingOnScreenTex(CAssetId(), zeus::CVector2i(), zeus::CVector2i());
|
2020-05-07 16:07:25 +00:00
|
|
|
if (x1e8_) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x1e8_ = TLockedToken<CTexture>();
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
x1e5_26_displayBillboard = false;
|
|
|
|
}
|
|
|
|
CActor::AcceptScriptMsg(msg, uid, mgr);
|
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
if (xe8_function == ESpecialFunction::ChaffTarget && msg == EScriptObjectMessage::InitializedInArea) {
|
2018-12-08 05:30:43 +00:00
|
|
|
AddMaterial(EMaterialTypes::Target, mgr);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (GetActive()) {
|
|
|
|
switch (xe8_function) {
|
|
|
|
case ESpecialFunction::HUDFadeIn: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
2019-03-09 08:58:27 +00:00
|
|
|
mgr.Player()->SetHudDisable(xfc_float1, 0.f, 0.5f);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::EscapeSequence: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Action && xfc_float1 >= 0.f) {
|
2019-03-09 08:58:27 +00:00
|
|
|
mgr.ResetEscapeSequenceTimer(xfc_float1);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::SpinnerController: {
|
|
|
|
switch (msg) {
|
|
|
|
case EScriptObjectMessage::Stop: {
|
|
|
|
x1e4_25_spinnerCanMove = false;
|
2018-05-20 05:01:17 +00:00
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Play: {
|
|
|
|
x1e4_25_spinnerCanMove = true;
|
2019-02-24 07:15:54 +00:00
|
|
|
mgr.Player()->SetAngularVelocityWR(zeus::CAxisAngle());
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Deactivate:
|
|
|
|
DeleteEmitter(x178_sfxHandle);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
case ESpecialFunction::ShotSpinnerController: {
|
|
|
|
switch (msg) {
|
|
|
|
case EScriptObjectMessage::Increment: {
|
|
|
|
x16c_ = zeus::clamp(0.f, x16c_ + 1.f, 1.f);
|
|
|
|
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::SetToMax: {
|
2020-08-23 17:06:01 +00:00
|
|
|
x16c_ = x104_float3;
|
2018-12-08 05:30:43 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::SetToZero: {
|
2019-03-09 08:58:27 +00:00
|
|
|
x16c_ = -0.5f * x104_float3;
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2018-05-20 05:01:17 +00:00
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
case ESpecialFunction::MapStation: {
|
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
|
|
|
mgr.MapWorldInfo()->SetMapStationUsed(true);
|
2020-04-09 23:55:27 +00:00
|
|
|
mgr.GetWorld()->GetMapWorld()->RecalculateWorldSphere(*mgr.MapWorldInfo(), *mgr.GetWorld());
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
case ESpecialFunction::MissileStation: {
|
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
2020-03-28 00:50:42 +00:00
|
|
|
CPlayerState& pState = *mgr.GetPlayerState();
|
2018-12-08 05:30:43 +00:00
|
|
|
pState.ResetAndIncrPickUp(CPlayerState::EItemType::Missiles,
|
|
|
|
pState.GetItemCapacity(CPlayerState::EItemType::Missiles));
|
|
|
|
}
|
|
|
|
break;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
case ESpecialFunction::PowerBombStation: {
|
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
2020-03-28 00:50:42 +00:00
|
|
|
CPlayerState& pState = *mgr.GetPlayerState();
|
2018-12-08 05:30:43 +00:00
|
|
|
pState.ResetAndIncrPickUp(CPlayerState::EItemType::PowerBombs,
|
|
|
|
pState.GetItemCapacity(CPlayerState::EItemType::PowerBombs));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::SaveStation: {
|
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
|
|
|
g_GameState->GetPlayerState()->IncrPickup(CPlayerState::EItemType::EnergyTanks, 1);
|
2020-05-07 16:07:25 +00:00
|
|
|
if (g_GameState->GetCardSerial() == 0) {
|
2018-12-08 05:30:43 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.DeferStateTransition(EStateManagerTransition::SaveGame);
|
|
|
|
x1e5_24_doSave = true;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::IntroBossRingController: {
|
2019-03-09 08:58:27 +00:00
|
|
|
if (x1a8_ringState != ERingState::Breakup) {
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (msg) {
|
|
|
|
case EScriptObjectMessage::Play: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (x1a8_ringState != ERingState::Scramble) {
|
2018-12-08 05:30:43 +00:00
|
|
|
RingScramble(mgr);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
for (SRingController& cont : x198_ringControllers) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(cont.x0_id)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
cont.xc_ = act->GetTransform().frontVector();
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2019-02-24 07:15:54 +00:00
|
|
|
cont.xc_ = zeus::skForward;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
2019-03-09 08:58:27 +00:00
|
|
|
x1a8_ringState = ERingState::Breakup;
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
case EScriptObjectMessage::SetToZero: {
|
2019-03-09 08:58:27 +00:00
|
|
|
x1a8_ringState = ERingState::Rotate;
|
|
|
|
x1ac_ringRotateTarget = GetTranslation() - mgr.GetPlayer().GetTranslation();
|
|
|
|
x1ac_ringRotateTarget.z() = 0.f;
|
|
|
|
x1ac_ringRotateTarget.normalize();
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
case EScriptObjectMessage::Action: {
|
|
|
|
RingScramble(mgr);
|
|
|
|
break;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
case EScriptObjectMessage::InitializedInArea: {
|
|
|
|
x198_ringControllers.reserve(3);
|
|
|
|
for (const SConnection& conn : x20_conns) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate) {
|
2018-12-08 05:30:43 +00:00
|
|
|
continue;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
|
|
|
for (auto it = search.first; it != search.second; ++it) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(it->second)) {
|
2020-03-21 04:12:13 +00:00
|
|
|
x198_ringControllers.emplace_back(it->second, 0.f, false);
|
2018-12-08 05:30:43 +00:00
|
|
|
act->RemoveMaterial(EMaterialTypes::Occluder, mgr);
|
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2019-03-09 08:58:27 +00:00
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2019-03-09 08:58:27 +00:00
|
|
|
std::sort(x198_ringControllers.begin(), x198_ringControllers.end(),
|
|
|
|
[&mgr](const SRingController& a, const SRingController& b) {
|
2020-05-07 16:07:25 +00:00
|
|
|
const TCastToConstPtr<CActor> actA(mgr.GetObjectById(a.x0_id));
|
|
|
|
const TCastToConstPtr<CActor> actB(mgr.GetObjectById(b.x0_id));
|
|
|
|
if (actA && actB) {
|
2019-03-09 08:58:27 +00:00
|
|
|
return actA->GetTranslation().z() < actB->GetTranslation().z();
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-03-09 08:58:27 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
for (auto& rc : x198_ringControllers) {
|
|
|
|
rc.x4_rotateSpeed = (x1b8_ringReverse ? 1.f : -1.f) * xfc_float1;
|
|
|
|
rc.x8_reachedTarget = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2018-06-08 21:00:18 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
default:
|
|
|
|
break;
|
2018-11-19 05:00:33 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::RadialDamage: {
|
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
|
|
|
CDamageInfo dInfo = x11c_damageInfo;
|
2019-03-09 08:58:27 +00:00
|
|
|
dInfo.SetRadius(xfc_float1);
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.ApplyDamageToWorld(GetUniqueId(), *this, GetTranslation(), dInfo,
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {0ull}));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::BossEnergyBar: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Increment) {
|
2019-03-09 08:58:27 +00:00
|
|
|
mgr.SetBossParams(uid, xfc_float1, u32(x100_float2) + 86);
|
2020-05-07 16:07:25 +00:00
|
|
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.SetBossParams(kInvalidUniqueId, 0.f, 0);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::EndGame: {
|
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
|
|
|
switch (GetSpecialEnding(mgr)) {
|
|
|
|
case 0:
|
2021-06-03 23:47:04 +00:00
|
|
|
g_Main->SetFlowState(EClientFlowStates::WinBad);
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2021-06-03 23:47:04 +00:00
|
|
|
g_Main->SetFlowState(EClientFlowStates::WinGood);
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2021-06-03 23:47:04 +00:00
|
|
|
g_Main->SetFlowState(EClientFlowStates::WinBest);
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
2018-11-19 05:00:33 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.SetShouldQuitGame(true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::CinematicSkip: {
|
|
|
|
if (msg == EScriptObjectMessage::Increment) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (ShouldSkipCinematic(mgr)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.SetSkipCinematicSpecialFunction(GetUniqueId());
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
|
|
|
mgr.SetSkipCinematicSpecialFunction(kInvalidUniqueId);
|
|
|
|
g_GameState->SystemOptions().SetCinematicState(mgr.GetWorld()->GetWorldAssetId(), GetEditorId(), true);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::ScriptLayerController: {
|
|
|
|
if (msg == EScriptObjectMessage::Decrement || msg == EScriptObjectMessage::Increment) {
|
|
|
|
if (x1bc_areaSaveId != -1 && x1c0_layerIdx != -1) {
|
|
|
|
TAreaId aId = mgr.GetWorld()->GetAreaIdForSaveId(x1bc_areaSaveId);
|
2021-06-04 06:08:05 +00:00
|
|
|
std::shared_ptr<CScriptLayerManager> worldLayerState;
|
2020-05-07 16:07:25 +00:00
|
|
|
if (aId != kInvalidAreaId) {
|
2019-08-14 14:58:54 +00:00
|
|
|
worldLayerState = mgr.WorldLayerState();
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2021-06-07 19:29:18 +00:00
|
|
|
const std::pair<CAssetId, TAreaId> worldAreaPair =
|
|
|
|
g_MemoryCardSys->GetAreaAndWorldIdForSaveId(x1bc_areaSaveId);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (worldAreaPair.first.IsValid()) {
|
|
|
|
worldLayerState = g_GameState->StateForWorld(worldAreaPair.first).GetLayerState();
|
|
|
|
aId = worldAreaPair.second;
|
2018-11-19 05:00:33 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
if (aId != kInvalidAreaId) {
|
2018-12-08 05:30:43 +00:00
|
|
|
worldLayerState->SetLayerActive(aId, x1c0_layerIdx, msg == EScriptObjectMessage::Increment);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-11-19 05:00:33 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
For some bizarre reason ScriptLayerController drops into EnvFxDensityController
|
|
|
|
[[fallthrough]];
|
|
|
|
We won't do that though
|
|
|
|
*/
|
|
|
|
case ESpecialFunction::EnvFxDensityController: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
2019-03-09 08:58:27 +00:00
|
|
|
mgr.GetEnvFxManager()->SetFxDensity(s32(x100_float2), xfc_float1);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-10-09 17:07:51 +00:00
|
|
|
case ESpecialFunction::RumbleEffect: {
|
|
|
|
if (msg != EScriptObjectMessage::Action) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
int rumbFxIdx = int(x100_float2);
|
|
|
|
if (rumbFxIdx < 0 || rumbFxIdx >= fxTranslation.size()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
ERumbleFxId rumbFx = fxTranslation[rumbFxIdx];
|
2022-10-16 19:04:26 +00:00
|
|
|
u32 param3 = x104_float3;
|
2022-10-09 17:07:51 +00:00
|
|
|
if ((param3 & 1) != 0) {
|
|
|
|
mgr.GetRumbleManager().Rumble(mgr, rumbFx, 1.f, ERumblePriority::One);
|
|
|
|
} else {
|
|
|
|
zeus::CVector3f pos = GetTranslation();
|
|
|
|
if ((param3 & 2) != 0) {
|
|
|
|
if (const CActor* act = TCastToConstPtr<CActor>(mgr.GetObjectById(uid))) {
|
|
|
|
pos = act->GetTranslation();
|
|
|
|
}
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2022-10-09 17:07:51 +00:00
|
|
|
mgr.GetRumbleManager().Rumble(mgr, pos, rumbFx, xfc_float1, ERumblePriority::One);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
break;
|
2022-10-09 17:07:51 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
case ESpecialFunction::InventoryActivator: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Action && mgr.GetPlayerState()->HasPowerUp(x1c4_item)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::FusionRelay: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Action && mgr.GetPlayerState()->IsFusionEnabled()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::AreaDamage: {
|
2019-11-24 15:01:07 +00:00
|
|
|
if ((msg == EScriptObjectMessage::Deleted || msg == EScriptObjectMessage::Deactivate) && x1e4_31_inAreaDamage) {
|
|
|
|
x1e4_31_inAreaDamage = false;
|
|
|
|
mgr.GetPlayer().DecrementEnvironmentDamage();
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.SetIsFullThreat(false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::DropBomb: {
|
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (xfc_float1 >= 1.f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetPlayer().GetPlayerGun()->DropBomb(CPlayerGun::EBWeapon::PowerBomb, mgr);
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.GetPlayer().GetPlayerGun()->DropBomb(CPlayerGun::EBWeapon::Bomb, mgr);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::RedundantHintSystem: {
|
|
|
|
CHintOptions& hintOptions = g_GameState->HintOptions();
|
2020-03-14 23:59:58 +00:00
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
|
|
|
hintOptions.ActivateContinueDelayHintTimer(xec_locatorName);
|
|
|
|
} else if (msg == EScriptObjectMessage::Increment) {
|
|
|
|
hintOptions.ActivateImmediateHintTimer(xec_locatorName);
|
|
|
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
|
|
|
hintOptions.DelayHint(xec_locatorName);
|
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::Billboard: {
|
|
|
|
if (msg == EScriptObjectMessage::Increment) {
|
|
|
|
const SObjectTag* objectTag = g_ResFactory->GetResourceIdByName(xec_locatorName);
|
2020-05-07 16:07:25 +00:00
|
|
|
const CAssetId assetId = objectTag ? objectTag->id : CAssetId();
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2019-03-09 08:58:27 +00:00
|
|
|
mgr.SetPendingOnScreenTex(assetId, {int(x104_float3), int(x108_float4)}, {int(xfc_float1), int(x100_float2)});
|
2018-12-08 05:30:43 +00:00
|
|
|
if (objectTag) {
|
|
|
|
x1e8_ = g_SimplePool->GetObj(*objectTag);
|
|
|
|
x1e5_26_displayBillboard = true;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
2019-03-09 08:58:27 +00:00
|
|
|
mgr.SetPendingOnScreenTex({}, {int(x104_float3), int(x108_float4)}, {int(xfc_float1), int(x100_float2)});
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x1e8_)
|
|
|
|
x1e8_ = TLockedToken<CTexture>();
|
|
|
|
x1e5_26_displayBillboard = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::PlayerInAreaRelay: {
|
|
|
|
if ((msg == EScriptObjectMessage::Action || msg == EScriptObjectMessage::SetToZero) &&
|
|
|
|
GetAreaIdAlways() == mgr.GetPlayer().GetAreaIdAlways()) {
|
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::HUDTarget: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Increment) {
|
2018-12-08 05:30:43 +00:00
|
|
|
AddMaterial(EMaterialTypes::Target, EMaterialTypes::RadarObject, mgr);
|
2020-05-07 16:07:25 +00:00
|
|
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
2018-12-08 05:30:43 +00:00
|
|
|
RemoveMaterial(EMaterialTypes::Target, EMaterialTypes::RadarObject, mgr);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::FogFader: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Increment) {
|
2019-03-09 08:58:27 +00:00
|
|
|
mgr.GetCameraManager()->SetFogDensity(x100_float2, xfc_float1);
|
2020-05-07 16:07:25 +00:00
|
|
|
} else if (msg == EScriptObjectMessage::Decrement) {
|
2019-03-09 08:58:27 +00:00
|
|
|
mgr.GetCameraManager()->SetFogDensity(x100_float2, 1.f);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
case ESpecialFunction::EnterLogbook: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Action) {
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr.DeferStateTransition(EStateManagerTransition::LogBook);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ESpecialFunction::Ending: {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (msg == EScriptObjectMessage::Action && GetSpecialEnding(mgr) == u32(xfc_float1)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-02-18 05:47:46 +00:00
|
|
|
break;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
2019-11-24 15:01:07 +00:00
|
|
|
void CScriptSpecialFunction::PreRender(CStateManager&, const zeus::CFrustum& frustum) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (xe8_function != ESpecialFunction::FogVolume && xe8_function != ESpecialFunction::ViewFrustumTester) {
|
2019-11-24 15:01:07 +00:00
|
|
|
return;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
|
|
|
if (!GetActive()) {
|
2019-11-24 15:01:07 +00:00
|
|
|
return;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-11-24 15:01:07 +00:00
|
|
|
|
|
|
|
bool val;
|
|
|
|
if (xe8_function == ESpecialFunction::FogVolume) {
|
|
|
|
val = frustum.aabbFrustumTest(zeus::CAABox(GetTranslation() - x10c_vector3f, GetTranslation() + x10c_vector3f));
|
|
|
|
} else {
|
|
|
|
val = frustum.pointFrustumTest(GetTranslation());
|
|
|
|
}
|
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
if (x1e4_30_ == val) {
|
2019-11-24 15:01:07 +00:00
|
|
|
return;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2022-10-09 17:07:51 +00:00
|
|
|
if (val) {
|
2019-11-24 15:01:07 +00:00
|
|
|
x1e4_28_frustumEntered = true;
|
2022-10-09 17:07:51 +00:00
|
|
|
} else {
|
|
|
|
x1e4_29_frustumExited = true;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2022-10-09 17:07:51 +00:00
|
|
|
x1e4_30_ = val;
|
2019-11-24 15:01:07 +00:00
|
|
|
}
|
|
|
|
|
2020-04-05 11:54:02 +00:00
|
|
|
void CScriptSpecialFunction::AddToRenderer(const zeus::CFrustum&, CStateManager& mgr) {
|
|
|
|
if (!GetActive()) {
|
2019-11-24 15:01:07 +00:00
|
|
|
return;
|
2020-04-05 11:54:02 +00:00
|
|
|
}
|
2019-11-24 15:01:07 +00:00
|
|
|
|
2020-04-05 11:54:02 +00:00
|
|
|
if (xe8_function == ESpecialFunction::FogVolume && x1e4_30_) {
|
2019-11-24 15:01:07 +00:00
|
|
|
EnsureRendered(mgr);
|
2020-04-05 11:54:02 +00:00
|
|
|
}
|
2019-11-24 15:01:07 +00:00
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2020-04-09 17:28:20 +00:00
|
|
|
void CScriptSpecialFunction::Render(CStateManager& mgr) {
|
2019-11-24 15:01:07 +00:00
|
|
|
if (xe8_function == ESpecialFunction::FogVolume) {
|
2022-10-09 17:07:51 +00:00
|
|
|
const float z = mgr.IntegrateVisorFog(xfc_float1 * std::sin(CGraphics::GetSecondsMod900() * x100_float2));
|
2019-11-24 15:01:07 +00:00
|
|
|
if (z > 0.f) {
|
|
|
|
zeus::CVector3f max = GetTranslation() + x10c_vector3f;
|
|
|
|
max.z() += z;
|
2020-05-07 16:07:25 +00:00
|
|
|
const zeus::CAABox box(GetTranslation() - x10c_vector3f, max);
|
2021-06-07 19:29:18 +00:00
|
|
|
const zeus::CTransform modelMtx =
|
|
|
|
zeus::CTransform::Translate(box.center()) * zeus::CTransform::Scale(box.extents());
|
2019-11-24 15:01:07 +00:00
|
|
|
g_Renderer->SetModelMatrix(modelMtx);
|
|
|
|
g_Renderer->RenderFogVolume(x118_color, zeus::CAABox(-1.f, 1.f), nullptr, nullptr);
|
|
|
|
}
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2019-11-24 15:01:07 +00:00
|
|
|
CActor::Render(mgr);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-11-24 15:01:07 +00:00
|
|
|
}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSpecialFunction::SkipCinematic(CStateManager& stateMgr) {
|
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
|
|
|
stateMgr.SetSkipCinematicSpecialFunction(kInvalidUniqueId);
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
2019-03-09 08:58:27 +00:00
|
|
|
void CScriptSpecialFunction::RingScramble(CStateManager& mgr) {
|
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
|
|
|
x1a8_ringState = ERingState::Scramble;
|
|
|
|
x1b8_ringReverse = !x1b8_ringReverse;
|
|
|
|
float dir = (x1b8_ringReverse ? 1.f : -1.f);
|
|
|
|
for (auto& rc : x198_ringControllers) {
|
|
|
|
rc.x4_rotateSpeed = dir * mgr.GetActiveRandom()->Range(x100_float2, x104_float3);
|
|
|
|
dir = -dir;
|
|
|
|
rc.x8_reachedTarget = false;
|
|
|
|
}
|
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2019-03-09 08:58:27 +00:00
|
|
|
void CScriptSpecialFunction::ThinkIntroBossRingController(float dt, CStateManager& mgr) {
|
|
|
|
if (x1a8_ringState != ERingState::Breakup) {
|
|
|
|
for (const auto& rc : x198_ringControllers) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(rc.x0_id)) {
|
2019-03-09 08:58:27 +00:00
|
|
|
zeus::CTransform newXf = act->GetTransform();
|
|
|
|
newXf.rotateLocalZ(zeus::degToRad(rc.x4_rotateSpeed * dt));
|
|
|
|
act->SetTransform(newXf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch (x1a8_ringState) {
|
|
|
|
case ERingState::Breakup: {
|
|
|
|
float minMag = 0.f;
|
|
|
|
for (const auto& rc : x198_ringControllers) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(rc.x0_id)) {
|
2019-03-09 08:58:27 +00:00
|
|
|
act->SetTranslation(act->GetTransform().basis[1] * 50.f * dt + act->GetTranslation());
|
|
|
|
minMag = std::min(act->GetTranslation().magnitude(), minMag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CalculateRenderBounds();
|
|
|
|
if (minMag != 0.f) {
|
|
|
|
/* Never actually happens */
|
|
|
|
for (const auto& rc : x198_ringControllers) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (CEntity* ent = mgr.ObjectById(rc.x0_id)) {
|
2019-03-09 08:58:27 +00:00
|
|
|
ent->SetActive(false);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-03-09 08:58:27 +00:00
|
|
|
}
|
|
|
|
SetActive(false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ERingState::Rotate: {
|
|
|
|
x1ac_ringRotateTarget =
|
2019-11-24 15:01:07 +00:00
|
|
|
zeus::CQuaternion::fromAxisAngle(zeus::skUp, zeus::degToRad(xfc_float1 * (x1b8_ringReverse ? 1.f : -1.f) * dt))
|
|
|
|
.transform(x1ac_ringRotateTarget);
|
2019-03-09 08:58:27 +00:00
|
|
|
bool allReachedTarget = true;
|
|
|
|
for (auto& rc : x198_ringControllers) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(rc.x0_id)) {
|
2019-03-09 08:58:27 +00:00
|
|
|
zeus::CVector3f lookDirFlat = act->GetTransform().basis[1];
|
|
|
|
lookDirFlat.z() = 0.f;
|
|
|
|
lookDirFlat.normalize();
|
|
|
|
if (std::acos(zeus::clamp(-1.f, lookDirFlat.dot(x1ac_ringRotateTarget), 1.f)) <=
|
|
|
|
zeus::degToRad((xfc_float1 + std::fabs(rc.x4_rotateSpeed)) / 30.f)) {
|
|
|
|
zeus::CTransform newXf = zeus::lookAt(zeus::skZero3f, x1ac_ringRotateTarget);
|
|
|
|
newXf.origin = act->GetTranslation();
|
|
|
|
act->SetTransform(newXf);
|
|
|
|
rc.x4_rotateSpeed = (x1b8_ringReverse ? 1.f : -1.f) * xfc_float1;
|
|
|
|
rc.x8_reachedTarget = true;
|
|
|
|
} else {
|
|
|
|
allReachedTarget = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (allReachedTarget) {
|
|
|
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
|
|
|
x1a8_ringState = ERingState::Stopped;
|
2020-05-07 16:07:25 +00:00
|
|
|
for (auto& rc : x198_ringControllers) {
|
2019-03-09 08:58:27 +00:00
|
|
|
rc.x8_reachedTarget = false;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-03-09 08:58:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2019-04-16 08:00:46 +00:00
|
|
|
void CScriptSpecialFunction::ThinkPlayerFollowLocator(float, CStateManager& mgr) {
|
|
|
|
for (const SConnection& conn : GetConnectionList()) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto search = mgr.GetIdListForScript(conn.x8_objId);
|
|
|
|
for (auto it = search.first; it != search.second; ++it) {
|
|
|
|
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(it->second)) {
|
2022-10-09 17:07:51 +00:00
|
|
|
if (!act->GetModelData() || !act->GetModelData()->HasAnimData()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
const zeus::CTransform xf = act->GetTransform() * act->GetLocatorTransform(xec_locatorName);
|
|
|
|
CPlayer& pl = mgr.GetPlayer();
|
|
|
|
pl.SetTransform(xf);
|
|
|
|
pl.SetVelocityWR({});
|
|
|
|
pl.SetAngularVelocityWR({});
|
|
|
|
pl.ClearForcesAndTorques();
|
|
|
|
return;
|
2019-04-16 08:00:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-10 03:15:26 +00:00
|
|
|
void CScriptSpecialFunction::ThinkSpinnerController(float dt, CStateManager& mgr, ESpinnerControllerMode mode) {
|
2020-05-07 16:07:25 +00:00
|
|
|
const bool allowWrap = xec_locatorName.find("AllowWrap") != std::string::npos;
|
|
|
|
const bool noBackward = xec_locatorName.find("NoBackward") != std::string::npos;
|
|
|
|
const float pointOneByDt = 0.1f * dt;
|
|
|
|
const float twoByDt = 2.f * dt;
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2019-06-11 03:09:38 +00:00
|
|
|
for (const SConnection& conn : x20_conns) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate) {
|
2019-06-11 03:09:38 +00:00
|
|
|
continue;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
const auto search = mgr.GetIdListForScript(conn.x8_objId);
|
2019-06-11 03:09:38 +00:00
|
|
|
for (auto it = search.first; it != search.second; ++it) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (const TCastToPtr<CScriptPlatform> plat = mgr.ObjectById((*it).second)) {
|
2019-06-11 03:09:38 +00:00
|
|
|
if (plat->HasModelData() && plat->GetModelData()->HasAnimData()) {
|
|
|
|
plat->SetControlledAnimation(true);
|
2020-08-23 17:06:01 +00:00
|
|
|
if (!x1e4_24_spinnerInitializedXf) {
|
|
|
|
x13c_spinnerInitialXf = plat->GetTransform();
|
|
|
|
x1e4_24_spinnerInitializedXf = true;
|
2019-06-11 03:09:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float f28 = x138_;
|
2020-05-07 16:07:25 +00:00
|
|
|
const float f29 = pointOneByDt * x100_float2;
|
2019-06-11 03:09:38 +00:00
|
|
|
|
|
|
|
if (mode == ESpinnerControllerMode::Zero) {
|
|
|
|
if (x1e4_25_spinnerCanMove) {
|
2020-05-07 16:07:25 +00:00
|
|
|
const CPlayer& pl = mgr.GetPlayer();
|
|
|
|
const zeus::CVector3f angVel = pl.GetAngularVelocityOR().getVector();
|
2019-06-11 03:09:38 +00:00
|
|
|
float mag = 0.f;
|
2020-05-07 16:07:25 +00:00
|
|
|
if (angVel.canBeNormalized()) {
|
2019-06-11 03:09:38 +00:00
|
|
|
mag = angVel.magnitude();
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
const float spinImpulse =
|
2019-11-24 15:01:07 +00:00
|
|
|
(pl.GetMorphballTransitionState() == CPlayer::EPlayerMorphBallState::Morphed ? 0.025f * mag : 0.f);
|
2020-05-07 16:07:25 +00:00
|
|
|
if (spinImpulse >= x180_) {
|
2019-06-11 03:09:38 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Play, mgr, EScriptObjectMessage::None);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
|
|
|
x180_ = spinImpulse;
|
|
|
|
x138_ += 0.01f * spinImpulse * xfc_float1;
|
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
if (!noBackward) {
|
2019-06-11 03:09:38 +00:00
|
|
|
x138_ -= f29;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
} else if (!noBackward) {
|
2020-03-03 08:31:49 +00:00
|
|
|
x138_ = f28 - twoByDt;
|
2019-06-11 03:09:38 +00:00
|
|
|
}
|
|
|
|
} else if (mode == ESpinnerControllerMode::One) {
|
2020-08-23 17:06:01 +00:00
|
|
|
x138_ = (0.01f * x16c_) * xfc_float1 + f28;
|
2019-06-11 03:09:38 +00:00
|
|
|
|
|
|
|
if (!noBackward) {
|
|
|
|
x138_ -= f29;
|
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
if (std::fabs(x16c_) < dt) {
|
2019-06-11 03:09:38 +00:00
|
|
|
x16c_ = 0.f;
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2020-03-03 08:31:49 +00:00
|
|
|
x16c_ -= (dt * (x16c_ <= 0.f ? -1.f : 1.f));
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
}
|
2020-03-03 08:31:49 +00:00
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
2020-03-03 08:31:49 +00:00
|
|
|
if (allowWrap) {
|
|
|
|
x138_ = std::fmod(x138_, 1.f);
|
2020-05-07 16:07:25 +00:00
|
|
|
if (x138_ < 0.f) {
|
2020-03-03 08:31:49 +00:00
|
|
|
x138_ += 1.f;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2020-03-03 08:31:49 +00:00
|
|
|
} else {
|
|
|
|
x138_ = zeus::clamp(0.f, x138_, 1.f);
|
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
2020-03-03 08:31:49 +00:00
|
|
|
bool r23 = true;
|
2020-08-23 17:06:01 +00:00
|
|
|
f28 = x138_ - f28; // always 0?
|
2020-03-03 08:31:49 +00:00
|
|
|
if (zeus::close_enough(x138_, 1.f, FLT_EPSILON)) {
|
|
|
|
if (!x1e4_27_sfx3Played) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (x174_sfx3 != 0xFFFF) {
|
2020-03-03 08:31:49 +00:00
|
|
|
CSfxManager::AddEmitter(x174_sfx3, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
2020-03-03 08:31:49 +00:00
|
|
|
x1e4_27_sfx3Played = true;
|
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
2020-03-03 08:31:49 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
|
|
|
r23 = false;
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2020-03-03 08:31:49 +00:00
|
|
|
x1e4_27_sfx3Played = false;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
2020-03-03 08:31:49 +00:00
|
|
|
if (zeus::close_enough(x138_, 0.f, FLT_EPSILON)) {
|
|
|
|
if (!x1e4_26_sfx2Played) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (x172_sfx2 != 0xFFFF) {
|
2020-03-03 08:31:49 +00:00
|
|
|
CSfxManager::AddEmitter(x172_sfx2, GetTranslation(), {}, true, false, 0x7F, kInvalidAreaId);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
2020-03-03 08:31:49 +00:00
|
|
|
x1e4_26_sfx2Played = true;
|
|
|
|
}
|
2019-06-11 03:09:38 +00:00
|
|
|
|
2020-03-03 08:31:49 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
|
|
|
r23 = false;
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2020-03-03 08:31:49 +00:00
|
|
|
x1e4_26_sfx2Played = false;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2020-03-03 08:31:49 +00:00
|
|
|
|
|
|
|
if (r23) {
|
|
|
|
if (x170_sfx1 != 0xFFFF) {
|
2020-08-23 17:06:01 +00:00
|
|
|
x184_.AddValue(0.f <= f28 ? 100 : 0x7f);
|
2020-05-07 16:07:25 +00:00
|
|
|
const std::optional<float> avg = x184_.GetAverage();
|
2020-03-03 08:31:49 +00:00
|
|
|
AddOrUpdateEmitter(0.f <= f28 ? x108_float4 : 1.f, x178_sfxHandle, x170_sfx1, GetTranslation(),
|
|
|
|
avg.value());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DeleteEmitter(x178_sfxHandle);
|
2019-06-11 03:09:38 +00:00
|
|
|
}
|
2020-03-03 08:31:49 +00:00
|
|
|
|
|
|
|
CAnimData* animData = plat->GetModelData()->GetAnimationData();
|
2020-05-07 16:07:25 +00:00
|
|
|
const float dur = animData->GetAnimationDuration(animData->GetDefaultAnimation()) * x138_;
|
2020-03-03 08:31:49 +00:00
|
|
|
animData->SetPhase(0.f);
|
|
|
|
animData->SetPlaybackRate(1.f);
|
|
|
|
const SAdvancementDeltas& deltas = plat->UpdateAnimation(dur, mgr, true);
|
2020-08-23 17:06:01 +00:00
|
|
|
plat->SetTransform(x13c_spinnerInitialXf * deltas.xc_rotDelta.toTransform(deltas.x0_posDelta));
|
2019-06-11 03:09:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-16 08:00:46 +00:00
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2019-02-03 21:20:05 +00:00
|
|
|
void CScriptSpecialFunction::ThinkObjectFollowLocator(float, CStateManager& mgr) {
|
|
|
|
TUniqueId followerAct = kInvalidUniqueId;
|
|
|
|
TUniqueId followedAct = kInvalidUniqueId;
|
|
|
|
for (const SConnection& conn : x20_conns) {
|
2019-11-24 15:01:07 +00:00
|
|
|
if (conn.x0_state != EScriptObjectState::Play ||
|
2020-05-07 16:07:25 +00:00
|
|
|
(conn.x4_msg != EScriptObjectMessage::Activate && conn.x4_msg != EScriptObjectMessage::Deactivate)) {
|
2019-02-03 21:20:05 +00:00
|
|
|
continue;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-02-03 21:20:05 +00:00
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
const auto search = mgr.GetIdListForScript(conn.x8_objId);
|
2019-02-03 21:20:05 +00:00
|
|
|
for (auto it = search.first; it != search.second; ++it) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(it->second)) {
|
2019-02-03 21:20:05 +00:00
|
|
|
if (conn.x4_msg == EScriptObjectMessage::Activate &&
|
|
|
|
(act->HasModelData() && act->GetModelData()->HasAnimData()) && act->GetActive()) {
|
|
|
|
followedAct = it->second;
|
|
|
|
} else if (conn.x4_msg == EScriptObjectMessage::Deactivate) {
|
|
|
|
followerAct = it->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
if (followerAct == kInvalidUniqueId || followedAct == kInvalidUniqueId) {
|
2019-02-03 21:20:05 +00:00
|
|
|
return;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-02-03 21:20:05 +00:00
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
const TCastToConstPtr<CActor> fromAct = mgr.GetObjectById(followedAct);
|
|
|
|
const TCastToPtr<CActor> toAct = mgr.ObjectById(followerAct);
|
2019-02-03 21:20:05 +00:00
|
|
|
toAct->SetTransform(fromAct->GetTransform() * fromAct->GetScaledLocatorTransform(xec_locatorName));
|
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2019-05-10 02:33:56 +00:00
|
|
|
void CScriptSpecialFunction::ThinkObjectFollowObject(float, CStateManager& mgr) {
|
|
|
|
TUniqueId followerAct = kInvalidUniqueId;
|
|
|
|
TUniqueId followedAct = kInvalidUniqueId;
|
|
|
|
for (const SConnection& conn : x20_conns) {
|
2019-11-24 15:01:07 +00:00
|
|
|
if (conn.x0_state != EScriptObjectState::Play ||
|
2020-05-07 16:07:25 +00:00
|
|
|
(conn.x4_msg != EScriptObjectMessage::Activate && conn.x4_msg != EScriptObjectMessage::Deactivate)) {
|
2019-05-10 02:33:56 +00:00
|
|
|
continue;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-05-10 02:33:56 +00:00
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
const auto search = mgr.GetIdListForScript(conn.x8_objId);
|
2019-05-10 02:33:56 +00:00
|
|
|
for (auto it = search.first; it != search.second; ++it) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(it->second)) {
|
2019-05-10 02:33:56 +00:00
|
|
|
if (conn.x4_msg == EScriptObjectMessage::Activate && act->GetActive()) {
|
|
|
|
followedAct = it->second;
|
|
|
|
} else if (conn.x4_msg == EScriptObjectMessage::Deactivate) {
|
|
|
|
followerAct = it->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
const TCastToConstPtr<CActor> followed = mgr.GetObjectById(followedAct);
|
|
|
|
const TCastToPtr<CActor> follower = mgr.ObjectById(followerAct);
|
|
|
|
if (followed && follower) {
|
2019-05-10 02:33:56 +00:00
|
|
|
follower->SetTransform(followed->GetTransform());
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-05-10 02:33:56 +00:00
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2019-05-10 02:33:56 +00:00
|
|
|
void CScriptSpecialFunction::ThinkChaffTarget(float dt, CStateManager& mgr) {
|
2022-10-09 17:07:51 +00:00
|
|
|
const zeus::CAABox box(GetTranslation() - 5.f, GetTranslation() + 5.f);
|
2021-06-07 00:07:45 +00:00
|
|
|
EntityList nearList;
|
2019-05-10 02:33:56 +00:00
|
|
|
mgr.BuildNearList(nearList, box, CMaterialFilter::MakeInclude({EMaterialTypes::Projectile}), nullptr);
|
|
|
|
|
2020-09-18 21:04:50 +00:00
|
|
|
for (const auto& uid : nearList) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (const TCastToPtr<CEnergyProjectile> proj = mgr.ObjectById(uid)) {
|
2019-05-10 02:33:56 +00:00
|
|
|
if (proj->GetHomingTargetId() == GetUniqueId()) {
|
|
|
|
proj->Set3d0_26(true);
|
|
|
|
if (mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {
|
|
|
|
mgr.GetPlayer().SetHudDisable(x100_float2, 0.5f, 2.5f);
|
2022-10-09 17:07:51 +00:00
|
|
|
x194_ = xfc_float1;
|
|
|
|
|
|
|
|
auto& filter = mgr.GetCameraFilterPass(7);
|
2019-05-10 03:15:26 +00:00
|
|
|
filter.SetFilter(EFilterType::Blend, EFilterShape::Fullscreen, 0.f, zeus::skWhite, CAssetId());
|
2019-05-10 02:33:56 +00:00
|
|
|
filter.DisableFilter(0.1f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x194_ = zeus::max(0.f, x194_ - dt);
|
|
|
|
if (x194_ != 0.f && mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {
|
2019-05-10 03:15:26 +00:00
|
|
|
float intfMag = x104_float3 * (0.5f + ((0.5f + x194_) / xfc_float1));
|
2020-05-07 16:07:25 +00:00
|
|
|
if (x194_ < 1.f) {
|
2019-05-10 02:33:56 +00:00
|
|
|
intfMag *= x194_;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-05-10 02:33:56 +00:00
|
|
|
|
|
|
|
mgr.GetPlayerState()->GetStaticInterference().AddSource(GetUniqueId(), intfMag, .5f);
|
|
|
|
|
2022-10-09 17:07:51 +00:00
|
|
|
if (mgr.GetPlayerState()->GetCurrentVisor() != CPlayerState::EPlayerVisor::Thermal) {
|
2019-05-10 03:15:26 +00:00
|
|
|
mgr.GetPlayer().AddOrbitDisableSource(mgr, GetUniqueId());
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2019-05-10 02:33:56 +00:00
|
|
|
mgr.GetPlayer().RemoveOrbitDisableSource(GetUniqueId());
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-05-10 02:33:56 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSpecialFunction::ThinkActorScale(float dt, CStateManager& mgr) {
|
2020-05-07 16:07:25 +00:00
|
|
|
const float deltaScale = dt * xfc_float1;
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
for (const SConnection& conn : x20_conns) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate) {
|
2018-12-08 05:30:43 +00:00
|
|
|
continue;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) {
|
2019-08-14 14:58:54 +00:00
|
|
|
CModelData* mData = act->GetModelData();
|
2018-12-08 05:30:43 +00:00
|
|
|
if (mData && (mData->HasAnimData() || mData->HasNormalModel())) {
|
|
|
|
zeus::CVector3f scale = mData->GetScale();
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2020-05-07 16:07:25 +00:00
|
|
|
if (deltaScale > 0.f) {
|
2019-03-09 08:58:27 +00:00
|
|
|
scale = zeus::min(zeus::CVector3f(deltaScale) + scale, zeus::CVector3f(x100_float2));
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2019-03-09 08:58:27 +00:00
|
|
|
scale = zeus::max(zeus::CVector3f(deltaScale) + scale, zeus::CVector3f(x100_float2));
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
mData->SetScale(scale);
|
|
|
|
}
|
2017-08-29 13:17:52 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-02-18 02:19:50 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSpecialFunction::ThinkSaveStation(float, CStateManager& mgr) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (!x1e5_24_doSave || mgr.GetDeferredStateTransition() == EStateManagerTransition::SaveGame) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
x1e5_24_doSave = false;
|
|
|
|
if (mgr.GetInSaveUI()) {
|
|
|
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
|
|
|
} else {
|
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSpecialFunction::ThinkRainSimulator(float, CStateManager& mgr) {
|
2022-10-09 17:07:51 +00:00
|
|
|
if ((static_cast< float >(mgr.GetInputFrameIdx() % 3600)) / 3600.f < 0.5f) {
|
2018-12-08 05:30:43 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
2020-05-07 16:07:25 +00:00
|
|
|
} else {
|
2018-12-08 05:30:43 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
|
|
|
|
2019-11-24 15:01:07 +00:00
|
|
|
void CScriptSpecialFunction::ThinkAreaDamage(float dt, CStateManager& mgr) {
|
2019-02-03 21:20:05 +00:00
|
|
|
const auto& playerState = mgr.GetPlayerState();
|
2019-11-24 15:01:07 +00:00
|
|
|
CPlayer& player = mgr.GetPlayer();
|
2020-05-07 16:07:25 +00:00
|
|
|
|
2019-11-24 15:01:07 +00:00
|
|
|
/* The following check is a URDE addition */
|
|
|
|
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 */
|
|
|
|
if (x1e4_31_inAreaDamage) {
|
|
|
|
x1e4_31_inAreaDamage = false;
|
|
|
|
player.DecrementEnvironmentDamage();
|
|
|
|
SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None);
|
|
|
|
mgr.SetIsFullThreat(false);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* End URDE Addition */
|
|
|
|
|
|
|
|
if (!x1e4_31_inAreaDamage) {
|
|
|
|
if (mgr.GetPlayer().GetAreaIdAlways() != GetAreaIdAlways() ||
|
2020-05-07 16:07:25 +00:00
|
|
|
playerState->GetCurrentSuitRaw() != CPlayerState::EPlayerSuit::Power) {
|
2019-11-24 15:01:07 +00:00
|
|
|
return;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2019-11-24 15:01:07 +00:00
|
|
|
x1e4_31_inAreaDamage = true;
|
|
|
|
player.IncrementEnvironmentDamage();
|
|
|
|
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
|
|
|
|
mgr.SetIsFullThreat(true);
|
|
|
|
} else if (mgr.GetPlayer().GetAreaIdAlways() != GetAreaIdAlways() ||
|
|
|
|
playerState->GetCurrentSuitRaw() != CPlayerState::EPlayerSuit::Power) {
|
|
|
|
x1e4_31_inAreaDamage = false;
|
|
|
|
player.DecrementEnvironmentDamage();
|
|
|
|
SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None);
|
|
|
|
mgr.SetIsFullThreat(false);
|
|
|
|
return;
|
|
|
|
}
|
2019-02-03 21:20:05 +00:00
|
|
|
|
2019-11-24 15:01:07 +00:00
|
|
|
CDamageInfo dInfo(CWeaponMode(EWeaponType::Heat), xfc_float1 * dt, 0.f, 0.f);
|
|
|
|
dInfo.SetNoImmunity(true);
|
|
|
|
mgr.ApplyDamage(GetUniqueId(), player.GetUniqueId(), GetUniqueId(), dInfo,
|
|
|
|
CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {}), {});
|
2019-02-03 21:20:05 +00:00
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptSpecialFunction::ThinkPlayerInArea(float dt, CStateManager& mgr) {
|
|
|
|
if (mgr.GetPlayer().GetAreaIdAlways() == GetAreaIdAlways()) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (x1e5_25_playerInArea) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x1e5_25_playerInArea = true;
|
|
|
|
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
|
|
|
|
} else if (x1e5_25_playerInArea) {
|
|
|
|
x1e5_25_playerInArea = false;
|
|
|
|
SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
2017-02-18 02:19:50 +00:00
|
|
|
}
|
2018-05-20 05:01:17 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CScriptSpecialFunction::ShouldSkipCinematic(CStateManager& stateMgr) const {
|
2022-02-21 02:28:07 +00:00
|
|
|
if (com_developer->toBoolean()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
return g_GameState->SystemOptions().GetCinematicState(stateMgr.GetWorld()->IGetWorldAssetId(), GetEditorId());
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
|
|
|
|
2022-10-09 17:07:51 +00:00
|
|
|
void CScriptSpecialFunction::DeleteEmitter(CSfxHandle& handle) {
|
2020-05-07 16:07:25 +00:00
|
|
|
if (!handle) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CSfxManager::RemoveEmitter(handle);
|
2022-10-09 17:07:51 +00:00
|
|
|
handle = CSfxHandle();
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
u32 CScriptSpecialFunction::GetSpecialEnding(const CStateManager& mgr) const {
|
2022-10-09 17:07:51 +00:00
|
|
|
const int rate = (mgr.GetPlayerState()->CalculateItemCollectionRate() * 100) / mgr.GetPlayerState()->GetPickupTotal();
|
|
|
|
int result;
|
2020-05-07 16:07:25 +00:00
|
|
|
if (rate < 75) {
|
2022-10-09 17:07:51 +00:00
|
|
|
result = 0;
|
|
|
|
} else {
|
|
|
|
result = 2;
|
|
|
|
if (rate < 100) {
|
|
|
|
result = 1;
|
|
|
|
}
|
2020-05-07 16:07:25 +00:00
|
|
|
}
|
2022-10-09 17:07:51 +00:00
|
|
|
return result;
|
2018-05-20 05:01:17 +00:00
|
|
|
}
|
|
|
|
|
2020-03-03 08:31:49 +00:00
|
|
|
void CScriptSpecialFunction::AddOrUpdateEmitter(float pitch, CSfxHandle& handle, u16 id, const zeus::CVector3f& pos,
|
|
|
|
float vol) {
|
|
|
|
if (!handle) {
|
|
|
|
handle = CSfxManager::AddEmitter(id, pos, zeus::skZero3f, vol, true, true, 0x7f, kInvalidAreaId);
|
|
|
|
} else {
|
|
|
|
CSfxManager::UpdateEmitter(handle, pos, zeus::skZero3f, vol);
|
|
|
|
CSfxManager::PitchBend(handle, 8192.f * pitch + 8192.f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-10 09:37:36 +00:00
|
|
|
CScriptSpecialFunction::SRingController::SRingController(TUniqueId uid, float rotateSpeed, bool reachedTarget)
|
|
|
|
: x0_id(uid), x4_rotateSpeed(rotateSpeed), x8_reachedTarget(reachedTarget) {}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|