Skip to content

Commit

Permalink
Merge pull request #664 from tukasa0001/develop
Browse files Browse the repository at this point in the history
mainにマージ
  • Loading branch information
tanakanira0118 authored Jun 9, 2022
2 parents 30f249c + 8deb772 commit 9b4924d
Show file tree
Hide file tree
Showing 18 changed files with 965 additions and 898 deletions.
16 changes: 8 additions & 8 deletions Modules/ExtendedPlayerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public static void CustomSyncSettings(this PlayerControl player)
opt.RoleOptions.ShapeshifterLeaveSkin = false;
break;
case CustomRoles.Warlock:
if (!Main.isCursed) opt.RoleOptions.ShapeshifterCooldown = Options.BHDefaultKillCooldown.GetFloat();
if (!Main.isCursed) opt.RoleOptions.ShapeshifterCooldown = Main.RealOptionsData.killCooldown; //Options.BHDefaultKillCooldown.GetFloat();
if (Main.isCursed) opt.RoleOptions.ShapeshifterCooldown = 1f;
break;
case CustomRoles.SerialKiller:
Expand All @@ -305,8 +305,8 @@ public static void CustomSyncSettings(this PlayerControl player)
case CustomRoles.Lighter:
if (player.GetPlayerTaskState().IsTaskFinished)
opt.CrewLightMod = Options.LighterTaskCompletedVision.GetFloat();
if (Utils.IsActive(SystemTypes.Electrical) && Options.LighterTaskCompletedDisableLightOut.GetBool())
opt.CrewLightMod *= 5;
if (Utils.IsActive(SystemTypes.Electrical) && Options.LighterTaskCompletedDisableLightOut.GetBool())
opt.CrewLightMod *= 5;
break;
case CustomRoles.EgoSchrodingerCat:
opt.SetVision(player, true);
Expand Down Expand Up @@ -358,7 +358,7 @@ public static void CustomSyncSettings(this PlayerControl player)
if (Utils.IsActive(SystemTypes.Electrical))//もし停電発生した場合
{
Main.AllPlayerSpeed[player.PlayerId] = Options.BlackOutMareSpeed.GetFloat();//Mareの速度を設定した値にする
Main.AllPlayerKillCooldown[player.PlayerId] = Options.BHDefaultKillCooldown.GetFloat() / 2;//Mareのキルクールを÷2する
Main.AllPlayerKillCooldown[player.PlayerId] = Main.RealOptionsData.killCooldown / 2; //Options.BHDefaultKillCooldown.GetFloat() / 2;//Mareのキルクールを÷2する
}
break;

Expand Down Expand Up @@ -401,8 +401,8 @@ public static void CustomSyncSettings(this PlayerControl player)
opt.EmergencyCooldown = 3600;
if (Options.CurrentGameMode == CustomGameMode.HideAndSeek && Options.HideAndSeekKillDelayTimer > 0)
opt.ImpostorLightMod = 0f;
opt.DiscussionTime = Main.DiscussionTime;
opt.VotingTime = Main.VotingTime;
opt.DiscussionTime = Mathf.Clamp(Main.DiscussionTime, 0, 300);
opt.VotingTime = Mathf.Clamp(Main.VotingTime, Options.TimeThiefLowerLimitVotingTime.GetInt(), 300);

