mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-20 01:46:25 +00:00
fix core name bug & solo pvp timer stops when everyone is waiting for revival
This commit is contained in:
1 parent
48cb17e7ba
commit
6b40ca1920
8 files changed
+44
-27
No files matched your search
+31
-15
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using EHR.Modules;
|
||||
using Hazel;
|
||||
@@ -18,7 +19,8 @@ internal static class SoloPVP
|
||||
public static Dictionary<byte, float> PlayerDF = [];
|
||||
|
||||
public static Dictionary<byte, int> PlayerScore = [];
|
||||
public static int RoundTime;
|
||||
public static Stopwatch RoundTimer;
|
||||
public static int GameTime = 180;
|
||||
|
||||
private static readonly Dictionary<byte, (string Text, long RemoveTimeStamp)> NameNotify = [];
|
||||
|
||||
@@ -99,8 +101,14 @@ internal static class SoloPVP
|
||||
LastCountdownTime = [];
|
||||
BackCountdown = [];
|
||||
PlayerScore = [];
|
||||
RoundTime = SoloPVP_GameTime.GetInt() + 8;
|
||||
Utils.SendRPC(CustomRPC.SoloPVPSync, 1, RoundTime);
|
||||
GameTime = SoloPVP_GameTime.GetInt();
|
||||
RoundTimer = Stopwatch.StartNew();
|
||||
LateTask.New(() =>
|
||||
{
|
||||
if (RoundTimer.IsRunning)
|
||||
RoundTimer.Restart();
|
||||
}, 3f);
|
||||
Utils.SendRPC(CustomRPC.SoloPVPSync, 1);
|
||||
|
||||
foreach (PlayerControl pc in Main.EnumerateAlivePlayerControls())
|
||||
{
|
||||
@@ -175,8 +183,6 @@ internal static class SoloPVP
|
||||
|
||||
public static void GetNameNotify(PlayerControl player, ref string name)
|
||||
{
|
||||
if (Options.CurrentGameMode != CustomGameMode.SoloPVP || player == null) return;
|
||||
|
||||
if (BackCountdown.TryGetValue(player.PlayerId, out int value))
|
||||
{
|
||||
name = string.Format(Translator.GetString("SoloPVP_BackCountDown"), value);
|
||||
@@ -202,17 +208,13 @@ internal static class SoloPVP
|
||||
|
||||
public static string GetHudText()
|
||||
{
|
||||
if (RoundTime == 60)
|
||||
{
|
||||
SoundManager.Instance.PlaySound(HudManager.Instance.LobbyTimerExtensionUI.lobbyTimerPopUpSound, false);
|
||||
Utils.FlashColor(new(1f, 1f, 0f, 0.4f), 1.4f);
|
||||
}
|
||||
return $"{RoundTime / 60:00}:{RoundTime % 60:00}";
|
||||
int roundTime = GameTime - (int)RoundTimer.Elapsed.TotalSeconds;
|
||||
return $"{roundTime / 60:00}:{roundTime % 60:00}";
|
||||
}
|
||||
|
||||
public static void OnPlayerAttack(PlayerControl killer, PlayerControl target)
|
||||
{
|
||||
if (killer == null || target == null || Options.CurrentGameMode != CustomGameMode.SoloPVP || !Main.IntroDestroyed) return;
|
||||
if (!Main.IntroDestroyed) return;
|
||||
|
||||
if (!killer.SoloAlive() || !target.SoloAlive() || target.inVent || target.MyPhysics.Animations.IsPlayingEnterVentAnimation()) return;
|
||||
|
||||
@@ -228,7 +230,7 @@ internal static class SoloPVP
|
||||
LastHurt[target.PlayerId] = Utils.TimeStamp;
|
||||
|
||||
float kcd = SoloPVP_ATKCooldown.GetFloat();
|
||||
if (killer.IsHost()) kcd += Math.Max(0.5f, Utils.CalculatePingDelay());
|
||||
if (killer.AmOwner) kcd += Math.Max(0.5f, Utils.CalculatePingDelay());
|
||||
killer.SetKillCooldown(kcd, target);
|
||||
|
||||
RPC.PlaySoundRPC(killer.PlayerId, Sounds.KillSound);
|
||||
@@ -333,8 +335,22 @@ internal static class SoloPVP
|
||||
if (LastFixedUpdate == now) return;
|
||||
LastFixedUpdate = now;
|
||||
|
||||
RoundTime--;
|
||||
Utils.SendRPC(CustomRPC.SoloPVPSync, 1, RoundTime);
|
||||
if (Main.AllAlivePlayerControls.Count <= 1)
|
||||
{
|
||||
if (ExtendedPlayerControl.TempExiled.Count == 0)
|
||||
{
|
||||
RoundTimer.Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
// apart from 1 player, everyone is waiting for revival.... stop the timer temporarily
|
||||
RoundTimer.Stop();
|
||||
}
|
||||
else if (!RoundTimer.IsRunning)
|
||||
{
|
||||
// resume the timer
|
||||
RoundTimer.Start();
|
||||
}
|
||||
|
||||
Utils.NotifyRoles(SendOption: SendOption.None);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace EHR
|
||||
|
||||
try
|
||||
{
|
||||
if (playerControl != null)
|
||||
if (playerControl)
|
||||
{
|
||||
MessageWriter writer = MessageWriter.Get(SendOption.Reliable);
|
||||
writer.StartMessage(5);
|
||||
|
||||
@@ -1206,7 +1206,7 @@ internal static class CustomRolesHelper
|
||||
CustomRoles.Bait when pc.Is(CustomRoles.Beartrap) => false,
|
||||
CustomRoles.Beartrap when pc.Is(CustomRoles.Bait) => false,
|
||||
CustomRoles.Schizophrenic when pc.Is(CustomRoles.Dictator) => false,
|
||||
CustomRoles.Swift when pc.GetCustomRole() is CustomRoles.Swooper or CustomRoles.Vampire or CustomRoles.Scavenger or CustomRoles.Puppeteer or CustomRoles.Warlock or CustomRoles.Consigliere or CustomRoles.Witch or CustomRoles.Nemesis => false,
|
||||
CustomRoles.Swift when pc.GetCustomRole() is CustomRoles.Swooper or CustomRoles.Vampire or CustomRoles.Scavenger or CustomRoles.Puppeteer or CustomRoles.Warlock or CustomRoles.Consigliere or CustomRoles.Witch or CustomRoles.Nemesis or CustomRoles.Viper or CustomRoles.ViperEHR => false,
|
||||
CustomRoles.Reach when pc.GetCustomRole() is CustomRoles.Mafioso or CustomRoles.Evolver or CustomRoles.Berserker => false,
|
||||
CustomRoles.Beartrap when pc.Is(CustomRoles.GuardianAngelEHR) => false,
|
||||
CustomRoles.Reach when pc.GetRoleTypes() is not (RoleTypes.Impostor or RoleTypes.Phantom or RoleTypes.Shapeshifter or RoleTypes.Viper) => false,
|
||||
|
||||
+2
-2
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using AmongUs.GameOptions;
|
||||
using EHR.Gamemodes;
|
||||
@@ -1233,8 +1234,7 @@ internal static class RPCHandlerPatch
|
||||
switch (reader.ReadPackedInt32())
|
||||
{
|
||||
case 1:
|
||||
int roundTime = reader.ReadPackedInt32();
|
||||
SoloPVP.RoundTime = roundTime;
|
||||
SoloPVP.RoundTimer = Stopwatch.StartNew();
|
||||
break;
|
||||
case 2:
|
||||
SoloPVP.PlayerScore[reader.ReadByte()] = reader.ReadPackedInt32();
|
||||
|
||||
+1
-1
@@ -3100,7 +3100,7 @@ public static class Utils
|
||||
|
||||
string targetRoleText =
|
||||
KnowsTargetRole(seer, target)
|
||||
? $"<size={fontSize}>{target.GetDisplayRoleName(seeTargetBetrayalAddons: shouldSeeTargetAddons)}{GetProgressText(target)}</size>\r\n"
|
||||
? $"<size={fontSize}>{GetRoleText(seer.PlayerId, target.PlayerId, seeTargetBetrayalAddons: shouldSeeTargetAddons)}{GetProgressText(target)}</size>\r\n"
|
||||
: string.Empty;
|
||||
|
||||
if (IsRevivingRoleAlive() && Main.DiedThisRound.Contains(seer.PlayerId))
|
||||
|
||||
@@ -791,7 +791,7 @@ internal static class GameEndChecker
|
||||
{
|
||||
reason = GameOverReason.ImpostorsByKill;
|
||||
|
||||
if (SoloPVP.RoundTime > 0) return false;
|
||||
if (SoloPVP.RoundTimer.IsRunning && SoloPVP.RoundTimer.Elapsed.TotalSeconds < SoloPVP.GameTime) return false;
|
||||
|
||||
HashSet<byte> winners = [Main.EnumeratePlayerControls().FirstOrDefault(x => !x.Is(CustomRoles.GM) && SoloPVP.GetRankFromScore(x.PlayerId) == 1)?.PlayerId ?? Main.EnumerateAlivePlayerControls().First().PlayerId];
|
||||
int kills = SoloPVP.PlayerScore[winners.First()];
|
||||
|
||||
@@ -326,7 +326,7 @@
|
||||
"AdrenalineCannotCallEmergencyMeeting": "As the <#ffff00>Adrenaline</color>, you cannot call emergency meetings currently",
|
||||
"Adventurer": "Adventurer",
|
||||
"AdventurerInfo": "Collect Resources to Perform Actions",
|
||||
"AdventurerInfoLong": "(Crewmates):\\nAs the Adventurer, you can collect resources listed below and craft them into weapons if you have the required amount of materials for it.<size=70%>\\n\\n<u><b>Resources (and how to obtain them):</b></u>\\n- ❖ (Complete a Task)\\n- Θ (Players Leave This Behind<sup>*</sup>)\\n- ♳ (Dead Bodies<sup>*</sup>)\\n- ⁂ (Shapeshift Skins<sup>*</sup>)\\n- ☀ (Fix Lights)\\n- ○ (Found in Groups<sup>*</sup>)\\n<size=50%><sup>*</sup> When this resource is available somewhere, you get an arrow pointing towards that location. (Except dead bodies.) Go there to collect it.</size>\\n\\n<u><b>Weapons (and their ingredients):</b></u>\\n- Gun (1 ♳ + 1 ❖) (Kill nearest player)\\n- Shield (3 ❖) (Gives nearest player a 1-time shield)\\n- Lantern (1 ☀ + 1 ❖) (Increases crewmates' vision for some time)\\n- Portal (2 Θ) (Swaps you with a random player)\\n- Wrench (1 ☀ + 2 ❖) (Clears the current sabotage)\\n- Proxy (2 ○ + 1 ❖) (Gives you +1 vote in the next meeting)\\n- Prediction (1 ♳ + 2 ⁂ + 1 ❖) (Reveals the nearest player's role)\\n- RNG (2 Θ + 2 ❖) (Makes a random weapon)</size>\\n\\nTo use your weapons, pet.",
|
||||
"AdventurerInfoLong": "(Crewmates):\\nAs the Adventurer, you can collect resources listed below and craft them into weapons if you have the required amount of materials for it.<size=70%>\\n\\n<u><b>Resources (and how to obtain them):</b></u>\\n- ❖ (Complete a Task)\\n- Θ (Players Leave This Behind<sup>*</sup>)\\n- ♳ (Dead Bodies<sup>*</sup>)\\n- ⁂ (Shapeshift Skins<sup>*</sup>)\\n- ☀ (Fix Lights)\\n- ○ (Found in Groups<sup>*</sup>)\\n<sup>*</sup> When this resource is available somewhere, you get an arrow pointing towards that location. (Except dead bodies.) Go there to collect it.\\n\\n<u><b>Weapons (and their ingredients):</b></u>\\n- Gun (1 ♳ + 1 ❖) (Kill nearest player)\\n- Shield (3 ❖) (Gives nearest player a 1-time shield)\\n- Lantern (1 ☀ + 1 ❖) (Increases crewmates' vision for some time)\\n- Portal (2 Θ) (Swaps you with a random player)\\n- Wrench (1 ☀ + 2 ❖) (Clears the current sabotage)\\n- Proxy (2 ○ + 1 ❖) (Gives you +1 vote in the next meeting)\\n- Prediction (1 ♳ + 2 ⁂ + 1 ❖) (Reveals the nearest player's role)\\n- RNG (2 Θ + 2 ❖) (Makes a random weapon)</size>\\n\\nTo use your weapons, pet.",
|
||||
"AdventurerFound": "Found Resource: {0}",
|
||||
"AdventurerGun.Gun": "Gun",
|
||||
"AdventurerGun.Lantern": "Lantern",
|
||||
@@ -576,7 +576,7 @@
|
||||
"CrusaderSkillLimit": "Maximum Crusades",
|
||||
"Dad": "Dad",
|
||||
"DadInfo": "You're that iconic dad....",
|
||||
"DadInfoLong": "(Crewmates):\\nAs the dad, your life depends on alcohol. When you get attacked or voted out, you survive, but your alcohol decreases. Alcohol also decreases slowly over time. To increase your alcohol level, you have to get money from completing tasks and go to a random selected vent to buy a beer. Beer increases your alcohol level. When you finish all your tasks, you get new tasks, but you don't have to do them for task win. You don't know how much alcohol you have at the time. You only see warning when your alcohol level is low. Alcohol is counted in ‰.\\n\\nYou also have some abilities that are unlocked if you have enough alcohol. To use ability, switch between them using pet button and use selected one by venting:\\n<size=60%>- Going for milk: You go for milk. When you use it, you get teleported outside the map. You also can't discuss or vote in meetings. You can do nothing. You will come back with milk after exactly 10 years. When you come back, crewmates instantly win. When you use it, everyone will be informed about it.\\n- Super vision: You will have max vision for some time.\\n- Sniffing: You get arrows pointing to existing dead bodies after using it. Arrows only update when you sniff again.\\n- Sleep: During sleep people can't interact with you, but you can't see or move. During sleep you also cannot use any abilities and your alcohol is stable. You wake up when a meeting starts.\\n- Rage: You kill next person you see.\\n- Giving drink: You give all nearby players a drink. Every of these players will say their role in meeting with a chance of an incorrect result.\\n- Becoming god of alcohol: Resets your alcohol to 1‰, but your alcohol will increase instead of decreasing from now on.</size>\\n<size=70%>Every ability (except going for milk) will reduce your alcohol after using it.\\nIf your alcohol reaches 0‰, you die.\\nAlso, you see which abilities you can use. It can give you some more information about your alcohol level.\\nTo make this role balanced, when someone attacks you, you lose alcohol after some time and not instantly.</size>",
|
||||
"DadInfoLong": "(Crewmates):\\nAs the dad, your life depends on alcohol. When you get attacked or voted out, you survive, but your alcohol decreases. Alcohol also decreases slowly over time. To increase your alcohol level, you have to get money from completing tasks and go to a random selected vent to buy a beer. Beer increases your alcohol level. When you finish all your tasks, you get new tasks, but you don't have to do them for task win. You don't know how much alcohol you have at the time. You only see warning when your alcohol level is low. Alcohol is counted in ‰.\\n\\nYou also have some abilities that are unlocked if you have enough alcohol. To use ability, switch between them using pet button and use selected one by venting:\\n<size=60%>- Going for milk: You go for milk. When you use it, you get teleported outside the map. You also can't discuss or vote in meetings. You can do nothing. You will come back with milk after exactly 10 years. When you come back, crewmates instantly win. When you use it, everyone will be informed about it.\\n- Super vision: You will have max vision for some time.\\n- Sniffing: You get arrows pointing to existing dead bodies after using it. Arrows only update when you sniff again.\\n- Sleep: During sleep people can't interact with you, but you can't see or move. During sleep you also cannot use any abilities and your alcohol is stable. You wake up when a meeting starts.\\n- Rage: You kill next person you see.\\n- Giving drink: You give all nearby players a drink. Every of these players will say their role in meeting with a chance of an incorrect result.\\n- Becoming god of alcohol: Resets your alcohol to 1‰, but your alcohol will increase instead of decreasing from now on.\\nEvery ability (except going for milk) will reduce your alcohol after using it.\\nIf your alcohol reaches 0‰, you die.\\nAlso, you see which abilities you can use. It can give you some more information about your alcohol level.\\nTo make this role balanced, when someone attacks you, you lose alcohol after some time and not instantly.</size>",
|
||||
"Dad.Ability.BecomeGodOfAlcohol": "Becoming God Of Alcohol",
|
||||
"Dad.Ability.GiveDrink": "Giving Drink",
|
||||
"Dad.Ability.GoForMilk": "Going For Milk",
|
||||
@@ -985,7 +985,7 @@
|
||||
"notifyJailedOnMeeting": "Notify Jailed player when meeting starts",
|
||||
"Journalist": "Journalist",
|
||||
"JournalistInfo": "Write Down Notes",
|
||||
"JournalistInfoLong": "(Crewmates):\\nAs the Journalist, you can write down notes. When you die, all players will see your notes in the next meeting.\\n\\nCommand: <b>/cmd note {add/remove/clear/view} [value]</b><size=80%>\\n- <b>add</b>: Add a note specified in [value]\\n- <b>remove</b>: Remove a note. Provide the index of it in [value] or leave [value] blank to remove the last note. You can see the indexes of your notes by using <b>/cmd note view</b>\\n- <b>clear</b>: Clear all notes (leave [value] blank)\\n- <b>view</b>: View all notes and their indexes (leave [value] blank)</size>\\n\\n<size=70%>Example uses:\\n<b>/cmd note add I think blue and yellow are Lovers</b>\\n<b>/cmd note remove 2</b>\\n<b>/cmd note clear</b>\\n<b>/cmd note view</b></size>",
|
||||
"JournalistInfoLong": "(Crewmates):\\nAs the Journalist, you can write down notes. When you die, all players will see your notes in the next meeting.\\n\\nCommand: <b>/cmd note {add/remove/clear/view} [value]</b><size=80%>\\n- <b>add</b>: Add a note specified in [value]\\n- <b>remove</b>: Remove a note. Provide the index of it in [value] or leave [value] blank to remove the last note. You can see the indexes of your notes by using <b>/cmd note view</b>\\n- <b>clear</b>: Clear all notes (leave [value] blank)\\n- <b>view</b>: View all notes and their indexes (leave [value] blank)\\n\\nExample uses:\\n<b>/cmd note add I think blue and yellow are Lovers</b>\\n<b>/cmd note remove 2</b>\\n<b>/cmd note clear</b>\\n<b>/cmd note view</b></size>",
|
||||
"Journalist.CommandUsage": "Usage: <b>/cmd note {add/remove/clear/view} [value]</b>",
|
||||
"JournalistError.ArgumentOutOfRange": "The index you provided is out of range. Use <b>/cmd note view</b> to see the indexes of your notes.",
|
||||
"JournalistError.IndexOutOfRange": "You didn't provide enough arguments.",
|
||||
@@ -1731,7 +1731,7 @@
|
||||
"ClockBlocker.MaxEmergencyCooldown": "Maximum Emergency Cooldown",
|
||||
"Commander": "Commander",
|
||||
"CommanderInfo": "Command your team",
|
||||
"CommanderInfoLong": "(Impostors):\\nAs the Commander, you can switch between 6 modes by venting/petting. You can execute the selected action by shapeshifting.<size=70%>\\n\\n<b><u>Mark:</u></b> Marks your shapeshift target with a unique color visible to all impostors. Use this to command them to kill that player!\\n\\n<b><u>Whistle:</u></b> This tells all or 1 specific<sup>*</sup> impostor(s) to come to you and gives them (each) an arrow pointing towards you.\\n\\n<b><u>Kill Anyone:</u></b> Notifies all or 1 specific<sup>*</sup> impostor(s) to kill anyone.\\n\\n<b><u>Leave Player Alive:</u></b> Shapeshifting into a crewmate marks that player with a unique color and text telling other impostors to not kill that player. Shapeshifting into an impostor tells that impostor to not kill anyone.\\n\\n<b><u>Don't Sabotage:</u></b> Notifies all impostors to not call any sabotage.\\n\\n<b><u>Use Ability:</u></b> Notifies all or 1 specific<sup>*</sup> impostor(s) to use their ability.\\n\\n<size=60%><sup>*</sup> If you shapeshift into an impostor, the action executes specifically and only on them.</size></size>",
|
||||
"CommanderInfoLong": "(Impostors):\\nAs the Commander, you can switch between 6 modes by venting/petting. You can execute the selected action by shapeshifting.<size=70%>\\n\\n<b><u>Mark:</u></b> Marks your shapeshift target with a unique color visible to all impostors. Use this to command them to kill that player!\\n\\n<b><u>Whistle:</u></b> This tells all or 1 specific<sup>*</sup> impostor(s) to come to you and gives them (each) an arrow pointing towards you.\\n\\n<b><u>Kill Anyone:</u></b> Notifies all or 1 specific<sup>*</sup> impostor(s) to kill anyone.\\n\\n<b><u>Leave Player Alive:</u></b> Shapeshifting into a crewmate marks that player with a unique color and text telling other impostors to not kill that player. Shapeshifting into an impostor tells that impostor to not kill anyone.\\n\\n<b><u>Don't Sabotage:</u></b> Notifies all impostors to not call any sabotage.\\n\\n<b><u>Use Ability:</u></b> Notifies all or 1 specific<sup>*</sup> impostor(s) to use their ability.\\n\\n<sup>*</sup> If you shapeshift into an impostor, the action executes specifically and only on them.</size>",
|
||||
"CommanderDontKill": "<size=1.7>Don't kill this player</size>",
|
||||
"CommanderDontKillAnyoneNotify": "Commander wants you to not kill",
|
||||
"CommanderDontKillMarkMode": "Mark a Player to Leave Alive",
|
||||
@@ -2630,7 +2630,7 @@
|
||||
"FollowerMaxBetTimes": "Maximum Number of Follows",
|
||||
"Gaslighter": "Gaslighter",
|
||||
"GaslighterInfo": "Make others doubt their own memory",
|
||||
"GaslighterInfoLong": "(Neutrals):\\nAs the Gaslighter, you do different actions through your kill button every round.<size=80%>\\n\\nRound 1: Normal kills\\nRound 2: Knight players\\nRound 3: Curse players (like Witch)\\nRound 4: Shield players\\n\\n</size><size=90%>Then the cycle repeats, or you stay on normally killing until the end of the game depending on the settings.\\nSettings determine your win condition.</size>",
|
||||
"GaslighterInfoLong": "(Neutrals):\\nAs the Gaslighter, you do different actions through your kill button every round.\\n\\nRound 1: Normal kills\\nRound 2: Knight players\\nRound 3: Curse players (like Witch)\\nRound 4: Shield players\\n\\nThen the cycle repeats, or you stay on normally killing until the end of the game depending on the settings.\\nSettings determine your win condition.",
|
||||
"Gaslighter.Curse": "In this round, you <#ff00ff>curse players</color>",
|
||||
"Gaslighter.CycleRepeats": "Kill Button Actions Cycle Repeats",
|
||||
"Gaslighter.Kill": "In this round, you <#ff1919>kill normally</color>",
|
||||
|
||||
@@ -138,7 +138,8 @@ internal class Trapster : RoleBase
|
||||
{
|
||||
Vector2 location = player.Pos();
|
||||
TrapsterBody.Add(player.PlayerId);
|
||||
Utils.RpcCreateDeadBody(location, (byte)IRandom.Instance.Next(17), player);
|
||||
PlayerControl randomPlayer = Main.EnumerateAlivePlayerControls().Without(player).RandomElement();
|
||||
Utils.RpcCreateDeadBody(location, (byte)randomPlayer.CurrentOutfit.ColorId, randomPlayer);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user