From 595d87423407391467be85e18490f8cdbe5f916a Mon Sep 17 00:00:00 2001 From: tedpark217 Date: Thu, 6 Jun 2024 18:39:25 -0700 Subject: [PATCH] change cut light range / update lobby gui again --- config.json | 8 ++++---- include/server/game/constants.hpp | 3 ++- include/server/game/torchlight.hpp | 2 +- src/client/gui/gui.cpp | 4 ++-- src/server/game/servergamestate.cpp | 4 +++- src/server/game/torchlight.cpp | 22 ++++++++++++---------- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/config.json b/config.json index 3601e59f..8045f629 100644 --- a/config.json +++ b/config.json @@ -2,7 +2,7 @@ "game": { "maze": { "directory": "maps", - "procedural": false, + "procedural": true, "maze_file": "test/itemRoom.maze" }, "disable_enemies": true @@ -14,17 +14,17 @@ "server": { "lobby_name": "Hope you're doing well!", "lobby_broadcast": true, - "max_players": 1, + "max_players": 2, "disable_dm": false, "skip_intro": true }, "client": { "default_name": "Conan O'Brien", "lobby_discovery": true, - "fullscreen": false, + "fullscreen": true, "draw_bboxes": false, "fps_counter": true, "presentation": false, - "render": 50 + "render": 75 } } diff --git a/include/server/game/constants.hpp b/include/server/game/constants.hpp index fa293223..4a767a83 100644 --- a/include/server/game/constants.hpp +++ b/include/server/game/constants.hpp @@ -85,4 +85,5 @@ #define ITEM_SPAWN_BOUND 3 #define LIGHTNING_LIGHT_CUT_TICKS 100 #define LIGHT_CUT_TICKS 200 -#define LIGHT_CUT_RANGE 25.0 \ No newline at end of file +#define LIGHT_CUT_RANGE 60.0 +#define LIGHT_CUT_RANGE_LIGHTNING 20.0 \ No newline at end of file diff --git a/include/server/game/torchlight.hpp b/include/server/game/torchlight.hpp index e3db996c..bfa600d3 100644 --- a/include/server/game/torchlight.hpp +++ b/include/server/game/torchlight.hpp @@ -32,7 +32,7 @@ class Torchlight : public Object { * @param the position the lightning hit (if exists) * @param the position of the light cut action (if exists) */ - void doTick(ServerGameState& state, std::optional lightning_light_cut_pos, std::optional action_light_cut_pos); + bool doTick(ServerGameState& state, std::optional lightning_light_cut_pos, std::optional action_light_cut_pos); /** * @brief manually set torchlight intensity, for use in intro cutscene diff --git a/src/client/gui/gui.cpp b/src/client/gui/gui.cpp index 4998e758..fc361be1 100644 --- a/src/client/gui/gui.cpp +++ b/src/client/gui/gui.cpp @@ -607,7 +607,7 @@ gui::widget::Flexbox::Ptr GUI::_createPlayerStatusRow( if (lobbyPlayer.get().desired_role == PlayerRole::DungeonMaster) { // Subcase 3 playerRoleString = "Player " + std::to_string(playerIndex) - + " wants to play as the Zeus."; + + " wants to play as Zeus."; color = font::Color::YELLOW; } else if (lobbyPlayer.get().desired_role == PlayerRole::Player) { @@ -877,7 +877,7 @@ gui::widget::Flexbox::Ptr GUI::_createPlayerStatusRow( color = font::Color::YELLOW; } else if (lobbyPlayer.get().desired_role == PlayerRole::Player) { - playerRoleString = "You want to play as the Player."; + playerRoleString = "You want to play as a Player."; color = font::Color::WHITE; } diff --git a/src/server/game/servergamestate.cpp b/src/server/game/servergamestate.cpp index 5f8a3b55..56dfe40c 100644 --- a/src/server/game/servergamestate.cpp +++ b/src/server/game/servergamestate.cpp @@ -1185,7 +1185,9 @@ void ServerGameState::doTorchlightTicks() { if (torchlight == nullptr) continue; - torchlight->doTick(*this, this->dmLightningCutLights, this->dmActionCutLights); + if (torchlight->doTick(*this, this->dmLightningCutLights, this->dmActionCutLights)) { + this->updated_entities.insert(torchlight->globalID); + } } } diff --git a/src/server/game/torchlight.cpp b/src/server/game/torchlight.cpp index 61ad6e7e..b4a8fd0b 100644 --- a/src/server/game/torchlight.cpp +++ b/src/server/game/torchlight.cpp @@ -10,13 +10,14 @@ SharedObject Torchlight::toShared() { auto so = Object::toShared(); - so.pointLightInfo = SharedPointLightInfo { + so.pointLightInfo = SharedPointLightInfo{ .intensity = this->curr_intensity, .ambient_color = this->properties.ambient_color, .diffuse_color = this->properties.diffuse_color, .specular_color = this->properties.specular_color, .attenuation_linear = this->properties.attenuation_linear, - .attenuation_quadratic = this->properties.attenuation_quadratic + .attenuation_quadratic = this->properties.attenuation_quadratic, + .is_cut = this->is_cut }; return so; } @@ -131,9 +132,9 @@ void Torchlight::init() { Torchlight::~Torchlight() {} -void Torchlight::doTick(ServerGameState& state, std::optional lightning_light_cut_pos, std::optional action_light_cut_pos) { +bool Torchlight::doTick(ServerGameState& state, std::optional lightning_light_cut_pos, std::optional action_light_cut_pos) { if(!this->properties.flickering) { - return; + return false; } // cut this light if within position of light cut @@ -141,9 +142,9 @@ void Torchlight::doTick(ServerGameState& state, std::optional lightni glm::vec3 pos = lightning_light_cut_pos.value(); // if within threshold, get out - if (glm::distance(pos, this->physics.shared.getCenterPosition()) <= LIGHT_CUT_RANGE) { - this->curr_intensity = 0.0f; - return; + if (glm::distance(pos, this->physics.shared.getCenterPosition()) <= LIGHT_CUT_RANGE_LIGHTNING) { + this->curr_intensity = 0.2f; + return false; } } @@ -151,10 +152,10 @@ void Torchlight::doTick(ServerGameState& state, std::optional lightni glm::vec3 pos = action_light_cut_pos.value(); // if within threshold, black out (slightly expand the light cut action range) - if (glm::distance(pos, this->physics.shared.getCenterPosition()) <= (1.5 * LIGHT_CUT_RANGE)) { - this->curr_intensity = 0.0f; + if (glm::distance(pos, this->physics.shared.getCenterPosition()) <= (LIGHT_CUT_RANGE)) { + this->curr_intensity = 0.2f; this->is_cut = true; - return; + return true; } } @@ -187,6 +188,7 @@ void Torchlight::doTick(ServerGameState& state, std::optional lightni } else if (this->curr_intensity < this->properties.min_intensity) { this->curr_intensity = this->properties.min_intensity; } + return false; } float Torchlight::getIntensity() const {