Skip to content

Commit 89a29af

Browse files
committed
Exposed EffectStartStrength and -StopStrength to Lua, added SetEffectStrength()
1 parent b3a2d72 commit 89a29af

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1414

1515
- Added `HDFirearm` lua bindings `EjectionOffset` (R/W) and `EjectionPos` (R). Work similarly to their Muzzle variants.
1616

17+
- Exposed `MovableObject` INI properties `EffectStartStrength` and `EffectStopStrength` to Lua (R/W). Default range in Lua is a float from 0-1 (0%-100%), but going outside of this range is possible.
18+
19+
- New `MovableObject` Lua function `SetEffectStrength(float strength)`, which sets both `EffectStartStrength` and `EffectStopStrength` to the given value in order to simplify setting glow strength to a specific value.
20+
1721
</details>
1822

1923
<details><summary><b>Changed</b></summary>

Source/Entities/MovableObject.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,30 @@ namespace RTE {
393393
/// @return The starting strength of the effect, 0-255.
394394
int GetEffectStartStrength() const { return m_EffectStartStrength; }
395395

396+
/// Gets the starting strength of this MovableObject's effect as a float.
397+
/// @return The starting strength of the effect, 0.0-1.0.
398+
float GetEffectStartStrengthFloat() const { return (float)m_EffectStartStrength / 255.0f; }
399+
400+
/// Sets the starting strength of this MovableObject's effect.
401+
/// @param strength The new starting strength of the effect, 0.0-1.0.
402+
void SetEffectStartStrengthFloat(float strength) { m_EffectStartStrength = std::floor((float)255 * strength); }
403+
396404
/// Gets the stopping strength of this MovableObject's effect.
397405
/// @return The stopping strength of the effect, 0-255.
398406
int GetEffectStopStrength() const { return m_EffectStopStrength; }
399407

408+
/// Gets the stopping strength of this MovableObject's effect as a float.
409+
/// @return The stopping strength of the effect, 0.0-1.0.
410+
float GetEffectStopStrengthFloat() const { return (float)m_EffectStopStrength / 255.0f; }
411+
412+
/// Sets the stopping strength of this MovableObject's effect.
413+
/// @param strength The new stopping strength of the effect, 0.0-1.0.
414+
void SetEffectStopStrengthFloat(float strength) { m_EffectStopStrength = std::floor((float)255 * strength); }
415+
416+
/// Sets both strengths of this MovableObject's effect.
417+
/// @param strength The new strengths of the effect, 0.0-1.0.
418+
void SetEffectStrength(float strength) { m_EffectStartStrength = m_EffectStopStrength = std::floor((float)255 * strength); }
419+
400420
/// Gets whether or not this MovableObject's effect is drawn every frame.
401421
/// @return Boolean indicating whether or not the effect is drawn.
402422
bool GetPostEffectEnabled() const { return m_PostEffectEnabled; }

Source/Lua/LuaBindingsEntities.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,8 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MovableObject) {
890890
.property("Diameter", &MovableObject::GetDiameter)
891891
.property("Scale", &MovableObject::GetScale, &MovableObject::SetScale)
892892
.property("EffectRotAngle", &MovableObject::GetEffectRotAngle, &MovableObject::SetEffectRotAngle)
893+
.property("EffectStartStrength", &MovableObject::GetEffectStartStrengthFloat, &MovableObject::SetEffectStartStrengthFloat)
894+
.property("EffectStopStrength", &MovableObject::GetEffectStopStrengthFloat, &MovableObject::SetEffectStopStrengthFloat)
893895
.property("GlobalAccScalar", &MovableObject::GetGlobalAccScalar, &MovableObject::SetGlobalAccScalar)
894896
.property("AirResistance", &MovableObject::GetAirResistance, &MovableObject::SetAirResistance)
895897
.property("AirThreshold", &MovableObject::GetAirThreshold, &MovableObject::SetAirThreshold)
@@ -988,7 +990,8 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MovableObject) {
988990
.def("RotateOffset", &MovableObject::RotateOffset)
989991
.def("SendMessage", &LuaAdaptersMovableObject::SendMessage1)
990992
.def("SendMessage", &LuaAdaptersMovableObject::SendMessage2)
991-
.def("RequestSyncedUpdate", &MovableObject::RequestSyncedUpdate);
993+
.def("RequestSyncedUpdate", &MovableObject::RequestSyncedUpdate)
994+
.def("SetEffectStrength", &MovableObject::SetEffectStrength);
992995
}
993996

994997
LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, PEmitter) {

0 commit comments

Comments
 (0)