From 883a25071c08eb8a99487cb01fe92ba89771e589 Mon Sep 17 00:00:00 2001 From: Acherons_ Date: Sun, 26 Apr 2020 00:15:45 -0400 Subject: [PATCH] Organized Main.cs, Various Fixes, bumped to v1.2 Split Cheats up into different cs files. Renamed namespace and project name Actually fixed Equipment not dropping. Caused by using the same HandleId for dropping items and Equipment. Might be a bug with always sprint when using a/d to move, though was fixed next time i launched the game --- CHackLoader.cs | 2 +- DrawMenu.cs | 166 ++--- ESPHelper.cs | 2 +- ItemManager.cs | 307 +++++++++ Main.cs | 950 ++-------------------------- Player.cs | 283 +++++++++ Properties/AssemblyInfo.cs | 8 +- Properties/Resources.Designer.cs | 33 +- README.md | 19 +- Render.cs | 105 +++ Teleporter.cs | 55 ++ RoRCheats.csproj => UmbraRoR.csproj | 9 +- RorCheats.sln => UmbraRoR.sln | 6 +- Utils.cs | 161 +++++ btn.cs | 2 +- 15 files changed, 1078 insertions(+), 1030 deletions(-) create mode 100644 ItemManager.cs create mode 100644 Player.cs create mode 100644 Render.cs create mode 100644 Teleporter.cs rename RoRCheats.csproj => UmbraRoR.csproj (98%) rename RorCheats.sln => UmbraRoR.sln (87%) create mode 100644 Utils.cs diff --git a/CHackLoader.cs b/CHackLoader.cs index 796cb2b..1b6dad3 100644 --- a/CHackLoader.cs +++ b/CHackLoader.cs @@ -5,7 +5,7 @@ using UnityEngine; using System.Threading.Tasks; -namespace RoRCheats +namespace UmbraRoR { public class Loader { diff --git a/DrawMenu.cs b/DrawMenu.cs index 5bebfec..5a1b403 100644 --- a/DrawMenu.cs +++ b/DrawMenu.cs @@ -2,7 +2,7 @@ using System; using UnityEngine; -namespace RoRCheats +namespace UmbraRoR { internal class DrawMenu { @@ -78,7 +78,7 @@ public static void DrawManagmentMenu(float x, float y, float widthSize, int mulY if (Main._CharacterCollected) { - Main.GetPlayers(Main.Players); //update this asap + Utils.GetPlayers(Main.Players); //update this asap int buttonPlacement = 1; for (int i = 0; i < Main.Players.Length; i++) { @@ -89,14 +89,14 @@ public static void DrawManagmentMenu(float x, float y, float widthSize, int mulY if (GUI.Button(btn.BtnRect(buttonPlacement, false, "lobby"), $"K I C K {Main.Players[i]}", buttonStyle)) { Chat.AddMessage("Kicked Player " + $"{Main.Players[i]}"); - Main.KickPlayer(Main.GetNetUserFromString(Main.Players[i].ToString()), Main.LocalNetworkUser); + Utils.KickPlayer(Utils.GetNetUserFromString(Main.Players[i].ToString()), Main.LocalNetworkUser); } buttonPlacement++; } } catch (NullReferenceException) { - Debug.LogWarning("RoRCheats: There is No Player Selected"); + Debug.LogWarning("UmbraRoR: There is No Player Selected"); } } } @@ -149,13 +149,13 @@ public static void CharacterWindowMethod(float x, float y, float widthSize, int } GUI.EndScrollView(); } - public static void DrawSpawnMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle) + public static void DrawItemMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle) { GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 20, 50f + 45 * 15), "", BGstyle); GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 10, 95f), "I T E M M E N U", LabelStyle); itemSpawnerScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * 15), itemSpawnerScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); - Main.GiveItem(buttonStyle, "itemSpawner"); + ItemManager.GiveItem(buttonStyle, "itemSpawner"); GUI.EndScrollView(); } public static void DrawEquipmentMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle, GUIStyle offStyle) @@ -164,7 +164,7 @@ public static void DrawEquipmentMenu(float x, float y, float widthSize, int mulY GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 10, 95f), "E Q U I P M E N T L I S T", LabelStyle); equipmentSpawnerScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * 15), equipmentSpawnerScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); - Main.GiveEquipment(buttonStyle, "equipmentSpawner"); + ItemManager.GiveEquipment(buttonStyle, "equipmentSpawner"); GUI.EndScrollView(); } public static void DrawBuffMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle LabelStyle, GUIStyle offStyle) @@ -173,7 +173,7 @@ public static void DrawBuffMenu(float x, float y, float widthSize, int mulY, GUI GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 10, 95f), "B U F F L I S T", LabelStyle); equipmentSpawnerScrollPosition = GUI.BeginScrollView(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * 15), equipmentSpawnerScrollPosition, new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), false, true); - Main.GiveBuff(buttonStyle, "giveBuff"); + PlayerMod.GiveBuff(buttonStyle, "giveBuff"); GUI.EndScrollView(); } @@ -199,19 +199,19 @@ public static void DrawTeleMenu(float x, float y, float widthSize, int mulY, GUI GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 5, 95f), "T E L E P O R T E R M E N U", LabelStyle); if (GUI.Button(btn.BtnRect(1, false, "tele"), "S K I P S T A G E", buttonStyle)) - Main.skipStage(); + Teleporter.skipStage(); if (GUI.Button(btn.BtnRect(2, false, "tele"), "I N S T A N T T E L E P O R T E R C H A R G E", buttonStyle)) - Main.InstaTeleporter(); + Teleporter.InstaTeleporter(); if (GUI.Button(btn.BtnRect(3, false, "tele"), "M O U N T A I N C H A L L E N G E - C O U N T : " + TeleporterInteraction.instance.shrineBonusStacks.ToString(), buttonStyle)) - Main.addMountain(); + Teleporter.addMountain(); if (GUI.Button(btn.BtnRect(4, false, "tele"), "S P A W N A L L P O R T A L S", buttonStyle)) - Main.SpawnPortals("all"); + Teleporter.SpawnPortals("all"); if (GUI.Button(btn.BtnRect(5, false, "tele"), "S P A W N B L U E P O R T A L", buttonStyle)) - Main.SpawnPortals("newt"); + Teleporter.SpawnPortals("newt"); if (GUI.Button(btn.BtnRect(6, false, "tele"), "S P A W N C E L E S T A L P O R T A L", buttonStyle)) - Main.SpawnPortals("blue"); + Teleporter.SpawnPortals("blue"); if (GUI.Button(btn.BtnRect(7, false, "tele"), "S P A W N G O L D P O R T A L", buttonStyle)) - Main.SpawnPortals("gold"); + Teleporter.SpawnPortals("gold"); } public static void DrawESPMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle OnStyle, GUIStyle OffStyle, GUIStyle LabelStyle) @@ -248,153 +248,153 @@ public static void DrawPlayerModMenu(float x, float y, float widthSize, int mulY GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), "", BGstyle); GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 5, 95f), "P L A Y E R M O D I F I C A T I O N M E N U", LabelStyle); - if (GUI.Button(btn.BtnRect(1, true, "playermod"), "G I V E M O N E Y : " + Main.moneyToGive.ToString(), buttonStyle)) + if (GUI.Button(btn.BtnRect(1, true, "playermod"), "G I V E M O N E Y : " + PlayerMod.moneyToGive.ToString(), buttonStyle)) { - Main.GiveMoney(); + PlayerMod.GiveMoney(); } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.PlayerModBtnY, 40, 40), "-", OffStyle)) { - if (Main.moneyToGive > 50) - Main.moneyToGive -= 50; + if (PlayerMod.moneyToGive > 50) + PlayerMod.moneyToGive -= 50; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.PlayerModBtnY, 40, 40), "+", OffStyle)) { - if (Main.moneyToGive >= 50) - Main.moneyToGive += 50; + if (PlayerMod.moneyToGive >= 50) + PlayerMod.moneyToGive += 50; } - if (GUI.Button(btn.BtnRect(2, true, "playermod"), "G I V E L U N A R C O I N S : " + Main.coinsToGive.ToString(), buttonStyle)) + if (GUI.Button(btn.BtnRect(2, true, "playermod"), "G I V E L U N A R C O I N S : " + PlayerMod.coinsToGive.ToString(), buttonStyle)) { - Main.GiveLunarCoins(); + PlayerMod.GiveLunarCoins(); } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.PlayerModBtnY, 40, 40), "-", OffStyle)) { - if (Main.coinsToGive > 10) - Main.coinsToGive -= 10; + if (PlayerMod.coinsToGive > 10) + PlayerMod.coinsToGive -= 10; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.PlayerModBtnY, 40, 40), "+", OffStyle)) { - if (Main.coinsToGive >= 10) - Main.coinsToGive += 10; + if (PlayerMod.coinsToGive >= 10) + PlayerMod.coinsToGive += 10; } - if (GUI.Button(btn.BtnRect(3, true, "playermod"), "G I V E E X P E R I E N C E : " + Main.xpToGive.ToString(), buttonStyle)) + if (GUI.Button(btn.BtnRect(3, true, "playermod"), "G I V E E X P E R I E N C E : " + PlayerMod.xpToGive.ToString(), buttonStyle)) { - Main.giveXP(); + PlayerMod.giveXP(); } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.PlayerModBtnY, 40, 40), "-", OffStyle)) { - if (Main.xpToGive > 50) - Main.xpToGive -= 50; + if (PlayerMod.xpToGive > 50) + PlayerMod.xpToGive -= 50; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.PlayerModBtnY, 40, 40), "+", OffStyle)) { - if (Main.xpToGive >= 50) - Main.xpToGive += 50; + if (PlayerMod.xpToGive >= 50) + PlayerMod.xpToGive += 50; } if (Main.damageToggle) { - if (GUI.Button(btn.BtnRect(4, true, "playermod"), "D A M A G E P E R L V L : " + Main.damagePerLvl.ToString(), OnStyle)) + if (GUI.Button(btn.BtnRect(4, true, "playermod"), "D A M A G E P E R L V L : " + PlayerMod.damagePerLvl.ToString(), OnStyle)) { Main.damageToggle = false; } } - else if (GUI.Button(btn.BtnRect(4, true, "playermod"), "D A M A G E P E R L V L " + Main.damagePerLvl.ToString(), OffStyle)) + else if (GUI.Button(btn.BtnRect(4, true, "playermod"), "D A M A G E P E R L V L " + PlayerMod.damagePerLvl.ToString(), OffStyle)) { Main.damageToggle = true; } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.PlayerModBtnY, 40, 40), "-", OffStyle)) { - if (Main.damagePerLvl > 0) - Main.damagePerLvl -= 10; + if (PlayerMod.damagePerLvl > 0) + PlayerMod.damagePerLvl -= 10; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.PlayerModBtnY, 40, 40), "+", OffStyle)) { - if (Main.damagePerLvl >= 0) - Main.damagePerLvl += 10; + if (PlayerMod.damagePerLvl >= 0) + PlayerMod.damagePerLvl += 10; } if (Main.critToggle) { - if (GUI.Button(btn.BtnRect(5, true, "playermod"), "C R I T P E R L V L : " + Main.CritPerLvl.ToString(), OnStyle)) + if (GUI.Button(btn.BtnRect(5, true, "playermod"), "C R I T P E R L V L : " + PlayerMod.CritPerLvl.ToString(), OnStyle)) { Main.critToggle = false; } } - else if (GUI.Button(btn.BtnRect(5, true, "playermod"), "C R I T P E R L V L : " + Main.CritPerLvl.ToString(), OffStyle)) + else if (GUI.Button(btn.BtnRect(5, true, "playermod"), "C R I T P E R L V L : " + PlayerMod.CritPerLvl.ToString(), OffStyle)) { Main.critToggle = true; } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.PlayerModBtnY, 40, 40), "-", OffStyle)) { - if (Main.CritPerLvl > 0) - Main.CritPerLvl -= 1; + if (PlayerMod.CritPerLvl > 0) + PlayerMod.CritPerLvl -= 1; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.PlayerModBtnY, 40, 40), "+", OffStyle)) { - if (Main.CritPerLvl >= 0) - Main.CritPerLvl += 1; + if (PlayerMod.CritPerLvl >= 0) + PlayerMod.CritPerLvl += 1; } if (Main.attackSpeedToggle) { - if (GUI.Button(btn.BtnRect(6, true, "playermod"), "A T T A C K S P E E D : " + Main.attackSpeed.ToString(), OnStyle)) + if (GUI.Button(btn.BtnRect(6, true, "playermod"), "A T T A C K S P E E D : " + PlayerMod.attackSpeed.ToString(), OnStyle)) { Main.attackSpeedToggle = false; } } - else if (GUI.Button(btn.BtnRect(6, true, "playermod"), "A T T A C K S P E E D : " + Main.attackSpeed.ToString(), OffStyle)) + else if (GUI.Button(btn.BtnRect(6, true, "playermod"), "A T T A C K S P E E D : " + PlayerMod.attackSpeed.ToString(), OffStyle)) { Main.attackSpeedToggle = true; } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.PlayerModBtnY, 40, 40), "-", OffStyle)) { - if (Main.attackSpeed > 0) - Main.attackSpeed -= 1; + if (PlayerMod.attackSpeed > 0) + PlayerMod.attackSpeed -= 1; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.PlayerModBtnY, 40, 40), "+", OffStyle)) { - if (Main.attackSpeed >= 0) - Main.attackSpeed += 1; + if (PlayerMod.attackSpeed >= 0) + PlayerMod.attackSpeed += 1; } if (Main.armorToggle) { - if (GUI.Button(btn.BtnRect(7, true, "playermod"), "A R M O R : " + Main.armor.ToString(), OnStyle)) + if (GUI.Button(btn.BtnRect(7, true, "playermod"), "A R M O R : " + PlayerMod.armor.ToString(), OnStyle)) { Main.armorToggle = false; } } - else if (GUI.Button(btn.BtnRect(7, true, "playermod"), "A R M O R : " + Main.armor.ToString(), OffStyle)) + else if (GUI.Button(btn.BtnRect(7, true, "playermod"), "A R M O R : " + PlayerMod.armor.ToString(), OffStyle)) { Main.armorToggle = true; } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.PlayerModBtnY, 40, 40), "-", OffStyle)) { - if (Main.armor > 0) - Main.armor -= 10; + if (PlayerMod.armor > 0) + PlayerMod.armor -= 10; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.PlayerModBtnY, 40, 40), "+", OffStyle)) { - if (Main.armor >= 0) - Main.armor += 10; + if (PlayerMod.armor >= 0) + PlayerMod.armor += 10; } if (Main.moveSpeedToggle) { - if (GUI.Button(btn.BtnRect(8, true, "playermod"), "M O V E S P E E D : " + Main.movespeed.ToString(), OnStyle)) + if (GUI.Button(btn.BtnRect(8, true, "playermod"), "M O V E S P E E D : " + PlayerMod.movespeed.ToString(), OnStyle)) { Main.moveSpeedToggle = false; } } - else if (GUI.Button(btn.BtnRect(8, true, "playermod"), "M O V E S P E E D : " + Main.movespeed.ToString(), OffStyle)) + else if (GUI.Button(btn.BtnRect(8, true, "playermod"), "M O V E S P E E D : " + PlayerMod.movespeed.ToString(), OffStyle)) { Main.moveSpeedToggle = true; } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.PlayerModBtnY, 40, 40), "-", OffStyle)) { - if (Main.movespeed > 7) - Main.movespeed -= 10; + if (PlayerMod.movespeed > 7) + PlayerMod.movespeed -= 10; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.PlayerModBtnY, 40, 40), "+", OffStyle)) { - if (Main.movespeed >= 7) - Main.movespeed += 10; + if (PlayerMod.movespeed >= 7) + PlayerMod.movespeed += 10; } /*if (Main._CharacterToggle) { @@ -431,7 +431,7 @@ public static void DrawPlayerModMenu(float x, float y, float widthSize, int mulY } if (GUI.Button(btn.BtnRect(11, false, "playermod"), "R E M O V E A L L B U F F S", buttonStyle)) { - Main.RemoveAllBuffs(); + PlayerMod.RemoveAllBuffs(); } if (Main.aimBot) { @@ -502,7 +502,7 @@ public static void DrawPlayerModMenu(float x, float y, float widthSize, int mulY } if (GUI.Button(btn.BtnRect(17, false, "playermod"), "U N L O C K A L L", buttonStyle)) { - Main.UnlockAll(); + PlayerMod.UnlockAll(); } } public static void DrawItemManagementMenu(float x, float y, float widthSize, int mulY, GUIStyle BGstyle, GUIStyle buttonStyle, GUIStyle OnStyle, GUIStyle OffStyle, GUIStyle LabelStyle) @@ -510,33 +510,33 @@ public static void DrawItemManagementMenu(float x, float y, float widthSize, int GUI.Box(new Rect(x + 0f, y + 0f, widthSize + 10, 50f + 45 * mulY), "", BGstyle); GUI.Label(new Rect(x + 5f, y + 5f, widthSize + 5, 95f), "I T E M M A N A G E M E N T M E N U", LabelStyle); - if (GUI.Button(btn.BtnRect(1, true, "itemmanager"), "G I V E A L L I T E M S : " + Main.allItemsQuantity.ToString(), buttonStyle)) + if (GUI.Button(btn.BtnRect(1, true, "itemmanager"), "G I V E A L L I T E M S : " + ItemManager.allItemsQuantity.ToString(), buttonStyle)) { - Main.GiveAllItems(); + ItemManager.GiveAllItems(); } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.ItemManagerBtnY, 40, 40), "-", OffStyle)) { - if (Main.allItemsQuantity > 1) - Main.allItemsQuantity -= 1; + if (ItemManager.allItemsQuantity > 1) + ItemManager.allItemsQuantity -= 1; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.ItemManagerBtnY, 40, 40), "+", OffStyle)) { - if (Main.allItemsQuantity >= 1) - Main.allItemsQuantity += 1; + if (ItemManager.allItemsQuantity >= 1) + ItemManager.allItemsQuantity += 1; } - if (GUI.Button(btn.BtnRect(2, true, "itemmanager"), "R O L L I T E M S : " + Main.itemsToRoll.ToString(), buttonStyle)) + if (GUI.Button(btn.BtnRect(2, true, "itemmanager"), "R O L L I T E M S : " + ItemManager.itemsToRoll.ToString(), buttonStyle)) { - Main.RollItems(Main.itemsToRoll.ToString()); + ItemManager.RollItems(ItemManager.itemsToRoll.ToString()); } if (GUI.Button(new Rect(x + widthSize - 80, y + Main.ItemManagerBtnY, 40, 40), "-", OffStyle)) { - if (Main.itemsToRoll > 5) - Main.itemsToRoll -= 5; + if (ItemManager.itemsToRoll > 5) + ItemManager.itemsToRoll -= 5; } if (GUI.Button(new Rect(x + widthSize - 35, y + Main.ItemManagerBtnY, 40, 40), "+", OffStyle)) { - if (Main.itemsToRoll >= 5) - Main.itemsToRoll += 5; + if (ItemManager.itemsToRoll >= 5) + ItemManager.itemsToRoll += 5; } /*if (Main.isDropItems) { @@ -552,6 +552,7 @@ public static void DrawItemManagementMenu(float x, float y, float widthSize, int if (Main._isItemSpawnMenuOpen) { + Main._isEquipmentSpawnMenuOpen = false; if (GUI.Button(btn.BtnRect(3, false, "itemmanager"), "I T E M S P A W N M E N U : O N", OnStyle)) { Main._isItemSpawnMenuOpen = false; @@ -563,6 +564,7 @@ public static void DrawItemManagementMenu(float x, float y, float widthSize, int } if (Main._isEquipmentSpawnMenuOpen) { + Main._isItemSpawnMenuOpen = false; if (GUI.Button(btn.BtnRect(4, false, "itemmanager"), "E Q U I P M E N T S P A W N M E N U : O N", OnStyle)) { Main._isEquipmentSpawnMenuOpen = false; @@ -572,16 +574,16 @@ public static void DrawItemManagementMenu(float x, float y, float widthSize, int { Main._isEquipmentSpawnMenuOpen = true; } - if (Main.isDropItemForAll) + if (ItemManager.isDropItemForAll) { if (GUI.Button(btn.BtnRect(5, false, "itemmanager"), "G I V E N I T E M S D R O P : O N", OnStyle)) { - Main.isDropItemForAll = false; + ItemManager.isDropItemForAll = false; } } else if (GUI.Button(btn.BtnRect(5, false, "itemmanager"), "G I V E N I T E M S D R O P : O F F", OffStyle)) { - Main.isDropItemForAll = true; + ItemManager.isDropItemForAll = true; } if (Main.noEquipmentCooldown) { @@ -596,11 +598,11 @@ public static void DrawItemManagementMenu(float x, float y, float widthSize, int } if (GUI.Button(btn.BtnRect(7, false, "itemmanager"), "S T A C K I N V E N T O R Y", buttonStyle)) { - Main.StackInventory(); + ItemManager.StackInventory(); } if (GUI.Button(btn.BtnRect(8, false, "itemmanager"), "C L E A R I N V E N T O R Y", buttonStyle)) { - Main.ClearInventory(); + ItemManager.ClearInventory(); } } diff --git a/ESPHelper.cs b/ESPHelper.cs index 47f4458..4558b2d 100644 --- a/ESPHelper.cs +++ b/ESPHelper.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace RoRCheats +namespace UmbraRoR { public static class ESPHelper { diff --git a/ItemManager.cs b/ItemManager.cs new file mode 100644 index 0000000..7616c28 --- /dev/null +++ b/ItemManager.cs @@ -0,0 +1,307 @@ +using System; +using System.Linq; +using System.Collections.Generic; +using UnityEngine; +using RoR2; +using UnityEngine.Networking; + +namespace UmbraRoR +{ + public class ItemManager + { + public static int itemsToRoll = 5; + public static bool isDropItems = false; + public static bool isDropItemForAll = false; + public static int allItemsQuantity = 1; + + const Int16 HandleItemId = 99; + const Int16 HandleEquipmentId = 98; + + class DropItemPacket : MessageBase + { + public GameObject Player; + public ItemIndex ItemIndex; + public override void Serialize(NetworkWriter writer) + { + writer.Write(Player); + writer.Write((UInt16)ItemIndex); + } + + public override void Deserialize(NetworkReader reader) + { + Player = reader.ReadGameObject(); + ItemIndex = (ItemIndex)reader.ReadUInt16(); + } + } + class DropEquipmentPacket : MessageBase + { + public GameObject Player; + public EquipmentIndex EquipmentIndex; + public override void Serialize(NetworkWriter writer) + { + writer.Write(Player); + writer.Write((UInt16)EquipmentIndex); + } + + public override void Deserialize(NetworkReader reader) + { + Player = reader.ReadGameObject(); + EquipmentIndex = (EquipmentIndex)reader.ReadUInt16(); + } + } + static void SendDropItem(GameObject player, ItemIndex itemIndex) + { + NetworkServer.SendToAll(HandleItemId, new DropItemPacket + { + Player = player, + ItemIndex = itemIndex + }); + } + static void SendDropEquipment(GameObject player, EquipmentIndex equipmentIndex) + { + NetworkServer.SendToAll(HandleEquipmentId, new DropEquipmentPacket + { + Player = player, + EquipmentIndex = equipmentIndex + }); + } + [RoR2.Networking.NetworkMessageHandler(msgType = HandleItemId, client = true)] + static void HandleDropItem(NetworkMessage netMsg) + { + var dropItem = netMsg.ReadMessage(); + var body = dropItem.Player.GetComponent(); + /*if (isDropItems) + body.inventory.RemoveItem(dropItem.ItemIndex, 1); + if (isDropItemForAll && !isDropItems)*/ + PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(dropItem.ItemIndex), body.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + body.transform.forward * 2f); + } + [RoR2.Networking.NetworkMessageHandler(msgType = HandleEquipmentId, client = true)] + static void HandleDropEquipment(NetworkMessage netMsg) + { + var dropEquipment = netMsg.ReadMessage(); + var body = dropEquipment.Player.GetComponent(); + /*if (isDropItems) + body.inventory.RemoveItem(dropItem.ItemIndex, 1); + if (isDropItemForAll && !isDropItems)*/ + PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(dropEquipment.EquipmentIndex), body.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + body.transform.forward * 2f); + } + + public static void DropItemMethod(ItemIndex itemIndex) + { + var user = RoR2.LocalUserManager.GetFirstLocalUser(); + var networkClient = NetworkClient.allClients.FirstOrDefault(); + if (networkClient != null) + { + networkClient.RegisterHandlerSafe(HandleItemId, HandleDropItem); + } + SendDropItem(user.cachedBody.gameObject, itemIndex); + } + + public static void DropEquipmentMethod(EquipmentIndex equipmentIndex) + { + var user = RoR2.LocalUserManager.GetFirstLocalUser(); + var networkClient = NetworkClient.allClients.FirstOrDefault(); + if (networkClient != null) + { + networkClient.RegisterHandlerSafe(HandleEquipmentId, HandleDropEquipment); + } + SendDropEquipment(user.cachedBody.gameObject, equipmentIndex); + } + + //clears inventory, duh. + public static void ClearInventory() + { + if (Main.LocalPlayerInv) + { + //Loops through every item in ItemIndex enum + foreach (string itemName in Enum.GetNames(typeof(ItemIndex))) + { + ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); //Convert itemName string to and ItemIndex + Main.LocalPlayerInv.ResetItem(itemIndex); int itemCount = Main.LocalPlayerInv.GetItemCount(itemIndex); + //If an item exists, delete the whole stack of it + if (itemCount >= 0) // Just > doesnt delete from top bar + { + Main.LocalPlayerInv.RemoveItem(itemIndex, itemCount); + Main.LocalPlayerInv.ResetItem(itemIndex); + Main.LocalPlayerInv.itemAcquisitionOrder.Remove(itemIndex); + + //Destroys BeetleGuardAllies on inventory clear, other wise they dont get removed until next stage. + //TODO: Find a way to refresh UI/Remove beetle guard health from ui on the left + if (itemName == "BeetleGland") + { + var localUser = RoR2.LocalUserManager.GetFirstLocalUser(); + var controller = localUser.cachedMasterController; + if (!controller) + { + return; + } + var body = controller.master.GetBody(); + if (!body) + { + return; + } + var bullseyeSearch = new RoR2.BullseyeSearch(); + bullseyeSearch.filterByLoS = false; + bullseyeSearch.maxDistanceFilter = float.MaxValue; + bullseyeSearch.maxAngleFilter = float.MaxValue; + bullseyeSearch.RefreshCandidates(); + var hurtBoxList = bullseyeSearch.GetResults(); + foreach (var hurtbox in hurtBoxList) + { + var mob = HurtBox.FindEntityObject(hurtbox); + string mobName = mob.name.Replace("Body(Clone)", ""); + if (mobName == "BeetleGuardAlly") + { + UnityEngine.GameObject.Destroy(mob); + } + } + } + } + } + Main.LocalPlayerInv.SetEquipmentIndex(EquipmentIndex.None); + } + } + + // random items + public static void RollItems(string ammount) + { + try + { + int num; + TextSerialization.TryParseInvariant(ammount, out num); + if (num > 0) + { + WeightedSelection> weightedSelection = new WeightedSelection>(8); + weightedSelection.AddChoice(Run.instance.availableTier1DropList, 80f); + weightedSelection.AddChoice(Run.instance.availableTier2DropList, 19f); + weightedSelection.AddChoice(Run.instance.availableTier3DropList, 1f); + for (int i = 0; i < num; i++) + { + List list = weightedSelection.Evaluate(UnityEngine.Random.value); + Main.LocalPlayerInv.GiveItem(list[UnityEngine.Random.Range(0, list.Count)].itemIndex, 1); + } + } + } + catch (ArgumentException) + { + } + } + + public static void GiveAllItems() + { + if (Main.LocalPlayerInv) + { + foreach (string itemName in Enum.GetNames(typeof(ItemIndex))) + { + //plantonhit kills you when you pick it up + if (itemName == "PlantOnHit" || itemName == "HealthDecay" || itemName == "TonicAffliction" || itemName == "BurnNearby" || itemName == "CrippleWardOnLevel" || itemName == "Ghost" || itemName == "ExtraLifeConsumed") + continue; + ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); + Main.LocalPlayerInv.GiveItem(itemIndex, allItemsQuantity); + } + } + } + + public static void StackInventory() + { + //Does the same thing as the shrine of order. Orders all your items into stacks of several random items. + Main.LocalPlayerInv.ShrineRestackInventory(Run.instance.runRNG); + } + + public static void GiveItem(GUIStyle buttonStyle, string buttonName) + { + //Removes null items and no icon items from item list. Might change if requested. + string[] unreleasedItems = { "AACannon", "PlasmaCore", "LevelBonus", "CooldownOnCrit", "PlantOnHit", "MageAttunement", "BoostHp", "BoostDamage", "CritHeal", "BurnNearby", "CrippleWardOnLevel", "ExtraLifeConsumed", "Ghost", "HealthDecay", "DrizzlePlayerHelper", "MonsoonPlayerHelper", "TempestOnKill", "Count" }; + int buttonPlacement = 1; + foreach (string itemName in Enum.GetNames(typeof(ItemIndex))) + { + bool unreleasedullItem = unreleasedItems.Any(itemName.Contains); + if (!unreleasedullItem) + { + if (GUI.Button(btn.BtnRect(buttonPlacement, false, buttonName), itemName, buttonStyle)) + { + ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); + var localUser = LocalUserManager.GetFirstLocalUser(); + if (localUser.cachedMasterController && localUser.cachedMasterController.master) + { + if (isDropItemForAll) + { + DropItemMethod(itemIndex); + } + else + { + Main.LocalPlayerInv.GiveItem(itemIndex, 1); + } + } + } + buttonPlacement++; + } + //Since "Ghost" is unreleased item, "GhostOnKill" was getting removed from item list. + else if (itemName == "GhostOnKill") + { + if (GUI.Button(btn.BtnRect(buttonPlacement, false, buttonName), itemName, buttonStyle)) + { + ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); + var localUser = LocalUserManager.GetFirstLocalUser(); + if (localUser.cachedMasterController && localUser.cachedMasterController.master) + { + if (isDropItemForAll) + { + DropItemMethod(itemIndex); + } + else + { + Main.LocalPlayerInv.GiveItem(itemIndex, 1); + } + } + } + buttonPlacement++; + } + } + } + + public static void GiveEquipment(GUIStyle buttonStyle, string buttonName) + { + //Removes null equipment and no icon equipment from item list. Might change if requested. + string[] unreleasedEquipment = { "SoulJar", "AffixYellow", "AffixGold", "GhostGun", "OrbitalLaser", "Enigma", "LunarPotion", "SoulCorruptor", "Count" }; + int buttonPlacement = 1; + foreach (string equipmentName in Enum.GetNames(typeof(EquipmentIndex))) + { + bool unreleasedullEquipment = unreleasedEquipment.Any(equipmentName.Contains); + if (!unreleasedullEquipment) + { + if (GUI.Button(btn.BtnRect(buttonPlacement, false, buttonName), equipmentName, buttonStyle)) + { + EquipmentIndex equipmentIndex = (EquipmentIndex)Enum.Parse(typeof(EquipmentIndex), equipmentName); + var localUser = LocalUserManager.GetFirstLocalUser(); + if (localUser.cachedMasterController && localUser.cachedMasterController.master) + { + if (isDropItemForAll) + { + DropEquipmentMethod(equipmentIndex); + } + else + { + Main.LocalPlayerInv.SetEquipmentIndex(equipmentIndex); + } + + } + } + buttonPlacement++; + } + } + } + + //Sets equipment cooldown to 0 if its on cooldown + public static void NoEquipmentCooldown() + { + EquipmentState equipment = Main.LocalPlayerInv.GetEquipment((uint)Main.LocalPlayerInv.activeEquipmentSlot); + + if (equipment.chargeFinishTime != Run.FixedTimeStamp.zero) + { + Main.LocalPlayerInv.SetEquipment(new EquipmentState(equipment.equipmentIndex, Run.FixedTimeStamp.zero, equipment.charges), (uint)Main.LocalPlayerInv.activeEquipmentSlot); + } + } + } + +} diff --git a/Main.cs b/Main.cs index 94c8de5..80e463f 100644 --- a/Main.cs +++ b/Main.cs @@ -12,6 +12,7 @@ Organize Files Possible features: Respawn Spawn Mobs +Pause Multiplayer game */ using System; using System.Linq; @@ -24,16 +25,16 @@ Spawn Mobs using UnityEngine.SceneManagement; using Console = RoR2.Console; -namespace RoRCheats +namespace UmbraRoR { public class Main : MonoBehaviour { public const string NAME = "U M B R A", - VERSION = "1.0"; + VERSION = "1.2"; public static string log = "[" + NAME + "] "; - public static List unlockableNames = GetAllUnlockables(); + public static List unlockableNames = Utils.GetAllUnlockables(); #region Player Variables public static CharacterMaster LocalPlayer; @@ -67,7 +68,7 @@ public const string #region Button Styles / Toggles public static GUIStyle MainBgStyle, StatBgSytle, TeleBgStyle, OnStyle, OffStyle, LabelStyle, TitleStyle, BtnStyle, ItemBtnStyle, CornerStyle, DisplayStyle, BgStyle; //make new BgStyle for stats menu public static GUIStyle BtnStyle1, BtnStyle2, BtnStyle3; - public static bool skillToggle, renderInteractables, renderMobs, damageToggle, critToggle, attackSpeedToggle, armorToggle, regenToggle, moveSpeedToggle, MouseToggle, FlightToggle, listItems, noEquipmentCooldown, listBuffs, dropMenu, ShowUnlockAll; + public static bool skillToggle, renderInteractables, renderMobs, damageToggle, critToggle, attackSpeedToggle, armorToggle, regenToggle, moveSpeedToggle, MouseToggle, FlightToggle, listItems, noEquipmentCooldown, listBuffs, dropMenu, ShowUnlockAll, aimBot, alwaysSprint, godToggle; public static float delay = 0, widthSize = 500; #endregion @@ -85,40 +86,18 @@ public const string public static Rect itemManagerRect; #endregion - public static Texture2D Image = null, ontexture, onpresstexture, offtexture, offpresstexture, cornertexture, backtexture, btntexture, btnpresstexture, btntexturelabel; public static Texture2D NewTexture2D { get { return new Texture2D(1, 1); } } - - #region Stats intervals / toggles - public static int itemsToRoll = 5; - public static int damagePerLvl = 10; - public static int CritPerLvl = 1; - public static float attackSpeed = 1; - public static float armor = 0; - public static float movespeed = 7; - public static int jumpCount = 1; - public static bool isDropItems = false; - public static bool isDropItemForAll = false; - public static bool alwaysSprint = false; - public static bool aimBot = false; - public static bool godToggle = false; - public static int allItemsQuantity = 1; - public static ulong xpToGive = 50; - public static uint moneyToGive = 50; - public static uint coinsToGive = 50; - public static int ESPLimit = 1; - #endregion + public static Texture2D Image = null, ontexture, onpresstexture, offtexture, offpresstexture, cornertexture, backtexture, btntexture, btnpresstexture, btntexturelabel; public static int PlayerModBtnY, MainMulY, StatMulY, TeleMulY, ESPMulY, LobbyMulY, itemSpawnerMulY, equipmentSpawnerMulY, buffMenuMulY, CharacterMulY, PlayerModMulY, ItemManagerMulY, ItemManagerBtnY; - - public static Dictionary nameToIndexMap = new Dictionary(); - public static string[] Players = new string[16]; + public static int btnY, mulY; public static Rect rect = new Rect(10, 10, 20, 20); - - public static int btnY, mulY; - private Vector2 scrollViewVector = Vector2.zero; public Rect dropDownRect = new Rect(10, 10, 20, 20); + public static Dictionary nameToIndexMap = new Dictionary(); + public static string[] Players = new string[16]; + #region On GUI private void OnGUI() { #region GenerateMenus @@ -154,7 +133,7 @@ private void OnGUI() if (_isItemSpawnMenuOpen) { itemSpawnerRect = GUI.Window(5, itemSpawnerRect, new GUI.WindowFunction(SetSpawnerBG), "", new GUIStyle()); - DrawMenu.DrawSpawnMenu(itemSpawnerRect.x, itemSpawnerRect.y, widthSize, itemSpawnerMulY, MainBgStyle, BtnStyle, LabelStyle); + DrawMenu.DrawItemMenu(itemSpawnerRect.x, itemSpawnerRect.y, widthSize, itemSpawnerMulY, MainBgStyle, BtnStyle, LabelStyle); //Debug.Log("X : " + itemSpawnerRect.x + " Y : " + itemSpawnerRect.y); } if (_isPlayerMod) @@ -192,7 +171,9 @@ private void OnGUI() } #endregion } + #endregion On GUI + #region Start public void Start() { SceneManager.sceneLoaded += OnSceneLoaded; @@ -345,7 +326,9 @@ public void Start() } #endregion } + #endregion Start + #region Update public void Update() { try @@ -365,7 +348,9 @@ public void Update() } } + #endregion Update + #region Inputs private void CheckInputs() { if (_isMenuOpen) @@ -384,9 +369,10 @@ private void CheckInputs() } if (Input.GetKeyDown(KeyCode.V)) { - GiveMoney(); + PlayerMod.GiveMoney(); } } + #endregion Inputs #region Routines private void CharacterRoutine() @@ -401,11 +387,11 @@ private void ESPRoutine() { if (renderInteractables) { - RenderInteractables(); + Render.RenderInteractables(); } if (renderMobs) { - RenderMobs(); + Render.RenderMobs(); } } @@ -413,7 +399,7 @@ private void EquipCooldownRoutine() { if (noEquipmentCooldown) { - NoEquipmentCooldown(); + ItemManager.NoEquipmentCooldown(); } } @@ -430,13 +416,13 @@ private void StatsRoutine() private void AimBotRoutine() { if (aimBot) - AimBot(); + PlayerMod.AimBot(); } private void GodRoutine() { if (godToggle) { - GodMode(); + PlayerMod.GodMode(); } else { @@ -446,14 +432,14 @@ private void GodRoutine() private void SprintRoutine() { if (alwaysSprint) - AlwaysSprint(); + PlayerMod.AlwaysSprint(); } private void FlightRoutine() { if (FlightToggle) { - Flight(); + PlayerMod.Flight(); } } @@ -463,23 +449,23 @@ private void ModStatsRoutine() { if (damageToggle) { - LevelPlayersDamage(); + PlayerMod.LevelPlayersDamage(); } if (critToggle) { - LevelPlayersCrit(); + PlayerMod.LevelPlayersCrit(); } if (attackSpeedToggle) { - SetplayersAttackSpeed(); + PlayerMod.SetplayersAttackSpeed(); } if (armorToggle) { - SetplayersArmor(); + PlayerMod.SetplayersArmor(); } if (moveSpeedToggle) { - SetplayersMoveSpeed(); + PlayerMod.SetplayersMoveSpeed(); } LocalPlayerBody.RecalculateStats(); @@ -495,7 +481,7 @@ public void OnSceneLoaded(Scene scene, LoadSceneMode mode) if (scene.name == "title") { enableRespawnButton = false; - RESETMENU(); + Utils.ResetMenu(); } else if (!LocalHealth.alive && inGame) { @@ -505,7 +491,7 @@ public void OnSceneLoaded(Scene scene, LoadSceneMode mode) { enableRespawnButton = false; ModStatsRoutine(); - SoftResetMenu(); + Utils.SoftResetMenu(); } } #endregion @@ -839,7 +825,7 @@ public static Texture2D BtnTexture { btntexture = NewTexture2D; btntexture.SetPixel(0, 0, new Color32(120, 120, 120, 255)); - //byte[] FileData = File.ReadAllBytes(Directory.GetCurrentDirectory() + "/BepInEx/plugins/RoRCheats/Resources/Images/ButtonStyle.png"); + //byte[] FileData = File.ReadAllBytes(Directory.GetCurrentDirectory() + "/BepInEx/plugins/UmbraRoR/Resources/Images/ButtonStyle.png"); //btntexture.LoadImage(FileData); btntexture.Apply(); } @@ -925,7 +911,7 @@ public static Texture2D OffTexture { offtexture = NewTexture2D; offtexture.SetPixel(0, 0, new Color32(120, 120, 120, 255)); - //byte[] FileData = File.ReadAllBytes(Directory.GetCurrentDirectory() + "/BepInEx/plugins/RoRCheats/Resources/Images/OffStyle.png"); + //byte[] FileData = File.ReadAllBytes(Directory.GetCurrentDirectory() + "/BepInEx/plugins/UmbraRoR/Resources/Images/OffStyle.png"); //offtexture.LoadImage(FileData); offtexture.Apply(); } @@ -964,8 +950,9 @@ public static Texture2D CornerTexture #endregion Textures - #endregion + #endregion Routines + #region Auto Button Placement // Rect for buttons // It automatically auto position buttons. There is no need to change it public static Rect BtnRect(int y, bool multiplyBtn) @@ -978,10 +965,12 @@ public static Rect BtnRect(int y, bool multiplyBtn) } return new Rect(rect.x + 5, rect.y + 5 + 45 * y, widthSize, 40); } + #endregion + #region Get Character // try and setup our character, if we hit an error we set it to false //TODO: Find a way to stop it from checking whilst in main menu/lobby menu - private static void GetCharacter() + public static void GetCharacter() { try { @@ -1007,865 +996,6 @@ private static void GetCharacter() _CharacterCollected = false; } } - - #region ESP - public static void RenderInteractables() - { - foreach (TeleporterInteraction teleporterInteraction in FindObjectsOfType()) - { - float distanceToObject = Vector3.Distance(Camera.main.transform.position, teleporterInteraction.transform.position); - Vector3 Position = Camera.main.WorldToScreenPoint(teleporterInteraction.transform.position); - var BoundingVector = new Vector3(Position.x, Position.y, Position.z); - if (BoundingVector.z > 0.01) - { - GUI.color = - teleporterInteraction.isIdle ? Color.magenta : - teleporterInteraction.isIdleToCharging || teleporterInteraction.isCharging ? Color.yellow : - teleporterInteraction.isCharged ? Color.green : Color.yellow; - int distance = (int)distanceToObject; - String friendlyName = "Teleporter"; - string status = "" + ( - teleporterInteraction.isIdle ? "Idle" : - teleporterInteraction.isCharging ? "Charging" : - teleporterInteraction.isCharged ? "Charged" : - teleporterInteraction.isActiveAndEnabled ? "Idle" : - teleporterInteraction.isIdleToCharging ? "Idle-Charging" : - teleporterInteraction.isInFinalSequence ? "Final-Sequence" : - "???"); - string boxText = $"{friendlyName}\n{status}\n{distance}m"; - GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText); - } - } - - foreach (PurchaseInteraction purchaseInteraction in PurchaseInteraction.FindObjectsOfType(typeof(PurchaseInteraction))) - { - if (purchaseInteraction.available) - { - float distanceToObject = Vector3.Distance(Camera.main.transform.position, purchaseInteraction.transform.position); - Vector3 Position = Camera.main.WorldToScreenPoint(purchaseInteraction.transform.position); - var BoundingVector = new Vector3(Position.x, Position.y, Position.z); - if (BoundingVector.z > 0.01) - { - int distance = (int)distanceToObject; - GUI.color = Color.green; - String friendlyName = purchaseInteraction.GetDisplayName(); - int cost = purchaseInteraction.cost; - string boxText = $"{friendlyName}\n${cost}\n{distance}m"; - GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText); - } - } - } - } - - //Nees improvement. Causes a lot of lag - public static void RenderMobs() - { - if (ESPLimit % 1000 == 0) - { - var localUser = RoR2.LocalUserManager.GetFirstLocalUser(); - var controller = localUser.cachedMasterController; - if (!controller) - { - return; - } - var body = controller.master.GetBody(); - if (!body) - { - return; - } - var inputBank = body.GetComponent(); - var aimRay = new Ray(inputBank.aimOrigin, inputBank.aimDirection); - var bullseyeSearch = new RoR2.BullseyeSearch(); - var team = body.GetComponent(); - bullseyeSearch.searchOrigin = aimRay.origin; - bullseyeSearch.searchDirection = aimRay.direction; - bullseyeSearch.filterByLoS = false; - bullseyeSearch.maxDistanceFilter = 125; - bullseyeSearch.maxAngleFilter = 40f; - bullseyeSearch.teamMaskFilter = RoR2.TeamMask.all; - bullseyeSearch.teamMaskFilter.RemoveTeam(team.teamIndex); - bullseyeSearch.RefreshCandidates(); - var hurtBoxList = bullseyeSearch.GetResults(); - foreach (var hurtbox in hurtBoxList) - { - var mob = HurtBox.FindEntityObject(hurtbox); - if (mob) - { - Vector3 MobPosition = Camera.main.WorldToScreenPoint(mob.transform.position); - var MobBoundingVector = new Vector3(MobPosition.x, MobPosition.y, MobPosition.z); - float distanceToMob = Vector3.Distance(Camera.main.transform.position, mob.transform.position); - if (MobBoundingVector.z > 0.01) - { - GUI.color = Color.red; - string mobName = mob.name.Replace("Body(Clone)", ""); - int mobDistance = (int)distanceToMob; - string mobBoxText = $"{mobName}\n{mobDistance}m"; - GUI.Label(new Rect(MobBoundingVector.x - 50f, (float)Screen.height - MobBoundingVector.y + 30f, 100f, 50f), mobBoxText); - //WriteToLog($"Drew label. \n{mobBoxText}\n"); - } - } - } - } - else - { - ESPLimit++; - } - } - #endregion - - #region Teleporter - public static void InstaTeleporter() - { - if (TeleporterInteraction.instance) - { - TeleporterInteraction.instance.holdoutZoneController.baseChargeDuration = 1; - } - } - - public static void skipStage() - { - Run.instance.AdvanceStage(Run.instance.nextStageScene); - Debug.Log("RoRCheats : Skipped Stage"); - } - - public static void addMountain() - { - TeleporterInteraction.instance.AddShrineStack(); - } - - public static void SpawnPortals(string portal) - { - if (TeleporterInteraction.instance) - { - if (portal.Equals("gold")) - { - Debug.Log("RoRCheats : Spawned Gold Portal"); - TeleporterInteraction.instance.shouldAttemptToSpawnGoldshoresPortal = true; - } - else if (portal.Equals("newt")) - { - Debug.Log("RoRCheats : Spawned Shop Portal"); - TeleporterInteraction.instance.shouldAttemptToSpawnShopPortal = true; - } - else if (portal.Equals("blue")) - { - Debug.Log("RoRCheats : Spawned Celestal Portal"); - TeleporterInteraction.instance.shouldAttemptToSpawnMSPortal = true; - } - else if (portal.Equals("all")) - { - Debug.Log("RoRCheats : Spawned All Portals"); - TeleporterInteraction.instance.shouldAttemptToSpawnGoldshoresPortal = true; - TeleporterInteraction.instance.shouldAttemptToSpawnShopPortal = true; - TeleporterInteraction.instance.shouldAttemptToSpawnMSPortal = true; - } - else - { - Debug.LogError("Selection was " + portal + " please contact mod developer."); - } - } - } - #endregion - - #region Player Modifiers - public static void GiveBuff(GUIStyle buttonStyle, string buttonName) - { - //LocalPlayerBody.AddBuff(buff); - - int buttonPlacement = 1; - foreach (string buffName in Enum.GetNames(typeof(BuffIndex))) - { - //bool unreleasedullItem = unreleasedItems.Any(item.Contains); - if (GUI.Button(btn.BtnRect(buttonPlacement, false, buttonName), buffName, buttonStyle)) - { - BuffIndex buffIndex = (BuffIndex)Enum.Parse(typeof(BuffIndex), buffName); - var localUser = LocalUserManager.GetFirstLocalUser(); - if (localUser.cachedMasterController && localUser.cachedMasterController.master) - { - LocalPlayerBody.AddBuff(buffIndex); - } - } - buttonPlacement++; - } - } - - public static void RemoveAllBuffs() - { - foreach (string buff in Enum.GetNames(typeof(BuffIndex))) - { - BuffIndex buffName = (BuffIndex)Enum.Parse(typeof(BuffIndex), buff); - LocalPlayerBody.RemoveBuff(buffName); - } - } - - // self explanatory - public static void giveXP() - { - LocalPlayer.GiveExperience(xpToGive); - } - public static void GiveMoney() - { - LocalPlayer.GiveMoney(moneyToGive); - } - //uh, duh. - public static void GiveLunarCoins() - { - LocalNetworkUser.AwardLunarCoins(coinsToGive); - } - public static void LevelPlayersCrit() - { - try - { - LocalPlayerBody.levelCrit = (float)CritPerLvl; - } - catch (NullReferenceException) - { - } - } - - public static void LevelPlayersDamage() - { - try - { - LocalPlayerBody.levelDamage = (float)damagePerLvl; - } - catch (NullReferenceException) - { - } - } - public static void SetplayersAttackSpeed() - { - try - { - LocalPlayerBody.baseAttackSpeed = attackSpeed; - } - catch (NullReferenceException) - { - } - } - public static void SetplayersArmor() - { - try - { - LocalPlayerBody.baseArmor = armor; - } - catch (NullReferenceException) - { - } - } - public static void SetplayersMoveSpeed() - { - try - { - LocalPlayerBody.baseMoveSpeed = movespeed; - } - catch (NullReferenceException) - { - } - } - - public static void AimBot() - { - if (CursorIsVisible()) - { - return; - } - var localUser = RoR2.LocalUserManager.GetFirstLocalUser(); - var controller = localUser.cachedMasterController; - if (!controller) - { - return; - } - var body = controller.master.GetBody(); - if (!body) - { - return; - } - - var inputBank = body.GetComponent(); - var aimRay = new Ray(inputBank.aimOrigin, inputBank.aimDirection); - var bullseyeSearch = new RoR2.BullseyeSearch(); - var team = body.GetComponent(); - bullseyeSearch.teamMaskFilter = RoR2.TeamMask.all; - bullseyeSearch.teamMaskFilter.RemoveTeam(team.teamIndex); - bullseyeSearch.filterByLoS = true; - bullseyeSearch.searchOrigin = aimRay.origin; - bullseyeSearch.searchDirection = aimRay.direction; - bullseyeSearch.sortMode = RoR2.BullseyeSearch.SortMode.Distance; - bullseyeSearch.maxDistanceFilter = float.MaxValue; - bullseyeSearch.maxAngleFilter = 20f;// ;// float.MaxValue; - bullseyeSearch.RefreshCandidates(); - var hurtBox = bullseyeSearch.GetResults().FirstOrDefault(); - if (hurtBox) - { - Vector3 direction = hurtBox.transform.position - aimRay.origin; - inputBank.aimDirection = direction; - } - } - - public static void AlwaysSprint() - { - var isMoving = LocalNetworkUser.inputPlayer.GetAxis("MoveVertical") != 0f || LocalNetworkUser.inputPlayer.GetAxis("MoveHorizontal") != 0f; - var localUser = RoR2.LocalUserManager.GetFirstLocalUser(); - if (localUser == null || localUser.cachedMasterController == null || localUser.cachedMasterController.master == null) return; - var controller = localUser.cachedMasterController; - var body = controller.master.GetBody(); - if (body && !body.isSprinting && !localUser.inputPlayer.GetButton("Sprint")) - { - if (isMoving) - { - body.isSprinting = true; - } - } - } - - public static void Respawn() - { - LocalPlayer.RespawnExtraLife(); - } - - public static void GodMode() - { - LocalHealth.godMode = true; - } - #endregion - - #region Flight - - public static void Flight() - { - try - { - var forwardDirection = LocalPlayerBody.GetComponent().moveVector.normalized; - var aimDirection = LocalPlayerBody.GetComponent().aimDirection.normalized; - var upDirection = LocalPlayerBody.GetComponent().moveVector.y + 1; - var downDirection = LocalPlayerBody.GetComponent().moveVector.y - 1; - var isForward = Vector3.Dot(forwardDirection, aimDirection) > 0f; - - var isSprinting = LocalNetworkUser.inputPlayer.GetButton("Sprint"); - var isJumping = LocalNetworkUser.inputPlayer.GetButton("Jump"); - // ReSharper disable once CompareOfFloatsByEqualityOperator - var isStrafing = LocalNetworkUser.inputPlayer.GetAxis("MoveVertical") != 0f; - - if (isSprinting) - { - LocalPlayerBody.characterMotor.velocity = forwardDirection * 100f; - LocalPlayerBody.characterMotor.velocity.y = upDirection * 0.510005f; - if (isStrafing) - { - if (isForward) - { - LocalPlayerBody.characterMotor.velocity.y = aimDirection.y * 100f; - } - else - { - LocalPlayerBody.characterMotor.velocity.y = aimDirection.y * -100f; - } - } - } - else if (isJumping) - { - LocalPlayerBody.characterMotor.velocity.y = upDirection * 100; - } - else - { - LocalPlayerBody.characterMotor.velocity = forwardDirection * 50; - LocalPlayerBody.characterMotor.velocity.y = upDirection * 0.510005f; - if (isStrafing) - { - if (isForward) - { - LocalPlayerBody.characterMotor.velocity.y = aimDirection.y * 50; - } - else - { - LocalPlayerBody.characterMotor.velocity.y = aimDirection.y * -50; - } - } - } - } - catch (NullReferenceException) { } - } - #endregion - - #region Item Managers - const Int16 HandleId = 99; - class DropItemPacket : MessageBase - { - public GameObject Player; - public ItemIndex ItemIndex; - public override void Serialize(NetworkWriter writer) - { - writer.Write(Player); - writer.Write((UInt16)ItemIndex); - } - - public override void Deserialize(NetworkReader reader) - { - Player = reader.ReadGameObject(); - ItemIndex = (ItemIndex)reader.ReadUInt16(); - } - } - class DropEquipmentPacket : MessageBase - { - public GameObject Player; - public EquipmentIndex EquipmentIndex; - public override void Serialize(NetworkWriter writer) - { - writer.Write(Player); - writer.Write((UInt16)EquipmentIndex); - } - - public override void Deserialize(NetworkReader reader) - { - Player = reader.ReadGameObject(); - EquipmentIndex = (EquipmentIndex)reader.ReadUInt16(); - } - } - static void SendDropItem(GameObject player, ItemIndex itemIndex) - { - NetworkServer.SendToAll(HandleId, new DropItemPacket - { - Player = player, - ItemIndex = itemIndex - }); - } - static void SendDropEquipment(GameObject player, EquipmentIndex equipmentIndex) - { - NetworkServer.SendToAll(HandleId, new DropEquipmentPacket - { - Player = player, - EquipmentIndex = equipmentIndex - }); - } - [RoR2.Networking.NetworkMessageHandler(msgType = HandleId, client = true)] - static void HandleDropItem(NetworkMessage netMsg) - { - var dropItem = netMsg.ReadMessage(); - var body = dropItem.Player.GetComponent(); - /*if (isDropItems) - body.inventory.RemoveItem(dropItem.ItemIndex, 1); - if (isDropItemForAll && !isDropItems)*/ - PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(dropItem.ItemIndex), body.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + body.transform.forward * 2f); - } - static void HandleDropEquipment(NetworkMessage netMsg) - { - var dropEquipment = netMsg.ReadMessage(); - var body = dropEquipment.Player.GetComponent(); - /*if (isDropItems) - body.inventory.RemoveItem(dropItem.ItemIndex, 1); - if (isDropItemForAll && !isDropItems)*/ - PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(dropEquipment.EquipmentIndex), body.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + body.transform.forward * 2f); - } - - public static void DropItemMethod(ItemIndex itemIndex) - { - var user = RoR2.LocalUserManager.GetFirstLocalUser(); - var networkClient = NetworkClient.allClients.FirstOrDefault(); - if (networkClient != null) - { - networkClient.RegisterHandlerSafe(HandleId, HandleDropItem); - } - SendDropItem(user.cachedBody.gameObject, itemIndex); - } - - public static void DropEquipmentMethod(EquipmentIndex equipmentIndex) - { - var user = RoR2.LocalUserManager.GetFirstLocalUser(); - var networkClient = NetworkClient.allClients.FirstOrDefault(); - if (networkClient != null) - { - networkClient.RegisterHandlerSafe(HandleId, HandleDropEquipment); - } - SendDropEquipment(user.cachedBody.gameObject, equipmentIndex); - } - - //clears inventory, duh. - public static void ClearInventory() - { - if (LocalPlayerInv) - { - //Loops through every item in ItemIndex enum - foreach (string itemName in Enum.GetNames(typeof(ItemIndex))) - { - ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); //Convert itemName string to and ItemIndex - LocalPlayerInv.ResetItem(itemIndex); int itemCount = LocalPlayerInv.GetItemCount(itemIndex); - //If an item exists, delete the whole stack of it - if (itemCount >= 0) // Just > doesnt delete from top bar - { - LocalPlayerInv.RemoveItem(itemIndex, itemCount); LocalPlayerInv.ResetItem(itemIndex); - LocalPlayerInv.itemAcquisitionOrder.Remove(itemIndex); - - //Destroys BeetleGuardAllies on inventory clear, other wise they dont get removed until next stage. - //TODO: Find a way to refresh UI/Remove beetle guard health from ui on the left - if (itemName == "BeetleGland") - { - var localUser = RoR2.LocalUserManager.GetFirstLocalUser(); - var controller = localUser.cachedMasterController; - if (!controller) - { - return; - } - var body = controller.master.GetBody(); - if (!body) - { - return; - } - var bullseyeSearch = new RoR2.BullseyeSearch(); - bullseyeSearch.filterByLoS = false; - bullseyeSearch.maxDistanceFilter = float.MaxValue; - bullseyeSearch.maxAngleFilter = float.MaxValue; - bullseyeSearch.RefreshCandidates(); - var hurtBoxList = bullseyeSearch.GetResults(); - foreach (var hurtbox in hurtBoxList) - { - var mob = HurtBox.FindEntityObject(hurtbox); - string mobName = mob.name.Replace("Body(Clone)", ""); - if (mobName == "BeetleGuardAlly") - { - UnityEngine.GameObject.Destroy(mob); - } - } - } - } - } - LocalPlayerInv.SetEquipmentIndex(EquipmentIndex.None); - } - } - - // random items - public static void RollItems(string ammount) - { - try - { - int num; - TextSerialization.TryParseInvariant(ammount, out num); - if (num > 0) - { - WeightedSelection> weightedSelection = new WeightedSelection>(8); - weightedSelection.AddChoice(Run.instance.availableTier1DropList, 80f); - weightedSelection.AddChoice(Run.instance.availableTier2DropList, 19f); - weightedSelection.AddChoice(Run.instance.availableTier3DropList, 1f); - for (int i = 0; i < num; i++) - { - List list = weightedSelection.Evaluate(UnityEngine.Random.value); - LocalPlayerInv.GiveItem(list[UnityEngine.Random.Range(0, list.Count)].itemIndex, 1); - } - } - } - catch (ArgumentException) - { - } - } - - public static void GiveAllItems() - { - if (LocalPlayerInv) - { - foreach (string itemName in Enum.GetNames(typeof(ItemIndex))) - { - //plantonhit kills you when you pick it up - if (itemName == "PlantOnHit" || itemName == "HealthDecay" || itemName == "TonicAffliction" || itemName == "BurnNearby" || itemName == "CrippleWardOnLevel" || itemName == "Ghost" || itemName == "ExtraLifeConsumed") - continue; - ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); - LocalPlayerInv.GiveItem(itemIndex, allItemsQuantity); - } - } - } - - public static void StackInventory() - { - //Does the same thing as the shrine of order. Orders all your items into stacks of several random items. - LocalPlayerInv.ShrineRestackInventory(Run.instance.runRNG); - } - - public static void GiveItem(GUIStyle buttonStyle, string buttonName) - { - //Removes null items and no icon items from item list. Might change if requested. - string[] unreleasedItems = { "AACannon", "PlasmaCore", "LevelBonus", "CooldownOnCrit", "PlantOnHit", "MageAttunement", "BoostHp", "BoostDamage", "CritHeal", "BurnNearby", "CrippleWardOnLevel", "ExtraLifeConsumed", "Ghost", "HealthDecay", "DrizzlePlayerHelper", "MonsoonPlayerHelper", "TempestOnKill", "Count" }; - int buttonPlacement = 1; - foreach (string itemName in Enum.GetNames(typeof(ItemIndex))) - { - bool unreleasedullItem = unreleasedItems.Any(itemName.Contains); - if (!unreleasedullItem) - { - if (GUI.Button(btn.BtnRect(buttonPlacement, false, buttonName), itemName, buttonStyle)) - { - ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); - var localUser = LocalUserManager.GetFirstLocalUser(); - if (localUser.cachedMasterController && localUser.cachedMasterController.master) - { - if (isDropItemForAll) - { - DropItemMethod(itemIndex); - } - else - { - LocalPlayerInv.GiveItem(itemIndex, 1); - } - } - } - buttonPlacement++; - } - //Since "Ghost" is unreleased item, "GhostOnKill" was getting removed from item list. - else if (itemName == "GhostOnKill") - { - if (GUI.Button(btn.BtnRect(buttonPlacement, false, buttonName), itemName, buttonStyle)) - { - ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); - var localUser = LocalUserManager.GetFirstLocalUser(); - if (localUser.cachedMasterController && localUser.cachedMasterController.master) - { - if (isDropItemForAll) - { - DropItemMethod(itemIndex); - } - else - { - LocalPlayerInv.GiveItem(itemIndex, 1); - } - } - } - buttonPlacement++; - } - } - } - - public static void GiveEquipment(GUIStyle buttonStyle, string buttonName) - { - //Removes null equipment and no icon equipment from item list. Might change if requested. - string[] unreleasedEquipment = { "SoulJar", "AffixYellow", "AffixGold", "GhostGun", "OrbitalLaser", "Enigma", "LunarPotion", "SoulCorruptor", "Count" }; - int buttonPlacement = 1; - foreach (string equipmentName in Enum.GetNames(typeof(EquipmentIndex))) - { - bool unreleasedullEquipment = unreleasedEquipment.Any(equipmentName.Contains); - if (!unreleasedullEquipment) - { - if (GUI.Button(btn.BtnRect(buttonPlacement, false, buttonName), equipmentName, buttonStyle)) - { - EquipmentIndex equipmentIndex = (EquipmentIndex)Enum.Parse(typeof(EquipmentIndex), equipmentName); - var localUser = LocalUserManager.GetFirstLocalUser(); - if (localUser.cachedMasterController && localUser.cachedMasterController.master) - { - if (isDropItemForAll) - { - DropEquipmentMethod(equipmentIndex); - } - else - { - LocalPlayerInv.SetEquipmentIndex(equipmentIndex); - } - - } - } - buttonPlacement++; - } - } - } - - //Sets equipment cooldown to 0 if its on cooldown - public static void NoEquipmentCooldown() - { - EquipmentState equipment = LocalPlayerInv.GetEquipment((uint)LocalPlayerInv.activeEquipmentSlot); - - if (equipment.chargeFinishTime != Run.FixedTimeStamp.zero) - { - LocalPlayerInv.SetEquipment(new EquipmentState(equipment.equipmentIndex, Run.FixedTimeStamp.zero, equipment.charges), (uint)LocalPlayerInv.activeEquipmentSlot); - } - } - #endregion - - #region Util - public static Boolean CursorIsVisible() - { - foreach (var mpeventSystem in RoR2.UI.MPEventSystem.readOnlyInstancesList) - if (mpeventSystem.isCursorVisible) - return true; - return false; - } - //More posibilities here using console. - //Not added to ui yet. - public static void BanPlayer(NetworkUser PlayerName, NetworkUser LocalNetworkUser) - { - Console.instance.RunClientCmd(LocalNetworkUser, "ban_steam", new string[] { PlayerName.Network_id.steamId.ToString() }); - } - - //Kicks player - public static void KickPlayer(NetworkUser PlayerName, NetworkUser LocalNetworkUser) - { - Console.instance.RunClientCmd(LocalNetworkUser, "kick_steam", new string[] { PlayerName.Network_id.steamId.ToString() }); - } - - public static NetworkUser GetNetUserFromString(string playerString) - { - if (playerString != "") - { - if (int.TryParse(playerString, out int result)) - { - if (result < NetworkUser.readOnlyInstancesList.Count && result >= 0) - { - return NetworkUser.readOnlyInstancesList[result]; - } - return null; - } - else - { - foreach (NetworkUser n in NetworkUser.readOnlyInstancesList) - { - if (n.userName.Equals(playerString, StringComparison.CurrentCultureIgnoreCase)) - { - return n; - } - } - return null; - } - } - return null; - } - - public static void GetPlayers(string[] Players) - { - NetworkUser n; - for (int i = 0; i < NetworkUser.readOnlyInstancesList.Count; i++) - { - n = NetworkUser.readOnlyInstancesList[i]; - - Players[i] = n.userName; - } - } - //Reset menu when you return to main menu - public static void RESETMENU() - { - _ifDragged = false; - _CharacterCollected = false; - _isStatMenuOpen = false; - _isTeleMenuOpen = false; - _isESPMenuOpen = false; - _ItemToggle = false; - _CharacterToggle = false; - _isLobbyMenuOpen = false; - _isEditStatsOpen = false; - _isItemSpawnMenuOpen = false; - _isPlayerMod = false; - _isEquipmentSpawnMenuOpen = false; - _isBuffMenuOpen = false; - _isItemManagerOpen = false; - damageToggle = false; - noEquipmentCooldown = false; - critToggle = false; - skillToggle = false; - renderInteractables = false; - renderMobs = false; - attackSpeedToggle = false; - armorToggle = false; - regenToggle = false; - moveSpeedToggle = false; - godToggle = false; - FlightToggle = false; - isDropItemForAll = false; - alwaysSprint = false; - aimBot = false; - } - //Soft reset when moving to next stage to keep player stat mods and god mode between stages - public static void SoftResetMenu() - { - _isMenuOpen = !_isMenuOpen; - GetCharacter(); - _isMenuOpen = !_isMenuOpen; - godToggle = !godToggle; - GetCharacter(); - godToggle = !godToggle; - - } - - public static void UnlockAll() - { - //Goes through resource file containing all unlockables... Easily updatable, just paste "RoR2.UnlockCatalog" and GetAllUnlockable does the rest. - //This is needed to unlock logs - foreach (var unlockableName in unlockableNames) - { - var unlockableDef = UnlockableCatalog.GetUnlockableDef(unlockableName); - NetworkUser networkUser = Util.LookUpBodyNetworkUser(LocalPlayerBody); - if (networkUser) - { - networkUser.ServerHandleUnlock(unlockableDef); - } - } - - //Gives all achievements. - var achievementManager = AchievementManager.GetUserAchievementManager(LocalUserManager.GetFirstLocalUser()); - foreach (var achievement in AchievementManager.allAchievementDefs) - { - achievementManager.GrantAchievement(achievement); - } - - //Give all survivors - var profile = LocalUserManager.GetFirstLocalUser().userProfile; - foreach (var survivor in SurvivorCatalog.allSurvivorDefs) - { - if (profile.statSheet.GetStatValueDouble(RoR2.Stats.PerBodyStatDef.totalTimeAlive, survivor.bodyPrefab.name) == 0.0) - profile.statSheet.SetStatValueFromString(RoR2.Stats.PerBodyStatDef.totalTimeAlive.FindStatDef(survivor.bodyPrefab.name), "0.1"); - } - - //All items and equipments - foreach (string itemName in Enum.GetNames(typeof(ItemIndex))) - { - ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); - profile.DiscoverPickup(PickupCatalog.FindPickupIndex(itemIndex)); - } - - foreach (string equipmentName in Enum.GetNames(typeof(EquipmentIndex))) - { - EquipmentIndex equipmentIndex = (EquipmentIndex)Enum.Parse(typeof(EquipmentIndex), equipmentName); - profile.DiscoverPickup(PickupCatalog.FindPickupIndex(equipmentIndex)); - } - } - public static List GetAllUnlockables() - { - var unlockableName = new List(); - - var assembly = Assembly.GetExecutingAssembly(); - var resourceName = "RoRCheats.Resources.Unlockables.txt"; - - Stream stream = assembly.GetManifestResourceStream(resourceName); - StreamReader reader = new StreamReader(stream); - while (!reader.EndOfStream) - { - string line1 = reader.ReadLine(); - line1 = line1.Replace("UnlockableCatalog.RegisterUnlockable(\"", ""); - line1 = line1.Replace("\", new UnlockableDef", ""); - line1 = line1.Replace("true", ""); - line1 = line1.Replace("});", ""); - line1 = line1.Replace("=", ""); - line1 = line1.Replace("\"", ""); - line1 = line1.Replace("false", ""); - line1 = line1.Replace(",", ""); - line1 = line1.Replace("hidden", ""); - line1 = line1.Replace("{", ""); - line1 = line1.Replace("nameToken", ""); - line1 = line1.Replace(" ", ""); - string[] lineArray = line1.Split(null); - foreach (var line in lineArray) - { - //TODO: Simplify later - if (line.StartsWith("Logs.") || line.StartsWith("Characters.") || line.StartsWith("Items.") || line.StartsWith("Skills.") || line.StartsWith("Skins.") || line.StartsWith("Shop.") || line.StartsWith("Artifacts.") || line.StartsWith("NewtStatue.")) - { - unlockableName.Add(line); - } - } - } - return unlockableName; - } - - // Used during testing and debugging - public static void WriteToLog(string logContent) - { - string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - using (StreamWriter outputFile = new StreamWriter(System.IO.Path.Combine(docPath, "UmbraLog.txt"), true)) - { - outputFile.WriteLine(log + logContent); - } - } #endregion } } diff --git a/Player.cs b/Player.cs new file mode 100644 index 0000000..276fded --- /dev/null +++ b/Player.cs @@ -0,0 +1,283 @@ +using System; +using System.Linq; +using UnityEngine; +using RoR2; + +namespace UmbraRoR +{ + public class PlayerMod + { + public static int damagePerLvl = 10; + public static int CritPerLvl = 1; + public static float attackSpeed = 1; + public static float armor = 0; + public static float movespeed = 7; + public static int jumpCount = 1; + public static ulong xpToGive = 50; + public static uint moneyToGive = 50; + public static uint coinsToGive = 50; + + public static void GiveBuff(GUIStyle buttonStyle, string buttonName) + { + //LocalPlayerBody.AddBuff(buff); + + int buttonPlacement = 1; + foreach (string buffName in Enum.GetNames(typeof(BuffIndex))) + { + //bool unreleasedullItem = unreleasedItems.Any(item.Contains); + if (GUI.Button(btn.BtnRect(buttonPlacement, false, buttonName), buffName, buttonStyle)) + { + BuffIndex buffIndex = (BuffIndex)Enum.Parse(typeof(BuffIndex), buffName); + var localUser = LocalUserManager.GetFirstLocalUser(); + if (localUser.cachedMasterController && localUser.cachedMasterController.master) + { + Main.LocalPlayerBody.AddBuff(buffIndex); + } + } + buttonPlacement++; + } + } + + public static void RemoveAllBuffs() + { + foreach (string buffName in Enum.GetNames(typeof(BuffIndex))) + { + BuffIndex buffIndex = (BuffIndex)Enum.Parse(typeof(BuffIndex), buffName); + while (Main.LocalPlayerBody.HasBuff(buffIndex)) + { + Main.LocalPlayerBody.RemoveBuff(buffIndex); + } + } + } + + // self explanatory + public static void giveXP() + { + Main.LocalPlayer.GiveExperience(xpToGive); + } + public static void GiveMoney() + { + Main.LocalPlayer.GiveMoney(moneyToGive); + } + //uh, duh. + public static void GiveLunarCoins() + { + Main.LocalNetworkUser.AwardLunarCoins(coinsToGive); + } + public static void LevelPlayersCrit() + { + try + { + Main.LocalPlayerBody.levelCrit = (float)CritPerLvl; + } + catch (NullReferenceException) + { + } + } + + public static void LevelPlayersDamage() + { + try + { + Main.LocalPlayerBody.levelDamage = (float)damagePerLvl; + } + catch (NullReferenceException) + { + } + } + public static void SetplayersAttackSpeed() + { + try + { + Main.LocalPlayerBody.baseAttackSpeed = attackSpeed; + } + catch (NullReferenceException) + { + } + } + public static void SetplayersArmor() + { + try + { + Main.LocalPlayerBody.baseArmor = armor; + } + catch (NullReferenceException) + { + } + } + public static void SetplayersMoveSpeed() + { + try + { + Main.LocalPlayerBody.baseMoveSpeed = movespeed; + } + catch (NullReferenceException) + { + } + } + + public static void AimBot() + { + if (Utils.CursorIsVisible()) + { + return; + } + var localUser = RoR2.LocalUserManager.GetFirstLocalUser(); + var controller = localUser.cachedMasterController; + if (!controller) + { + return; + } + var body = controller.master.GetBody(); + if (!body) + { + return; + } + + var inputBank = body.GetComponent(); + var aimRay = new Ray(inputBank.aimOrigin, inputBank.aimDirection); + var bullseyeSearch = new RoR2.BullseyeSearch(); + var team = body.GetComponent(); + bullseyeSearch.teamMaskFilter = RoR2.TeamMask.all; + bullseyeSearch.teamMaskFilter.RemoveTeam(team.teamIndex); + bullseyeSearch.filterByLoS = true; + bullseyeSearch.searchOrigin = aimRay.origin; + bullseyeSearch.searchDirection = aimRay.direction; + bullseyeSearch.sortMode = RoR2.BullseyeSearch.SortMode.Distance; + bullseyeSearch.maxDistanceFilter = float.MaxValue; + bullseyeSearch.maxAngleFilter = 20f;// ;// float.MaxValue; + bullseyeSearch.RefreshCandidates(); + var hurtBox = bullseyeSearch.GetResults().FirstOrDefault(); + if (hurtBox) + { + Vector3 direction = hurtBox.transform.position - aimRay.origin; + inputBank.aimDirection = direction; + } + } + + public static void AlwaysSprint() + { + var isMoving = Main.LocalNetworkUser.inputPlayer.GetAxis("MoveVertical") != 0f || Main.LocalNetworkUser.inputPlayer.GetAxis("MoveHorizontal") != 0f; + var localUser = RoR2.LocalUserManager.GetFirstLocalUser(); + if (localUser == null || localUser.cachedMasterController == null || localUser.cachedMasterController.master == null) return; + var controller = localUser.cachedMasterController; + var body = controller.master.GetBody(); + if (body && !body.isSprinting && !localUser.inputPlayer.GetButton("Sprint")) + { + if (isMoving) + { + body.isSprinting = true; + } + } + } + + //Respawn... Not sure how to implement it. + public static void Respawn() + { + Main.LocalPlayer.RespawnExtraLife(); + } + + public static void GodMode() + { + Main.LocalHealth.godMode = true; + } + + public static void Flight() + { + try + { + var forwardDirection = Main.LocalPlayerBody.GetComponent().moveVector.normalized; + var aimDirection = Main.LocalPlayerBody.GetComponent().aimDirection.normalized; + var upDirection = Main.LocalPlayerBody.GetComponent().moveVector.y + 1; + var downDirection = Main.LocalPlayerBody.GetComponent().moveVector.y - 1; + var isForward = Vector3.Dot(forwardDirection, aimDirection) > 0f; + + var isSprinting = Main.LocalNetworkUser.inputPlayer.GetButton("Sprint"); + var isJumping = Main.LocalNetworkUser.inputPlayer.GetButton("Jump"); + // ReSharper disable once CompareOfFloatsByEqualityOperator + var isStrafing = Main.LocalNetworkUser.inputPlayer.GetAxis("MoveVertical") != 0f; + + if (isSprinting) + { + Main.LocalPlayerBody.characterMotor.velocity = forwardDirection * 100f; + Main.LocalPlayerBody.characterMotor.velocity.y = upDirection * 0.510005f; + if (isStrafing) + { + if (isForward) + { + Main.LocalPlayerBody.characterMotor.velocity.y = aimDirection.y * 100f; + } + else + { + Main.LocalPlayerBody.characterMotor.velocity.y = aimDirection.y * -100f; + } + } + } + else if (isJumping) + { + Main.LocalPlayerBody.characterMotor.velocity.y = upDirection * 100; + } + else + { + Main.LocalPlayerBody.characterMotor.velocity = forwardDirection * 50; + Main.LocalPlayerBody.characterMotor.velocity.y = upDirection * 0.510005f; + if (isStrafing) + { + if (isForward) + { + Main.LocalPlayerBody.characterMotor.velocity.y = aimDirection.y * 50; + } + else + { + Main.LocalPlayerBody.characterMotor.velocity.y = aimDirection.y * -50; + } + } + } + } + catch (NullReferenceException) { } + } + + public static void UnlockAll() + { + //Goes through resource file containing all unlockables... Easily updatable, just paste "RoR2.UnlockCatalog" and GetAllUnlockable does the rest. + //This is needed to unlock logs + foreach (var unlockableName in Main.unlockableNames) + { + var unlockableDef = UnlockableCatalog.GetUnlockableDef(unlockableName); + NetworkUser networkUser = Util.LookUpBodyNetworkUser(Main.LocalPlayerBody); + if (networkUser) + { + networkUser.ServerHandleUnlock(unlockableDef); + } + } + + //Gives all achievements. + var achievementManager = AchievementManager.GetUserAchievementManager(LocalUserManager.GetFirstLocalUser()); + foreach (var achievement in AchievementManager.allAchievementDefs) + { + achievementManager.GrantAchievement(achievement); + } + + //Give all survivors + var profile = LocalUserManager.GetFirstLocalUser().userProfile; + foreach (var survivor in SurvivorCatalog.allSurvivorDefs) + { + if (profile.statSheet.GetStatValueDouble(RoR2.Stats.PerBodyStatDef.totalTimeAlive, survivor.bodyPrefab.name) == 0.0) + profile.statSheet.SetStatValueFromString(RoR2.Stats.PerBodyStatDef.totalTimeAlive.FindStatDef(survivor.bodyPrefab.name), "0.1"); + } + + //All items and equipments + foreach (string itemName in Enum.GetNames(typeof(ItemIndex))) + { + ItemIndex itemIndex = (ItemIndex)Enum.Parse(typeof(ItemIndex), itemName); + profile.DiscoverPickup(PickupCatalog.FindPickupIndex(itemIndex)); + } + + foreach (string equipmentName in Enum.GetNames(typeof(EquipmentIndex))) + { + EquipmentIndex equipmentIndex = (EquipmentIndex)Enum.Parse(typeof(EquipmentIndex), equipmentName); + profile.DiscoverPickup(PickupCatalog.FindPickupIndex(equipmentIndex)); + } + } + } +} diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 661e056..3c71b86 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -5,11 +5,11 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("RiskOfRainCheats")] +[assembly: AssemblyTitle("UmbraRoR")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("RiskOfRainCheats")] +[assembly: AssemblyProduct("UmbraRoR")] [assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.2.0.0")] +[assembly: AssemblyFileVersion("1.2.0.0")] diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index b74d65d..55b318d 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace RoRCheats.Properties { +namespace UmbraRoR.Properties { using System; @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RoRCheats.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UmbraRoR.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -61,21 +61,22 @@ internal Resources() { } /// - /// Looks up a localized string similar to private static void Init() + /// Looks up a localized string similar to using System; + ///using System.Collections.Generic; + ///using System.Linq; + /// + ///namespace RoR2 + ///{ + /// // Token: 0x020004E0 RID: 1248 + /// public static class UnlockableCatalog + /// { + /// // Token: 0x06001EA1 RID: 7841 RVA: 0x0007D942 File Offset: 0x0007BB42 + /// private static void RegisterUnlockable(string name, UnlockableDef unlockableDef) /// { - /// UnlockableCatalog.RegisterUnlockable("Logs.BeetleBody.0", new UnlockableDef - /// { - /// nameToken = "UNLOCKABLE_LOG_BEETLE" - /// }); - /// UnlockableCatalog.RegisterUnlockable("Logs.BeetleGuardBody.0", new UnlockableDef - /// { - /// nameToken = "UNLOCKABLE_LOG_BEETLEGUARD" - /// }); - /// UnlockableCatalog.RegisterUnlockable("Logs.BeetleQueenBody.0", new UnlockableDef - /// { - /// nameToken = "UNLOCKABLE_LOG_BEETLEQUEEN" - /// }); - /// UnlockableCatalog.RegisterUnlockable("Logs.BisonBod [rest of string was truncated]";. + /// unlockableDef.name = name; + /// unlockableDef.index = new UnlockableIndex(UnlockableCatalog.nameToDefTable.Count); + /// UnlockableCatalog.nameToDefTable.Add(name, unlockableDef); + /// [rest of string was truncated]";. /// internal static string Unlockables { get { diff --git a/README.md b/README.md index 9cbe20b..4b333d7 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ Make ESP less laggy? Clear Items despawn beatle gaurds/Allies from UI Press X to go down while fly is enabled add media section to github readme -Organize Files Possible features: Respawn @@ -50,11 +49,11 @@ Spawn Mobs ### Requirements - [ ] A Mono Injector. [Sharpmonoinjector](https://github.com/warbler/SharpMonoInjector) is recommended and is used in this tutorial. -1. Head to [releases](https://github.com/Acher0ns/Umbra-Mod-Menu/releases) and download `Umbra Menu.zip` +1. Head to [releases](https://github.com/Acher0ns/Umbra-Mod-Menu/releases) and download `UmbraMenu.zip` 2. Extract the zip 3. Use your favorite mono injector to inject the dll (If you do not know how to use sharpmonoinjector, scroll down to that section) ``` -Namespace: RoRCheats +Namespace: UmbraRoR Class: Loader Method: Load ``` @@ -80,11 +79,11 @@ Method: Load 5) UnityEngine.IMGUModule.dll 6) UnityEngine.CoreModule.dll ``` -6. Press ctrl+b to build dll and it should be located where you found the .sln file -> bin -> Debug -> RoRCheats.dll +6. Press ctrl+b to build dll and it should be located where you found the .sln file -> bin -> Debug -> UmbraRoR.dll 7. Use your favorite mono injector to inject the dll (If you do not know how to use sharpmonoinjector, scroll down to that section) ``` -Namespace: RoRCheats +Namespace: UmbraRoR Class: Loader Method: Load ``` @@ -99,15 +98,15 @@ After you have your dll file, you'll need to have a way to inject it into the ga obviously replacing [path to folder with smi.exe in it] with the proper path (keep the quotes). For example my command is: -`cd "C:\Users\Kamron Cole\Documents\My Cheats\RoR2\SharpMonoInjector.Console\SharpMonoInjector.Console"` +`cd "C:\Users\Username\Documents\My Cheats\RoR2\SharpMonoInjector.Console\SharpMonoInjector.Console"` 3. You can tell if you're in the proper directory if you type `dir` and you see SharpMonoInjector.dll and smi.exe listed 4. Once you are in the proper directory and Risk of Rain 2 is open, type -`smi.exe inject -p "Risk of Rain 2" -a "[Path to RoRCheats.dll]" -n RoRCheats -c Loader -m Load` +`smi.exe inject -p "Risk of Rain 2" -a "[Path to UmbraRoR.dll]" -n UmbraRoR -c Loader -m Load` -again replacing [Path to RoRCheats.dll] with the proper path (keep the quotes) +again replacing [Path to UmbraRoR.dll] with the proper path (keep the quotes) ### Batch file 1. Once you have sharpmonoinjector downloaded from [here](https://github.com/warbler/SharpMonoInjector/releases/download/v2.2/SharpMonoInjector.Console.zip), extract the zip. @@ -117,10 +116,10 @@ again replacing [Path to RoRCheats.dll] with the proper path (keep the quotes) @echo off cd "[path to folder with smi.exe]" cls -smi.exe inject -p "Risk of Rain 2" -a "[Path to RoRCheats.dll]" -n RoRCheats -c Loader -m Load +smi.exe inject -p "Risk of Rain 2" -a "[Path to UmbraRoR.dll]" -n UmbraRoR -c Loader -m Load pause ``` -4. Replace [path to folder with smi.exe] and [Path to RoRCheats.dll] with the proper paths (keep quotes if they are there) +4. Replace [path to folder with smi.exe] and [Path to UmbraRoR.dll] with the proper paths (keep quotes if they are there) 5. Press ctrl+shift+s and name it `start.bat` (make sure you replace .txt with .bat) 6. If everything was done properly, while the game is open just run `start.bat` as administrator and the Menu should automatically be injected into the game diff --git a/Render.cs b/Render.cs new file mode 100644 index 0000000..5bee322 --- /dev/null +++ b/Render.cs @@ -0,0 +1,105 @@ +using System; +using UnityEngine; +using RoR2; + +namespace UmbraRoR +{ + public class Render : MonoBehaviour + { + public static void RenderInteractables() + { + foreach (TeleporterInteraction teleporterInteraction in FindObjectsOfType()) + { + float distanceToObject = Vector3.Distance(Camera.main.transform.position, teleporterInteraction.transform.position); + Vector3 Position = Camera.main.WorldToScreenPoint(teleporterInteraction.transform.position); + var BoundingVector = new Vector3(Position.x, Position.y, Position.z); + if (BoundingVector.z > 0.01) + { + GUI.color = + teleporterInteraction.isIdle ? Color.magenta : + teleporterInteraction.isIdleToCharging || teleporterInteraction.isCharging ? Color.yellow : + teleporterInteraction.isCharged ? Color.green : Color.yellow; + int distance = (int)distanceToObject; + String friendlyName = "Teleporter"; + string status = "" + ( + teleporterInteraction.isIdle ? "Idle" : + teleporterInteraction.isCharging ? "Charging" : + teleporterInteraction.isCharged ? "Charged" : + teleporterInteraction.isActiveAndEnabled ? "Idle" : + teleporterInteraction.isIdleToCharging ? "Idle-Charging" : + teleporterInteraction.isInFinalSequence ? "Final-Sequence" : + "???"); + string boxText = $"{friendlyName}\n{status}\n{distance}m"; + GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText); + } + } + + foreach (PurchaseInteraction purchaseInteraction in PurchaseInteraction.FindObjectsOfType(typeof(PurchaseInteraction))) + { + if (purchaseInteraction.available) + { + float distanceToObject = Vector3.Distance(Camera.main.transform.position, purchaseInteraction.transform.position); + Vector3 Position = Camera.main.WorldToScreenPoint(purchaseInteraction.transform.position); + var BoundingVector = new Vector3(Position.x, Position.y, Position.z); + if (BoundingVector.z > 0.01) + { + int distance = (int)distanceToObject; + GUI.color = Color.green; + String friendlyName = purchaseInteraction.GetDisplayName(); + int cost = purchaseInteraction.cost; + string boxText = $"{friendlyName}\n${cost}\n{distance}m"; + GUI.Label(new Rect(BoundingVector.x - 50f, (float)Screen.height - BoundingVector.y, 100f, 50f), boxText); + } + } + } + } + + //Needs improvement. Causes a lot of lag + public static void RenderMobs() + { + var localUser = RoR2.LocalUserManager.GetFirstLocalUser(); + var controller = localUser.cachedMasterController; + if (!controller) + { + return; + } + var body = controller.master.GetBody(); + if (!body) + { + return; + } + var inputBank = body.GetComponent(); + var aimRay = new Ray(inputBank.aimOrigin, inputBank.aimDirection); + var bullseyeSearch = new RoR2.BullseyeSearch(); + var team = body.GetComponent(); + bullseyeSearch.searchOrigin = aimRay.origin; + bullseyeSearch.searchDirection = aimRay.direction; + bullseyeSearch.filterByLoS = false; + bullseyeSearch.maxDistanceFilter = 125; + bullseyeSearch.maxAngleFilter = 40f; + bullseyeSearch.teamMaskFilter = RoR2.TeamMask.all; + bullseyeSearch.teamMaskFilter.RemoveTeam(team.teamIndex); + bullseyeSearch.RefreshCandidates(); + var hurtBoxList = bullseyeSearch.GetResults(); + foreach (var hurtbox in hurtBoxList) + { + var mob = HurtBox.FindEntityObject(hurtbox); + if (mob) + { + Vector3 MobPosition = Camera.main.WorldToScreenPoint(mob.transform.position); + var MobBoundingVector = new Vector3(MobPosition.x, MobPosition.y, MobPosition.z); + float distanceToMob = Vector3.Distance(Camera.main.transform.position, mob.transform.position); + if (MobBoundingVector.z > 0.01) + { + GUI.color = Color.red; + string mobName = mob.name.Replace("Body(Clone)", ""); + int mobDistance = (int)distanceToMob; + string mobBoxText = $"{mobName}\n{mobDistance}m"; + GUI.Label(new Rect(MobBoundingVector.x - 50f, (float)Screen.height - MobBoundingVector.y + 30f, 100f, 50f), mobBoxText); + //WriteToLog($"Drew label. \n{mobBoxText}\n"); + } + } + } + } + } +} diff --git a/Teleporter.cs b/Teleporter.cs new file mode 100644 index 0000000..63b927c --- /dev/null +++ b/Teleporter.cs @@ -0,0 +1,55 @@ +using UnityEngine; +using RoR2; + +namespace UmbraRoR +{ + public class Teleporter + { + public static void InstaTeleporter() + { + if (TeleporterInteraction.instance) + { + TeleporterInteraction.instance.holdoutZoneController.baseChargeDuration = 1; + } + } + + public static void skipStage() + { + Run.instance.AdvanceStage(Run.instance.nextStageScene); + } + + public static void addMountain() + { + TeleporterInteraction.instance.AddShrineStack(); + } + + public static void SpawnPortals(string portal) + { + if (TeleporterInteraction.instance) + { + if (portal.Equals("gold")) + { + Debug.Log("UmbraRoR : Spawned Gold Portal"); + TeleporterInteraction.instance.shouldAttemptToSpawnGoldshoresPortal = true; + } + else if (portal.Equals("newt")) + { + Debug.Log("UmbraRoR : Spawned Shop Portal"); + TeleporterInteraction.instance.shouldAttemptToSpawnShopPortal = true; + } + else if (portal.Equals("blue")) + { + Debug.Log("UmbraRoR : Spawned Celestal Portal"); + TeleporterInteraction.instance.shouldAttemptToSpawnMSPortal = true; + } + else if (portal.Equals("all")) + { + Debug.Log("UmbraRoR : Spawned All Portals"); + TeleporterInteraction.instance.shouldAttemptToSpawnGoldshoresPortal = true; + TeleporterInteraction.instance.shouldAttemptToSpawnShopPortal = true; + TeleporterInteraction.instance.shouldAttemptToSpawnMSPortal = true; + } + } + } + } +} diff --git a/RoRCheats.csproj b/UmbraRoR.csproj similarity index 98% rename from RoRCheats.csproj rename to UmbraRoR.csproj index f974e30..cd9f62c 100644 --- a/RoRCheats.csproj +++ b/UmbraRoR.csproj @@ -7,8 +7,8 @@ {16E3F076-0420-44EE-ADC5-ADF5F3E657F4} Library Properties - RoRCheats - RoRCheats + UmbraRoR + UmbraRoR v4.6 512 @@ -333,13 +333,18 @@ + + True True Resources.resx + + + diff --git a/RorCheats.sln b/UmbraRoR.sln similarity index 87% rename from RorCheats.sln rename to UmbraRoR.sln index 2bffc2f..76701a8 100644 --- a/RorCheats.sln +++ b/UmbraRoR.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.168 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RoRCheats", "RoRCheats.csproj", "{16E3F076-0420-44EE-ADC5-ADF5F3E657F4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UmbraRoR", "UmbraRoR.csproj", "{16E3F076-0420-44EE-ADC5-ADF5F3E657F4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Utils.cs b/Utils.cs new file mode 100644 index 0000000..97d4bec --- /dev/null +++ b/Utils.cs @@ -0,0 +1,161 @@ +using System; +using System.IO; +using System.Reflection; +using System.Collections.Generic; +using RoR2; +using Console = RoR2.Console; + +namespace UmbraRoR +{ + public class Utils + { + public static Boolean CursorIsVisible() + { + foreach (var mpeventSystem in RoR2.UI.MPEventSystem.readOnlyInstancesList) + if (mpeventSystem.isCursorVisible) + return true; + return false; + } + //More posibilities here using console. + //Not added to ui yet. + public static void BanPlayer(NetworkUser PlayerName, NetworkUser LocalNetworkUser) + { + Console.instance.RunClientCmd(LocalNetworkUser, "ban_steam", new string[] { PlayerName.Network_id.steamId.ToString() }); + } + + //Kicks player + public static void KickPlayer(NetworkUser PlayerName, NetworkUser LocalNetworkUser) + { + Console.instance.RunClientCmd(LocalNetworkUser, "kick_steam", new string[] { PlayerName.Network_id.steamId.ToString() }); + } + + public static NetworkUser GetNetUserFromString(string playerString) + { + if (playerString != "") + { + if (int.TryParse(playerString, out int result)) + { + if (result < NetworkUser.readOnlyInstancesList.Count && result >= 0) + { + return NetworkUser.readOnlyInstancesList[result]; + } + return null; + } + else + { + foreach (NetworkUser n in NetworkUser.readOnlyInstancesList) + { + if (n.userName.Equals(playerString, StringComparison.CurrentCultureIgnoreCase)) + { + return n; + } + } + return null; + } + } + return null; + } + + public static void GetPlayers(string[] Players) + { + NetworkUser n; + for (int i = 0; i < NetworkUser.readOnlyInstancesList.Count; i++) + { + n = NetworkUser.readOnlyInstancesList[i]; + + Players[i] = n.userName; + } + } + //Reset menu when you return to main menu + public static void ResetMenu() + { + Main._ifDragged = false; + Main._CharacterCollected = false; + Main._isStatMenuOpen = false; + Main._isTeleMenuOpen = false; + Main._isESPMenuOpen = false; + Main._ItemToggle = false; + Main._CharacterToggle = false; + Main._isLobbyMenuOpen = false; + Main._isEditStatsOpen = false; + Main._isItemSpawnMenuOpen = false; + Main._isPlayerMod = false; + Main._isEquipmentSpawnMenuOpen = false; + Main._isBuffMenuOpen = false; + Main._isItemManagerOpen = false; + Main.damageToggle = false; + Main.noEquipmentCooldown = false; + Main.critToggle = false; + Main.skillToggle = false; + Main.renderInteractables = false; + Main.renderMobs = false; + Main.attackSpeedToggle = false; + Main.armorToggle = false; + Main.regenToggle = false; + Main.moveSpeedToggle = false; + Main.FlightToggle = false; + Main.godToggle = false; + Main.alwaysSprint = false; + Main.aimBot = false; + ItemManager.isDropItemForAll = false; + } + //Soft reset when moving to next stage to keep player stat mods and god mode between stages + public static void SoftResetMenu() + { + Main._isMenuOpen = !Main._isMenuOpen; + Main.GetCharacter(); + Main._isMenuOpen = !Main._isMenuOpen; + Main.godToggle = !Main.godToggle; + Main.GetCharacter(); + Main.godToggle = !Main.godToggle; + + } + + public static List GetAllUnlockables() + { + var unlockableName = new List(); + + var assembly = Assembly.GetExecutingAssembly(); + var resourceName = "UmbraRoR.Resources.Unlockables.txt"; + + Stream stream = assembly.GetManifestResourceStream(resourceName); + StreamReader reader = new StreamReader(stream); + while (!reader.EndOfStream) + { + string line1 = reader.ReadLine(); + line1 = line1.Replace("UnlockableCatalog.RegisterUnlockable(\"", ""); + line1 = line1.Replace("\", new UnlockableDef", ""); + line1 = line1.Replace("true", ""); + line1 = line1.Replace("});", ""); + line1 = line1.Replace("=", ""); + line1 = line1.Replace("\"", ""); + line1 = line1.Replace("false", ""); + line1 = line1.Replace(",", ""); + line1 = line1.Replace("hidden", ""); + line1 = line1.Replace("{", ""); + line1 = line1.Replace("nameToken", ""); + line1 = line1.Replace(" ", ""); + string[] lineArray = line1.Split(null); + foreach (var line in lineArray) + { + //TODO: Simplify later + if (line.StartsWith("Logs.") || line.StartsWith("Characters.") || line.StartsWith("Items.") || line.StartsWith("Skills.") || line.StartsWith("Skins.") || line.StartsWith("Shop.") || line.StartsWith("Artifacts.") || line.StartsWith("NewtStatue.")) + { + unlockableName.Add(line); + } + } + } + return unlockableName; + } + + // Used during testing and debugging + public static void WriteToLog(string logContent) + { + string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); + using (StreamWriter outputFile = new StreamWriter(System.IO.Path.Combine(docPath, "UmbraLog.txt"), true)) + { + outputFile.WriteLine(Main.log + logContent); + } + } + } +} diff --git a/btn.cs b/btn.cs index 04e270e..7d1f517 100644 --- a/btn.cs +++ b/btn.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace RoRCheats +namespace UmbraRoR { internal class btn {