mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Some adjustments + fix nuget.config nightmare (whoever made this, I would like to know your location)
This commit is contained in:
1 parent
084a3e1ffd
commit
a72dcdfacf
10 files changed
+102
-75
No files matched your search
+3
-3
@@ -27,10 +27,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.8.13" PrivateAssets="all"/>
|
||||
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2024.9.4"/>
|
||||
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.1.0-rc.1"/>
|
||||
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.697" Private="false" ExcludeAssets="runtime;native"/>
|
||||
<PackageReference Include="Samboy063.Cpp2IL.Core" Version="2022.1.0-pre-release.15"/>
|
||||
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.704" Private="false" ExcludeAssets="runtime;native"/>
|
||||
<PackageReference Include="Samboy063.Cpp2IL.Core" Version="2022.1.0-pre-release.18"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -240,7 +240,7 @@ static class ExtendedPlayerControl
|
||||
AmongUsClient.Instance.FinishRpcImmediately(writer);
|
||||
}
|
||||
|
||||
public static (RoleTypes roleType, CustomRoles customRole) GetRoleMap(this PlayerControl player, byte targetId = byte.MaxValue) => Utils.GetRoleMap(player.PlayerId, targetId);
|
||||
public static (RoleTypes RoleType, CustomRoles CustomRole) GetRoleMap(this PlayerControl player, byte targetId = byte.MaxValue) => Utils.GetRoleMap(player.PlayerId, targetId);
|
||||
|
||||
// https://github.com/Ultradragon005/TownofHost-Enhanced/blob/ea5f1e8ea87e6c19466231c305d6d36d511d5b2d/Modules/ExtendedPlayerControl.cs
|
||||
public static void RpcRevive(this PlayerControl player)
|
||||
@@ -254,7 +254,7 @@ static class ExtendedPlayerControl
|
||||
|
||||
Main.PlayerStates[player.PlayerId].IsDead = false;
|
||||
Main.PlayerStates[player.PlayerId].deathReason = PlayerState.DeathReason.etc;
|
||||
player.RpcChangeRoleBasis(player.GetRoleMap().customRole, true);
|
||||
player.RpcChangeRoleBasis(player.GetRoleMap().CustomRole, true);
|
||||
player.ResetKillCooldown();
|
||||
player.SyncSettings();
|
||||
player.SetKillCooldown();
|
||||
@@ -271,69 +271,78 @@ static class ExtendedPlayerControl
|
||||
if (!GameStates.IsInGame || !AmongUsClient.Instance.AmHost) return;
|
||||
|
||||
var playerId = player.PlayerId;
|
||||
var playerRole = Utils.GetRoleMap(playerId).customRole;
|
||||
var playerRole = Utils.GetRoleMap(playerId).CustomRole;
|
||||
var newRoleType = newCustomRole.GetRoleTypes();
|
||||
RoleTypes remeberRoleType;
|
||||
|
||||
if (Options.CurrentGameMode == CustomGameMode.Speedrun && newCustomRole == CustomRoles.Runner)
|
||||
newRoleType = SpeedrunManager.CanKill.Contains(player.PlayerId) ? RoleTypes.Impostor : RoleTypes.Crewmate;
|
||||
|
||||
// Desync role to normal role
|
||||
if (playerRole.IsDesyncRole() && !newCustomRole.IsDesyncRole())
|
||||
{
|
||||
foreach (var seer in Main.AllPlayerControls)
|
||||
{
|
||||
var isSelf = player.PlayerId == seer.PlayerId;
|
||||
if (!isSelf && seer.HasDesyncRole() && !seer.AmOwner)
|
||||
remeberRoleType = newCustomRole.GetVNRole() is CustomRoles.Noisemaker ? RoleTypes.Noisemaker : RoleTypes.Scientist;
|
||||
else remeberRoleType = newRoleType;
|
||||
var oldRoleIsDesync = playerRole.IsDesyncRole();
|
||||
var newRoleIsDesync = newCustomRole.IsDesyncRole();
|
||||
|
||||
SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seer.PlayerId, playerId)] = (remeberRoleType, newCustomRole);
|
||||
player.RpcSetRoleDesync(remeberRoleType, seer.GetClientId());
|
||||
}
|
||||
}
|
||||
// Normal role to desync role
|
||||
else if (!playerRole.IsDesyncRole() && newCustomRole.IsDesyncRole())
|
||||
switch (oldRoleIsDesync, newRoleIsDesync)
|
||||
{
|
||||
foreach (var seer in Main.AllPlayerControls)
|
||||
// Desync role to normal role
|
||||
case (true, false):
|
||||
{
|
||||
var isSelf = player.PlayerId == seer.PlayerId;
|
||||
if (isSelf)
|
||||
foreach (var seer in Main.AllPlayerControls)
|
||||
{
|
||||
remeberRoleType = player.IsHost() ? RoleTypes.Crewmate : RoleTypes.Impostor;
|
||||
|
||||
// For Desync Shapeshifter
|
||||
if (newCustomRole.GetDYRole() is RoleTypes.Shapeshifter)
|
||||
remeberRoleType = RoleTypes.Shapeshifter;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!player.IsHost() && seer.HasDesyncRole()) remeberRoleType = newCustomRole.GetVNRole() is CustomRoles.Noisemaker ? RoleTypes.Noisemaker : RoleTypes.Scientist;
|
||||
var isSelf = player.PlayerId == seer.PlayerId;
|
||||
if (!isSelf && seer.HasDesyncRole() && !seer.AmOwner)
|
||||
remeberRoleType = newCustomRole.GetVNRole() is CustomRoles.Noisemaker ? RoleTypes.Noisemaker : RoleTypes.Scientist;
|
||||
else remeberRoleType = newRoleType;
|
||||
|
||||
SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seer.PlayerId, playerId)] = (remeberRoleType, newCustomRole);
|
||||
player.RpcSetRoleDesync(remeberRoleType, seer.GetClientId());
|
||||
}
|
||||
|
||||
SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seer.PlayerId, playerId)] = (remeberRoleType, newCustomRole);
|
||||
player.RpcSetRoleDesync(remeberRoleType, seer.GetClientId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Desync role to desync role
|
||||
// Normal role to normal role
|
||||
else
|
||||
{
|
||||
var playerIsDesync = player.HasDesyncRole();
|
||||
foreach (var seer in Main.AllPlayerControls)
|
||||
// Normal role to desync role
|
||||
case (false, true):
|
||||
{
|
||||
var seerClientId = seer.GetClientId();
|
||||
if (seerClientId == -1) continue;
|
||||
|
||||
if ((playerIsDesync || seer.HasDesyncRole()) && seer.PlayerId != playerId)
|
||||
foreach (var seer in Main.AllPlayerControls)
|
||||
{
|
||||
remeberRoleType = Utils.GetRoleMap(seer.PlayerId, playerId).roleType;
|
||||
}
|
||||
else remeberRoleType = newRoleType;
|
||||
if (player.PlayerId == seer.PlayerId)
|
||||
{
|
||||
remeberRoleType = player.IsHost() ? RoleTypes.Crewmate : RoleTypes.Impostor;
|
||||
|
||||
SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seer.PlayerId, playerId)] = (remeberRoleType, newCustomRole);
|
||||
player.RpcSetRoleDesync(remeberRoleType, seer.GetClientId());
|
||||
// For Desync Shapeshifter
|
||||
if (newCustomRole.GetDYRole() is RoleTypes.Shapeshifter)
|
||||
remeberRoleType = RoleTypes.Shapeshifter;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!player.IsHost() && seer.HasDesyncRole()) remeberRoleType = newCustomRole.GetVNRole() is CustomRoles.Noisemaker ? RoleTypes.Noisemaker : RoleTypes.Scientist;
|
||||
else remeberRoleType = newRoleType;
|
||||
}
|
||||
|
||||
SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seer.PlayerId, playerId)] = (remeberRoleType, newCustomRole);
|
||||
player.RpcSetRoleDesync(remeberRoleType, seer.GetClientId());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
// Desync role to desync role
|
||||
// Normal role to normal role
|
||||
default:
|
||||
{
|
||||
var playerIsDesync = player.HasDesyncRole();
|
||||
foreach (var seer in Main.AllPlayerControls)
|
||||
{
|
||||
var seerClientId = seer.GetClientId();
|
||||
if (seerClientId == -1) continue;
|
||||
|
||||
if ((playerIsDesync || seer.HasDesyncRole()) && seer.PlayerId != playerId)
|
||||
remeberRoleType = Utils.GetRoleMap(seer.PlayerId, playerId).RoleType;
|
||||
else remeberRoleType = newRoleType;
|
||||
|
||||
SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seer.PlayerId, playerId)] = (remeberRoleType, newCustomRole);
|
||||
player.RpcSetRoleDesync(remeberRoleType, seer.GetClientId());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,10 +353,14 @@ static class ExtendedPlayerControl
|
||||
foreach (var target in Main.AllPlayerControls)
|
||||
{
|
||||
if (SelectRolesPatch.RpcSetRoleReplacer.RoleMap.TryGetValue((seer.PlayerId, target.PlayerId), out var map))
|
||||
Logger.Info($"seer {seer.Data?.PlayerName}-{seer.PlayerId}, target {target.Data?.PlayerName}-{target.PlayerId} => {map.roleType}, {map.customRole}", "Role Map");
|
||||
Logger.Info($"seer {seer.Data?.PlayerName}-{seer.PlayerId}, target {target.Data?.PlayerName}-{target.PlayerId} => {map.RoleType}, {map.CustomRole}", "Role Map");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Main.ChangedRole = true;
|
||||
|
||||
Logger.Info($"{player.GetNameWithRole()}'s role basis was changed to {newRoleType} ({newCustomRole}) (from role: {playerRole}) - oldRoleIsDesync: {oldRoleIsDesync}, newRoleIsDesync: {newRoleIsDesync}", "RpcChangeRoleBasis");
|
||||
}
|
||||
|
||||
// https://github.com/Ultradragon005/TownofHost-Enhanced/blob/ea5f1e8ea87e6c19466231c305d6d36d511d5b2d/Modules/Utils.cs
|
||||
|
||||
+5
-7
@@ -649,7 +649,7 @@ public static class Utils
|
||||
if (p.Role == null) return false;
|
||||
|
||||
var hasTasks = true;
|
||||
var States = Main.PlayerStates[p.PlayerId];
|
||||
var state = Main.PlayerStates[p.PlayerId];
|
||||
if (p.Disconnected) return false;
|
||||
if (p.Role.IsImpostor)
|
||||
hasTasks = false;
|
||||
@@ -665,9 +665,7 @@ public static class Utils
|
||||
case CustomGameMode.HideAndSeek: return HnSManager.HasTasks(p);
|
||||
}
|
||||
|
||||
if (false) return false;
|
||||
|
||||
var role = States.MainRole;
|
||||
var role = state.MainRole;
|
||||
switch (role)
|
||||
{
|
||||
case CustomRoles.GM:
|
||||
@@ -776,7 +774,7 @@ public static class Utils
|
||||
case CustomRoles.Doomsayer:
|
||||
hasTasks = false;
|
||||
break;
|
||||
case CustomRoles.Dad when ((Dad)States.Role).DoneTasks:
|
||||
case CustomRoles.Dad when ((Dad)state.Role).DoneTasks:
|
||||
case CustomRoles.Workaholic:
|
||||
case CustomRoles.Terrorist:
|
||||
case CustomRoles.Sunnyboy:
|
||||
@@ -800,7 +798,7 @@ public static class Utils
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (CustomRoles subRole in States.SubRoles)
|
||||
foreach (CustomRoles subRole in state.SubRoles)
|
||||
{
|
||||
switch (subRole)
|
||||
{
|
||||
@@ -2531,7 +2529,7 @@ public static class Utils
|
||||
GetPlayerById(playerId)?.RpcResetAbilityCooldown();
|
||||
}
|
||||
|
||||
public static (RoleTypes roleType, CustomRoles customRole) GetRoleMap(byte seerId, byte targetId = byte.MaxValue)
|
||||
public static (RoleTypes RoleType, CustomRoles CustomRole) GetRoleMap(byte seerId, byte targetId = byte.MaxValue)
|
||||
{
|
||||
if (targetId == byte.MaxValue) targetId = seerId;
|
||||
return SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seerId, targetId)];
|
||||
|
||||
@@ -978,7 +978,7 @@ internal class SelectRolesPatch
|
||||
private static Dictionary<byte, CustomRpcSender> Senders = [];
|
||||
private static Dictionary<byte, RoleTypes> StoragedData = [];
|
||||
private static Dictionary<byte, bool> DataDisconnected = [];
|
||||
public static Dictionary<(byte seerId, byte targetId), (RoleTypes roleType, CustomRoles customRole)> RoleMap = [];
|
||||
public static Dictionary<(byte SeerID, byte TargetID), (RoleTypes RoleType, CustomRoles CustomRole)> RoleMap = [];
|
||||
public static List<CustomRpcSender> OverriddenSenderList = [];
|
||||
|
||||
public static void Initialize()
|
||||
@@ -1074,7 +1074,7 @@ internal class SelectRolesPatch
|
||||
try
|
||||
{
|
||||
// canOverride should be false for the host during assign
|
||||
seer.SetRole(roleType, false);
|
||||
seer.SetRole(roleType, canOverride: false);
|
||||
|
||||
// send rpc set role for other clients
|
||||
sender.AutoStartRpc(seer.NetId, (byte)RpcCalls.SetRole, target.GetClientId())
|
||||
@@ -1113,7 +1113,7 @@ internal class SelectRolesPatch
|
||||
|
||||
int targetClientId = target.GetClientId();
|
||||
|
||||
RoleTypes roleType = RoleMap.TryGetValue((target.PlayerId, target.PlayerId), out var roleMap) ? roleMap.roleType : StoragedData.GetValueOrDefault(target.PlayerId, RoleTypes.Crewmate);
|
||||
RoleTypes roleType = RoleMap.TryGetValue((target.PlayerId, target.PlayerId), out var roleMap) ? roleMap.RoleType : StoragedData.GetValueOrDefault(target.PlayerId, RoleTypes.Crewmate);
|
||||
|
||||
var stream = MessageWriter.Get(SendOption.Reliable);
|
||||
stream.StartMessage(6);
|
||||
@@ -1141,6 +1141,13 @@ internal class SelectRolesPatch
|
||||
Senders = null;
|
||||
OverriddenSenderList = null;
|
||||
StoragedData = null;
|
||||
|
||||
if (PlayerControl.AllPlayerControls.Count <= 1) return;
|
||||
|
||||
PlayerControl.AllPlayerControls.ForEach((Action<PlayerControl>)(PlayerNameColor.Set));
|
||||
PlayerControl.LocalPlayer.StopAllCoroutines();
|
||||
DestroyableSingleton<HudManager>.Instance.StartCoroutine(DestroyableSingleton<HudManager>.Instance.CoShowIntro());
|
||||
DestroyableSingleton<HudManager>.Instance.HideGameLoader();
|
||||
}
|
||||
|
||||
private static void RpcSetDisconnected(MessageWriter stream, bool disconnected)
|
||||
@@ -1149,7 +1156,7 @@ internal class SelectRolesPatch
|
||||
{
|
||||
if (disconnected)
|
||||
{
|
||||
// if player left the game, remember current data
|
||||
// If player left the game, remember current data
|
||||
DataDisconnected[playerinfo.PlayerId] = playerinfo.Disconnected;
|
||||
|
||||
playerinfo.Disconnected = true;
|
||||
|
||||
@@ -3935,6 +3935,7 @@
|
||||
"ShifterInfo": "Steal Someone's Role",
|
||||
"ShifterInfoLong": "(Neutrals):\\nAs the Shifter, you must steal someone's role by using your pet button near them. Depending on the settings, you may also steal their progress in their role and ability uses, and their add-ons.\\nIf you have this role when the game ends, you lose!",
|
||||
"TryChangeBasis": "Try Changing Role Basis <#ffff00>(EXPERIMENTAL)</color>",
|
||||
"ShifterKillButtonText": "Shift Role",
|
||||
"Tremor": "Tremor",
|
||||
"TremorInfo": "When Doom Happens, Everyone is Doomed",
|
||||
"TremorInfoLong": "(Neutral):\\nAs the Tremor, you see a timer below your name indicating when doom happens. When you kill, the timer decreases. If doom happens, you kill everyone that comes near you, and you have a specified amount of time to kill everyone, otherwise you suicide.",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AmongUs.GameOptions;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -78,6 +79,7 @@ namespace EHR.Crewmate
|
||||
|
||||
var state = Main.PlayerStates[reporter.PlayerId];
|
||||
state.deathReason = PlayerState.DeathReason.Sacrifice;
|
||||
state.RealKiller = (DateTime.Now, reporter.PlayerId);
|
||||
state.SetDead();
|
||||
reporter.RpcExileV2();
|
||||
|
||||
|
||||
@@ -123,5 +123,10 @@ namespace EHR.Neutral
|
||||
{
|
||||
OnCheckMurder(pc, ExternalRpcPetPatch.SelectKillButtonTarget(pc));
|
||||
}
|
||||
|
||||
public override void SetButtonTexts(HudManager hud, byte id)
|
||||
{
|
||||
hud.KillButton?.OverrideText(Translator.GetString("ShifterKillButtonText"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ public class Werewolf : RoleBase
|
||||
}
|
||||
|
||||
public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = KillCooldown.GetFloat();
|
||||
public override bool CanUseImpostorVentButton(PlayerControl pc) => (CanRampage && (!UseUnshiftTrigger.GetBool() || UseUnshiftTriggerForNKs.GetBool())) || IsRampaging || pc.inVent;
|
||||
public override bool CanUseImpostorVentButton(PlayerControl pc) => (CanRampage && (!UseUnshiftTrigger.GetBool() || !UseUnshiftTriggerForNKs.GetBool())) || IsRampaging || pc.inVent;
|
||||
public override bool CanUseKillButton(PlayerControl pc) => IsRampaging;
|
||||
|
||||
public override void ApplyGameOptions(IGameOptions opt, byte id)
|
||||
@@ -78,7 +78,7 @@ public class Werewolf : RoleBase
|
||||
if (UsePhantomBasis.GetBool() && UsePhantomBasisForNKs.GetBool())
|
||||
AURoleOptions.PhantomCooldown = 1f;
|
||||
if (UseUnshiftTrigger.GetBool() && UseUnshiftTriggerForNKs.GetBool())
|
||||
AURoleOptions.ShapeshifterCooldown = 1f;
|
||||
AURoleOptions.ShapeshifterCooldown = RampageDur.GetFloat() + 0.5f;
|
||||
|
||||
AURoleOptions.EngineerCooldown = 0f;
|
||||
AURoleOptions.EngineerInVentMaxTime = 0f;
|
||||
@@ -125,8 +125,9 @@ public class Werewolf : RoleBase
|
||||
if (lastTime + (long)RampageCD.GetFloat() < now)
|
||||
{
|
||||
lastTime = -10;
|
||||
if (!player.IsModClient()) player.Notify(GetString(UseUnshiftTrigger.GetBool() && UseUnshiftTriggerForNKs.GetBool() ? "WWCanRampageUnshift" : "WWCanRampage"));
|
||||
player.RpcChangeRoleBasis(CustomRoles.EngineerEHR);
|
||||
var unshift = UseUnshiftTrigger.GetBool() && UseUnshiftTriggerForNKs.GetBool();
|
||||
if (!player.IsModClient()) player.Notify(GetString(unshift ? "WWCanRampageUnshift" : "WWCanRampage"));
|
||||
player.RpcChangeRoleBasis(unshift ? CustomRoles.Werewolf : CustomRoles.EngineerEHR);
|
||||
SendRPC();
|
||||
CD = 0;
|
||||
}
|
||||
@@ -207,7 +208,7 @@ public class Werewolf : RoleBase
|
||||
else if (ww.lastTime != -10)
|
||||
{
|
||||
var cooldown = ww.lastTime + (long)RampageCD.GetFloat() - Utils.TimeStamp;
|
||||
str.Append(string.Format(GetString("WWCD"), cooldown + 2));
|
||||
str.Append(string.Format(GetString("WWCD"), cooldown + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -45,7 +45,7 @@ public class Main : BasePlugin
|
||||
public const string ModColor = "#00ffff";
|
||||
public const bool AllowPublicRoom = true;
|
||||
public const string ForkId = "EHR";
|
||||
public const string SupportedAUVersion = "2024.8.13";
|
||||
public const string SupportedAUVersion = "2024.9.4";
|
||||
public static readonly Version Version = Version.Parse(PluginVersion);
|
||||
public static ManualLogSource Logger;
|
||||
public static bool HasArgumentException;
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json"/>
|
||||
<add key="Samboy" value="https://nuget.samboy.dev/v3/index.json"/>
|
||||
</packageSources>
|
||||
<packageSources>
|
||||
<add key="nuget" value="https://api.nuget.org/v3/index.json"/>
|
||||
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json"/>
|
||||
<add key="Samboy" value="https://nuget.samboy.dev/v3/index.json"/>
|
||||
</packageSources>
|
||||
</configuration>
|
||||
Reference in new issue
Block a user