From e80336d1b6597fbd45d01c63f00b6c497ef07b53 Mon Sep 17 00:00:00 2001 From: Bri-11 <4brianjr11@gmail.com> Date: Sat, 8 Feb 2025 10:22:12 -0500 Subject: [PATCH 1/6] Improve Romantic's conditions --- Roles/Neutral/Romantic.cs | 76 +++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index e00c13b337..ca28b56936 100644 --- a/Roles/Neutral/Romantic.cs +++ b/Roles/Neutral/Romantic.cs @@ -7,7 +7,6 @@ using static TOHE.Options; using static TOHE.Translator; - namespace TOHE.Roles.Neutral; internal class Romantic : RoleBase @@ -35,6 +34,14 @@ internal class Romantic : RoleBase public static OptionItem RuthlessKCD; public static OptionItem RuthlessCanVent; + private static readonly Dictionary ConvertingRolesAndAddons = new() + { + [CustomRoles.Cultist] = CustomRoles.Charmed, + [CustomRoles.Jackal] = CustomRoles.Sidekick, + [CustomRoles.Virus] = CustomRoles.Contagious, + [CustomRoles.Ritualist] = CustomRoles.Enchanted + }; + public static byte VengefulTargetId; private static readonly Dictionary BetTimes = []; public static readonly Dictionary BetPlayer = []; @@ -254,21 +261,57 @@ private static void ChangeRole(PlayerControl player) if (romantic == 0x73) return; var pc = Utils.GetPlayerById(romantic); if (pc == null) return; - if (player.GetCustomRole().IsImpostorTeamV3()) + if (player.GetRealKiller() == pc) { - Logger.Info($"Impostor Romantic Partner Died changing {pc.GetNameWithRole()} to Refugee", "Romantic"); + pc.SetDeathReason(PlayerState.DeathReason.FollowingSuicide); + pc.RpcMurderPlayer(pc); + return; + } + else if (player.GetCustomRole().IsNE() || player.GetCustomRole().IsNC()) + { + Logger.Info($"Neutral Romantic Partner Died => Changing {pc.GetNameWithRole()} to Ruthless Romantic", "Romantic"); + pc.RpcChangeRoleBasis(CustomRoles.RuthlessRomantic); + pc.RpcSetCustomRole(CustomRoles.RuthlessRomantic); + pc.GetRoleClass().OnAdd(pc.PlayerId); + Utils.NotifyRoles(SpecifyTarget: pc); + pc.ResetKillCooldown(); + pc.SetKillCooldown(); + } + else if (ConvertingRolesAndAddons.TryGetValue(player.GetCustomRole(), out var convertedRole)) + { + Logger.Info($"Converted Romantic Partner Died => Romantic becomes their ally {pc.GetNameWithRole()}", "Romantic"); + pc.GetRoleClass().OnRemove(pc.PlayerId); + pc.RpcChangeRoleBasis(convertedRole); + pc.RpcSetCustomRole(convertedRole); + pc.GetRoleClass().OnAdd(pc.PlayerId); + if (convertedRole.IsAdditionRole()) + { + pc.RpcChangeRoleBasis(CustomRoles.RuthlessRomantic); + pc.RpcSetCustomRole(CustomRoles.RuthlessRomantic); + pc.GetRoleClass().OnAdd(pc.PlayerId); + } + Utils.NotifyRoles(SpecifyTarget: pc); + pc.ResetKillCooldown(); + pc.SetKillCooldown(); + } + else if (player.GetCustomRole().IsImpostorTeamV3()) + { + Logger.Info($"Impostor Romantic Partner Died => Changing {pc.GetNameWithRole()} to Refugee", "Romantic"); pc.GetRoleClass()?.OnRemove(pc.PlayerId); + pc.RpcChangeRoleBasis(CustomRoles.Refugee); pc.RpcSetCustomRole(CustomRoles.Refugee); pc.GetRoleClass()?.OnAdd(pc.PlayerId); Utils.NotifyRoles(SpecifyTarget: pc); pc.ResetKillCooldown(); pc.SetKillCooldown(); } - else if (player.IsNeutralKiller()) + else if (player.GetCustomRole().IsNK() || player.GetCustomRole().IsNA() || player.GetCustomRole().IsCoven() || player.GetCustomRole().IsTasklessCrewmate()) { - Logger.Info($"Neutral Romantic Partner Died changing {pc.GetNameWithRole()} to Ruthless Romantic", "Romantic"); - pc.RpcSetCustomRole(CustomRoles.RuthlessRomantic); - pc.GetRoleClass().OnAdd(pc.PlayerId); + Logger.Info($"NK/NA/Coven/Taskless Crew Romantic Partner Died => Changing {pc.GetNameWithRole()} to {player.GetNameWithRole().RemoveHtmlTags()}", "Romantic"); + pc.GetRoleClass()?.OnRemove(pc.PlayerId); + pc.RpcChangeRoleBasis(player.GetCustomRole()); + pc.RpcSetCustomRole(player.GetCustomRole()); + pc.GetRoleClass()?.OnAdd(pc.PlayerId); Utils.NotifyRoles(SpecifyTarget: pc); pc.ResetKillCooldown(); pc.SetKillCooldown(); @@ -277,10 +320,14 @@ private static void ChangeRole(PlayerControl player) { _ = new LateTask(() => { - Logger.Info($"Crew/nnk Romantic Partner Died changing {pc.GetNameWithRole().RemoveHtmlTags()} to Vengeful romantic", "Romantic"); + Logger.Info($"Crew/NB Romantic Partner Died => Changing {pc.GetNameWithRole().RemoveHtmlTags()} to Vengeful Romantic", "Romantic"); var killer = player.GetRealKiller(); - if (killer == null) //change role to RuthlessRomantic if there is no killer for partner in game + if (killer == null //if no killer + || Main.PlayerStates[player.PlayerId].deathReason == PlayerState.DeathReason.Vote //or if partner is ejected + || killer == player //or if partner dies by suicide + || !killer.IsAlive()) //or if killer is dead,romantic will become ruthless romantic { + pc.RpcChangeRoleBasis(CustomRoles.RuthlessRomantic); pc.RpcSetCustomRole(CustomRoles.RuthlessRomantic); pc.GetRoleClass().OnAdd(pc.PlayerId); Logger.Info($"No real killer for {player.GetRealName().RemoveHtmlTags()}, role changed to ruthless romantic", "Romantic"); @@ -289,6 +336,7 @@ private static void ChangeRole(PlayerControl player) { VengefulTargetId = killer.PlayerId; + pc.RpcChangeRoleBasis(CustomRoles.VengefulRomantic); pc.RpcSetCustomRole(CustomRoles.VengefulRomantic); pc.GetRoleClass().OnAdd(pc.PlayerId); if (pc.GetRoleClass() is VengefulRomantic VR) VR.SendRPC(pc.PlayerId); @@ -304,7 +352,6 @@ private static void ChangeRole(PlayerControl player) internal class VengefulRomantic : RoleBase { - //===========================SETUP================================\\ public override CustomRoles Role => CustomRoles.VengefulRomantic; public override bool IsDesyncRole => new Romantic().IsDesyncRole; @@ -365,7 +412,7 @@ public override void ReceiveRPC(MessageReader reader, PlayerControl NaN) if (Target != byte.MaxValue) VengefulTarget.Add(PlayerId, Target); } - public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = Romantic.VengefulKCD.GetFloat(); + public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = hasKilledKiller ? 300f : Romantic.VengefulKCD.GetFloat(); public override bool CanUseImpostorVentButton(PlayerControl pc) => Romantic.VengefulCanVent.GetBool(); } @@ -377,14 +424,7 @@ internal class RuthlessRomantic : RoleBase public override CustomRoles ThisRoleBase => new Romantic().ThisRoleBase; public override Custom_RoleType ThisRoleType => Custom_RoleType.NeutralKilling; //==================================================================\\ - public override void Init() - { - - } - public override void Add(byte playerId) - { - } public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = Romantic.RuthlessKCD.GetFloat(); public override bool CanUseKillButton(PlayerControl pc) => true; public override bool CanUseImpostorVentButton(PlayerControl pc) => Romantic.RuthlessCanVent.GetBool(); From 57f67c5a8edc72a80af5092f767e1f120e1d9d58 Mon Sep 17 00:00:00 2001 From: Bri-11 <4brianjr11@gmail.com> Date: Thu, 13 Feb 2025 10:09:22 -0500 Subject: [PATCH 2/6] Update Romantic.cs --- Roles/Neutral/Romantic.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index ca28b56936..c4e79ae77b 100644 --- a/Roles/Neutral/Romantic.cs +++ b/Roles/Neutral/Romantic.cs @@ -245,6 +245,11 @@ public override void OnPlayerExiled(PlayerControl player, NetworkedPlayerInfo ex } private void OthersAfterPlayerDeathTask(PlayerControl killer, PlayerControl player, bool inMeeting) { + var pc = _Player; + if (player.IsAnySubRole(x => x.IsBetrayalAddonV2() && x is not CustomRoles.Soulless and not CustomRoles.Egoist)) + { + player.GetCustomSubRoles().DoIf(x => x.IsBetrayalAddonV2() && !pc.Is(x), x => pc.RpcSetCustomRole(x)); + } ChangeRole(player); } private static void ChangeRole(PlayerControl player) From fdc28e8c2b203161a7c2ea4b04b2a2786c5874d9 Mon Sep 17 00:00:00 2001 From: Bri-11 <4brianjr11@gmail.com> Date: Thu, 13 Feb 2025 10:16:44 -0500 Subject: [PATCH 3/6] Update Romantic.cs --- Roles/Neutral/Romantic.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index c4e79ae77b..a600474495 100644 --- a/Roles/Neutral/Romantic.cs +++ b/Roles/Neutral/Romantic.cs @@ -248,7 +248,7 @@ private void OthersAfterPlayerDeathTask(PlayerControl killer, PlayerControl play var pc = _Player; if (player.IsAnySubRole(x => x.IsBetrayalAddonV2() && x is not CustomRoles.Soulless and not CustomRoles.Egoist)) { - player.GetCustomSubRoles().DoIf(x => x.IsBetrayalAddonV2() && !pc.Is(x), x => pc.RpcSetCustomRole(x)); + player.GetCustomSubRoles().DoIf(x => x.IsBetrayalAddonV2() && x is not CustomRoles.Soulless and not CustomRoles.Egoist && !pc.Is(x), x => pc.RpcSetCustomRole(x)); } ChangeRole(player); } From 522fce038aac8b0b8ee920720ad3b3b657f46661 Mon Sep 17 00:00:00 2001 From: Bri-11 <4brianjr11@gmail.com> Date: Thu, 13 Feb 2025 10:49:31 -0500 Subject: [PATCH 4/6] Some changes --- Resources/Lang/en_US.json | 1 + Roles/Neutral/Romantic.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 17c0d34d5b..312de33878 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -3706,6 +3706,7 @@ "RomanticProtectCooldown": "Protect Cooldown", "RomanticBetPlayer": "You picked your partner", "RomanticBetOnYou": "The Romantic chose you as their Partner!", + "RomanticRoleChange": "Your partner died. Your role has been changed to {0}.", "VengefulKCD": "Vengeful Romantic Kill Cooldown", "VengefulCanVent": "Vengeful Romantic Can Vent", "RuthlessKCD": "Ruthless Romantic Kill Cooldown", diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index a600474495..21fb0ae826 100644 --- a/Roles/Neutral/Romantic.cs +++ b/Roles/Neutral/Romantic.cs @@ -1,5 +1,6 @@ using Hazel; using InnerNet; +using MS.Internal.Xml.XPath; using TOHE.Modules; using TOHE.Roles.Core; using TOHE.Roles.Double; @@ -352,6 +353,7 @@ private static void ChangeRole(PlayerControl player) pc.SetKillCooldown(); }, 0.2f, "Convert to Vengeful Romantic"); } + pc.Notify(string.Format(GetString("RomanticRoleChange"), pc.GetDisplayRoleAndSubName(pc, false))); } } @@ -417,7 +419,7 @@ public override void ReceiveRPC(MessageReader reader, PlayerControl NaN) if (Target != byte.MaxValue) VengefulTarget.Add(PlayerId, Target); } - public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = hasKilledKiller ? 300f : Romantic.VengefulKCD.GetFloat(); + public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = Romantic.VengefulKCD.GetFloat(); public override bool CanUseImpostorVentButton(PlayerControl pc) => Romantic.VengefulCanVent.GetBool(); } From 6af88a3d47f0559d7b060b8cfbd57a44f4da2b80 Mon Sep 17 00:00:00 2001 From: Bri-11 <4brianjr11@gmail.com> Date: Thu, 13 Feb 2025 11:16:34 -0500 Subject: [PATCH 5/6] Fixes --- Resources/Lang/en_US.json | 1 - Roles/Neutral/Romantic.cs | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Resources/Lang/en_US.json b/Resources/Lang/en_US.json index 312de33878..17c0d34d5b 100644 --- a/Resources/Lang/en_US.json +++ b/Resources/Lang/en_US.json @@ -3706,7 +3706,6 @@ "RomanticProtectCooldown": "Protect Cooldown", "RomanticBetPlayer": "You picked your partner", "RomanticBetOnYou": "The Romantic chose you as their Partner!", - "RomanticRoleChange": "Your partner died. Your role has been changed to {0}.", "VengefulKCD": "Vengeful Romantic Kill Cooldown", "VengefulCanVent": "Vengeful Romantic Can Vent", "RuthlessKCD": "Ruthless Romantic Kill Cooldown", diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index 21fb0ae826..1e49253c4e 100644 --- a/Roles/Neutral/Romantic.cs +++ b/Roles/Neutral/Romantic.cs @@ -2,6 +2,7 @@ using InnerNet; using MS.Internal.Xml.XPath; using TOHE.Modules; +using TOHE.Roles.AddOns.Impostor; using TOHE.Roles.Core; using TOHE.Roles.Double; using UnityEngine; @@ -266,14 +267,14 @@ private static void ChangeRole(PlayerControl player) }); if (romantic == 0x73) return; var pc = Utils.GetPlayerById(romantic); - if (pc == null) return; + if (pc == null || !pc.IsAlive()) return; if (player.GetRealKiller() == pc) { pc.SetDeathReason(PlayerState.DeathReason.FollowingSuicide); pc.RpcMurderPlayer(pc); return; } - else if (player.GetCustomRole().IsNE() || player.GetCustomRole().IsNC()) + if (player.GetCustomRole().IsNE() || player.GetCustomRole().IsNC()) { Logger.Info($"Neutral Romantic Partner Died => Changing {pc.GetNameWithRole()} to Ruthless Romantic", "Romantic"); pc.RpcChangeRoleBasis(CustomRoles.RuthlessRomantic); @@ -353,7 +354,6 @@ private static void ChangeRole(PlayerControl player) pc.SetKillCooldown(); }, 0.2f, "Convert to Vengeful Romantic"); } - pc.Notify(string.Format(GetString("RomanticRoleChange"), pc.GetDisplayRoleAndSubName(pc, false))); } } From ba34466a20ba16c881fcacd5dfa8f2b4e3b01dc0 Mon Sep 17 00:00:00 2001 From: Bri-11 <4brianjr11@gmail.com> Date: Thu, 13 Feb 2025 11:20:36 -0500 Subject: [PATCH 6/6] Remove --- Roles/Neutral/Romantic.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index 1e49253c4e..3138b6f737 100644 --- a/Roles/Neutral/Romantic.cs +++ b/Roles/Neutral/Romantic.cs @@ -1,8 +1,6 @@ using Hazel; using InnerNet; -using MS.Internal.Xml.XPath; using TOHE.Modules; -using TOHE.Roles.AddOns.Impostor; using TOHE.Roles.Core; using TOHE.Roles.Double; using UnityEngine;