Skip to content

Commit

Permalink
custom impostor bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GDjkhp committed Jun 18, 2024
1 parent 9cea59f commit ca5c8e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
15 changes: 13 additions & 2 deletions gui/tabs/host_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace HostTab {
if (openUtils) {
if (IsInLobby()) {
ImGui::BeginChild("host#list", ImVec2(200, 0) * State.dpiScale, true, ImGuiWindowFlags_NoBackground);
bool shouldEndListBox = ImGui::ListBoxHeader("Choose Roles", ImVec2(200, 150) * State.dpiScale);
bool shouldEndListBox = ImGui::ListBoxHeader("Choose Roles", ImVec2(200, 290) * State.dpiScale);
auto allPlayers = GetAllPlayerData();
auto playerAmount = allPlayers.size();
auto maxImpostorAmount = GetMaxImpostorAmount((int)playerAmount);
Expand Down Expand Up @@ -93,6 +93,17 @@ namespace HostTab {
if (State.engineers_amount + State.scientists_amount + State.crewmates_amount >= (int)playerAmount)
State.assignedRoles[index] = RoleType::Random;
} //Some may set all players to non imps. This hangs the game on beginning. Leave space to Random so we have imps.

if (options.GetGameMode() == GameModes__Enum::HideNSeek)
{
if (State.assignedRoles[index] == RoleType::Shapeshifter)
State.assignedRoles[index] = RoleType::Random;
else if (State.assignedRoles[index] == RoleType::Scientist)
State.assignedRoles[index] = RoleType::Engineer;
else if (State.assignedRoles[index] == RoleType::Crewmate)
State.assignedRoles[index] = RoleType::Engineer;
} //Assign other roles in hidenseek causes game bug.
//These are organized. Do not change the order unless you find it necessary.

if (!IsInGame()) {
if (options.GetGameMode() == GameModes__Enum::HideNSeek)
Expand All @@ -116,7 +127,7 @@ namespace HostTab {
if (IsInLobby() && ToggleButton("Custom Impostor Amount", &State.CustomImpostorAmount))
State.Save();
State.ImpostorCount = std::clamp(State.ImpostorCount, 0, int(Game::MAX_PLAYERS));
if (IsInLobby() && ImGui::InputInt("Impostor Count", &State.ImpostorCount))
if (IsInLobby() && State.CustomImpostorAmount && ImGui::InputInt("Impostor Count", &State.ImpostorCount))
State.Save();

/*int32_t maxPlayers = options.GetMaxPlayers();
Expand Down
2 changes: 1 addition & 1 deletion gui/tabs/players_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace PlayersTab {
ImGui::SameLine(100 * State.dpiScale);
ImGui::BeginChild("players#list", ImVec2(200, 0) * State.dpiScale, true, ImGuiWindowFlags_NoBackground);
auto selectedPlayer = State.selectedPlayer.validate();
bool shouldEndListBox = ImGui::ListBoxHeader("###players#list", ImVec2(200, 150) * State.dpiScale);
bool shouldEndListBox = ImGui::ListBoxHeader("###players#list", ImVec2(200, 230) * State.dpiScale);
auto localData = GetPlayerData(*Game::pLocalPlayer);
std::vector<PlayerSelection> selectedPlayers = {};
for (auto id : State.selectedPlayers) {
Expand Down
8 changes: 2 additions & 6 deletions hooks/RoleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ void AssignRoles(RoleRates& roleRates, int roleChance, RoleTypes__Enum role, il2
// return; //Skip assigns when pre assigned enough imps.
//}

if (options.GetGameMode() == GameModes__Enum::HideNSeek) {
if (role == RoleTypes__Enum::Impostor)
roleCount = maxImpostorAmount; //Sometime the game would accidently make imp amount > what we want.
if (role == RoleTypes__Enum::Engineer)
roleCount = playerAmount - maxImpostorAmount; //For unknown reason Game simply set engineer amount in hidenseek to 0.
}
if (options.GetGameMode() == GameModes__Enum::HideNSeek && role == RoleTypes__Enum::Engineer)
roleCount = allPlayers.size() - 1;

if (role == RoleTypes__Enum::Shapeshifter && roleCount >= maxImpostorAmount)
roleCount = maxImpostorAmount; //In previous version, aum would assign more imps than MaxImpostorAmount based on shapeshifter amount.
Expand Down

0 comments on commit ca5c8e0

Please sign in to comment.