Percentage Based Role Spawns, Fix Mod Updater, Remove Unnecessary Strings

This commit is contained in:
Gurge44 committed 2023-12-23 20:12:35 +01:00
1 parent efc9d10cb3
commit 667e44c2f3
9 files changed
+103 -71

No files matched your search

+38 -11
View File
@@ -1,4 +1,5 @@
using AmongUs.GameOptions;
using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -107,7 +108,7 @@ internal class CustomRoleSelector
for (int i2 = 0; i2 < roleList.Count; i2++)
{
CustomRoles role = roleList[i2];
if (role.GetMode() == 2)
if (role.GetMode() == 100)
{
if (role.IsImpostor()) ImpOnList.Add(role);
else if (role.IsNonNK()) NonNeutralKillingOnList.Add(role);
@@ -123,16 +124,42 @@ internal class CustomRoleSelector
else if (role.IsNK() && !NeutralKillingOnList.Contains(role)) NeutralKillingOnList.Add(role);
else if (!roleOnList.Contains(role)) roleOnList.Add(role);
}
// Career settings are: enabled
// Career settings are: enabled (percentage is 1-99%)
for (int i3 = 0; i3 < roleList.Count; i3++)
{
CustomRoles role = roleList[i3];
if (role.GetMode() == 1)
int chance = role.GetMode();
if (chance is < 100 and > 0)
{
if (role.IsImpostor()) ImpRateList.Add(role);
else if (role.IsNonNK()) NonNeutralKillingRateList.Add(role);
else if (role.IsNK()) NeutralKillingRateList.Add(role);
else roleRateList.Add(role);
chance /= 5;
if (role.IsImpostor())
{
for (int i = 0; i < chance; i++)
{
ImpRateList.Add(role);
}
}
else if (role.IsNonNK())
{
for (int i = 0; i < chance; i++)
{
NonNeutralKillingRateList.Add(role);
}
}
else if (role.IsNK())
{
for (int i = 0; i < chance; i++)
{
NeutralKillingRateList.Add(role);
}
}
else
{
for (int i = 0; i < chance; i++)
{
roleRateList.Add(role);
}
}
}
}
@@ -153,7 +180,7 @@ internal class CustomRoleSelector
while (ImpRateList.Count > 0)
{
var select = ImpRateList[rd.Next(0, ImpRateList.Count)];
ImpRateList.Remove(select);
while (ImpRateList.Contains(select)) ImpRateList.Remove(select);
rolesToAssign.Add(select);
readyRoleNum++;
Logger.Info(select.ToString() + " added to the impostor role waiting list", "CustomRoleSelector");
@@ -181,7 +208,7 @@ internal class CustomRoleSelector
while (NonNeutralKillingRateList.Count > 0 && optNonNeutralKillingNum > 0)
{
var select = NonNeutralKillingRateList[rd.Next(0, NonNeutralKillingRateList.Count)];
NonNeutralKillingRateList.Remove(select);
while (NonNeutralKillingRateList.Contains(select)) NonNeutralKillingRateList.Remove(select);
rolesToAssign.Add(select);
readyRoleNum++;
readyNonNeutralKillingNum += select.GetCount();
@@ -210,7 +237,7 @@ internal class CustomRoleSelector
while (NeutralKillingRateList.Count > 0 && optNeutralKillingNum > 0)
{
var select = NeutralKillingRateList[rd.Next(0, NeutralKillingRateList.Count)];
NeutralKillingRateList.Remove(select);
while (NeutralKillingRateList.Contains(select)) NeutralKillingRateList.Remove(select);
rolesToAssign.Add(select);
readyRoleNum++;
readyNeutralKillingNum += select.GetCount();
@@ -236,7 +263,7 @@ internal class CustomRoleSelector
while (roleRateList.Count > 0)
{
var select = roleRateList[rd.Next(0, roleRateList.Count)];
roleRateList.Remove(select);
while (roleRateList.Contains(select)) roleRateList.Remove(select);
rolesToAssign.Add(select);
readyRoleNum++;
Logger.Info(select.ToString() + " joined the crew role waiting list", "CustomRoleSelector");
+1 -1
View File
@@ -96,7 +96,7 @@ public class ModUpdater
Logger.Info(assets.ToString(), "ModUpdater");
for (int i = 0; i < assets.Count; i++)
{
if (assets[i]["name"].ToString() == $"TOH-Enhanced.{latestVersion}.zip")
if (assets[i]["name"].ToString() == $"TOHE+.v{latestVersion}.zip")
{
downloadUrl = assets[i]["browser_download_url"].ToString();
break;
+12 -14
View File
@@ -82,14 +82,23 @@ public static class Options
"Rate0",
"Rate5",
"Rate10",
"Rate15",
"Rate20",
"Rate25",
"Rate30",
"Rate35",
"Rate40",
"Rate45",
"Rate50",
"Rate55",
"Rate60",
"Rate65",
"Rate70",
"Rate75",
"Rate80",
"Rate85",
"Rate90",
"Rate95",
"Rate100",
];
public static readonly string[] ratesZeroOne =
@@ -999,18 +1008,7 @@ public static class Options
}
}
public static int GetRoleSpawnMode(CustomRoles role)
{
var mode = CustomRoleSpawnChances.TryGetValue(role, out var sc) ? sc.GetChance() : 0;
return mode switch
{
0 => 0,
1 => 1,
2 => 2,
100 => 1,
_ => 1,
};
}
public static int GetRoleSpawnMode(CustomRoles role) => CustomRoleSpawnChances.TryGetValue(role, out var sc) ? sc.GetChance() : 0;
public static int GetRoleCount(CustomRoles role)
{
var mode = GetRoleSpawnMode(role);
@@ -3636,7 +3634,7 @@ public static class Options
public static void SetupRoleOptions(int id, TabGroup tab, CustomRoles role, CustomGameMode customGameMode = CustomGameMode.Standard, bool zeroOne = false)
{
var spawnOption = StringOptionItem.Create(id, role.ToString(), zeroOne ? ratesZeroOne : ratesToggle, 0, tab, false).SetColor(Utils.GetRoleColor(role))
var spawnOption = StringOptionItem.Create(id, role.ToString(), zeroOne ? ratesZeroOne : rates, 0, tab, false).SetColor(Utils.GetRoleColor(role))
.SetHeader(true)
.SetGameMode(customGameMode) as StringOptionItem;
var countOption = IntegerOptionItem.Create(id + 1, "Maximum", new(1, 15, 1), 1, tab, false)
@@ -3714,7 +3712,7 @@ public static class Options
public static void SetupSingleRoleOptions(int id, TabGroup tab, CustomRoles role, int count, CustomGameMode customGameMode = CustomGameMode.Standard, bool zeroOne = false)
{
var spawnOption = StringOptionItem.Create(id, role.ToString(), zeroOne ? ratesZeroOne : ratesToggle, 0, tab, false).SetColor(Utils.GetRoleColor(role))
var spawnOption = StringOptionItem.Create(id, role.ToString(), zeroOne ? ratesZeroOne : rates, 0, tab, false).SetColor(Utils.GetRoleColor(role))
.SetHeader(true)
.SetGameMode(customGameMode) as StringOptionItem;
// 初期値,最大値,最小値が同じで、stepが0のどうやっても変えることができない個数オプション
+5 -5
View File
@@ -24,16 +24,16 @@ public class StringOptionItem(int id, string name, int defaultValue, TabGroup ta
}
public int GetChance()
{
//0%or100%の場合
//For 0% or 100%
if (Selections.Length == 2) return CurrentValue * 100;
//TOHE的职业生成模式
//TOHE’s career generation mode
if (Selections.Length == 3) return CurrentValue;
//0%~100%or5%~100%の場合
var offset = 12 - Selections.Length;
//For 0% to 100% or 5% to 100%
var offset = Options.rates.Length - Selections.Length;
var index = CurrentValue + offset;
var rate = index <= 1 ? index * 5 : (index - 1) * 10;
var rate = index * 5;
return rate;
}
public override int GetValue()
+11 -10
View File
@@ -337,12 +337,13 @@ public static class Utils
{
if (Options.HideGameSettings.GetBool() && Main.AllPlayerControls.Length > 1)
return string.Empty;
string mode = role.GetMode() switch
{
0 => GetString("RoleOffNoColor"),
1 => GetString("RoleRateNoColor"),
_ => GetString("RoleOnNoColor")
};
string mode = GetString($"Rate{role.GetMode()}").RemoveHtmlTags();
//string mode = role.GetMode() switch
//{
// 0 => GetString("RoleOffNoColor"),
// 1 => GetString("RoleRateNoColor"),
// _ => GetString("RoleOnNoColor")
//};
return parentheses ? $"({mode})" : mode;
}
public static string GetDeathReason(PlayerState.DeathReason status)
@@ -1268,7 +1269,7 @@ public static class Utils
foreach (var role in Options.CustomRoleCounts)
{
if (!role.Key.IsEnable()) continue;
string mode = role.Key.GetMode() == 1 ? GetString("RoleRateNoColor") : GetString("RoleOnNoColor");
string mode = GetString($"Rate{role.Key.GetMode()}");
sb.Append($"\n【{GetRoleName(role.Key)}:{mode} ×{role.Key.GetCount()}】\n");
ShowChildrenSettings(Options.CustomRoleSpawnChances[role.Key], ref sb);
var text = sb.ToString();
@@ -1299,7 +1300,7 @@ public static class Utils
foreach (var role in Options.CustomRoleCounts)
{
if (!role.Key.IsEnable()) continue;
string mode = role.Key.GetMode() == 1 ? GetString("RoleRateNoColor") : GetString("RoleOnNoColor");
string mode = GetString($"Rate{role.Key.GetMode()}");
sb.Append($"\n【{GetRoleName(role.Key)}:{mode} ×{role.Key.GetCount()}】\n");
ShowChildrenSettings(Options.CustomRoleSpawnChances[role.Key], ref sb);
var text = sb.ToString();
@@ -1339,10 +1340,10 @@ public static class Utils
for (int i = 0; i < list.Count; i++)
{
CustomRoles role = (CustomRoles)list[i];
string mode = role.GetMode() == 1 ? GetString("RoleRateNoColor") : GetString("RoleOnNoColor");
string mode = GetString($"Rate{role.GetMode()}");
if (role.IsEnable())
{
var roleDisplay = $"\n{GetRoleName(role)}:{mode} x{role.GetCount()}";
var roleDisplay = $"\n{GetRoleName(role)}: {mode} x{role.GetCount()}";
if (role.IsAdditionRole()) addonsb.Append(roleDisplay);
else if (role.IsCrewmate()) crewsb.Append(roleDisplay);
else if (role.IsImpostor() || role.IsMadmate()) impsb.Append(roleDisplay);
+1 -1
View File
@@ -78,11 +78,11 @@ public static class OptionsMenuBehaviourStartPatch
Main.Instance.Unload();
}
}
#if DEBUG
if (UseVersionProtocol == null || UseVersionProtocol.ToggleButton == null)
{
UseVersionProtocol = ClientOptionItem.Create("UseVersionProtocol", Main.UseVersionProtocol, __instance);
}
#if DEBUG
if ((VersionCheat == null || VersionCheat.ToggleButton == null) && DebugModeManager.AmDebugger)
{
VersionCheat = ClientOptionItem.Create("VersionCheat", Main.VersionCheat, __instance);
+13 -10
View File
@@ -2422,10 +2422,11 @@ class FixedUpdatePatch
if (!lowLoad)
{
long now = GetTimeStamp();
switch (player.GetCustomRole())
{
case CustomRoles.Veteran when GameStates.IsInTask:
if (Main.VeteranInProtect.TryGetValue(player.PlayerId, out var vtime) && vtime + Options.VeteranSkillDuration.GetInt() < GetTimeStamp())
if (Main.VeteranInProtect.TryGetValue(player.PlayerId, out var vtime) && vtime + Options.VeteranSkillDuration.GetInt() < now)
{
Main.VeteranInProtect.Remove(player.PlayerId);
player.RpcResetAbilityCooldown();
@@ -2434,7 +2435,7 @@ class FixedUpdatePatch
break;
case CustomRoles.Express when GameStates.IsInTask:
if (Main.ExpressSpeedUp.TryGetValue(player.PlayerId, out var etime) && etime + Options.ExpressSpeedDur.GetInt() < GetTimeStamp())
if (Main.ExpressSpeedUp.TryGetValue(player.PlayerId, out var etime) && etime + Options.ExpressSpeedDur.GetInt() < now)
{
Main.ExpressSpeedUp.Remove(player.PlayerId);
Main.AllPlayerSpeed[player.PlayerId] = Main.ExpressSpeedNormal;
@@ -2443,14 +2444,14 @@ class FixedUpdatePatch
break;
case CustomRoles.Grenadier when GameStates.IsInTask:
if (Main.GrenadierBlinding.TryGetValue(player.PlayerId, out var gtime) && gtime + Options.GrenadierSkillDuration.GetInt() < GetTimeStamp())
if (Main.GrenadierBlinding.TryGetValue(player.PlayerId, out var gtime) && gtime + Options.GrenadierSkillDuration.GetInt() < now)
{
Main.GrenadierBlinding.Remove(player.PlayerId);
player.RpcResetAbilityCooldown();
player.Notify(string.Format(GetString("GrenadierSkillStop"), (int)Main.GrenadierNumOfUsed[player.PlayerId]));
MarkEveryoneDirtySettingsV3();
}
if (Main.MadGrenadierBlinding.TryGetValue(player.PlayerId, out var mgtime) && mgtime + Options.GrenadierSkillDuration.GetInt() < GetTimeStamp())
if (Main.MadGrenadierBlinding.TryGetValue(player.PlayerId, out var mgtime) && mgtime + Options.GrenadierSkillDuration.GetInt() < now)
{
Main.MadGrenadierBlinding.Remove(player.PlayerId);
player.RpcResetAbilityCooldown();
@@ -2460,7 +2461,7 @@ class FixedUpdatePatch
break;
case CustomRoles.Lighter when GameStates.IsInTask:
if (Main.Lighter.TryGetValue(player.PlayerId, out var ltime) && ltime + Options.LighterSkillDuration.GetInt() < GetTimeStamp())
if (Main.Lighter.TryGetValue(player.PlayerId, out var ltime) && ltime + Options.LighterSkillDuration.GetInt() < now)
{
Main.Lighter.Remove(player.PlayerId);
player.RpcResetAbilityCooldown();
@@ -2470,7 +2471,7 @@ class FixedUpdatePatch
break;
case CustomRoles.SecurityGuard when GameStates.IsInTask:
if (Main.BlockSabo.TryGetValue(player.PlayerId, out var stime) && stime + Options.SecurityGuardSkillDuration.GetInt() < GetTimeStamp())
if (Main.BlockSabo.TryGetValue(player.PlayerId, out var stime) && stime + Options.SecurityGuardSkillDuration.GetInt() < now)
{
Main.BlockSabo.Remove(player.PlayerId);
player.RpcResetAbilityCooldown();
@@ -2479,7 +2480,7 @@ class FixedUpdatePatch
break;
case CustomRoles.TimeMaster when GameStates.IsInTask:
if (Main.TimeMasterInProtect.TryGetValue(player.PlayerId, out var ttime) && ttime + Options.TimeMasterSkillDuration.GetInt() < GetTimeStamp())
if (Main.TimeMasterInProtect.TryGetValue(player.PlayerId, out var ttime) && ttime + Options.TimeMasterSkillDuration.GetInt() < now)
{
Main.TimeMasterInProtect.Remove(player.PlayerId);
player.RpcResetAbilityCooldown();
@@ -2544,7 +2545,7 @@ class FixedUpdatePatch
break;
}
if (Main.AllKillers.TryGetValue(player.PlayerId, out var ktime) && ktime + Options.WitnessTime.GetInt() < GetTimeStamp()) Main.AllKillers.Remove(player.PlayerId);
if (Main.AllKillers.TryGetValue(player.PlayerId, out var ktime) && ktime + Options.WitnessTime.GetInt() < now) Main.AllKillers.Remove(player.PlayerId);
if (GameStates.IsInTask && player.IsAlive() && Options.LadderDeath.GetBool()) FallFromLadder.FixedUpdate(player);
if (GameStates.IsInGame) LoversSuicide();
@@ -2557,14 +2558,14 @@ class FixedUpdatePatch
Main.PuppeteerDelayList.Remove(player.PlayerId);
Main.PuppeteerDelay.Remove(player.PlayerId);
}
else if (Main.PuppeteerDelayList[player.PlayerId] + Options.PuppeteerManipulationEndsAfterTime.GetInt() < GetTimeStamp() && Options.PuppeteerManipulationEndsAfterFixedTime.GetBool())
else if (Main.PuppeteerDelayList[player.PlayerId] + Options.PuppeteerManipulationEndsAfterTime.GetInt() < now && Options.PuppeteerManipulationEndsAfterFixedTime.GetBool())
{
Main.PuppeteerList.Remove(player.PlayerId);
Main.PuppeteerDelayList.Remove(player.PlayerId);
Main.PuppeteerDelay.Remove(player.PlayerId);
Main.AllAlivePlayerControls.Where(x => x.Is(CustomRoles.Puppeteer)).Do(x => NotifyRoles(SpecifySeer: x, SpecifyTarget: player));
}
else if (Main.PuppeteerDelayList[player.PlayerId] + Main.PuppeteerDelay[player.PlayerId] < GetTimeStamp())
else if (Main.PuppeteerDelayList[player.PlayerId] + Main.PuppeteerDelay[player.PlayerId] < now)
{
Vector2 puppeteerPos = player.transform.position;//PuppeteerListのKeyの位置
Dictionary<byte, float> targetDistance = [];
@@ -2613,11 +2614,13 @@ class FixedUpdatePatch
}
if (GameStates.IsInGame && Main.RefixCooldownDelay <= 0)
{
foreach (PlayerControl pc in Main.AllPlayerControls)
{
if (pc.Is(CustomRoles.Vampire) || pc.Is(CustomRoles.Warlock) || pc.Is(CustomRoles.Assassin) || pc.Is(CustomRoles.Undertaker) || pc.Is(CustomRoles.Poisoner))
Main.AllPlayerKillCooldown[pc.PlayerId] = Options.DefaultKillCooldown * 2;
}
}
if (!Main.DoBlockNameChange && AmongUsClient.Instance.AmHost)
ApplySuffix(__instance);
+21 -18
View File
@@ -2254,18 +2254,27 @@
"RoleRateNoColor","启用","Random","Рандом","啟用","启用"
"RoleOnNoColor","优先","Always","ВКЛ","優先","优先"
"RoleOffNoColor","禁用","Disabled","ВЫКЛ","禁用","禁用"
"Rate0","0%","0%","0%","0%","0%"
"Rate5","5%","5%","5%","5%","5%"
"Rate10","10%","10%","10%","10%","10%"
"Rate20","20%","20%","20%","20%","20%"
"Rate30","30%","30%","30%","30%","30%"
"Rate40","40%","40%","40%","40%","40%"
"Rate50","50%","50%","50%","50%","50%"
"Rate60","60%","60%","60%","60%","60%"
"Rate70","70%","70%","70%","70%","70%"
"Rate80","80%","80%","80%","80%","80%"
"Rate90","90%","90%","90%","90%","90%"
"Rate100","100%","100%","100%","100%","100%"
"Rate0","<#444444>0%</color>","<#444444>0%</color>","<#444444>0%</color>","<#444444>0%</color>","<#444444>0%</color>"
"Rate5","<#808F8F>5%</color>","<#808F8F>5%</color>","<#808F8F>5%</color>","<#808F8F>5%</color>","<#808F8F>5%</color>"
"Rate10","<#799595>10%</color>","<#799595>10%</color>","<#799595>10%</color>","<#799595>10%</color>","<#799595>10%</color>"
"Rate15","<#719C9C>15%</color>","<#719C9C>15%</color>","<#719C9C>15%</color>","<#719C9C>15%</color>","<#719C9C>15%</color>"
"Rate20","<#6AA2A2>20%</color>","<#6AA2A2>20%</color>","<#6AA2A2>20%</color>","<#6AA2A2>20%</color>","<#6AA2A2>20%</color>"
"Rate25","<#62A9A9>25%</color>","<#62A9A9>25%</color>","<#62A9A9>25%</color>","<#62A9A9>25%</color>","<#62A9A9>25%</color>"
"Rate30","<#5BB0B0>30%</color>","<#5BB0B0>30%</color>","<#5BB0B0>30%</color>","<#5BB0B0>30%</color>","<#5BB0B0>30%</color>"
"Rate35","<#53B6B6>35%</color>","<#53B6B6>35%</color>","<#53B6B6>35%</color>","<#53B6B6>35%</color>","<#53B6B6>35%</color>"
"Rate40","<#4CBDBD>40%</color>","<#4CBDBD>40%</color>","<#4CBDBD>40%</color>","<#4CBDBD>40%</color>","<#4CBDBD>40%</color>"
"Rate45","<#44C4C4>45%</color>","<#44C4C4>45%</color>","<#44C4C4>45%</color>","<#44C4C4>45%</color>","<#44C4C4>45%</color>"
"Rate50","<#3CCACA>50%</color>","<#3CCACA>50%</color>","<#3CCACA>50%</color>","<#3CCACA>50%</color>","<#3CCACA>50%</color>"
"Rate55","<#35D1D1>55%</color>","<#35D1D1>55%</color>","<#35D1D1>55%</color>","<#35D1D1>55%</color>","<#35D1D1>55%</color>"
"Rate60","<#2DD7D7>60%</color>","<#2DD7D7>60%</color>","<#2DD7D7>60%</color>","<#2DD7D7>60%</color>","<#2DD7D7>60%</color>"
"Rate65","<#26DEDE>65%</color>","<#26DEDE>65%</color>","<#26DEDE>65%</color>","<#26DEDE>65%</color>","<#26DEDE>65%</color>"
"Rate70","<#1EE5E5>70%</color>","<#1EE5E5>70%</color>","<#1EE5E5>70%</color>","<#1EE5E5>70%</color>","<#1EE5E5>70%</color>"
"Rate75","<#17EBEB>75%</color>","<#17EBEB>75%</color>","<#17EBEB>75%</color>","<#17EBEB>75%</color>","<#17EBEB>75%</color>"
"Rate80","<#0FF2F2>80%</color>","<#0FF2F2>80%</color>","<#0FF2F2>80%</color>","<#0FF2F2>80%</color>","<#0FF2F2>80%</color>"
"Rate85","<#08F8F8>85%</color>","<#08F8F8>85%</color>","<#08F8F8>85%</color>","<#08F8F8>85%</color>","<#08F8F8>85%</color>"
"Rate90","<#07F9F9>90%</color>","<#07F9F9>90%</color>","<#07F9F9>90%</color>","<#07F9F9>90%</color>","<#07F9F9>90%</color>"
"Rate95","<#00FFFF>95%</color>","<#00FFFF>95%</color>","<#00FFFF>95%</color>","<#00FFFF>95%</color>","<#00FFFF>95%</color>"
"Rate100","<#00FFA5>100%</color>","<#00FFA5>100%</color>","<#00FFA5>100%</color>","<#00FFA5>100%</color>","<#00FFA5>100%</color>"
"Preset","预设","Preset","Сохранения","設定檔","预设"
"Preset_1","预设1","Preset 1","Сохранение 1","設定檔1","预设1"
"Preset_2","预设2","Preset 2","Сохранение 2","設定檔2","预设2"
@@ -3356,12 +3365,6 @@
"Prefix.Physicist","","Physicist ","","",""
"PrefixB.Physicist","","<color=#ffffff>(</color>Physicist<color=#ffffff>)</color> ","","",""
"## Mod Updater Text Strings"
"updatePleaseWait","","Updating, Please Wait....","","",""
"updateRestart","","Update Completed!\nRestart your game for the update to complete.","","",""
"updateManually","","Update Failed!\nPlease update the mod manually.","","",""
"Close","","Close","","",""
"## Agitater"
"Agitater","煽动者","Agitater","Агитатор","","Agitador"
"AgitaterInfo","这个炸弹给你了!","Pass a Bomb onto others","Вот тебе подарок в виде бомбы","","Pásale la patata caliente a otros"
Can't render this file because it is too large.
+1 -1
View File
@@ -7,7 +7,7 @@
<Description>TOHE+</Description>
<Authors>Gurge44</Authors>
<langVersion>preview</langVersion>
<AmongUs>E:\Program Files\AmongUs</AmongUs>
<AmongUs>D:\Epic Games\AmongUs</AmongUs>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>True</Optimize>
<AssemblyName>$(MSBuildProjectName)+</AssemblyName>