Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
自瞄设置
Browse files Browse the repository at this point in the history
  • Loading branch information
xifangczy committed Aug 20, 2021
1 parent 5413b89 commit 864a902
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 22 deletions.
31 changes: 25 additions & 6 deletions BmMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public BmMod(IntPtr intPtr) : base(intPtr) { }
//自瞄按键
public static bool AimBotState = false;
public static int AimBotKeyNum = 0;
public static int AimBotKeyConfig = 1;
//public static int AimBotKeyConfig = 1;
public static int AimBotKeyOrig = 0;
public static readonly string[] AimBotKeyStr = { "[关]", "<color=lime>[F键]</color>", "<color=lime>[右键]</color>", "<color=lime>[左键]</color>", "<color=lime>[CTRL]</color>", "<color=lime>[ALT]</color>" };
readonly KeyCode[] AimBotKeyCode = { KeyCode.None, KeyCode.F, KeyCode.Mouse1, KeyCode.Mouse0, KeyCode.LeftControl, KeyCode.LeftAlt };
public static bool[] AimBotKeyConfig = { true, true, true, true, true, true };
//射速 + 子弹飞行速度 开关
public static bool WeaponSpeedState = false;
public static bool WeaponSpeedWindowState = false;
Expand Down Expand Up @@ -156,16 +157,16 @@ void Update()
//自瞄 切换
if (Input.GetKeyDown(KeyCode.F2))
{
AimBotState = !AimBotState;
if (AimBotState)
NextAimBotKey();
if(AimBotKeyNum != 0 && AimBotState == false)
{
AimBotState = true;
Window.MenuRect = new Rect(Window.MenuRect.x, Window.MenuRect.y, Window.MenuRect.width, Window.MenuRect.height + 45);
AimBotKeyNum = AimBotKeyOrig == 0 ? AimBotKeyConfig : AimBotKeyOrig;
}
else
if (AimBotKeyNum == 0)
{
AimBotState = false;
Window.MenuRect = new Rect(Window.MenuRect.x, Window.MenuRect.y, Window.MenuRect.width, Window.MenuRect.height - 45);
AimBotKeyNum = 0;
}
}
//切换起飞模式
Expand Down Expand Up @@ -336,6 +337,7 @@ void Update()
{
CurWeaponObj.WeaponAttr.AttDis = 9999f;
CurWeaponObj.WeaponAttr.AttDistance = 9999f;
CurWeaponObj.WeaponAttr.Radius = 9999f;
}
//恢复重力
if (HeroMoveManager.HMMJS.movement.gravity == 0)
Expand Down Expand Up @@ -501,6 +503,23 @@ void ZoomShield()
Shield.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
}
}
//自瞄按钮
public static void NextAimBotKey()
{
while (true)
{
AimBotKeyNum++;
if (AimBotKeyNum >= AimBotKeyConfig.Length)
{
AimBotKeyNum = 0;
break;
}
if (AimBotKeyConfig[AimBotKeyNum])
{
break;
}
}
}
//自瞄
void AimBot()
{
Expand Down
25 changes: 22 additions & 3 deletions MainMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class MainMod : BasePlugin
public static ConfigEntry<float> AimBotSightRange = Config.Bind("config", "AimBotSightRange", BmMod.AimBotSightRange);
public static ConfigEntry<bool> AimBotModelMagneticState = Config.Bind("config", "AimBotModelMagneticState", BmMod.AimBotModelMagneticState);
public static ConfigEntry<bool> AimBotModelForceState = Config.Bind("config", "AimBotModelForceState", BmMod.AimBotModelForceState);
public static ConfigEntry<int> AimBotKeyConfig = Config.Bind("config", "AimBotKeyConfig", BmMod.AimBotKeyConfig);
public static ConfigEntry<string> AimBotKeyConfig = Config.Bind("config", "AimBotKeyConfig", BoolArray2String(BmMod.AimBotKeyConfig));
public static ConfigEntry<float> BulletSpeedNum = Config.Bind("config", "BulletSpeedNum", BmMod.BulletSpeedNum);
public static ConfigEntry<int> AttSpeedNum = Config.Bind("config", "AttSpeedNum", BmMod.AttSpeedNum);
public static ConfigEntry<float> AimBotForceDistance = Config.Bind("config", "AimBotForceDistance", BmMod.AimBotForceDistance);
Expand All @@ -33,7 +33,7 @@ public override void Load()
BmMod.AimBotSightRange = AimBotSightRange.Value;
BmMod.AimBotModelMagneticState = AimBotModelMagneticState.Value;
BmMod.AimBotModelForceState = AimBotModelForceState.Value;
BmMod.AimBotKeyConfig = AimBotKeyConfig.Value;
BmMod.AimBotKeyConfig = String2BoolArray(AimBotKeyConfig.Value);
BmMod.BulletSpeedNum = BulletSpeedNum.Value;
BmMod.AttSpeedNum = AttSpeedNum.Value;
BmMod.AimBotForceDistance = AimBotForceDistance.Value;
Expand All @@ -49,13 +49,32 @@ public static void SaveConfig()
AimBotSightRange.Value = BmMod.AimBotSightRange;
AimBotModelMagneticState.Value = BmMod.AimBotModelMagneticState;
AimBotModelForceState.Value = BmMod.AimBotModelForceState;
AimBotKeyConfig.Value = BmMod.AimBotKeyConfig;
AimBotKeyConfig.Value = BoolArray2String(BmMod.AimBotKeyConfig);
BulletSpeedNum.Value = BmMod.BulletSpeedNum;
AttSpeedNum.Value = BmMod.AttSpeedNum;
AimBotForceDistance.Value = BmMod.AimBotForceDistance;
AimBotShieldState.Value = BmMod.AimBotShieldState;
Config.Save();
}

