From 2d0d13c620690fbc757325a9f1edee9dc62399c6 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Wed, 20 Nov 2024 08:18:27 +0100 Subject: [PATCH 1/3] Implement GetCollidable and SetCollidable lua methods for moveables --- CHANGELOG.md | 5 +++-- TombEngine/Game/control/los.cpp | 2 +- .../Scripting/Internal/ReservedScriptNames.h | 2 ++ .../TEN/Objects/Moveable/MoveableObject.cpp | 19 +++++++++++++++++++ .../TEN/Objects/Moveable/MoveableObject.h | 2 ++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd8085dcc..545e00556 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Allow more than 1000 static mesh slots in a level. ### Lua API changes +* Added Moveable:GetCollidable() and Moveable:SetCollidable() functions. * Added Flow.GetNextLevel() function to get script entry for incoming level, if it's about to start. * Added support for transparency value in DisplayString class. * Added extra argument for SetAmbientTrack() function to specify if new ambient track should play from the beginning. @@ -120,8 +121,8 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Added Flow.LensFlare() and Flow.Starfield() classes. * Added Inventory.GetUsedItem(), Inventory.SetUsedItem() and Inventory.ClearUsedItem() functions. * Added Input.KeyClearAll() function. -* Added Moveable.GetJointRotation() and optional 'offset' parameter for Moveable.GetJointPosition(). -* Added Moveable.GetTargetState() function. +* Added Moveable:GetJointRotation() and optional 'offset' parameter for Moveable.GetJointPosition(). +* Added Moveable:GetTargetState() function. * Added Room:GetRoomNumber() function. * Removed anims.monkeyAutoJump. It is now a player menu configuration. * Fixed Volume:GetActive() method. diff --git a/TombEngine/Game/control/los.cpp b/TombEngine/Game/control/los.cpp index 87939b760..733d2f309 100644 --- a/TombEngine/Game/control/los.cpp +++ b/TombEngine/Game/control/los.cpp @@ -592,7 +592,7 @@ int ObjectOnLOS2(GameVector* origin, GameVector* target, Vector3i* vec, MESH_INF if (priorityObjectID != GAME_OBJECT_ID::ID_NO_OBJECT && item.ObjectNumber != priorityObjectID) continue; - if (item.ObjectNumber != ID_LARA && Objects[item.ObjectNumber].collision == nullptr) + if (item.ObjectNumber != ID_LARA && (Objects[item.ObjectNumber].collision == nullptr || !item.Collidable)) continue; if (item.ObjectNumber == ID_LARA && priorityObjectID != ID_LARA) diff --git a/TombEngine/Scripting/Internal/ReservedScriptNames.h b/TombEngine/Scripting/Internal/ReservedScriptNames.h index ca2980f7d..54042b164 100644 --- a/TombEngine/Scripting/Internal/ReservedScriptNames.h +++ b/TombEngine/Scripting/Internal/ReservedScriptNames.h @@ -96,6 +96,8 @@ static constexpr char ScriptReserved_New[] = "New"; static constexpr char ScriptReserved_Init[] = "Init"; static constexpr char ScriptReserved_Enable[] = "Enable"; static constexpr char ScriptReserved_Disable[] = "Disable"; +static constexpr char ScriptReserved_GetCollidable[] = "GetCollidable"; +static constexpr char ScriptReserved_SetCollidable[] = "SetCollidable"; static constexpr char ScriptReserved_MakeInvisible[] = "MakeInvisible"; static constexpr char ScriptReserved_SetVisible[] = "SetVisible"; static constexpr char ScriptReserved_Explode[] = "Explode"; diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp index fa72ce12c..7308d8cf2 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp +++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp @@ -168,6 +168,9 @@ void Moveable::Register(sol::state& state, sol::table& parent) ScriptReserved_SetVisible, &Moveable::SetVisible, + ScriptReserved_SetCollidable, & Moveable::SetCollidable, + ScriptReserved_GetCollidable, & Moveable::GetCollidable, + /// Explode item. This also kills and disables item. // @function Moveable:Explode ScriptReserved_Explode, &Moveable::Explode, @@ -1166,6 +1169,22 @@ void Moveable::Shatter() KillItem(m_num); } +/// Get the item's collision state. +// @treturn bool item's collision state +// @function Moveable:GetCollidable +bool Moveable::GetCollidable() +{ + return m_item->Collidable; +} + +/// Set the item's collision. +// @bool collidable true if the caller should be collidable, false if no collision should occur. +// @function Moveable:SetCollidable +void Moveable::SetCollidable(bool isCollidable) +{ + m_item->Collidable = isCollidable; +} + /// Make the item invisible. Alias for `Moveable:SetVisible(false)`. // @function Moveable:MakeInvisible void Moveable::MakeInvisible() diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h index dfb795f31..2ad56a48a 100644 --- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h +++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.h @@ -118,6 +118,8 @@ public: void DisableItem(); void MakeInvisible(); void SetVisible(bool isVisible); + [[nodiscard]] bool GetCollidable(); + void SetCollidable(bool isCollidable); void Explode(); void Shatter(); From db68eeaca3436af858538edc512ead81567084bd Mon Sep 17 00:00:00 2001 From: Joey Quint Date: Wed, 20 Nov 2024 08:15:26 +0100 Subject: [PATCH 2/3] Expose wind (#1465) * Expose wind * Update EffectsFunctions.cpp --------- Co-authored-by: Sezz --- CHANGELOG.md | 2 ++ Documentation/doc/1 modules/Effects.html | 26 +++++++++++++++++++ .../Scripting/Internal/ReservedScriptNames.h | 1 + .../Internal/TEN/Effects/EffectsFunctions.cpp | 12 +++++++++ 4 files changed, 41 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 545e00556..e25e64231 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,8 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fixed incorrect behaviour of Logic.EnableEvent() and Logic.DisableEvent() functions. * Fixed collision callbacks not properly clearing after leveljump. +* Added Effects.GetWind() function. + ## [Version 1.5](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.7.2) - 2024-11-03 ### Bug fixes diff --git a/Documentation/doc/1 modules/Effects.html b/Documentation/doc/1 modules/Effects.html index 27cd390a2..c7672b1db 100644 --- a/Documentation/doc/1 modules/Effects.html +++ b/Documentation/doc/1 modules/Effects.html @@ -143,6 +143,10 @@ MakeEarthquake(strength) Make an earthquake + + GetWind() + Get the current wind for the current frame. +
@@ -498,6 +502,28 @@ + +
+ + GetWind() +
+
+ Get the current wind for the current frame. + This represents the 3D displacement applied by the engine on things like particles affected by wind. + + + + +

