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

Neutral Apocalypse #637

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
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 Modules/AntiBlackout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static class AntiBlackout
///<summary>
/// Check num alive Impostors & Crewmates & NeutralKillers
///</summary>

public static bool BlackOutIsActive => !Options.DisableAntiBlackoutProtects.GetBool() && CheckBlackOut();

///<summary>
Expand Down
37 changes: 36 additions & 1 deletion Modules/CustomRoleSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static void SelectCustomRoles()
int optImpNum = Main.RealOptionsData.GetInt(Int32OptionNames.NumImpostors);
int optNonNeutralKillingNum = 0;
int optNeutralKillingNum = 0;
int optNeutralApocalypseNum = 0;

if (Options.NonNeutralKillingRolesMaxPlayer.GetInt() > 0 && Options.NonNeutralKillingRolesMaxPlayer.GetInt() >= Options.NonNeutralKillingRolesMinPlayer.GetInt())
{
Expand All @@ -31,10 +32,15 @@ public static void SelectCustomRoles()
{
optNeutralKillingNum = rd.Next(Options.NeutralKillingRolesMinPlayer.GetInt(), Options.NeutralKillingRolesMaxPlayer.GetInt() + 1);
}
if (Options.NeutralApocalypseRolesMaxPlayer.GetInt() > 0 && Options.NeutralApocalypseRolesMaxPlayer.GetInt() >= Options.NeutralApocalypseRolesMinPlayer.GetInt())
{
optNeutralApocalypseNum = rd.Next(Options.NeutralApocalypseRolesMinPlayer.GetInt(), Options.NeutralApocalypseRolesMaxPlayer.GetInt() + 1);
}

int readyRoleNum = 0;
int readyNonNeutralKillingNum = 0;
int readyNeutralKillingNum = 0;
int readyNeutralApocalypseNum = 0;

List<CustomRoles> rolesToAssign = [];
List<CustomRoles> roleList = [];
Expand All @@ -51,6 +57,9 @@ public static void SelectCustomRoles()
List<CustomRoles> NeutralKillingOnList = [];
List<CustomRoles> NeutralKillingRateList = [];

List<CustomRoles> NeutralApocalypseOnList = [];
List<CustomRoles> NeutralApocalypseRateList = [];

List<CustomRoles> roleRateList = [];

if (Options.CurrentGameMode == CustomGameMode.FFA)
Expand Down Expand Up @@ -125,6 +134,7 @@ public static void SelectCustomRoles()
else if (role.IsMini()) MiniRateList.Add(role);
else if (role.IsNonNK()) NonNeutralKillingRateList.Add(role);
else if (role.IsNK()) NeutralKillingRateList.Add(role);
else if (role.IsNA()) NeutralApocalypseRateList.Add(role);
else roleRateList.Add(role);
}
}
Expand Down Expand Up @@ -241,7 +251,32 @@ public static void SelectCustomRoles()
if (readyNeutralKillingNum >= optNeutralKillingNum) break;
}
}

