This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
BmMod.cs
693 lines (679 loc) · 30.7 KB
/
BmMod.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
using HeroCameraName;
using Il2CppSystem.Collections.Generic;
using Item;
using System;
using System.Linq;
using System.Runtime.InteropServices;
using UnityEngine;
namespace BmMod
{
public class BmMod : MonoBehaviour
{
public BmMod(IntPtr intPtr) : base(intPtr) { }
#region [变量初始化]
//菜单
public static bool MenuState = true;
//无限子弹
public static bool AmmoState = false;
//不消耗子弹
public static bool NoBulletConsumeState = false;
//无后座
public static bool NoRecoilState = false;
//自瞄按键
public static bool AimBotState = false;
public static int AimBotKeyNum = 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 float BulletSpeedNum = 1000; //弹速
public static int AttSpeedNum = 500; //射速
public static bool BulletSpeedState = true;
public static bool AttSpeedState = false; //默认关闭射速 大部分武器 射速无法调整
//快速换弹
public static bool QuickReloadBulletState = false;
//提高精准度
public static bool AccuracyState = false;
//攻击距离
public static bool AttDistanceState = false;
//起飞
public static bool SuperJumpState = false;
public static readonly string[] SuperJumpStr = { "[关]", "<color=lime>[超级跳]</color>", "<color=lime>[零重力]</color>" };
public static int SuperJumpType = 0;
readonly float OrigGravity = 11.65f;
//超级速度
public static bool SuperRunState = false;
public static int SuperRunOrig = 600;
public static int SuperRunSet = 1200;
public static bool SuperRunWindowState = false;
//地图信息
bool ESPState = false; //透视
bool TipsState = false;
public static Vector3 SaveHeroPosition; //储存玩家位置
//查看物品ID
public static bool ShowAllIdState = false;
//实验室
public static bool TestWindowState = false;
public static bool ShowBloodBarState = false; //显示怪物血条
public static bool ZoomWeakState = false; //放大弱点
public static float ZoomWeakNum = 2; //放大弱点 倍数
//鼠标状态
bool CursorState = false;
//模型大小
public static int MonstersModelState = 0;
public static int MyModelState = 0;
//自瞄设置
public static bool AimBotWindowState = false;
public static float AimBotSightRange = 0.1f; //默认自瞄范围
public static bool AimBotMagneticState = true; //磁力自瞄 默认
public static bool AimBotForceState = false; //暴力自瞄
public static bool AimBotPlusState = false; //转起来
public static float AimBotForceDistance = 5; // 优先瞄准离自己距离多少以内的敌人
public static bool AimBotShieldState = false; // 干掉盾牌
[DllImport("user32.dll")]
static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
#endregion
void OnGUI()
{
//if (Cursor.lockState == CursorLockMode.Locked) return;
//主菜单
if (MenuState)
{
Window.MenuRect = GUI.Window(0, Window.MenuRect, (GUI.WindowFunction)Window.MenuWindow, "[Home] 隐藏菜单");
}
//地图信息
if (TipsState)
{
Window.TipsRect = GUI.Window(1, Window.TipsRect, (GUI.WindowFunction)Window.TipsWindow, "地图信息");
}
//实验室
if (TestWindowState)
{
Window.TestRect = GUI.Window(2, Window.TestRect, (GUI.WindowFunction)Window.TestWindow, "实验室");
}
//自瞄设置
if (AimBotWindowState)
{
Window.AimBotRect = GUI.Window(3, Window.AimBotRect, (GUI.WindowFunction)Window.AimBotWindow, "自瞄设置");
}
//查看物品ID
if (ShowAllIdState)
{
foreach (var keyValuePair in NewPlayerManager.PlayerDict)
{
var value = keyValuePair.Value;
if (value.centerPointTrans == null) { continue; }
var dist = Vector3.Distance(HeroMoveManager.HeroObj.centerPointTrans.position, keyValuePair.value.centerPointTrans.position);
var screenPos = CameraManager.MainCameraCom.WorldToScreenPoint(value.centerPointTrans.transform.position);
if (screenPos.z > 0)
{
GUI.Label(new Rect(screenPos.x, Screen.height - screenPos.y, 300, 100), value.FightType + "/" + value.Shape + "/" + value.SID + "/" + value.ObjectID + "/" + dist);
}
}
}
//透视
if (ESPState)
{
GUIStyle Style = new GUIStyle();
Style.normal.textColor = Color.yellow;
foreach (var keyValuePair in NewPlayerManager.PlayerDict)
{
if (!ShowObject(keyValuePair.value)) { continue; }
var screenPos = CameraManager.MainCameraCom.WorldToScreenPoint(keyValuePair.value.centerPointTrans.transform.position);
if (screenPos.z > 0)
{
var dist = Vector3.Distance(HeroMoveManager.HeroObj.centerPointTrans.position, keyValuePair.value.centerPointTrans.position);
float Clamp = Mathf.Clamp(dist - 10, 10, 30);
Style.fontSize = 40 - (int)Clamp;
Clamp = (int)Mathf.Clamp(dist + 150, 150, 240);
Style.normal.textColor = new Color32(255, 128, 64, (byte)Clamp);
GUI.Label(new Rect(screenPos.x, Screen.height - screenPos.y, 150, 100), ShowObjectName(keyValuePair.value) + "(" + dist.ToString("0") + "m)", Style);
}
}
}
}
void Update()
{
//菜单 开关
if (Input.GetKeyDown(KeyCode.Home))
{
MenuState = !MenuState;
if (!MenuState)
{
AimBotWindowState = false;
TestWindowState = false;
}
}
//无限子弹 开关
if (Input.GetKeyDown(KeyCode.F1)) { AmmoState = !AmmoState; }
//自瞄 切换
if (Input.GetKeyDown(KeyCode.F2))
{
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);
}
if (AimBotKeyNum == 0)
{
AimBotState = false;
Window.MenuRect = new Rect(Window.MenuRect.x, Window.MenuRect.y, Window.MenuRect.width, Window.MenuRect.height - 45);
}
}
//切换起飞模式
if (Input.GetKeyDown(KeyCode.F3))
{
SuperJumpType++;
SuperJumpState = true;
if (SuperJumpType == 1)
{
Window.MenuRect = new Rect(Window.MenuRect.x, Window.MenuRect.y, Window.MenuRect.width, Window.MenuRect.height + 20);
}
else if(SuperJumpType == 3)
{
SuperJumpType = 0;
SuperJumpState = false;
Window.MenuRect = new Rect(Window.MenuRect.x, Window.MenuRect.y, Window.MenuRect.width, Window.MenuRect.height - 20);
}
}
//超级移速
if (Input.GetKeyDown(KeyCode.F4)) { SuperRunToggle(); }
//无后坐力
if (Input.GetKeyDown(KeyCode.F5)) { NoRecoilState = !NoRecoilState; }
//不耗子弹
if (Input.GetKeyDown(KeyCode.F6)) { NoBulletConsumeState = !NoBulletConsumeState; }
//提高精准度
if (Input.GetKeyDown(KeyCode.F7)) { AccuracyState = !AccuracyState; }
//近战距离
if (Input.GetKeyDown(KeyCode.F8)) { AttDistanceState = !AttDistanceState; }
//射速 + 子弹飞行速度
if (Input.GetKeyDown(KeyCode.F9))
{
WeaponSpeedState = !WeaponSpeedState;
if (WeaponSpeedState)
{
Window.MenuRect = new Rect(Window.MenuRect.x, Window.MenuRect.y, Window.MenuRect.width, Window.MenuRect.height + 110);
}
else
{
Window.MenuRect = new Rect(Window.MenuRect.x, Window.MenuRect.y, Window.MenuRect.width, Window.MenuRect.height - 110);
}
}
//快速换弹
if (Input.GetKeyDown(KeyCode.F11)) { QuickReloadBulletState = !QuickReloadBulletState; }
//if (Input.GetKeyDown(KeyCode.G))
//{
// GM.GMManager.instance.OpenGMPanel();
// GM.GMManager.instance.CreateGMBtn();
//}
if (HeroCameraManager.HeroObj == null || CameraManager.MainCamera == null || HeroCameraManager.HeroObj.BulletPreFormCom.weapondict == null) { return; }
//当前武器ID和对象
int CurWeaponID = HeroCameraManager.HeroObj.PlayerCom.CurWeaponID;
WeaponPerformanceObj CurWeaponObj = HeroCameraManager.HeroObj.BulletPreFormCom.ReturnWeapon(CurWeaponID);
//if (Input.GetKeyDown(KeyCode.Keypad0))
//{
// //MainMod.Log.LogWarning();
//}
//隐藏显示鼠标
if (Input.GetKeyDown(KeyCode.Insert) || (CursorState && Input.GetKeyDown(KeyCode.Mouse1)))
{
CursorState = !CursorState;
if (CursorState)
{
new WarTeamerInfoPanel().ShowCursor();
}
else
{
//奇怪的实现方式 但有用
WarTeamerInfoManager.Instance.OpenTeamerInfo();
new WarTeamerInfoPanel().ShowCursor();
WarTeamerInfoManager.Instance.CloseTeamerInfo();
}
}
//地图提示
if (Input.GetKeyDown(KeyCode.C)) { TipsState = true; }
if (Input.GetKeyUp(KeyCode.C)) { TipsState = false; }
//透视
if (Input.GetKeyDown(KeyCode.X)) { ESPState = !ESPState; }
//全屏捡钱/子弹/武器/卷轴
if (Input.GetKeyDown(KeyCode.Mouse2))
{
/*
* (ServerDefine.FightType)16777225 && Shape 5504 魂
* NWARRIOR_DROP_CASH 钱
* NWARRIOR_DROP_BULLET 子弹 次技能
* NWARRIOR_DROP_EQUIP 武器
* NWARRIOR_DROP_RELIC 卷轴
* NWARRIOR_NPC_GOLDENCUP 金爵
* NWARRIOR_DROP_TRIGGER && Shape 5513 包子
* keyValuePair.Value.DropOPCom.FlyMeToTheMoon(HeroCameraManager.HeroID); 有BUG
* 东西过多 使用 修改AutoPickRange属性 会造成卡顿
*/
foreach (var keyValuePair in NewPlayerManager.PlayerDict)
{
if (keyValuePair.Value.FightType == ServerDefine.FightType.NWARRIOR_DROP_BULLET || keyValuePair.Value.Shape == 5513)
{
keyValuePair.Value.DropOPCom.AutoPickRange = 99999f;
continue;
}
if (keyValuePair.Value.Shape == 5504 || keyValuePair.Value.FightType == ServerDefine.FightType.NWARRIOR_DROP_CASH)
{
Vector3 HeroPosition = HeroCameraManager.HeroTran.position;
keyValuePair.Value.gameTrans.position = new Vector3(HeroPosition.x, HeroPosition.y, HeroPosition.z);
continue;
}
if (keyValuePair.Value.FightType == ServerDefine.FightType.NWARRIOR_DROP_EQUIP
|| keyValuePair.Value.FightType == ServerDefine.FightType.NWARRIOR_DROP_RELIC
|| keyValuePair.Value.FightType == ServerDefine.FightType.NWARRIOR_NPC_GOLDENCUP)
{
Ray ray = new Ray(CameraManager.MainCamera.position, CameraManager.MainCamera.forward);
Vector3 position = ray.GetPoint(3);
keyValuePair.Value.gameTrans.position = new Vector3(position.x + GetRandomNumber(-2, 2), position.y, position.z + GetRandomNumber(-2, 2));
}
}
}
//模型大小更改
if (MonstersModelState != 0)
{
List<NewPlayerObject> monsters = NewPlayerManager.GetMonsters();
foreach (NewPlayerObject newPlayerObject in monsters)
{
if (MonstersModelState == 1)
{
newPlayerObject.gameTrans.localScale *= 1.5f;
}
else
{
newPlayerObject.gameTrans.localScale *= 0.5f;
}
}
MonstersModelState = 0;
}
if (MyModelState != 0)
{
if (MyModelState == 1)
{
HeroCameraManager.HeroTran.localScale *= 1.5f;
}
else if (MyModelState == 2)
{
HeroCameraManager.HeroTran.localScale *= 0.5f;
}
else
{
HeroCameraManager.HeroTran.localScale = new Vector3(1, 1, 1);
}
MyModelState = 0;
}
//显示血条(透视怪?)
if (ShowBloodBarState)
{
List<NewPlayerObject> monsters = NewPlayerManager.GetMonsters();
foreach (NewPlayerObject newPlayerObject in monsters)
{
if (newPlayerObject.BloodBarCom != null)
{
newPlayerObject.BloodBarCom.ShowBloodBar();
}
}
}
//射速 弹速设置
if (WeaponSpeedState)
{
if (AttSpeedState)
{
CurWeaponObj.WeaponAttr.AttSpeed = SetList(AttSpeedNum, 0, 0, 10000);
}
if (BulletSpeedState)
{
CurWeaponObj.WeaponAttr.BulletSpeed = BulletSpeedNum;
}
}
//无限子弹
if (AmmoState)
{
CurWeaponObj.ReloadBulletImmediately();
CurWeaponObj.ModifyBulletInMagzine(100, 100);
}
//快速换弹
if (QuickReloadBulletState)
{
CurWeaponObj.WeaponAttr.FillTime = 1;
}
//提高精准度
if (AccuracyState) { CurWeaponObj.WeaponAttr.Accuracy = SetList(100, 100, 100); }
//近战距离
if (AttDistanceState)
{
CurWeaponObj.WeaponAttr.AttDis = 9999f;
CurWeaponObj.WeaponAttr.AttDistance = 9999f;
CurWeaponObj.WeaponAttr.Radius = 9999f;
}
//恢复重力
if (HeroMoveManager.HMMJS.movement.gravity == 0)
{
if (SuperJumpType != 2)
{
HeroMoveManager.HMMJS.movement.gravity = OrigGravity;
}
}
//起飞
if (SuperJumpType == 1 && Input.GetKey(KeyCode.Space) && !HeroMoveManager.HMMJS.inputJump) { HeroCameraManager.HeroTran.Translate(Vector3.up * 0.3f); }
//零重力
if (SuperJumpType == 2)
{
HeroMoveManager.HMMJS.movement.gravity = 0;
if (Input.GetKey(KeyCode.Space))
{
HeroCameraManager.HeroTran.Translate(Vector3.up * 0.1f);
}
else if (Input.GetKey(KeyCode.LeftControl))
{
HeroCameraManager.HeroTran.Translate(Vector3.down * 0.1f);
}
}
//超级移速
if (SuperRunState) { HeroCameraManager.HeroObj.playerProp.Speed = SuperRunSet; }
//自瞄
if (AimBotKeyNum != 0 && Input.GetKey(AimBotKeyCode[AimBotKeyNum]))
{
if (AimBotPlusState)
{
AimBotPlus();
}
else
{
AimBot();
}
}
//自瞄多选按钮 TODO
//for(int i=1; i <= AimBotKeyCode.Length; i++)
//{
// if (Input.GetKey(AimBotKeyCode[i]))
// {
// if (AimBotPlusState)
// {
// AimBotPlus();
// }
// else
// {
// AimBot();
// }
// }
//}
}
void LateUpdate()
{
//大头大头 下雨不愁
if (ZoomWeakState)
{
List<NewPlayerObject> monsters = NewPlayerManager.GetMonsters();
Transform weakTrans;
foreach (var monster in monsters)
{
try
{
weakTrans = monster.BodyPartCom.GetWeakTrans(false);
}
catch
{
continue;
}
weakTrans.localScale = new Vector3(ZoomWeakNum, ZoomWeakNum, ZoomWeakNum);
}
}
}
List<int> SetList(int One = 0, int Two = 0, int Three = 0, int Four = 10000)
{
var List = new List<int>(4);
List.Add(One);
List.Add(Two);
List.Add(Three);
List.Add(Four);
return List;
}
public static bool ShowObject(NewPlayerObject obj)
{
return obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_EVENT
|| obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_REFRESH
|| obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_ITEMBOX
|| obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_SHOP
|| obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_PASSBOX
|| obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_MAGICBOX
|| obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_LOCKEDBOX
|| obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_INITBOX
|| obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_SMITH
|| (obj.FightType == ServerDefine.FightType.WARRIOR_OBSTACLE_NORMAL && (obj.Shape == 4406 || obj.Shape == 4419 || obj.Shape == 4427 || obj.Shape == 4430))
|| (obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_TRANSFER && (obj.Shape == 4016 || obj.Shape == 4009 || obj.Shape == 4019 || obj.Shape == 4029))
|| obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_GSCASHSHOP;
}
//Object ID 转名字
public static string ShowObjectName(NewPlayerObject obj)
{
if (obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_SMITH)
{
return "工匠";
}
else if (obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_SHOP)
{
return "行脚商";
}
else if (obj.FightType == ServerDefine.FightType.WARRIOR_OBSTACLE_NORMAL && (obj.Shape == 4406 || obj.Shape == 4419 || obj.Shape == 4427 || obj.Shape == 4430))
{
return "<color=red>未开秘境</color>";
}
else if (obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_TRANSFER && (obj.Shape == 4016 || obj.Shape == 4009 || obj.Shape == 4019 || obj.Shape == 4029))
{
return "<color=red>已开秘境</color>";
}
else if (obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_EVENT || obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_REFRESH)
{
return "<color=orange>橙色宝箱</color>";
}
else if (obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_GSCASHSHOP)
{
return "奇货商";
}
else if (obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_PASSBOX)
{
return "过关宝箱";
}
else if (obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_ITEMBOX || obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_MAGICBOX)
{
return "奖励宝箱";
}
else if (obj.FightType == ServerDefine.FightType.NWARRIOR_NPC_INITBOX)
{
return "初始宝箱";
}
return obj.FightType.ToString();
}
//随机数
float GetRandomNumber(float minimum, float maximum)
{
return (UnityEngine.Random.value * (maximum - minimum) + minimum);
}
//切换超级速度开关
public static void SuperRunToggle()
{
if (HeroCameraManager.HeroObj == null) { return; }
SuperRunState = !SuperRunState;
if (SuperRunState)
{
SuperRunOrig = HeroCameraManager.HeroObj.playerProp.Speed;
}
else
{
HeroCameraManager.HeroObj.playerProp.Speed = SuperRunOrig;
}
}
//马头锐士克星 可还行
void ZoomShield()
{
var Shields = GameObject.FindGameObjectsWithTag("Monster_Shield");
foreach (var Shield in Shields)
{
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()
{
List<NewPlayerObject> monsters = NewPlayerManager.GetMonsters();
if (monsters == null) { return; }
Vector3 HeroPos = CameraManager.MainCamera.position;
float CenterRange = 1; //筛选准心最近
float DistanceRange = 99999; //筛选距离最近
bool DistanceFlag = false; //是否存在距离最近的敌人
Transform ResTran = null; //储存Transform结果
foreach (var monster in monsters)
{
//MainMod.Log.LogWarning("isSpecialUndieChallenge " + monster.BloodBarCom.BloodBar.isSpecialUndieChallenge);
//MainMod.Log.LogWarning("isUndieChallenge " + monster.BloodBarCom.BloodBar.isUndieChallenge);
//MainMod.Log.LogWarning("isUndieStart " + monster.BloodBarCom.BloodBar.isUndieStart);
//MainMod.Log.LogWarning("isUndieStart " + monster.BloodBarCom.BloodBar.m_UndieMonsterBar);
//MainMod.Log.LogWarning("isUndieStart " + monster.BloodBarCom.BloodBar.m_UndieChallengeBar);
if (monster.playerProp.HP == 1 && (monster.BloodBarCom.BloodBar.isSpecialUndieChallenge || monster.BloodBarCom.BloodBar.isUndieChallenge || monster.BloodBarCom.BloodBar.isUndieStart)) { continue; } // 无敌怪
try
{
Transform weakTrans = monster.BodyPartCom.GetWeakTrans(false);
if (weakTrans != null)
{
Vector3 vector = CameraManager.MainCameraCom.WorldToViewportPoint(weakTrans.position); // 转二维坐标
if (vector.z <= 0) { continue; } // 忽略身后目标
float CenterDistance = Vector3.Distance(new Vector3(0.5f, 0.5f, 0), new Vector3(vector.x, vector.y, 0)); // 计算目标与准星距离
vector = weakTrans.position - HeroPos;
float Distance = vector.magnitude;
if (Distance <= AimBotForceDistance)
{
DistanceFlag = true;
}
else if (CenterDistance > AimBotSightRange)
{
continue;
}
//发射射线查看是否有阻挡
Ray ray = new Ray(HeroPos, vector);
var hits = Physics.RaycastAll(ray, Distance);
//开启了破坏护盾功能并存在护盾 执行ZoomShield
if (AimBotShieldState && hits.Any(hit => hit.collider.gameObject.tag == "Monster_Shield")) { ZoomShield(); }
//查询是否存在阻挡
bool query = hits.Any(hit => hit.collider.gameObject.layer == 0 || hit.collider.gameObject.layer == 30 || hit.collider.gameObject.layer == 31 || hit.collider.gameObject.tag == "Monster_Shield");
if (query) { continue; }
//找到最近的敌人
if (DistanceFlag)
{
if (Distance < DistanceRange)
{
DistanceRange = Distance;
ResTran = weakTrans;
}
}
else if (CenterDistance < CenterRange)
{
CenterRange = CenterDistance;
ResTran = weakTrans;
}
}
}
catch
{
continue;
}
}
if (ResTran != null)
{
if (AimBotMagneticState)
{
//磁吸 代码修改自 https://github.com/shalzuth/AutoGunfireReborn/blob/e4a24e3e08fb6197418acf74084206122714782b/GunfireRebornMods/Mods/Aimbot.cs#L56
Vector3 position = ResTran.position + new Vector3(0, 0.2f);
Vector3 screenAim = CameraManager.MainCameraCom.WorldToScreenPoint(position);
Vector2 aimTarget = new Vector2(screenAim.x, Screen.height - screenAim.y);
if (aimTarget != Vector2.zero)
{
float x = (aimTarget.x - Screen.width / 2.0f) / 2.5f;
float y = (aimTarget.y - Screen.height / 2.0f) / 2.5f;
mouse_event(0x0001, (int)x, (int)y, 0, 0);
}
}
else
{
//暴力 代码修改自 https://github.com/pentium1131/GunfireReborn-aimbot/blob/4be263a6478c87a23b8c6a19fb4065fac9791047/Main.cs#L191
Vector3 objpos = new Vector3
{
x = HeroCameraManager.HeroObj.gameTrans.position.x,
y = ResTran.position.y + 0.2f,
z = HeroCameraManager.HeroObj.gameTrans.position.z
};
Vector3 forward = ResTran.position - objpos;
forward.y += 0.14f;
HeroCameraManager.HeroObj.gameTrans.rotation = Quaternion.LookRotation(forward);
forward = ResTran.position - HeroPos;
forward.y += 0.14f;
CameraManager.MainCamera.rotation = Quaternion.LookRotation(forward);
}
}
}
//转起来
void AimBotPlus()
{
List<NewPlayerObject> monsters = NewPlayerManager.GetMonsters();
if (monsters == null) { return; }
Vector3 position = CameraManager.MainCamera.position;
Transform transform = null;
float SightRange = 9999999;
foreach (var monster in monsters)
{
if (monster.playerProp.HP == 1 && (monster.BloodBarCom.BloodBar.isSpecialUndieChallenge || monster.BloodBarCom.BloodBar.isUndieChallenge || monster.BloodBarCom.BloodBar.isUndieStart)) { continue; } // 无敌怪
try
{
Transform weakTrans = monster.BodyPartCom.GetWeakTrans(false);
if (weakTrans != null)
{
Vector3 vector = weakTrans.position - position;
float Distance = vector.magnitude;
Ray ray = new Ray(position, vector);
var hits = Physics.RaycastAll(ray, Distance);
if (hits.Any(hit => hit.collider.gameObject.tag == "Monster_Shield")) { ZoomShield(); }
bool query = hits.Any(hit => hit.collider.gameObject.layer == 0 || hit.collider.gameObject.layer == 30 || hit.collider.gameObject.layer == 31 || hit.collider.gameObject.tag == "Monster_Shield");
if (!query && Distance < SightRange)
{
SightRange = Distance;
transform = weakTrans;
}
}
}
catch
{
continue;
}
}
if (transform != null)
{
Vector3 forward = transform.position - position;
forward.y += 0.14f;
Quaternion rotation = Quaternion.LookRotation(forward);
CameraManager.MainCamera.rotation = rotation;
}
}
}
}