Skip to content

Commit

Permalink
Fix more visual glitches
Browse files Browse the repository at this point in the history
  • Loading branch information
g0aty committed Dec 20, 2024
1 parent 92b019b commit 4db5e95
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 34 deletions.
49 changes: 26 additions & 23 deletions hooks/MeetingHud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,33 @@ void dMeetingHud_Close(MeetingHud* __this, MethodInfo* method) {
PlayerControl_CmdCheckName(p, GetPlayerOutfit(playerData)->fields.PlayerName, NULL);
}
}*/
uint8_t alivePlayers = 0;
for (auto p : GetAllPlayerData()) {
if (!p->fields.IsDead) alivePlayers++;
}
for (auto i : State.voteMonitor) {
if (alivePlayers < 7) break;
auto voter = GetPlayerDataById(i.first), target = GetPlayerDataById(i.second);
if (target == NULL || target->fields.IsDead) continue;
std::string voterFc = convert_from_string(voter->fields.FriendCode), targetFc = convert_from_string(target->fields.FriendCode);
if (!PlayerIsImpostor(voter) &&
std::find(State.tournamentCallers.begin(), State.tournamentCallers.end(), voterFc) == State.tournamentCallers.end() &&
std::find(State.tournamentCalledOut.begin(), State.tournamentCalledOut.end(), targetFc) == State.tournamentCalledOut.end()) {
if (PlayerIsImpostor(target)) {
UpdatePoints(voter, 1.5); //CorrectCallout
State.tournamentCalloutPoints[voterFc] += 1;
LOG_DEBUG("Correct callout by " + ToString(target));
State.tournamentCorrectCallers[voterFc] = target->fields.PlayerId;
}
else {
UpdatePoints(voter, -1.5); //IncorrectCallout
LOG_DEBUG("Incorrect callout by " + ToString(target));
State.vanishedPlayers.clear();
if (IsHost() && State.TournamentMode) {
uint8_t alivePlayers = 0;
for (auto p : GetAllPlayerData()) {
if (!p->fields.IsDead) alivePlayers++;
}
for (auto i : State.voteMonitor) {
if (alivePlayers < 7) break;
auto voter = GetPlayerDataById(i.first), target = GetPlayerDataById(i.second);
if (target == NULL || target->fields.IsDead) continue;
std::string voterFc = convert_from_string(voter->fields.FriendCode), targetFc = convert_from_string(target->fields.FriendCode);
if (!PlayerIsImpostor(voter) &&
std::find(State.tournamentCallers.begin(), State.tournamentCallers.end(), voterFc) == State.tournamentCallers.end() &&
std::find(State.tournamentCalledOut.begin(), State.tournamentCalledOut.end(), targetFc) == State.tournamentCalledOut.end()) {
if (PlayerIsImpostor(target)) {
UpdatePoints(voter, 1.5); //CorrectCallout
State.tournamentCalloutPoints[voterFc] += 1;
LOG_DEBUG("Correct callout by " + ToString(target));
State.tournamentCorrectCallers[voterFc] = target->fields.PlayerId;
}
else {
UpdatePoints(voter, -1.5); //IncorrectCallout
LOG_DEBUG("Incorrect callout by " + ToString(target));
}
State.tournamentCallers.push_back(voterFc);
State.tournamentCalledOut.push_back(targetFc);
}
State.tournamentCallers.push_back(voterFc);
State.tournamentCalledOut.push_back(targetFc);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions hooks/PlayerControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void dPlayerControl_FixedUpdate(PlayerControl* __this, MethodInfo* method) {

bool hideName = GameOptions().GetGameMode() == GameModes__Enum::HideNSeek && !(GameOptions().GetBool(app::BoolOptionNames__Enum::ShowCrewmateNames));

bool shouldSeeName = ((!State.PanicMode && (State.RevealRoles || State.ShowKillCD || State.PlayerColoredDots)) || PlayerControl_get_Visible(__this, NULL)) && !hideName;
bool shouldSeeName = ((!State.PanicMode && (State.RevealRoles || State.ShowKillCD || State.PlayerColoredDots)) || !hideName) && PlayerControl_get_Visible(__this, NULL);

if (State.PlayerColoredDots && shouldSeeName && !State.PanicMode)
{
Expand Down Expand Up @@ -605,9 +605,9 @@ void dPlayerControl_FixedUpdate(PlayerControl* __this, MethodInfo* method) {
isPlaying = true;
break;
}
if (isPlaying == State.ShowProtections)
if (isPlaying == (State.ShowProtections && !State.PanicMode))
break;
if (!State.ShowProtections)
if (!State.ShowProtections || State.PanicMode)
app::PlayerControl_RemoveProtection(__this, nullptr);
std::pair<int32_t/*ColorId*/, float/*Time*/> pair;
synchronized(State.protectMutex) {
Expand All @@ -619,7 +619,7 @@ void dPlayerControl_FixedUpdate(PlayerControl* __this, MethodInfo* method) {
if (_Duration > 0.f)
app::PlayerControl_TurnOnProtection(__this, State.ShowProtections, pair.first, __this->fields.protectedByGuardianId, nullptr);
options.SetFloat(app::FloatOptionNames__Enum::ProtectionDurationSeconds, ProtectionDurationSeconds);
} while (State.PanicMode);
} while (0);

/*if ((State.Wallhack || State.IsRevived) && __this == *Game::pLocalPlayer && !State.FreeCam
&& !State.playerToFollow.has_value() && !State.PanicMode) {
Expand Down
18 changes: 13 additions & 5 deletions hooks/PlayerPhysics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,41 @@ void dPlayerPhysics_FixedUpdate(PlayerPhysics* __this, MethodInfo* method)
bool shouldSeeGhost = localData->fields.IsDead || State.ShowGhosts;
auto playerData = GetPlayerData(player);
auto roleType = playerData->fields.RoleType;
bool isFullyVanished = std::find(State.vanishedPlayers.begin(), State.vanishedPlayers.end(), GetPlayerData(player)->fields.PlayerId) != State.vanishedPlayers.end();
bool isFullyVanished = std::find(State.vanishedPlayers.begin(), State.vanishedPlayers.end(), playerData->fields.PlayerId) != State.vanishedPlayers.end();
bool isDead = playerData->fields.IsDead;
auto nameText = Component_get_gameObject((Component_1*)player->fields.cosmetics->fields.nameText, NULL);
bool isSeekerBody = player->fields.cosmetics->fields.bodyType == PlayerBodyTypes__Enum::Seeker || player->fields.cosmetics->fields.bodyType == PlayerBodyTypes__Enum::LongSeeker;
if (player->fields.inVent) {
if (!PlayerControl_get_Visible(player, NULL) && State.ShowPlayersInVents && (!isFullyVanished || shouldSeePhantom) && !State.PanicMode) {
PlayerControl_set_Visible(player, true, NULL);
GameObject_SetActive(nameText, true, NULL);
player->fields.invisibilityAlpha = 0.5f;
CosmeticsLayer_SetPhantomRoleAlpha(player->fields.cosmetics, player->fields.invisibilityAlpha, NULL);
if (isSeekerBody) {
SpriteRenderer_set_color(player->fields.cosmetics->fields.skin->fields.layer, Palette__TypeInfo->static_fields->ClearWhite, NULL);
}
}
else if (player->fields.invisibilityAlpha == 0.5f && (!(State.ShowPlayersInVents && (!isFullyVanished || shouldSeePhantom)) || State.PanicMode)) {
PlayerControl_set_Visible(player, false, NULL);
GameObject_SetActive(nameText, false, NULL);
player->fields.invisibilityAlpha = 0.f;
CosmeticsLayer_SetPhantomRoleAlpha(player->fields.cosmetics, player->fields.invisibilityAlpha, NULL);
if (isSeekerBody) {
SpriteRenderer_set_color(player->fields.cosmetics->fields.skin->fields.layer, Palette__TypeInfo->static_fields->ClearWhite, NULL);
}
}
}
else if (!isDead) {
player->fields.invisibilityAlpha = isFullyVanished ? (shouldSeePhantom ? 0.5f : 0.f) : 1.f;
CosmeticsLayer_SetPhantomRoleAlpha(player->fields.cosmetics, player->fields.invisibilityAlpha, NULL);
PlayerControl_set_Visible(player, player->fields.invisibilityAlpha > 0.f, NULL);
GameObject_SetActive(nameText, player->fields.invisibilityAlpha > 0.f, NULL);
if (isSeekerBody) {
SpriteRenderer_set_color(player->fields.cosmetics->fields.skin->fields.layer, Palette__TypeInfo->static_fields->ClearWhite, NULL);
}
}
else if (playerData->fields.IsDead) {
PlayerControl_set_Visible(player, shouldSeeGhost && !State.PanicMode, NULL);
GameObject_SetActive(nameText, shouldSeeGhost && !State.PanicMode, NULL);
player->fields.invisibilityAlpha = shouldSeeGhost && !State.PanicMode ? 1.f : 0.f;
}
GameObject_SetActive(nameText, player->fields.invisibilityAlpha > 0.f, NULL);
}
app::PlayerPhysics_FixedUpdate(__this, method);
}
Expand Down
4 changes: 2 additions & 2 deletions rpc/RpcSetRole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ void RpcSetRole::Process()
{
if (Player == nullptr) return;

bool isDeadRole = Role == RoleTypes__Enum::CrewmateGhost || Role == RoleTypes__Enum::GuardianAngel || Role == RoleTypes__Enum::ImpostorGhost;
//bool isDeadRole = Role == RoleTypes__Enum::CrewmateGhost || Role == RoleTypes__Enum::GuardianAngel || Role == RoleTypes__Enum::ImpostorGhost;

PlayerControl_RpcSetRole(Player, Role, Player->fields.roleAssigned && !isDeadRole, NULL);
PlayerControl_RpcSetRole(Player, Role, true, NULL);
}

SetRole::SetRole(RoleTypes__Enum role)
Expand Down

0 comments on commit 4db5e95

Please sign in to comment.