Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE: January 2025 - Optimizing / New features / Bug fixing. #45

Merged
merged 19 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
67e9d62
PE: Better object error messages.
plemsoft Jan 7, 2025
e1e2f81
PE: Bug fix - only one delete/add quest button per behavior.
plemsoft Jan 7, 2025
72ed2b8
PE: Added weapon slot 11 to be used for interactions ONLY, can't be u…
plemsoft Jan 7, 2025
163a8d5
PE: Added to setup.ini - "editorvsync" option, my gpu is burning and …
plemsoft Jan 7, 2025
82fbc8b
PE: Bug fix - restore position of lua moved particles.
plemsoft Jan 7, 2025
effdf9a
PE: Optimizing - max startup - adding all media to assets lists now 4…
plemsoft Jan 7, 2025
8ceab26
PE: Added DLUA error if script do not have any "newlines".
plemsoft Jan 7, 2025
407e815
PE: Optimizing - DLUA now use less memory.
plemsoft Jan 7, 2025
314f358
PE: Bug fix - When using load game or when died and weapon already lo…
plemsoft Jan 7, 2025
7b159da
PE: Added log vram usage to Guru-MapEditor.log
plemsoft Jan 7, 2025
639a4a1
PE: Optimizing - cStr - changed to use ringbuffer instead of temp sto…
plemsoft Jan 7, 2025
1767310
PE: Storyboard max screens increased from 50 to 150, max widgets from…
plemsoft Jan 7, 2025
1fe8df7
PE: Optimizing - terrain/trees/veg will now only load textures when t…
plemsoft Jan 7, 2025
e45a9a5
PE: New lua commands - DisableBoundHudKeys() and EnableBoundHudKeys()…
plemsoft Jan 8, 2025
201f523
PE: New LUA commands Convert2DTo3D, Convert3DTo2D, ScreenCordsToPercent.
plemsoft Jan 10, 2025
4270c30
PE: My bad spelling.
plemsoft Jan 10, 2025
04479c5
PE: Added Wicked Particle System (LUA only for now).
plemsoft Jan 17, 2025
ef9ccf6
PE: Added - Quest Type "Activate" (4 Necrym59).
plemsoft Jan 17, 2025
ebe97b2
PE: New LUA command - PositionSound(Entity,Slot,X,Y,Z)
plemsoft Jan 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

//#define FASTBULLETPHYSICS

#ifdef WINVER
#undef WINVER
#endif
//PE: We need the latest dpi functions.
#define WINVER 0x0605
#include "Windows.h"
#include "WinUser.h"

#define _USING_V110_SDK71_
#include "stdafx.h"
#include "DarkLUA.h"
Expand Down Expand Up @@ -45,6 +53,13 @@ extern StoryboardStruct Storyboard;
#include "optick.h"
#endif

#include "..\..\..\..\Guru-WickedMAX\wickedcalls.h"
#include "WickedEngine.h"
using namespace std;
using namespace wiGraphics;
using namespace wiScene;
using namespace wiECS;

// Prototypes
extern void DrawSpritesFirst(void);
extern void DrawSpritesLast(void);
Expand Down Expand Up @@ -5834,6 +5849,59 @@ int QuatLERP(lua_State *L)
lua_pushnumber(L, qa.w * at + qb.w * bt );
return 4;
}

int ScreenCoordsToPercent(lua_State* L)
{
int n = lua_gettop(L);
if (n < 2) return 0;
float fX = lua_tonumber(L, 1);
float fY = lua_tonumber(L, 2);
float fPercentX = ( fX / (float) g_dwScreenWidth) * 100.0f;
float fPercentY = (fY / (float)g_dwScreenHeight) * 100.0f;
lua_pushnumber(L, fPercentX);
lua_pushnumber(L, fPercentY);
return 2;

}

int LuaConvert2DTo3D(lua_State* L)
{
int n = lua_gettop(L);
if (n < 2) return 0;
float fX = lua_tonumber(L, 1);
float fY = lua_tonumber(L, 2);

float x = (fX * g_dwScreenWidth) / 100.0f;
float y = (fY * g_dwScreenHeight) / 100.0f;

float fOutX = 0, fOutY = 0, fOutZ = 0;
float fDirX = 0, fDirY = 0, fDirZ = 0;
Convert2Dto3D(x, y, &fOutX, &fOutY, &fOutZ, &fDirX, &fDirY, &fDirZ);

lua_pushnumber(L, fOutX);
lua_pushnumber(L, fOutY);
lua_pushnumber(L, fOutZ);
lua_pushnumber(L, fDirX);
lua_pushnumber(L, fDirY);
lua_pushnumber(L, fDirZ);
return 6;
}


