Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev 2.2.0 #1289

Draft
wants to merge 145 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
056f193
New Option:Dictator use Command to Expel instead of Vote
hinhinarrrrrr Sep 29, 2024
eb5d84d
Fix
hinhinarrrrrr Sep 29, 2024
dc9f6bb
First commit
Tommy-XL Oct 1, 2024
1b12817
Forgot
Tommy-XL Oct 1, 2024
c87f816
Set private
Tommy-XL Oct 1, 2024
b5cc3fa
TOH send at 500
NikoCat233 Oct 20, 2024
801ea04
/start command
laikrai Nov 2, 2024
1daeee2
Merge remote-tracking branch 'upstream/main'
laikrai Nov 2, 2024
6aaacad
New translations en_us.json (Chinese Traditional)
0xDrMoe Nov 3, 2024
5afbf94
New translations en_us.json (Chinese Traditional)
0xDrMoe Nov 3, 2024
00d1ae8
Merge branch 'EnhancedNetwork:main' into main
laikrai Nov 3, 2024
6a5e4ee
New translations en_us.json (Japanese)
0xDrMoe Nov 3, 2024
dce80ec
New translations en_us.json (Spanish, Latin America)
0xDrMoe Nov 4, 2024
0516c51
New translations en_us.json (Spanish, Latin America)
0xDrMoe Nov 4, 2024
77c52ca
Update en_US.json with RefugeeLongInfo
this-dude-codes Nov 5, 2024
aab5a5f
Merge pull request #1280 from this-dude-codes/main
0xDrMoe Nov 8, 2024
25c8aed
Add some NA settings
ApeMV Nov 8, 2024
3b4bcd5
Angry ID Sounds
ApeMV Nov 8, 2024
326369e
Shocker
laikrai Nov 8, 2024
294d68e
Token by file hash
NikoCat233 Nov 9, 2024
3f794fe
Avoid null
NikoCat233 Nov 9, 2024
6207255
Merge branch 'pr/1237' into dev_2.2.0
NikoCat233 Nov 9, 2024
62bab01
Merge branch 'CriticalErrorManager' into dev_2.2.0
NikoCat233 Nov 9, 2024
6e9e8f2
Move Test AntiBlackOut to Debug Only
NikoCat233 Nov 9, 2024
177c3f4
Merge branch 'Keep-Up-With-TOH-Delayed-Network-Data' into dev_2.2.0
NikoCat233 Nov 9, 2024
02e63c9
Merge branch 'pr/1276' into dev_2.2.0
NikoCat233 Nov 9, 2024
712f777
Merge branch 'Api-Key-By-Dll-hash' into dev_2.2.0
NikoCat233 Nov 9, 2024
08761de
Change Version Number
NikoCat233 Nov 9, 2024
a0b23bc
Ignore token.env
NikoCat233 Nov 9, 2024
c2b50a6
Added Dictator Button Gui
NikoCat233 Nov 9, 2024
2ad6707
Merge remote-tracking branch 'upstream/l10n_main' into dev_2.2.0
NikoCat233 Nov 9, 2024
84ad321
renevant introduction
Limeau Nov 9, 2024
9c8b37d
Fix RpcTeleport leading ban
NikoCat233 Nov 9, 2024
0ee108e
New translations en_us.json (Chinese Traditional)
0xDrMoe Nov 9, 2024
8a449bd
revenant rename
Limeau Nov 9, 2024
f5ccc08
Disable pva playerid + name
NikoCat233 Nov 9, 2024
1929ea1
New translations en_us.json (Chinese Traditional)
0xDrMoe Nov 9, 2024
38264d9
Apply actually playtested code
ApeMV Nov 9, 2024
ad396b7
Rename Revenant .cs to Revenant.cs
Limeau Nov 9, 2024
9a07425
option holder
Limeau Nov 9, 2024
d145442
Merge branch 'main' of https://github.com/Limeau/TownofHost-Enhanced
Limeau Nov 9, 2024
d172643
balance change
laikrai Nov 10, 2024
f407c08
Refactor Shocker logic
laikrai Nov 13, 2024
68e5863
fix death reason and win con
laikrai Nov 14, 2024
c68f754
New translations en_us.json (Chinese Traditional)
0xDrMoe Nov 16, 2024
b9e6555
Merge pull request #1 from NikoCat233/dev_2.2.0
NikoCat233 Nov 17, 2024
f4defa0
Change API endpoint
NikoCat233 Nov 17, 2024
ed19bdd
Fix Spy name not syncing by role base
NikoCat233 Nov 17, 2024
5f71b21
Fix rebirth can vote mini and solsticer
NikoCat233 Nov 17, 2024
b8f5a31
Change Lawyer to Single Role
NikoCat233 Nov 17, 2024
4bcff59
Fix change gamemode shows HideNSeek
NikoCat233 Nov 17, 2024
07fb131
Fix Host DoomSayer can guess infinitely
NikoCat233 Nov 17, 2024
e26b0b5
Add UI for dictator
NikoCat233 Nov 17, 2024
5622085
Change ReportBodyOutOfGameC
NikoCat233 Nov 17, 2024
86aca3b
Fix Spy name not syncing by role base
NikoCat233 Nov 17, 2024
c355fd4
Fix rebirth can vote mini and solsticer
NikoCat233 Nov 17, 2024
bab932e
Change Lawyer to Single Role
NikoCat233 Nov 17, 2024
4e1c947
Fix change gamemode shows HideNSeek
NikoCat233 Nov 17, 2024
f417bb2
Fix Host DoomSayer can guess infinitely
NikoCat233 Nov 17, 2024
68d5a00
Add UI for dictator
NikoCat233 Nov 17, 2024
f9b7858
Change ReportBodyOutOfGameC
NikoCat233 Nov 17, 2024
4b030bc
Revert "Change API endpoint"
NikoCat233 Nov 17, 2024
338ddeb
Merge pull request #5 from LightCat233/merge-to-niko
NikoCat233 Nov 17, 2024
2415f4f
Merge pull request #6 from Limeau/main
NikoCat233 Nov 18, 2024
5b72292
Merge branch 'dev_2.2.0' of https://github.com/NikoCat233/TownofHost-…
NikoCat233 Nov 18, 2024
6c3e824
Fix Revenant
NikoCat233 Nov 18, 2024
0acb7aa
Exclude Reventant from count types
NikoCat233 Nov 18, 2024
0ad4ba8
Merge remote-tracking branch 'upstream/l10n_main' into dev_2.2.0
NikoCat233 Nov 18, 2024
0720d5c
Change Version Nubmer
NikoCat233 Nov 18, 2024
3370b56
supposedly fix blackscreen after meeting
laikrai Nov 18, 2024
8d985b8
winner role text
laikrai Nov 18, 2024
ae52ff1
small fix
laikrai Nov 20, 2024
eed6c85
small fix
laikrai Nov 20, 2024
ef87179
Fix ban manager kicking null puid
NikoCat233 Nov 21, 2024
c911ad5
Fix duplicated role id
NikoCat233 Nov 21, 2024
9bee573
Lift the priority check murder in case it cant douse
NikoCat233 Nov 21, 2024
d1dd6ff
Banned copycat from baker
NikoCat233 Nov 21, 2024
d8cc803
Merge pull request #1285 from NikoCat233/dev_2.2.0
0xDrMoe Nov 22, 2024
c43a1e2
revenant typo fix
Limeau Nov 22, 2024
f0fe288
Merge pull request #1290 from Limeau/main
NikoCat233 Nov 23, 2024
f4da1e7
Fix War rpc not sync
NikoCat233 Nov 23, 2024
428464a
Merge pull request #1282 from ApeMV/main
NikoCat233 Nov 23, 2024
fea7a35
Jackal Rework - Basis
NikoCat233 Nov 23, 2024
8067e0e
Add SideKick become boss
NikoCat233 Nov 23, 2024
c5d29e3
Fix SideKick can show tasks
NikoCat233 Nov 23, 2024
2db9f65
Fix setitngs Id & translations
NikoCat233 Nov 23, 2024
078fbb3
Update JackalInfoLong
NikoCat233 Nov 23, 2024
5b42cce
Disable HorseMode
NikoCat233 Nov 23, 2024
6c21b51
Fix some ban bugs
NikoCat233 Nov 23, 2024
3280c90
Change some guard animations
NikoCat233 Nov 23, 2024
66c57ab
Add some logging
NikoCat233 Nov 23, 2024
9151291
Merge pull request #1292 from NikoCat233/Rework-Jackal-and-SideKick-&…
NikoCat233 Nov 23, 2024
5934110
Global review some onAdd
NikoCat233 Nov 23, 2024
ac20705
Godfather now uses change role basis
NikoCat233 Nov 23, 2024
ae199ca
Return ChiefOfPolice
NikoCat233 Nov 23, 2024
9889bff
Merge branch 'dev_2.2.0' into role/Shocker
laikrai Nov 23, 2024
527cec4
Fixes and Improvements
NikoCat233 Nov 24, 2024
58ad2c7
Fix death reason and can pass addon
NikoCat233 Nov 24, 2024
4f291f6
Merge pull request #1293 from EnhancedNetwork/Return-CheifOfPolice
NikoCat233 Nov 24, 2024
9ca56ee
Rework Amnesiac
NikoCat233 Nov 24, 2024
d59264c
Seems good
NikoCat233 Nov 24, 2024
a54b8a9
Merge pull request #1294 from EnhancedNetwork/Rework-Amnesiac
NikoCat233 Nov 24, 2024
1fd3171
Change default settings of Jackal
NikoCat233 Nov 24, 2024
cc44ff6
Change Version Number Alpha 3
NikoCat233 Nov 24, 2024
25154ce
Fix non Amnesiac can report and change role
NikoCat233 Nov 24, 2024
5e4d7e6
Amnesiac fix again
NikoCat233 Nov 24, 2024
7d96da1
Fix translation for ChiefofPolice
NikoCat233 Nov 24, 2024
53829cc
Change some guard animations
NikoCat233 Nov 24, 2024
9767df1
Fix Kamikaze rpc not syncing
NikoCat233 Nov 24, 2024
58e34de
Lift the proirity of Consigliere guess
NikoCat233 Nov 24, 2024
aa931c4
Alpha 3 HotFix 1
NikoCat233 Nov 24, 2024
dd16260
Change intro sound for 4 roles
PEPPERcula Nov 25, 2024
20eddac
Add failed Notify for QuickShooter
NikoCat233 Nov 26, 2024
5d1424c
Fix host name never actually changed using /rn
NikoCat233 Nov 26, 2024
e1e62ea
Fix oiiai removed witch or hexmaster but spell remains
NikoCat233 Nov 26, 2024
81635b9
Test Fix vanilla players get banned for sabotages after change role b…
NikoCat233 Nov 26, 2024
1003683
Fix Sidekick turn to jackal show -100 sometimes
NikoCat233 Nov 26, 2024
bcc0933
Merge pull request #1298 from PEPPERcula/main
NikoCat233 Nov 26, 2024
13a3f05
Attempt 2
ApeMV Nov 25, 2024
e8a6851
Change the position of set death reason
NikoCat233 Nov 26, 2024
aca03a3
Fix token.env appearing on git
NikoCat233 Nov 26, 2024
22b819b
Format and fix wrong configure
NikoCat233 Nov 26, 2024
93a46dc
Merge pull request #1301 from EnhancedNetwork/Fix-token.env-appear-on…
NikoCat233 Nov 26, 2024
60db735
requested changes
laikrai Nov 26, 2024
f9a198d
Merge branch 'dev_2.2.0' into role/Shocker
laikrai Nov 26, 2024
8582b00
OnFixedUpdateOthers
laikrai Nov 27, 2024
aadcb8b
Now tasks always re assign on set role mid game
NikoCat233 Nov 28, 2024
dca1e5d
Add logging for Enigma
NikoCat233 Nov 28, 2024
fff7d96
Add additional Exile calls to prevent dead alive
NikoCat233 Nov 28, 2024
53fdb4d
Prevent meeting to be called shortly after last one
NikoCat233 Nov 28, 2024
789f2d8
Try fix get Summary text error
NikoCat233 Nov 28, 2024
16a73fe
Fix mod news never actually loaded
NikoCat233 Nov 28, 2024
f6a5d36
Traitor see imps in intro
NikoCat233 Nov 28, 2024
dae4bf0
EvilMini cant be guessed option
NikoCat233 Nov 28, 2024
a5ca37a
Fix bugs where mis guess can be ignored
NikoCat233 Nov 28, 2024
5b9faf4
Add kill notify for guardian & temp fix spy
NikoCat233 Nov 28, 2024
fd0f3a7
Add place holder for mod news past version
NikoCat233 Nov 28, 2024
314cec6
Add crowded into TOHE
NikoCat233 Nov 29, 2024
eb88d5f
Add credits for Crowded
NikoCat233 Nov 29, 2024
09b74de
switch vanilla regions changes playercount
NikoCat233 Nov 29, 2024
c25880c
Add BlockMoveInVents
NikoCat233 Nov 29, 2024
3cd06e6
Merge pull request #1283 from laikrai/role/Shocker
NikoCat233 Nov 29, 2024
7c025af
Fix shocker custom collider not destorying
NikoCat233 Nov 29, 2024
f43cb3a
Mulit bug fixes
NikoCat233 Nov 29, 2024
4640cfe
Change Version 220 Alpha 4
NikoCat233 Nov 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ FodyWeavers.xsd
TOHE.sln
.vscode/settings.json
/token.env
token.env
28 changes: 26 additions & 2 deletions Modules/AntiBlackout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ private static void RevivePlayersAndSetDummyImp()
if (CustomWinnerHolder.WinnerTeam != CustomWinner.Default) return;

