Skip to content

Commit

Permalink
1044
Browse files Browse the repository at this point in the history
  • Loading branch information
ZsFabTest committed Aug 17, 2023
1 parent b4b7653 commit 0fd7048
Show file tree
Hide file tree
Showing 18 changed files with 605 additions and 28 deletions.
34 changes: 28 additions & 6 deletions Nebula/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class CustomOptionHolder
"option.display.percentage.andSoForth", "option.display.percentage.10", "option.display.percentage.20", "option.display.percentage.30", "option.display.percentage.40",
"option.display.percentage.50", "option.display.percentage.60", "option.display.percentage.70", "option.display.percentage.80", "option.display.percentage.90" };
public static string[] presets = new string[] { "option.display.preset.1", "option.display.preset.2", "option.display.preset.3", "option.display.preset.4", "option.display.preset.5" };
public static string[] gamemodesNormal = new string[] { "gamemode.standard", "gamemode.freePlay" };
public static string[] gamemodesNormal = new string[] { "gamemode.standard", "gamemode.freePlay", "gamemode.battle" };
public static string[] gamemodesHnS = new string[] { "gamemode.standard", "gamemode.freePlay" };

private static byte ToByte(float f)
Expand Down Expand Up @@ -153,6 +153,7 @@ public static CustomOption GetCurrentGameModeOption()
public static CustomOption showExtraRoles;
public static CustomOption showNumberOfEvilNeutralRoles;
public static CustomOption dontShowImpostorCountIfDidntExile;
public static CustomOption dontShowExtraVotes;

public static CustomOption limiterOptions;
public static CustomOption timeLimitOption;
Expand Down Expand Up @@ -252,6 +253,14 @@ public static CustomOption GetCurrentGameModeOption()
public static CustomOption ValidPerksOption;
public static CustomOption MustDoTasksToWinOption;

public static CustomOption BattleOption;
public static CustomOption BattleKillCooldownOption;
public static CustomOption BattleInitCooldownOption;
public static CustomOption BattleSnipeCoolDownOption;
public static CustomOption BattleShotSizeOption;
public static CustomOption BattleShotEffectiveRangeOption;
public static CustomOption BattleNoticeRangeOption;

public static void AddExclusiveAssignment(ref List<ExclusiveAssignment> exclusiveAssignments)
{
if (!exclusiveAssignmentParent.getBool()) return;
Expand Down Expand Up @@ -342,7 +351,7 @@ public static void Load()
{
CustomOption.optionSaver = new DataSaver("options.dat");

gameModeNormal = CustomOption.Create(Color.white, "option.gameMode", gamemodesNormal, gamemodesNormal[0], null, true, false, "", CustomOptionTab.Settings).SetGameMode(CustomGameMode.All).SetIdentifier("option.gameModeNormal");
gameModeNormal = CustomOption.Create(Color.white, "option.gameMode", gamemodesNormal, gamemodesNormal[0], null, true, false, "", CustomOptionTab.Settings).SetGameMode(CustomGameMode.ActuallyAll).SetIdentifier("option.gameModeNormal");
gameModeHnS = CustomOption.Create(Color.white, "option.gameMode", gamemodesHnS, gamemodesHnS[0], null, true, false, "", CustomOptionTab.Settings).SetGameMode(CustomGameMode.All).SetIdentifier("option.gameModeHnS");


Expand All @@ -359,7 +368,7 @@ public static void Load()
CustomOption.RegisterTopOption(SoloFreePlayOption);
CountOfDummiesOption = CustomOption.Create(Color.white, "option.countOfDummies", 0, 0, 126, 1, SoloFreePlayOption).SetGameMode(CustomGameMode.All);

meetingOptions = CustomOption.Create(Color.white, "option.meetingOptions", false, null, true, false, "", CustomOptionTab.Settings).SetGameMode(~(CustomGameMode.AllHnS));
meetingOptions = CustomOption.Create(Color.white, "option.meetingOptions", false, null, true, false, "", CustomOptionTab.Settings).SetGameMode(CustomGameMode.AllStandard);
CustomOption.RegisterTopOption(meetingOptions);
maxNumberOfMeetings = CustomOption.Create(Color.white, "option.maxNumberOfMeetings", 10, 0, 15, 1, meetingOptions);
deathPenaltyForDiscussionTime = CustomOption.Create(Color.white, "option.deathPenaltyForDiscussionTime", 5f, 0f, 30f, 1f, meetingOptions);
Expand Down Expand Up @@ -425,6 +434,7 @@ public static void Load()
return false;
}
});
dontShowExtraVotes = CustomOption.Create(Color.white, "option.dontShowExtraVotes", false, meetingOptions);

