-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- New Role: Guesser - Changed the colors of some roles - Changed name of Child to Mini - Changed Version check to allow to check for modified versions of the mod. (Forks don't need to use different versioning now) - Changed Role Assignment to make Spy incompatible with Mini (former child) - Fixed a bug where a Jester win was triggered, when the partner of a Jester Lover was voted out - Fixed a bug where a Mini lose was triggered, when the partner of a Crew Mini Lover was voted out
- Loading branch information
Showing
16 changed files
with
679 additions
and
549 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
using HarmonyLib; | ||
using Hazel; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using UnhollowerBaseLib; | ||
using static TheOtherRoles.TheOtherRoles; | ||
using static TheOtherRoles.MapOptions; | ||
using System.Collections; | ||
using System; | ||
using System.Text; | ||
using UnityEngine; | ||
using System.Reflection; | ||
|
||
namespace TheOtherRoles { | ||
[HarmonyPatch(typeof(ExileController), "Begin")] | ||
class ExileControllerBeginPatch { | ||
public static void Prefix(ExileController __instance, [HarmonyArgument(0)]ref GameData.PlayerInfo exiled, [HarmonyArgument(1)]bool tie) { | ||
// Shifter shift | ||
if (Shifter.shifter != null && AmongUsClient.Instance.AmHost && Shifter.futureShift != null) { // We need to send the RPC from the host here, to make sure that the order of shifting and erasing is correct (for that reason the futureShifted and futureErased are being synced) | ||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ShifterShift, Hazel.SendOption.Reliable, -1); | ||
writer.Write(Shifter.futureShift.PlayerId); | ||
AmongUsClient.Instance.FinishRpcImmediately(writer); | ||
RPCProcedure.shifterShift(Shifter.futureShift.PlayerId); | ||
} | ||
Shifter.futureShift = null; | ||
|
||
// Eraser erase | ||
if (Eraser.eraser != null && AmongUsClient.Instance.AmHost && Eraser.futureErased != null) { // We need to send the RPC from the host here, to make sure that the order of shifting and erasing is correct (for that reason the futureShifted and futureErased are being synced) | ||
foreach (PlayerControl target in Eraser.futureErased) { | ||
if (target != null) { | ||
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.ErasePlayerRoles, Hazel.SendOption.Reliable, -1); | ||
writer.Write(target.PlayerId); | ||
AmongUsClient.Instance.FinishRpcImmediately(writer); | ||
RPCProcedure.erasePlayerRoles(target.PlayerId); | ||
} | ||
} | ||
} | ||
Eraser.futureErased = new List<PlayerControl>(); | ||
|
||
// Trickster boxes | ||
if (Trickster.trickster != null && JackInTheBox.hasJackInTheBoxLimitReached()) { | ||
JackInTheBox.convertToVents(); | ||
} | ||
|
||
// SecurityGuard vents and cameras | ||
var allCameras = ShipStatus.Instance.AllCameras.ToList(); | ||
MapOptions.camerasToAdd.ForEach(camera => { | ||
camera.gameObject.SetActive(true); | ||
camera.gameObject.GetComponent<SpriteRenderer>().color = Color.white; | ||
allCameras.Add(camera); | ||
}); | ||
ShipStatus.Instance.AllCameras = allCameras.ToArray(); | ||
MapOptions.camerasToAdd = new List<SurvCamera>(); | ||
|
||
foreach (Vent vent in MapOptions.ventsToSeal) { | ||
PowerTools.SpriteAnim animator = vent.GetComponent<PowerTools.SpriteAnim>(); | ||
animator?.Stop(); | ||
vent.EnterVentAnim = vent.ExitVentAnim = null; | ||
vent.myRend.sprite = animator == null ? SecurityGuard.getStaticVentSealedSprite() : SecurityGuard.getAnimatedVentSealedSprite(); | ||
vent.myRend.color = Color.white; | ||
vent.name = "SealedVent_" + vent.name; | ||
} | ||
MapOptions.ventsToSeal = new List<Vent>(); | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(UnityEngine.Object), nameof(UnityEngine.Object.Destroy), new Type[] { typeof(UnityEngine.Object) })] | ||
class ExileControllerDestroyPatch { | ||
static void Prefix(UnityEngine.Object obj) { | ||
if (ExileController.Instance == null || obj != ExileController.Instance.gameObject) return; | ||
var exiled = ExileController.Instance.exiled; | ||
|
||
// Mini exile lose condition | ||
if (exiled != null && Mini.mini != null && Mini.mini.PlayerId == exiled.PlayerId && !Mini.isGrownUp() && !Mini.mini.Data.IsImpostor) { | ||
Mini.triggerMiniLose = true; | ||
} | ||
// Jester win condition | ||
else if (exiled != null && Jester.jester != null && Jester.jester.PlayerId == exiled.PlayerId) { | ||
Jester.triggerJesterWin = true; | ||
} | ||
|
||
// Reset custom button timers where necessary | ||
CustomButton.MeetingEndedUpdate(); | ||
|
||
// Mini set adapted cooldown | ||
if (Mini.mini != null && PlayerControl.LocalPlayer == Mini.mini && Mini.mini.Data.IsImpostor) { | ||
var multiplier = Mini.isGrownUp() ? 0.66f : 2f; | ||
Mini.mini.SetKillTimer(PlayerControl.GameOptions.KillCooldown * multiplier); | ||
} | ||
|
||
// Seer spawn souls | ||
if (Seer.deadBodyPositions != null && Seer.seer != null && PlayerControl.LocalPlayer == Seer.seer && (Seer.mode == 0 || Seer.mode == 2)) { | ||
foreach (Vector3 pos in Seer.deadBodyPositions) { | ||
GameObject soul = new GameObject(); | ||
soul.transform.position = pos; | ||
soul.layer = 5; | ||
var rend = soul.AddComponent<SpriteRenderer>(); | ||
rend.sprite = Seer.getSoulSprite(); | ||
|
||
if(Seer.limitSoulDuration) { | ||
HudManager.Instance.StartCoroutine(Effects.Lerp(Seer.soulDuration, new Action<float>((p) => { | ||
if (rend != null) { | ||
var tmp = rend.color; | ||
tmp.a = Mathf.Clamp01(1 - p); | ||
rend.color = tmp; | ||
} | ||
if (p == 1f && rend != null && rend.gameObject != null) UnityEngine.Object.Destroy(rend.gameObject); | ||
}))); | ||
} | ||
} | ||
Seer.deadBodyPositions = new List<Vector3>(); | ||
} | ||
|
||
// Arsonist deactivate dead poolable players | ||
if (Arsonist.arsonist != null && Arsonist.arsonist == PlayerControl.LocalPlayer) { | ||
int visibleCounter = 0; | ||
Vector3 bottomLeft = new Vector3(-HudManager.Instance.UseButton.transform.localPosition.x, HudManager.Instance.UseButton.transform.localPosition.y, HudManager.Instance.UseButton.transform.localPosition.z); | ||
bottomLeft += new Vector3(-0.25f, -0.25f, 0); | ||
foreach (PlayerControl p in PlayerControl.AllPlayerControls) { | ||
if (!Arsonist.dousedIcons.ContainsKey(p.PlayerId)) continue; | ||
if (p.Data.IsDead || p.Data.Disconnected) { | ||
Arsonist.dousedIcons[p.PlayerId].gameObject.SetActive(false); | ||
} else { | ||
Arsonist.dousedIcons[p.PlayerId].transform.localPosition = bottomLeft + Vector3.right * visibleCounter * 0.35f; | ||
visibleCounter++; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
[HarmonyPatch(typeof(TranslationController), nameof(TranslationController.GetString), new Type[] { typeof(StringNames), typeof(Il2CppReferenceArray<Il2CppSystem.Object>) })] | ||
class ExileControllerMessagePatch { | ||
static void Postfix(ref string __result, [HarmonyArgument(0)]StringNames id, [HarmonyArgument(1)]Il2CppReferenceArray<Il2CppSystem.Object> parts) { | ||
if (ExileController.Instance != null && ExileController.Instance.exiled != null) { | ||
PlayerControl player = Helpers.playerById(ExileController.Instance.exiled.Object.PlayerId); | ||
if (player == null) return; | ||
// Exile role text | ||
if (id == StringNames.ExileTextPN || id == StringNames.ExileTextSN || id == StringNames.ExileTextPP || id == StringNames.ExileTextSP) { | ||
__result = player.Data.PlayerName + " was The " + String.Join(" ", RoleInfo.getRoleInfoForPlayer(player).Select(x => x.name).ToArray()); | ||
} | ||
// Hide number of remaining impostors on Jester win | ||
if (id == StringNames.ImpostorsRemainP || id == StringNames.ImpostorsRemainS) { | ||
if (Jester.jester != null && player.PlayerId == Jester.jester.PlayerId) __result = ""; | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.