int LuaConvert3DTo2D(lua_State* L)
{
int n = lua_gettop(L);
if (n < 3) return 0;
float fX = lua_tonumber(L, 1);
float fY = lua_tonumber(L, 2);
float fZ = lua_tonumber(L, 3);
ImVec2 Convert3DTo2D(float x, float y, float z);
ImVec2 v2DPos = Convert3DTo2D(fX, fY, fZ);
lua_pushnumber(L, v2DPos.x);
lua_pushnumber(L, v2DPos.y);
return 2;
}

// end of Fast Quaternion functions
int RotateObject ( lua_State *L )
{
Expand Down Expand Up @@ -7022,8 +7090,20 @@ int DisplayCurrentScreen(lua_State* L)
lua_pushnumber(L, iSpecialLuaReturn);
return 1;
}
bool bDisableKeyToggles = false;
int DisableBoundHudKeys(lua_State* L)
{
bDisableKeyToggles = true;
return 0;
}
int EnableBoundHudKeys(lua_State* L)
{
bDisableKeyToggles = false;
return 0;
}
int CheckScreenToggles(lua_State* L)
{
if (bDisableKeyToggles) return 0;
extern void TriggerScreenFromKeyPress();
TriggerScreenFromKeyPress();
return 1;
Expand Down Expand Up @@ -9671,6 +9751,191 @@ int EffectSetLifespan(lua_State* L)
return 0;
}

#ifdef WICKEDPARTICLESYSTEM
std::vector<uint32_t> vWickedEmitterEffects;
void CleanUpEmitterEffects(void)
{
Scene& scene = wiScene::GetScene();

std::vector<uint32_t> vEntityDelete;
for (int i = 0; i < vWickedEmitterEffects.size(); i++)
{
uint32_t root = vWickedEmitterEffects[i];
for (int a = 0; a < scene.emitters.GetCount(); a++)
{
Entity emitter = scene.emitters.GetEntity(a);
HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter);
if (hier)
{
if (hier->parentID == root)
{
vEntityDelete.push_back(emitter);
}
}
}
vEntityDelete.push_back(root);
}

for (int i = 0; i < vEntityDelete.size(); i++)
{
scene.Entity_Remove(vEntityDelete[i]);
}
vEntityDelete.clear();
vWickedEmitterEffects.clear();
}

//PE: WParticleEffectPosition("FileName") - Return EffectID
int WParticleEffectLoad(lua_State* L)
{
lua = L;
int n = lua_gettop(L);
if (n < 1) return 0;

Scene& scene = wiScene::GetScene();

char pFileName[MAX_PATH];
strcpy(pFileName, lua_tostring(L, 1));

uint32_t root = 0;
uint32_t count_before = scene.emitters.GetCount();

cstr pOldDir = GetDir();

char path[MAX_PATH];
strcpy(path, pFileName);
GG_GetRealPath(path, 0);

WickedCall_LoadWiScene(path, false, NULL, NULL);
uint32_t count_after = scene.emitters.GetCount();
if (count_before != count_after)
{
Entity emitter = scene.emitters.GetEntity(scene.emitters.GetCount() - 1);
if (scene.emitters.GetCount() > 0)
{
Entity emitter = scene.emitters.GetEntity(0);
HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter);
if (hier)
{
root = hier->parentID;
}
}
wiEmittedParticle* ec = scene.emitters.GetComponent(emitter);
if (ec)
{
ec->Restart();
ec->SetVisible(true);
}
}
if (root != 0)
vWickedEmitterEffects.push_back(root);
lua_pushnumber(L, root);
return 1;

}
//PE: WParticleEffectPosition(EffectID,x,y,z)
int WParticleEffectPosition(lua_State* L)
{
lua = L;
int n = lua_gettop(L);
if (n < 4) return 0;

Entity root = lua_tonumber(L, 1);
float fX = lua_tonumber(L, 2);
float fY = lua_tonumber(L, 3);
float fZ = lua_tonumber(L, 4);

Scene& scene = wiScene::GetScene();
TransformComponent* root_tranform = scene.transforms.GetComponent(root);
if (root_tranform)
{
root_tranform->ClearTransform();
root_tranform->Translate(XMFLOAT3(fX, fY, fZ));
root_tranform->UpdateTransform();
}

//for (int i = 0; i < scene.emitters.GetCount(); i++)
//{
// Entity emitter = scene.emitters.GetEntity(i);
// HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter);
// if (hier)
// {
// if (hier->parentID == root)
// {
// }
// }
//}

return 0;
}
int WParticleEffectVisible(lua_State* L)
{
lua = L;
int n = lua_gettop(L);
if (n < 2) return 0;

Entity root = lua_tonumber(L, 1);
bool bVisible = lua_tonumber(L, 2);

Scene& scene = wiScene::GetScene();

for (int i = 0; i < scene.emitters.GetCount(); i++)
{
Entity emitter = scene.emitters.GetEntity(i);
HierarchyComponent* hier = scene.hierarchy.GetComponent(emitter);
if (hier)
{
if (hier->parentID == root)
{
wiEmittedParticle* ec = scene.emitters.GetComponent(emitter);
if (ec)
{
ec->SetVisible(bVisible);
}
}
}
}

return 0;
}