PlayerControl dummyImp = Main.AllAlivePlayerControls.FirstOrDefault(x => x.PlayerId != ExilePlayerId);
if (dummyImp == null) return;

if (dummyImp == null)
{
Logger.Warn("Cant find a alive dummy Imp, AntiBlackout may break?", "AntiBlackout.RevivePlayersAndSetDummyImp");
Logger.SendInGame("Cant find a alive dummy Imp, AntiBlackout may break?");
return;
}

foreach (var seer in Main.AllPlayerControls)
{
Expand All @@ -127,7 +133,25 @@ public static void RestoreIsDead(bool doSend = true, [CallerMemberName] string c
}
isDeadCache.Clear();
IsCached = false;
if (doSend) SendGameData();
if (doSend)
{
SendGameData();
_ = new LateTask(() => RestoreIsDeadByExile(), 0.3f, "AntiBlackOut_RestoreIsDeadByExile");
}
}

private static void RestoreIsDeadByExile()
{
var sender = CustomRpcSender.Create("AntiBlackout RestoreIsDeadByExile", SendOption.Reliable);
foreach (var player in Main.AllPlayerControls)
{
if (player.Data.IsDead && !player.Data.Disconnected)
{
sender.AutoStartRpc(player.NetId, (byte)RpcCalls.Exiled);
sender.EndRpc();
}
}
sender.SendMessage();
}

