Lighting the stars + like so many other stuff

This commit is contained in:
Ape committed 2026-02-01 20:19:24 +01:00
1 parent a6c3220892
commit e9f1c1aaf1
11 files changed
+284 -139

No files matched your search

-62
View File
@@ -1,62 +0,0 @@
using AmongUs.GameOptions;
using System;
using InnerNet;
using UnityEngine;
namespace AmongUsRevamped;
public static class CustomRolesAssigner
{
private static readonly System.Random random = new System.Random();
public static void AssignRoles()
{
List<(string roleName, int percentage)> crewmateRoles = new List<(string, int)>
{
("Jester", Options.JesterPerc.GetInt()),
("Mayor", Options.MayorPerc.GetInt())
};
List<(string roleName, int percentage)> impostorRoles = new List<(string, int)>
{
};
List<PlayerControl> availablePlayers = new List<PlayerControl>();
foreach (var player in PlayerControl.AllPlayerControls)
{
availablePlayers.Add(player);
}
availablePlayers = availablePlayers.OrderBy(x => random.Next()).ToList();
Dictionary<PlayerControl, string> playerRoles = new Dictionary<PlayerControl, string>();
HashSet<string> assignedRoles = new HashSet<string>();
foreach (var player in availablePlayers)
{
bool isCrewmate = !player.Data.Role.IsImpostor;
List<(string roleName, int percentage)> rolesToAssign = isCrewmate ? crewmateRoles : impostorRoles;
foreach (var (roleName, percentage) in rolesToAssign)
{
if (assignedRoles.Contains(roleName))
continue;
int randomValue = random.Next(0, 101);
Logger.Info($"{roleName}, Value: {randomValue}, Percentage: {percentage}", "StartGameCustomRole1");
if (randomValue <= percentage && !playerRoles.ContainsKey(player))
{
playerRoles[player] = roleName;
assignedRoles.Add(roleName);
Logger.Info($"({player.PlayerId}) {player.Data.PlayerName} -> {roleName}", "StartGameCustomRole2");
break;
}
}
}
}
}
+115
View File
@@ -0,0 +1,115 @@
using AmongUs.GameOptions;
using System;
using InnerNet;
using UnityEngine;
namespace AmongUsRevamped;
public static class CustomRoleManagement
{
public static Dictionary<byte, string> PlayerRoles = new Dictionary<byte, string>();
private static readonly System.Random random = new System.Random();
public static void AssignRoles()
{
// crewmateRoles = assigned with crewmate role base
// impostorRoles = assigned with impostor role base
List<(string roleName, int percentage)> crewmateRoles = new List<(string, int)>
{
("Jester", Options.JesterPerc.GetInt()),
("Mayor", Options.MayorPerc.GetInt())
};
List<(string roleName, int percentage)> impostorRoles = new List<(string, int)>
{
};
List<PlayerControl> availablePlayers = new List<PlayerControl>();
foreach (var player in PlayerControl.AllPlayerControls)
{
availablePlayers.Add(player);
}
availablePlayers = availablePlayers.OrderBy(x => random.Next()).ToList();
PlayerRoles.Clear();
HashSet<string> assignedRoles = new HashSet<string>();
foreach (var player in availablePlayers)
{
bool isCrewmate = !player.Data.Role.IsImpostor;
List<(string roleName, int percentage)> rolesToAssign = isCrewmate ? crewmateRoles : impostorRoles;
foreach (var (roleName, percentage) in rolesToAssign)
{
if (assignedRoles.Contains(roleName))
continue;
int randomValue = random.Next(0, 101);
Logger.Info($"{roleName}, Value: {randomValue}, Percentage: {percentage}", "StartGameCustomRole1");
if (randomValue <= percentage && !PlayerRoles.ContainsKey(player.PlayerId))
{
PlayerRoles[player.PlayerId] = roleName;
assignedRoles.Add(roleName);
Logger.Info($"({player.PlayerId}) {player.Data.PlayerName} -> {roleName}", "StartGameCustomRole2");
break;
}
}
}
}
public static string GetActiveRoles()
{
var crewmateRoles = new List<string>();
var neutralRoles = new List<string>();
var impostorRoles = new List<string>();
var lines = new List<string>();
if (Options.MayorPerc.GetInt() > 1) crewmateRoles.Add($"Mayor ({Options.MayorPerc.GetInt()}%)");
if (Options.JesterPerc.GetInt() > 1) neutralRoles.Add($"Jester ({Options.JesterPerc.GetInt()})%");
void AddCategory(string header, List<string> roles)
{
if (roles.Count == 0) return;
if (lines.Count > 0) lines.Add("");
lines.Add(header);
lines.AddRange(roles);
}
AddCategory("Crewmate:", crewmateRoles);
AddCategory("Neutral:", neutralRoles);
AddCategory("Impostor:", impostorRoles);
return lines.Count > 0 ? string.Join("\n", lines) : string.Empty;
}
public static void SendRoleMessages(Dictionary<string, string> roleMessages)
{
HashSet<string> sentRoles = new HashSet<string>();
var players = PlayerControl.AllPlayerControls.ToArray().ToList();
float delay = 0f;
foreach (var player in players)
{
if (!PlayerRoles.TryGetValue(player.PlayerId, out string role)) continue;
if (!roleMessages.ContainsKey(role)) continue;
if (sentRoles.Contains(role)) continue;
new LateTask(() =>
{
Utils.SendPrivateMessage(player, roleMessages[role]);
}, delay, "SendRoleMessage");
sentRoles.Add(role);
delay += 2.2f;
}
}
}
+15 -7
View File
@@ -134,9 +134,16 @@ public static class Utils
string name = region.Name;
// Joining games shows incorrect regions
if (!AmongUsClient.Instance.AmHost)
{
name = "";
return name;
}
if (AmongUsClient.Instance.NetworkMode != NetworkModes.OnlineGame)
{
name = "Local Game";
name = "Server: Local Game";
return name;
}
@@ -145,9 +152,9 @@ public static class Utils
// Official servers
name = name switch
{
"North America" => "NA",
"Europe" => "EU",
"Asia" => "AS",
"North America" => "Server: NA",
"Europe" => "Server: EU",
"Asia" => "Server: AS",
_ => name
};
@@ -160,11 +167,11 @@ public static class Utils
{
// Modded Servers
if (ip.Contains("au-eu"))
name = "MEU";
name = "Server: MEU";
else if (ip.Contains("au-as"))
name = "MAS";
name = "Server: MAS";
else
name = "MNA";
name = "Server: MNA";
return name;
}
@@ -191,6 +198,7 @@ public static class Utils
LateTask.Tasks.Clear();
FixedUpdateInGamePatch.ProcessedModerators.Clear();
NormalGameEndChecker.ImpCheckComplete = false;
CreateOptionsPickerPatch.SetDleks2 = false;
}
public static PlayerControl[] AllAlivePlayerControls