//WParticleEffectAction(EffectID,Action) - Action = 1 Burst all. 2 = Pause. - 3 = Resume. - 4 = Restart
int WParticleEffectAction(lua_State* L)
{
lua = L;
int n = lua_gettop(L);
if (n < 2) return 0;
Entity root = lua_tonumber(L, 1);
int iAction = lua_tonumber(L, 2);
WickedCall_PerformEmitterAction(iAction, root);
return 0;
}
//PE: Missing command for position sound if different then entity position.
int entity_lua_positionsound(lua_State* L)
{
int n = lua_gettop(L);
if (n < 5) return 0;
int e = lua_tonumber(L, 1);
int v = lua_tonumber(L, 2);
float fX = lua_tonumber(L, 3);
float fY = lua_tonumber(L, 4);
float fZ = lua_tonumber(L, 5);
int entity_lua_sound_convertVtoTSND(int te, int tv);
int snd = entity_lua_sound_convertVtoTSND(e, v);
if (snd > 0)
{
PositionSound(snd, fX, fY, fZ);
}
return 0;
}

//disableindoor
// rotate
// Stop
// copy lua code from app.
// add emitter with all settings.
#endif


// Misc Commands

int GetBulletHit(lua_State* L)
Expand Down Expand Up @@ -12179,6 +12444,11 @@ void addFunctions()
lua_register(lua, "QuatSLERP", QuatSLERP );
lua_register(lua, "QuatLERP", QuatLERP );

lua_register(lua, "Convert3DTo2D", LuaConvert3DTo2D); // x,y = Convert3DTo2D(x,y,z)
lua_register(lua, "Convert2DTo3D", LuaConvert2DTo3D); // px,py,pz,dx,dy,dz = Convert2DTo3D(x percent,y percent) -- percent
lua_register(lua, "ScreenCoordsToPercent", ScreenCoordsToPercent); // percentx,percentx = ScreenCordsToPercent(x,y) -- return percent positions.


// Lua control of dynamic light
lua_register(lua, "GetEntityLightNumber", GetEntityLightNumber );
lua_register(lua, "GetLightPosition", GetLightPosition );
Expand Down Expand Up @@ -12731,6 +13001,18 @@ void addFunctions()
lua_register(lua, "EffectSetColor", EffectSetColor);
lua_register(lua, "EffectSetLifespan", EffectSetLifespan);

#ifdef WICKEDPARTICLESYSTEM
//PE: Wicked particle system.
lua_register(lua, "WParticleEffectLoad", WParticleEffectLoad);
lua_register(lua, "WParticleEffectPosition", WParticleEffectPosition);
lua_register(lua, "WParticleEffectVisible", WParticleEffectVisible);
lua_register(lua, "WParticleEffectAction", WParticleEffectAction);

//PE: Other missing commands.
lua_register(lua, "PositionSound", entity_lua_positionsound);

#endif

