Do some stuff with role basis changer (not finished)

This commit is contained in:
Gurge44 committed 2024-09-05 16:41:24 +02:00
1 parent c16f9481a1
commit 020a265e02
15 files changed
+42 -63

No files matched your search

+1 -1
View File
@@ -52,7 +52,7 @@ namespace EHR
if (TaskFinishWins.GetBool()) return;
CanKill.Add(pc.PlayerId);
// pc.ChangeRoleBasis(RoleTypes.Impostor);
pc.RpcChangeRoleBasis(CustomRoles.Runner);
pc.Notify(Translator.GetString("Speedrun_CompletedTasks"));
}
+3 -17
View File
@@ -29,8 +29,6 @@ internal static class CustomRolesHelper
CustomRoles.Evolver,
CustomRoles.ToiletMaster,
CustomRoles.Telekinetic,
CustomRoles.Necromancer,
CustomRoles.Deathknight,
CustomRoles.Dad,
CustomRoles.Whisperer,
@@ -42,13 +40,6 @@ internal static class CustomRolesHelper
CustomRoles.Dasher
];
// private static readonly List<CustomRoles> ExperimentalRoleList =
// [
// CustomRoles.Shifter
// ];
//
// public static bool IsExperimental(this CustomRoles role) => ExperimentalRoleList.Contains(role);
public static bool IsForOtherGameMode(this CustomRoles role) => HnSManager.AllHnSRoles.Contains(role) || role is
CustomRoles.KB_Normal or
CustomRoles.Killer or
@@ -274,6 +265,7 @@ internal static class CustomRolesHelper
CustomRoles.BallLightning => CustomRoles.Impostor,
CustomRoles.Greedier => CustomRoles.Impostor,
CustomRoles.Workaholic => CustomRoles.Engineer,
CustomRoles.Amnesiac => Amnesiac.RoleBasis.GetValue() == 0 ? CustomRoles.Engineer : CustomRoles.Crewmate,
CustomRoles.Speedrunner => CustomRoles.Crewmate,
CustomRoles.CursedWolf => CustomRoles.Impostor,
CustomRoles.Collector => CustomRoles.Crewmate,
@@ -301,7 +293,6 @@ internal static class CustomRolesHelper
CustomRoles.Deathpact => CustomRoles.Shapeshifter,
CustomRoles.Bloodhound => CustomRoles.Crewmate,
CustomRoles.Tracker => CustomRoles.Crewmate,
CustomRoles.Deathknight => CustomRoles.Crewmate,
CustomRoles.Merchant => CustomRoles.Crewmate,
CustomRoles.Lookout => CustomRoles.Crewmate,
CustomRoles.Guardian => CustomRoles.Crewmate,
@@ -388,7 +379,6 @@ internal static class CustomRolesHelper
CustomRoles.Crusader => UsePets && Crusader.UsePet.GetBool() ? RoleTypes.GuardianAngel : RoleTypes.Impostor,
CustomRoles.CopyCat => UsePets && CopyCat.UsePet.GetBool() ? RoleTypes.GuardianAngel : RoleTypes.Impostor,
CustomRoles.Refugee => RoleTypes.Impostor,
CustomRoles.Amnesiac => RoleTypes.Impostor,
CustomRoles.Agitater => RoleTypes.Impostor,
CustomRoles.Monarch => UsePets && Monarch.UsePet.GetBool() ? RoleTypes.GuardianAngel : RoleTypes.Impostor,
CustomRoles.Deputy => UsePets && Deputy.UsePet.GetBool() ? RoleTypes.GuardianAngel : RoleTypes.Impostor,
@@ -468,6 +458,7 @@ internal static class CustomRolesHelper
CustomRoles.RuthlessRomantic => RoleTypes.Impostor,
CustomRoles.Succubus => RoleTypes.Impostor,
CustomRoles.Necromancer => RoleTypes.Impostor,
CustomRoles.Deathknight => RoleTypes.Impostor,
CustomRoles.Virus => RoleTypes.Impostor,
CustomRoles.Farseer => UsePets && Farseer.UsePet.GetBool() ? RoleTypes.GuardianAngel : RoleTypes.Impostor,
CustomRoles.Ritualist => RoleTypes.Impostor,
@@ -706,11 +697,6 @@ internal static class CustomRolesHelper
CustomRoles.Crusader when Crusader.UsePet.GetBool() => true,
CustomRoles.Witness when Options.WitnessUsePet.GetBool() => true,
CustomRoles.Refugee => true,
CustomRoles.Necromancer => true,
CustomRoles.Deathknight => true,
CustomRoles.Sidekick => true,
// Speedrun
CustomRoles.Runner => true,
@@ -959,7 +945,7 @@ internal static class CustomRolesHelper
public static RoleTypes GetRoleTypes(this CustomRoles role)
{
if (Enum.TryParse<RoleTypes>(role.GetVNRole(checkDesyncRole: true).ToString(), ignoreCase: true, out var type)) return type;
if (Enum.TryParse<RoleTypes>(role.GetVNRole(checkDesyncRole: true).ToString().Replace("EHR", ""), ignoreCase: true, out var type)) return type;
return role.IsImpostor() ? RoleTypes.Impostor : RoleTypes.Crewmate;
}
+8 -7
View File
@@ -279,13 +279,17 @@ static class ExtendedPlayerControl
var newRoleType = newCustomRole.GetRoleTypes();
RoleTypes remeberRoleType;
if (Options.CurrentGameMode == CustomGameMode.Speedrun && newCustomRole == CustomRoles.Runner)
newRoleType = SpeedrunManager.CanKill.Contains(player.PlayerId) ? RoleTypes.Impostor : RoleTypes.Crewmate;
// Desync role to normal role
if (playerRole.IsDesyncRole() && !newCustomRole.IsDesyncRole())
{
foreach (var seer in Main.AllPlayerControls)
{
var isSelf = player.PlayerId == seer.PlayerId;
if (!isSelf && seer.HasDesyncRole() && !(seer.AmOwner || seer.IsModClient())) remeberRoleType = newCustomRole.GetVNRole() is CustomRoles.Noisemaker ? RoleTypes.Noisemaker : RoleTypes.Scientist;
if (!isSelf && seer.HasDesyncRole() && !(seer.AmOwner || seer.IsModClient()))
remeberRoleType = newCustomRole.GetVNRole() is CustomRoles.Noisemaker ? RoleTypes.Noisemaker : RoleTypes.Scientist;
else remeberRoleType = newRoleType;
SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seer.PlayerId, playerId)] = (remeberRoleType, newCustomRole);
@@ -305,9 +309,7 @@ static class ExtendedPlayerControl
// For Desync Shapeshifter
if (newCustomRole.GetDYRole() is RoleTypes.Shapeshifter)
{
remeberRoleType = RoleTypes.Shapeshifter;
}
}
else
{
@@ -330,8 +332,7 @@ static class ExtendedPlayerControl
{
remeberRoleType = SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seer.PlayerId, playerId)].roleType;
}
else
remeberRoleType = newRoleType;
else remeberRoleType = newRoleType;
SelectRolesPatch.RpcSetRoleReplacer.RoleMap[(seer.PlayerId, playerId)] = (remeberRoleType, newCustomRole);
player.RpcSetRoleDesync(remeberRoleType, seer.GetClientId());
@@ -344,8 +345,8 @@ static class ExtendedPlayerControl
{
foreach (var target in Main.AllPlayerControls)
{
SelectRolesPatch.RpcSetRoleReplacer.RoleMap.TryGetValue((seer.PlayerId, target.PlayerId), out var map);
Logger.Info($"seer {seer.Data?.PlayerName}-{seer.PlayerId}, target {target.Data?.PlayerName}-{target.PlayerId} => {map.roleType}, {map.customRole}", "Role Map");
if (SelectRolesPatch.RpcSetRoleReplacer.RoleMap.TryGetValue((seer.PlayerId, target.PlayerId), out var map))
Logger.Info($"seer {seer.Data?.PlayerName}-{seer.PlayerId}, target {target.Data?.PlayerName}-{target.PlayerId} => {map.roleType}, {map.customRole}", "Role Map");
}
}
}
@@ -231,7 +231,7 @@ public sealed class PlayerGameOptionsSender(PlayerControl player) : GameOptionsS
if (role.IsDesyncRole() && role.IsCrewmate() && !CrewmateVanillaRoles.NoiseMakerImpostorAlert.GetBool()) AURoleOptions.NoisemakerImpostorAlert = true;
else AURoleOptions.NoisemakerImpostorAlert = CrewmateVanillaRoles.NoiseMakerImpostorAlert.GetBool();
// if (Shifter.WasShifter.Contains(player.PlayerId) && role.IsImpostor()) opt.SetVision(true);
if (Shifter.WasShifter.Contains(player.PlayerId) && role.IsImpostor()) opt.SetVision(true);
Main.PlayerStates[player.PlayerId].Role.ApplyGameOptions(opt, player.PlayerId);
+4 -1
View File
@@ -88,7 +88,7 @@ public class PlayerState(byte playerId)
public bool IsBlackOut { get; set; }
public bool IsSuicide => deathReason == DeathReason.Suicide;
public TaskState TaskState { get; } = new();
public TaskState TaskState { get; set; } = new();
public void SetMainRole(CustomRoles role)
{
@@ -109,6 +109,9 @@ public class PlayerState(byte playerId)
SubRoles.ForEach(SetAddonCountTypes);
if (!Player.HasKillButton() && role == CustomRoles.Refugee)
Player.RpcChangeRoleBasis(CustomRoles.Refugee);
Role = role.GetRoleClass();
if (!role.RoleExist(countDead: true))
+1 -1
View File
@@ -665,7 +665,7 @@ public static class Utils
case CustomGameMode.HideAndSeek: return HnSManager.HasTasks(p);
}
// if (Shifter.ForceDisableTasks(p.PlayerId)) return false;
if (false) return false;
var role = States.MainRole;
switch (role)
-6
View File
@@ -246,12 +246,6 @@ internal class ChangeRoleSettings
Revolutionist.CurrentDrawTarget = byte.MaxValue;
Main.PlayerColors = [];
if (Options.CurrentGameMode == CustomGameMode.Speedrun && !Options.UsePets.GetBool())
{
Options.UsePets.SetValue(1);
PlayerControl.LocalPlayer.ShowPopUp(GetString("PetsForceEnabled"));
}
RPC.SyncAllPlayerNames();
RPC.SyncAllClientRealNames();
+2 -1
View File
@@ -936,6 +936,7 @@ class ReportDeadBodyPatch
if (!Librarian.OnAnyoneReport(__instance)) return false;
if (!Hypnotist.OnAnyoneReport()) return false;
if (!Altruist.OnAnyoneCheckReportDeadBody(__instance, target)) return false;
if (!BoobyTrap.OnAnyoneCheckReportDeadBody(__instance, target)) return false;
if (!Main.PlayerStates[__instance.PlayerId].Role.CheckReportDeadBody(__instance, target, killer)) return false;
@@ -1434,7 +1435,7 @@ static class FixedUpdatePatch
ApplySuffix(__instance);
}
if (__instance.AmOwner && inTask && ((Main.ChangedRole && localPlayer && AmongUsClient.Instance.AmHost) || (!__instance.Is(CustomRoleTypes.Impostor) /* || Shifter.WasShifter.Contains(__instance.PlayerId)*/) && __instance.CanUseKillButton() && !__instance.Data.IsDead))
if (__instance.AmOwner && inTask && ((Main.ChangedRole && localPlayer && AmongUsClient.Instance.AmHost) || (!__instance.Is(CustomRoleTypes.Impostor)) && __instance.CanUseKillButton() && !__instance.Data.IsDead))
{
var players = __instance.GetPlayersInAbilityRangeSorted();
PlayerControl closest = players.Count == 0 ? null : players[0];
+1
View File
@@ -4527,6 +4527,7 @@
"Prefix.Haunter": "Haunter",
"GotGhostRoleNotify": "<#ffff00>You were assigned a ghost role!</color>",
"NumOfTasks": "Number of Tasks to Finish",
"AmnesiacRoleBasis": "Role Basis",
"RememberCooldown": "Remember Cooldown",
"RefugeeKillCD": "<color=#ff1919>Renegade</color>'s Kill Cooldown",
"AmnesiacRemembered": "An Amnesiac remembered your role!",
+2 -1
View File
@@ -43,7 +43,7 @@ public class SwordsMan : RoleBase
=> !Main.PlayerStates[pc.PlayerId].IsDead
&& !IsKilled(pc.PlayerId);
public static bool IsKilled(byte playerId) => Killed.Contains(playerId);
private static bool IsKilled(byte playerId) => Killed.Contains(playerId);
public override void Add(byte playerId)
{
@@ -72,6 +72,7 @@ public class SwordsMan : RoleBase
SendRPC(killer.PlayerId);
Killed.Add(killer.PlayerId);
SetKillCooldown(killer.PlayerId);
killer.RpcChangeRoleBasis(CustomRoles.CrewmateEHR);
Utils.NotifyRoles(SpecifySeer: killer, SpecifyTarget: killer);
}
}
+1 -1
View File
@@ -67,7 +67,7 @@ namespace EHR.Impostor
}
}
public override bool CheckReportDeadBody(PlayerControl reporter, NetworkedPlayerInfo target, PlayerControl killer)
public static bool OnAnyoneCheckReportDeadBody(PlayerControl reporter, NetworkedPlayerInfo target)
{
if (BoobyTrapBody.Contains(target.PlayerId) && reporter.IsAlive())
{
+9 -5
View File
@@ -17,6 +17,7 @@ public class Amnesiac : RoleBase
private static OptionItem IncompatibleNeutralMode;
private static OptionItem CanVent;
public static OptionItem RememberMode;
public static OptionItem RoleBasis;
public static readonly CustomRoles[] AmnesiacIncompatibleNeutralMode =
[
@@ -50,6 +51,8 @@ public class Amnesiac : RoleBase
.SetParent(CustomRoleSpawnChances[CustomRoles.Amnesiac]);
CanVent = new BooleanOptionItem(Id + 13, "CanVent", false, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Amnesiac]);
RoleBasis = new StringOptionItem(Id + 14, "AmnesiacRoleBasis", [CustomRoles.Engineer.ToColoredString(), CustomRoles.Crewmate.ToColoredString()], 1, TabGroup.NeutralRoles)
.SetParent(CustomRoleSpawnChances[CustomRoles.Amnesiac]);
}
public override void Init()
@@ -151,16 +154,16 @@ public class Amnesiac : RoleBase
amneNotifyString = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Amnesiac), GetString("RememberedImpostor"));
break;
case Team.Crewmate:
RememberedRole = !targetRole.IsTaskBasedCrewmate() && (CanRememberCrewPower.GetBool() || targetRole.GetCrewmateRoleCategory() != RoleOptionType.Crewmate_Power) ? targetRole : CustomRoles.Sheriff;
RememberedRole = CanRememberCrewPower.GetBool() || targetRole.GetCrewmateRoleCategory() != RoleOptionType.Crewmate_Power ? targetRole : CustomRoles.Sheriff;
amneNotifyString = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Amnesiac), GetString("RememberedCrewmate"));
break;
case Team.Neutral:
if (targetRole.IsNK())
if (!SingleRoles.Contains(targetRole))
{
RememberedRole = targetRole;
amneNotifyString = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Amnesiac), GetString("RememberedNeutralKiller"));
}
else if (targetRole.IsNonNK())
else
{
RememberedRole = AmnesiacIncompatibleNeutralMode[IncompatibleNeutralMode.GetValue()];
amneNotifyString = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Amnesiac), GetString($"Remembered{RememberedRole}"));
@@ -173,15 +176,16 @@ public class Amnesiac : RoleBase
}
if (RememberedRole == null)
if (!RememberedRole.HasValue)
{
amnesiac.Notify(Utils.ColorString(Utils.GetRoleColor(CustomRoles.Amnesiac), GetString("AmnesiacInvalidTarget")));
return;
}
var role = (CustomRoles)RememberedRole;
var role = RememberedRole.Value;
amnesiac.RpcSetCustomRole(role);
amnesiac.RpcChangeRoleBasis(role);
amnesiac.Notify(amneNotifyString);
target.Notify(Utils.ColorString(Utils.GetRoleColor(CustomRoles.Amnesiac), GetString("AmnesiacRemembered")));
+2 -2
View File
@@ -115,11 +115,11 @@ public class Jackal : RoleBase
public override bool OnCheckMurder(PlayerControl killer, PlayerControl target)
{
if (killer.GetAbilityUseLimit() < 1 || !CanBeSidekick(target, out var needBasisChange, out var targetRoleType) || (needBasisChange && SKCanKill.GetBool() && !UsePets.GetBool())) return true;
if (killer.GetAbilityUseLimit() < 1 || !CanBeSidekick(target, out var needBasisChange, out var targetRoleType)) return true;
killer.RpcRemoveAbilityUse();
target.RpcSetCustomRole(targetRoleType == RoleTypes.Shapeshifter ? CustomRoles.Recruit : CustomRoles.Sidekick);
// if (needBasisChange) target.ChangeRoleBasis(RoleTypes.Impostor);
if (needBasisChange) target.RpcChangeRoleBasis(CustomRoles.Sidekick);
SidekickId = target.PlayerId;
Main.ResetCamPlayerList.Add(target.PlayerId);
+1
View File
@@ -76,6 +76,7 @@ namespace EHR.Neutral
{
if (Deathknight.DeathknightId == byte.MaxValue)
{
if (!target.HasKillButton()) target.RpcChangeRoleBasis(CustomRoles.Deathknight);
target.RpcSetCustomRole(CustomRoles.Deathknight);
killer.SetKillCooldown();
+6 -19
View File
@@ -1,4 +1,4 @@
/*using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using AmongUs.GameOptions;
using EHR.Crewmate;
@@ -13,15 +13,12 @@ namespace EHR.Neutral
public static bool On;
public static List<byte> WasShifter = [];
private static Dictionary<byte, RoleTypes> AllPlayerBasis = [];
private static OptionItem KillCooldown;
private static OptionItem CanVent;
private static OptionItem HasImpostorVision;
private static OptionItem TryChangeBasis;
public override bool IsEnable => On;
public static bool ForceDisableTasks(byte id) => !TryChangeBasis.GetBool() && WasShifter.Contains(id) && AllPlayerBasis.TryGetValue(id, out var basis) && basis is RoleTypes.Impostor or RoleTypes.Shapeshifter;
public override void SetupCustomOption()
{
@@ -33,10 +30,6 @@ namespace EHR.Neutral
.SetParent(Options.CustomRoleSpawnChances[CustomRoles.Shifter]);
HasImpostorVision = new BooleanOptionItem(Id + 4, "ImpostorVision", true, TabGroup.NeutralRoles)
.SetParent(Options.CustomRoleSpawnChances[CustomRoles.Shifter]);
TryChangeBasis = new BooleanOptionItem(Id + 5, "TryChangeBasis", false, TabGroup.NeutralRoles)
.SetHidden(true)
.SetParent(Options.CustomRoleSpawnChances[CustomRoles.Shifter]);
TryChangeBasis.SetValue(0);
}
public override void Init()
@@ -46,16 +39,11 @@ namespace EHR.Neutral
On = false;
WasShifter = [];
AllPlayerBasis = [];
LateTask.New(() => AllPlayerBasis = Main.AllPlayerControls.ToDictionary(x => x.PlayerId, x => x.GetRoleTypes()), 10f, log: false);
}
public override void Add(byte playerId)
{
On = true;
if (!TryChangeBasis.GetBool() || playerId == 0)
WasShifter.Add(playerId);
}
public override void SetKillCooldown(byte id) => Main.AllPlayerKillCooldown[id] = KillCooldown.GetFloat();
@@ -85,8 +73,7 @@ namespace EHR.Neutral
}
killer.RpcSetCustomRole(targetRole);
if (TryChangeBasis.GetBool())
killer.ChangeRoleBasis(target.GetRoleTypes());
killer.RpcChangeRoleBasis(targetRole);
var targetRoleBase = Main.PlayerStates[target.PlayerId].Role;
LateTask.New(() => Main.PlayerStates[killer.PlayerId].Role = targetRoleBase, 0.5f, "Change RoleBase");
@@ -94,7 +81,7 @@ namespace EHR.Neutral
killer.SetAbilityUseLimit(target.GetAbilityUseLimit());
var taskState = target.GetTaskState();
if (taskState.hasTasks) Main.PlayerStates[killer.PlayerId].taskState = taskState;
if (taskState.HasTasks) Main.PlayerStates[killer.PlayerId].TaskState = taskState;
var killerSubRoles = killer.GetCustomSubRoles().ToList();
var targetSubRoles = target.GetCustomSubRoles().ToList();
@@ -126,6 +113,8 @@ namespace EHR.Neutral
Utils.NotifyRoles(SpecifyTarget: killer);
Utils.NotifyRoles(SpecifyTarget: target);
WasShifter.Add(killer.PlayerId);
return false;
}
@@ -134,6 +123,4 @@ namespace EHR.Neutral
OnCheckMurder(pc, ExternalRpcPetPatch.SelectKillButtonTarget(pc));
}
}
}
*/
}