Returns:

+
    + + Vec3 + The wind. +
+ + + +
diff --git a/TombEngine/Scripting/Internal/ReservedScriptNames.h b/TombEngine/Scripting/Internal/ReservedScriptNames.h index 54042b164..de32a0aaf 100644 --- a/TombEngine/Scripting/Internal/ReservedScriptNames.h +++ b/TombEngine/Scripting/Internal/ReservedScriptNames.h @@ -301,6 +301,7 @@ static constexpr char ScriptReserved_EmitBlood[] = "EmitBlood"; static constexpr char ScriptReserved_EmitFire[] = "EmitFire"; static constexpr char ScriptReserved_MakeExplosion[] = "MakeExplosion"; static constexpr char ScriptReserved_MakeEarthquake[] = "MakeEarthquake"; +static constexpr char ScriptReserved_GetWind[] = "GetWind"; static constexpr char ScriptReserved_Vibrate[] = "Vibrate"; static constexpr char ScriptReserved_FlashScreen[] = "FlashScreen"; static constexpr char ScriptReserved_FadeIn[] = "FadeIn"; diff --git a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp index 9514e38e8..e3404b00e 100644 --- a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp +++ b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp @@ -10,6 +10,7 @@ #include "Game/effects/explosion.h" #include "Game/effects/spark.h" #include "Game/effects/tomb4fx.h" +#include "Game/effects/weather.h" #include "Game/Setup.h" #include "Objects/Utils/object_helper.h" #include "Scripting/Internal/LuaHandler.h" @@ -31,6 +32,7 @@ Functions to generate effects. using namespace TEN::Effects::DisplaySprite; using namespace TEN::Effects::Electricity; +using namespace TEN::Effects::Environment; using namespace TEN::Effects::Explosion; using namespace TEN::Effects::Spark; @@ -308,6 +310,15 @@ namespace TEN::Scripting::Effects Camera.bounce = -str; } + /// Get the wind vector for the current game frame. + // This represents the 3D displacement applied by the engine on things like particles affected by wind. + // @function GetWind() + // @treturn Vec3 Wind vector. + static Vec3 GetWind() + { + return Vec3(Weather.Wind()); + } + void Register(sol::state* state, sol::table& parent) { auto tableEffects = sol::table(state->lua_state(), sol::create); @@ -321,6 +332,7 @@ namespace TEN::Scripting::Effects tableEffects.set_function(ScriptReserved_MakeExplosion, &MakeExplosion); tableEffects.set_function(ScriptReserved_EmitFire, &EmitFire); tableEffects.set_function(ScriptReserved_MakeEarthquake, &Earthquake); + tableEffects.set_function(ScriptReserved_GetWind, &GetWind); auto handler = LuaHandler{ state }; handler.MakeReadOnlyTable(tableEffects, ScriptReserved_BlendID, BLEND_IDS); From f218644703dbf98586de24127b1e3decb4871031 Mon Sep 17 00:00:00 2001 From: Lwmte <3331699+Lwmte@users.noreply.github.com> Date: Wed, 20 Nov 2024 08:21:56 +0100 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e25e64231..65ef8c398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): ### Lua API changes * Added Moveable:GetCollidable() and Moveable:SetCollidable() functions. * Added Flow.GetNextLevel() function to get script entry for incoming level, if it's about to start. +* Added Effects.GetWind() function to get current wind speed vector. * Added support for transparency value in DisplayString class. * Added extra argument for SetAmbientTrack() function to specify if new ambient track should play from the beginning. * Use load camera instead of load screen by playing fixed camera from OnEnd() event and removing loadScreenFile field from level's gameflow entry. @@ -47,8 +48,6 @@ TombEngine releases are located in this repository (alongside with Tomb Editor): * Fixed incorrect behaviour of Logic.EnableEvent() and Logic.DisableEvent() functions. * Fixed collision callbacks not properly clearing after leveljump. -* Added Effects.GetWind() function. - ## [Version 1.5](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.7.2) - 2024-11-03 ### Bug fixes