Skip to content

Commit

Permalink
Fixed bugs
Browse files Browse the repository at this point in the history
Added more minigame hacks
  • Loading branch information
Lyzev committed Apr 27, 2024
1 parent d18290a commit 8ca300c
Show file tree
Hide file tree
Showing 10 changed files with 307 additions and 16 deletions.
4 changes: 4 additions & 0 deletions SchummelPartie/SchummelPartie.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@
<Compile Include="module\modules\ModuleBarnBrawl.cs" />
<Compile Include="module\modules\ModuleBattyBatter.cs" />
<Compile Include="module\modules\ModuleBomber.cs" />
<Compile Include="module\modules\ModuleCrownCapture.cs" />
<Compile Include="module\modules\ModuleDaringDogfight.cs" />
<Compile Include="module\modules\ModuleElementalMages.cs" />
<Compile Include="module\modules\ModuleExplosiveExchange.cs" />
<Compile Include="module\modules\ModuleFinder.cs" />
<Compile Include="module\modules\ModuleGUI.cs"/>
<Compile Include="module\modules\ModuleDebug.cs"/>
Expand Down
4 changes: 4 additions & 0 deletions SchummelPartie/module/ModuleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public static void Init()
Modules.Add(new ModuleTanks());
Modules.Add(new ModuleSidestepSlope());
Modules.Add(new ModuleSpeedySpotlights());
Modules.Add(new ModuleDaringDogfight());
Modules.Add(new ModuleElementalMages());
Modules.Add(new ModuleCrownCapture());
Modules.Add(new ModuleExplosiveExchange());
Modules.Add(new ModuleGUI());
// Code to generate markdown for the modules
// StringBuilder markdown = new StringBuilder();
Expand Down
2 changes: 1 addition & 1 deletion SchummelPartie/module/modules/ModuleBomber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public override void OnUpdate()
{
if (Enabled)
{
if (GameManager.Minigame is BattyBatterController bomberController)
if (GameManager.Minigame is BomberController bomberController)
{
foreach (var player in bomberController.players)
{
Expand Down
55 changes: 55 additions & 0 deletions SchummelPartie/module/modules/ModuleCrownCapture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using System.Linq;
using System.Reflection;
using SchummelPartie.setting.settings;

namespace SchummelPartie.module.modules;

public class ModuleCrownCapture : ModuleMinigame<BombKingController>
{

public SettingSwitch NoStun;
public SettingSwitch AlwaysCrown;

public ModuleCrownCapture() : base("Crown Capture", "No Punch Interval, No Stun, Always Crown")
{
NoStun = new(Name, "No Stun", false);
AlwaysCrown = new(Name, "Always Crown", false);
}

public override void OnUpdate()
{
if (Enabled)
{
if (GameManager.Minigame is BombKingController bombKingController)
{
foreach (var player in bombKingController.players)
{
if (player is BombKingPlayer bombKingPlayer)
{
if (player.IsMe())
{
if ((bool) NoStun.GetValue())
{
bombKingPlayer.Stunned = false;
}
if ((bool) AlwaysCrown.GetValue())
{
if (!bombKingPlayer.HoldingCrown)
{
foreach (var p in bombKingController.players)
{
if (p is BombKingPlayer enemy && enemy.HoldingCrown)
{
enemy.HoldingCrown = false;
}
}
bombKingPlayer.HoldingCrown = true;
}
}
}
}
}
}
}
}
}
103 changes: 103 additions & 0 deletions SchummelPartie/module/modules/ModuleDaringDogfight.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using System;
using System.Linq;
using System.Reflection;
using MelonLoader;
using SchummelPartie.render;
using SchummelPartie.setting.settings;
using UnityEngine;

namespace SchummelPartie.module.modules;

public class ModuleDaringDogfight : ModuleMinigame<PlanesController>
{
public SettingSwitch GodMode;
public SettingSwitch KillAll;
public SettingSwitch BurstShot;
public SettingSwitch ESP;

public ModuleDaringDogfight() : base("Daring Dogfight", "God Mode, Kill All, Burst Shot, ESP.")
{
GodMode = new(Name, "God Mode", false);
KillAll = new(Name, "Kill All", false);
BurstShot = new(Name, "Burst Shot", false);
ESP = new(Name, "Extra Sensory Perception", false);
}

public override void OnUpdate()
{
if (Enabled && ((bool) GodMode.GetValue() || (bool) KillAll.GetValue()))
{
if (GameManager.Minigame is PlanesController planesController)
{
foreach (var player in planesController.players)
{
if (player is PlanesPlayer planesPlayer)
{
if (player.IsMe())
{
if ((bool) GodMode.GetValue())
{
planesPlayer.Health = 5;
}

if ((bool) KillAll.GetValue())
{
foreach (var enemy in planesController.players)
{
if (enemy is PlanesPlayer planesEnemy && !enemy.IsDead && !enemy.IsMe())
{
planesController.TryDamagePlayer(planesPlayer, planesEnemy, enemy.GetPlayerPosition());
}
}
}

if ((bool) BurstShot.GetValue())
{
typeof(PlanesPlayer).GetField("m_fireCooldown", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(planesPlayer, 0f);
}
}
}
}
}
}
}

public override void OnGUI()
{
base.OnGUI();
if (Enabled && (bool) ESP.GetValue())
{
try
{
if (GameManager.Minigame is PlanesController planesController && GameManager.Minigame.Playable)
{
var me = planesController.players.First(player => player.IsMe());
if (Camera.current != null && me.transform != null)
{
Vector3 mePos = Camera.current.WorldToScreenPoint(me.transform.position);
if (planesController.players is { Count: > 0 })
{
foreach (var player in planesController.players)
{
if (player is PlanesPlayer && player.transform != null)
{
if (!player.IsDead && (!player.IsOwner || player.GamePlayer.IsAI))
{
Vector3 playerPos =
Camera.current.WorldToScreenPoint(player.transform.position);
Render.DrawESP(playerPos, 50f, 100f, Color.red, me: mePos,
name: $"[{player.GamePlayer.Name}]");
}
}
}
}
}
}
}
catch (Exception e)
{
MelonLogger.Error(e.ToString());
}
}
}
}
70 changes: 70 additions & 0 deletions SchummelPartie/module/modules/ModuleElementalMages.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Reflection;
using MelonLoader;
using SchummelPartie.setting.settings;

namespace SchummelPartie.module.modules;

public class ModuleElementalMages : ModuleMinigame<ElementalMagesController>
{
public SettingSwitch InstantPickupCrystal;
public SettingSwitch NoCameraShake;

public ModuleElementalMages() : base("Elemental Mages", "Instantly pick up crystals and disable camera shake.")
{
InstantPickupCrystal = new(Name, "Instant Pickup Crystal", false);
NoCameraShake = new(Name, "No Camera Shake", false);
}

public override void OnUpdate()
{
if (Enabled && ((bool) InstantPickupCrystal.GetValue() || (bool) NoCameraShake.GetValue()))
{
if (GameManager.Minigame is ElementalMagesController elementalMagesController)
{
foreach (var player in elementalMagesController.players)
{
if (player is ElementalMagesPlayer elementalMagesPlayer)
{
if (player.IsMe())
{
if ((bool) InstantPickupCrystal.GetValue())
{
try
{
foreach (var crystal in elementalMagesController.crystals)
{
elementalMagesController.RPCDespawnCrystal(null, crystal.id, (byte) player.OwnerSlot);
}
}
catch (Exception)
{
// ignored
}
}

if ((bool) NoCameraShake.GetValue())
{
FieldInfo cameraShakeField = elementalMagesPlayer.GetType().GetField("cameraShake",
BindingFlags.NonPublic | BindingFlags.Instance);
if (cameraShakeField != null)
{
CameraShake cameraShake = (CameraShake)cameraShakeField.GetValue(elementalMagesPlayer);
if (cameraShake != null)
{
cameraShake.enabled = false;
}
}
else
{
MelonLogger.Error(
$"[{Name}] Could not find field cameraShake in BarnBrawlPlayer.");
}
}
}
}
}
}
}
}
}
50 changes: 50 additions & 0 deletions SchummelPartie/module/modules/ModuleExplosiveExchange.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System.Linq;
using System.Reflection;
using SchummelPartie.setting.settings;

namespace SchummelPartie.module.modules;

public class ModuleExplosiveExchange : ModuleMinigame<PassTheBombController>
{

public SettingSwitch NoStun;
public SettingSwitch NoBomb;

public ModuleExplosiveExchange() : base("Explosive Exchange", "No Punch Interval, No Stun, Always Crown")
{
NoStun = new(Name, "No Stun", false);
NoBomb = new(Name, "No Bomb", false);
}

public override void OnUpdate()
{
if (Enabled)
{
if (GameManager.Minigame is PassTheBombController passTheBombController)
{
foreach (var player in passTheBombController.players)
{
if (player is PassTheBombPlayer passTheBombPlayer)
{
if (player.IsMe())
{
if ((bool) NoStun.GetValue())
{
passTheBombPlayer.Stunned = false;
}
if ((bool) NoBomb.GetValue())
{
PassTheBombPlayer enemy = (PassTheBombPlayer) passTheBombController.players.FirstOrDefault(p => !p.IsMe() && !p.IsDead);
if (enemy != null)
{
enemy.HoldingBomb = true;
}
passTheBombPlayer.HoldingBomb = false;
}
}
}
}
}
}
}
}
30 changes: 18 additions & 12 deletions SchummelPartie/module/modules/ModuleForcePresent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Reflection;
using HarmonyLib;
using MelonLoader;
using SchummelPartie.setting.settings;
Expand All @@ -12,7 +13,7 @@ public class ModuleForcePresent : Module

public SettingDropDown ActionID;

public ModuleForcePresent() : base("Force Present", "Forces the present to be the one you want.")
public ModuleForcePresent() : base("Force Present", "Forces the present to be the one you want. (NOT TESTED)")
{
Instance = this;
ActionID = new(Name, "Action ID", new Dictionary<int, string>
Expand All @@ -30,13 +31,16 @@ public static class PresentItemPatch
[HarmonyPrefix]
internal static bool Prefix(PresentItem __instance, ref byte actionID)
{
if (ModuleForcePresent.Instance.Enabled)
GamePlayer player = ((GamePlayer) typeof(PresentItem).GetField("player", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance));
if (player.BoardObject.IsOwner && !player.IsAI)
{
MelonLogger.Msg(
$"[{ModuleForcePresent.Instance.Name}] [Client] Force Present ID: {ModuleForcePresent.Instance.ActionID}");
actionID = (byte) (int) ModuleForcePresent.Instance.ActionID.GetValue();
if (ModuleForcePresent.Instance.Enabled)
{
MelonLogger.Msg(
$"[{ModuleForcePresent.Instance.Name}] [Client] Force Present ID: {ModuleForcePresent.Instance.ActionID.GetValue()}");
actionID = (byte) (int) ModuleForcePresent.Instance.ActionID.GetValue();
}
}

return true;
}
}
Expand All @@ -45,15 +49,17 @@ internal static bool Prefix(PresentItem __instance, ref byte actionID)
public static class NetBehaviourPatch
{
[HarmonyPrefix]
internal static bool Prefix(string method, NetRPCDelivery delivery, params object[] parameters)
internal static bool Prefix(NetBehaviour __instance, string method, NetRPCDelivery delivery, params object[] parameters)
{
if (ModuleForcePresent.Instance.Enabled && method == "RPCOpenPresent")
if (__instance.IsOwner)
{
MelonLogger.Msg(
$"[{ModuleForcePresent.Instance.Name}] [Server] Force Present ID: {ModuleForcePresent.Instance.ActionID}");
parameters[0] = ModuleForcePresent.Instance.ActionID;
if (ModuleForcePresent.Instance.Enabled && method == "RPCOpenPresent")
{
MelonLogger.Msg(
$"[{ModuleForcePresent.Instance.Name}] [Server] Force Present ID: {ModuleForcePresent.Instance.ActionID.GetValue()}");
parameters[0] = (byte) (int) ModuleForcePresent.Instance.ActionID.GetValue();
}
}

return true;
}
}
1 change: 0 additions & 1 deletion SchummelPartie/module/modules/ModuleRythm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ internal static bool Prefix(RhythmPlayer __instance)
{
MelonLogger.Error(e.ToString());
}

}
}
}
Expand Down
Loading

0 comments on commit 8ca300c

Please sign in to comment.