lua_register(lua, "GetBulletHit", GetBulletHit);
lua_register(lua, "SetFlashLight" , SetFlashLight );
lua_register(lua, "SetAttachmentVisible" , SetAttachmentVisible );
Expand Down Expand Up @@ -12799,6 +13081,8 @@ void addFunctions()
lua_register(lua, "DisplayCurrentScreen", DisplayCurrentScreen);
lua_register(lua, "GetCurrentScreen", GetCurrentScreen);
lua_register(lua, "CheckScreenToggles", CheckScreenToggles);
lua_register(lua, "DisableBoundHudKeys", DisableBoundHudKeys);
lua_register(lua, "EnableBoundHudKeys", EnableBoundHudKeys);
lua_register(lua, "ScreenToggle", ScreenToggle);
lua_register(lua, "ScreenToggleByKey", ScreenToggleByKey);
lua_register(lua, "GetIfUsingTABScreen", GetIfUsingTABScreen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DARKLUA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>GGREDUCED;WIN32;NDEBUG;_WINDOWS;_USRDLL;DARKLUA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>lua;%(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\Dark Wicked Shared\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\;$(ProjectDir)..\..\..\..\SDK\RecastContrib;$(ProjectDir)..\..\..\..\SDK\RecastContrib\fastlz;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DebugUtils/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Detour/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourCrowd/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourTileCache/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Recast/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\;$(ProjectDir)..\..\..\..\SDK\RecastContrib\SDL\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../../../../../../WICKEDREPO/WickedEngine;lua;%(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\Dark Wicked Shared\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\;$(ProjectDir)..\..\..\..\SDK\RecastContrib;$(ProjectDir)..\..\..\..\SDK\RecastContrib\fastlz;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DebugUtils/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Detour/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourCrowd/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourTileCache/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Recast/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\;$(ProjectDir)..\..\..\..\SDK\RecastContrib\SDL\include</AdditionalIncludeDirectories>
<WholeProgramOptimization>false</WholeProgramOptimization>
<DisableSpecificWarnings>4005;4995;4723</DisableSpecificWarnings>
<InlineFunctionExpansion>Disabled</InlineFunctionExpansion>
Expand Down Expand Up @@ -133,14 +133,14 @@
<ClCompile>
<Optimization>Disabled</Optimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;DARKLUA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>GGREDUCED;WIN32;NDEBUG;_WINDOWS;_USRDLL;DARKLUA_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level1</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>lua;%(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\Dark Wicked Shared\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\;$(ProjectDir)..\..\..\..\SDK\RecastContrib;$(ProjectDir)..\..\..\..\SDK\RecastContrib\fastlz;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DebugUtils/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Detour/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourCrowd/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourTileCache/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Recast/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\;$(ProjectDir)..\..\..\..\SDK\RecastContrib\SDL\include</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>../../../../../../WICKEDREPO/WickedEngine;lua;%(AdditionalIncludeDirectories);$(ProjectDir)..\..\..\Include\;$(ProjectDir)..\..\..\..\Dark Wicked Shared\Include\;$(ProjectDir)..\..\..\..\GameGuru\Include\;$(ProjectDir)..\..\..\..\SDK\RecastContrib;$(ProjectDir)..\..\..\..\SDK\RecastContrib\fastlz;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DebugUtils/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Detour/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourCrowd/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\DetourTileCache/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\Recast/Include;$(ProjectDir)..\..\..\..\Guru-WickedMAX\GGRecastDetour\;$(ProjectDir)..\..\..\..\SDK\RecastContrib\SDL\include</AdditionalIncludeDirectories>
<WholeProgramOptimization>false</WholeProgramOptimization>
<DisableSpecificWarnings>4005;4995;4723</DisableSpecificWarnings>
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7585,6 +7585,9 @@ DARKSDK_DLL bool LoadDBO ( LPSTR pPassedInFilename, sObject** ppObject )
// construct the object
if (!DBOConvertBlockToObject((void*)pDBOBlock, dwBlockSize, ppObject))
{
char str[1024];
sprintf_s(str, "Failed to load object: %s", pFilename);
Message(0, str, "Error");
RunTimeError(RUNTIMEERROR_B3DOBJECTLOADFAILED);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,9 @@ DARKSDK_DLL bool SetNewObjectFinalProperties ( int iID, float fRadius )
if ( pObject->ppFrameList==NULL )
{
// free object if insufficient data
char str[1024];
sprintf_s(str, "ObjectID: %d. Do not have a framelist.", iID);
Message(0, str, "Error");
RunTimeError ( RUNTIMEERROR_B3DOBJECTLOADFAILED );
SAFE_DELETE ( g_ObjectList [ iID ] );
return false;
Expand Down
Loading