mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
Fix Vulture CD and other things
This commit is contained in:
1 parent
cea420f3be
commit
41c018737c
9 files changed
+94
-94
No files matched your search
+19
-15
@@ -883,6 +883,8 @@ public static class Options
|
||||
|
||||
public static OptionItem DIYGameSettings;
|
||||
public static OptionItem PlayerCanSetColor;
|
||||
public static OptionItem PlayerCanSetName;
|
||||
public static OptionItem PlayerCanTPInAndOut;
|
||||
|
||||
//Add-Ons
|
||||
public static OptionItem NameDisplayAddons;
|
||||
@@ -1319,6 +1321,8 @@ public static class Options
|
||||
HideGameSettings = BooleanOptionItem.Create(19400, "HideGameSettings", false, TabGroup.SystemSettings, false);
|
||||
DIYGameSettings = BooleanOptionItem.Create(19401, "DIYGameSettings", false, TabGroup.SystemSettings, false);
|
||||
PlayerCanSetColor = BooleanOptionItem.Create(19402, "PlayerCanSetColor", false, TabGroup.SystemSettings, false);
|
||||
PlayerCanSetName = BooleanOptionItem.Create(19410, "PlayerCanSetName", false, TabGroup.SystemSettings, false);
|
||||
PlayerCanTPInAndOut = BooleanOptionItem.Create(19411, "PlayerCanTPInAndOut", false, TabGroup.SystemSettings, false);
|
||||
FormatNameMode = StringOptionItem.Create(19403, "FormatNameMode", formatNameModes, 0, TabGroup.SystemSettings, false);
|
||||
DisableEmojiName = BooleanOptionItem.Create(19404, "DisableEmojiName", true, TabGroup.SystemSettings, false);
|
||||
ChangeNameToRoleInfo = BooleanOptionItem.Create(19405, "ChangeNameToRoleInfo", true, TabGroup.SystemSettings, false);
|
||||
@@ -2260,32 +2264,32 @@ public static class Options
|
||||
public static Dictionary<CustomRoles, OverrideTasksData> AllData = [];
|
||||
public CustomRoles Role { get; private set; }
|
||||
public int IdStart { get; private set; }
|
||||
public OptionItem doOverride;
|
||||
public OptionItem assignCommonTasks;
|
||||
public OptionItem numLongTasks;
|
||||
public OptionItem numShortTasks;
|
||||
public OptionItem DoOverride;
|
||||
public OptionItem AssignCommonTasks;
|
||||
public OptionItem NumLongTasks;
|
||||
public OptionItem NumShortTasks;
|
||||
|
||||
public OverrideTasksData(int idStart, TabGroup tab, CustomRoles role)
|
||||
{
|
||||
IdStart = idStart;
|
||||
Role = role;
|
||||
Dictionary<string, string> replacementDic = new() { { "%role%", Utils.ColorString(Utils.GetRoleColor(role), Utils.GetRoleName(role)) } };
|
||||
doOverride = BooleanOptionItem.Create(idStart++, "doOverride", false, tab, false)
|
||||
DoOverride = BooleanOptionItem.Create(idStart++, "doOverride", false, tab, false)
|
||||
.SetParent(CustomRoleSpawnChances[role])
|
||||
.SetValueFormat(OptionFormat.None);
|
||||
doOverride.ReplacementDictionary = replacementDic;
|
||||
assignCommonTasks = BooleanOptionItem.Create(idStart++, "assignCommonTasks", true, tab, false)
|
||||
.SetParent(doOverride)
|
||||
DoOverride.ReplacementDictionary = replacementDic;
|
||||
AssignCommonTasks = BooleanOptionItem.Create(idStart++, "assignCommonTasks", true, tab, false)
|
||||
.SetParent(DoOverride)
|
||||
.SetValueFormat(OptionFormat.None);
|
||||
assignCommonTasks.ReplacementDictionary = replacementDic;
|
||||
numLongTasks = IntegerOptionItem.Create(idStart++, "roleLongTasksNum", new(0, 99, 1), 3, tab, false)
|
||||
.SetParent(doOverride)
|
||||
AssignCommonTasks.ReplacementDictionary = replacementDic;
|
||||
NumLongTasks = IntegerOptionItem.Create(idStart++, "roleLongTasksNum", new(0, 90, 1), 3, tab, false)
|
||||
.SetParent(DoOverride)
|
||||
.SetValueFormat(OptionFormat.Pieces);
|
||||
numLongTasks.ReplacementDictionary = replacementDic;
|
||||
numShortTasks = IntegerOptionItem.Create(idStart++, "roleShortTasksNum", new(0, 99, 1), 3, tab, false)
|
||||
.SetParent(doOverride)
|
||||
NumLongTasks.ReplacementDictionary = replacementDic;
|
||||
NumShortTasks = IntegerOptionItem.Create(idStart, "roleShortTasksNum", new(0, 90, 1), 3, tab, false)
|
||||
.SetParent(DoOverride)
|
||||
.SetValueFormat(OptionFormat.Pieces);
|
||||
numShortTasks.ReplacementDictionary = replacementDic;
|
||||
NumShortTasks.ReplacementDictionary = replacementDic;
|
||||
|
||||
if (!AllData.ContainsKey(role)) AllData.Add(role, this);
|
||||
else Logger.Warn("OverrideTasksData created for duplicate CustomRoles", "OverrideTasksData");
|
||||
|
||||
+27
-35
@@ -1138,35 +1138,38 @@ internal class ChatCommands
|
||||
|
||||
case "/tpout":
|
||||
canceled = true;
|
||||
if (!GameStates.IsLobby) break;
|
||||
if (!GameStates.IsLobby || !Options.PlayerCanTPInAndOut.GetBool()) break;
|
||||
player.TP(new Vector2(0.1f, 3.8f));
|
||||
break;
|
||||
|
||||
case "/tpin":
|
||||
canceled = true;
|
||||
if (!GameStates.IsLobby) break;
|
||||
if (!GameStates.IsLobby || !Options.PlayerCanTPInAndOut.GetBool()) break;
|
||||
player.TP(new Vector2(-0.2f, 1.3f));
|
||||
break;
|
||||
|
||||
//case "/quit":
|
||||
//case "/qt":
|
||||
// subArgs = args.Length < 2 ? string.Empty : args[1];
|
||||
// var cid = player.PlayerId.ToString();
|
||||
// cid = cid.Length != 1 ? cid.Substring(1, 1) : cid;
|
||||
// if (subArgs.Equals(cid))
|
||||
// {
|
||||
// string name = player.GetRealName();
|
||||
// Utils.SendMessage(string.Format(GetString("Message.PlayerQuitForever"), name));
|
||||
// AmongUsClient.Instance.KickPlayer(player.GetClientId(), true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Utils.SendMessage(string.Format(GetString("SureUse.quit"), cid), player.PlayerId);
|
||||
// }
|
||||
// break;
|
||||
case "/rename":
|
||||
case "/rn":
|
||||
if (!Options.PlayerCanSetName.GetBool() || args.Length < 1) break;
|
||||
if (GameStates.IsInGame)
|
||||
{
|
||||
Utils.SendMessage(GetString("Message.OnlyCanUseInLobby"), player.PlayerId);
|
||||
break;
|
||||
}
|
||||
|
||||
var name = args.Skip(1).Join(delimiter: " ");
|
||||
if (name.Length is > 10 or < 1)
|
||||
{
|
||||
Utils.SendMessage(GetString("Message.AllowNameLength"), player.PlayerId);
|
||||
break;
|
||||
}
|
||||
|
||||
Main.AllPlayerNames[player.PlayerId] = name;
|
||||
break;
|
||||
|
||||
case "/id":
|
||||
string msgText = GetString("PlayerIdList");
|
||||
msgText = Main.AllPlayerControls.Aggregate(msgText, (current, pc) => current + "\n" + pc.PlayerId + " → " + Main.AllPlayerNames[pc.PlayerId]);
|
||||
msgText = Main.AllPlayerControls.Aggregate(msgText, (current, pc) => $"{current}\n{pc.PlayerId} \u2192 {Main.AllPlayerNames[pc.PlayerId]}");
|
||||
|
||||
Utils.SendMessage(msgText, player.PlayerId);
|
||||
break;
|
||||
@@ -1179,24 +1182,13 @@ internal class ChatCommands
|
||||
MeetingHud.Instance?.CastVote(player.PlayerId, voteId);
|
||||
break;
|
||||
case "/ask":
|
||||
try
|
||||
{
|
||||
Mathematician.Ask(player, args[1], args[2]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (args.Length < 3) break;
|
||||
Mathematician.Ask(player, args[1], args[2]);
|
||||
break;
|
||||
case "/ans":
|
||||
case "/answer":
|
||||
try
|
||||
{
|
||||
Mathematician.Reply(player, args[1]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (args.Length < 2) break;
|
||||
Mathematician.Reply(player, args[1]);
|
||||
break;
|
||||
case "/ban":
|
||||
case "/kick":
|
||||
|
||||
@@ -56,9 +56,6 @@ public static class HudSpritePatch
|
||||
{
|
||||
switch (player.GetCustomRole())
|
||||
{
|
||||
case CustomRoles.Commander:
|
||||
newAbilityButton = CustomButton.Get("Commander");
|
||||
break;
|
||||
case CustomRoles.Assassin:
|
||||
case CustomRoles.Undertaker:
|
||||
if (Main.PlayerStates[player.PlayerId].Role is not Assassin assassin) break;
|
||||
|
||||
@@ -121,27 +121,27 @@ class RpcSetTasksPatch
|
||||
// Null measures
|
||||
if (Main.RealOptionsData == null)
|
||||
{
|
||||
Logger.Warn("警告:RealOptionsDataがnullです。", "RpcSetTasksPatch");
|
||||
Logger.Warn("Warning: RealOptionsData is null.", "RpcSetTasksPatch");
|
||||
return;
|
||||
}
|
||||
|
||||
var pc = Utils.GetPlayerById(playerId);
|
||||
CustomRoles? RoleNullable = pc?.GetCustomRole();
|
||||
if (RoleNullable == null) return;
|
||||
CustomRoles role = RoleNullable.Value;
|
||||
if (pc == null) return;
|
||||
CustomRoles role = pc.Is(CustomRoles.Specter) ? CustomRoles.Specter : pc.GetCustomRole();
|
||||
|
||||
// Default number of tasks
|
||||
bool hasCommonTasks = true;
|
||||
int NumLongTasks = Main.NormalOptions.NumLongTasks;
|
||||
int NumShortTasks = Main.NormalOptions.NumShortTasks;
|
||||
|
||||
if (Options.OverrideTasksData.AllData.TryGetValue(role, out var data) && data.doOverride.GetBool())
|
||||
if (Options.OverrideTasksData.AllData.TryGetValue(role, out var data) && data.DoOverride.GetBool())
|
||||
{
|
||||
hasCommonTasks = data.assignCommonTasks.GetBool(); // Whether to assign common tasks (regular tasks)
|
||||
hasCommonTasks = data.AssignCommonTasks.GetBool(); // Whether to assign common tasks (regular tasks)
|
||||
// Even if assigned, it will not be reassigned and will be assigned the same common tasks as other crews.
|
||||
NumLongTasks = data.numLongTasks.GetInt(); // Number of long tasks to allocate
|
||||
NumShortTasks = data.numShortTasks.GetInt(); // Number of short tasks to allocate
|
||||
NumLongTasks = data.NumLongTasks.GetInt(); // Number of long tasks to allocate
|
||||
NumShortTasks = data.NumShortTasks.GetInt(); // Number of short tasks to allocate
|
||||
// Longs and shorts are constantly reallocated.
|
||||
if (role == CustomRoles.Specter) Main.PlayerStates[pc.PlayerId].TaskState.AllTasksCount = NumLongTasks + NumShortTasks;
|
||||
}
|
||||
|
||||
if (pc.Is(CustomRoles.Busy))
|
||||
|
||||
@@ -972,6 +972,8 @@
|
||||
"HideGameSettings": "Hide Game Settings",
|
||||
"DIYGameSettings": "Enable only custom /n messages",
|
||||
"PlayerCanSetColor": "Players can use the /color command",
|
||||
"PlayerCanSetName": "Players can use the /rename command",
|
||||
"PlayerCanTPInAndOut": "Players can use the /tpin & /tpout command",
|
||||
"KPDCamouflageMode": "Camouflage Appearance",
|
||||
"RoleOptions": "Role Options",
|
||||
"ModeOptions": "Mode Options",
|
||||
|
||||
@@ -9,6 +9,7 @@ namespace EHR.Roles.AddOns.GhostRoles
|
||||
public Team Team => Team.Neutral;
|
||||
|
||||
private static OptionItem SnatchWin;
|
||||
private static Options.OverrideTasksData Tasks;
|
||||
|
||||
public bool IsWon;
|
||||
|
||||
@@ -40,6 +41,7 @@ namespace EHR.Roles.AddOns.GhostRoles
|
||||
Options.SetupRoleOptions(649100, TabGroup.OtherRoles, CustomRoles.Specter);
|
||||
SnatchWin = BooleanOptionItem.Create(649102, "SnatchWin", false, TabGroup.OtherRoles, false)
|
||||
.SetParent(Options.CustomRoleSpawnChances[CustomRoles.Specter]);
|
||||
Tasks = Options.OverrideTasksData.Create(649103, TabGroup.OtherRoles, CustomRoles.Specter);
|
||||
}
|
||||
|
||||
public void OnFinishedTasks(PlayerControl pc)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace EHR.Roles.Crewmate
|
||||
using System;
|
||||
|
||||
namespace EHR.Roles.Crewmate
|
||||
{
|
||||
internal class Mathematician : RoleBase
|
||||
{
|
||||
@@ -23,24 +25,38 @@
|
||||
|
||||
public static void Ask(PlayerControl pc, string num1Str, string num2Str)
|
||||
{
|
||||
if (pc == null || !pc.IsAlive() || !GameStates.IsMeeting || State.AskedQuestion || !int.TryParse(num1Str, out var num1) || !int.TryParse(num2Str, out var num2)) return;
|
||||
try
|
||||
{
|
||||
if (pc == null || !pc.IsAlive() || !GameStates.IsMeeting || State.AskedQuestion || !int.TryParse(num1Str, out var num1) || !int.TryParse(num2Str, out var num2)) return;
|
||||
|
||||
State.AskedQuestion = true;
|
||||
State.Answer = num1 + num2;
|
||||
State.MathematicianPlayerId = pc.PlayerId;
|
||||
State.AskedQuestion = true;
|
||||
State.Answer = num1 + num2;
|
||||
State.MathematicianPlayerId = pc.PlayerId;
|
||||
|
||||
string question = string.Format(Translator.GetString("MathematicianQuestionString"), num1, num2);
|
||||
Utils.SendMessage(question, title: Translator.GetString("Mathematician"));
|
||||
string question = string.Format(Translator.GetString("MathematicianQuestionString"), num1, num2);
|
||||
Utils.SendMessage(question, title: Translator.GetString("Mathematician"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.ThrowException(e);
|
||||
}
|
||||
}
|
||||
public static void Reply(PlayerControl pc, string answerStr)
|
||||
{
|
||||
if (pc == null || !pc.IsAlive() || !GameStates.IsMeeting || !State.AskedQuestion || State.MathematicianPlayerId == pc.PlayerId || !int.TryParse(answerStr, out var answer)) return;
|
||||
|
||||
if (answer == State.Answer)
|
||||
try
|
||||
{
|
||||
State.ProtectedPlayerId = pc.PlayerId;
|
||||
Utils.SendMessage(string.Format(Translator.GetString("MathematicianAnsweredString"), pc.GetRealName(), answer), title: Translator.GetString("Mathematician"));
|
||||
State.AskedQuestion = false;
|
||||
if (pc == null || !pc.IsAlive() || !GameStates.IsMeeting || !State.AskedQuestion || State.MathematicianPlayerId == pc.PlayerId || !int.TryParse(answerStr, out var answer)) return;
|
||||
|
||||
if (answer == State.Answer)
|
||||
{
|
||||
State.ProtectedPlayerId = pc.PlayerId;
|
||||
Utils.SendMessage(string.Format(Translator.GetString("MathematicianAnsweredString"), pc.GetRealName(), answer), title: Translator.GetString("Mathematician"));
|
||||
State.AskedQuestion = false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.ThrowException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace EHR.Roles.Impostor
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ public class Vulture : RoleBase
|
||||
{
|
||||
Utils.GetPlayerById(playerId).Notify(GetString("VultureCooldownUp"));
|
||||
}
|
||||
}, VultureReportCD.GetFloat() + 8f, "Vulture CD"); //for some reason that idk vulture cd completes 8s faster when the game starts, so I added 8f for now
|
||||
}, VultureReportCD.GetFloat() + 8f, "Vulture CD");
|
||||
}
|
||||
|
||||
public override bool IsEnable => playerIdList.Count > 0;
|
||||
@@ -118,7 +118,6 @@ public class Vulture : RoleBase
|
||||
{
|
||||
if (GameStates.IsInTask)
|
||||
{
|
||||
//Utils.GetPlayerById(apc).RpcGuardAndKill(Utils.GetPlayerById(apc));
|
||||
Utils.GetPlayerById(apc).Notify(GetString("VultureCooldownUp"));
|
||||
}
|
||||
}, VultureReportCD.GetFloat(), "Vulture CD");
|
||||
@@ -131,29 +130,21 @@ public class Vulture : RoleBase
|
||||
{
|
||||
if (!ArrowsPointingToDeadBody.GetBool()) return;
|
||||
|
||||
var pos = target.Pos();
|
||||
float minDis = float.MaxValue;
|
||||
foreach (PlayerControl pc in Main.AllAlivePlayerControls)
|
||||
{
|
||||
if (pc.PlayerId == target.PlayerId) continue;
|
||||
var dis = Vector2.Distance(pc.Pos(), pos);
|
||||
if (dis < minDis && dis < 1.5f)
|
||||
{
|
||||
minDis = dis;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (byte pc in playerIdList)
|
||||
{
|
||||
var player = Utils.GetPlayerById(pc);
|
||||
if (player == null || !player.IsAlive()) continue;
|
||||
LocateArrow.Add(pc, target.transform.position);
|
||||
SendRPC(pc, true, target.transform.position);
|
||||
Utils.NotifyRoles(SpecifySeer: player, SpecifyTarget: player);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CheckReportDeadBody(PlayerControl pc, GameData.PlayerInfo target, PlayerControl killer)
|
||||
{
|
||||
if (AbilityLeftInRound[pc.PlayerId] <= 0) return true;
|
||||
if (Utils.TimeStamp - LastReport[pc.PlayerId] < VultureReportCD.GetFloat()) return true;
|
||||
|
||||
BodyReportCount[pc.PlayerId]++;
|
||||
AbilityLeftInRound[pc.PlayerId]--;
|
||||
Logger.Msg($"target.object {target.Object}, is null? {target.Object == null}", "VultureNull");
|
||||
@@ -169,7 +160,7 @@ public class Vulture : RoleBase
|
||||
pc.Notify(GetString("VultureBodyReported"));
|
||||
UnreportablePlayers.Remove(target.PlayerId);
|
||||
UnreportablePlayers.Add(target.PlayerId);
|
||||
//playerIdList.Remove(target.PlayerId);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user