additionalEmergencyCoolDown.alternativeOptionScreenBuilder = (refresher) =>
{
Expand Down Expand Up @@ -571,7 +581,7 @@ MetaScreenContent getSuitableContent()
};
};

limiterOptions = CustomOption.Create(Color.white, "option.limitOptions", false, null, true, false, "", CustomOptionTab.Settings).SetGameMode(~CustomGameMode.AllHnS);
limiterOptions = CustomOption.Create(Color.white, "option.limitOptions", false, null, true, false, "", CustomOptionTab.Settings).SetGameMode(CustomGameMode.AllStandard);
CustomOption.RegisterTopOption(limiterOptions);
timeLimitOption = CustomOption.Create(Color.white, "option.timeLimitOption", 20f, 1f, 80f, 1f, limiterOptions).SetGameMode(CustomGameMode.All);
timeLimitSecondOption = CustomOption.Create(Color.white, "option.timeLimitSecondOption", 0f, 0f, 55f, 5f, limiterOptions).SetGameMode(CustomGameMode.All);
Expand Down Expand Up @@ -649,7 +659,7 @@ MetaScreenContent getSuitableContent()
DangerousDownloadSpotOption = CustomOption.Create(Color.white, "option.dangerousDownloadSpot", false, TasksOption).SetGameMode(CustomGameMode.All);
UseVanillaSafeTaskOption = CustomOption.Create(Color.white, "option.useVanillaSafeTask", true, TasksOption).SetGameMode(CustomGameMode.All);

SabotageOption = CustomOption.Create(Color.white, "option.sabotageOption", false, null, true, false, "", CustomOptionTab.Settings).SetGameMode(~(CustomGameMode.AllHnS));
SabotageOption = CustomOption.Create(Color.white, "option.sabotageOption", false, null, true, false, "", CustomOptionTab.Settings).SetGameMode(CustomGameMode.AllStandard);
CustomOption.RegisterTopOption(SabotageOption);
SabotageCoolDownOption = CustomOption.Create(Color.white, "option.sabotageCoolDown", 30f, 5f, 60f, 5f, SabotageOption).SetGameMode(CustomGameMode.All);
SabotageCoolDownOption.suffix = "second";
Expand Down Expand Up @@ -750,7 +760,7 @@ MetaScreenContent[][] AddKillCoolDownProceedIgnoringOptions(Action refresher,par
);


streamersOption = CustomOption.Create(Color.white, "option.streamersOption", false, null, true, false, "", CustomOptionTab.Settings).SetGameMode(~CustomGameMode.AllHnS);
streamersOption = CustomOption.Create(Color.white, "option.streamersOption", false, null, true, false, "", CustomOptionTab.Settings).SetGameMode(CustomGameMode.AllStandard);
CustomOption.RegisterTopOption(streamersOption);
enforcePreventingSpoilerOption = CustomOption.Create(Color.white, "option.streamersOption.enforcePreventingSpoiler", false, streamersOption).SetGameMode(CustomGameMode.All);

Expand Down Expand Up @@ -799,5 +809,17 @@ MetaScreenContent[][] AddKillCoolDownProceedIgnoringOptions(Action refresher,par
}
}
Map.MapData.CreateOptionData();

