From b6fb5f81737bb736f43ad23e94cfc829acd4c8f0 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sat, 27 Aug 2022 23:06:44 -0500 Subject: [PATCH] Add Friction Volume script --- dScripts/CMakeLists.txt | 1 + dScripts/CppScripts.cpp | 3 +++ dScripts/FrictionVolume.cpp | 14 ++++++++++++++ dScripts/FrictionVolume.h | 11 +++++++++++ 4 files changed, 29 insertions(+) create mode 100644 dScripts/FrictionVolume.cpp create mode 100644 dScripts/FrictionVolume.h diff --git a/dScripts/CMakeLists.txt b/dScripts/CMakeLists.txt index ac35b76d..d3ce823b 100644 --- a/dScripts/CMakeLists.txt +++ b/dScripts/CMakeLists.txt @@ -87,6 +87,7 @@ set(DSCRIPT_SOURCES "ActivityManager.cpp" "FlameJetServer.cpp" "ForceVolumeServer.cpp" "FountainOfImagination.cpp" + "FrictionVolume.cpp" "FvBounceOverWall.cpp" "FvBrickPuzzleServer.cpp" "FvCandle.cpp" diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 73c50d62..71e03b70 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -170,6 +170,7 @@ #include "MailBoxServer.h" #include "ActMine.h" #include "FireFirstSkillonStartup.h" +#include "FrictionVolume.h" // Racing Scripts #include "RaceImagineCrateServer.h" @@ -627,6 +628,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new FvRaceSmashEggImagineServer(); else if (scriptName == "scripts\\ai\\RACING\\OBJECTS\\RACE_SMASH_SERVER.lua") script = new RaceSmashServer(); + else if (scriptName == "scripts\\02_server\\Map\\General\\L_FRICTION_VOLUME_SERVER.lua") + script = new FrictionVolume(); //NT: else if (scriptName == "scripts\\02_server\\Map\\NT\\L_NT_SENTINELWALKWAY_SERVER.lua") diff --git a/dScripts/FrictionVolume.cpp b/dScripts/FrictionVolume.cpp new file mode 100644 index 00000000..7d587eb7 --- /dev/null +++ b/dScripts/FrictionVolume.cpp @@ -0,0 +1,14 @@ +#include "FrictionVolume.h" +#include "PhantomPhysicsComponent.h" +#include "Entity.h" + +void FrictionVolume::OnStartup(Entity* self) { + auto frictionAmount = self->GetVarAs(m_FrictionVariable); + if (!frictionAmount) frictionAmount = m_DefaultFriction; + auto* phanPhys = self->GetComponent(); + if (!phanPhys) return; + + phanPhys->SetPhysicsEffectActive(true); + phanPhys->SetEffectType(4); // this should be noted in a enum somewhere + phanPhys->SetDirectionalMultiplier(frictionAmount); +} diff --git a/dScripts/FrictionVolume.h b/dScripts/FrictionVolume.h new file mode 100644 index 00000000..2290e921 --- /dev/null +++ b/dScripts/FrictionVolume.h @@ -0,0 +1,11 @@ +#pragma once +#include "CppScripts.h" + +class FrictionVolume : public CppScripts::Script +{ +public: + void OnStartup(Entity* self) override; +private: + const float m_DefaultFriction = 1.5; + const std::u16string m_FrictionVariable = u"FrictionAmt"; +};