1111
1212#include " StdInc.h"
1313#include " lua/CLuaFunctionParser.h"
14+ #include < game/CFx.h>
1415
1516void CLuaEffectDefs::LoadFunctions ()
1617{
@@ -35,6 +36,7 @@ void CLuaEffectDefs::LoadFunctions()
3536 {" setEffectDensity" , SetEffectDensity},
3637 {" getEffectDensity" , GetEffectDensity},
3738 {" fxCreateParticle" , ArgumentParser<FxCreateParticle>},
39+ {" fxAddShadow" , ArgumentParser<FxAddShadow>},
3840 };
3941
4042 // Add functions
@@ -62,6 +64,7 @@ void CLuaEffectDefs::AddClass(lua_State* luaVM)
6264 lua_classfunction (luaVM, " addWaterSplash" , " fxAddWaterSplash" );
6365 lua_classfunction (luaVM, " addWood" , " fxAddWood" );
6466 lua_classfunction (luaVM, " createParticle" , " fxCreateParticle" );
67+ lua_classfunction (luaVM, " createShadow" , " fxAddShadow" );
6568
6669 lua_classfunction (luaVM, " setDensity" , " setEffectDensity" );
6770 lua_classfunction (luaVM, " setSpeed" , " setEffectSpeed" );
@@ -647,3 +650,23 @@ bool CLuaEffectDefs::FxCreateParticle(FxParticleSystems eParticleSystem, CVector
647650{
648651 return CStaticFunctionDefinitions::FxCreateParticle (eParticleSystem, vecPosition, vecDirection, fR /255 , fG /255 , fB /255 , fA /255 , bRandomizeColors.value_or (false ), iCount.value_or (1 ), fBrightness .value_or (1 .0f ), fSize .value_or (0 .3f ), bRandomizeSizes.value_or (false ), fLife .value_or (1 .0f ));
649652}
653+
654+ bool CLuaEffectDefs::FxAddShadow (eShadowTextureType shadowTextureType, CVector vecPosition, CVector2D vecOffset1, CVector2D vecOffset2, SColor color,
655+ eShadowType shadowType,
656+ float zDistance, bool bDrawOnWater, bool bDrawOnBuildings)
657+ {
658+ if (vecOffset1.Length () > 32 )
659+ {
660+ throw std::invalid_argument (" First offset can not be longer than 32 units" );
661+ }
662+ else if (vecOffset2.Length () > 32 ) // bigger and close to limit shadows size can be partially invisible
663+ {
664+ throw std::invalid_argument (" Second offset can not be longer than 32 units" );
665+ }
666+ else if (zDistance < 0 || zDistance > 3000 ) // negative distance not working
667+ {
668+ throw std::invalid_argument (" Z Distance must be between 0.0 and 3000.0" );
669+ }
670+ return CStaticFunctionDefinitions::FxAddShadow (shadowTextureType, vecPosition, vecOffset1, vecOffset2, color, shadowType, zDistance, bDrawOnWater,
671+ bDrawOnBuildings);
672+ }
0 commit comments