BattleOption = CustomOption.Create(Color.white, "option.battleOption", new string[] { "option.empty" }, "option.empty", null, true, false, "", CustomOptionTab.Settings).SetGameMode(CustomGameMode.Battle);
CustomOption.RegisterTopOption(BattleOption);
BattleInitCooldownOption = CustomOption.Create(Color.white, "option.battleOption.initCooldownOption", 15f,1f,40f,1f,BattleOption,false,false,"", CustomOptionTab.Settings).SetGameMode(CustomGameMode.ActuallyAll);
BattleSnipeCoolDownOption = CustomOption.Create(Color.white, "option.battleOption.snipeCoolDown", 20f, 5f, 60f, 2.5f,BattleOption,false,false,"",CustomOptionTab.Settings).SetGameMode(CustomGameMode.ActuallyAll);
BattleSnipeCoolDownOption.suffix = "second";
BattleShotSizeOption = CustomOption.Create(Color.white, "option.battleOption.shotSizeOption",1f, 0.5f, 4f, 0.25f,BattleOption,false,false,"",CustomOptionTab.Settings).SetGameMode(CustomGameMode.ActuallyAll);
BattleShotSizeOption.suffix = "cross";
BattleShotEffectiveRangeOption = CustomOption.Create(Color.white, "option.battleOption.shotEffectiveRangeOption", 20f, 2f, 40f, 2f,BattleOption,false,false,"",CustomOptionTab.Settings).SetGameMode(CustomGameMode.ActuallyAll);
BattleShotEffectiveRangeOption.suffix = "cross";
BattleNoticeRangeOption = CustomOption.Create(Color.white, "option.battleOption.noticeRangeOption", 20f, 2f, 50f, 2f,BattleOption,false,false,"",CustomOptionTab.Settings).SetGameMode(CustomGameMode.ActuallyAll);
BattleNoticeRangeOption.suffix = "cross";
}
}
4 changes: 4 additions & 0 deletions Nebula/Game/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ public class TaskData
public int AllTasks { get; set; }
//ノルマタスク数
public int Quota { get; set; }
//真实的任务数量
public int ActualTasks { get; set; }
//完了タスク数
public int Completed { get; set; }
//クルーメイトのタスク勝利に反映させるかどうか
Expand All @@ -485,6 +487,7 @@ public TaskData(int DisplayTasks, int AllTasks, int Quota, bool IsCrewmateTask,
this.Quota = Quota;
this.IsInfluencedCrewmatesTasks = IsCrewmateTask;
this.IsInfiniteCrewmateTasks = IsInfiniteQuota;
this.ActualTasks = 0;
}

