This repository has been archived by the owner on Jan 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCraft.cs
140 lines (130 loc) · 6.52 KB
/
Craft.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nhaama;
using Nhaama.Memory;
using System.Text.RegularExpressions;
using Advanced_Combat_Tracker;
using System.Threading;
using System.Data;
namespace MoreLogLine
{
class Craft
{
private static NhaamaProcess _FFXIVProcess;
//private MoreLogLineUI _UI;
public static bool isCrafting = false;
private static uint Progress;
private static ulong ProgressOffset = (ulong)0x1CAB98C;
private static ulong ProgressPtr;
private static uint Step;
private static ulong StepOffset = ProgressOffset - 4;
private static ulong StepPtr;
private static uint Quality;
private static ulong QualityOffset = ProgressOffset + 8;
private static ulong QualityPtr;
//private uint HQRate;
//private ulong HQRateOffset = ProgressOffset + 0x10+4;
private static uint Durability;
private static ulong DurabilityOffset = ProgressOffset + 0x14;
private static ulong DurabilityPtr;
private static UInt16 Condition;
private static ulong ConditionOffset = ProgressOffset + 0x1C;
private static ulong ConditionPtr;
//normal=1, good=2, excellent=3, poor=4
private static uint Craftsmanship;
private static ulong CraftsmanshipOffset = (ulong)0x1C8B6D8 + 0x160 + 4 * 0x46;
private static ulong CraftsmanshipPtr;
private static uint Control;
private static ulong ControlOffset = (ulong)0x1C8B6D8 + 0x160 + 4 * 0x47;
private static ulong ControlPtr;
private static uint MaxCP;
private static ulong MaxCPOffset = (ulong)0x1C8B6D8 + 0x160 + 4 * 0x0b;
private static ulong MaxCPPtr;
private static uint CurrentCP;
private static Nhaama.Memory.Pointer CurrentCPPtr;
private static Regex StartCraft = new Regex("^.{14} 00:0842:([^:]+?)从背包里取出了材料。");
private static Regex EndCraft = new Regex("^.{14} 00:0842:([^:]+?)中止了制作作业。");
private static Regex CraftSkill = new Regex("^.{14} 00:08(42|2b):([^:]+?)发动([^:]+?)");
private static Regex CraftSucess = new Regex("^.{14} 00:08c2:([^:]+?)制作([^:]+?)成功");
public static void InitPtr(NhaamaProcess FFXIVProcess) {
try {
_FFXIVProcess = FFXIVProcess;
ulong ffxivOffset = _FFXIVProcess.GetModuleBasedOffset("ffxiv_dx11.exe", 0);
ProgressPtr = ffxivOffset + ProgressOffset;
QualityPtr = ffxivOffset + QualityOffset;
StepPtr = ffxivOffset + StepOffset;
DurabilityPtr = ffxivOffset + DurabilityOffset;
ConditionPtr = ffxivOffset + ConditionOffset;
CraftsmanshipPtr = ffxivOffset + CraftsmanshipOffset;
ControlPtr = ffxivOffset + ControlOffset;
MaxCPPtr = ffxivOffset + MaxCPOffset;
CurrentCPPtr = new Nhaama.Memory.Pointer(FFXIVProcess, 0x1C62680, 0x18AE);
MoreLogLineUI.AddParserMessage("Points Found!");
}
catch {
MoreLogLineUI.AddParserMessage("Points Not Found!");
throw new Exception("Could not find Points.");
}
}
public static void CleanStatus() {
Progress = Quality = Durability = 0;
Step = Condition = 1;
}
public static void ReadStatus() {
Step = _FFXIVProcess.ReadUInt32(StepPtr);
Progress = _FFXIVProcess.ReadUInt32(ProgressPtr);
Quality = _FFXIVProcess.ReadUInt32(QualityPtr);
//HQRate = FFXIVProcess.ReadUInt32(FFXIVProcess.GetModuleBasedOffset("ffxiv_dx11.exe", HQRateOffset));
Durability = _FFXIVProcess.ReadUInt32(DurabilityPtr);
Condition = _FFXIVProcess.ReadUInt16(ConditionPtr);
//normal=1, good=2, excellent=3, poor=4
Craftsmanship = _FFXIVProcess.ReadUInt32(CraftsmanshipPtr);
Control = _FFXIVProcess.ReadUInt32(ControlPtr);
MaxCP = _FFXIVProcess.ReadUInt32(MaxCPPtr);
CurrentCP = _FFXIVProcess.ReadUInt16(CurrentCPPtr);
}
public static void ProcessLogLine(bool isImport, DateTime dateTime, string logline) {
if (StartCraft.IsMatch(logline)) {
isCrafting = true;
OnLogLine_CraftStart(isImport, dateTime);
}
else if (isCrafting == true) {
if (CraftSkill.IsMatch(logline)) {
OnLogLine_CraftSkill(isImport, dateTime);
}
else if (EndCraft.IsMatch(logline) || CraftSucess.IsMatch(logline)) {
OnLogLine_CraftEnd(isImport, dateTime);
isCrafting = false;
}
}
}
private static string GenCraftLogLine(DateTime time) {
string timestamp = "[" + time.ToString("HH:mm:ss.fff") + "] ";
return $"{timestamp}{MessageType.CraftHead}:{Step:X}:{Progress:X}:{Quality:X}:{Durability:X}:{Condition:X}:{CurrentCP:X}:{MaxCP:X}:{Control:X}:{Craftsmanship:X}";
}
private static void OnLogLine_CraftStart(bool isImport,DateTime time) {
ReadStatus();
CleanStatus();
string logline= GenCraftLogLine(time);
LogLineEventArgs logLine = new LogLineEventArgs(logline, 0, ActGlobals.oFormActMain.LastEstimatedTime, ActGlobals.oFormActMain.ActiveZone.ZoneName, false);
LogLineHandle.SendLogLine(isImport, logLine);
}
private static void OnLogLine_CraftSkill(bool isImport,DateTime time) {
Thread.Sleep(200);
ReadStatus();
string logline = GenCraftLogLine(time);
LogLineEventArgs logLine = new LogLineEventArgs(logline, 0, ActGlobals.oFormActMain.LastEstimatedTime, ActGlobals.oFormActMain.ActiveZone.ZoneName, false);
LogLineHandle.SendLogLine(isImport, logLine);
}
private static void OnLogLine_CraftEnd(bool isImport,DateTime time) {
ReadStatus();
string logline = GenCraftLogLine(time);
LogLineEventArgs logLine = new LogLineEventArgs(logline, 0, ActGlobals.oFormActMain.LastEstimatedTime, ActGlobals.oFormActMain.ActiveZone.ZoneName, false);
LogLineHandle.SendLogLine(isImport, logLine);
CleanStatus();
}
}
}