Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions Client/game_sa/CPhysicalSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class CPhysicalSAInterface : public CEntitySAInterface
CVector m_vecUnk; // 280
uint32 m_pad4; // 292
CPtrNodeDoubleLink<void>* m_pControlCodeNodeLink; // 296
float m_fLighting; // 300
float m_fLighting2; // 304
float m_fLighting; // 300 surface brightness
float m_fLighting2; // 304 dynamic lighting (unused, always set to 0 in the GTA code)
class CShadowDataSA* m_pShadowData; // 308

CRect* GetBoundRect_(CRect* pRect);
Expand Down
42 changes: 42 additions & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void CLuaElementDefs::LoadFunctions()
{"setElementFrozen", SetElementFrozen},
{"setLowLODElement", ArgumentParser<SetLowLodElement>},
{"setElementCallPropagationEnabled", SetElementCallPropagationEnabled},
{"setElementLighting", ArgumentParser<SetElementLighting>},
};

// Add functions
Expand Down Expand Up @@ -191,6 +192,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setLowLOD", "setLowLODElement");
lua_classfunction(luaVM, "setCallPropagationEnabled", "setElementCallPropagationEnabled");
lua_classfunction(luaVM, "setStreamable", "setElementStreamable");
lua_classfunction(luaVM, "setLighting", "setElementLighting");

lua_classvariable(luaVM, "callPropagationEnabled", "setElementCallPropagationEnabled", "isElementCallPropagationEnabled");
lua_classvariable(luaVM, "waitingForGroundToLoad", NULL, "isElementWaitingForGroundToLoad");
Expand Down Expand Up @@ -225,6 +227,7 @@ void CLuaElementDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "velocity", SetElementVelocity, OOP_GetElementVelocity);
lua_classvariable(luaVM, "angularVelocity", SetElementAngularVelocity, OOP_GetElementTurnVelocity);
lua_classvariable(luaVM, "isElement", NULL, "isElement");
lua_classvariable(luaVM, "lighting", "setElementLighting", "getElementLighting");
// TODO: Support element data: player.data["age"] = 1337; <=> setElementData(player, "age", 1337)

lua_registerclass(luaVM, "Element");
Expand Down Expand Up @@ -1340,6 +1343,7 @@ std::variant<bool, float> CLuaElementDefs::GetElementLighting(CClientEntity* ent
break;
}
case CCLIENTOBJECT:
case CCLIENTWEAPON:
{
CObject* object = static_cast<CClientObject*>(entity)->GetGameObject();
if (object)
Expand Down Expand Up @@ -2604,3 +2608,41 @@ int CLuaElementDefs::IsElementWaitingForGroundToLoad(lua_State* luaVM)
lua_pushboolean(luaVM, false);
return 1;
}

bool CLuaElementDefs::SetElementLighting(CClientEntity* entity, float lighting)
{
switch (entity->GetType())
{
case CCLIENTPLAYER:
case CCLIENTPED:
{
auto* ped = static_cast<CClientPed*>(entity)->GetGamePlayer();
if (!ped)
return false;

ped->SetLighting(lighting);
return true;
}
case CCLIENTVEHICLE:
{
auto* vehicle = static_cast<CClientVehicle*>(entity)->GetGameVehicle();
if (!vehicle)
return false;

vehicle->SetLighting(lighting);
return true;
}
case CCLIENTOBJECT:
case CCLIENTWEAPON:
{
auto* object = static_cast<CClientObject*>(entity)->GetGameObject();
if (!object)
return false;

object->SetLighting(lighting);
return true;
}
}

return false;
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ class CLuaElementDefs : public CLuaDefs
LUA_DECLARE(SetElementFrozen);
static bool SetLowLodElement(lua_State* luaVM, CClientEntity* pEntity, std::optional<CClientEntity*> pLowLodEntity);
LUA_DECLARE(SetElementCallPropagationEnabled);
static bool SetElementLighting(CClientEntity* entity, float lighting);
};
Loading