diff --git a/Patches/PetActionsPatch.cs b/Patches/PetActionsPatch.cs index 277e7a578..99bbc1bb8 100644 --- a/Patches/PetActionsPatch.cs +++ b/Patches/PetActionsPatch.cs @@ -191,12 +191,13 @@ internal static class ExternalRpcPetPatch { PlayerControl target = FastVector2.TryGetClosestPlayerInRangeTo(pc, 3.5f, out PlayerControl closest) ? closest : null; - if (target != null) + if (target) { - if (target.Is(CustomRoles.Detour)) + if (target.Is(CustomRoles.Detour) && target.GetAbilityUseLimit() >= 1f) { + target.RpcRemoveAbilityUse(); PlayerControl tempTarget = target; - FastVector2.TryGetClosestPlayerTo(target, out target, x => x.PlayerId != pc.PlayerId); + FastVector2.TryGetClosestPlayerTo(tempTarget, out target, x => x.PlayerId != pc.PlayerId); Logger.Info($"Target was {tempTarget.GetNameWithRole()}, new target is {target.GetNameWithRole()}", "Detour"); if (tempTarget.AmOwner) diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 9fdd97cca..aaa13a184 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -127,8 +127,9 @@ internal static class CheckMurderPatch return false; } - if (target.Is(CustomRoles.Detour)) + if (target.Is(CustomRoles.Detour) && target.GetAbilityUseLimit() >= 1f) { + target.RpcRemoveAbilityUse(); PlayerControl tempTarget = target; FastVector2.TryGetClosestPlayerTo(tempTarget, out target, x => x.PlayerId != killer.PlayerId); Logger.Info($"Target was {tempTarget.GetNameWithRole()}, new target is {target.GetNameWithRole()}", "Detour"); diff --git a/Roles/Standard/Crewmate/Power/Detour.cs b/Roles/Standard/Crewmate/Power/Detour.cs index 558b993b7..0ca4db8ff 100644 --- a/Roles/Standard/Crewmate/Power/Detour.cs +++ b/Roles/Standard/Crewmate/Power/Detour.cs @@ -5,9 +5,16 @@ internal class Detour : RoleBase public static int TotalRedirections; public override bool IsEnable => false; + private static OptionItem AbilityUseLimit; + private static OptionItem AbilityUseGainWithEachTaskCompleted; + private static OptionItem AbilityChargesWhenFinishedTasks; + public override void SetupCustomOption() { - Options.SetupRoleOptions(5590, TabGroup.CrewmateRoles, CustomRoles.Detour); + StartSetup(5590) + .AutoSetupOption(ref AbilityUseLimit, 0f, new FloatValueRule(0, 20, 0.05f), OptionFormat.Times) + .AutoSetupOption(ref AbilityUseGainWithEachTaskCompleted, 0.4f, new FloatValueRule(0f, 5f, 0.05f), OptionFormat.Times) + .AutoSetupOption(ref AbilityChargesWhenFinishedTasks, 0.2f, new FloatValueRule(0f, 5f, 0.05f), OptionFormat.Times); } public override void Init() @@ -15,5 +22,8 @@ internal class Detour : RoleBase TotalRedirections = 0; } - public override void Add(byte playerId) { } + public override void Add(byte playerId) + { + playerId.SetAbilityUseLimit(AbilityUseLimit.GetFloat()); + } } \ No newline at end of file