Skip to content

Commit

Permalink
新增任务诅咒模式
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Oct 25, 2024
1 parent 3e9a982 commit ad2de16
Show file tree
Hide file tree
Showing 27 changed files with 1,246 additions and 9 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@

### 翻译:

**ZH:** 沫夏悠轩、Conscience、方块
**ZH:** 沫夏悠轩、Conscience

**EN:** 九头蛇

Expand All @@ -497,11 +497,12 @@
[TooManyRolesMods](https://github.com/Hardel-DW/TooManyRolesMods) - Idea for the Detective and Time Master roles came from **Hardel-DW**. Also some code snippets from their implementation were used.\
[TownOfUs](https://github.com/slushiegoose/Town-Of-Us) - Idea for the Swapper, Shifter, Arsonist and a similar Mayor role came from **Slushiegoose**\
[Ottomated](https://twitter.com/ottomated_) - Idea for the Morphling, Snitch and Camouflager role came from **Ottomated**\
[Crowded-Mod](https://github.com/CrowdedMods/CrowdedMod) - Our implementation for 10+ player lobbies were inspired by the one from the **Crowded Mod Team**\
[Crowded-Mod](https://github.com/CrowdedMods/CrowdedMod) - Our implementation for 15+ player lobbies were inspired by the one from the **Crowded Mod Team**\
[Goose-Goose-Duck](https://store.steampowered.com/app/1568590/Goose_Goose_Duck) - Idea for the Vulture role came from **Slushiegoose**\
[TheEpicRoles](https://github.com/LaicosVK/TheEpicRoles) - Idea for the first kill shield (partly) and the tabbed option menu (fully + some code), by **LaicosVK** **DasMonschta** **Nova**\
[Ninja](#ninja), [Thief](#thief), [Lawyer](#lawyer) / [Pursuer](#pursuer), [Deputy](#deputy), [Portalmaker](#portalmaker), [Guesser Modifier](#guesser-modifier) - Idea: [K3ndo](https://github.com/K3ndoo) ; Developed by [Gendelo](https://github.com/gendelo3) & [Mallöris](https://github.com/Mallaris) \
[PropHunt](https://github.com/ugackMiner53/PropHunt) - Idea and core code by **ugackMiner53**\
[Cursed Among Us](https://github.com/XiezibanWrite/Cursed-Among-Us-Continued) - Idea by **Kyle Smith**, core code by [XiezibanWrite](https://github.com/XiezibanWrite/Cursed-Among-Us-Continued) and [SuperNewRoles](https://github.com/SuperNewRoles/SuperNewRoles)

## 许可

Expand Down
Binary file modified Strings.xlsx
Binary file not shown.
20 changes: 13 additions & 7 deletions TheOtherRoles/Helper/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -555,12 +555,24 @@ public static void AddUnique<T>(this Il2CppSystem.Collections.Generic.List<T> se
if (!self.Contains(item)) self.Add(item);
}

public static int GetRandomIndex<T>(List<T> list)
public static T GetRandom<T>(this T[] list)
{
var indexData = UnityEngine.Random.Range(0, list.Length);
return list[indexData];
}

public static int GetRandom<T>(List<T> list)
{
var indexData = UnityEngine.Random.Range(0, list.Count);
return indexData;
}

public static T GetRandom<T>(this Il2CppSystem.Collections.Generic.List<T> list)
{
var indexData = UnityEngine.Random.Range(0, list.Count);
return list[indexData];
}

public static void ForEach<T>(this Il2CppArrayBase<T> list, Action<T> func)
{
foreach (T obj in list) func(obj);
Expand Down Expand Up @@ -608,12 +620,6 @@ public static Il2CppSystem.Collections.Generic.List<T> ToIl2CppList<T>(this IEnu
return newList;
}

public static T GetRandom<T>(this T[] list)
{
var indexData = UnityEngine.Random.Range(0, list.Length);
return list[indexData];
}

public static T Find<T>(this Il2CppSystem.Collections.Generic.List<T> data, Predicate<T> match)
{
return data.ToList().Find(match);
Expand Down
3 changes: 3 additions & 0 deletions TheOtherRoles/Options/CustomOptionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@ public class CustomOptionHolder

public static CustomOption disableMedbayWalk;

public static CustomOption enableCursedTasks;

public static CustomOption enableCamoComms;
public static CustomOption fungleDisableCamoComms;

Expand Down Expand Up @@ -776,6 +778,7 @@ public static void Load()
allowParallelMedBayScans = Create(44, Types.General, "allowParallelMedBayScans", false);
finishTasksBeforeHauntingOrZoomingOut = Create(42, Types.General, "finishTasksBeforeHauntingOrZoomingOut", false);
disableTaskGameEnd = Create(43, Types.General, "disableTaskGameEnd", false);
enableCursedTasks = Create(45, Types.General, cs(Palette.Purple, "enableCursedTasks"), false);

//Map options
enableMapOptions = Create(200, Types.General, "enableMapOptions", false, null, true);
Expand Down
2 changes: 2 additions & 0 deletions TheOtherRoles/Options/ModOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal class ModOption
public static bool isCanceled;

public static int restrictDevices;
public static bool CursedTasks;

// public static float restrictAdminTime = 600f;
//public static float restrictAdminTimeMax = 600f;
Expand Down Expand Up @@ -113,6 +114,7 @@ public static void clearAndReloadMapOptions()
ShowVentsOnMeetingMap = CustomOptionHolder.ShowVentsOnMeetingMap.getBool();
randomLigherPlayer = CustomOptionHolder.randomLigherPlayer.getBool();
allowModGuess = CustomOptionHolder.allowModGuess.getBool();
CursedTasks = CustomOptionHolder.enableCursedTasks.getBool();
firstKillPlayer = null;
isRoundOne = true;
isCanceled = false;
Expand Down
113 changes: 113 additions & 0 deletions TheOtherRoles/Patches/CursedTasks/Burger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using System.Linq;
using UnityEngine;
namespace TheOtherRoles.Patches.CursedTasks;

internal static class Burger
{
[HarmonyPatch(typeof(BurgerMinigame))]
private static class BurgerMinigamePatch
{
[HarmonyPatch(nameof(BurgerMinigame.Begin)), HarmonyPostfix]
private static void BeginPostfix(BurgerMinigame __instance)
{
if (!ModOption.CursedTasks) return;
switch (Random.RandomRange(0f, 1f))
{
case <= 0.50f: // 50%
__instance.ExpectedToppings = new(6);
__instance.ExpectedToppings[0] = BurgerToppingTypes.Plate;
for (var i = 1; i < __instance.ExpectedToppings.Count; i++)
{
var topping = (BurgerToppingTypes)IntRange.Next(0, 6);
var set = __instance.ExpectedToppings.Count(t => t == topping) < topping switch
{
BurgerToppingTypes.TopBun => 1,
BurgerToppingTypes.BottomBun => 1,
BurgerToppingTypes.Lettuce => 3,
_ => 2
};
if (set) __instance.ExpectedToppings[i] = topping;
else i--;
}
break;
case <= 0.70f: // 20%
__instance.ExpectedToppings = new(6);
__instance.ExpectedToppings[0] = BurgerToppingTypes.Plate;
var bun = (new BurgerToppingTypes[] { BurgerToppingTypes.Meat, BurgerToppingTypes.Onion, BurgerToppingTypes.Tomato }).GetRandom();
__instance.ExpectedToppings[1] = bun;
__instance.ExpectedToppings[5] = bun;
for (var i = 2; i < __instance.ExpectedToppings.Count - 1; i++)
{
var topping = (BurgerToppingTypes)IntRange.Next(2, 6);
var set = __instance.ExpectedToppings.Count(t => t == topping) < topping switch
{
BurgerToppingTypes.TopBun => 1,
BurgerToppingTypes.BottomBun => 1,
BurgerToppingTypes.Lettuce => 3,
_ => 2
};
if (set) __instance.ExpectedToppings[i] = topping;
else i--;
}
break;
case <= 0.90f: // 20%
__instance.ExpectedToppings = new(6);
__instance.ExpectedToppings[0] = BurgerToppingTypes.Plate;
__instance.ExpectedToppings[1] = BurgerToppingTypes.Lettuce;
__instance.ExpectedToppings[5] = BurgerToppingTypes.Lettuce;
for (var i = 2; i < __instance.ExpectedToppings.Count - 1; i++)
{
var topping = (new BurgerToppingTypes[] { BurgerToppingTypes.Lettuce, BurgerToppingTypes.Onion, BurgerToppingTypes.Tomato }).GetRandom();
var set = __instance.ExpectedToppings.Count(t => t == topping) < topping switch
{
BurgerToppingTypes.TopBun => 1,
BurgerToppingTypes.BottomBun => 1,
BurgerToppingTypes.Lettuce => 3,
_ => 2
};
if (set) __instance.ExpectedToppings[i] = topping;
else i--;
}
break;
case <= 0.95f: // 5%
__instance.ExpectedToppings = new(3);
__instance.ExpectedToppings[0] = BurgerToppingTypes.Plate;
__instance.ExpectedToppings[1] = BurgerToppingTypes.BottomBun;
__instance.ExpectedToppings[2] = BurgerToppingTypes.TopBun;
break;
case <= 1.00f: // 5%
__instance.ExpectedToppings = new(6);
__instance.ExpectedToppings[0] = BurgerToppingTypes.Plate;
if (BoolRange.Next(0.1f))
{
__instance.ExpectedToppings[1] = BurgerToppingTypes.Lettuce;
__instance.ExpectedToppings[5] = BurgerToppingTypes.Lettuce;
}
else
{
__instance.ExpectedToppings[1] = BurgerToppingTypes.BottomBun;
__instance.ExpectedToppings[5] = BurgerToppingTypes.TopBun;
}
for (var i = 2; i < __instance.ExpectedToppings.Count - 1; i++)
{
var topping = (BurgerToppingTypes)IntRange.Next(2, 6);
if (__instance.ExpectedToppings.Count(t => t == topping) >= 2) i--;
else __instance.ExpectedToppings[i] = topping;
}
if (BoolRange.Next(0.01f))
{
var burgerToppingTypes = __instance.ExpectedToppings[5];
__instance.ExpectedToppings[5] = __instance.ExpectedToppings[4];
__instance.ExpectedToppings[4] = burgerToppingTypes;
}
break;
}

for (var i = 0; i < __instance.PaperSlots.Length; i++)
{
if (i < __instance.ExpectedToppings.Count - 1) __instance.PaperSlots[i].sprite = __instance.PaperToppings[(int)__instance.ExpectedToppings[i + 1]];
else __instance.PaperSlots[i].enabled = false;
}
}
}
}
19 changes: 19 additions & 0 deletions TheOtherRoles/Patches/CursedTasks/CaliDistributar.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using UnityEngine;
namespace TheOtherRoles.Patches.CursedTasks
{
internal class CaliDistributar
{
[HarmonyPatch(typeof(SweepMinigame))]
private static class SweepMinigamePatch
{
[HarmonyPatch(nameof(SweepMinigame.FixedUpdate)), HarmonyPrefix]
private static void FixedUpdatePrefix(SweepMinigame __instance)
{
if (!ModOption.CursedTasks) return;
var numer = new System.Random();
float num = numer.Next(10, 50);
__instance.timer += Time.fixedDeltaTime * num;
}
}
}
}
34 changes: 34 additions & 0 deletions TheOtherRoles/Patches/CursedTasks/CardSlide.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using UnityEngine;
using Random = UnityEngine.Random;

namespace TheOtherRoles.Patches.CursedTasks
{
internal static class CustomCardSwipe
{
private static readonly bool PrevState = false;

[HarmonyPatch(typeof(CardSlideGame))]
private static class CardSlidePatch
{
[HarmonyPatch(nameof(CardSlideGame.Begin))]
[HarmonyPrefix]
private static void BeginPrefix(CardSlideGame __instance)
{
if (!ModOption.CursedTasks) return;
__instance.AcceptedTime = new FloatRange(0.5f, 0.5f);
}

[HarmonyPatch(nameof(CardSlideGame.Update))]
[HarmonyPrefix]
private static void PutCardBackPrefix(CardSlideGame __instance)
{
if (!ModOption.CursedTasks) return;
var CurrentState = __instance.redLight.color == Color.red;
if (PrevState == CurrentState || !CurrentState) return;
var randomNumber = Random.RandomRangeInt(0, 40);
if (randomNumber == 0) __instance.AcceptedTime = new FloatRange(0.25f, 2f);
else __instance.AcceptedTime = new FloatRange(0.495f, 0.505f);
}
}
}
}
21 changes: 21 additions & 0 deletions TheOtherRoles/Patches/CursedTasks/CollectShells.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace TheOtherRoles.Patches.CursedTasks;

internal class CollectShells
{
[HarmonyPatch(typeof(CollectShellsMinigame))]
private static class CollectShellsMinigameMinigamePatch
{
[HarmonyPatch(nameof(CollectShellsMinigame.Begin)), HarmonyPrefix]

private static void BeginPrefix(CollectShellsMinigame __instance)
{
if (!ModOption.CursedTasks) return;
var Rd = new System.Random();

__instance.numShellsRange = (IntRange)Rd.Next(4, 20);

}
}


}
17 changes: 17 additions & 0 deletions TheOtherRoles/Patches/CursedTasks/Course.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace TheOtherRoles.Patches.CursedTasks
{
internal class Course
{
[HarmonyPatch(typeof(CourseMinigame))]
private static class CourseMinigamePatch
{
[HarmonyPatch(nameof(CourseMinigame.Begin)), HarmonyPrefix]
private static void BeginPrefix(CourseMinigame __instance)
{
if (!ModOption.CursedTasks) return;
var rd = new System.Random();
__instance.NumPoints = rd.Next(20, 27);
}
}
}
}
Loading

0 comments on commit ad2de16

Please sign in to comment.