Skip to content

Commit

Permalink
Sprinter speed bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
dabao40 committed Dec 7, 2024
1 parent b2227bc commit 1d2f483
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
Binary file modified Strings.xlsx
Binary file not shown.
4 changes: 1 addition & 3 deletions TheOtherRoles/CustomGameModes/FreePlayGM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ public static void removeModifier(RoleId modifierId)
break;
case RoleId.Chameleon:
Chameleon.chameleon.RemoveAll(x => x.PlayerId == playerId);
break;
case RoleId.Mini:
Mini.mini = null;
Chameleon.lastMoved.Clear();
break;
case RoleId.Invert:
Invert.invert.RemoveAll(x => x.PlayerId == playerId);
Expand Down
2 changes: 2 additions & 0 deletions TheOtherRoles/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public class CustomOptionHolder {
public static CustomOption sprinterCooldown;
public static CustomOption sprinterDuration;
public static CustomOption sprinterFadeTime;
public static CustomOption sprinterSpeedBonus;

public static CustomOption fortuneTellerSpawnRate;
public static CustomOption fortuneTellerNumTasks;
Expand Down Expand Up @@ -947,6 +948,7 @@ public static void Load() {
sprinterCooldown = CustomOption.Create(4006, Types.Crewmate, "sprinterCooldown", 30f, 2.5f, 60f, 2.5f, sprinterSpawnRate, false, "unitSeconds");
sprinterDuration = CustomOption.Create(4007, Types.Crewmate, "sprintDuration", 15f, 10f, 60f, 2.5f, sprinterSpawnRate, false, "unitSeconds");
sprinterFadeTime = CustomOption.Create(4008, Types.Crewmate, "sprintFadeTime", 0.5f, 0.0f, 2.5f, 0.5f, sprinterSpawnRate, false, "unitSeconds");
sprinterSpeedBonus = CustomOption.Create(4009, Types.Crewmate, "sprinterSpeedBonus", 1.25f, 0.5f, 2f, 0.25f, sprinterSpawnRate, false, "unitTimes");

detectiveSpawnRate = CustomOption.Create(120, Types.Crewmate, cs(Detective.color, "detective"), rates, null, true);
detectiveAnonymousFootprints = CustomOption.Create(121, Types.Crewmate, "detectiveAnonymousFootprints", false, detectiveSpawnRate);
Expand Down
7 changes: 4 additions & 3 deletions TheOtherRoles/Patches/UsablesPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,12 @@ public static bool Prefix(KillButton __instance) {
[HarmonyPatch(typeof(MapBehaviour), nameof(MapBehaviour.Show))]
public static class MapBehaviourShowPatch {
public static void Prefix(MapBehaviour __instance, ref MapOptions opts) {
bool blockSabotageJanitor = Janitor.janitor != null && Janitor.janitor == CachedPlayer.LocalPlayer.PlayerControl;
bool blockSabotageMafioso = Mafioso.mafioso != null && Mafioso.mafioso == CachedPlayer.LocalPlayer.PlayerControl && Godfather.godfather != null && !Godfather.godfather.Data.IsDead;
if (blockSabotageJanitor || blockSabotageMafioso) {
if (!CachedPlayer.LocalPlayer.PlayerControl.roleCanUseSabotage()) {
if (opts.Mode == MapOptions.Modes.Sabotage) opts.Mode = MapOptions.Modes.Normal;
}
else {
if (opts.Mode == MapOptions.Modes.Normal) opts.Mode = MapOptions.Modes.Sabotage;
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions TheOtherRoles/Resources/stringData.json
Original file line number Diff line number Diff line change
Expand Up @@ -4891,6 +4891,10 @@
"13": "\u5f57\u661f\u4e4b\u5b50\u9690\u8eab\u6240\u9700\u65f6\u95f4",
"14": "\u5f57\u661f\u4e4b\u5b50\u96b1\u8eab\u6240\u9700\u6642\u9593"
},
"sprinterSpeedBonus": {
"0": "Sprinting Speed Bonus",
"13": "\u51b2\u523a\u65f6\u901f\u5ea6\u589e\u52a0\u500d\u7387"
},
"undertaker": {
"0": "Undertaker",
"11": "\u30a2\u30f3\u30c0\u30fc\u30c6\u30a4\u30ab\u30fc",
Expand Down
18 changes: 6 additions & 12 deletions TheOtherRoles/TheOtherRoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5514,7 +5514,8 @@ public static class Sprinter

public static float sprintCooldown = 30f;
public static float sprintDuration = 15f;
public static float fadeTime = 0.5f;
public static float fadeTime = 0.5f;
public static float speedBonus = 0.25f;

public static bool sprinting = false;

Expand Down Expand Up @@ -5546,15 +5547,6 @@ public static float sprintFade(PlayerControl player)
return 1.0f;
}

public static bool isSprinting()
{
if (CachedPlayer.LocalPlayer.PlayerControl == sprinter && !sprinter.Data.IsDead)
{
return sprinting;
}
return false;
}

public static void setSprinting(PlayerControl player, bool sprinting = true)
{
if (player == sprinter && !sprinter.Data.IsDead)
Expand Down Expand Up @@ -5582,7 +5574,8 @@ public static void clearAndReload()
sprinting = false;
sprintCooldown = CustomOptionHolder.sprinterCooldown.getFloat();
sprintDuration = CustomOptionHolder.sprinterDuration.getFloat();
fadeTime = CustomOptionHolder.sprinterFadeTime.getFloat();
fadeTime = CustomOptionHolder.sprinterFadeTime.getFloat();
speedBonus = CustomOptionHolder.sprinterSpeedBonus.getFloat();
acTokenMove = null;
}

Expand All @@ -5592,7 +5585,8 @@ public static class PlayerPhysicsSprinterPatch
public static void Postfix(PlayerPhysics __instance)
{
if (__instance.myPlayer == sprinter)
{
{
if (GameData.Instance && sprinting && __instance.AmOwner && __instance.myPlayer.CanMove) __instance.body.velocity *= 1 + speedBonus;
var sprinter = __instance.myPlayer;
if (sprinter == null || sprinter.Data.IsDead) return;

Expand Down

0 comments on commit 1d2f483

Please sign in to comment.