-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPreCombatFollowTask.cs
More file actions
101 lines (85 loc) · 3.41 KB
/
PreCombatFollowTask.cs
File metadata and controls
101 lines (85 loc) · 3.41 KB
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
using System.Threading.Tasks;
using DreamPoeBot.Common;
using DreamPoeBot.Loki.Bot;
using DreamPoeBot.Loki.Bot.Pathfinding;
using DreamPoeBot.Loki.Common;
using DreamPoeBot.Loki.Game;
using FollowBot.SimpleEXtensions;
using log4net;
using static DreamPoeBot.Loki.Game.LokiPoe;
namespace FollowBot
{
class PreCombatFollowTask : ITask
{
private readonly ILog Log = Logger.GetLoggerInstanceForType();
private int FollowFailCounter = 0;
public string Name { get { return "PreCombatFollowTask"; } }
public string Description { get { return "This task will keep the bot under a specific distance from the leader, in combat situation."; } }
public string Author { get { return "NotYourFriend, origial code from Unknown"; } }
public string Version { get { return "0.0.0.1"; } }
public void Start()
{
Log.InfoFormat("[{0}] Task Loaded.", Name);
}
public void Stop()
{
}
public void Tick()
{
}
public async Task<bool> Run()
{
if (!FollowBotSettings.Instance.ShouldKill) return false;
if (!FollowBotSettings.Instance.ShouldFollow) return false;
if (!LokiPoe.IsInGame || LokiPoe.Me.IsDead || LokiPoe.Me.IsInTown || LokiPoe.Me.IsInHideout)
{
ProcessHookManager.SetKeyState(FollowBot.LastBoundMoveSkillKey, 0);
return false;
}
var leader = FollowBot.Leader;
if (leader == null)
{
ProcessHookManager.SetKeyState(FollowBot.LastBoundMoveSkillKey, 0);
return false;
}
var leaderPos = leader.Position;
var mypos = LokiPoe.Me.Position;
if (leaderPos == Vector2i.Zero || mypos == Vector2i.Zero)
{
ProcessHookManager.SetKeyState(FollowBot.LastBoundMoveSkillKey, 0);
return false;
}
var distance = leaderPos.Distance(mypos);
if (distance > FollowBotSettings.Instance.MaxCombatDistance)
{
var pos = ExilePather.FastWalkablePositionFor(mypos.GetPointAtDistanceBeforeEnd(
leaderPos,
LokiPoe.Random.Next(FollowBotSettings.Instance.FollowDistance,
FollowBotSettings.Instance.MaxFollowDistance)));
if (pos == Vector2i.Zero || !ExilePather.PathExistsBetween(mypos, pos))
{
ProcessHookManager.SetKeyState(FollowBot.LastBoundMoveSkillKey, 0);
return false;
}
// Cast Phase run if we have it.
FollowBot.PhaseRun();
if (ExilePather.PathDistance(mypos, pos) < 45)
LokiPoe.InGameState.SkillBarHud.UseAt(FollowBot.LastBoundMoveSkillSlot, false, pos, false);
else
Move.Towards(pos, $"{FollowBot.Leader.Name}");
return true;
}
ProcessHookManager.SetKeyState(FollowBot.LastBoundMoveSkillKey, 0);
////KeyManager.ClearAllKeyStates();
return false;
}
public async Task<LogicResult> Logic(Logic logic)
{
return LogicResult.Unprovided;
}
public MessageResult Message(Message message)
{
return MessageResult.Unprocessed;
}
}
}