Skip to content

Romantic Improvements #1475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 28 commits into
base: dev_2.3.0
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
03bbb2a
Merge pull request #26 from EnhancedNetwork/dev_2.2.0
Bri1101 Feb 3, 2025
e35832c
Merge pull request #27 from EnhancedNetwork/dev_2.2.0
Bri1101 Feb 5, 2025
e85cedf
Merge pull request #28 from EnhancedNetwork/dev_2.2.0
Bri1101 Feb 6, 2025
e80336d
Improve Romantic's conditions
Bri1101 Feb 8, 2025
31a8da0
Merge pull request #29 from EnhancedNetwork/dev_2.2.0
Bri1101 Feb 12, 2025
57f67c5
Update Romantic.cs
Bri1101 Feb 13, 2025
3991d66
Merge
Bri1101 Feb 13, 2025
fdc28e8
Update Romantic.cs
Bri1101 Feb 13, 2025
522fce0
Some changes
Bri1101 Feb 13, 2025
6af88a3
Fixes
Bri1101 Feb 13, 2025
ba34466
Remove
Bri1101 Feb 13, 2025
1cae5de
Merge pull request #30 from EnhancedNetwork/dev_2.2.0
Bri1101 Feb 15, 2025
8d013e4
Merge remote-tracking branch 'origin/main' into romantic
Bri1101 Feb 15, 2025
cd3fb67
Merge pull request #31 from EnhancedNetwork/dev_2.3.0
Bri1101 Feb 21, 2025
c907998
Merge remote-tracking branch 'origin/main' into romantic
Bri1101 Feb 21, 2025
ed04741
Merge pull request #32 from EnhancedNetwork/dev_2.3.0
Bri1101 Feb 23, 2025
676ed9c
Merge remote-tracking branch 'origin/main' into romantic
Bri1101 Feb 25, 2025
677c83c
Merge pull request #33 from EnhancedNetwork/dev_2.3.0
Bri1101 Mar 5, 2025
04f653f
Merge remote-tracking branch 'origin/main' into romantic
Bri1101 Mar 5, 2025
92b9ecb
Merge pull request #34 from EnhancedNetwork/dev_2.3.0
Bri1101 Mar 27, 2025
5a5a02f
Merge pull request #35 from EnhancedNetwork/dev_2.3.0
Bri1101 Apr 15, 2025
c422709
Merge
Bri1101 Apr 21, 2025
25eb89a
Merge pull request #36 from EnhancedNetwork/dev_2.3.0
Bri1101 Apr 26, 2025
f81ac8a
Merge remote-tracking branch 'origin/main' into romantic
Bri1101 Apr 30, 2025
e57e49a
Merge pull request #37 from EnhancedNetwork/dev_2.3.0
Bri1101 May 11, 2025
07aa7ad
Merge remote-tracking branch 'origin/main' into romantic
Bri1101 May 11, 2025
1868b23
Merge pull request #39 from EnhancedNetwork/dev_2.3.0
Bri1101 May 19, 2025
560aaed
Merge remote-tracking branch 'origin/main' into romantic
Bri1101 May 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 52 additions & 16 deletions Roles/Neutral/Romantic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using static TOHE.Options;
using static TOHE.Translator;


namespace TOHE.Roles.Neutral;

internal class Romantic : RoleBase
Expand Down Expand Up @@ -35,6 +34,14 @@ internal class Romantic : RoleBase
public static OptionItem RuthlessKCD;
public static OptionItem RuthlessCanVent;

private static readonly Dictionary<CustomRoles, CustomRoles> 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<byte, int> BetTimes = [];
public static readonly Dictionary<byte, byte> BetPlayer = [];
Expand Down Expand Up @@ -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)
Expand All @@ -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();
Expand All @@ -284,14 +326,15 @@ 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
|| killer == player //or if partner dies by suicide
|| !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");
Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down