too tired to think about what I just did

This commit is contained in:
Gurge44 committed 2024-11-27 21:58:53 +01:00
1 parent 3b2ba90d83
commit c8010f9d60
12 files changed
+208 -46

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@
<Description>EHR</Description>
<Authors>Gurge44</Authors>
<langVersion>preview</langVersion>
<AmongUs>C:\Program Files\Epic Games\AmongUs</AmongUs>
<AmongUs>E:\Program Files\AmongUs</AmongUs>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>True</Optimize>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
+103 -2
View File
@@ -1,7 +1,9 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using HarmonyLib;
using UnityEngine;
namespace EHR
{
@@ -9,18 +11,117 @@ namespace EHR
{
public static HashSet<byte> Taskers = [];
public static readonly Dictionary<CustomGameMode, OptionItem> GameModeIntegrationSettings = [];
public static OptionItem HotPotatoTimerMultiplier;
public static OptionItem MoveAndStopMinGreenTimeBonus;
public static OptionItem MoveAndStopMaxGreenTimeBonus;
public static OptionItem NaturalDisastersDisasterSpawnCooldownMultiplier;
public static OptionItem NaturalDisastersWarningDurationMultiplier;
public static OptionItem RoomRushTimeLimitMultiplier;
public static OptionItem RoomRushDontKillLastPlayer;
public static OptionItem RoomRushDontLowerTimeLimitWhenTwoPlayersEnterCorrectRoom;
public static OptionItem RoomRushDontKillPlayersOutsideRoomWhenTimeRunsOut;
public static OptionItem SpeedrunTimeLimitMultiplier;
public static void SetupCustomOption()
{
var id = 69_217_001;
var color = ColorUtility.TryParseHtmlString("#f542ad", out Color c) ? c : Color.magenta;
const CustomGameMode gameMode = CustomGameMode.AllInOne;
foreach (CustomGameMode mode in Enum.GetValues<CustomGameMode>())
{
if (mode is CustomGameMode.Standard or gameMode) continue;
bool defaultValue = mode is CustomGameMode.HotPotato or CustomGameMode.MoveAndStop or CustomGameMode.NaturalDisasters or CustomGameMode.RoomRush or CustomGameMode.SoloKombat or CustomGameMode.Speedrun;
GameModeIntegrationSettings[mode] = new BooleanOptionItem(id++, $"AllInOne.{mode}.Integration", defaultValue, TabGroup.GameSettings)
.SetGameMode(gameMode)
.SetColor(color);
}
HotPotatoTimerMultiplier = new IntegerOptionItem(id++, "AllInOne.HotPotato.TimerMultiplier", new(1, 10, 1), 3, TabGroup.GameSettings)
.SetValueFormat(OptionFormat.Multiplier)
.SetGameMode(gameMode)
.SetColor(color);
MoveAndStopMinGreenTimeBonus = new IntegerOptionItem(id++, "AllInOne.MoveAndStop.MinGreenTimeBonus", new(0, 60, 1), 5, TabGroup.GameSettings)
.SetValueFormat(OptionFormat.Seconds)
.SetGameMode(gameMode)
.SetColor(color);
MoveAndStopMaxGreenTimeBonus = new IntegerOptionItem(id++, "AllInOne.MoveAndStop.MaxGreenTimeBonus", new(0, 60, 1), 20, TabGroup.GameSettings)
.SetValueFormat(OptionFormat.Seconds)
.SetGameMode(gameMode)
.SetColor(color);
NaturalDisastersDisasterSpawnCooldownMultiplier = new IntegerOptionItem(id++, "AllInOne.NaturalDisasters.DisasterSpawnCooldownMultiplier", new(1, 10, 1), 4, TabGroup.GameSettings)
.SetValueFormat(OptionFormat.Multiplier)
.SetGameMode(gameMode)
.SetColor(color);
NaturalDisastersWarningDurationMultiplier = new IntegerOptionItem(id++, "AllInOne.NaturalDisasters.WarningDurationMultiplier", new(1, 10, 1), 6, TabGroup.GameSettings)
.SetValueFormat(OptionFormat.Multiplier)
.SetGameMode(gameMode)
.SetColor(color);
RoomRushTimeLimitMultiplier = new IntegerOptionItem(id++, "AllInOne.RoomRush.TimeLimitMultiplier", new(1, 10, 1), 3, TabGroup.GameSettings)
.SetValueFormat(OptionFormat.Multiplier)
.SetGameMode(gameMode)
.SetColor(color);
RoomRushDontKillLastPlayer = new BooleanOptionItem(id++, "AllInOne.RoomRush.DontKillLastPlayer", true, TabGroup.GameSettings)
.SetGameMode(gameMode)
.SetColor(color);
RoomRushDontLowerTimeLimitWhenTwoPlayersEnterCorrectRoom = new BooleanOptionItem(id++, "AllInOne.RoomRush.DontLowerTimeLimitWhenTwoPlayersEnterCorrectRoom", true, TabGroup.GameSettings)
.SetGameMode(gameMode)
.SetColor(color);
RoomRushDontKillPlayersOutsideRoomWhenTimeRunsOut = new BooleanOptionItem(id++, "AllInOne.RoomRush.DontKillPlayersOutsideRoomWhenTimeRunsOut", true, TabGroup.GameSettings)
.SetGameMode(gameMode)
.SetColor(color);
SpeedrunTimeLimitMultiplier = new IntegerOptionItem(id, "AllInOne.Speedrun.TimeLimitMultiplier", new(1, 10, 1), 3, TabGroup.GameSettings)
.SetValueFormat(OptionFormat.Multiplier)
.SetGameMode(gameMode)
.SetColor(color);
}
public static void Init()
{
Taskers = [];
}
public static CustomGameMode GetPrioritizedGameModeForRoles()
{
Dictionary<CustomGameMode, int> order = new()
{
{ CustomGameMode.HideAndSeek, 0 },
{ CustomGameMode.CaptureTheFlag, 1 },
{ CustomGameMode.FFA, 2 },
{ CustomGameMode.SoloKombat, 3 },
{ CustomGameMode.RoomRush, 4 },
{ CustomGameMode.Speedrun, 5 },
{ CustomGameMode.NaturalDisasters, 6 },
{ CustomGameMode.MoveAndStop, 7 },
{ CustomGameMode.HotPotato, 8 }
};
return order.Where(x => x.Key.IsActiveOrIntegrated()).MinBy(x => x.Value).Key;
}
[HarmonyPatch(typeof(PlayerControl), nameof(PlayerControl.FixedUpdate))]
private static class FixedUpdatePatch
{
[SuppressMessage("ReSharper", "UnusedMember.Local")]
public static void Postfix(PlayerControl __instance)
{
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || GameStates.IsEnded || !CustomGameMode.AllInOne.IsActiveOrIntegrated() || Main.HasJustStarted || __instance.Is(CustomRoles.Killer)) return;
if (!AmongUsClient.Instance.AmHost || !GameStates.IsInTask || GameStates.IsEnded || !CustomGameMode.AllInOne.IsActiveOrIntegrated() || Main.HasJustStarted || __instance.Is(CustomRoles.Killer) || CustomGameMode.HideAndSeek.IsActiveOrIntegrated()) return;
var gameModes = Enum.GetValues<CustomGameMode>().Where(x => x.IsActiveOrIntegrated()).Split(x => x is CustomGameMode.CaptureTheFlag or CustomGameMode.FFA or CustomGameMode.SoloKombat);
if (gameModes.TrueList.Count == 0 || gameModes.FalseList.Count == 0) return;
bool doneWithTasks = Taskers.Contains(__instance.PlayerId) && __instance.GetTaskState().IsTaskFinished;
+3 -1
View File
@@ -138,7 +138,9 @@ namespace EHR
if (resetTime)
{
int time = Time.GetInt();
HotPotatoState.TimeLeft = Options.CurrentGameMode == CustomGameMode.AllInOne ? time * 3 : time;
if (Options.CurrentGameMode == CustomGameMode.AllInOne) time *= AllInOneGameMode.HotPotatoTimerMultiplier.GetInt();
HotPotatoState.TimeLeft = time;
HotPotatoState.RoundNum++;
}
+2 -2
View File
@@ -166,7 +166,7 @@ namespace EHR
MapNames.Airship => ExtraGreenTimeOnAirhip.GetInt(),
MapNames.Fungle => ExtraGreenTimeOnFungle.GetInt(),
_ => 0
} + (Options.CurrentGameMode == CustomGameMode.AllInOne ? IRandom.Instance.Next(10, 40) : 0);
} + (Options.CurrentGameMode == CustomGameMode.AllInOne ? IRandom.Instance.Next(AllInOneGameMode.MoveAndStopMinGreenTimeBonus.GetInt(), AllInOneGameMode.MoveAndStopMaxGreenTimeBonus.GetInt() + 1) : 0);
private static IntegerValueRule CounterValueRule => new(1, 100, 1);
private static IntegerValueRule ExtraTimeValue => new(0, 50, 1);
@@ -177,7 +177,7 @@ namespace EHR
private static int StartingGreenTime(PlayerControl pc)
{
if (Options.CurrentGameMode == CustomGameMode.AllInOne) return 80;
if (Options.CurrentGameMode == CustomGameMode.AllInOne) return 60;
bool tutorial = EnableTutorial.GetBool() && !HasPlayed.Contains(pc.FriendCode);
return Main.CurrentMap == MapNames.Airship ? tutorial ? 57 : 47 : tutorial ? 47 : 37;
}
+2 -2
View File
@@ -255,7 +255,7 @@ namespace EHR
long now = Utils.TimeStamp;
int frequency = DisasterFrequency.GetInt();
if (Options.CurrentGameMode == CustomGameMode.AllInOne) frequency *= 5;
if (Options.CurrentGameMode == CustomGameMode.AllInOne) frequency *= AllInOneGameMode.NaturalDisastersDisasterSpawnCooldownMultiplier.GetInt();
if (now - LastDisaster >= frequency)
{
@@ -277,7 +277,7 @@ namespace EHR
SystemTypes? room = disaster.Name == "BuildingCollapse" ? roomKvp.Key : null;
float warningTime = DisasterWarningTime.GetFloat();
if (Options.CurrentGameMode == CustomGameMode.AllInOne) warningTime *= 6;
if (Options.CurrentGameMode == CustomGameMode.AllInOne) warningTime *= AllInOneGameMode.NaturalDisastersWarningDurationMultiplier.GetInt();
PreparingDisasters.Add(new(position, warningTime, Sprite(disaster.Name), disaster.Name, room));
}
+5 -6
View File
@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using AmongUs.GameOptions;
using Beebyte.Obfuscator;
using EHR.Modules;
using HarmonyLib;
using Hazel;
@@ -231,7 +230,7 @@ namespace EHR
aapc.Do(x => x.Notify(time.ToString()));
yield return new WaitForSeconds(1f);
}
Skip:
if (ventLimit > 0) aapc.Do(x => x.RpcChangeRoleBasis(CustomRoles.EngineerEHR));
@@ -295,7 +294,7 @@ namespace EHR
}
TimeLeft = Math.Max((int)Math.Round(time * GlobalTimeMultiplier.GetFloat()), 4);
if (Options.CurrentGameMode == CustomGameMode.AllInOne) TimeLeft *= 3;
if (Options.CurrentGameMode == CustomGameMode.AllInOne) TimeLeft *= AllInOneGameMode.RoomRushTimeLimitMultiplier.GetInt();
Logger.Info($"Starting a new round - Goal = from: {Translator.GetString(previous.ToString())}, to: {Translator.GetString(RoomGoal.ToString())} - Time: {TimeLeft} ({Main.CurrentMap})", "RoomRush");
Main.AllPlayerControls.Do(x => LocateArrow.RemoveAllTarget(x.PlayerId));
if (DisplayArrowToRoom.GetBool()) Main.AllPlayerControls.Do(x => LocateArrow.Add(x.PlayerId, goalPos));
@@ -384,7 +383,7 @@ namespace EHR
int timeLeft = TimeWhenFirstPlayerEntersRoom.GetInt();
if (DonePlayers.Count == 2 && timeLeft < TimeLeft && notAllInOne)
if (DonePlayers.Count == 2 && timeLeft < TimeLeft && (notAllInOne || !AllInOneGameMode.RoomRushDontLowerTimeLimitWhenTwoPlayersEnterCorrectRoom.GetBool()))
{
Logger.Info($"Two players entered the correct room, setting the timer to {timeLeft}", "RoomRush");
TimeLeft = timeLeft;
@@ -394,7 +393,7 @@ namespace EHR
Achievements.Type.WheresTheBlueShell.CompleteAfterGameEnd();
}
if (DonePlayers.Count == aapc.Length - 1 && notAllInOne)
if (DonePlayers.Count == aapc.Length - 1 && (notAllInOne || !AllInOneGameMode.RoomRushDontKillLastPlayer.GetBool()))
{
PlayerControl last = aapc.First(x => !DonePlayers.Contains(x.PlayerId));
Logger.Info($"All players entered the correct room except one, killing the last player ({last.GetRealName()})", "RoomRush");
@@ -404,7 +403,7 @@ namespace EHR
return;
}
}
else if ((room == null || room.RoomId != RoomGoal) && notAllInOne)
else if ((room == null || room.RoomId != RoomGoal) && (notAllInOne || !AllInOneGameMode.RoomRushDontKillPlayersOutsideRoomWhenTimeRunsOut.GetBool()))
DonePlayers.Remove(pc.PlayerId);
}
+2 -2
View File
@@ -57,7 +57,7 @@ namespace EHR
public static void ResetTimer(PlayerControl pc)
{
int timer = TimeLimit.GetInt();
if (Options.CurrentGameMode == CustomGameMode.AllInOne) timer *= 3;
if (Options.CurrentGameMode == CustomGameMode.AllInOne) timer *= AllInOneGameMode.SpeedrunTimeLimitMultiplier.GetInt();
if (TimeStacksUp.GetBool())
Timers[pc.PlayerId] += timer;
@@ -73,7 +73,7 @@ namespace EHR
CanKill.Add(pc.PlayerId);
Main.AllPlayerKillCooldown[pc.PlayerId] = KillCooldown.GetInt();
pc.RpcChangeRoleBasis(CustomRoles.Runner);
pc.RpcChangeRoleBasis(Options.CurrentGameMode == CustomGameMode.AllInOne ? CustomRoles.Killer : CustomRoles.Runner);
pc.Notify(Translator.GetString("Speedrun_CompletedTasks"));
pc.SyncSettings();
pc.SetKillCooldown(KillCooldown.GetInt());
+68 -26
View File
@@ -34,37 +34,79 @@ namespace EHR.Modules
if (Main.GM.Value && Main.AllPlayerControls.Length == 1) return;
switch (Options.CurrentGameMode)
// switch (Options.CurrentGameMode)
// {
// case CustomGameMode.SoloKombat:
// AssignRoleToEveryone(CustomRoles.KB_Normal);
// return;
// case CustomGameMode.FFA:
// AssignRoleToEveryone(CustomRoles.Killer);
// return;
// case CustomGameMode.MoveAndStop:
// AssignRoleToEveryone(CustomRoles.Tasker);
// return;
// case CustomGameMode.HotPotato:
// AssignRoleToEveryone(CustomRoles.Potato);
// return;
// case CustomGameMode.Speedrun:
// AssignRoleToEveryone(CustomRoles.Runner);
// return;
// case CustomGameMode.CaptureTheFlag:
// AssignRoleToEveryone(CustomRoles.CTFPlayer);
// return;
// case CustomGameMode.NaturalDisasters:
// AssignRoleToEveryone(CustomRoles.NDPlayer);
// return;
// case CustomGameMode.RoomRush:
// AssignRoleToEveryone(CustomRoles.RRPlayer);
// return;
// case CustomGameMode.HideAndSeek:
// HnSManager.AssignRoles();
// RoleResult = HnSManager.PlayerRoles.ToDictionary(x => x.Key, x => x.Value.Role);
// return;
// }
if (Options.CurrentGameMode != CustomGameMode.Standard)
{
case CustomGameMode.SoloKombat:
AssignRoleToEveryone(CustomRoles.KB_Normal);
Dictionary<CustomGameMode, CustomRoles> gameModeRoles = new()
{
{ CustomGameMode.SoloKombat, CustomRoles.KB_Normal },
{ CustomGameMode.FFA, CustomRoles.Killer },
{ CustomGameMode.MoveAndStop, CustomRoles.Tasker },
{ CustomGameMode.HotPotato, CustomRoles.Potato },
{ CustomGameMode.Speedrun, CustomRoles.Runner },
{ CustomGameMode.CaptureTheFlag, CustomRoles.CTFPlayer },
{ CustomGameMode.NaturalDisasters, CustomRoles.NDPlayer },
{ CustomGameMode.RoomRush, CustomRoles.RRPlayer }
};
if (gameModeRoles.TryGetValue(Options.CurrentGameMode, out var role))
{
AssignRoleToEveryone(role);
return;
case CustomGameMode.FFA:
AssignRoleToEveryone(CustomRoles.Killer);
return;
case CustomGameMode.AllInOne:
case CustomGameMode.MoveAndStop:
AssignRoleToEveryone(CustomRoles.Tasker);
return;
case CustomGameMode.HotPotato:
AssignRoleToEveryone(CustomRoles.Potato);
return;
case CustomGameMode.Speedrun:
AssignRoleToEveryone(CustomRoles.Runner);
return;
case CustomGameMode.CaptureTheFlag:
AssignRoleToEveryone(CustomRoles.CTFPlayer);
return;
case CustomGameMode.NaturalDisasters:
AssignRoleToEveryone(CustomRoles.NDPlayer);
return;
case CustomGameMode.RoomRush:
AssignRoleToEveryone(CustomRoles.RRPlayer);
return;
case CustomGameMode.HideAndSeek:
}
bool hns = Options.CurrentGameMode == CustomGameMode.HideAndSeek;
if (Options.CurrentGameMode == CustomGameMode.AllInOne)
{
var prioritizedGameMode = AllInOneGameMode.GetPrioritizedGameModeForRoles();
if (gameModeRoles.TryGetValue(prioritizedGameMode, out var allInOneRole))
{
AssignRoleToEveryone(allInOneRole);
return;
}
hns = prioritizedGameMode == CustomGameMode.HideAndSeek;
}
if (hns)
{
HnSManager.AssignRoles();
RoleResult = HnSManager.PlayerRoles.ToDictionary(x => x.Key, x => x.Value.Role);
return;
}
}
var rd = IRandom.Instance;
+3 -1
View File
@@ -811,7 +811,7 @@ namespace EHR
_ => CustomGameMode.Standard
};
public static bool IsActiveOrIntegrated(this CustomGameMode customGameMode) => CurrentGameMode == customGameMode || (CurrentGameMode == CustomGameMode.AllInOne && customGameMode is not CustomGameMode.FFA and not CustomGameMode.CaptureTheFlag and not CustomGameMode.HideAndSeek and not CustomGameMode.Standard and not CustomGameMode.AllInOne);
public static bool IsActiveOrIntegrated(this CustomGameMode customGameMode) => CurrentGameMode == customGameMode || (CurrentGameMode == CustomGameMode.AllInOne && AllInOneGameMode.GameModeIntegrationSettings.TryGetValue(customGameMode, out var option) && option.GetBool());
[HarmonyPatch(typeof(TranslationController), nameof(TranslationController.Initialize))]
[HarmonyPostfix]
@@ -1363,6 +1363,8 @@ namespace EHR
MainLoadingText = "Building Settings for Other Gamemodes";
AllInOneGameMode.SetupCustomOption();
// SoloKombat
SoloKombatManager.SetupCustomOption();
// FFA
+3 -3
View File
@@ -212,7 +212,7 @@ namespace EHR
public bool IsCurrentlyHidden()
{
var mode = EHR.Options.CurrentGameMode;
return CheckHidden() || (GameMode != CustomGameMode.All && GameMode != mode && !(mode == CustomGameMode.AllInOne && GameMode is CustomGameMode.SoloKombat or CustomGameMode.MoveAndStop or CustomGameMode.HotPotato or CustomGameMode.Speedrun or CustomGameMode.NaturalDisasters or CustomGameMode.RoomRush));
return CheckHidden() || (GameMode != CustomGameMode.All && GameMode != mode && !(mode == CustomGameMode.AllInOne && AllInOneGameMode.GameModeIntegrationSettings.TryGetValue(GameMode, out var option) && option.GetBool()));
}
private bool CheckHidden()
@@ -234,7 +234,7 @@ namespace EHR
return string.Format(Translator.GetString("Format." + ValueFormat), value);
}
protected void Refresh()
private void Refresh()
{
if (OptionBehaviour is StringOption opt)
{
@@ -334,7 +334,7 @@ namespace EHR
private static readonly List<OptionItem> Options = new(1024);
public static IReadOnlyDictionary<int, OptionItem> FastOptions => FastOpts;
private static readonly Dictionary<int, OptionItem> FastOpts = new(1024);
public static int CurrentPreset { get; set; }
public static int CurrentPreset { get; private set; }
#endregion
}
+2
View File
@@ -211,9 +211,11 @@ namespace EHR
switch (Options.CurrentGameMode)
{
case CustomGameMode.AllInOne when CustomGameMode.SoloKombat.IsActiveOrIntegrated() && !killer.Is(CustomRoles.Killer):
case CustomGameMode.SoloKombat:
SoloKombatManager.OnPlayerAttack(killer, target);
return false;
case CustomGameMode.AllInOne when CustomGameMode.FFA.IsActiveOrIntegrated() && killer.Is(CustomRoles.Killer):
case CustomGameMode.FFA:
FFAManager.OnPlayerAttack(killer, target);
return false;
+14
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using AmongUs.GameOptions;
using EHR.AddOns.Crewmate;
using EHR.AddOns.GhostRoles;
@@ -255,6 +256,19 @@ namespace EHR
// Convert list of tasks to array (Il2CppStructArray)
taskTypeIds = new(TasksList.Count);
for (var i = 0; i < TasksList.Count; i++) taskTypeIds[i] = TasksList[i];
Il2CppSystem.Text.StringBuilder sb = new();
foreach (TaskTypes taskType in usedTaskTypes)
{
GetTaskFromTaskType(taskType).AppendTaskText(sb);
}
Logger.Info($" Assigned tasks:\n{sb.Replace("\r\n", "\n")}", pc.GetRealName(), multiLine: true);
return;
PlayerTask GetTaskFromTaskType(TaskTypes type) => ShortTasks.ToArray().Concat(LongTasks.ToArray()).FirstOrDefault(t => t.TaskType == type);
}
private static void Shuffle<T>(Il2CppSystem.Collections.Generic.List<T> list)