mirror of
https://github.com/ApeMV/AmongUsRevamped.git
synced 2026-10-19 15:51:59 +00:00
1st Unique feature - Custom HNS impostor count
This commit is contained in:
1 parent
765ffb9265
commit
f6f4e3b8e5
4 files changed
+66
-3
No files matched your search
@@ -5,6 +5,7 @@ global using System.Linq;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HNSRevamped;
|
||||
|
||||
@@ -34,6 +35,7 @@ public partial class Main : BasePlugin
|
||||
public static void Prefix(ModManager __instance)
|
||||
{
|
||||
__instance.ShowModStamp();
|
||||
LateTask.Update(Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,8 @@ namespace HNSRevamped
|
||||
//Mod
|
||||
public static OptionItem DisableTasks;
|
||||
|
||||
// HNS
|
||||
public static OptionItem NumSeekers;
|
||||
|
||||
public static bool IsLoaded = false;
|
||||
|
||||
@@ -68,6 +70,11 @@ namespace HNSRevamped
|
||||
.SetColor(Color.red)
|
||||
.SetHeader(true);
|
||||
|
||||
|
||||
|
||||
NumSeekers = IntegerOptionItem.Create(70000, "# Seekers", new(0, 15, 1), 1, TabGroup.HNSSettings, false)
|
||||
.SetValueFormat(OptionFormat.Level)
|
||||
.SetHeader(true);
|
||||
IsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -19,10 +19,11 @@ namespace HNSRevamped;
|
||||
|
||||
public static class Utils
|
||||
{
|
||||
public static bool isHideNSeek => GameOptionsManager.Instance.CurrentGameOptions.GameMode == GameModes.HideNSeek;
|
||||
public static bool InGame => AmongUsClient.Instance && AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started;
|
||||
public static bool isHideNSeek => GameOptionsManager.Instance.CurrentGameOptions.GameMode == GameModes.HideNSeek;
|
||||
|
||||
public static string ColorString(Color32 color, string str) => $"<#{color.r:x2}{color.g:x2}{color.b:x2}{color.a:x2}>{str}</color>";
|
||||
public static string ColorToHex(Color32 color) => $"#{color.r:x2}{color.g:x2}{color.b:x2}{color.a:x2}";
|
||||
public static string ColorString(Color32 color, string str) => $"<#{color.r:x2}{color.g:x2}{color.b:x2}{color.a:x2}>{str}</color>";
|
||||
public static string ColorToHex(Color32 color) => $"#{color.r:x2}{color.g:x2}{color.b:x2}{color.a:x2}";
|
||||
|
||||
public static bool IsPlayerModerator(string friendCode)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using InnerNet;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HNSRevamped;
|
||||
|
||||
[HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.CoStartGame))]
|
||||
internal class ApplyCustomImpostorCount
|
||||
{
|
||||
public static void Postfix(AmongUsClient __instance)
|
||||
{
|
||||
if (!AmongUsClient.Instance.AmHost || !Utils.isHideNSeek) return;
|
||||
|
||||
int seekersCount = Options.NumSeekers.GetInt();
|
||||
|
||||
int toAdd = Math.Max(0, seekersCount - 1);
|
||||
|
||||
var candidates = new List<PlayerControl>();
|
||||
foreach (var p in PlayerControl.AllPlayerControls)
|
||||
{
|
||||
if (p.Data.Role.TeamType != RoleTeamTypes.Impostor)
|
||||
candidates.Add(p);
|
||||
}
|
||||
|
||||
toAdd = Math.Min(toAdd, candidates.Count);
|
||||
|
||||
System.Random rand = new System.Random();
|
||||
for (int i = candidates.Count - 1; i > 0; i--)
|
||||
{
|
||||
int j = rand.Next(i + 1);
|
||||
(candidates[i], candidates[j]) = (candidates[j], candidates[i]);
|
||||
}
|
||||
|
||||
// 1st RpcSetRole forces the role on that user. 2nd is needed to allow them to kill.
|
||||
for (int i = 0; i < toAdd; i++)
|
||||
{
|
||||
var player = candidates[i];
|
||||
|
||||
player.RpcSetRole(AmongUs.GameOptions.RoleTypes.Impostor, false);
|
||||
|
||||
foreach (var p in PlayerControl.AllPlayerControls)
|
||||
{
|
||||
if (p.Data.Role.TeamType == RoleTeamTypes.Impostor)
|
||||
{
|
||||
new LateTask(() =>
|
||||
{
|
||||
p.RpcSetRole(AmongUs.GameOptions.RoleTypes.Impostor, false);
|
||||
}, 9f, "Secondary RPCSetRole");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user