public static void SendGameData([CallerMemberName] string callerMethodName = "")
Expand Down
11 changes: 8 additions & 3 deletions Modules/BanManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,20 @@ public static string GetHashedPuid(this ClientData player)
{
if (player == null) return "";
string puid = player.ProductUserId;
return GetHashedPuid(puid);
}
public static string GetHashedPuid(string puid)
{
using SHA256 sha256 = SHA256.Create();

// get sha-256 hash
byte[] sha256Bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(puid));
string sha256Hash = BitConverter.ToString(sha256Bytes).Replace("-", "").ToLower();

// pick front 5 and last 4
return string.Concat(sha256Hash.AsSpan(0, 5), sha256Hash.AsSpan(sha256Hash.Length - 4));
}

public static void AddBanPlayer(ClientData player)
{
if (!AmongUsClient.Instance.AmHost || player == null) return;
Expand Down Expand Up @@ -225,9 +230,9 @@ public static bool CheckEACList(string code, string hashedPuid)
var splitUser = user["friendcode"].ToString().Split('#')[0].ToLower().Trim();

if ((!string.IsNullOrEmpty(splitCode) && (splitCode == splitUser))
|| (user["hashPUID"].ToString().ToLower().Trim() == hashedPuid.ToLower().Trim()))
|| !hashedPuid.IsNullOrWhiteSpace() && (user["hashPUID"].ToString().ToLower().Trim() == hashedPuid.ToLower().Trim()))
{
Logger.Warn($"friendcode : {code}, hashedPUID : {hashedPuid} banned by EAC reason : {user["reason"]}", "CheckEACList");
Logger.Warn($"friendcode : {code}, hashedPUID : {hashedPuid} banned by EAC reason : {user["friendcode"]} {user["reason"]}", "CheckEACList");
return true;
}
}
Expand Down
172 changes: 172 additions & 0 deletions Modules/CriticalErrorManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
using Hazel;
using static TOHE.Translator;

