diff --git a/Roles/Neutral/Romantic.cs b/Roles/Neutral/Romantic.cs index a868db9e75..396ef2c593 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 = []; @@ -238,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() && x is not CustomRoles.Soulless and not CustomRoles.Egoist && !pc.Is(x), x => pc.RpcSetCustomRole(x)); + } ChangeRole(player); } private static void ChangeRole(PlayerControl player) @@ -260,22 +272,52 @@ private static void ChangeRole(PlayerControl player) pc.RpcMurderPlayer(pc); return; } - if (player.GetCustomRole().IsImpostorTeamV3()) + if (player.GetCustomRole().IsNE() || player.GetCustomRole().IsNC()) + { + Logger.Info($"Neutral Romantic Partner Died => Changing {pc.GetNameWithRole()} to Ruthless Romantic", "Romantic"); + pc.GetRoleClass()?.OnRemove(pc.PlayerId); + 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"); + 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"); + Logger.Info($"NK/NA/Coven/Taskless Crew Romantic Partner Died => Changing {pc.GetNameWithRole()} to {player.GetNameWithRole().RemoveHtmlTags()}", "Romantic"); pc.GetRoleClass()?.OnRemove(pc.PlayerId); - pc.RpcSetCustomRole(CustomRoles.RuthlessRomantic); - pc.GetRoleClass().OnAdd(pc.PlayerId); + pc.RpcChangeRoleBasis(player.GetCustomRole()); + pc.RpcSetCustomRole(player.GetCustomRole()); + pc.GetRoleClass()?.OnAdd(pc.PlayerId); Utils.NotifyRoles(SpecifyTarget: pc); pc.ResetKillCooldown(); pc.SetKillCooldown(); @@ -284,7 +326,7 @@ 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 //if no killer || Main.PlayerStates[player.PlayerId].deathReason == PlayerState.DeathReason.Vote //or if partner is ejected @@ -292,6 +334,7 @@ private static void ChangeRole(PlayerControl player) || !killer.IsAlive()) //or if killer is dead,romantic will become ruthless romantic { pc.GetRoleClass()?.OnRemove(pc.PlayerId); + 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"); @@ -301,6 +344,7 @@ private static void ChangeRole(PlayerControl player) VengefulTargetId = killer.PlayerId; pc.GetRoleClass()?.OnRemove(pc.PlayerId); + pc.RpcChangeRoleBasis(CustomRoles.VengefulRomantic); pc.RpcSetCustomRole(CustomRoles.VengefulRomantic); pc.GetRoleClass().OnAdd(pc.PlayerId); if (pc.GetRoleClass() is VengefulRomantic VR) VR.SendRPC(pc.PlayerId); @@ -316,7 +360,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; @@ -395,14 +438,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();