// Select NeutralApocalypse "Always"
while (NeutralApocalypseOnList.Count > 0 && optNeutralApocalypseNum > 0)
{
var select = NeutralApocalypseOnList[rd.Next(0, NeutralApocalypseOnList.Count)];
NeutralApocalypseOnList.Remove(select);
rolesToAssign.Add(select);
readyRoleNum++;
readyNeutralApocalypseNum += select.GetCount();
Logger.Info(select.ToString() + " Add to NeutralApocalypse waiting list (priority)", "CustomRoleSelector");
if (readyRoleNum >= playerCount) goto EndOfAssign;
if (readyNeutralApocalypseNum >= optNeutralApocalypseNum) break;
}
if (readyRoleNum < playerCount && readyNeutralApocalypseNum < optNeutralApocalypseNum)
{
while (NeutralApocalypseRateList.Count > 0 && optNeutralApocalypseNum > 0)
{
var select = NeutralApocalypseRateList[rd.Next(0, NeutralApocalypseRateList.Count)];
NeutralApocalypseRateList.Remove(select);
rolesToAssign.Add(select);
readyRoleNum++;
readyNeutralApocalypseNum += select.GetCount();
Logger.Info(select.ToString() + " Add to NeutralApocalypse waiting list", "CustomRoleSelector");
if (readyRoleNum >= playerCount) goto EndOfAssign;
if (readyNeutralApocalypseNum >= optNeutralApocalypseNum) break;
}
}
// Select Crewmates "Always"
while (roleOnList.Count > 0)
{
Expand Down
63 changes: 44 additions & 19 deletions Modules/CustomRolesHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ static class CustomRolesHelper
CustomRoles.Dictator => CustomRoles.Crewmate,
CustomRoles.Inhibitor => CustomRoles.Impostor,
CustomRoles.Saboteur => CustomRoles.Impostor,
CustomRoles.Berserker => CustomRoles.Impostor,
CustomRoles.Doctor => CustomRoles.Scientist,
CustomRoles.ScientistTOHE => CustomRoles.Scientist,
CustomRoles.Tracefinder => CustomRoles.Scientist,
Expand Down Expand Up @@ -266,6 +265,9 @@ public static RoleTypes GetDYRole(this CustomRoles role) // Role has a kill butt
CustomRoles.Spiritcaller => RoleTypes.Impostor,
CustomRoles.ChiefOfPolice => RoleTypes.Impostor,
CustomRoles.Quizmaster => RoleTypes.Impostor,
CustomRoles.Baker => RoleTypes.Impostor,
CustomRoles.Berserker => RoleTypes.Impostor,
CustomRoles.War => RoleTypes.Impostor,
_ => RoleTypes.GuardianAngel
};
}
Expand Down Expand Up @@ -412,6 +414,8 @@ CustomRoles.Imitator or
CustomRoles.Bandit or
CustomRoles.Pestilence or
CustomRoles.PlagueBearer or
CustomRoles.Baker or
CustomRoles.Famine or
CustomRoles.Agitater or
CustomRoles.Innocent or
CustomRoles.Vulture or
Expand All @@ -434,6 +438,7 @@ CustomRoles.DarkHide or
// CustomRoles.PotionMaster or
CustomRoles.Doomsayer or
CustomRoles.SoulCollector or
CustomRoles.Death or
CustomRoles.Pirate or
CustomRoles.Seeker or
CustomRoles.Pixie or
Expand All @@ -442,6 +447,8 @@ CustomRoles.RuthlessRomantic or
CustomRoles.VengefulRomantic or
CustomRoles.Doppelganger or
CustomRoles.SchrodingersCat or
CustomRoles.Berserker or
CustomRoles.War or
// CustomRoles.Juggernaut or
// CustomRoles.Jinx or
// CustomRoles.Poisoner or
Expand Down Expand Up @@ -509,10 +516,8 @@ CustomRoles.Shroud or
CustomRoles.Virus or
CustomRoles.BloodKnight or
CustomRoles.Spiritcaller or
CustomRoles.PlagueBearer or
CustomRoles.Agitater or
CustomRoles.RuthlessRomantic or
CustomRoles.Pestilence;
CustomRoles.RuthlessRomantic;
}
public static bool IsNonNK(this CustomRoles role) // ROLE ASSIGNING, NOT NEUTRAL TYPE
{
Expand All @@ -529,7 +534,6 @@ CustomRoles.Maverick or
CustomRoles.Opportunist or
CustomRoles.Pursuer or
CustomRoles.Shaman or
CustomRoles.SoulCollector or
CustomRoles.CursedSoul or
CustomRoles.Doomsayer or
CustomRoles.Executioner or
Expand Down Expand Up @@ -594,7 +598,6 @@ CustomRoles.Collector or
CustomRoles.Succubus or
CustomRoles.Phantom or
CustomRoles.Mario or
CustomRoles.SoulCollector or
CustomRoles.Pirate or
CustomRoles.Terrorist or
CustomRoles.Vulture or
Expand All @@ -603,6 +606,19 @@ CustomRoles.Solsticer or
CustomRoles.Revolutionist or
CustomRoles.Provocateur;
}
public static bool IsNA(this CustomRoles role)
{
return role is
CustomRoles.PlagueBearer or
CustomRoles.Pestilence or
CustomRoles.SoulCollector or
CustomRoles.Death or
CustomRoles.Baker or
CustomRoles.Famine or
CustomRoles.Berserker or
CustomRoles.War;

}
public static bool IsSnitchTarget(this CustomRoles role)
{
if (role is CustomRoles.Arsonist && Options.ArsonistCanIgniteAnytime.GetBool()) return true;
Expand Down Expand Up @@ -638,7 +654,6 @@ CustomRoles.Virus or
CustomRoles.Succubus or
CustomRoles.BloodKnight or
CustomRoles.Spiritcaller or
CustomRoles.PlagueBearer or
CustomRoles.Agitater or
CustomRoles.RuthlessRomantic or
CustomRoles.Shroud or
Expand Down Expand Up @@ -688,7 +703,6 @@ CustomRoles.Warlock or
CustomRoles.Undertaker or
CustomRoles.RiftMaker or
CustomRoles.Assassin or
CustomRoles.Berserker or
CustomRoles.Anonymous or
CustomRoles.Visionary or
CustomRoles.Miner or
Expand Down Expand Up @@ -767,6 +781,7 @@ CustomRoles.Crewpostor or
CustomRoles.Shroud or
CustomRoles.Wraith or
CustomRoles.SoulCollector or
CustomRoles.Death or
CustomRoles.Vulture or
CustomRoles.Taskinator or
CustomRoles.Convict or
Expand All @@ -790,6 +805,8 @@ CustomRoles.Pursuer or
CustomRoles.Agitater or
CustomRoles.PlagueBearer or
CustomRoles.Pestilence or
CustomRoles.Baker or
CustomRoles.Famine or
CustomRoles.Pirate or
CustomRoles.Seeker or
CustomRoles.Pixie or
Expand Down Expand Up @@ -826,6 +843,8 @@ CustomRoles.Succubus or
CustomRoles.Doomsayer or
CustomRoles.Spiritcaller or
CustomRoles.SchrodingersCat or
CustomRoles.Berserker or
CustomRoles.War or
CustomRoles.Quizmaster;
}
/* public static bool IsCoven(this CustomRoles role)
Expand Down Expand Up @@ -878,7 +897,6 @@ CustomRoles.DarkHide or
CustomRoles.Necromancer or
CustomRoles.Pirate or
CustomRoles.Provocateur or
CustomRoles.SoulCollector or
CustomRoles.Wraith or
CustomRoles.Juggernaut or
CustomRoles.Pelican or
Expand Down Expand Up @@ -966,6 +984,8 @@ CustomRoles.VengefulRomantic or
CustomRoles.Pixie or
CustomRoles.Seeker or
CustomRoles.SchrodingersCat or
CustomRoles.Berserker or
CustomRoles.War or
CustomRoles.Quizmaster;
}
public static bool IsMadmate(this CustomRoles role)
Expand All @@ -987,6 +1007,7 @@ CustomRoles.Pursuer or
CustomRoles.Imitator or
CustomRoles.Agitater or
CustomRoles.PlagueBearer or
CustomRoles.Baker or
CustomRoles.Pirate or
CustomRoles.Hater or
CustomRoles.Totocalcio or
Expand Down Expand Up @@ -1503,7 +1524,6 @@ public static bool CheckAddonConfilct(CustomRoles role, PlayerControl pc, bool c
break;
case CustomRoles.Mare:
if (pc.Is(CustomRoles.Underdog)
|| pc.Is(CustomRoles.Berserker)
|| pc.Is(CustomRoles.Inhibitor)
|| pc.Is(CustomRoles.Saboteur)
|| pc.Is(CustomRoles.Swift)
Expand Down Expand Up @@ -1893,8 +1913,14 @@ public static CountTypes GetCountTypes(this CustomRoles role)
CustomRoles.Shroud => CountTypes.Shroud,
CustomRoles.Werewolf => CountTypes.Werewolf,
CustomRoles.Wraith => CountTypes.Wraith,
CustomRoles.Pestilence => CountTypes.Pestilence,
CustomRoles.PlagueBearer => CountTypes.PlagueBearer,
CustomRoles.Pestilence => CountTypes.Apocalypse,
CustomRoles.PlagueBearer => CountTypes.Apocalypse,
CustomRoles.SoulCollector => CountTypes.Apocalypse,
CustomRoles.Death => CountTypes.Apocalypse,
CustomRoles.Baker => CountTypes.Apocalypse,
CustomRoles.Famine => CountTypes.Apocalypse,
CustomRoles.Berserker => CountTypes.Apocalypse,
CustomRoles.War => CountTypes.Apocalypse,
CustomRoles.Agitater => CountTypes.Agitater,
CustomRoles.Parasite => CountTypes.Impostor,
CustomRoles.SerialKiller => CountTypes.SerialKiller,
Expand Down Expand Up @@ -1970,16 +1996,17 @@ public static CountTypes GetCountTypes(this CustomRoles role)
CustomRoles.Pickpocket => CustomWinner.Pickpocket,
CustomRoles.Traitor => CustomWinner.Traitor,
CustomRoles.Vulture => CustomWinner.Vulture,
CustomRoles.Pestilence => CustomWinner.Pestilence,
CustomRoles.Apocalypse => CustomWinner.Apocalypse,
CustomRoles.Medusa => CustomWinner.Medusa,
CustomRoles.Spiritcaller => CustomWinner.Spiritcaller,
CustomRoles.Glitch => CustomWinner.Glitch,
CustomRoles.PlagueBearer => CustomWinner.Plaguebearer,
//CustomRoles.PlagueBearer => CustomWinner.Apocalypse,
CustomRoles.Masochist => CustomWinner.Masochist,
CustomRoles.Doomsayer => CustomWinner.Doomsayer,
CustomRoles.Shroud => CustomWinner.Shroud,
CustomRoles.Seeker => CustomWinner.Seeker,
CustomRoles.SoulCollector => CustomWinner.SoulCollector,
//CustomRoles.SoulCollector => CustomWinner.Apocalypse,
//CustomRoles.Death => CustomWinner.Apocalypse,
CustomRoles.RuthlessRomantic => CustomWinner.RuthlessRomantic,
CustomRoles.Mini => CustomWinner.NiceMini,
CustomRoles.Doppelganger => CustomWinner.Doppelganger,
Expand All @@ -2004,8 +2031,6 @@ public static CountTypes GetCountTypes(this CustomRoles role)
CountTypes.Shroud => CustomRoles.Shroud,
CountTypes.Werewolf => CustomRoles.Werewolf,
CountTypes.Wraith => CustomRoles.Wraith,
CountTypes.Pestilence => CustomRoles.Pestilence,
CountTypes.PlagueBearer => CustomRoles.PlagueBearer,
CountTypes.Agitater => CustomRoles.Agitater,
CountTypes.SerialKiller => CustomRoles.SerialKiller,
CountTypes.Quizmaster => CustomRoles.Quizmaster,
Expand All @@ -2027,6 +2052,7 @@ public static CountTypes GetCountTypes(this CustomRoles role)
CountTypes.Spiritcaller => CustomRoles.Spiritcaller,
CountTypes.Arsonist => CustomRoles.Arsonist,
CountTypes.RuthlessRomantic => CustomRoles.RuthlessRomantic,
CountTypes.Apocalypse => CustomRoles.Apocalypse,
//CountTypes.Impostor => CustomRoles.ImpostorTOHE,
//CountTypes.Crew => CustomRoles.CrewmateTOHE,
//CountTypes.None => throw new System.NotImplementedException(),
Expand Down Expand Up @@ -2073,9 +2099,8 @@ public enum CountTypes
Traitor,
Medusa,
Spiritcaller,
Pestilence,
Apocalypse,
Quizmaster,
PlagueBearer,
Glitch,
Arsonist,
Huntsman,
Expand Down
10 changes: 9 additions & 1 deletion Modules/ExtendedPlayerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@ public static bool CanUseKillButton(this PlayerControl pc)
CustomRoles.Spiritcaller => pc.IsAlive(),
CustomRoles.PlagueBearer => pc.IsAlive(),
CustomRoles.Pestilence => pc.IsAlive(),
CustomRoles.Baker => pc.IsAlive(),
CustomRoles.Berserker => pc.IsAlive(),
CustomRoles.War => pc.IsAlive(),
CustomRoles.Pirate => pc.IsAlive(),
CustomRoles.Pixie => pc.IsAlive(),
CustomRoles.Seeker => pc.IsAlive(),
Expand Down Expand Up @@ -652,6 +655,7 @@ CustomRoles.ChiefOfPolice or
// CustomRoles.Chameleon => true,
CustomRoles.Parasite => true,
CustomRoles.Refugee => true,
CustomRoles.Berserker or CustomRoles.War => true,
CustomRoles.Spiritcaller => Spiritcaller.CanVent.GetBool(),
CustomRoles.Quizmaster => Quizmaster.CanUseVentButton(pc),

Expand Down Expand Up @@ -764,6 +768,9 @@ public static void ResetKillCooldown(this PlayerControl player)
case CustomRoles.Berserker:
Main.AllPlayerKillCooldown[player.PlayerId] = Options.BerserkerKillCooldown.GetFloat();
break;
case CustomRoles.War:
Main.AllPlayerKillCooldown[player.PlayerId] = Options.WarKillCooldown.GetFloat();
break;
case CustomRoles.Kamikaze:
Kamikaze.SetKillCooldown(player.PlayerId);
break;
Expand Down Expand Up @@ -1320,6 +1327,7 @@ public static List<PlayerControl> GetPlayersInAbilityRangeSorted(this PlayerCont
public static bool IsNeutralBenign(this PlayerControl player) => player.GetCustomRole().IsNB();
public static bool IsNeutralEvil(this PlayerControl player) => player.GetCustomRole().IsNE();
public static bool IsNeutralChaos(this PlayerControl player) => player.GetCustomRole().IsNC();
public static bool IsNeutralApocalypse(this PlayerControl player) => player.GetCustomRole().IsNA();
public static bool IsNonNeutralKiller(this PlayerControl player) => player.GetCustomRole().IsNonNK();
public static bool IsSnitchTarget(this PlayerControl player) => player.GetCustomRole().IsSnitchTarget();

Expand Down Expand Up @@ -1375,7 +1383,7 @@ public static bool KnowRoleTarget(PlayerControl seer, PlayerControl target)
(target.Is(CustomRoles.President) && seer.Is(CustomRoles.Madmate) && President.MadmatesSeePresident.GetBool() && President.CheckPresidentReveal[target.PlayerId] == true) ||
(target.Is(CustomRoles.President) && seer.GetCustomRole().IsNeutral() && President.NeutralsSeePresident.GetBool() && President.CheckPresidentReveal[target.PlayerId] == true) ||
(target.Is(CustomRoles.President) && (seer.GetCustomRole().IsImpostorTeam()) && President.ImpsSeePresident.GetBool() && President.CheckPresidentReveal[target.PlayerId] == true)) return true;

else if (target.IsNeutralApocalypse() && seer.IsNeutralApocalypse()) return true;

else return false;
}
Expand Down
3 changes: 3 additions & 0 deletions Modules/GameOptionsSender/PlayerGameOptionsSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ public override IGameOptions BuildGameOptions()
case CustomRoles.Pestilence:
opt.SetVision(PlagueBearer.PestilenceHasImpostorVision.GetBool());
break;
case CustomRoles.Berserker or CustomRoles.War:
opt.SetVision(Options.BerserkerHasImpostorVision.GetBool());
break;
case CustomRoles.Pelican:
Pelican.ApplyGameOptions(opt);
break;
Expand Down
2 changes: 2 additions & 0 deletions Modules/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ public enum DeathReason
Targeted,
Retribution,
WrongAnswer,
Armageddon,
Starved,

//Please add all new roles with deathreason & new deathreason in Susceptible.CallEnabledAndChange
etc = -1,
Expand Down
3 changes: 3 additions & 0 deletions Modules/NameColorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ private static bool KnowTargetRoleColor(PlayerControl seer, PlayerControl target
// PlagueDoctor
if (seer.Is(CustomRoles.PlagueDoctor) && target.Is(CustomRoles.PlagueDoctor)) color = Main.roleColors[CustomRoles.PlagueDoctor];

// Apocalypse
if (seer.IsNeutralApocalypse() && target.IsNeutralApocalypse()) color = Main.roleColors[CustomRoles.Apocalypse];

if (color != "") return true;
else return seer == target
|| (Main.GodMode.Value && seer.AmOwner)
Expand Down
Loading