namespace TOHE.Modules;

public static class CriticalErrorManager
{
private static bool IsError = false;
private static bool ErrorFromRpc = false;
private static byte ModdedPlayerId = byte.MinValue;

public static void SetCreiticalError(string reason, bool whileLoading, string sourseError = "")
{
Logger.Fatal($"Error: {reason} - triggered critical error", "Anti-black");
IsError = true;

if (!whileLoading) return;

if (AmongUsClient.Instance.AmHost)
{
ChatUpdatePatch.DoBlockChat = true;
Main.OverrideWelcomeMsg = GetString("AntiBlackOutNotifyInLobby");
}
else
{
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.AntiBlackout, SendOption.Reliable);
writer.Write(reason);
writer.Write(sourseError);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
}
public static void ReadRpc(PlayerControl player, MessageReader reader)
{
IsError = true;
ErrorFromRpc = true;
Logger.Fatal($"Modded client: {player?.Data?.PlayerName}({player.PlayerId}): triggered critical error: {reader.ReadString()}", "Anti-black");
Logger.Error($"Error: {reader.ReadString()}", "CriticalErrorManager");

ModdedPlayerId = player.PlayerId;
ChatUpdatePatch.DoBlockChat = true;
Main.OverrideWelcomeMsg = string.Format(GetString("RpcAntiBlackOutNotifyInLobby"), player?.Data?.PlayerName, GetString("EndWhenPlayerBug"));
}
public static void CheckEndGame()
{
if (!IsError) return;

if (AmongUsClient.Instance.AmHost)
{
if (ErrorFromRpc)
{
var player = ModdedPlayerId.GetPlayer();

if (GameStates.IsShip || !GameStates.IsLobby || GameStates.IsCoStartGame)
{
if (Options.EndWhenPlayerBug.GetBool())
{
ChatUpdatePatch.DoBlockChat = true;
Main.OverrideWelcomeMsg = string.Format(GetString("RpcAntiBlackOutNotifyInLobby"), player?.Data?.PlayerName, GetString("EndWhenPlayerBug"));

Logger.SendInGame(string.Format(GetString("RpcAntiBlackOutEndGame"), player?.Data?.PlayerName));

if (GameStates.IsInGame && !GameStates.IsCoStartGame)
{
CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Error);
GameManager.Instance.LogicFlow.CheckEndCriteria();
RPC.ForceEndGame(CustomWinner.Error);
}
else
{
_ = new LateTask(() =>
{
CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Error);
GameManager.Instance.LogicFlow.CheckEndCriteria();
RPC.ForceEndGame(CustomWinner.Error);
}, 1.5f, "RPC Anti-Black End Game As Critical Error");
}
}
else
{
Logger.SendInGame(string.Format(GetString("RpcAntiBlackOutIgnored"), player?.Data?.PlayerName));

if (player != null)
{
if (GameStates.IsInGame && !GameStates.IsCoStartGame)
{
AmongUsClient.Instance.KickPlayer(player.GetClientId(), false);
Logger.SendInGame(string.Format(GetString("RpcAntiBlackOutKicked"), player?.Data?.PlayerName));
}
else
{
_ = new LateTask(() =>
{
if (player == null) return;
AmongUsClient.Instance.KickPlayer(player.GetClientId(), false);
Logger.SendInGame(string.Format(GetString("RpcAntiBlackOutKicked"), player?.Data?.PlayerName));
}, 0.5f, "RPC Anti-Black Kicked As Critical Error");
}

ChatUpdatePatch.DoBlockChat = false;
}
}
}
else if (GameStartManager.Instance != null)
{
// We imagine rpc is received when starting game in lobby, not fucked yet
if (AmongUsClient.Instance.AmHost)
{
GameStartManager.Instance.ResetStartState();
if (player != null)
{
AmongUsClient.Instance.KickPlayer(player.GetClientId(), false);
}
}
Logger.SendInGame(string.Format(GetString("RpcAntiBlackOutKicked"), player?.Data?.PlayerName));
}
else
{
Logger.SendInGame("[Critical Error] Your client is in a unknow state while receiving AntiBlackOut rpcs from others");
Logger.Fatal($"Client is in a unknow state while receiving AntiBlackOut rpcs from others", "Anti-black");
}
}
else
{
Logger.SendInGame(GetString("AntiBlackOutLoggerSendInGame"));

if (GameStates.IsShip || !GameStates.IsLobby || GameStates.IsCoStartGame)
{
_ = new LateTask(() =>
{
CustomWinnerHolder.ResetAndSetWinner(CustomWinner.Error);
GameManager.Instance.LogicFlow.CheckEndCriteria();
RPC.ForceEndGame(CustomWinner.Error);
}, 0.5f, "Anti-Black End Game As Critical Error");
}
else if (GameStartManager.Instance != null)
{
GameStartManager.Instance.ResetStartState();
AmongUsClient.Instance.RemoveUnownedObjects();
Logger.SendInGame(GetString("AntiBlackOutLoggerSendInGame"));
}
else
{
Logger.SendInGame("Host in a unknow antiblack bugged state");
Logger.Fatal($"Host in a unknow antiblack bugged state", "Anti-black");
}
}
}
else
{
if (Options.EndWhenPlayerBug.GetBool())
{
Logger.SendInGame(GetString("AntiBlackOutRequestHostToForceEnd"));
}
else
{
Logger.SendInGame(GetString("AntiBlackOutHostRejectForceEnd"));

_ = new LateTask(() =>
{
if (AmongUsClient.Instance.AmConnected)
{
AmongUsClient.Instance.ExitGame(DisconnectReasons.Custom);
Logger.Fatal($"Disconnected from the game due critical error", "Anti-black");
}
}, 1.5f, "Anti-Black Exit Game Due Critical Error");
}
}
IsError = false;
ErrorFromRpc = false;
ModdedPlayerId = byte.MinValue;
}
}
22 changes: 20 additions & 2 deletions Modules/CustomRolesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public static RoleTypes GetDYRole(this CustomRoles role) // Role has a kill butt