if (player.AmOwner) PlayerControl.GameOptions = opt;
MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)RpcCalls.SyncSettings, SendOption.Reliable, clientId);
Expand Down Expand Up @@ -622,7 +622,7 @@ public static void ExiledSchrodingerCatTeamChange(this PlayerControl player)
}
public static void ResetKillCooldown(this PlayerControl player)
{
Main.AllPlayerKillCooldown[player.PlayerId] = Options.BHDefaultKillCooldown.GetFloat(); //キルクールをデフォルトキルクールに変更
Main.AllPlayerKillCooldown[player.PlayerId] = Main.RealOptionsData.killCooldown; //Options.BHDefaultKillCooldown.GetFloat(); //キルクールをデフォルトキルクールに変更
switch (player.GetCustomRole())
{
case CustomRoles.SerialKiller:
Expand Down Expand Up @@ -673,7 +673,7 @@ public static bool IsDouseDone(this PlayerControl player)
public static void ResetThiefVotingTime(this PlayerControl thief)
{
for (var i = 0; i < Main.TimeThiefKillCount[thief.PlayerId]; i++)
Main.VotingTime += Options.TimeThiefDecreaseVotingTime.GetInt();
Main.VotingTime += Options.TimeThiefDecreaseMeetingTime.GetInt();
Main.TimeThiefKillCount[thief.PlayerId] = 0; //初期化
}
public static void RemoveDousePlayer(this PlayerControl target) //死亡時、切断時に呼ばれる
Expand Down
22 changes: 11 additions & 11 deletions Modules/OptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public static CustomGameMode CurrentGameMode
public static CustomOption BountyTargetChangeTime;
public static CustomOption BountySuccessKillCooldown;
public static CustomOption BountyFailureKillCooldown;
public static CustomOption BHDefaultKillCooldown;
//public static CustomOption BHDefaultKillCooldown;
public static CustomOption SerialKillerCooldown;
public static CustomOption SerialKillerLimit;
public static CustomOption TimeThiefDecreaseDiscussionTime;
public static CustomOption TimeThiefDecreaseVotingTime;
public static CustomOption TimeThiefDecreaseMeetingTime;
public static CustomOption TimeThiefLowerLimitVotingTime;
public static CustomOption VampireKillDelay;
public static CustomOption BlackOutMareSpeed;
public static CustomOption ShapeMasterShapeshiftDuration;
Expand Down Expand Up @@ -250,12 +250,12 @@ public static void Load()
CustomRoleSpawnChances = new Dictionary<CustomRoles, CustomOption>();
// Impostor
SetupRoleOptions(1000, CustomRoles.BountyHunter);
BountyTargetChangeTime = CustomOption.Create(1010, Color.white, "BountyTargetChangeTime", 10, 5, 1000, 5, CustomRoleSpawnChances[CustomRoles.BountyHunter]);
BountySuccessKillCooldown = CustomOption.Create(1011, Color.white, "BountySuccessKillCooldown", 5, 5, 999, 1, CustomRoleSpawnChances[CustomRoles.BountyHunter]);
BountyFailureKillCooldown = CustomOption.Create(1012, Color.white, "BountyFailureKillCooldown", 50, 5, 999, 5, CustomRoleSpawnChances[CustomRoles.BountyHunter]);
BountyTargetChangeTime = CustomOption.Create(1010, Color.white, "BountyTargetChangeTime", 60f, 10f, 900f, 2.5f, CustomRoleSpawnChances[CustomRoles.BountyHunter]);
BountySuccessKillCooldown = CustomOption.Create(1011, Color.white, "BountySuccessKillCooldown", 2.5f, 0f, 180f, 2.5f, CustomRoleSpawnChances[CustomRoles.BountyHunter]);
BountyFailureKillCooldown = CustomOption.Create(1012, Color.white, "BountyFailureKillCooldown", 50f, 0f, 180f, 2.5f, CustomRoleSpawnChances[CustomRoles.BountyHunter]);
SetupRoleOptions(1100, CustomRoles.SerialKiller);
SerialKillerCooldown = CustomOption.Create(1110, Color.white, "SerialKillerCooldown", 20, 1, 1000, 1, CustomRoleSpawnChances[CustomRoles.SerialKiller]);
SerialKillerLimit = CustomOption.Create(1111, Color.white, "SerialKillerLimit", 60, 5, 1000, 5, CustomRoleSpawnChances[CustomRoles.SerialKiller]);
SerialKillerCooldown = CustomOption.Create(1110, Color.white, "SerialKillerCooldown", 20f, 1f, 180f, 2.5f, CustomRoleSpawnChances[CustomRoles.SerialKiller]);
SerialKillerLimit = CustomOption.Create(1111, Color.white, "SerialKillerLimit", 60f, 5f, 900f, 5f, CustomRoleSpawnChances[CustomRoles.SerialKiller]);
SetupRoleOptions(1200, CustomRoles.ShapeMaster);
ShapeMasterShapeshiftDuration = CustomOption.Create(1210, Color.white, "ShapeMasterShapeshiftDuration", 10, 1, 1000, 1, CustomRoleSpawnChances[CustomRoles.ShapeMaster]);
SetupRoleOptions(1300, CustomRoles.Vampire);
Expand All @@ -269,10 +269,10 @@ public static void Load()
SetupRoleOptions(2300, CustomRoles.Mare);
BlackOutMareSpeed = CustomOption.Create(2310, Color.white, "BlackOutMareSpeed", 2f, 0.25f, 3f, 0.25f, CustomRoleSpawnChances[CustomRoles.Mare]);
SetupRoleOptions(2400, CustomRoles.TimeThief);
TimeThiefDecreaseDiscussionTime = CustomOption.Create(2410, Color.white, "TimeThiefDecreaseDiscussionTime", 1, 0, 100, 1, CustomRoleSpawnChances[CustomRoles.TimeThief]);
TimeThiefDecreaseVotingTime = CustomOption.Create(2411, Color.white, "TimeThiefDecreaseVotingTime", 1, 0, 100, 1, CustomRoleSpawnChances[CustomRoles.TimeThief]);
TimeThiefDecreaseMeetingTime = CustomOption.Create(2410, Color.white, "TimeThiefDecreaseMeetingTime", 20, 0, 100, 1, CustomRoleSpawnChances[CustomRoles.TimeThief]);
TimeThiefLowerLimitVotingTime = CustomOption.Create(2411, Color.white, "TimeThiefLowerLimitVotingTime", 10, 1, 300, 1, CustomRoleSpawnChances[CustomRoles.TimeThief]);

BHDefaultKillCooldown = CustomOption.Create(5010, Color.white, "BHDefaultKillCooldown", 30, 1, 999, 1, null, true);
//BHDefaultKillCooldown = CustomOption.Create(5010, Color.white, "BHDefaultKillCooldown", 30, 1, 999, 1, null, true);
DefaultShapeshiftCooldown = CustomOption.Create(5011, Color.white, "DefaultShapeshiftCooldown", 15, 5, 999, 5, null, true);
CanMakeMadmateCount = CustomOption.Create(5012, Color.white, "CanMakeMadmateCount", 0, 0, 15, 1, null, true);

Expand Down
5 changes: 5 additions & 0 deletions Modules/RPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public static bool Prefix(PlayerControl __instance, [HarmonyArgument(0)] byte ca
Logger.Info("名前変更:" + __instance.GetNameWithRole() + " => " + name, "SetName");
if (subReader.BytesRemaining > 0 && subReader.ReadBoolean()) return false;
break;
case RpcCalls.SendChat:
var text = subReader.ReadString();
Logger.Info($"{__instance.GetNameWithRole()}:{text}", "SendChat");
ChatCommands.OnReceiveChat(__instance, text);
break;
case RpcCalls.StartMeeting:
var p = Utils.GetPlayerById(subReader.ReadByte());
Logger.Info($"{__instance.GetNameWithRole()} => {p?.GetNameWithRole() ?? "null"}", "StartMeeting");
Expand Down
42 changes: 20 additions & 22 deletions Modules/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public static bool HasTasks(GameData.PlayerInfo p, bool ForRecompute = true)
}
public static string GetProgressText(PlayerControl pc)
{
if (!Main.playerVersion.ContainsKey(0)) return ""; //ホストがMODを入れていなければ未記入を返す
var taskState = pc.GetPlayerTaskState();
var Comms = false;
if (taskState.hasTasks)
Expand All @@ -197,16 +198,19 @@ public static string GetProgressText(PlayerControl pc)
}
public static string GetProgressText(byte playerId, bool comms = false)
{
if (!Main.AllPlayerCustomRoles.TryGetValue(playerId, out var role)) return "Invalid";
if (!Main.playerVersion.ContainsKey(0)) return ""; //ホストがMODを入れていなければ未記入を返す
string colorCode = "<color=#ffff00>";
string closeCode = "</color>";
if (!Main.AllPlayerCustomRoles.TryGetValue(playerId, out var role)) return $" {colorCode}Invalid{closeCode}";
string ProgressText = "";
switch (role)
{
case CustomRoles.Arsonist:
ProgressText = Main.DousedPlayerCount.TryGetValue(playerId, out var doused) ?
$"<color={GetRoleColorCode(CustomRoles.Arsonist)}>({doused.Item1}/{doused.Item2})</color>" : "Invalid";
$"<color={GetRoleColorCode(CustomRoles.Arsonist)}>({doused.Item1}/{doused.Item2}){closeCode}" : " Invalid"; //アーソニストの場合はもともと色付けをしていないため、色付けをしない
break;
case CustomRoles.Sheriff:
ProgressText += Main.SheriffShotLimit.TryGetValue(playerId, out var shotLimit) ? $" <color=#ffff00>({shotLimit})</color>" : "Invalid";
ProgressText += colorCode + (Main.SheriffShotLimit.TryGetValue(playerId, out var shotLimit) ? $"({shotLimit})" : "Invalid") + closeCode;
break;
case CustomRoles.Sniper:
ProgressText += $" {Sniper.GetBulletCount(playerId)}";
Expand All @@ -217,14 +221,14 @@ public static string GetProgressText(byte playerId, bool comms = false)
if (taskState.hasTasks)
{
string Completed = comms ? "?" : $"{taskState.CompletedTasksCount}";
ProgressText = $"<color=#ffff00>({Completed}/{taskState.AllTasksCount})</color>";
ProgressText = $"{colorCode}({Completed}/{taskState.AllTasksCount}){closeCode}";
}
break;
}

return ProgressText;
}
public static void ShowActiveRoles()
public static void ShowActiveSettingsHelp()
{
SendMessage(GetString("CurrentActiveSettingsHelp") + ":");
if (Options.CurrentGameMode == CustomGameMode.HideAndSeek)
Expand All @@ -247,14 +251,14 @@ public static void ShowActiveRoles()
}
if (Options.NoGameEnd.GetBool()) { SendMessage(GetString("NoGameEndInfo")); }
}
public static void ShowActiveSettings()
public static void ShowActiveSettings(byte PlayerId = byte.MaxValue)
{
var text = GetString("Roles") + ":";
if (Options.CurrentGameMode == CustomGameMode.HideAndSeek)
{
if (CustomRoles.HASFox.IsEnable()) text += String.Format("\n{0}:{1}", GetRoleName(CustomRoles.HASFox), CustomRoles.HASFox.GetCount());
if (CustomRoles.HASTroll.IsEnable()) text += String.Format("\n{0}:{1}", GetRoleName(CustomRoles.HASTroll), CustomRoles.HASTroll.GetCount());
SendMessage(text);
SendMessage(text, PlayerId);
text = GetString("Settings") + ":";
text += GetString("HideAndSeek");
}
Expand All @@ -265,13 +269,13 @@ public static void ShowActiveSettings()
if (role is CustomRoles.HASFox or CustomRoles.HASTroll) continue;
if (role.IsEnable()) text += String.Format("\n{0}:{1}", GetRoleName(role), role.GetCount());
}
SendMessage(text);
SendMessage(text, PlayerId);
text = GetString("Attributes") + ":";
if (Options.EnableLastImpostor.GetBool())
{
text += String.Format("\n{0}:{1}", GetString("LastImpostor"), Options.EnableLastImpostor.GetString());
}
SendMessage(text);
SendMessage(text, PlayerId);
text = GetString("Settings") + ":";
foreach (var role in Options.CustomRoleCounts)
{
Expand Down Expand Up @@ -313,13 +317,13 @@ public static void ShowActiveSettings()
}
if (Options.StandardHAS.GetBool()) text += String.Format("\n{0}:{1}", GetString("StandardHAS"), GetOnOff(Options.StandardHAS.GetBool()));
if (Options.NoGameEnd.GetBool()) text += String.Format("\n{0}:{1}", GetString("NoGameEnd"), GetOnOff(Options.NoGameEnd.GetBool()));
SendMessage(text);
SendMessage(text, PlayerId);
}
public static void ShowLastRoles()
public static void ShowLastResult(byte PlayerId = byte.MaxValue)
{
if (AmongUsClient.Instance.IsGameStarted)
{
SendMessage(GetString("CantUse/lastroles"));
SendMessage(GetString("CantUse/lastroles"), PlayerId);
return;
}
var text = GetString("LastResult") + ":";
Expand All @@ -336,7 +340,7 @@ public static void ShowLastRoles()
text += $"\n  {Main.AllPlayerNames[id]}:{GetRoleName(Main.AllPlayerCustomRoles[id])}{GetShowLastSubRolesText(id)}";
text += $" {GetVitalText(id)}";
}
SendMessage(text);
SendMessage(text, PlayerId);
}

