diff --git a/src/otclient/luafunctions.cpp b/src/otclient/luafunctions.cpp index 2875d10c..9478fad9 100644 --- a/src/otclient/luafunctions.cpp +++ b/src/otclient/luafunctions.cpp @@ -521,6 +521,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassMemberFunction("setAnimated", &UIMap::setAnimated); g_lua.bindClassMemberFunction("setKeepAspectRatio", &UIMap::setKeepAspectRatio); g_lua.bindClassMemberFunction("setMapShader", &UIMap::setMapShader); + g_lua.bindClassMemberFunction("setMinimumAmbientLight", &UIMap::setMinimumAmbientLight); g_lua.bindClassMemberFunction("isMultifloor", &UIMap::isMultifloor); g_lua.bindClassMemberFunction("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled); g_lua.bindClassMemberFunction("isDrawingTexts", &UIMap::isDrawingTexts); @@ -539,6 +540,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassMemberFunction("getMaxZoomOut", &UIMap::getMaxZoomOut); g_lua.bindClassMemberFunction("getZoom", &UIMap::getZoom); g_lua.bindClassMemberFunction("getMapShader", &UIMap::getMapShader); + g_lua.bindClassMemberFunction("getMinimumAmbientLight", &UIMap::getMinimumAmbientLight); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UIProgressRectPtr(new UIProgressRect); } ); diff --git a/src/otclient/mapview.cpp b/src/otclient/mapview.cpp index e20daffd..f184a046 100644 --- a/src/otclient/mapview.cpp +++ b/src/otclient/mapview.cpp @@ -57,6 +57,7 @@ MapView::MapView() m_cachedFirstVisibleFloor = 7; m_cachedLastVisibleFloor = 7; m_updateTilesPos = 0; + m_minimumAmbientLight = 0; m_optimizedSize = Size(Otc::AWARE_X_TILES, Otc::AWARE_Y_TILES) * Otc::TILE_PIXELS; m_framebuffer = g_framebuffers.createFrameBuffer(); @@ -102,14 +103,15 @@ void MapView::draw(const Rect& rect) m_lightView->reset(); m_lightView->resize(m_framebuffer->getSize()); - if(cameraPosition.z <= 7) - m_lightView->setGlobalLight(g_map.getLight()); - else { - Light undergroundLight; - undergroundLight.color = 215; - undergroundLight.intensity = 16; - m_lightView->setGlobalLight(undergroundLight); + Light ambientLight; + if(cameraPosition.z <= 7) { + ambientLight = g_map.getLight(); + } else { + ambientLight.color = 215; + ambientLight.intensity = 0; } + ambientLight.intensity = std::max(m_minimumAmbientLight*255, ambientLight.intensity); + m_lightView->setGlobalLight(ambientLight); } } g_painter->setColor(Color::white); diff --git a/src/otclient/mapview.h b/src/otclient/mapview.h index eee84ad1..bed821a1 100644 --- a/src/otclient/mapview.h +++ b/src/otclient/mapview.h @@ -88,6 +88,9 @@ public: void setCameraPosition(const Position& pos); Position getCameraPosition(); + void setMinimumAmbientLight(float intensity) { m_minimumAmbientLight = intensity; } + float getMinimumAmbientLight() { return m_minimumAmbientLight; } + // drawing related void setDrawFlags(Otc::DrawFlags drawFlags) { m_drawFlags = drawFlags; requestVisibleTilesCacheUpdate(); } Otc::DrawFlags getDrawFlags() { return m_drawFlags; } @@ -149,6 +152,7 @@ private: Otc::DrawFlags m_drawFlags; std::vector m_spiral; LightViewPtr m_lightView; + float m_minimumAmbientLight; }; #endif diff --git a/src/otclient/uimap.h b/src/otclient/uimap.h index ad76338f..d3cfb0fc 100644 --- a/src/otclient/uimap.h +++ b/src/otclient/uimap.h @@ -56,6 +56,7 @@ public: void setAnimated(bool enable) { m_mapView->setAnimated(enable); } void setKeepAspectRatio(bool enable); void setMapShader(const PainterShaderProgramPtr& shader) { m_mapView->setShader(shader); } + void setMinimumAmbientLight(float intensity) { m_mapView->setMinimumAmbientLight(intensity); } bool isMultifloor() { return m_mapView->isMultifloor(); } bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); } @@ -76,6 +77,7 @@ public: int getMaxZoomOut() { return m_maxZoomOut; } int getZoom() { return m_zoom; } PainterShaderProgramPtr getMapShader() { return m_mapView->getShader(); } + float getMinimumAmbientLight() { return m_mapView->getMinimumAmbientLight(); } protected: virtual void onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode);