Skip to content

Commit

Permalink
Merge pull request EnhancedNetwork#1245 from MargaretTheFool/coven
Browse files Browse the repository at this point in the history
Coven (New Faction... again....)
  • Loading branch information
NikoCat233 authored Jan 6, 2025
2 parents fe828c5 + 503d7e5 commit 0381fba
Show file tree
Hide file tree
Showing 104 changed files with 8,138 additions and 4,553 deletions.
23 changes: 19 additions & 4 deletions Modules/AntiBlackout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace TOHE;
public static class AntiBlackout
{
///<summary>
/// Check num alive Impostors & Crewmates & NeutralKillers
/// Check num alive Impostors & Crewmates & NeutralKillers & Coven
///</summary>
public static bool BlackOutIsActive => false; /*!Options.DisableAntiBlackoutProtects.GetBool() && CheckBlackOut();*/

Expand All @@ -26,6 +26,7 @@ public static bool CheckBlackOut()
HashSet<byte> Impostors = [];
HashSet<byte> Crewmates = [];
HashSet<byte> NeutralKillers = [];
HashSet<byte> Coven = [];

var lastExiled = ExileControllerWrapUpPatch.AntiBlackout_LastExiled;
foreach (var pc in Main.AllAlivePlayerControls)
Expand All @@ -34,24 +35,30 @@ public static bool CheckBlackOut()
if (lastExiled != null && pc.PlayerId == lastExiled.PlayerId) continue;

// Impostors
if (pc.Is(Custom_Team.Impostor))
if (pc.Is(Custom_Team.Impostor) && !Main.PlayerStates[pc.PlayerId].IsNecromancer)
Impostors.Add(pc.PlayerId);

// Only Neutral killers
else if (pc.IsNeutralKiller() || pc.IsNeutralApocalypse())
else if ((pc.IsNeutralKiller() || pc.IsNeutralApocalypse()) && !Main.PlayerStates[pc.PlayerId].IsNecromancer)
NeutralKillers.Add(pc.PlayerId);

//Coven
if (pc.Is(Custom_Team.Coven) || Main.PlayerStates[pc.PlayerId].IsNecromancer)
Coven.Add(pc.PlayerId);

// Crewmate
else Crewmates.Add(pc.PlayerId);
}

var numAliveImpostors = Impostors.Count;
var numAliveCrewmates = Crewmates.Count;
var numAliveNeutralKillers = NeutralKillers.Count;
var numAliveCoven = Coven.Count;

Logger.Info($" {numAliveImpostors}", "AntiBlackout Num Alive Impostors");
Logger.Info($" {numAliveCrewmates}", "AntiBlackout Num Alive Crewmates");
Logger.Info($" {numAliveNeutralKillers}", "AntiBlackout Num Alive Neutral Killers");
Logger.Info($" {numAliveCoven}", "AntiBlackout Num Alive Coven");

var BlackOutIsActive = false;

Expand All @@ -61,12 +68,20 @@ public static bool CheckBlackOut()

// Alive Impostors > or = others team count
if (!BlackOutIsActive)
BlackOutIsActive = (numAliveNeutralKillers + numAliveCrewmates) <= numAliveImpostors;
BlackOutIsActive = (numAliveNeutralKillers + numAliveCrewmates + numAliveCoven) <= numAliveImpostors;

// One Impostor and one Neutral Killer is alive, and living Crewmates very few
if (!BlackOutIsActive)
BlackOutIsActive = numAliveNeutralKillers == 1 && numAliveImpostors == 1 && numAliveCrewmates <= 2;

// One Neutral Killer and one Coven is alive, and living Crewmates very few
if (!BlackOutIsActive)
BlackOutIsActive = numAliveNeutralKillers == 1 && numAliveCoven == 1 && numAliveCrewmates <= 2;

// One Coven and one Impostor is alive, and living Crewmates very few
if (!BlackOutIsActive)
BlackOutIsActive = numAliveCoven == 1 && numAliveImpostors == 1 && numAliveCrewmates <= 2;

Logger.Info($" {BlackOutIsActive}", "BlackOut Is Active");
return BlackOutIsActive;
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static void SendMessage(PlayerControl player, string message)

if (GameStates.IsInGame) operate = 3;
if (CheckCommond(ref msg, "id|guesslist|gl编号|玩家编号|玩家id|id列表|玩家列表|列表|所有id|全部id|編號|玩家編號")) operate = 1;
else if (CheckCommond(ref msg, "shoot|guess|bet|st|gs|bt|猜|赌|賭|sp|jj|tl|trial|审判|判|审|審判|審|compare|cmp|比较|比較|duel|sw|swap|st|换票|换|換票|換|finish|结束|结束会议|結束|結束會議|reveal|展示", false)) operate = 2;
else if (CheckCommond(ref msg, "shoot|guess|bet|st|gs|bt|猜|赌|賭|sp|jj|tl|trial|审判|判|审|審判|審|compare|cmp|比较|比較|duel|sw|swap|st|换票|换|換票|換|finish|结束|结束会议|結束|結束會議|reveal|展示|rt|rit|ritual|bloodritual", false)) operate = 2;
else if (ChatSentBySystem.Contains(GetTextHash(msg))) operate = 5;

if ((operate == 1 || Blackmailer.CheckBlackmaile(player)) && player.IsAlive())
Expand Down Expand Up @@ -280,4 +280,4 @@ public static void SendPreviousMessagesToAll()
}
}
}
}
}
91 changes: 47 additions & 44 deletions Modules/CustomRolesHelper.cs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Modules/CustomWinnerHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public static bool CheckForConvertedWinner(byte playerId)
case CustomRoles.Contagious:
ResetAndSetWinner(CustomWinner.Virus);
return true;
case CustomRoles.Enchanted:
ResetAndSetWinner(CustomWinner.Coven);
return true;
}
}
return false;
Expand Down
2 changes: 2 additions & 0 deletions Modules/DisableDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static void FixedUpdate()
bool ignore = (Options.DisableDevicesIgnoreImpostors.GetBool() && pc.Is(Custom_Team.Impostor)) ||
(Options.DisableDevicesIgnoreNeutrals.GetBool() && pc.Is(Custom_Team.Neutral)) ||
(Options.DisableDevicesIgnoreCrewmates.GetBool() && pc.Is(Custom_Team.Crewmate)) ||
(Options.DisableDevicesIgnoreCoven.GetBool() && pc.Is(Custom_Team.Coven)) ||
(Options.DisableDevicesIgnoreAfterAnyoneDied.GetBool() && GameStates.AlreadyDied);

var mapId = Utils.GetActiveMapId();
Expand Down Expand Up @@ -157,6 +158,7 @@ public static void UpdateDisableDevices()
(Options.DisableDevicesIgnoreImpostors.GetBool() && player.Is(Custom_Team.Impostor)) ||
(Options.DisableDevicesIgnoreNeutrals.GetBool() && player.Is(Custom_Team.Neutral)) ||
(Options.DisableDevicesIgnoreCrewmates.GetBool() && player.Is(Custom_Team.Crewmate)) ||
(Options.DisableDevicesIgnoreCoven.GetBool() && player.Is(Custom_Team.Coven)) ||
(Options.DisableDevicesIgnoreAfterAnyoneDied.GetBool() && GameStates.AlreadyDied);

var admins = UnityEngine.Object.FindObjectsOfType<MapConsole>(true);
Expand Down
30 changes: 22 additions & 8 deletions Modules/ExtendedPlayerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using TOHE.Roles.AddOns.Common;
using TOHE.Roles.AddOns.Impostor;
using TOHE.Roles.Core;
using TOHE.Roles.Coven;
using TOHE.Roles.Crewmate;
using TOHE.Roles.Impostor;
using TOHE.Roles.Neutral;
Expand Down Expand Up @@ -1172,7 +1173,8 @@ public static bool IsNonCrewSheriff(this PlayerControl sheriff)
|| sheriff.Is(CustomRoles.Charmed)
|| sheriff.Is(CustomRoles.Infected)
|| sheriff.Is(CustomRoles.Contagious)
|| sheriff.Is(CustomRoles.Egoist);
|| sheriff.Is(CustomRoles.Egoist)
|| sheriff.Is(CustomRoles.Enchanted);
}
public static bool ShouldBeDisplayed(this CustomRoles subRole)
{
Expand All @@ -1185,6 +1187,7 @@ CustomRoles.Admired and not
CustomRoles.Soulless and not
CustomRoles.Lovers and not
CustomRoles.Infected and not
CustomRoles.Enchanted and not
CustomRoles.Contagious;
}

