Some fixes and improvements

This commit is contained in:
Gurge44 committed 2024-08-28 10:35:19 +02:00
1 parent ccd0d7a45d
commit f7fd249a34
18 files changed
+96 -28

No files matched your search

+2
View File
@@ -273,6 +273,7 @@ public enum CustomRoles
Evolver,
Executioner,
Totocalcio, // Follower
Gaslighter,
Glitch,
God,
FFF, // Hater
@@ -329,6 +330,7 @@ public enum CustomRoles
DarkHide, // Stalker
Succubus,
Sunnyboy,
Technician,
Tank,
Terrorist,
Tiger,
+1
View File
@@ -7,6 +7,7 @@
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=AU/@EntryIndexedValue">AU</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CD/@EntryIndexedValue">CD</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CK/@EntryIndexedValue">CK</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CNO/@EntryIndexedValue">CNO</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=CTF/@EntryIndexedValue">CTF</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DLL/@EntryIndexedValue">DLL</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=DY/@EntryIndexedValue">DY</s:String>
+16 -2
View File
@@ -343,10 +343,24 @@ static class ExtendedPlayerControl
AmongUsClient.Instance.FinishRpcImmediately(msg);
}
public static bool HasAbilityCD(this PlayerControl pc) => Main.AbilityCD.ContainsKey(pc.PlayerId);
public static void AddKCDAsAbilityCD(this PlayerControl pc) => AddAbilityCD(pc, (int)Math.Round(Main.AllPlayerKillCooldown.TryGetValue(pc.PlayerId, out var KCD) ? KCD : Options.DefaultKillCooldown));
public static void AddAbilityCD(this PlayerControl pc, bool includeDuration = true) => Utils.AddAbilityCD(pc.GetCustomRole(), pc.PlayerId, includeDuration);
public static void AddAbilityCD(this PlayerControl pc, int CD) => Main.AbilityCD[pc.PlayerId] = (TimeStamp, CD);
public static bool HasAbilityCD(this PlayerControl pc) => Main.AbilityCD.ContainsKey(pc.PlayerId);
public static void AddAbilityCD(this PlayerControl pc, int CD)
{
Main.AbilityCD[pc.PlayerId] = (TimeStamp, CD);
SendRPC(CustomRPC.SyncAbilityCD, 1, pc.PlayerId, CD);
}
public static void RemoveAbilityCD(this PlayerControl pc)
{
if (Main.AbilityCD.ContainsKey(pc.PlayerId))
{
Main.AbilityCD.Remove(pc.PlayerId);
SendRPC(CustomRPC.SyncAbilityCD, 3, pc.PlayerId);
}
}
public static float GetAbilityUseLimit(this PlayerControl pc) => Main.AbilityUseLimit.GetValueOrDefault(pc.PlayerId, float.NaN);
public static float GetAbilityUseLimit(this byte playerId) => Main.AbilityUseLimit.GetValueOrDefault(playerId, float.NaN);
+31 -2
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using AmongUs.GameOptions;
@@ -56,6 +57,7 @@ public enum CustomRPC
RemoveSubRole,
Arrow,
FixModdedClientCNO,
SyncAbilityCD,
// Roles
SyncRoleData,
@@ -365,6 +367,33 @@ internal class RPCHandlerPatch
if (reader.ReadBoolean()) TargetArrow.ReceiveRPC(reader);
else LocateArrow.ReceiveRPC(reader);
break;
case CustomRPC.SyncAbilityCD:
{
switch (reader.ReadPackedInt32())
{
case 1:
{
byte id = reader.ReadByte();
int cd = reader.ReadPackedInt32();
long ts = Utils.TimeStamp;
Main.AbilityCD[id] = (ts, cd);
break;
}
case 2:
{
Main.AbilityCD.Clear();
break;
}
case 3:
{
byte id = reader.ReadByte();
Main.AbilityCD.Remove(id);
break;
}
}
break;
}
case CustomRPC.SyncRoleData:
{
byte id = reader.ReadByte();
@@ -399,7 +428,7 @@ internal class RPCHandlerPatch
case CustomRPC.SyncSentry:
{
byte id = reader.ReadByte();
if (Main.PlayerStates[id].Role is not EHR.Impostor.Sentry sentry) break;
if (Main.PlayerStates[id].Role is not Impostor.Sentry sentry) break;
sentry.MonitoredRoom = Utils.GetPlayerById(id).GetPlainShipRoom();
break;
}
@@ -912,7 +941,7 @@ internal static class RPC
Main.Instance.StartCoroutine(VersionCheck());
return;
static System.Collections.IEnumerator VersionCheck()
static IEnumerator VersionCheck()
{
while (PlayerControl.LocalPlayer == null) yield return null;
MessageWriter writer = AmongUsClient.Instance.StartRpc(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.VersionCheck);
+4 -1
View File
@@ -2450,7 +2450,9 @@ public static class Utils
{
if (role.UsesPetInsteadOfKill())
{
Main.AbilityCD[playerId] = (TimeStamp, (int)Math.Round(Main.AllPlayerKillCooldown.TryGetValue(playerId, out var KCD) ? KCD : Options.DefaultKillCooldown));
int kcd = (int)Math.Round(Main.AllPlayerKillCooldown.TryGetValue(playerId, out var KCD) ? KCD : Options.DefaultKillCooldown);
Main.AbilityCD[playerId] = (TimeStamp, kcd);
SendRPC(CustomRPC.SyncAbilityCD, 1, playerId, kcd);
return;
}
@@ -2507,6 +2509,7 @@ public static class Utils
CD = (int)Math.Round(CD * 0.75f);
Main.AbilityCD[playerId] = (TimeStamp, CD);
SendRPC(CustomRPC.SyncAbilityCD, 1, playerId, CD);
if (Options.UseUnshiftTrigger.GetBool() && role.SimpleAbilityTrigger() && (!role.IsNeutral() || Options.UseUnshiftTriggerForNKs.GetBool()))
GetPlayerById(playerId)?.RpcResetAbilityCooldown();
+15 -6
View File
@@ -589,8 +589,15 @@ class MurderPlayerPatch
}
if (killer.Is(CustomRoles.Sniper))
{
if (!Options.UsePets.GetBool()) killer.RpcResetAbilityCooldown();
else Main.AbilityCD[killer.PlayerId] = (TimeStamp, Options.DefaultShapeshiftCooldown.GetInt());
else
{
int cd = Options.DefaultShapeshiftCooldown.GetInt();
Main.AbilityCD[killer.PlayerId] = (TimeStamp, cd);
SendRPC(CustomRPC.SyncAbilityCD, 1, killer.PlayerId, cd);
}
}
if (killer != __instance)
{
@@ -1089,6 +1096,7 @@ class ReportDeadBodyPatch
}
Main.AbilityCD.Clear();
SendRPC(CustomRPC.SyncAbilityCD, 2);
if (player.Is(CustomRoles.Damocles))
{
@@ -1234,7 +1242,7 @@ static class FixedUpdatePatch
var player = __instance;
var playerId = player.PlayerId;
var lpId = PlayerControl.LocalPlayer.PlayerId;
var localPlayer = player.PlayerId == lpId; // Updates that are independent of the player are only executed for the local player.
var localPlayer = playerId == lpId; // Updates that are independent of the player are only executed for the local player.
bool lowLoad = false;
if (Options.LowLoadMode.GetBool())
@@ -1297,9 +1305,9 @@ static class FixedUpdatePatch
if (!GameStates.IsLobby)
{
if (player.Is(CustomRoles.Spurt) && !Mathf.Approximately(Main.AllPlayerSpeed[player.PlayerId], Spurt.StartingSpeed[player.PlayerId]) && !inTask && !GameStates.IsMeeting) // fix ludicrous bug
if (player.Is(CustomRoles.Spurt) && !Mathf.Approximately(Main.AllPlayerSpeed[playerId], Spurt.StartingSpeed[playerId]) && !inTask && !GameStates.IsMeeting) // fix ludicrous bug
{
Main.AllPlayerSpeed[player.PlayerId] = Spurt.StartingSpeed[player.PlayerId];
Main.AllPlayerSpeed[playerId] = Spurt.StartingSpeed[playerId];
player.MarkDirtySettings();
}
@@ -1336,7 +1344,7 @@ static class FixedUpdatePatch
PlagueBearer.playerIdList.Remove(playerId);
}
bool checkPos = inTask && player != null && alive && !Pelican.IsEaten(player.PlayerId);
bool checkPos = inTask && player != null && alive && !Pelican.IsEaten(playerId);
if (checkPos) Asthmatic.OnCheckPlayerPosition(player);
foreach (var state in Main.PlayerStates.Values)
{
@@ -1372,6 +1380,7 @@ static class FixedUpdatePatch
if (timer.START_TIMESTAMP + timer.TOTALCD < TimeStamp || !alive)
{
Main.AbilityCD.Remove(playerId);
SendRPC(CustomRPC.SyncAbilityCD, 3, playerId);
}
if (!player.IsModClient() && timer.TOTALCD - (now - timer.START_TIMESTAMP) <= 60) NotifyRoles(SpecifySeer: player, SpecifyTarget: player);
@@ -1434,7 +1443,7 @@ static class FixedUpdatePatch
{
if (GameStates.IsLobby)
{
if (Main.PlayerVersion.TryGetValue(player.PlayerId, out var ver))
if (Main.PlayerVersion.TryGetValue(playerId, out var ver))
{
if (Main.ForkId != ver.forkId)
__instance.cosmetics.nameText.text = $"<color=#ff0000><size=1.2>{ver.forkId}</size>\n{__instance?.name}</color>";
+1 -1
View File
@@ -2356,7 +2356,7 @@
"LoadingHint.25": "Meeting not ending when everyone voted?\nPress F6 to end the meeting while also counting the votes!",
"LoadingHint.26": "Do you have a friend who thinks they understand everything, and you want to prove them wrong?\nTurn on the Chemist role and see their reaction!",
"LoadingHint.27": "The Dev's favorite roles are:\nEcho, Penguin, Rift Maker, Bubble, Evolver, Rogue, Vengeance....\nand basically all crewmate roles :D",
"LoadingHint.28": "Did you know?\nEHR has 7 different game modes! Try them out!\nSwitch game modes using the ⇄ button next to the huge title in the top left of the settings menu!",
"LoadingHint.28": "Did you know?\nEHR has 9 different game modes! Try them out!\nSwitch game modes using the ⇄ button next to the huge title in the top left of the settings menu!",
"LoadingHint.29": "Did you know?\nEHR has a unique game mode for expert gamers called Stop And Go!\nGive it a try after this game!",
"LoadingHint.30": "Getting Crewmate over and over again? Didn't get to kill for the last half an hour?\nUnleash your bloodthirst in our Free For All game mode!",
"LoadingHint.31": "Did you know?\nEHR has a custom Hide And Seek game mode with 12 special roles dedicated for this playstyle!",
+3 -2
View File
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using EHR.Modules;
using Hazel;
namespace EHR.Crewmate
{
@@ -19,7 +20,7 @@ namespace EHR.Crewmate
public override void SetupCustomOption()
{
StartSetup(647250, TabGroup.CrewmateRoles, CustomRoles.Grappler)
StartSetup(647250)
.AutoSetupOption(ref AbilityUseLimit, 0, new IntegerValueRule(0, 20, 1), OptionFormat.Times)
.AutoSetupOption(ref AbilityUseGainWithEachTaskCompleted, 0.3f, new FloatValueRule(0f, 5f, 0.05f), OptionFormat.Times)
.AutoSetupOption(ref AbilityChargesWhenFinishedTasks, 0.2f, new FloatValueRule(0f, 5f, 0.05f), OptionFormat.Times);
@@ -56,7 +57,7 @@ namespace EHR.Crewmate
return base.GetProgressText(playerId, comms) + (InUse ? "<#00ff00>\u271a</color>" : string.Empty);
}
public void ReceiveRPC(Hazel.MessageReader reader)
public void ReceiveRPC(MessageReader reader)
{
InUse = reader.ReadBoolean();
}
+1 -1
View File
@@ -15,7 +15,7 @@ namespace EHR.Crewmate
public override void SetupCustomOption()
{
StartSetup(647450, TabGroup.CrewmateRoles, CustomRoles.Journalist);
StartSetup(647450);
}
public override void Init()
+1 -1
View File
@@ -24,7 +24,7 @@ namespace EHR.Crewmate
public override void SetupCustomOption()
{
StartSetup(647950, TabGroup.CrewmateRoles, CustomRoles.Negotiator)
StartSetup(647950)
.AutoSetupOption(ref LowVision, 0.4f, new FloatValueRule(0f, 1f, 0.05f), OptionFormat.Multiplier)
.AutoSetupOption(ref LowSpeed, 0.9f, new FloatValueRule(0.1f, 2f, 0.1f), OptionFormat.Multiplier)
.AutoSetupOption(ref AbilityUseLimit, 0, new IntegerValueRule(0, 20, 1), OptionFormat.Times)
+1 -1
View File
@@ -21,7 +21,7 @@ namespace EHR.Impostor
public override void SetupCustomOption()
{
StartSetup(649250, TabGroup.ImpostorRoles, CustomRoles.Assumer)
StartSetup(649250)
.AutoSetupOption(ref VoteReceiverDies, false)
.AutoSetupOption(ref MinPlayersToAssume, 6, new IntegerValueRule(1, 15, 1), OptionFormat.Players)
.AutoSetupOption(ref CanKill, true)
+1 -1
View File
@@ -25,7 +25,7 @@ namespace EHR.Impostor
public override void SetupCustomOption()
{
StartSetup(647550, TabGroup.ImpostorRoles, CustomRoles.Hypnotist)
StartSetup(647550)
.AutoSetupOption(ref AbilityCooldown, 30, new IntegerValueRule(0, 60, 1), OptionFormat.Seconds)
.AutoSetupOption(ref AbilityDuration, 15, new IntegerValueRule(0, 30, 1), OptionFormat.Seconds)
.AutoSetupOption(ref AbilityUseLimit, 1, new IntegerValueRule(0, 5, 1), OptionFormat.Times)
+7 -4
View File
@@ -32,7 +32,7 @@ namespace EHR.Neutral
public override void SetupCustomOption()
{
StartSetup(648350, TabGroup.NeutralRoles, CustomRoles.Gaslighter)
StartSetup(648350)
.AutoSetupOption(ref KillCooldown, 22.5f, new FloatValueRule(0f, 120f, 0.5f), OptionFormat.Seconds)
.AutoSetupOption(ref WinCondition, 0, WinConditionOptions)
.AutoSetupOption(ref CycleRepeats, false);
@@ -55,6 +55,8 @@ namespace EHR.Neutral
CycleFinished = false;
}
public override bool CanUseKillButton(PlayerControl pc) => pc.IsAlive();
public override void SetKillCooldown(byte id)
{
Main.AllPlayerKillCooldown[id] = CurrentRound switch
@@ -112,15 +114,16 @@ namespace EHR.Neutral
CurrentRound++;
}
var pc = GaslighterId.GetPlayer();
float limit = CurrentRound switch
{
Round.Knight => Monarch.KnightMax.GetFloat(),
Round.Shield => Medic.SkillLimit,
_ => 0
_ => float.NaN
};
GaslighterId.SetAbilityUseLimit(limit);
if (!float.IsNaN(limit)) GaslighterId.SetAbilityUseLimit(limit);
else pc?.RemoveAbilityCD();
var pc = GaslighterId.GetPlayer();
pc?.ResetKillCooldown();
pc?.Notify(Translator.GetString($"Gaslighter.{CurrentRound}"));
}
+1
View File
@@ -111,6 +111,7 @@ namespace EHR.Neutral
}
Main.AbilityCD.Remove(killer.PlayerId);
Utils.SendRPC(CustomRPC.SyncAbilityCD, 3, killer.PlayerId);
killer.SyncSettings();
// ------------------------------------------------------------------------------------------
+1 -1
View File
@@ -187,7 +187,7 @@ namespace EHR.Neutral
if (seer.IsModClient() && !hud && self) return string.Empty;
if (self) return Translator.GetString(simon.DoMode ? "SimonDoMode" : "SimonDontMode");
else if (simon.MarkedPlayers.TryGetValue(target.PlayerId, out var value)) return Translator.GetString(GetNotify(value.Instruction, value.DoAction, true));
if (simon.MarkedPlayers.TryGetValue(target.PlayerId, out var value)) return Translator.GetString(GetNotify(value.Instruction, value.DoAction, true));
return string.Empty;
}
+1 -1
View File
@@ -22,7 +22,7 @@ namespace EHR.Neutral
public override void SetupCustomOption()
{
StartSetup(646950, TabGroup.NeutralRoles, CustomRoles.Tank)
StartSetup(646950)
.AutoSetupOption(ref Speed, 0.7f, new FloatValueRule(0.1f, 3f, 0.1f), OptionFormat.Multiplier)
.AutoSetupOption(ref CanBeGuessed, false)
.AutoSetupOption(ref CanBeKilled, true)
+2 -3
View File
@@ -13,17 +13,16 @@ namespace EHR.Neutral
private static OptionItem VentCooldown;
private static OptionItem MaxInVentTime;
private static readonly Dictionary<SystemTypes, OptionItem> PointGains = [];
private bool fixedSabotage;
public bool IsWon;
private PlayerControl TechnicianPC;
public override bool IsEnable => On;
public override void SetupCustomOption()
{
StartSetup(646950, TabGroup.NeutralRoles, CustomRoles.Technician)
StartSetup(646450)
.AutoSetupOption(ref WinsAlone, false)
.AutoSetupOption(ref RequiredPoints, 5, new IntegerValueRule(1, 50, 1))
.AutoSetupOption(ref CanVent, false)
+7 -1
View File
@@ -194,8 +194,14 @@ namespace EHR
}
// Option setup simplifier
protected static OptionSetupHandler StartSetup(int id, TabGroup tab, CustomRoles role)
protected OptionSetupHandler StartSetup(int id)
{
var role = Enum.Parse<CustomRoles>(this.GetType().Name, true);
var tab = TabGroup.OtherRoles;
if (role.IsImpostor()) tab = TabGroup.ImpostorRoles;
else if (role.IsNeutral(check: true)) tab = TabGroup.NeutralRoles;
else if (role.IsCrewmate()) tab = TabGroup.CrewmateRoles;
Options.SetupRoleOptions(id++, tab, role);
return new(++id, tab, role);
}