public static string BoolArray2String(bool[] arg)
{
return string.Join(",", arg);
}

public static bool[] String2BoolArray(string arg)
{
string[] Str = arg.Split(',');
bool[] Res = new bool[Str.Length];
for (int i = 0; i < Str.Length; i++)
{
if (Str[i] == "True")
Res[i] = true;
else
Res[i] = false;
}
return Res;
}
}

//注入脚本
Expand Down
32 changes: 19 additions & 13 deletions Window.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using HeroCameraName;
using System;
using System.Linq;
using UnhollowerBaseLib;
using UnityEngine;

Expand All @@ -22,13 +23,13 @@ public static void MenuWindow(int windowID)
AmmoState = GUILayout.Toggle(AmmoState, AmmoState ? "[F1] 无限子弹 <color=lime>[开]</color>" : "[F1] 无限子弹 [关]", null);

GUILayout.BeginHorizontal(null);
if (GUILayout.Toggle(AimBotState, "[F2] 自瞄" + AimBotKeyStr[AimBotKeyNum], null) != BmMod.AimBotState)
if (GUILayout.Toggle(AimBotState, "[F2] 自瞄" + AimBotKeyStr[AimBotKeyNum], null) != AimBotState)
{
AimBotState = !AimBotState;
if (AimBotState)
{
MenuRect = new Rect(MenuRect.x, MenuRect.y, MenuRect.width, MenuRect.height + 45);
AimBotKeyNum = AimBotKeyOrig == 0 ? AimBotKeyConfig : AimBotKeyOrig;
NextAimBotKey();
}
else
{
Expand All @@ -41,14 +42,17 @@ public static void MenuWindow(int windowID)
if (AimBotState)
{
GUILayout.BeginHorizontal(null);
for (int i = 1; i < AimBotKeyStr.Length; i++)
for (int i = 1, j = 0; i < AimBotKeyConfig.Length; i++)
{
if (GUILayout.Toggle(AimBotKeyNum == i, AimBotKeyStr[i], null))
if (AimBotKeyConfig[i])
{
AimBotKeyNum = i;
AimBotKeyOrig = i;
j++;
if(GUILayout.Toggle(AimBotKeyNum == i, AimBotKeyStr[i], null))
{
AimBotKeyNum = i;
}
}
if (i % 3 == 0)
if (j % 3 == 0)
{
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(null);
Expand Down Expand Up @@ -148,7 +152,7 @@ public static void MenuWindow(int windowID)
GUI.DragWindow(new Rect(0, 0, 10000, 420));
}

//地图提示窗口
// 提示窗口
public static void TipsWindow(int windowID)
{
Il2CppReferenceArray<GUILayoutOption> options = null;
Expand Down Expand Up @@ -196,17 +200,19 @@ public static void TipsWindow(int windowID)
GUI.DragWindow(new Rect(0, 0, 10000, 400));
}

//自瞄设置
// 自瞄设置
public static void AimBotWindow(int windowID)
{
GUILayout.Space(5);
GUILayout.Label("自瞄默认按钮", null);
GUILayout.Label("自瞄按键筛选", null);
GUILayout.BeginHorizontal(null);
for (int i = 1; i < AimBotKeyStr.Length; i++)
{
if (GUILayout.Toggle(AimBotKeyConfig == i, AimBotKeyStr[i], null))
AimBotKeyConfig[i] = GUILayout.Toggle(AimBotKeyConfig[i], AimBotKeyStr[i], null);
//至少保留一个按钮
if(AimBotKeyConfig.Where(x => x == true).Count() == 1)
{
AimBotKeyConfig = i;
AimBotKeyConfig[i] = true;
}
if (i % 3 == 0)
{
Expand Down Expand Up @@ -248,7 +254,7 @@ public static void AimBotWindow(int windowID)
GUI.DragWindow(new Rect(0, 0, 10000, 250));
}

//实验室窗口
// 实验室窗口
public static void TestWindow(int windowID)
{
GUILayout.Space(10);
Expand Down

0 comments on commit 864a902

Please sign in to comment.