Expand Down Expand Up @@ -1258,9 +1261,11 @@ public static List<PlayerControl> GetPlayersInAbilityRangeSorted(this PlayerCont
public static bool IsTransformedNeutralApocalypse(this PlayerControl player) => player.GetCustomRole().IsTNA();
public static bool IsNonNeutralKiller(this PlayerControl player) => player.GetCustomRole().IsNonNK();

public static bool IsPlayerCoven(this PlayerControl player) => player.GetCustomRole().IsCoven();
public static bool IsMurderedThisRound(this PlayerControl player) => player.PlayerId.IsMurderedThisRound();
public static bool IsMurderedThisRound(this byte playerId) => Main.MurderedThisRound.Contains(playerId);


public static bool KnowDeathReason(this PlayerControl seer, PlayerControl target)
=> (Options.EveryoneCanSeeDeathReason.GetBool()
|| seer.Is(CustomRoles.Doctor) || seer.Is(CustomRoles.Autopsy)
Expand All @@ -1284,12 +1289,15 @@ public static bool KnowRoleTarget(PlayerControl seer, PlayerControl target)
else if (Altruist.HasEnabled && seer.IsMurderedThisRound()) return false;
else if (seer.GetCustomRole() == target.GetCustomRole() && seer.GetCustomRole().IsNK()) return true;
else if (Options.LoverKnowRoles.GetBool() && seer.Is(CustomRoles.Lovers) && target.Is(CustomRoles.Lovers)) return true;
else if (Options.ImpsCanSeeEachOthersRoles.GetBool() && seer.Is(Custom_Team.Impostor) && target.Is(Custom_Team.Impostor)) return true;
else if (Madmate.MadmateKnowWhosImp.GetBool() && seer.Is(CustomRoles.Madmate) && target.Is(Custom_Team.Impostor)) return true;
else if (Madmate.ImpKnowWhosMadmate.GetBool() && target.Is(CustomRoles.Madmate) && seer.Is(Custom_Team.Impostor)) return true;
else if (seer.Is(Custom_Team.Impostor) && target.GetCustomRole().IsGhostRole() && target.GetCustomRole().IsImpostor()) return true;
else if (target.GetRoleClass().KnowRoleTarget(seer, target)) return true;
else if (seer.GetRoleClass().KnowRoleTarget(seer, target)) return true;
else if (Options.ImpsCanSeeEachOthersRoles.GetBool() && seer.Is(Custom_Team.Impostor) && target.Is(Custom_Team.Impostor) && !Main.PlayerStates[seer.PlayerId].IsNecromancer && !Main.PlayerStates[target.PlayerId].IsNecromancer) return true;
else if (Madmate.MadmateKnowWhosImp.GetBool() && seer.Is(CustomRoles.Madmate) && target.Is(Custom_Team.Impostor) && !Main.PlayerStates[seer.PlayerId].IsNecromancer && !Main.PlayerStates[target.PlayerId].IsNecromancer) return true;
else if (Madmate.ImpKnowWhosMadmate.GetBool() && target.Is(CustomRoles.Madmate) && seer.Is(Custom_Team.Impostor) && !Main.PlayerStates[seer.PlayerId].IsNecromancer && !Main.PlayerStates[target.PlayerId].IsNecromancer) return true;
else if (seer.Is(Custom_Team.Impostor) && target.GetCustomRole().IsGhostRole() && target.GetCustomRole().IsImpostor() && !Main.PlayerStates[seer.PlayerId].IsNecromancer && !Main.PlayerStates[target.PlayerId].IsNecromancer) return true;
else if (Ritualist.EnchantedKnowsCoven.GetBool() && seer.Is(CustomRoles.Enchanted) && target.Is(Custom_Team.Coven)) return true;
else if (target.Is(CustomRoles.Enchanted) && seer.Is(Custom_Team.Coven)) return true;
else if (target.Is(Custom_Team.Coven) && seer.Is(Custom_Team.Coven)) return true;
else if (target.GetRoleClass().KnowRoleTarget(seer, target) && !Main.PlayerStates[seer.PlayerId].IsNecromancer && !Main.PlayerStates[target.PlayerId].IsNecromancer) return true;
else if (seer.GetRoleClass().KnowRoleTarget(seer, target) && !Main.PlayerStates[seer.PlayerId].IsNecromancer && !Main.PlayerStates[target.PlayerId].IsNecromancer) return true;
else if (Solsticer.OtherKnowSolsticer(target)) return true;
else if (Overseer.IsRevealedPlayer(seer, target) && !target.Is(CustomRoles.Trickster)) return true;
else if (Gravestone.EveryoneKnowRole(target)) return true;
Expand Down Expand Up @@ -1321,6 +1329,7 @@ public static bool ShowSubRoleTarget(this PlayerControl seer, PlayerControl targ
if (seer.PlayerId == target.PlayerId) return true;
else if (seer.Is(CustomRoles.GM) || target.Is(CustomRoles.GM) || seer.Is(CustomRoles.God) || (seer.IsHost() && Main.GodMode.Value)) return true;
else if (Options.ImpsCanSeeEachOthersAddOns.GetBool() && seer.Is(Custom_Team.Impostor) && target.Is(Custom_Team.Impostor) && !subRole.IsBetrayalAddon()) return true;
else if (Options.CovenCanSeeEachOthersAddOns.GetBool() && seer.Is(Custom_Team.Coven) && target.Is(Custom_Team.Coven) && !subRole.IsBetrayalAddon()) return true;
else if (Options.ApocCanSeeEachOthersAddOns.GetBool() && seer.IsNeutralApocalypse() && target.IsNeutralApocalypse() && !subRole.IsBetrayalAddon()) return true;

else if ((subRole is CustomRoles.Madmate
Expand All @@ -1330,7 +1339,8 @@ or CustomRoles.Admired
or CustomRoles.Charmed
or CustomRoles.Infected
or CustomRoles.Contagious
or CustomRoles.Egoist)
or CustomRoles.Egoist
or CustomRoles.Enchanted)
&& KnowSubRoleTarget(seer, target))
return true;
else if (Main.VisibleTasksCount && !seer.IsAlive())
Expand Down Expand Up @@ -1361,6 +1371,10 @@ public static bool KnowSubRoleTarget(PlayerControl seer, PlayerControl target)
else if (seer.Is(CustomRoles.Egoist) && target.Is(CustomRoles.Egoist) && Egoist.ImpEgoistVisibalToAllies.GetBool())
return true;
}
if (seer.Is(Custom_Team.Coven))
{
if (target.Is(CustomRoles.Enchanted) && Ritualist.EnchantedKnowsCoven.GetBool()) return true;
}
else if (Admirer.HasEnabled && Admirer.CheckKnowRoleTarget(seer, target)) return true;
else if (Cultist.HasEnabled && Cultist.KnowRole(seer, target)) return true;
else if (Infectious.HasEnabled && Infectious.KnowRole(seer, target)) return true;
Expand Down
19 changes: 19 additions & 0 deletions Modules/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class PlayerState(byte playerId)
#pragma warning restore IDE1006
public TaskState taskState = new();
public bool IsBlackOut { get; set; } = false;
public bool IsNecromancer { get; set; } = false;
public (DateTime, byte) RealKiller = (DateTime.MinValue, byte.MaxValue);
public List<(DateTime, CustomRoles)> MainRoleLogs = [];
public PlainShipRoom LastRoom = null;
Expand All @@ -44,6 +45,11 @@ public void SetMainRole(CustomRoles role)
var pc = PlayerId.GetPlayer();
if (pc == null) return;

if (pc.Is(CustomRoles.Necromancer))
{
IsNecromancer = true;
}

// check for role addon
if (pc.Is(CustomRoles.Madmate))
{
Expand Down Expand Up @@ -97,6 +103,14 @@ public void SetMainRole(CustomRoles role)
{
countTypes = CountTypes.OutOfGame;
}
if (pc.Is(CustomRoles.Enchanted))
{
countTypes = CountTypes.Coven;
}
if (Main.PlayerStates[pc.PlayerId].IsNecromancer)
{
countTypes = CountTypes.Coven;
}

MainRoleLogs.Add((DateTime.Now, role));

Expand Down Expand Up @@ -222,6 +236,10 @@ public void SetSubRole(CustomRoles role, PlayerControl pc = null)
case CustomRoles.Soulless:
countTypes = CountTypes.OutOfGame;
break;

case CustomRoles.Enchanted:
countTypes = CountTypes.Coven;
break;
}
}
public void RemoveSubRole(CustomRoles addOn)
Expand Down Expand Up @@ -321,6 +339,7 @@ public enum DeathReason
Sacrificed,
Electrocuted,
Scavenged,
BlastedOff,

//Please add all new roles with deathreason & new deathreason in Utils.DeathReasonIsEnable();
etc = -1,
Expand Down
Loading

0 comments on commit 0381fba

Please sign in to comment.