-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathRandomJumper.cs
203 lines (178 loc) · 5.98 KB
/
RandomJumper.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
using System;
using System.ComponentModel;
using System.Configuration;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Security.Cryptography;
using System.Threading;
using MemoryRobot;
using robotManager.FiniteStateMachine;
using robotManager.Helpful;
using robotManager.Products;
using wManager;
using wManager.Plugin;
using wManager.Wow.Bot.States;
using wManager.Wow.Bot.Tasks;
using wManager.Wow.Class;
using wManager.Wow.Enums;
using wManager.Wow.Helpers;
using wManager.Wow.Helpers.FightClassCreator;
using wManager.Wow.ObjectManager;
using System.Windows.Forms;
using Math = robotManager.Helpful.Math;
using Timer = robotManager.Helpful.Timer;
public class Main : wManager.Plugin.IPlugin
{
private Random randomizer;
private Stopwatch timer;
private bool isRunning;
private int nextJump;
private int nextJumpTimes;
private static WoWLocalPlayer Me = ObjectManager.Me;
private BackgroundWorker pulseThread;
public void Start()
{
pulseThread = new BackgroundWorker();
pulseThread.DoWork += Pulse;
pulseThread.RunWorkerAsync();
}
public void Pulse(object sender, DoWorkEventArgs args)
{
try
{
nextJump = randomizer.Next(
RandomJumpSettings.CurrentSetting.MinRandomJumpTime,
RandomJumpSettings.CurrentSetting.MaxRandomJumpTime + 1);
nextJumpTimes = randomizer.Next(
RandomJumpSettings.CurrentSetting.MinRandomJumps,
RandomJumpSettings.CurrentSetting.MaxRandomJumps + 1);
timer.Start();
while (isRunning)
{
if (timer.Elapsed.TotalMilliseconds > nextJump)
{
if (!Me.IsFlying && (!RandomJumpSettings.CurrentSetting.NotDuringCasting || !Me.IsCast) && (!RandomJumpSettings.CurrentSetting.OutOfCombatOnly || !Me.InCombat))
{
for (int i = 0; i < nextJumpTimes; i++)
{
Move.JumpOrAscend(Move.MoveAction.PressKey, 50);
Thread.Sleep(1000);
}
nextJump = randomizer.Next(
RandomJumpSettings.CurrentSetting.MinRandomJumpTime,
RandomJumpSettings.CurrentSetting.MaxRandomJumpTime + 1);
nextJumpTimes = randomizer.Next(
RandomJumpSettings.CurrentSetting.MinRandomJumps,
RandomJumpSettings.CurrentSetting.MaxRandomJumps + 1);
timer.Restart();
}
}
Thread.Sleep(50);
}
}
catch (Exception e)
{
}
}
public void Dispose()
{
try
{
isRunning = false;
}
catch (Exception e)
{
}
}
public void Initialize()
{
randomizer = new Random();
timer = new Stopwatch();
isRunning = true;
RandomJumpSettings.Load();
Start();
}
public void Settings()
{
RandomJumpSettings.Load();
RandomJumpSettings.CurrentSetting.ToForm();
RandomJumpSettings.CurrentSetting.Save();
}
}
public class RandomJumpSettings : Settings
{
public RandomJumpSettings()
{
MinRandomJumpTime = 10000;
MaxRandomJumpTime = 25000;
MinRandomJumps = 1;
MaxRandomJumps = 2;
OutOfCombatOnly = true;
NotDuringCasting = true;
}
public static RandomJumpSettings CurrentSetting { get; set; }
public bool Save()
{
try
{
return Save(AdviserFilePathAndName("RandomJumper", ObjectManager.Me.Name + "." + Usefuls.RealmName));
}
catch (Exception e)
{
Logging.WriteDebug("RandomJumpSettings => Save(): " + e);
return false;
}
}
public static bool Load()
{
try
{
if (File.Exists(AdviserFilePathAndName("RandomJumper", ObjectManager.Me.Name + "." + Usefuls.RealmName)))
{
CurrentSetting =
Load<RandomJumpSettings>(AdviserFilePathAndName("RandomJumper",
ObjectManager.Me.Name + "." + Usefuls.RealmName));
return true;
}
CurrentSetting = new RandomJumpSettings();
}
catch (Exception e)
{
Logging.WriteDebug("RandomJumps => Load(): " + e);
}
return false;
}
[Setting]
[Category("Settings")]
[DisplayName("Random Minimum Milliseconds")]
[Description("Minimum time passed since last jump, in milliseconds.")]
public int MinRandomJumpTime { get; set; }
[Setting]
[Category("Settings")]
[DisplayName("Random Maximum Milliseconds")]
[Description("Maximum time passed since last jump, in milliseconds.")]
public int MaxRandomJumpTime { get; set; }
[Setting]
[Category("Settings")]
[DisplayName("Random Minimum Jumps")]
[Description("Minimum jumps in a row.")]
public int MinRandomJumps { get; set; }
[Setting]
[Category("Settings")]
[DisplayName("Random Maximum Jumps")]
[Description("Maximum jumps in a row.")]
public int MaxRandomJumps { get; set; }
[Setting]
[Category("Settings")]
[DisplayName("Only jump out of combat.")]
[Description("Only jump out of combat.")]
public bool OutOfCombatOnly { get; set; }
[Setting]
[Category("Settings")]
[DisplayName("Dont jump during casting.")]
[Description("Dont jump during casting.")]
public bool NotDuringCasting { get; set; }
}