From 9d0fe6a1d8c812b5f6a8df9dd9039d61999d0fea Mon Sep 17 00:00:00 2001
From: Lwmte <3331699+Lwmte@users.noreply.github.com>
Date: Sun, 9 Mar 2025 20:01:43 +0100
Subject: [PATCH] Ribbon particle (#1606)
---
Documentation/doc/1 modules/Effects.html | 93 +++++++++++++++++++
.../doc/4 enums/Effects.FeatherMode.html | 2 +-
Documentation/doc/4 enums/Objects.ObjID.html | 6 ++
.../Scripting/Internal/ReservedScriptNames.h | 2 +
.../Internal/TEN/Effects/EffectsFunctions.cpp | 51 ++++++++++
5 files changed, 153 insertions(+), 1 deletion(-)
diff --git a/Documentation/doc/1 modules/Effects.html b/Documentation/doc/1 modules/Effects.html
index 5f3c6e3f0..3e7751034 100644
--- a/Documentation/doc/1 modules/Effects.html
+++ b/Documentation/doc/1 modules/Effects.html
@@ -171,6 +171,10 @@
GetWind() |
Get the wind vector for the current game frame. |
+
+ EmitStreamer(mov, tag, pos, dir[, rot][, startColor][, endColor][, width][, life][, vel][, expRate][, rotRate][, edgeFeatherMode][, lengthFeatherMode][, blendID]) |
+ Emit an extending streamer effect. |
+
@@ -711,6 +715,95 @@ EmitAdvancedParticle(particle)
+
+
+
+ EmitStreamer(mov, tag, pos, dir[, rot][, startColor][, endColor][, width][, life][, vel][, expRate][, rotRate][, edgeFeatherMode][, lengthFeatherMode][, blendID])
+
+
+ Emit an extending streamer effect.
+
+
+
+ Parameters:
+
+ - mov
+ Moveable
+ Moveable object with which to associate the effect.
+
+ - tag
+ int[opt]
+ Numeric tag with which to associate the effect on the moveable. Default: 0
+
+ - pos
+ Vec3
+ World position.
+
+ - dir
+ Vec3
+ Direction vector of movement velocity.
+
+ - rot
+ float
+ Start rotation in degrees. Default: 0
+ (optional)
+
+ - startColor
+ Color
+ Color at the start of life. Default: Color(255, 255, 255, 255))
+ (optional)
+
+ - endColor
+ Color
+ Color at the end of life. Default: Color(0, 0, 0, 0))
+ (optional)
+
+ - width
+ float
+ Width in world units. Default: 0
+ (optional)
+
+ - life
+ float
+ Lifetime in seconds. Default: 1
+ (optional)
+
+ - vel
+ float
+ Movement velocity in world units per second. Default: 0
+ (optional)
+
+ - expRate
+ float
+ Width expansion rate in world units per second. Default: 0
+ (optional)
+
+ - rotRate
+ float
+ Rotation rate in degrees per second. Default: 0
+ (optional)
+
+ - edgeFeatherMode
+ Effects.StreamerFeatherMode
+ Edge feather mode. Default: Effects.FeatherID.NONE
+ (optional)
+
+ - lengthFeatherMode
+ Effects.StreamerFeatherMode
+ Length feather mode. Not implemented yet.
+ (optional)
+
+ - blendID
+ BlendID
+ Renderer blend ID. Default: Effects.BlendID.ALPHA_BLEND
+ (optional)
+
+
+
+
+
+
+
diff --git a/Documentation/doc/4 enums/Effects.FeatherMode.html b/Documentation/doc/4 enums/Effects.FeatherMode.html
index aeab018ee..f4a4fb39f 100644
--- a/Documentation/doc/4 enums/Effects.FeatherMode.html
+++ b/Documentation/doc/4 enums/Effects.FeatherMode.html
@@ -143,7 +143,7 @@
Table of Effects.FeatherMode constants.
- To be used with ??? function.
+ To be used with Effects.EmitStreamer function.
NONE
diff --git a/Documentation/doc/4 enums/Objects.ObjID.html b/Documentation/doc/4 enums/Objects.ObjID.html
index 0daeb40f0..7d7426efa 100644
--- a/Documentation/doc/4 enums/Objects.ObjID.html
+++ b/Documentation/doc/4 enums/Objects.ObjID.html
@@ -505,6 +505,11 @@ DAMOCLES_SWORD
ELECTRIC_CLEANER
SLAMMING_DOORS
SWINGING_BLADE
+ELECTRIC_BALL
+ELECTRIC_BALL_IMPACT_POINT
+THOR_HAMMER_HANDLE
+THOR_HAMMER_HEAD
+MOVING_LASER
PUZZLE_ITEM1
PUZZLE_ITEM2
PUZZLE_ITEM3
@@ -940,6 +945,7 @@ FISHTANK
DOPPELGANGER_ORIGIN
CORPSE
WRAITH_TRAP
+WATERFALL_EMITTER
MESHSWAP1
MESHSWAP2
MESHSWAP3
diff --git a/TombEngine/Scripting/Internal/ReservedScriptNames.h b/TombEngine/Scripting/Internal/ReservedScriptNames.h
index ab9c556b8..7db33a007 100644
--- a/TombEngine/Scripting/Internal/ReservedScriptNames.h
+++ b/TombEngine/Scripting/Internal/ReservedScriptNames.h
@@ -321,6 +321,7 @@ static constexpr char ScriptReserved_EmitSpotLight[] = "EmitSpotLight";
static constexpr char ScriptReserved_EmitBlood[] = "EmitBlood";
static constexpr char ScriptReserved_EmitAirBubble[] = "EmitAirBubble";
static constexpr char ScriptReserved_EmitFire[] = "EmitFire";
+static constexpr char ScriptReserved_EmitStreamer[] = "EmitStreamer";
static constexpr char ScriptReserved_MakeExplosion[] = "MakeExplosion";
static constexpr char ScriptReserved_MakeEarthquake[] = "MakeEarthquake";
@@ -388,6 +389,7 @@ static constexpr char ScriptReserved_EventType[] = "EventType";
static constexpr char ScriptReserved_AlignMode[] = "AlignMode";
static constexpr char ScriptReserved_ScaleMode[] = "ScaleMode";
static constexpr char ScriptReserved_ParticleAnimationType[] = "ParticleAnimationType";
+static constexpr char ScriptReserved_FeatherMode[] = "StreamerFeatherMode";
static constexpr char ScriptReserved_LevelVars[] = "LevelVars";
static constexpr char ScriptReserved_GameVars[] = "GameVars";
diff --git a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp
index 25ef6013d..3c1effb87 100644
--- a/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Effects/EffectsFunctions.cpp
@@ -10,6 +10,7 @@
#include "Game/effects/Electricity.h"
#include "Game/effects/explosion.h"
#include "Game/effects/spark.h"
+#include "Game/effects/Streamer.h"
#include "Game/effects/tomb4fx.h"
#include "Game/effects/weather.h"
#include "Game/Setup.h"
@@ -21,6 +22,7 @@
#include "Scripting/Internal/TEN/Effects/BlendIDs.h"
#include "Scripting/Internal/TEN/Effects/EffectIDs.h"
#include "Scripting/Internal/TEN/Effects/ParticleAnimTypes.h"
+#include "Scripting/Internal/TEN/Effects/FeatherModes.h"
#include "Scripting/Internal/TEN/Types/Color/Color.h"
#include "Scripting/Internal/TEN/Types/Rotation/Rotation.h"
#include "Scripting/Internal/TEN/Types/Vec3/Vec3.h"
@@ -28,6 +30,7 @@
#include "Sound/sound.h"
#include "Specific/clock.h"
#include "Specific/trutils.h"
+#include
/// Functions to generate effects.
// @tentable Effects
@@ -39,6 +42,7 @@ using namespace TEN::Effects::Electricity;
using namespace TEN::Effects::Environment;
using namespace TEN::Effects::Explosion;
using namespace TEN::Effects::Spark;
+using namespace TEN::Effects::Streamer;
using namespace TEN::Math;
using namespace TEN::Scripting::Types;
@@ -543,6 +547,51 @@ namespace TEN::Scripting::Effects
return Vec3(Weather.Wind());
}
+/// Emit an extending streamer effect.
+// @function EmitStreamer
+// @tparam Moveable mov Moveable object with which to associate the effect.
+// @tparam int[opt] tag Numeric tag with which to associate the effect on the moveable. __Default: 0__
+// @tparam Vec3 pos World position.
+// @tparam Vec3 dir Direction vector of movement velocity.
+// @tparam[opt] float rot Start rotation in degrees. __Default: 0__
+// @tparam[opt] Color startColor Color at the start of life. __Default: Color(255, 255, 255, 255))__
+// @tparam[opt] Color endColor Color at the end of life. __Default: Color(0, 0, 0, 0))__
+// @tparam[opt] float width Width in world units. __Default: 0__
+// @tparam[opt] float life Lifetime in seconds. __Default: 1__
+// @tparam[opt] float vel Movement velocity in world units per second. __Default: 0__
+// @tparam[opt] float expRate Width expansion rate in world units per second. __Default: 0__
+// @tparam[opt] float rotRate Rotation rate in degrees per second. __Default: 0__
+// @tparam[opt] Effects.StreamerFeatherMode edgeFeatherMode Edge feather mode. __Default: Effects.FeatherID.NONE__
+// @tparam[opt] Effects.StreamerFeatherMode lengthFeatherMode Length feather mode. __Not implemented yet.__
+// @tparam[opt] Effects.BlendID blendID Renderer blend ID. __Default: Effects.BlendID.ALPHA_BLEND__
+ static void EmitStreamer(const Moveable& mov, TypeOrNil tag, const Vec3& pos, const Vec3& dir, TypeOrNil rot, TypeOrNil startColor, TypeOrNil endColor,
+ TypeOrNil width, TypeOrNil life, TypeOrNil vel, TypeOrNil expRate, TypeOrNil rotRate,
+ TypeOrNil edgeFeatherMode, TypeOrNil lengthFeatherMode, TypeOrNil blendID)
+ {
+ int movID = mov.GetIndex();
+ int convertedTag = ValueOr(tag, 0);
+ auto convertedPos = pos.ToVector3();
+ auto convertedDir = dir.ToVector3();
+ auto convertedRot = ANGLE(ValueOr(rot, 0));
+ auto convertedStartColor = ValueOr(startColor, ScriptColor(255, 255, 255, 255));
+ auto convertedEndColor = ValueOr(endColor, ScriptColor(0, 0, 0, 0));
+
+ auto convertedWidth = ValueOr(width, 0.0f);
+ auto convertedLife = ValueOr(life, 1.0f);
+ auto convertedVel = ValueOr(vel, 0.0f) / (float)FPS;
+ auto convertedExpRate = ValueOr(expRate, 0.0f) / (float)FPS;
+ auto convertedRotRate = ANGLE(ValueOr(rotRate, 0.0f) / (float)FPS);
+
+ auto convertedEdgeFeatherID = ValueOr(edgeFeatherMode, StreamerFeatherMode::None);
+ auto convertedLengthFeatherID = ValueOr(lengthFeatherMode, StreamerFeatherMode::None);
+ auto convertedBlendID = ValueOr(blendID, BlendMode::AlphaBlend);
+
+ StreamerEffect.Spawn(
+ movID, convertedTag, convertedPos, convertedDir, convertedRot, convertedStartColor, convertedEndColor,
+ convertedWidth, convertedLife, convertedVel, convertedExpRate, convertedRotRate,
+ convertedEdgeFeatherID, convertedBlendID);
+ }
+
void Register(sol::state* state, sol::table& parent)
{
auto tableEffects = sol::table(state->lua_state(), sol::create);
@@ -557,6 +606,7 @@ namespace TEN::Scripting::Effects
tableEffects.set_function(ScriptReserved_EmitSpotLight, &EmitSpotLight);
tableEffects.set_function(ScriptReserved_EmitBlood, &EmitBlood);
tableEffects.set_function(ScriptReserved_EmitAirBubble, &EmitAirBubble);
+ tableEffects.set_function(ScriptReserved_EmitStreamer, &EmitStreamer);
tableEffects.set_function(ScriptReserved_EmitFire, &EmitFire);
tableEffects.set_function(ScriptReserved_MakeExplosion, &MakeExplosion);
@@ -566,6 +616,7 @@ namespace TEN::Scripting::Effects
auto handler = LuaHandler(state);
handler.MakeReadOnlyTable(tableEffects, ScriptReserved_BlendID, BLEND_IDS);
handler.MakeReadOnlyTable(tableEffects, ScriptReserved_EffectID, EFFECT_IDS);
+ handler.MakeReadOnlyTable(tableEffects, ScriptReserved_FeatherMode, FEATHER_MODES);
handler.MakeReadOnlyTable(tableEffects, ScriptReserved_ParticleAnimationType, PARTICLE_ANIM_TYPES);
}
}