public static bool HasImpKillButton(this PlayerControl player, bool considerVanillaShift = false)
{
/*
if (player == null) return false;
var customRole = player.GetCustomRole();
bool ModSideHasKillButton = customRole.GetDYRole() == RoleTypes.Impostor || customRole.GetVNRole() is CustomRoles.Impostor or CustomRoles.Shapeshifter or CustomRoles.Phantom;
Expand All @@ -59,6 +60,14 @@ public static bool HasImpKillButton(this PlayerControl player, bool considerVani
(OriginalRole.GetDYRole() is RoleTypes.Impostor or RoleTypes.Shapeshifter || OriginalRole.GetVNRole() is CustomRoles.Impostor or CustomRoles.Shapeshifter or CustomRoles.Phantom) : ModSideHasKillButton;

return vanillaSideHasKillButton;
*/

// Due to the fact that change role basis is widely used in mod
// this function now always uses current mod role to decide kill button access?

if (player == null) return false;
var customRole = player.GetCustomRole();
return customRole.GetDYRole() == RoleTypes.Impostor || customRole.GetVNRole() is CustomRoles.Impostor or CustomRoles.Shapeshifter or CustomRoles.Phantom;
}
//This is a overall check for vanilla clients to see if they are imp basis
public static bool IsGhostRole(this CustomRoles role)
Expand Down Expand Up @@ -150,6 +159,7 @@ public static bool IsAmneCrew(this PlayerControl target)
return target.IsCrewVenter()
|| target.GetCustomRole() is
CustomRoles.Sheriff or
CustomRoles.ChiefOfPolice or
CustomRoles.LazyGuy or
CustomRoles.SuperStar or
CustomRoles.Celebrity or
Expand Down Expand Up @@ -564,6 +574,8 @@ public static bool CheckAddonConfilct(CustomRoles role, PlayerControl pc, bool c
case CustomRoles.Overclocked:
if (!pc.CanUseKillButton())
return false;
if (pc.Is(CustomRoles.Reverie))
return false;
break;

case CustomRoles.Lazy:
Expand Down Expand Up @@ -790,7 +802,8 @@ public static bool CheckAddonConfilct(CustomRoles role, PlayerControl pc, bool c
case CustomRoles.Rascal:
if (pc.Is(CustomRoles.SuperStar)
|| pc.Is(CustomRoles.NiceMini)
|| pc.Is(CustomRoles.Madmate))
|| pc.Is(CustomRoles.Madmate)
|| pc.Is(CustomRoles.ChiefOfPolice))
return false;
if (!pc.GetCustomRole().IsCrewmate())
return false;
Expand Down Expand Up @@ -1251,8 +1264,10 @@ var r when r.IsNA() => CountTypes.Apocalypse,
CustomRoles.Glitch => CountTypes.Glitch,
CustomRoles.Spiritcaller => CountTypes.Spiritcaller,
CustomRoles.RuthlessRomantic => CountTypes.RuthlessRomantic,
CustomRoles.Shocker => CountTypes.Shocker,
CustomRoles.SchrodingersCat => CountTypes.None,
CustomRoles.Solsticer => CountTypes.None,
CustomRoles.Revenant => CountTypes.None,
_ => role.IsImpostorTeam() ? CountTypes.Impostor : CountTypes.Crew,

// CustomRoles.Phantom => CountTypes.OutOfGame,
Expand Down Expand Up @@ -1316,6 +1331,7 @@ var r when r.IsNA() => CountTypes.Apocalypse,
CustomRoles.RuthlessRomantic => CustomWinner.RuthlessRomantic,
CustomRoles.Mini => CustomWinner.NiceMini,
CustomRoles.Doppelganger => CustomWinner.Doppelganger,
CustomRoles.Shocker => CustomWinner.Shocker,
_ => throw new NotImplementedException()

};
Expand Down Expand Up @@ -1355,6 +1371,7 @@ var r when r.IsNA() => CountTypes.Apocalypse,
CountTypes.Spiritcaller => CustomRoles.Spiritcaller,
CountTypes.Arsonist => CustomRoles.Arsonist,
CountTypes.RuthlessRomantic => CustomRoles.RuthlessRomantic,
CountTypes.Shocker => CustomRoles.Shocker,
_ => throw new NotImplementedException()
};
public static bool HasSubRole(this PlayerControl pc) => Main.PlayerStates[pc.PlayerId].SubRoles.Any();
Expand Down Expand Up @@ -1435,5 +1452,6 @@ public enum CountTypes
Werewolf,
Agitater,
RuthlessRomantic,
Necromancer
Necromancer,
Shocker
}
2 changes: 1 addition & 1 deletion Modules/DelayNetworkedData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private static void DelaySpawnPlayerInfo(InnerNetClient __instance, int clientId

foreach (var player in batch)
{
if (messageWriter.Length > 1600) break;
if (messageWriter.Length > 500) break;
if (player != null && player.ClientId != clientId && !player.Disconnected)
{
__instance.WriteSpawnMessage(player, player.OwnerId, player.SpawnFlags, messageWriter);
Expand Down
4 changes: 2 additions & 2 deletions Modules/EAC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ public static bool RpcReportDeadBodyCheck(PlayerControl player, NetworkedPlayerI
if (!GameStates.IsInGame)
{
WarnHost();
Report(player, "Report body out of game");
HandleCheat(player, "Report body out of game");
Report(player, "Report body out of game C");
HandleCheat(player, "Report body out of game C");
Logger.Fatal($"玩家【{player.GetClientId()}:{player.GetRealName()}】非游戏内开会,已驳回", "EAC");
return true;
}
Expand Down
10 changes: 9 additions & 1 deletion Modules/ExtendedPlayerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static void RpcSetCustomRole(this PlayerControl player, CustomRoles role)
if (role < CustomRoles.NotAssigned)
{
Main.PlayerStates[player.PlayerId].SetMainRole(role);
// player.GetRoleClass()?.OnAdd(player.PlayerId);
// Remember to manually add OnAdd if you are setting role mid game
}
else if (role >= CustomRoles.NotAssigned) //500:NoSubRole 501~:SubRole
{
Expand Down Expand Up @@ -274,7 +276,7 @@ public static void RpcSetPetDesync(this PlayerControl player, string petId, Play
public static void RpcExile(this PlayerControl player)
{
player.Exiled();
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, SendOption.None, -1);
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(player.NetId, (byte)RpcCalls.Exiled, SendOption.Reliable, -1);
AmongUsClient.Instance.FinishRpcImmediately(writer);
}
public static void RpcExileDesync(this PlayerControl player, PlayerControl seer)
Expand Down Expand Up @@ -836,6 +838,12 @@ public static void RpcTeleport(this PlayerControl player, Vector2 position, bool
netTransform.SetDirtyBit(uint.MaxValue);
}

if (!AmongUsClient.Instance.AmHost && !netTransform.AmOwner)
{
Logger.Error($"Canceled RpcTeleport bcz I am not host and not the owner of {player.PlayerId}'s netTransform.", "RpcTeleport");
return;
}

ushort newSid = (ushort)(netTransform.lastSequenceId + 8);
MessageWriter messageWriter = AmongUsClient.Instance.StartRpcImmediately(netTransform.NetId, (byte)RpcCalls.SnapTo, SendOption.Reliable);
NetHelpers.WriteVector2(position, messageWriter);
Expand Down
Loading