Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dabao40 committed Dec 28, 2024
1 parent 667bb79 commit be78790
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 265 deletions.
Binary file modified Strings.xlsx
Binary file not shown.
157 changes: 26 additions & 131 deletions TheOtherRoles/Buttons.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions TheOtherRoles/CustomGameModes/FreePlayGM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void SetWidget(int tab)

if (tab == 0)
{
inner = gui.Arrange(GUIAlignment.Center, RoleInfo.allRoleInfos.Where(x => x != RoleInfo.bomberB && x != RoleInfo.bomberA && x != RoleInfo.mimicA && x != RoleInfo.mimicK && x != RoleInfo.arsonist && x != RoleInfo.bountyHunter && !x.isModifier).Select(r => gui.RawButton(GUIAlignment.Center, roleMaskedTittleAttr, Helpers.cs(r.color, r.name), () =>
inner = gui.Arrange(GUIAlignment.Center, RoleInfo.allRoleInfos.Where(x => x != RoleInfo.bomberB && !x.isModifier).Select(r => gui.RawButton(GUIAlignment.Center, roleMaskedTittleAttr, Helpers.cs(r.color, r.name), () =>
{
bool isImpostorFormer = PlayerControl.LocalPlayer.Data.Role.IsImpostor;
var formerRole = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer, false).FirstOrDefault();
Expand Down Expand Up @@ -141,7 +141,7 @@ public static void removeModifier(RoleId modifierId)
break;
case RoleId.Chameleon:
Chameleon.chameleon.RemoveAll(x => x.PlayerId == playerId);
Chameleon.lastMoved.Clear();
Chameleon.removeChameleonFully(player);
break;
case RoleId.Invert:
Invert.invert.RemoveAll(x => x.PlayerId == playerId);
Expand Down
2 changes: 0 additions & 2 deletions TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ public class CustomOptionHolder {
public static CustomOption fungleElectrical;
public static CustomOption miraVitals;
public static CustomOption randomGameStartPosition;
public static CustomOption noticeNewDeadBodies;
public static CustomOption activateProps;
public static CustomOption numAccelTraps;
public static CustomOption accelerationDuration;
Expand Down Expand Up @@ -1224,7 +1223,6 @@ public static void Load() {
airshipAdditionalSpawn = CustomOption.Create(6073, Types.General, "airshipAdditionalSpawn", false);
fungleElectrical = CustomOption.Create(6074, Types.General, "fungleElectrical", false);
randomGameStartPosition = CustomOption.Create(6071, Types.General, "randomGameStartPosition", false);
noticeNewDeadBodies = CustomOption.Create(6098, Types.General, "noticeNewDeadBodies", true);

camsNightVision = CustomOption.Create(11, Types.General, "camsNightVision", false, null, true, heading: "headingNightVision");
camsNoNightVisionIfImpVision = CustomOption.Create(12, Types.General, "camsNoNightVisionIfImpVision", false, camsNightVision, false);
Expand Down
30 changes: 29 additions & 1 deletion TheOtherRoles/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,13 @@ static public SpriteRenderer CreateSharpBackground(SpriteRenderer renderer, Colo
return renderer;
}

static public float GetKillCooldown(this PlayerControl player)
{
if (player == SerialKiller.serialKiller) return SerialKiller.killCooldown;
if (player == SchrodingersCat.schrodingersCat) return SchrodingersCat.killCooldown;
return GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown;
}

static public IEnumerator Sequence(params IEnumerator[] enumerator)
{
foreach (var e in enumerator) yield return e;
Expand Down Expand Up @@ -978,7 +985,7 @@ public static void setLook(this PlayerControl target, String playerName, int col

SkinViewData nextSkin = null;
try { nextSkin = ShipStatus.Instance.CosmeticsCache.GetSkin(skinId); } catch { return; };

PlayerPhysics playerPhysics = target.MyPhysics;
AnimationClip clip = null;
var spriteAnim = playerPhysics.myPlayer.cosmetics.skin.animator;
Expand Down Expand Up @@ -1438,6 +1445,27 @@ public static List<PlayerControl> getKillerTeamMembers(PlayerControl player) {
return team;
}

/// <summary>
/// Check whether the action should be done. (i.e. Veteran alert)
/// </summary>
/// <param name="player">The action player</param>
/// <param name="target">The target of the action player</param>
/// <returns></returns>
public static bool checkSuspendAction(PlayerControl player, PlayerControl target)
{
if (player == null || target == null) return false;
if (Veteran.veteran != null && target == Veteran.veteran && Veteran.alertActive)
{
if (isEvil(player))
{
_ = checkMuderAttempt(player, target); // Gives the Veteran the achievement
checkMurderAttemptAndKill(target, player);
return true;
}
}
return false;
}

public static bool isNeutral(PlayerControl player) {
RoleInfo roleInfo = RoleInfo.getRoleInfoForPlayer(player, false, true).FirstOrDefault();
if (roleInfo != null)
Expand Down
9 changes: 0 additions & 9 deletions TheOtherRoles/Modules/CustomOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,6 @@ public static void drawTab(LobbyViewSettingsPane __instance, CustomOptionType op
if ((int)optionType == 99)
categoryHeaderMasked.Title.text = new Dictionary<CustomOptionType, string>() { { CustomOptionType.Impostor, ModTranslation.getString("impostorRoles") }, { CustomOptionType.Neutral, ModTranslation.getString("neutralRoles") },
{ CustomOptionType.Crewmate, ModTranslation.getString("crewmateRoles") }, { CustomOptionType.Modifier, ModTranslation.getString("modifiers") } }[curType];
var color = titleText.Contains("<color=") && (int)optionType != 99 ? Helpers.HexToColor(titleText.Substring(8, 6)) : Color.white;
categoryHeaderMasked.Title.outlineColor = color;
categoryHeaderMasked.Title.outlineWidth = 0.2f;
categoryHeaderMasked.transform.SetParent(__instance.settingsContainer);
categoryHeaderMasked.transform.localScale = Vector3.one;
categoryHeaderMasked.transform.localPosition = new Vector3(-9.77f, num, -2f);
Expand Down Expand Up @@ -579,9 +576,6 @@ public static void drawTab(LobbyViewSettingsPane __instance, CustomOptionType op
}
if ((int)optionType == 99)
{
var color = option.getName().Contains("<color=") ? Helpers.HexToColor(option.getName().Substring(8, 6)) : Color.white;
viewSettingsInfoPanel.titleText.outlineColor = color;
viewSettingsInfoPanel.titleText.outlineWidth = 0.2f;
if (option.type == CustomOptionType.Modifier)
viewSettingsInfoPanel.settingText.text = viewSettingsInfoPanel.settingText.text + GameOptionsDataPatch.buildModifierExtras(option);
}
Expand Down Expand Up @@ -877,9 +871,6 @@ private static void createSettings(GameOptionsMenu menu, List<CustomOption> opti
categoryHeaderMasked.SetHeader(StringNames.ImpostorsCategory, 20);
string titleText = option.heading != "" ? option.getHeading() : option.getName();
categoryHeaderMasked.Title.text = titleText;
var color = titleText.Contains("<color=") ? Helpers.HexToColor(titleText.Substring(8, 6)) : Color.white;
categoryHeaderMasked.Title.outlineColor = color;
categoryHeaderMasked.Title.outlineWidth = 0.2f;
categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f;
categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, num, -2f);
num -= 0.63f;
Expand Down
12 changes: 6 additions & 6 deletions TheOtherRoles/Patches/ExileControllerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@ static void WrapUpPostfix(NetworkedPlayerInfo exiled)
// Reset custom button timers where necessary
CustomButton.MeetingEndedUpdate();

if (SchrodingersCat.schrodingersCat != null && CachedPlayer.LocalPlayer.PlayerControl == SchrodingersCat.schrodingersCat && CachedPlayer.LocalPlayer.Data.Role.IsImpostor) {
SchrodingersCat.schrodingersCat.SetKillTimerUnchecked(SchrodingersCat.killCooldown);
}

// Mini set adapted cooldown
if (Mini.mini != null && CachedPlayer.LocalPlayer.PlayerControl == Mini.mini && Mini.mini.Data.Role.IsImpostor) {
var multiplier = Mini.isGrownUp() ? 0.66f : 2f;
Mini.mini.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * multiplier);
}

// Mimic(Assistant) and Mimic(Killer) reset outfit
if (MimicA.mimicA != null) MimicA.mimicA.setDefaultLook();
if (MimicK.mimicK != null) MimicK.mimicK.setDefaultLook();
Mini.mini.SetKillTimer(CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown() * multiplier);
}

if (Mayor.mayor != null && CachedPlayer.LocalPlayer.PlayerControl == Mayor.mayor && exiled != null)
{
Expand Down
48 changes: 8 additions & 40 deletions TheOtherRoles/Patches/MeetingPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -979,37 +979,6 @@ public static void Postfix(MeetingIntroAnimation __instance, ref Il2CppSystem.Co
}
}

// From Town-Of-Us-R
[HarmonyPatch(typeof(MeetingHud), nameof(MeetingHud.CoIntro))]
public static class ShowNewDead
{
public static Sprite megaphone => Helpers.loadSpriteFromResources("TheOtherRoles.Resources.DeadMegaphone.png", 100f);
public static readonly List<byte> ReportedBodies = new();
public static void Postfix(MeetingHud __instance, NetworkedPlayerInfo reportedBody, Il2CppReferenceArray<NetworkedPlayerInfo> deadBodies)
{
ReportedBodies.Clear();
if (!CustomOptionHolder.noticeNewDeadBodies.getBool()) return;
foreach (var player in __instance.playerStates)
{
if (deadBodies?.Any(x => x.PlayerId == player.TargetPlayerId) == true)
{
if (reportedBody != null && player.TargetPlayerId == reportedBody.PlayerId)
{
player.Megaphone.gameObject.SetActive(true);
player.Megaphone.enabled = true;
player.Megaphone.transform.localEulerAngles = Vector3.zero;
player.Megaphone.transform.localScale = Vector3.one;
player.Megaphone.sprite = megaphone;
}
player.HighlightedFX.enabled = true;
player.HighlightedFX.color = Palette.ImpostorRed;

ReportedBodies.Add(player.TargetPlayerId);
}
}
}
}

[HarmonyPatch(typeof(MeetingIntroAnimation), nameof(MeetingIntroAnimation.Init))]
public static class MeetingIntroAnimationInitPatch
{
Expand Down Expand Up @@ -1075,6 +1044,14 @@ public static void Prefix(PlayerControl __instance, [HarmonyArgument(0)]Networke
BomberA.bombTarget = null;
BomberB.bombTarget = null;

Sprinter.sprinting = false;
Ninja.stealthed = false;
Fox.stealthed = false;

// Mimic(Assistant) and Mimic(Killer) reset outfit
if (MimicA.mimicA != null) MimicA.mimicA.setDefaultLook();
if (MimicK.mimicK != null) MimicK.mimicK.setDefaultLook();

TranslatableTag tag = meetingTarget == null ? EventDetail.EmergencyButton : EventDetail.Report;
if (meetingTarget != null)
{
Expand Down Expand Up @@ -1261,15 +1238,6 @@ static void Postfix(MeetingHud __instance) {
__instance.StartCoroutine(Effects.SwayX(playerState.transform));
}
}

if (CustomOptionHolder.noticeNewDeadBodies.getBool())
{
foreach (var state in __instance.playerStates)
{
if (ShowNewDead.ReportedBodies?.Contains(state.TargetPlayerId) == true)
if (!state.HighlightedFX.enabled) state.HighlightedFX.enabled = true;
}
}
}
}

Expand Down
37 changes: 17 additions & 20 deletions TheOtherRoles/Patches/PlayerControlPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -891,15 +891,15 @@ static void trackerUpdate() {
}
else if (Tracker.tracker.Data.IsDead)
{
Tracker.DangerMeterParent?.SetActive(false);
Tracker.Meter?.gameObject?.SetActive(false);
if (Tracker.DangerMeterParent != null) Tracker.DangerMeterParent?.SetActive(false);
if (Tracker.Meter?.gameObject != null) Tracker.Meter?.gameObject?.SetActive(false);
if (Tracker.arrow?.arrow != null) Tracker.arrow.arrow.SetActive(false);
}
}

// Handle corpses tracking
if (Tracker.tracker != null && Tracker.tracker == CachedPlayer.LocalPlayer.PlayerControl && Tracker.corpsesTrackingTimer >= 0f && !Tracker.tracker.Data.IsDead) {
bool arrowsCountChanged = Tracker.localArrows.Count != Tracker.deadBodyPositions.Count();
bool arrowsCountChanged = Tracker.localArrows.Count != Tracker.deadBodyPositions.Count;
int index = 0;

if (arrowsCountChanged) {
Expand Down Expand Up @@ -1923,6 +1923,7 @@ public static void miniCooldownUpdate() {
HudManagerStartPatch.assassinButton.MaxTimer = Assassin.cooldown * multiplier;
HudManagerStartPatch.thiefKillButton.MaxTimer = Thief.cooldown * multiplier;
HudManagerStartPatch.serialKillerButton.MaxTimer = SerialKiller.suicideTimer * (Mini.isGrownUp() ? 2f : 1f);
HudManagerStartPatch.schrodingersCatKillButton.MaxTimer = SchrodingersCat.killCooldown * multiplier;
}
}

Expand Down Expand Up @@ -2089,12 +2090,6 @@ public static void Postfix(PlayerControl __instance) {
bomberBUpdate();
// Bait
baitUpdate();
// Ninja
//ninjaUpdate();
// Sprinter
//sprinterUpdate();
// Serial Killer
//serialKillerUpdate();
// Evil Tracker
evilTrackerUpdate();
// Evil Hacker
Expand Down Expand Up @@ -2446,7 +2441,7 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]PlayerC
}

if (CachedPlayer.LocalPlayer.PlayerControl == SchrodingersCat.schrodingersCat && __instance == SchrodingersCat.schrodingersCat && SchrodingersCat.team == SchrodingersCat.Team.Impostor)
SchrodingersCat.schrodingersCat.SetKillTimer(SchrodingersCat.killCooldown);
SchrodingersCat.schrodingersCat.SetKillTimerUnchecked(SchrodingersCat.killCooldown);

if (Sheriff.sheriff != null && CachedPlayer.LocalPlayer.PlayerControl == Sheriff.sheriff && __instance == Sheriff.sheriff)
{
Expand Down Expand Up @@ -2528,7 +2523,7 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]PlayerC
if (SerialKiller.serialKiller != null && CachedPlayer.LocalPlayer.PlayerControl == SerialKiller.serialKiller && __instance == SerialKiller.serialKiller && target != SerialKiller.serialKiller)
{
_ = new StaticAchievementToken("serialKiller.common1");
SerialKiller.serialKiller.SetKillTimer(SerialKiller.killCooldown);
SerialKiller.serialKiller.SetKillTimerUnchecked(SerialKiller.killCooldown);
HudManagerStartPatch.serialKillerButton.Timer = SerialKiller.suicideTimer;
SerialKiller.isCountDown = true;
}
Expand Down Expand Up @@ -2747,11 +2742,6 @@ public static void Postfix(PlayerControl __instance, [HarmonyArgument(0)]PlayerC
{
MimicK.mimicK.setDefaultLook();
MimicK.victim = null;
if (MimicA.mimicA != null)
{
MimicA.mimicA.setDefaultLook();
MimicA.isMorph = false;
}
}

if (MimicA.mimicA != null && target == MimicA.mimicA)
Expand Down Expand Up @@ -2925,20 +2915,27 @@ public static bool Prefix(PlayerControl __instance)
}

[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.SetKillTimer))]
class PlayerControlSetCoolDownPatch {
static class PlayerControlSetCoolDownPatch {
public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)]float time) {
if (GameOptionsManager.Instance.currentGameOptions.GameMode == GameModes.HideNSeek) return true;
if (GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown <= 0f) return false;
if (CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown() <= 0f) return false;
float multiplier = 1f;
float addition = 0f;
if (Mini.mini != null && CachedPlayer.LocalPlayer.PlayerControl == Mini.mini) multiplier = Mini.isGrownUp() ? 0.66f : 2f;
if (BountyHunter.bountyHunter != null && CachedPlayer.LocalPlayer.PlayerControl == BountyHunter.bountyHunter) addition = BountyHunter.punishmentTime;
if (Ninja.ninja != null && CachedPlayer.LocalPlayer.PlayerControl == Ninja.ninja && Ninja.penalized) addition = Ninja.killPenalty;

__instance.killTimer = Mathf.Clamp(time, 0f, GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * multiplier + addition);
FastDestroyableSingleton<HudManager>.Instance.KillButton.SetCoolDown(__instance.killTimer, GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * multiplier + addition);
float max = Mathf.Max(CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown() * multiplier + addition, __instance.killTimer);
__instance.SetKillTimerUnchecked(Mathf.Clamp(time, 0f, max), max);
return false;
}

public static void SetKillTimerUnchecked(this PlayerControl player, float time, float max = float.NegativeInfinity)
{
if (max == float.NegativeInfinity) max = time;
player.killTimer = time;
FastDestroyableSingleton<HudManager>.Instance.KillButton.SetCoolDown(time, max);
}
}

[HarmonyPatch(typeof(KillAnimation), nameof(KillAnimation.CoPerformKill))]
Expand Down
4 changes: 2 additions & 2 deletions TheOtherRoles/Patches/UsablesPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ public static bool Prefix(KillButton __instance) {
MurderAttemptResult res = Helpers.checkMurderAttemptAndKill(CachedPlayer.LocalPlayer.PlayerControl, __instance.currentTarget, showAnimation: showAnimation);
// Handle blank kill
if (res == MurderAttemptResult.BlankKill) {
CachedPlayer.LocalPlayer.PlayerControl.killTimer = GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown;
CachedPlayer.LocalPlayer.PlayerControl.killTimer = CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown();
if (CachedPlayer.LocalPlayer.PlayerControl == Cleaner.cleaner)
Cleaner.cleaner.killTimer = HudManagerStartPatch.cleanerCleanButton.Timer = HudManagerStartPatch.cleanerCleanButton.MaxTimer;
else if (CachedPlayer.LocalPlayer.PlayerControl == Warlock.warlock)
Warlock.warlock.killTimer = HudManagerStartPatch.warlockCurseButton.Timer = HudManagerStartPatch.warlockCurseButton.MaxTimer;
else if (CachedPlayer.LocalPlayer.PlayerControl == Mini.mini && Mini.mini.Data.Role.IsImpostor)
Mini.mini.SetKillTimer(GameOptionsManager.Instance.currentNormalGameOptions.KillCooldown * (Mini.isGrownUp() ? 0.66f : 2f));
Mini.mini.SetKillTimer(CachedPlayer.LocalPlayer.PlayerControl.GetKillCooldown() * (Mini.isGrownUp() ? 0.66f : 2f));
else if (CachedPlayer.LocalPlayer.PlayerControl == Witch.witch)
Witch.witch.killTimer = HudManagerStartPatch.witchSpellButton.Timer = HudManagerStartPatch.witchSpellButton.MaxTimer;
else if (CachedPlayer.LocalPlayer.PlayerControl == Assassin.assassin)
Expand Down
Loading

0 comments on commit be78790

Please sign in to comment.