public static string GetShowLastSubRolesText(byte id)
Expand Down Expand Up @@ -380,7 +384,7 @@ public static void CheckTerroristWin(GameData.PlayerInfo Terrorist)
else if (!pc.Data.IsDead)
{
//生存者は爆死
pc.MurderPlayer(pc);
pc.RpcMurderPlayer(pc);
PlayerState.SetDeathReason(pc.PlayerId, PlayerState.DeathReason.Bombed);
PlayerState.SetDead(pc.PlayerId);
}
Expand Down Expand Up @@ -715,20 +719,14 @@ public static void AfterMeetingTasks()
{
if (pc.Is(CustomRoles.SerialKiller))
{
pc.RpcGuardAndKill(pc);
pc.RpcResetAbilityCooldown();
Main.SerialKillerTimer.Add(pc.PlayerId, 0f);
}
if (pc.Is(CustomRoles.BountyHunter))
{
pc.RpcGuardAndKill(pc);
pc.RpcResetAbilityCooldown();
Main.BountyTimer.Add(pc.PlayerId, 0f);
}
if (PlayerControl.GameOptions.MapId != 4)//Airship以外
if (pc.Is(CustomRoles.SerialKiller) || pc.Is(CustomRoles.BountyHunter))
{
//main.AirshipMeetingTimer.Add(pc.PlayerId, 0f);
Main.AllPlayerKillCooldown[pc.PlayerId] *= 2; //GuardAndKillを実行する関係でキルクールを2倍に
}
}
}

Expand Down
Loading

0 comments on commit 9b4924d

Please sign in to comment.