more combining

This commit is contained in:
Gurge44 committed 2025-04-04 22:06:33 +02:00
1 parent bb11d18ece
commit b8fb56722b
11 files changed
+71 -29

No files matched your search

+20 -6
View File
@@ -6,6 +6,7 @@ using AmongUs.GameOptions;
using EHR.Modules;
using EHR.Neutral;
using HarmonyLib;
using Hazel;
using UnityEngine;
namespace EHR;
@@ -329,6 +330,9 @@ public static class CaptureTheFlag
TeamData[CTFTeam.Yellow] = new(CTFTeam.Yellow, yellowFlag, yellowPlayers, byte.MaxValue);
// Teleport players to their respective bases
var sender = CustomRpcSender.Create("CTF - OnGameStart", SendOption.Reliable);
var hasValue = false;
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
{
if (PlayerTeams.TryGetValue(pc.PlayerId, out CTFTeam team))
@@ -336,19 +340,29 @@ public static class CaptureTheFlag
switch (team)
{
case CTFTeam.Blue:
pc.TP(blueFlagBase.Position);
pc.Notify(string.Format(Translator.GetString("CTF_Notify_EnemyTeamRoom"), yellowFlagBase.RoomName));
sender.TP(pc, blueFlagBase.Position);
sender.Notify(pc, string.Format(Translator.GetString("CTF_Notify_EnemyTeamRoom"), yellowFlagBase.RoomName));
break;
case CTFTeam.Yellow:
pc.TP(yellowFlagBase.Position);
pc.Notify(string.Format(Translator.GetString("CTF_Notify_EnemyTeamRoom"), blueFlagBase.RoomName));
sender.TP(pc, yellowFlagBase.Position);
sender.Notify(pc, string.Format(Translator.GetString("CTF_Notify_EnemyTeamRoom"), blueFlagBase.RoomName));
break;
}
}
pc.RpcChangeRoleBasis(CustomRoles.CTFPlayer);
pc.RpcResetAbilityCooldown();
pc.RpcChangeRoleBasis(CustomRoles.CTFPlayer, sender: sender);
sender.RpcResetAbilityCooldown(pc);
hasValue = true;
if (sender.stream.Length > 800)
{
sender.SendMessage();
sender = CustomRpcSender.Create("CTF - OnGameStart", SendOption.Reliable);
hasValue = false;
}
}
sender.SendMessage(dispose: !hasValue);
ValidTag = true;
GameStartTS = Utils.TimeStamp;
+7 -2
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using HarmonyLib;
using Hazel;
using UnityEngine;
using static EHR.Translator;
@@ -432,17 +433,21 @@ internal static class MoveAndStop
{
case Events.VentAccess:
{
Main.AllAlivePlayerControls.Do(x => x.RpcChangeRoleBasis(CustomRoles.EngineerEHR));
var sender = CustomRpcSender.Create("MoveAndStop - VentAccess", SendOption.Reliable);
Main.AllAlivePlayerControls.Do(x => x.RpcChangeRoleBasis(CustomRoles.EngineerEHR, sender: sender));
sender.SendMessage();
LateTask.New(() =>
{
sender = CustomRpcSender.Create("MoveAndStop - VentAccess (Remove)", SendOption.Reliable);
Main.AllAlivePlayerControls.Do(x =>
{
x.RpcChangeRoleBasis(CustomRoles.Tasker);
x.RpcChangeRoleBasis(CustomRoles.Tasker, sender: sender);
if (x.inVent || x.MyPhysics.Animations.IsPlayingEnterVentAnimation())
LateTask.New(() => x.MyPhysics.RpcExitVent(x.GetClosestVent().Id), 1f, log: false);
});
sender.SendMessage();
}, duration, log: false);
break;
+4 -2
View File
@@ -326,8 +326,10 @@ public static class RoomRush
if (ventLimit > 0)
{
if (Options.CurrentGameMode == CustomGameMode.AllInOne) aapc.DoIf(x => x.GetRoleMap().RoleType is RoleTypes.Crewmate or RoleTypes.Noisemaker or RoleTypes.Scientist or RoleTypes.Tracker, x => x.RpcChangeRoleBasis(CustomRoles.EngineerEHR));
else aapc.Do(x => x.RpcChangeRoleBasis(CustomRoles.EngineerEHR));
var sender = CustomRpcSender.Create("Room Rush - Venting RpcChangeRoleBasis", SendOption.Reliable);
if (Options.CurrentGameMode == CustomGameMode.AllInOne) aapc.DoIf(x => x.GetRoleMap().RoleType is RoleTypes.Crewmate or RoleTypes.Noisemaker or RoleTypes.Scientist or RoleTypes.Tracker, x => x.RpcChangeRoleBasis(CustomRoles.EngineerEHR, sender: sender));
else aapc.Do(x => x.RpcChangeRoleBasis(CustomRoles.EngineerEHR, sender: sender));
sender.SendMessage();
}
Utils.SendRPC(CustomRPC.RoomRushDataSync, 1);
+2 -1
View File
@@ -113,6 +113,8 @@ public class CustomRpcSender
else
throw new InvalidOperationException(errorMsg);
}
Logger.Info($"\"{name}\" is finished (Length: {stream.Length})", "CustomRpcSender");
if (!dispose)
{
@@ -121,7 +123,6 @@ public class CustomRpcSender
}
currentState = State.Finished;
Logger.Info($"\"{name}\" is finished", "CustomRpcSender");
stream.Recycle();
}
+1 -1
View File
@@ -395,7 +395,7 @@ internal static class ExtendedPlayerControl
while (AntiBlackout.SkipTasks || ExileController.Instance) yield return null;
yield return new WaitForSeconds(1f);
Logger.Msg($"Now that the anti-blackout processing or ejection screen showing is complete, the role basis of {player.GetNameWithRole()} will be changed", "RpcChangeRoleBasis");
player.RpcChangeRoleBasis(newCustomRole, loggerRoleMap);
player.RpcChangeRoleBasis(newCustomRole, loggerRoleMap, sender);
}
}
+1 -1
View File
@@ -967,7 +967,7 @@ internal static class IntroCutsceneDestroyPatch
}
}
if (hasValue) sender.SendMessage();
sender.SendMessage(dispose: !hasValue);
}, 0.4f, "Show Pet For Everyone");
LateTask.New(() => Main.ProcessShapeshifts = true, 1f, "Enable SS Processing");
+8 -3
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Hazel;
using static EHR.Options;
using static EHR.Translator;
@@ -128,13 +129,17 @@ public class CopyCat : RoleBase
{
TempLimit = pc.GetAbilityUseLimit();
var sender = CustomRpcSender.Create("Copycat.OnCheckMurder", SendOption.Reliable);
pc.RpcSetCustomRole(role);
pc.RpcChangeRoleBasis(role);
pc.RpcChangeRoleBasis(role, sender: sender);
pc.SetAbilityUseLimit(tpc.GetAbilityUseLimit());
sender.SetKillCooldown(pc);
sender.Notify(pc, string.Format(GetString("CopyCatRoleChange"), Utils.GetRoleName(role)));
sender.SendMessage();
pc.SyncSettings();
pc.SetKillCooldown();
pc.Notify(string.Format(GetString("CopyCatRoleChange"), Utils.GetRoleName(role)));
return false;
}
-1
View File
@@ -114,7 +114,6 @@ internal class Changeling : RoleBase
shapeshifter.RpcChangeRoleBasis(CurrentRole);
ChangedRole[shapeshifter.PlayerId] = true;
shapeshifter.RpcResetAbilityCooldown();
if (!DisableShapeshiftAnimations.GetBool()) LateTask.New(() => shapeshifter.RpcShapeshift(shapeshifter, false), 1f, log: false);
}, 0.3f, log: false);
return false;
+14 -4
View File
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using EHR.Crewmate;
using EHR.Modules;
using Hazel;
using static EHR.Options;
using static EHR.Translator;
using static EHR.Utils;
@@ -182,10 +183,19 @@ public class Mastermind : RoleBase
return false;
}
killer.Kill(target);
killer.Notify(GetString("MastermindTargetSurvived"));
killer.RpcChangeRoleBasis(killer.GetCustomRole());
var sender = CustomRpcSender.Create("Mastermind.ForceKillForManipulatedPlayer", SendOption.Reliable);
const MurderResultFlags resultFlags = (MurderResultFlags)(8 | 1);
if (AmongUsClient.Instance.AmClient) killer.MurderPlayer(target, resultFlags);
sender.AutoStartRpc(killer.NetId, 12);
sender.WriteNetObject(target);
sender.Write((int)resultFlags);
sender.EndRpc();
sender.Notify(killer, GetString("MastermindTargetSurvived"));
killer.RpcChangeRoleBasis(killer.GetCustomRole(), sender: sender);
sender.SendMessage();
LateTask.New(() =>
{
+3 -3
View File
@@ -159,15 +159,15 @@ public class Jackal : RoleBase
{
if (killer.GetAbilityUseLimit() < 1 || !CanBeSidekick(target)) return true;
var sender = CustomRpcSender.Create("Jackal.OnCheckMurder", SendOption.Reliable);
killer.RpcRemoveAbilityUse();
target.RpcSetCustomRole(CustomRoles.Sidekick);
target.RpcChangeRoleBasis(CustomRoles.Sidekick);
target.RpcChangeRoleBasis(CustomRoles.Sidekick, sender: sender);
SidekickId = target.PlayerId;
Main.ResetCamPlayerList.Add(target.PlayerId);
var sender = CustomRpcSender.Create("Jackal.OnCheckMurder", SendOption.Reliable);
sender.Notify(killer, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Jackal), GetString("GangsterSuccessfullyRecruited")), setName: false);
sender.Notify(target, Utils.ColorString(Utils.GetRoleColor(CustomRoles.Jackal), GetString("BeRecruitedByJackal")), setName: false);
+11 -5
View File
@@ -1,4 +1,6 @@
namespace EHR.Impostor;
using Hazel;
namespace EHR.Impostor;
internal class SchrodingersCat : RoleBase
{
@@ -37,15 +39,19 @@ internal class SchrodingersCat : RoleBase
if (!StealsExactImpostorRole.GetBool() && (killerRole.IsImpostor() || killerRole.IsMadmate())) killerRole = CustomRoles.Refugee;
if (killerRole == CustomRoles.Jackal) killerRole = CustomRoles.Sidekick;
if (Options.SingleRoles.Contains(killerRole)) killerRole = CustomRoles.Amnesiac;
var sender = CustomRpcSender.Create("SchrodingersCat.OnCheckMurderAsTarget", SendOption.Reliable);
target.RpcSetCustomRole(killerRole);
target.RpcChangeRoleBasis(killerRole);
target.RpcChangeRoleBasis(killerRole, sender: sender);
killer.SetKillCooldown(5f);
sender.SetKillCooldown(killer, 5f);
killer.Notify(string.Format(Translator.GetString("SchrodingersCat.Notify.KillerRecruited"), target.GetRealName(), CustomRoles.SchrodingersCat.ToColoredString()), 10f);
target.Notify(string.Format(Translator.GetString("SchrodingersCat.Notify.RecruitedByKiller"), killer.GetRealName(), killerRole.ToColoredString()));
sender.Notify(killer, string.Format(Translator.GetString("SchrodingersCat.Notify.KillerRecruited"), target.GetRealName(), CustomRoles.SchrodingersCat.ToColoredString()), 10f, setName: false);
sender.Notify(target, string.Format(Translator.GetString("SchrodingersCat.Notify.RecruitedByKiller"), killer.GetRealName(), killerRole.ToColoredString()), setName: false);
sender.SendMessage();
Utils.NotifyRoles(SpecifySeer: killer, ForceLoop: true);
Utils.NotifyRoles(SpecifySeer: target, ForceLoop: true);