public TaskData(bool hasFakeTask, bool fakeTaskIsExecutable)
Expand All @@ -494,6 +497,7 @@ public TaskData(bool hasFakeTask, bool fakeTaskIsExecutable)
{
var gameOption = GameOptionsManager.Instance.CurrentGameOptions;
tasks = gameOption.GetInt(Int32OptionNames.NumCommonTasks) + gameOption.GetInt(Int32OptionNames.NumLongTasks) + gameOption.GetInt(Int32OptionNames.NumShortTasks);
ActualTasks = tasks;
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions Nebula/Game/GameModeProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public GameModeProperty(Module.CustomGameMode RelatedMode, int MinPlayers, bool
static public GameModeProperty FreePlayMode;
static public GameModeProperty StandardHnSMode;
static public GameModeProperty FreePlayHnSMode;
static public GameModeProperty BattleMode;

static public void Load()
{
Expand All @@ -64,6 +65,7 @@ static public void Load()
Module.CustomOptionTab.Settings | Module.CustomOptionTab.CrewmateRoles | Module.CustomOptionTab.ImpostorRoles | Module.CustomOptionTab.AdvancedSettings);
FreePlayHnSMode = new GameModeProperty(Module.CustomGameMode.FreePlayHnS, new IntRange(0, 1), false, false, false, null, Roles.Roles.HnSCrewmate, Roles.Roles.HnSReaper,
Module.CustomOptionTab.Settings | Module.CustomOptionTab.AdvancedSettings);
BattleMode = new GameModeProperty(Module.CustomGameMode.Battle,2,false,false,false,null,Roles.Roles.Crewmate,Roles.Roles.Impostor,Module.CustomOptionTab.Settings);
}

static public GameModeProperty GetProperty(Module.CustomGameMode gameMode)
Expand Down
17 changes: 10 additions & 7 deletions Nebula/Module/CustomOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ namespace Nebula.Module;
[Flags]
public enum CustomGameMode
{
Standard = 0x0001,
FreePlay = 0x0002,
StandardHnS = 0x0010,
FreePlayHnS = 0x0020,
All = int.MaxValue,
AllHnS = 0x0030
Standard = 1,
FreePlay = 2,
StandardHnS = 4,
FreePlayHnS = 8,
All = 15,
AllHnS = 12,
AllStandard = 3,
Battle = 16,
ActuallyAll = 31,

}

Expand All @@ -40,7 +43,7 @@ public static class CustomGameModes
{
static public List<CustomGameMode> AllGameModes = new List<CustomGameMode>()
{
CustomGameMode.Standard,CustomGameMode.FreePlay,CustomGameMode.Standard,CustomGameMode.Standard,
CustomGameMode.Standard,CustomGameMode.FreePlay,CustomGameMode.Battle,CustomGameMode.Standard,
CustomGameMode.Standard,CustomGameMode.Standard,CustomGameMode.Standard,CustomGameMode.Standard,
CustomGameMode.StandardHnS,CustomGameMode.FreePlayHnS
};
Expand Down
6 changes: 3 additions & 3 deletions Nebula/Nebula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ public class NebulaPlugin : BasePlugin
public const string AmongUsVersion = "2023.3.28";
public const string PluginGuid = "cn.zsfabtest.amongus.nebular";
public const string PluginName = "TheNebula-R-LTS";
public const string PluginVersion = "1.0.4.3";
public const string PluginVersion = "1.0.4.4";
public const bool IsSnapshot = true;

public static string PluginVisualVersion = (IsSnapshot ? "23.08.17-" : "") + PluginVersion;
public static string PluginStage = IsSnapshot ? "Snapshot" : "";

public const string PluginVersionForFetch = "1.0.4.3";
public byte[] PluginVersionData = new byte[] { 1, 0, 4, 3 };
public const string PluginVersionForFetch = "1.0.4.4";
public byte[] PluginVersionData = new byte[] { 1, 0, 4, 4 };

public static NebulaPlugin Instance;

Expand Down
12 changes: 10 additions & 2 deletions Nebula/Patches/EndGamePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public class EndCondition
public static EndCondition OracleWin = new EndCondition(136,Roles.NeutralRoles.Oracle.RoleColor,"oracle",1,Module.CustomGameMode.Standard);
public static EndCondition GhostWin = new EndCondition(137,new(1f,1f,1f),"ghost",1,Module.CustomGameMode.Standard);
public static EndCondition PuppeteerWin = new EndCondition(138,Roles.NeutralRoles.Puppeteer.RoleColor,"puppeteer",1,Module.CustomGameMode.Standard);

public static EndCondition YellowTeamWin = new EndCondition(139,Roles.BattleRoles.YellowTeam.RoleColor,"yellowTeam",1,Module.CustomGameMode.Battle);
public static EndCondition GreenTeamWin = new EndCondition(140,Roles.BattleRoles.GreenTeam.RoleColor,"greenTeam",1,Module.CustomGameMode.Battle);

public static HashSet<EndCondition> AllEnds = new HashSet<EndCondition>() {
CrewmateWinByVote ,CrewmateWinByTask,CrewmateWinDisconnect,
Expand All @@ -56,7 +57,7 @@ public class EndCondition
JesterWin,JackalWin,ArsonistWin,EmpiricWin,PaparazzoWin,VultureWin,SpectreWin,SantaWin,
LoversWin,TrilemmaWin,AvengerWin,
NoGame,NobodyWin,NobodySkeldWin,NobodyMiraWin,NobodyPolusWin,NobodyAirshipWin,
PavlovWin,MoriartyWin,MoriartyWinByKillHolmes,CascrubinterWin,GuesserWin,YandereWin,WerewolfWin,ChallengerWin,OracleWin,GhostWin,PuppeteerWin
PavlovWin,MoriartyWin,MoriartyWinByKillHolmes,CascrubinterWin,GuesserWin,YandereWin,WerewolfWin,ChallengerWin,OracleWin,GhostWin,PuppeteerWin,YellowTeamWin,GreenTeamWin
};

public static EndCondition GetEndCondition(GameOverReason gameOverReason)
Expand Down Expand Up @@ -745,6 +746,9 @@ public class PlayerStatistics

public int AliveZombieSidekick;

public int AliveYellowTeam;
public int AliveGreenTeam;

public bool IsValid;

//
Expand Down Expand Up @@ -814,6 +818,8 @@ public PlayerStatistics(ShipStatus __instance)
AliveZombieSidekick = 0;
AlivePuppeteer = 0;

AliveYellowTeam = 0;
AliveGreenTeam = 0;

Roles.Side side;

Expand Down Expand Up @@ -1085,6 +1091,8 @@ public PlayerStatistics(ShipStatus __instance)
AliveWerewolf = GetAlivePlayers(Roles.Side.Werewolf);
AliveChallenger = GetAlivePlayers(Roles.Side.Challenger);
AliveOracle = GetAlivePlayers(Roles.Side.Oracle);
AliveYellowTeam = GetAlivePlayers(Roles.Side.YellowTeam);
AliveGreenTeam = GetAlivePlayers(Roles.Side.GreenTeam);

if (!Roles.Roles.Lover.loversAsIndependentSideOption.getBool())
{
Expand Down
2 changes: 1 addition & 1 deletion Nebula/Patches/GameStartManagerPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static void Postfix(GameStartManager __instance)
if (AmongUsClient.Instance.AmHost)
{

int minPlayers= Game.GameModeProperty.GetProperty(CustomOptionHolder.GetCustomGameMode()).MinPlayers;
int minPlayers = Game.GameModeProperty.GetProperty(CustomOptionHolder.GetCustomGameMode()).MinPlayers;
int maxPlayers = Game.GameModeProperty.GetProperty(CustomOptionHolder.GetCustomGameMode()).MaxPlayers ?? 15;
__instance.MinPlayers = minPlayers;

Expand Down
12 changes: 7 additions & 5 deletions Nebula/Patches/MeetingPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using Nebula.Module;
using UnityEngine;

namespace Nebula.Patches;

Expand Down Expand Up @@ -448,8 +449,8 @@ static bool Prefix(MeetingHud __instance, Il2CppStructArray<MeetingHud.VoterStat
else if (Roles.ComplexRoles.SwapSystem.isSwapped && playerVoteArea.TargetPlayerId == swapped2.TargetPlayerId) playerVoteArea = swapped1;
playerVoteArea.ClearForResults();
int num2 = 0;
//bool mayorFirstVoteDisplayed = false;
Dictionary<int, int> votesApplied = new();
//bool mayorFirstVoteDisplayed = !CustomOptionHolder.dontShowExtraVotes.getBool();
Dictionary<int, float> votesApplied = new();
for (int j = 0; j < states.Length; j++)
{
MeetingHud.VoterState voterState = states[j];
Expand All @@ -466,14 +467,15 @@ static bool Prefix(MeetingHud __instance, Il2CppStructArray<MeetingHud.VoterStat
__instance.BloopAVoteIcon(playerById, num, __instance.SkippedVoting.transform);
num++;
}
else if (voterState.VotedForId == targetPlayerId && !playerById.IsDead)
else if (voterState.VotedForId == targetPlayerId && !playerById.IsDead && (!votesApplied.ContainsKey(voter.PlayerId) || !CustomOptionHolder.dontShowExtraVotes.getBool()))
{
__instance.BloopAVoteIcon(playerById, num2, playerVoteArea.transform);
num2++;
}

if (!votesApplied.ContainsKey(voter.PlayerId))
if (!votesApplied.ContainsKey(voter.PlayerId)){
votesApplied[voter.PlayerId] = 0;
}

votesApplied[voter.PlayerId]++;
}
Expand Down
17 changes: 17 additions & 0 deletions Nebula/Patches/RoleAssignmentPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,23 @@ private static void assignRoles(AssignMap assignMap)
crewmates.RemoveAll((p) => p.PlayerId == PlayerControl.LocalPlayer.PlayerId);
}

if (CustomOptionHolder.GetCustomGameMode() == Module.CustomGameMode.Battle){
var allPlayers = new List<byte>();
foreach (var player in PlayerControl.AllPlayerControls.GetFastEnumerator())
{
allPlayers.Add(player.PlayerId);
}

var array = Helpers.GetRandomArray(allPlayers.Count);

for(int tmp = 0;tmp < allPlayers.Count;tmp++){
if(array[tmp] % 2 == 0) assignMap.AssignRole(allPlayers[tmp],Roles.Roles.YellowTeam.id);
else assignMap.AssignRole(allPlayers[tmp],Roles.Roles.GreenTeam.id);
}

return;
}

if (property.RequireImpostors)
{
//メタ的にインポスターを要求する場合
Expand Down
Loading

0 comments on commit 0fd7048

Please sign in to comment.