forked from nt153133/LlamaLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRefreshPfBase.cs
More file actions
136 lines (118 loc) · 4.86 KB
/
RefreshPfBase.cs
File metadata and controls
136 lines (118 loc) · 4.86 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
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
using System;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using Buddy.Coroutines;
using ff14bot;
using ff14bot.AClasses;
using ff14bot.Behavior;
using ff14bot.Enums;
using ff14bot.Helpers;
using ff14bot.Managers;
using ff14bot.RemoteWindows;
using GreyMagic;
using TreeSharp;
namespace LlamaLibrary
{
public class RefreshPfBase : BotBase
{
private const int Offset0 = 0x1CA;
private const int Offset2 = 0x160;
private Composite _root;
private readonly int AgentId = 0;
public RefreshPfBase()
{
AgentId = getAgent();
}
public override string Name => "PF Refresh";
public override PulseFlags PulseFlags => PulseFlags.Chat | PulseFlags.Party | PulseFlags.Windows | PulseFlags.GameEvents;
public override bool IsAutonomous => true;
public override bool RequiresProfile => false;
public override Composite Root => _root;
public override bool WantButton { get; } = false;
public AtkAddonControl PfWindow => RaptureAtkUnitManager.GetWindowByName("LookingForGroup");
public AtkAddonControl PfConditionWindow => RaptureAtkUnitManager.GetWindowByName("LookingForGroupCondition");
public override void Start()
{
_root = new ActionRunCoroutine(r => Run());
}
private async Task<bool> Run()
{
switch (Core.Me.Icon)
{
case PlayerIcon.Recruiting_Party_Members:
await Coroutine.Sleep(1000);
break;
case PlayerIcon.None:
{
if (PfWindow == null)
{
AgentModule.ToggleAgentInterfaceById(AgentId);
await Coroutine.Wait(5000, () => PfWindow != null);
if (PfWindow != null)
{
PfWindow.SendAction(1, 3, 0xE);
await Coroutine.Wait(5000, () => PfConditionWindow != null);
if (PfConditionWindow != null)
{
var elements = ___Elements(PfConditionWindow);
var data = Core.Memory.ReadString((IntPtr) elements[187].Data, Encoding.UTF8);
if (data != "")
{
PfConditionWindow.SendAction(1, 3, 0x0);
Log("Registering PF");
await Coroutine.Sleep(2000);
await Coroutine.Wait(5000, () => PfConditionWindow == null);
if (PfWindow != null)
{
Log("Closing PF window");
PfWindow.SendAction(1, 3, uint.MaxValue);
}
}
else
{
Log("No Comment Setup. Quiting");
TreeRoot.Stop("No Comment Setup");
}
}
else
{
Log("Condition window didn't open");
TreeRoot.Stop("Shit Happens");
}
}
else
{
Log("PF window didn't open");
TreeRoot.Stop("Shit Happens");
}
}
break;
}
}
return true;
}
private int getAgent()
{
var patternFinder = new PatternFinder(Core.Memory);
IntPtr agentVtable = patternFinder.Find("48 8D 05 ? ? ? ? 48 89 51 ? 48 89 01 45 33 FF Add 3 TraceRelative");
return AgentModule.FindAgentIdByVtable(agentVtable);
}
private static TwoInt[] ___Elements(AtkAddonControl WindowByName)
{
if (WindowByName == null) return null;
var elementCount = ElementCount(WindowByName);
var addr = Core.Memory.Read<IntPtr>(WindowByName.Pointer + Offset2);
return Core.Memory.ReadArray<TwoInt>(addr, elementCount);
}
private static ushort ElementCount(AtkAddonControl WindowByName)
{
return WindowByName != null ? Core.Memory.Read<ushort>(WindowByName.Pointer + Offset0) : (ushort) 0;
}
private void Log(string text, params object[] args)
{
var msg = string.Format("[" + Name + "] " + text, args);
Logging.Write(Colors.Pink, msg);
}
}
}