Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b054bf31b | ||
|
|
a960f76920 | ||
|
|
00447d3e78 | ||
|
|
c5de098865 | ||
|
|
4ce7d02e75 | ||
|
|
c7827d0fa3 | ||
|
|
7513e75f74 | ||
|
|
0923b0802c | ||
|
|
2c9c78f933 | ||
|
|
c1ef7c141f | ||
|
|
a98934fc9a | ||
|
|
2b8f38b758 | ||
|
|
2545581807 | ||
|
|
e595b67d33 | ||
|
|
dcd7831368 | ||
|
|
4725af5491 | ||
|
|
a1cdf15c7e | ||
|
|
c461938ddd | ||
|
|
3d6546b528 | ||
|
|
b0d4068eb2 | ||
|
|
b0d8e1a274 | ||
|
|
a39aefb44c | ||
|
|
adf824519b | ||
|
|
4cb5442161 | ||
|
|
b74e09ac8b | ||
|
|
dd9433f565 | ||
|
|
a802ffa0e5 | ||
|
|
fe12b59b5c | ||
|
|
5f40e28332 | ||
|
|
44190a522b | ||
|
|
98d2664c28 | ||
|
|
94418cbe56 | ||
|
|
72c2e38f94 | ||
|
|
be5c8ad6e3 | ||
|
|
255f328b67 | ||
|
|
1dbb9e3bf1 | ||
|
|
df7b55e47c | ||
|
|
ed77d955ef | ||
|
|
e4e7b37fd2 | ||
|
|
9f728fdf30 | ||
|
|
7c96adb591 | ||
|
|
14a1d3be74 | ||
|
|
94aae80046 | ||
|
|
404e7215fa | ||
|
|
b3f6002846 | ||
|
|
960cfea102 | ||
|
|
7cc4093079 | ||
|
|
d23ba65d51 | ||
|
|
6b41b52008 | ||
|
|
3cbbbff093 | ||
|
|
81b754125a | ||
|
|
29544507eb | ||
|
|
8471d5ef88 | ||
|
|
a4bc632ae7 | ||
|
|
1f2d3a40d9 | ||
|
|
3a88da3c6e | ||
|
|
790d42cee0 | ||
|
|
c9f541362d | ||
|
|
efd2808a2e | ||
|
|
11ec9bc45d | ||
|
|
74645e8e93 | ||
|
|
af7209af48 | ||
|
|
7df31c66d2 | ||
|
|
0bb45c8390 | ||
|
|
07e682d488 | ||
|
|
a1508a7b05 | ||
|
|
57989fd8b9 | ||
|
|
c4031069c6 | ||
|
|
ecaab5dc76 | ||
|
|
a220dd2377 | ||
|
|
e1149bc254 | ||
|
|
6a53efce1e | ||
|
|
a67adc0070 | ||
|
|
03f6b6331f | ||
|
|
ee720f8dfd | ||
|
|
b152486327 | ||
|
|
70f1f69067 | ||
|
|
f56465ebf3 | ||
|
|
3b8b1ef9db | ||
|
|
a4bb2eeca2 | ||
|
|
f222431784 | ||
|
|
7c5958f8ad | ||
|
|
561f1b8b72 | ||
|
|
9ad1062020 | ||
|
|
2ed7a883b3 | ||
|
|
4859c4dc4a | ||
|
|
03f25ebcfb | ||
|
|
0580ec68e9 | ||
|
|
b4e6565443 | ||
|
|
e74d6b6bd4 | ||
|
|
b8c9dc971f | ||
|
|
b51200c1f3 | ||
|
|
943bd4fc4d | ||
|
|
3d2b1b376e | ||
|
|
73cd48f8b1 | ||
|
|
c4a7823c83 | ||
|
|
50aac5cea0 | ||
|
|
228d50bb5d | ||
|
|
5e16f48cf2 | ||
|
|
6fb29ddfad | ||
|
|
ac4dde6bf0 | ||
|
|
6c643b2419 | ||
|
|
2f44905c27 | ||
|
|
b2cf62a21c | ||
|
|
245c05b208 | ||
|
|
333ad6f0b4 | ||
|
|
c75dbbc241 | ||
|
|
421b11504f | ||
|
|
bb18350457 | ||
|
|
831f28b2aa | ||
|
|
475b9bbd00 | ||
|
|
a963a8595a | ||
|
|
5c712c5a31 | ||
|
|
8651ec74a6 | ||
|
|
6fadd528f1 | ||
|
|
f20cf89d5f | ||
|
|
c13db0a501 | ||
|
|
7b80867bd1 | ||
|
|
a2f877c455 | ||
|
|
504f853893 | ||
|
|
b1f6c062fb | ||
|
|
876a833590 | ||
|
|
160e45c75a | ||
|
|
66f15488e1 | ||
|
|
389dac879b | ||
|
|
8b6351cbd6 | ||
|
|
ca126e0d66 | ||
|
|
6c0b293328 | ||
|
|
aee54cc115 | ||
|
|
2817479d33 | ||
|
|
8de5bcf987 | ||
|
|
a25cc951c9 | ||
|
|
50ee1d1a3e | ||
|
|
7f39062f14 | ||
|
|
619cb667cd | ||
|
|
4da6efd54e | ||
|
|
5fe3db52bf | ||
|
|
d760f2411a | ||
|
|
1706312957 | ||
|
|
d686fdcb5a | ||
|
|
a93839e0be | ||
|
|
6e00e3f91e | ||
|
|
41c5f4c226 | ||
|
|
95f7b76a03 | ||
|
|
c137daec40 | ||
|
|
c89e2d4e84 | ||
|
|
1901246bab | ||
|
|
c15cb33c2c | ||
|
|
377de9e244 | ||
|
|
335b053b32 | ||
|
|
2516f9b248 | ||
|
|
d9e5f2f1dd | ||
|
|
0549df75b6 | ||
|
|
35264bc855 | ||
|
|
5167ce0ba8 | ||
|
|
7df330a9fb | ||
|
|
24c2d2cbf0 | ||
|
|
d51139025b | ||
|
|
e7148f827d | ||
|
|
3d5d918d24 | ||
|
|
ff969abbc7 | ||
|
|
541e9331c0 | ||
|
|
f182e345c2 | ||
|
|
5a0f7226ed | ||
|
|
8bb1d728ff | ||
|
|
38e05830a2 | ||
|
|
89340c42b0 | ||
|
|
8e44643a51 | ||
|
|
7afbbee3e1 | ||
|
|
6cf96c71f3 | ||
|
|
997059dd4b | ||
|
|
b445cbf42f | ||
|
|
19e7c9d02e | ||
|
|
d3f0f89da1 | ||
|
|
70b1ed88bb | ||
|
|
1a4682bf29 | ||
|
|
19fbcc48ab | ||
|
|
c63ac6947a | ||
|
|
98da4e072c | ||
|
|
a2adfe5b6f | ||
|
|
9cc91b4568 | ||
|
|
068cbd6e20 | ||
|
|
f713847df2 | ||
|
|
c39a882272 | ||
|
|
5f9ca6b399 | ||
|
|
bfe6b69edd | ||
|
|
8dbdf0840c | ||
|
|
4cba618722 | ||
|
|
4cc4aa27f0 | ||
|
|
3e69e6c3ac | ||
|
|
6414210095 | ||
|
|
83e6798439 | ||
|
|
779fbaad86 | ||
|
|
962d47722d | ||
|
|
89079f74d8 | ||
|
|
8dc074e987 | ||
|
|
12d4c60f7a | ||
|
|
fae49c4c3b | ||
|
|
a4e55ab164 | ||
|
|
dc8c1e063e | ||
|
|
1d9168d96e | ||
|
|
2d4a6192f2 | ||
|
|
7b51c018a7 | ||
|
|
121bfbaa8e | ||
|
|
8d2b36d5fd | ||
|
|
c83d3e336f | ||
|
|
5f76749be7 | ||
|
|
57d2257283 | ||
|
|
1657beb9a8 | ||
|
|
1829498647 | ||
|
|
cb53c74c6c | ||
|
|
4e6190ac7b | ||
|
|
bb374ee491 | ||
|
|
a06f0fcdb2 | ||
|
|
1a2b63fff7 | ||
|
|
220d6a4f9b | ||
|
|
d6860d5294 | ||
|
|
c37c43ce92 | ||
|
|
5984adf015 | ||
|
|
4276957837 | ||
|
|
a0691f1c19 | ||
|
|
ca6994a720 | ||
|
|
cb09a369c2 | ||
|
|
535f6b4551 | ||
|
|
1f798b9a3a | ||
|
|
1fd5320df2 | ||
|
|
5818bcd7ed | ||
|
|
93250f84cf | ||
|
|
010beebcb6 | ||
|
|
e6aa70a74c | ||
|
|
f6801eeaab | ||
|
|
522d0517a6 | ||
|
|
c90fb15557 | ||
|
|
5726e73d40 | ||
|
|
5d70782c49 | ||
|
|
3430e116e3 | ||
|
|
139b2089d5 | ||
|
|
0056dcfc11 | ||
|
|
c5d5ccab0e | ||
|
|
7c1febf307 | ||
|
|
5955f90c03 | ||
|
|
8931a633f1 | ||
|
|
ae5dbab855 | ||
|
|
fe09e9c35f | ||
|
|
023733d88f | ||
|
|
93944250e6 | ||
|
|
c9f7b3a14b | ||
|
|
ae75e9007d | ||
|
|
181b486db7 | ||
|
|
4e7349fac4 | ||
|
|
36da78cb78 | ||
|
|
bfddb53fa0 | ||
|
|
185ce4d930 | ||
|
|
7d82b1af9f | ||
|
|
cb47bf730b | ||
|
|
b2fecf1155 | ||
|
|
201ac734cb | ||
|
|
bb6aa9e121 | ||
|
|
b68b0d85f6 | ||
|
|
7f03157c25 | ||
|
|
461b0b00d1 | ||
|
|
24d798d6b2 | ||
|
|
447fd103de | ||
|
|
b7d492e5d2 | ||
|
|
3b701735e6 | ||
|
|
928f9612c0 | ||
|
|
a440729a67 | ||
|
|
64c5ab78bc | ||
|
|
c370410d53 | ||
|
|
98b1376111 | ||
|
|
622a4d5fde | ||
|
|
fb0c63f8a8 | ||
|
|
1610f1cd31 | ||
|
|
ab2d6c1de4 | ||
|
|
b62e4a7425 | ||
|
|
8f64c0ca4e | ||
|
|
57138a7be0 | ||
|
|
6aa02b94d9 | ||
|
|
be89383add | ||
|
|
0097bfa8c3 | ||
|
|
9393b0cb24 | ||
|
|
6812f30732 | ||
|
|
c6680ced12 | ||
|
|
b47ce6f529 | ||
|
|
9b874d3747 | ||
|
|
2b6465be22 | ||
|
|
d2574022fc | ||
|
|
87ae5e437a | ||
|
|
c486b860d0 | ||
|
|
4784551e10 | ||
|
|
030caec91f | ||
|
|
8b0bdef670 | ||
|
|
6651ec7d9f | ||
|
|
d4fe1f2ab0 | ||
|
|
4e1a0673c9 | ||
|
|
f904fe024b | ||
|
|
bb41bcb25e | ||
|
|
743debb58b | ||
|
|
180fc2d228 | ||
|
|
d148014b7f | ||
|
|
9fa721d5e4 | ||
|
|
8a5d1d5f64 | ||
|
|
cc245b0e8a | ||
|
|
49bc6befb7 | ||
|
|
f82e35382c | ||
|
|
224fc9917a | ||
|
|
eb0b681b9d | ||
|
|
f61a7c32d4 |
No files matched your search
@@ -0,0 +1,3 @@
|
||||
[submodule "BetterGenshinImpact/Script"]
|
||||
path = BetterGenshinImpact/Script
|
||||
url = https://github.com/babalae/bettergi-scripts.git
|
||||
@@ -19,9 +19,17 @@ public class AvatarClassifyGen
|
||||
// 读取基础图像
|
||||
// List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "*.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// 只用一个图像
|
||||
List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Sethos.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// List<string> sideImageFiles2 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Clorinde.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Xilonen.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// List<string> sideImageFiles2 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_MomokaCostumeErrantry.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// sideImageFiles.AddRange(sideImageFiles2);
|
||||
// List<string> sideImageFiles3 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_NilouCostumeFairy.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// sideImageFiles.AddRange(sideImageFiles3);
|
||||
// List<string> sideImageFiles4 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Kachina.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// sideImageFiles.AddRange(sideImageFiles4);
|
||||
// List<string> sideImageFiles5 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Mualani.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// sideImageFiles.AddRange(sideImageFiles5);
|
||||
// List<string> sideImageFiles6 = Directory.GetFiles(Path.Combine(BaseDir, "side_src"), "UI_AvatarIcon_Side_Kinich.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// sideImageFiles.AddRange(sideImageFiles6);
|
||||
|
||||
// 生成训练集
|
||||
GenTo(sideImageFiles, Path.Combine(BaseDir, @"dateset\train"), 200);
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace BetterGenshinImpact.Test.Dataset;
|
||||
|
||||
public class AvatarClassifyTransparentGen
|
||||
{
|
||||
// 基础图像文件夹
|
||||
private const string BaseDir = @"E:\HuiTask\更好的原神\自动秘境\自动战斗\队伍识别\分类器\";
|
||||
|
||||
// 背景图像文件夹
|
||||
private static readonly string BackgroundDir = Path.Combine(BaseDir, "background");
|
||||
|
||||
private static readonly Random Rd = new Random();
|
||||
|
||||
// 在类的开头添加一个新的常量
|
||||
private const string SideSrcDir = "side_src";
|
||||
|
||||
private const string SideSrcTransportDir = "side_src_transport";
|
||||
|
||||
public static void GenAll()
|
||||
{
|
||||
// 调整透明度(可选,取消注释以启用)
|
||||
AdjustTransparency(0.5f);
|
||||
|
||||
// 读取基础图像
|
||||
List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "*.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
// 只用一个图像
|
||||
// List<string> sideImageFiles = Directory.GetFiles(Path.Combine(BaseDir, SideSrcTransportDir), "UI_AvatarIcon_Side_Xilonen.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
|
||||
// 生成训练集
|
||||
GenTo(sideImageFiles, Path.Combine(BaseDir, @"dateset\train"), 200);
|
||||
// 生成测试集
|
||||
GenTo(sideImageFiles, Path.Combine(BaseDir, @"dateset\test"), 40);
|
||||
// GenTo(new List<string> { sideImageFiles[1] }, Path.Combine(BaseDir, @"dateset\test"), 1);
|
||||
}
|
||||
|
||||
static void GenTo(List<string> sideImageFiles, string dataFolder, int count)
|
||||
{
|
||||
// 保留区域 从底边中心为固定点
|
||||
var reservedSize = new Size(60, 80);
|
||||
|
||||
Directory.CreateDirectory(dataFolder);
|
||||
// 循环生成每个基础图像对应的数据集
|
||||
foreach (string sideImageFile in sideImageFiles)
|
||||
{
|
||||
// 获取基础图像文件名
|
||||
string sideImageFileName = Path.GetFileNameWithoutExtension(sideImageFile);
|
||||
sideImageFileName = sideImageFileName.Replace("UI_AvatarIcon_Side_", "");
|
||||
// 创建基础图像对应的数据集文件夹
|
||||
string sideDataFolder = Path.Combine(dataFolder, sideImageFileName);
|
||||
Directory.CreateDirectory(sideDataFolder);
|
||||
|
||||
// 读取基础图像
|
||||
Mat sideImageSrc = Cv2.ImRead(sideImageFile, ImreadModes.Unchanged);
|
||||
var channels = sideImageSrc.Split();
|
||||
var alphaChannel = channels[3]; // 透明通道
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Cv2.Multiply(channels[i], alphaChannel, channels[i], 1 / 255.0);
|
||||
}
|
||||
|
||||
var sideImage = new Mat();
|
||||
Cv2.Merge(channels[..3], sideImage);
|
||||
|
||||
// Cv2.ImShow("avatar", sideImage);
|
||||
|
||||
// 循环生成图像
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
// 随机挑选一张背景图像
|
||||
string backgroundImageFile = Path.Combine(BackgroundDir, Directory.GetFiles(BackgroundDir, "*.png")[Rd.Next(Directory.GetFiles(BackgroundDir, "*.png").Length)]);
|
||||
|
||||
// 从背景图像中随机取一块 128x128 的区域
|
||||
Mat backgroundImage = Cv2.ImRead(backgroundImageFile, ImreadModes.Color);
|
||||
Rect backgroundRect = new Rect(Rd.Next(backgroundImage.Width - 128), new Random().Next(backgroundImage.Height - 128), 128, 128);
|
||||
Mat backgroundImageRegion = backgroundImage[backgroundRect];
|
||||
|
||||
// 随机平移、缩放保留区域
|
||||
float scale = (float)(Rd.NextDouble() * (1.6 - 0.7) + 0.7);
|
||||
int w = (int)(sideImage.Width * scale);
|
||||
int h = (int)(sideImage.Height * scale);
|
||||
|
||||
Debug.WriteLine($"{sideImageFileName} 生成随机缩放{scale}");
|
||||
|
||||
// 把保留区域合成到背景图像上
|
||||
Mat backgroundImageRegionClone = backgroundImageRegion.Clone();
|
||||
var resizedSideImage = new Mat();
|
||||
Cv2.Resize(sideImage, resizedSideImage, new Size(128 * scale, 128 * scale));
|
||||
// Cv2.ImShow("resizedSideImage", resizedSideImage);
|
||||
var resizedMaskImage = new Mat();
|
||||
// Cv2.Threshold(alphaChannel, alphaChannel, 200, 255, ThresholdTypes.Otsu);
|
||||
Cv2.Resize(255 - alphaChannel, resizedMaskImage, new Size(128 * scale, 128 * scale), 0, 0, InterpolationFlags.Cubic);
|
||||
var resizedAlphaChannel = new Mat();
|
||||
Cv2.Resize(alphaChannel, resizedAlphaChannel, new Size(128 * scale, 128 * scale), 0, 0, InterpolationFlags.Cubic);
|
||||
|
||||
// Cv2.ImShow("resizedMaskImage", resizedMaskImage);
|
||||
// generatedImage[transformedRect] = resizedSideImage;
|
||||
Mat result;
|
||||
if (scale > 1)
|
||||
{
|
||||
int xSpace1 = (int)((128 - reservedSize.Width * scale) / 2.0);
|
||||
int ySpace1 = (int)(128 - reservedSize.Height * scale);
|
||||
int xSpace2 = (int)((resizedSideImage.Width - 128) / 2.0);
|
||||
int ySpace2 = resizedSideImage.Height - 128;
|
||||
int xSpace = Math.Min(xSpace1, xSpace2);
|
||||
int ySpace = Math.Min(ySpace1, ySpace2);
|
||||
int offsetX = Rd.Next(-xSpace, xSpace);
|
||||
int offsetY = Rd.Next(-ySpace, 0);
|
||||
Debug.WriteLine($"{sideImageFileName} 缩放{scale}大于1 偏移 ({offsetX},{offsetY})");
|
||||
|
||||
var roi = new Rect((resizedSideImage.Width - 128) / 2 + offsetX, (resizedSideImage.Height - 128) + offsetY, 128, 128);
|
||||
// result = new Mat();
|
||||
// Cv2.BitwiseAnd(backgroundImageRegionClone, backgroundImageRegionClone, result, resizedMaskImage[roi]);
|
||||
result = Mul(backgroundImageRegionClone, resizedAlphaChannel[roi]);
|
||||
Cv2.Add(result, resizedSideImage[roi], result);
|
||||
}
|
||||
else
|
||||
{
|
||||
int xSpace = (128 - w) / 2;
|
||||
int ySpace = 128 - h;
|
||||
int offsetX = Rd.Next(-xSpace, xSpace);
|
||||
int offsetY = Rd.Next(-ySpace, 0);
|
||||
Debug.WriteLine($"{sideImageFileName} 缩放{scale}小于等于1 偏移 ({offsetX},{offsetY})");
|
||||
|
||||
var roi = new Rect((128 - resizedSideImage.Width) / 2 + offsetX, (128 - resizedSideImage.Height) + offsetY, resizedSideImage.Width, resizedSideImage.Height);
|
||||
var res = new Mat();
|
||||
// Cv2.BitwiseAnd(backgroundImageRegionClone[roi], backgroundImageRegionClone[roi], res, resizedMaskImage);
|
||||
res = Mul(backgroundImageRegionClone[roi], resizedAlphaChannel);
|
||||
Cv2.Add(res, resizedSideImage, res);
|
||||
backgroundImageRegionClone[roi] = res;
|
||||
result = backgroundImageRegionClone.Clone();
|
||||
}
|
||||
|
||||
// Cv2.ImShow("avatarR", result);
|
||||
// 保存生成的图像
|
||||
Cv2.ImWrite(Path.Combine(sideDataFolder, $"{sideImageFileName}_t_{i}.png"), result);
|
||||
}
|
||||
}
|
||||
|
||||
static Mat Mul(Mat background, Mat alphaChannel)
|
||||
{
|
||||
var channels = background.Split();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Cv2.Multiply(channels[i], 255 - alphaChannel, channels[i], 1 / 255.0);
|
||||
}
|
||||
Mat result = new Mat();
|
||||
Cv2.Merge(channels[..3], result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// 在类中添加以下新方法
|
||||
public static void AdjustTransparency(float targetAlpha = 0.5f)
|
||||
{
|
||||
string sourcePath = Path.Combine(BaseDir, SideSrcDir);
|
||||
string destinationPath = Path.Combine(BaseDir, SideSrcTransportDir);
|
||||
|
||||
Directory.CreateDirectory(destinationPath);
|
||||
|
||||
List<string> sideImageFiles = Directory.GetFiles(sourcePath, "*.png", SearchOption.TopDirectoryOnly).ToList();
|
||||
|
||||
foreach (string sideImageFile in sideImageFiles)
|
||||
{
|
||||
string fileName = Path.GetFileName(sideImageFile);
|
||||
string destFile = Path.Combine(destinationPath, fileName);
|
||||
|
||||
Mat image = Cv2.ImRead(sideImageFile, ImreadModes.Unchanged);
|
||||
Mat[] channels = Cv2.Split(image);
|
||||
|
||||
if (channels.Length == 4) // 确保图像有透明通道
|
||||
{
|
||||
Mat alphaChannel = channels[3];
|
||||
Cv2.Multiply(alphaChannel, targetAlpha, alphaChannel);
|
||||
|
||||
Mat result = new Mat();
|
||||
Cv2.Merge(channels, result);
|
||||
|
||||
Cv2.ImWrite(destFile, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"警告:{fileName} 没有透明通道,将直接复制原文件。");
|
||||
File.Copy(sideImageFile, destFile, true);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"已完成透明度调整,结果保存在 {destinationPath}");
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Title="Test"
|
||||
Width="120"
|
||||
Width="240"
|
||||
Height="450"
|
||||
mc:Ignorable="d">
|
||||
<Canvas>
|
||||
@@ -43,13 +43,21 @@
|
||||
Width="100"
|
||||
Height="23"
|
||||
Click="MapDrawTeleportPoint"
|
||||
Content="超大地图标点" />
|
||||
Content="画传送点" />
|
||||
<Button Canvas.Left="10"
|
||||
Canvas.Top="190"
|
||||
Width="100"
|
||||
Height="23"
|
||||
Click="GenAvatarData"
|
||||
Content="生成侧面头像数据集" />
|
||||
Content="侧面头像数据集" />
|
||||
<Button Canvas.Left="120"
|
||||
Canvas.Top="190"
|
||||
Width="100"
|
||||
Height="23"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Click="GenAvatarDataT"
|
||||
Content="透明头像数据集" />
|
||||
<Button Canvas.Left="10"
|
||||
Canvas.Top="220"
|
||||
Width="100"
|
||||
@@ -62,5 +70,13 @@
|
||||
Height="23"
|
||||
Click="MapPathView"
|
||||
Content="路线地图查看" />
|
||||
<Button Canvas.Left="120"
|
||||
Canvas.Top="10"
|
||||
Width="100"
|
||||
Height="23"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Click="ZoomOut"
|
||||
Content="缩小地图到256" />
|
||||
</Canvas>
|
||||
</Window>
|
||||
@@ -1,17 +1,13 @@
|
||||
using System.Windows;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Test.Dataset;
|
||||
using BetterGenshinImpact.Test.Simple;
|
||||
using BetterGenshinImpact.Test.Simple.AllMap;
|
||||
using BetterGenshinImpact.Test.Simple.Track;
|
||||
using BetterGenshinImpact.Test.View;
|
||||
using System.Windows;
|
||||
|
||||
namespace BetterGenshinImpact.Test;
|
||||
|
||||
/// <summary>
|
||||
/// MainWindow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
@@ -48,8 +44,8 @@ public partial class MainWindow : Window
|
||||
private void DoMatchTest(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
// KeyPointMatchTest.Test();
|
||||
EntireMapTest.Test();
|
||||
// EntireMapTest.Storage();
|
||||
// EntireMapTest.Test();
|
||||
EntireMapTest.Storage();
|
||||
// BigMapMatchTest.Test();
|
||||
|
||||
// FeatureTransfer.Transfer();
|
||||
@@ -74,4 +70,14 @@ public partial class MainWindow : Window
|
||||
{
|
||||
MapPathTest.Test();
|
||||
}
|
||||
|
||||
private void ZoomOut(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ScaleTest.ZoomOutTest();
|
||||
}
|
||||
|
||||
private void GenAvatarDataT(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AvatarClassifyTransparentGen.GenAll();
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class MapPuzzle
|
||||
|
||||
public static void Put()
|
||||
{
|
||||
string folderPath = @"E:\HuiTask\更好的原神\地图匹配\UI_Map"; // 图片文件夹路径
|
||||
string folderPath = @"E:\HuiTask\更好的原神\地图匹配\UI_Map_5.0"; // 图片文件夹路径
|
||||
string pattern = @"UI_MapBack_([-+]?\d+)_([-+]?\d+)(.*)";
|
||||
var images = Directory.GetFiles(folderPath, "*.png", SearchOption.TopDirectoryOnly); // 获取所有图片文件路径
|
||||
|
||||
@@ -157,8 +157,11 @@ public class MapPuzzle
|
||||
Debug.WriteLine("");
|
||||
}
|
||||
|
||||
// 地图图片块
|
||||
SaveImagesAs1024X1024(arr, imageLocations, @"E:\HuiTask\更好的原神\地图匹配\有用的素材\5.0\地图块", minRow, minCol);
|
||||
|
||||
// 保存大图
|
||||
Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\map_46_2048.png", largeImage);
|
||||
// Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\map_50_2048.png", largeImage);
|
||||
// Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\combined_image_sd4x.png", largeImage.Resize(new Size(largeImage.Width / 4, largeImage.Height / 4), 0, 0, InterpolationFlags.Cubic));
|
||||
// Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\combined_image_small.png", largeImage.Resize(new Size(1400, 1300), 0, 0, InterpolationFlags.Cubic));
|
||||
|
||||
@@ -170,6 +173,36 @@ public class MapPuzzle
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveImagesAs1024X1024(int[,] arr, Dictionary<(int row, int col), ImgInfo> imageLocations, string outputFolder, int minRow, int minCol)
|
||||
{
|
||||
if (!Directory.Exists(outputFolder))
|
||||
{
|
||||
Directory.CreateDirectory(outputFolder);
|
||||
}
|
||||
|
||||
for (int row = 0; row < arr.GetLength(0); row++)
|
||||
{
|
||||
for (int col = 0; col < arr.GetLength(1); col++)
|
||||
{
|
||||
if (arr[row, col] == 1)
|
||||
{
|
||||
var key = (row + minRow, col + minCol);
|
||||
if (imageLocations.TryGetValue(key, out var imgInfo))
|
||||
{
|
||||
var img = imgInfo.Img;
|
||||
if (img.Width != 1204 || img.Height != 1204)
|
||||
{
|
||||
img = imgInfo.Img.Resize(new Size(1024, 1024), 0, 0, InterpolationFlags.Nearest);
|
||||
}
|
||||
var outputPath = Path.Combine(outputFolder, $"{row}_{col}.png");
|
||||
Cv2.ImWrite(outputPath, img);
|
||||
img.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ImgInfo
|
||||
{
|
||||
public Mat Img { get; set; }
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using BetterGenshinImpact.Service;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath.Model;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.Service;
|
||||
using OpenCvSharp;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
|
||||
namespace BetterGenshinImpact.Test.Simple.AllMap;
|
||||
|
||||
@@ -10,24 +13,28 @@ public class MapTeleportPointDraw
|
||||
{
|
||||
public static void Draw()
|
||||
{
|
||||
var pList = LoadTeleportPoint(@"E:\HuiTask\更好的原神\地图匹配\地图点位\Json_Integration\锚点&神像\");
|
||||
var map = new Mat(@"E:\HuiTask\更好的原神\地图匹配\genshin_map_带标记.png");
|
||||
DrawTeleportPoint(map, pList.ToArray());
|
||||
Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\genshin_map_带标记_传送点.png", map);
|
||||
// var pList = LoadTeleportPoint(@"E:\HuiTask\更好的原神\地图匹配\地图点位\5.0");
|
||||
// pList.AddRange(MapAssets.Instance.TpPositions);
|
||||
var map = new Mat(@"E:\HuiTask\更好的原神\地图匹配\有用的素材\5.0\mainMap1024BlockColor.png");
|
||||
DrawTeleportPoint(map, MapAssets.Instance.TpPositions);
|
||||
Cv2.ImWrite(@"E:\HuiTask\更好的原神\地图匹配\有用的素材\5.0\传送点_1024_0.34.3.png", map);
|
||||
}
|
||||
|
||||
public static void DrawTeleportPoint(Mat map, Point[] points)
|
||||
public static void DrawTeleportPoint(Mat map, List<GiWorldPosition> points)
|
||||
{
|
||||
foreach (var point in points)
|
||||
{
|
||||
Cv2.Circle(map, new Point(point.X, point.Y), 10, Scalar.Red, 2);
|
||||
var p = MapCoordinate.GameToMain1024(point.Position);
|
||||
Cv2.Circle(map, p, 4, Scalar.Red, 2);
|
||||
// 写文字
|
||||
Cv2.PutText(map, $"[{point.X:F2},{point.Y:F2}]", new Point(p.X + 10, p.Y + 5), HersheyFonts.HersheySimplex, 1, Scalar.Red, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Point> LoadTeleportPoint(string folderPath)
|
||||
public static List<GiWorldPosition> LoadTeleportPoint(string folderPath)
|
||||
{
|
||||
string[] files = Directory.GetFiles(folderPath, "*.*", SearchOption.AllDirectories);
|
||||
List<Point> points = new();
|
||||
List<GiWorldPosition> points = new();
|
||||
foreach (var file in files)
|
||||
{
|
||||
var gamePoint = JsonSerializer.Deserialize<GamePoint>(File.ReadAllText(file), ConfigService.JsonOptions);
|
||||
@@ -48,17 +55,12 @@ public class MapTeleportPointDraw
|
||||
/// </summary>
|
||||
/// <param name="position">[a,b,c]</param>
|
||||
/// <returns></returns>
|
||||
public static Point Transform(decimal[] position)
|
||||
public static GiWorldPosition Transform(decimal[] position)
|
||||
{
|
||||
// 四舍六入五取偶
|
||||
var a = (int)Math.Round(position[0]); // 上
|
||||
var c = (int)Math.Round(position[2]); // 左
|
||||
|
||||
// 转换1024区块坐标,大地图坐标系正轴是往左上方向的
|
||||
// 这里写最左上角的区块坐标(m,n)/(上,左),截止4.5版本,最左上角的区块坐标是(5,7)
|
||||
|
||||
int m = 5, n = 7;
|
||||
return new Point((n + 1) * 1024 - c, (m + 1) * 1024 - a);
|
||||
return new GiWorldPosition
|
||||
{
|
||||
Position = position,
|
||||
};
|
||||
}
|
||||
|
||||
class GamePoint
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace BetterGenshinImpact.Test.Simple;
|
||||
|
||||
public class ScaleTest
|
||||
{
|
||||
public static void ZoomOutTest()
|
||||
{
|
||||
var mainMap2048BlockMat = new Mat(@"E:\HuiTask\更好的原神\地图匹配\有用的素材\5.0\mainMap2048Block.png", ImreadModes.Color);
|
||||
// 缩小 2048/512 = 4
|
||||
var targetFilePath = @"E:\HuiTask\更好的原神\地图匹配\有用的素材\5.0\mainMap1024BlockColor.png";
|
||||
// opencv 缩小
|
||||
var mainMap256BlockMat = mainMap2048BlockMat.Resize(new Size(mainMap2048BlockMat.Width / 2, mainMap2048BlockMat.Height / 2));
|
||||
mainMap256BlockMat.SaveImage(targetFilePath);
|
||||
}
|
||||
}
|
||||
@@ -13,22 +13,22 @@ internal class MapPathTest
|
||||
{
|
||||
public static void Test()
|
||||
{
|
||||
var wayJson = File.ReadAllText(Global.Absolute(@"log\way\yl3.json"));
|
||||
var way = JsonSerializer.Deserialize<GiPath>(wayJson, ConfigService.JsonOptions) ?? throw new Exception("way json deserialize failed");
|
||||
|
||||
var points = way.WayPointList.Select(giPathPoint => giPathPoint.MatchRect.GetCenterPoint()).ToList();
|
||||
|
||||
var pointsRect = Cv2.BoundingRect(points);
|
||||
var allMap = new Mat(@"E:\HuiTask\更好的原神\地图匹配\有用的素材\mainMap2048Block.png");
|
||||
|
||||
// 按顺序连线,每个点都画圈
|
||||
for (var i = 0; i < points.Count - 1; i++)
|
||||
{
|
||||
Cv2.Line(allMap, points[i], points[i + 1], Scalar.Red, 1);
|
||||
Cv2.Circle(allMap, points[i], 3, Scalar.Red, -1);
|
||||
}
|
||||
|
||||
var map = allMap[new Rect(pointsRect.X - 100, pointsRect.Y - 100, pointsRect.Width + 200, pointsRect.Height + 200)];
|
||||
Cv2.ImShow("map", map);
|
||||
// var wayJson = File.ReadAllText(Global.Absolute(@"log\way\yl3.json"));
|
||||
// var way = JsonSerializer.Deserialize<GiPath>(wayJson, ConfigService.JsonOptions) ?? throw new Exception("way json deserialize failed");
|
||||
//
|
||||
// var points = way.WayPointList.Select(giPathPoint => giPathPoint.MatchRect.GetCenterPoint()).ToList();
|
||||
//
|
||||
// var pointsRect = Cv2.BoundingRect(points);
|
||||
// var allMap = new Mat(@"E:\HuiTask\更好的原神\地图匹配\有用的素材\mainMap2048Block.png");
|
||||
//
|
||||
// // 按顺序连线,每个点都画圈
|
||||
// for (var i = 0; i < points.Count - 1; i++)
|
||||
// {
|
||||
// Cv2.Line(allMap, points[i], points[i + 1], Scalar.Red, 1);
|
||||
// Cv2.Circle(allMap, points[i], 3, Scalar.Red, -1);
|
||||
// }
|
||||
//
|
||||
// var map = allMap[new Rect(pointsRect.X - 100, pointsRect.Y - 100, pointsRect.Width + 200, pointsRect.Height + 200)];
|
||||
// Cv2.ImShow("map", map);
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,21 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:bgivc="clr-namespace:BetterGenshinImpact.View.Converters"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml">
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:vio="http://schemas.lepo.co/wpfui/2022/xaml/violeta">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ui:ThemesDictionary Theme="Dark" />
|
||||
<ui:ControlsDictionary />
|
||||
<vio:ControlsDictionary />
|
||||
<ResourceDictionary Source="/View/Controls/WpfUi/FaFontIconStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<FontFamily x:Key="TextThemeFontFamily">/Assets/Fonts/MiSans-Regular.ttf#MiSans</FontFamily>
|
||||
<FontFamily x:Key="DigitalThemeFontFamily">/Assets/Fonts/deluge-led.ttf#Deluge LED</FontFamily>
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
<bgivc:BooleanToVisibilityRevertConverter x:Key="BooleanToVisibilityRevertConverter" />
|
||||
<bgivc:BooleanToEnableTextConverter x:Key="BooleanToEnableTextConverter" />
|
||||
<bgivc:InverseBooleanConverter x:Key="InverseBooleanConverter" />
|
||||
<bgivc:NotNullConverter x:Key="NotNullConverter" />
|
||||
</ResourceDictionary>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using BetterGenshinImpact.Helpers.Extensions;
|
||||
using BetterGenshinImpact.Hutao;
|
||||
using BetterGenshinImpact.Service;
|
||||
using BetterGenshinImpact.Service.Interface;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
@@ -10,6 +11,7 @@ using BetterGenshinImpact.View.Pages;
|
||||
using BetterGenshinImpact.ViewModel;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
@@ -20,7 +22,11 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using BetterGenshinImpact.View.Pages.View;
|
||||
using BetterGenshinImpact.ViewModel.Pages.OneDragon;
|
||||
using BetterGenshinImpact.ViewModel.Pages.View;
|
||||
using Wpf.Ui;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact;
|
||||
|
||||
@@ -35,6 +41,10 @@ public partial class App : Application
|
||||
.CheckIntegration()
|
||||
.UseElevated()
|
||||
.UseSingleInstance("BetterGI")
|
||||
.ConfigureLogging(builder =>
|
||||
{
|
||||
builder.ClearProviders();
|
||||
})
|
||||
.ConfigureServices(
|
||||
(context, services) =>
|
||||
{
|
||||
@@ -65,7 +75,6 @@ public partial class App : Application
|
||||
|
||||
// App Host
|
||||
services.AddHostedService<ApplicationHostService>();
|
||||
|
||||
// Page resolver service
|
||||
services.AddSingleton<IPageService, PageService>();
|
||||
|
||||
@@ -87,13 +96,30 @@ public partial class App : Application
|
||||
services.AddView<HotKeyPage, HotKeyPageViewModel>();
|
||||
services.AddView<NotificationSettingsPage, NotificationSettingsPageViewModel>();
|
||||
services.AddView<KeyMouseRecordPage, KeyMouseRecordPageViewModel>();
|
||||
// services.AddView<DispatcherPage, DispatcherPageViewModel>();
|
||||
services.AddView<JsListPage, JsListViewModel>();
|
||||
services.AddView<MapPathingPage, MapPathingViewModel>();
|
||||
services.AddView<OneDragonFlowPage, OneDragonFlowViewModel>();
|
||||
services.AddSingleton<PathingConfigViewModel>();
|
||||
// services.AddView<PathingConfigView, PathingConfigViewModel>();
|
||||
|
||||
// 一条龙 ViewModels
|
||||
// services.AddSingleton<CraftViewModel>();
|
||||
// services.AddSingleton<DailyCommissionViewModel>();
|
||||
// services.AddSingleton<DailyRewardViewModel>();
|
||||
// services.AddSingleton<DomainViewModel>();
|
||||
// services.AddSingleton<ForgingViewModel>();
|
||||
// services.AddSingleton<LeyLineBlossomViewModel>();
|
||||
// services.AddSingleton<MailViewModel>();
|
||||
// services.AddSingleton<SereniteaPotViewModel>();
|
||||
// services.AddSingleton<TcgViewModel>();
|
||||
|
||||
// My Services
|
||||
services.AddSingleton<TaskTriggerDispatcher>();
|
||||
services.AddSingleton<NotificationService>();
|
||||
services.AddHostedService(sp => sp.GetRequiredService<NotificationService>());
|
||||
services.AddSingleton<NotifierManager>();
|
||||
services.AddSingleton<IScriptService, ScriptService>();
|
||||
services.AddSingleton<HutaoNamedPipe>();
|
||||
|
||||
// Configuration
|
||||
//services.Configure<AppConfig>(context.Configuration.GetSection(nameof(AppConfig)));
|
||||
@@ -238,7 +264,23 @@ public partial class App : Application
|
||||
e = e.InnerException;
|
||||
}
|
||||
|
||||
MessageBox.Show("程序异常:" + e.Source + "\r\n--" + Environment.NewLine + e.StackTrace + "\r\n---" + Environment.NewLine + e.Message);
|
||||
try
|
||||
{
|
||||
ExceptionReport.Show(e);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Fallback.
|
||||
System.Windows.Forms.MessageBox.Show(
|
||||
$"""
|
||||
程序异常:{e.Source}
|
||||
--
|
||||
{e.StackTrace}
|
||||
--
|
||||
{e.Message}
|
||||
"""
|
||||
);
|
||||
}
|
||||
|
||||
// log
|
||||
GetLogger<App>().LogDebug(e, "UnHandle Exception");
|
||||
|
||||
|
After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 199 KiB |
|
After Width: | Height: | Size: 114 KiB |
|
After Width: | Height: | Size: 197 KiB |
|
After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 198 KiB |
|
After Width: | Height: | Size: 136 KiB |
|
After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 2.5 MiB After Width: | Height: | Size: 2.7 MiB |
@@ -1182,6 +1182,7 @@
|
||||
"其老爷",
|
||||
"关宏",
|
||||
"关垂",
|
||||
"杏仁长老",
|
||||
"仲夏庭园",
|
||||
"无妄引咎密宫",
|
||||
"华池岩岫",
|
||||
@@ -1341,6 +1342,21 @@
|
||||
"残毁的剑柄",
|
||||
"裂断的剑柄",
|
||||
"未熄的剑柄",
|
||||
"意志破碎的残片",
|
||||
"意志明晰的寄偶",
|
||||
"意志巡游的符像",
|
||||
"聚燃的石块",
|
||||
"聚燃的命种",
|
||||
"聚燃的游像眼",
|
||||
"秘源轴",
|
||||
"秘源机鞘",
|
||||
"秘源真芯",
|
||||
"稚嫩的尖齿",
|
||||
"老练的尖齿",
|
||||
"横行霸者的利齿",
|
||||
"卫从的木哨",
|
||||
"战士的铁哨",
|
||||
"龙冠武士的金哨",
|
||||
"小灯草",
|
||||
"慕风蘑菇",
|
||||
"蒲公英籽",
|
||||
@@ -1384,6 +1400,15 @@
|
||||
"子探测单元",
|
||||
"湖光铃兰",
|
||||
"初露之源",
|
||||
"颗粒果",
|
||||
"烛伞蘑菇",
|
||||
"烬芯花",
|
||||
"澄晶实",
|
||||
"苦种",
|
||||
"肉龙掌",
|
||||
"灼灼彩菊",
|
||||
"浪沫羽鳃",
|
||||
"青蜜莓",
|
||||
"红莲蛾",
|
||||
"蝴蝶",
|
||||
"黑背鲈鱼",
|
||||
@@ -1471,6 +1496,15 @@
|
||||
"「公平」的教导",
|
||||
"「正义」的教导",
|
||||
"「秩序」的教导",
|
||||
"「角逐」的哲学",
|
||||
"「焚燔」的哲学",
|
||||
"「纷争」的哲学",
|
||||
"「角逐」的指引",
|
||||
"「焚燔」的指引",
|
||||
"「纷争」的指引",
|
||||
"「角逐」的教导",
|
||||
"「焚燔」的教导",
|
||||
"「纷争」的教导",
|
||||
"「金鱼草」的种子",
|
||||
"「鸣草」的种子",
|
||||
"「清心」的种子",
|
||||
@@ -1551,6 +1585,9 @@
|
||||
"魔晶块",
|
||||
"奇异的「牙齿」",
|
||||
"汲取了生命力的龙牙",
|
||||
"牛奶",
|
||||
"糖",
|
||||
"固晶甲虫",
|
||||
"新鲜的鸟蛋",
|
||||
"新鲜的绯樱绣球",
|
||||
"新鲜的海草",
|
||||
@@ -1561,6 +1598,9 @@
|
||||
"新鲜的绝云椒椒",
|
||||
"新鲜的树莓",
|
||||
"新鲜的香辛果",
|
||||
"「永远高挂的落日」",
|
||||
"「岸上游泳的鱼儿」",
|
||||
"「夜晚显现的明月」",
|
||||
"纯洁松果",
|
||||
"碎星铁矿",
|
||||
"烹饪",
|
||||
@@ -1849,6 +1889,69 @@
|
||||
"更改旋律",
|
||||
"准备演出",
|
||||
"继续演出",
|
||||
"感谢信",
|
||||
"开始演奏",
|
||||
"募刻巧像",
|
||||
"摆放巧像",
|
||||
"绘想游迹",
|
||||
"召唤激流",
|
||||
"放入",
|
||||
"旋转管道",
|
||||
"让魔水流动吧!",
|
||||
"就是现在",
|
||||
"敲一敲…",
|
||||
"我带你飞一次?",
|
||||
"我来帮忙!",
|
||||
"戳一戳",
|
||||
"出发吧!",
|
||||
"有点奇怪…",
|
||||
"拉你一把",
|
||||
"发生什么了?",
|
||||
"交给我吧",
|
||||
"已经安全了!",
|
||||
"我需要那颗星星",
|
||||
"用力拉",
|
||||
"一起用力拉",
|
||||
"你已经做得很好了",
|
||||
"搭乘「空中列车」",
|
||||
"这是什么比赛?",
|
||||
"与纠结的小人结队",
|
||||
"与贪吃的小人结队",
|
||||
"与莽撞的小人结队",
|
||||
"开始挑战",
|
||||
"放置蘑菇",
|
||||
"放置苹果",
|
||||
"放置风车菊",
|
||||
"放置鸟蛋",
|
||||
"放置树莓",
|
||||
"放置禽肉",
|
||||
"放置蘑菇",
|
||||
"放置甜甜花",
|
||||
"放置绝云椒椒",
|
||||
"走左边",
|
||||
"走右边",
|
||||
"走前面",
|
||||
"算我一个!",
|
||||
"找到你啦!",
|
||||
"等待海上列车…",
|
||||
"推一下",
|
||||
"我来猜猜",
|
||||
"是元能构装体?",
|
||||
"是水深渊法师?",
|
||||
"是穿蓝衣服的小兔子?",
|
||||
"是超大松鼠?",
|
||||
"是短鬓虎?",
|
||||
"是穿绿衣服的狐狸?",
|
||||
"我来试试",
|
||||
"关于巨龙…",
|
||||
"你还好吗?",
|
||||
"魔线飞行",
|
||||
"老旧的日记",
|
||||
"发黄的信件",
|
||||
"准备留影",
|
||||
"用力拔",
|
||||
"更加用力拔",
|
||||
"污损的快件",
|
||||
"无锋剑",
|
||||
"银剑",
|
||||
"训练大剑",
|
||||
@@ -4545,6 +4648,127 @@
|
||||
"布蕾斯特",
|
||||
"苏定",
|
||||
"玄理",
|
||||
"奥比奇",
|
||||
"波波拉诺",
|
||||
"温柔的守卫",
|
||||
"藏宝爱好者",
|
||||
"卡佩",
|
||||
"艾德加",
|
||||
"席尔万",
|
||||
"卢西恩",
|
||||
"进入席尔万房间",
|
||||
"进入卢西恩房间",
|
||||
"进入艾德加房间",
|
||||
"议论纷纷的群众",
|
||||
"议论纷纷的群众",
|
||||
"议论纷纷的群众",
|
||||
"议论纷纷的群众",
|
||||
"议论纷纷的群众",
|
||||
"议论纷纷的群众",
|
||||
"进入席尔万房间",
|
||||
"艾德加",
|
||||
"卡佩",
|
||||
"奥比奇",
|
||||
"波波拉诺",
|
||||
"探长",
|
||||
"埃斯诺尔",
|
||||
"帕纽尔",
|
||||
"罗泽尔",
|
||||
"优雅的雕像",
|
||||
"用力推!!!",
|
||||
"用力拽!!!",
|
||||
"用力抬!!!",
|
||||
"温和的雕像",
|
||||
"平静的雕像",
|
||||
"福罗贝尔",
|
||||
"奥雷卢",
|
||||
"埃斯唐普",
|
||||
"西梅",
|
||||
"萨博兰",
|
||||
"苏法什",
|
||||
"陈旧的手稿",
|
||||
"疲惫的手稿",
|
||||
"兴奋的纸蛙",
|
||||
"沉稳的纸蛙",
|
||||
"好心的纸蛙",
|
||||
"忧郁的纸蛙",
|
||||
"123木头人",
|
||||
"123木头人2",
|
||||
"门后的声音",
|
||||
"注脚",
|
||||
"巨人卫兵",
|
||||
"路人",
|
||||
"星轨王城守卫",
|
||||
"店长",
|
||||
"粮油店长",
|
||||
"巨人卫兵",
|
||||
"巨人卫兵",
|
||||
"巨人卫兵",
|
||||
"巨人卫兵",
|
||||
"星轨王城守卫",
|
||||
"肖维涅",
|
||||
"我来试试",
|
||||
"我来试试",
|
||||
"我来试试",
|
||||
"我来试试",
|
||||
"我来试试",
|
||||
"我来试试",
|
||||
"巨人卫兵",
|
||||
"巨人卫兵",
|
||||
"埃斯诺尔",
|
||||
"失望的纸蛙",
|
||||
"不满的纸蛙",
|
||||
"发生什么了?",
|
||||
"字迹歪歪扭扭的信",
|
||||
"杏仁",
|
||||
"溪泉",
|
||||
"柑橘",
|
||||
"翻看书页",
|
||||
"布勒凡",
|
||||
"布勒施",
|
||||
"欧立威",
|
||||
"毕塞尔特",
|
||||
"搭乘「空中列车」",
|
||||
"杜林",
|
||||
"小杜林",
|
||||
"拜希麦·五世",
|
||||
"爆竹",
|
||||
"板栗",
|
||||
"白果",
|
||||
"瑟杜尔",
|
||||
"威尔",
|
||||
"积木卫兵",
|
||||
"蒙塔纳",
|
||||
"魔女M",
|
||||
"魔女B",
|
||||
"冲在前面的士兵",
|
||||
"冲在前面的士兵",
|
||||
"门内的人",
|
||||
"门内的人",
|
||||
"门内的人",
|
||||
"飞鼠",
|
||||
"士兵",
|
||||
"士兵",
|
||||
"小飞鼠",
|
||||
"飞鼠妈妈",
|
||||
"老旧的日记",
|
||||
"发黄的信件",
|
||||
"进入「邪龙」的巢穴",
|
||||
"德维特",
|
||||
"许迪",
|
||||
"克朗谢",
|
||||
"埃洛夫",
|
||||
"杏仁",
|
||||
"溪泉",
|
||||
"柑橘",
|
||||
"等待海上列车…",
|
||||
"前往提瓦特",
|
||||
"前往星轨王城",
|
||||
"前往破碎之海",
|
||||
"前往提瓦特",
|
||||
"「一篇未完成的手稿」",
|
||||
"杏仁",
|
||||
"溪泉",
|
||||
"亡国的美奈姬·卷五",
|
||||
"少女薇拉的忧郁·卷一",
|
||||
"少女薇拉的忧郁·卷二",
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# 启动参数说明
|
||||
|
||||
启动参数本质是 Unity 独立平台播放器命令行参数 ,测试下来有用的参数大概如下:
|
||||
|
||||
- `-window-mode exclusive` 参数
|
||||
- **独占全屏**,即选择游戏进程以独占全屏模式运行
|
||||
- **该功能与游戏内浏览器功能不兼容,你应仅在能独立描述独占全屏的技术原理和效果的情况下开启本项**
|
||||
- `-screen-fullscreen` 参数
|
||||
- **全屏**,即选择启动游戏后的游戏界面是否设置为全屏
|
||||
- `-popupwindow` 参数
|
||||
- **无边框**,即选择启动游戏后的游戏界面是否设置为无边框窗口
|
||||
- `-platform_type CLOUD_THIRD_PARTY_MOBILE` 参数
|
||||
- **触摸屏模式**,即启用原神内置的触摸屏操作模式(键鼠输入将被忽略)
|
||||
- 分辨率
|
||||
- 该功能可以快速设置下方的覆盖屏幕宽度和高度选项,有一些常见的预设项可供选择
|
||||
- `-screen-width` 参数
|
||||
- **宽度**,即选择启动游戏后的游戏界面的宽度,例如 `1920`
|
||||
- `-screen-height` 参数
|
||||
- **高度**,即选择启动游戏后的游戏界面的高度,例如 `1080`
|
||||
- `-monitor` 参数
|
||||
- **显示器**,允许多显示器用户选择指定的显示器来运行游戏
|
||||
|
Before Width: | Height: | Size: 117 KiB |
|
Before Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 76 KiB |
|
Before Width: | Height: | Size: 229 KiB |
@@ -5,30 +5,38 @@
|
||||
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<LangVersion>12.0</LangVersion>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ApplicationIcon>Assets\logo.ico</ApplicationIcon>
|
||||
<ApplicationIcon>Assets\Images\logo.ico</ApplicationIcon>
|
||||
<AssemblyName>BetterGI</AssemblyName>
|
||||
<AssemblyVersion>0.36.0</AssemblyVersion>
|
||||
<Platforms>x64</Platforms>
|
||||
<DebugType>embedded</DebugType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\*.jpg" />
|
||||
<None Remove="Assets\*.png" />
|
||||
<None Remove="Assets\*.ico" />
|
||||
<None Remove="Assets\Images\*.jpg" />
|
||||
<None Remove="Assets\Images\*" />
|
||||
<None Remove="Assets\Images\*.png" />
|
||||
<None Remove="Assets\Images\*.ico" />
|
||||
<None Remove="Assets\Fonts\*.ttf" />
|
||||
<None Remove="Assets\Highlighting\*.xshd" />
|
||||
<None Remove="Assets\Strings\*.html" />
|
||||
<None Remove="Assets\Strings\*.md" />
|
||||
<None Remove="Assets\Audios\*.mp3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="Assets\*.jpg" />
|
||||
<Resource Include="Assets\*.png" />
|
||||
<Resource Include="Assets\*.ico" />
|
||||
<Resource Include="Assets\Images\*.jpg" />
|
||||
<Resource Include="Assets\Images\Anniversary\*" />
|
||||
<Resource Include="Assets\Images\*.png" />
|
||||
<Resource Include="Assets\Images\*.ico" />
|
||||
<Resource Include="Assets\Fonts\*.ttf" />
|
||||
<Resource Include="Assets\Highlighting\*.xshd" />
|
||||
<Resource Include="Assets\Strings\*.html" />
|
||||
<Resource Include="Assets\Strings\*.md" />
|
||||
<Resource Include="Assets\Audios\*.mp3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -41,31 +49,34 @@
|
||||
<PackageReference Include="Microsoft.ML.OnnxRuntime.Managed" Version="1.18.1" />
|
||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2592.51" />
|
||||
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
|
||||
<PackageReference Include="OpenCvSharp4.WpfExtensions" Version="4.8.0.20230708" />
|
||||
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.8.0.20230708" />
|
||||
<PackageReference Include="OpenCvSharp4.Windows" Version="4.8.0.20230708" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.122" />
|
||||
<PackageReference Include="Microsoft.ClearScript.V8" Version="7.4.5" />
|
||||
<PackageReference Include="Microsoft.ClearScript.V8.Native.win-x64" Version="7.4.5" />
|
||||
<PackageReference Include="MouseKeyHook" Version="5.7.1" />
|
||||
<PackageReference Include="PresentMonFps" Version="2.0.1" />
|
||||
<PackageReference Include="PresentMonFps" Version="2.0.5" />
|
||||
<PackageReference Include="Sdcb.PaddleInference" Version="2.5.0.1" />
|
||||
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.openblas" Version="2.5.1" />
|
||||
<PackageReference Include="Sdcb.PaddleOCR" Version="2.7.0" />
|
||||
<PackageReference Include="Sdcb.PaddleOCR.Models.Online" Version="2.7.0.1" />
|
||||
<PackageReference Include="Sdl.MultiSelectComboBox" Version="1.0.103" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.RichTextBoxEx.Wpf" Version="1.1.0.1" />
|
||||
<PackageReference Include="System.IO.Hashing" Version="8.0.0" />
|
||||
<PackageReference Include="Vanara.PInvoke.NtDll" Version="4.0.2" />
|
||||
<PackageReference Include="Vanara.PInvoke.SHCore" Version="4.0.2" />
|
||||
<PackageReference Include="Vanara.PInvoke.User32" Version="4.0.2" />
|
||||
<PackageReference Include="WPF-UI" Version="3.0.5" />
|
||||
<PackageReference Include="WPF-UI.Tray" Version="3.0.5" />
|
||||
<PackageReference Include="WPF-UI.Violeta" Version="3.0.5.23" />
|
||||
<PackageReference Include="YoloV8" Version="4.1.7" />
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="3.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(Configuration)' == 'Debug'">
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -74,27 +85,6 @@
|
||||
<ProjectReference Include="..\Fischless.WindowsInput\Fischless.WindowsInput.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="GameTask\TaskContext.cs">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</Compile>
|
||||
<Compile Update="View\MaskWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\Pages\HotkeyPage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\Pages\TriggerSettingsPage.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\PickerWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="View\Windows\MapViewer.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Assets\Map\**">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -147,15 +137,11 @@
|
||||
<None Update="User\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Script\**">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="GameTask\Common\Element\Assets\MapPoint\" />
|
||||
<Folder Include="Script\AutoCrystalfly\" />
|
||||
<Folder Include="View\Controls\WpfUi\" />
|
||||
<Folder Include="GameTask\OneDragon\" />
|
||||
<Folder Include="User\AutoPathing\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -55,6 +55,12 @@ public partial class AllConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private bool _wgcUseBitmapCache = true;
|
||||
|
||||
/// <summary>
|
||||
/// 自动修复Win11下BitBlt截图方式不可用的问题
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _autoFixWin11BitBlt = true;
|
||||
|
||||
/// <summary>
|
||||
/// 推理使用的设备
|
||||
/// </summary>
|
||||
@@ -122,12 +128,22 @@ public partial class AllConfig : ObservableObject
|
||||
public AutoDomainConfig AutoDomainConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 脚本类配置
|
||||
/// 宏配置
|
||||
/// </summary>
|
||||
public MacroConfig MacroConfig { get; set; } = new();
|
||||
|
||||
public RecordConfig RecordConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 脚本配置
|
||||
/// </summary>
|
||||
public ScriptConfig ScriptConfig { get; set; } = new();
|
||||
|
||||
// /// <summary>
|
||||
// /// 路径追踪配置
|
||||
// /// </summary>
|
||||
public PathingConditionConfig PathingConditionConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 快捷键配置
|
||||
/// </summary>
|
||||
@@ -160,6 +176,9 @@ public partial class AllConfig : ObservableObject
|
||||
AutoWoodConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoFightConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoDomainConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
|
||||
ScriptConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
PathingConditionConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
}
|
||||
|
||||
public void OnAnyPropertyChanged(object? sender, EventArgs args)
|
||||
|
||||
@@ -1,14 +1,27 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
public class Global
|
||||
{
|
||||
public static string Version { get; } = "0.32.5";
|
||||
public static string Version { get; } = Assembly.GetExecutingAssembly().GetName().Version!.ToString(3);
|
||||
|
||||
public static string StartUpPath { get; set; } = AppContext.BaseDirectory;
|
||||
|
||||
public static readonly JsonSerializerOptions ManifestJsonOptions = new()
|
||||
{
|
||||
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals,
|
||||
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower,
|
||||
WriteIndented = true,
|
||||
AllowTrailingCommas = true,
|
||||
ReadCommentHandling = JsonCommentHandling.Skip,
|
||||
};
|
||||
|
||||
public static string Absolute(string relativePath)
|
||||
{
|
||||
return Path.Combine(StartUpPath, relativePath);
|
||||
@@ -16,12 +29,7 @@ public class Global
|
||||
|
||||
public static string ScriptPath()
|
||||
{
|
||||
return Absolute("Script");
|
||||
}
|
||||
|
||||
public static string ScriptPath(string folderName)
|
||||
{
|
||||
return Path.Combine(Absolute("Script"), folderName);
|
||||
return Absolute("User\\JsScript");
|
||||
}
|
||||
|
||||
public static string? ReadAllTextIfExist(string relativePath)
|
||||
|
||||
@@ -170,6 +170,34 @@ public partial class HotKeyConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _test2HotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 路径记录开始
|
||||
[ObservableProperty]
|
||||
private string _recBigMapPosHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _recBigMapPosHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 路径记录开始
|
||||
[ObservableProperty]
|
||||
private string _pathRecorderHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _pathRecorderHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 添加路径记录点
|
||||
[ObservableProperty]
|
||||
private string _addWaypointHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _addWaypointHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 路径执行
|
||||
[ObservableProperty]
|
||||
private string _executePathHotkey = "";
|
||||
|
||||
[ObservableProperty]
|
||||
private string _executePathHotkeyType = HotKeyTypeEnum.KeyboardMonitor.ToString();
|
||||
|
||||
// 日志与状态窗口展示
|
||||
[ObservableProperty]
|
||||
private string _logBoxDisplayHotkey = "";
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
using BetterGenshinImpact.Model;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
[Serializable]
|
||||
public partial class PathingConditionConfig : ObservableObject
|
||||
{
|
||||
// 路径追踪条件配置
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<Condition> _partyConditions = [];
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<Condition> _avatarConditions = [];
|
||||
|
||||
/// <summary>
|
||||
/// 找出当前应该切换的队伍名称
|
||||
/// </summary>
|
||||
/// <param name="materialName">采集物名称</param>
|
||||
/// <param name="specialActions">特殊动作</param>
|
||||
/// <returns></returns>
|
||||
public string? FilterPartyName(string materialName, List<string?> specialActions)
|
||||
{
|
||||
if (specialActions is { Count: > 0 })
|
||||
{
|
||||
// 特殊动作匹配队伍名
|
||||
foreach (var action in specialActions)
|
||||
{
|
||||
if (string.IsNullOrEmpty(action))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ConditionDefinitions.ActionCnDic.TryGetValue(action, out var actionCn))
|
||||
{
|
||||
continue; // 不校验
|
||||
}
|
||||
|
||||
var condition = PartyConditions.FirstOrDefault(c => c.Subject == "动作" && c.Object.Contains(actionCn));
|
||||
if (condition is { Result: not null })
|
||||
{
|
||||
return condition.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 采集物匹配队伍名
|
||||
var materialCondition = PartyConditions.FirstOrDefault(c => c.Subject == "采集物" && c.Object.Contains(materialName));
|
||||
if (materialCondition is { Result: not null })
|
||||
{
|
||||
return materialCondition.Result;
|
||||
}
|
||||
else
|
||||
{
|
||||
materialCondition = PartyConditions.FirstOrDefault(c => c.Subject == "采集物" && c.Object.Contains("全部"));
|
||||
if (materialCondition is { Result: not null })
|
||||
{
|
||||
return materialCondition.Result;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过条件配置生成队伍配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public PathingPartyConfig BuildPartyConfigByCondition(CombatScenes combatScenes)
|
||||
{
|
||||
PathingPartyConfig partyConfig = new();
|
||||
// 使用最优先匹配上的条件
|
||||
foreach (var avatarCondition in AvatarConditions)
|
||||
{
|
||||
if (avatarCondition.Result == "循环短E" || avatarCondition.Result == "循环长E")
|
||||
{
|
||||
foreach (var avatar in combatScenes.Avatars)
|
||||
{
|
||||
if (avatarCondition is { Object: not null } && avatarCondition.Object.Contains(avatar.Name))
|
||||
{
|
||||
partyConfig.GuardianAvatarIndex = avatar.Index.ToString();
|
||||
if (avatarCondition.Result == "循环长E")
|
||||
{
|
||||
partyConfig.GuardianElementalSkillLongPress = true;
|
||||
partyConfig.GuardianElementalSkillSecondInterval = avatar.SkillHoldCd.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
else
|
||||
{
|
||||
partyConfig.GuardianElementalSkillLongPress = false;
|
||||
partyConfig.GuardianElementalSkillSecondInterval = avatar.SkillCd.ToString(CultureInfo.CurrentCulture);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(partyConfig.GuardianAvatarIndex))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var avatarCondition in AvatarConditions)
|
||||
{
|
||||
if (avatarCondition.Result == "作为主要行走角色")
|
||||
{
|
||||
foreach (var avatar in combatScenes.Avatars)
|
||||
{
|
||||
if (avatarCondition is { Object: not null } && avatarCondition.Object.Contains(avatar.Name))
|
||||
{
|
||||
partyConfig.MainAvatarIndex = avatar.Index.ToString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(partyConfig.MainAvatarIndex))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 默认元素力采集角色
|
||||
// var elementalCollectAvatars = ElementalCollectAvatarConfigs.Lists;
|
||||
// foreach (var avatar in combatScenes.Avatars)
|
||||
// {
|
||||
// var elementalCollectAvatar = elementalCollectAvatars.FirstOrDefault(x => x.Name == avatar.Name);
|
||||
// if (elementalCollectAvatar != null)
|
||||
// {
|
||||
// if (elementalCollectAvatar.ElementalType == ElementalType.Hydro)
|
||||
// {
|
||||
// partyConfig.HydroCollectAvatarIndex = avatar.Index.ToString();
|
||||
// }
|
||||
// else if (elementalCollectAvatar.ElementalType == ElementalType.Electro)
|
||||
// {
|
||||
// partyConfig.ElectroCollectAvatarIndex = avatar.Index.ToString();
|
||||
// }
|
||||
// else if (elementalCollectAvatar.ElementalType == ElementalType.Anemo)
|
||||
// {
|
||||
// partyConfig.AnemoCollectAvatarIndex = avatar.Index.ToString();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
return partyConfig;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
[Serializable]
|
||||
public partial class PathingPartyConfig : ObservableObject
|
||||
{
|
||||
// 配置是否启用,不启用会使用路径追踪内的条件配置
|
||||
[ObservableProperty]
|
||||
private bool _enabled = false;
|
||||
|
||||
// 切换到队伍的名称
|
||||
[ObservableProperty]
|
||||
private string _partyName = string.Empty;
|
||||
|
||||
// 主要行走追踪的角色编号
|
||||
[ObservableProperty]
|
||||
private string _mainAvatarIndex = string.Empty;
|
||||
|
||||
// [盾角]使用元素战技的角色编号
|
||||
[ObservableProperty]
|
||||
private string _guardianAvatarIndex = string.Empty;
|
||||
|
||||
// [盾角]使用元素战技的时间间隔(s)
|
||||
[ObservableProperty]
|
||||
private string _guardianElementalSkillSecondInterval = string.Empty;
|
||||
|
||||
// [盾角]使用元素战技的方式 长按/短按
|
||||
[ObservableProperty]
|
||||
private bool _guardianElementalSkillLongPress = false;
|
||||
|
||||
// // normal_attack 配置几号位
|
||||
// [ObservableProperty]
|
||||
// private string _normalAttackAvatarIndex = string.Empty;
|
||||
//
|
||||
// // elemental_skill 配置几号位
|
||||
// [ObservableProperty]
|
||||
// private string _elementalSkillAvatarIndex = string.Empty;
|
||||
|
||||
// // hydro_collect 配置几号位
|
||||
// [ObservableProperty]
|
||||
// private string _hydroCollectAvatarIndex = string.Empty;
|
||||
//
|
||||
// // electro_collect 配置几号位
|
||||
// [ObservableProperty]
|
||||
// private string _electroCollectAvatarIndex = string.Empty;
|
||||
//
|
||||
// // anemo_collect 配置几号位
|
||||
// [ObservableProperty]
|
||||
// private string _anemoCollectAvatarIndex = string.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
public List<string> AvatarIndexList { get; } = ["", "1", "2", "3", "4"];
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Config;
|
||||
|
||||
/// <summary>
|
||||
/// 脚本配置
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public partial class ScriptConfig : ObservableObject
|
||||
{
|
||||
// 自动更新脚本仓库周期(天)
|
||||
[ObservableProperty]
|
||||
private int _autoUpdateScriptRepoPeriod = 1;
|
||||
|
||||
// 上次更新脚本仓库时间
|
||||
[ObservableProperty]
|
||||
private DateTime _lastUpdateScriptRepoTime = DateTime.MinValue;
|
||||
|
||||
// 脚本仓库按钮红点是否展示
|
||||
[ObservableProperty]
|
||||
private bool _scriptRepoHintDotVisible = false;
|
||||
|
||||
// 已订阅的脚本路径列表
|
||||
[ObservableProperty]
|
||||
private List<string> _subscribedScriptPaths = [];
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class PaddleOcrService : IOcrService
|
||||
|
||||
public PaddleOcrService()
|
||||
{
|
||||
var path = Global.Absolute("Assets\\Model\\PaddleOcr");
|
||||
var path = Global.Absolute(@"Assets\Model\PaddleOcr");
|
||||
var localDetModel = DetectionModel.FromDirectory(Path.Combine(path, "ch_PP-OCRv4_det"), ModelVersion.V4);
|
||||
var localClsModel = ClassificationModel.FromDirectory(Path.Combine(path, "ch_ppocr_mobile_v2.0_cls"));
|
||||
var localRecModel = RecognizationModel.FromDirectory(Path.Combine(path, "ch_PP-OCRv4_rec"), Path.Combine(path, "ppocr_keys_v1.txt"), ModelVersion.V4);
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using Compunet.YoloV8;
|
||||
using OpenCvSharp;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
|
||||
public class BgiYoloV8Predictor(string modelRelativePath) : IDisposable
|
||||
{
|
||||
private readonly YoloV8Predictor _predictor = YoloV8Builder.CreateDefaultBuilder()
|
||||
.UseOnnxModel(Global.Absolute(modelRelativePath))
|
||||
.WithSessionOptions(BgiSessionOption.Instance.Options)
|
||||
.Build();
|
||||
|
||||
public YoloV8Predictor Predictor => _predictor;
|
||||
|
||||
/// <summary>
|
||||
/// 检测
|
||||
/// </summary>
|
||||
/// <param name="region">图像</param>
|
||||
/// <returns>类别-矩形框</returns>
|
||||
public Dictionary<string, List<Rect>> Detect(ImageRegion region)
|
||||
{
|
||||
using var memoryStream = new MemoryStream();
|
||||
region.SrcBitmap.Save(memoryStream, ImageFormat.Bmp);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
var result = _predictor.Detect(memoryStream);
|
||||
|
||||
var dict = new Dictionary<string, List<Rect>>();
|
||||
foreach (var box in result.Boxes)
|
||||
{
|
||||
if (!dict.ContainsKey(box.Class.Name))
|
||||
{
|
||||
dict[box.Class.Name] = [new Rect(box.Bounds.X, box.Bounds.Y, box.Bounds.Width, box.Bounds.Height)];
|
||||
}
|
||||
else
|
||||
{
|
||||
dict[box.Class.Name].Add(new Rect(box.Bounds.X, box.Bounds.Y, box.Bounds.Width, box.Bounds.Height));
|
||||
}
|
||||
}
|
||||
Debug.WriteLine("YOLOv8识别结果:" + JsonSerializer.Serialize(dict));
|
||||
return dict;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_predictor.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,12 @@ public class PickTextInference : ITextInference
|
||||
|
||||
public PickTextInference()
|
||||
{
|
||||
var modelPath = Global.Absolute("Assets\\Model\\Yap\\model_training.onnx");
|
||||
var modelPath = Global.Absolute(@"Assets\Model\Yap\model_training.onnx");
|
||||
if (!File.Exists(modelPath)) throw new FileNotFoundException("Yap模型文件不存在", modelPath);
|
||||
|
||||
_session = new InferenceSession(modelPath, BgiSessionOption.Instance.Options);
|
||||
|
||||
var wordJsonPath = Global.Absolute("Assets\\Model\\Yap\\index_2_word.json");
|
||||
var wordJsonPath = Global.Absolute(@"Assets\Model\Yap\index_2_word.json");
|
||||
if (!File.Exists(wordJsonPath)) throw new FileNotFoundException("Yap字典文件不存在", wordJsonPath);
|
||||
|
||||
var json = File.ReadAllText(wordJsonPath);
|
||||
|
||||
@@ -15,12 +15,12 @@ public class Predictor
|
||||
public Predictor()
|
||||
{
|
||||
var options = new SessionOptions();
|
||||
var modelPath = Global.Absolute("Assets\\Model\\Fish\\bgi_fish.onnx");
|
||||
var modelPath = Global.Absolute(@"Assets\Model\Fish\bgi_fish.onnx");
|
||||
if (!File.Exists(modelPath)) throw new FileNotFoundException("自动钓鱼模型文件不存在", modelPath);
|
||||
|
||||
_session = new InferenceSession(modelPath, options);
|
||||
|
||||
var wordJsonPath = Global.Absolute("Assets\\Model\\Fish\\label.json");
|
||||
var wordJsonPath = Global.Absolute(@"Assets\Model\Fish\label.json");
|
||||
if (!File.Exists(wordJsonPath)) throw new FileNotFoundException("自动钓鱼模型分类文件不存在", wordJsonPath);
|
||||
|
||||
var json = File.ReadAllText(wordJsonPath);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace BetterGenshinImpact.Core.Recognition.OpenCv.FeatureMatch;
|
||||
|
||||
/// <summary>
|
||||
/// FlannMatch
|
||||
/// 优点:
|
||||
/// 1. 速度快:FlannMatch 使用的是近似最近邻搜索算法,适合处理大规模数据集,速度比暴力匹配器快得多。
|
||||
/// 2. 可扩展性好:适用于高维特征空间,能够处理大量特征点。
|
||||
/// 缺点:
|
||||
/// 1. 精度较低:由于是近似搜索,匹配的精度可能不如暴力匹配器高。
|
||||
/// 2. 复杂性高:需要对参数进行调优,以获得最佳性能。
|
||||
/// BfMatch
|
||||
/// 优点:
|
||||
/// 1. 精度高:BfMatch 进行的是精确匹配,能够找到最优的匹配对。
|
||||
/// 2. 简单易用:不需要复杂的参数调优,适合初学者和简单应用。
|
||||
/// 缺点:
|
||||
/// 1. 速度慢:对于大规模数据集,暴力匹配器的速度较慢,因为它需要计算所有特征点之间的距离。
|
||||
/// 2. 不适合高维数据:在高维特征空间中,计算量会显著增加,性能下降明显。
|
||||
/// 选择建议
|
||||
/// • 大规模数据集:如果你需要处理大量特征点,且对速度要求较高,FlannMatch 是一个更好的选择。
|
||||
/// • 高精度要求:如果你的应用对匹配精度要求很高,且数据规模较小,BfMatch 会更合适。
|
||||
/// </summary>
|
||||
public enum DescriptorMatcherType
|
||||
{
|
||||
// 快速近似最近邻搜索库
|
||||
BruteForce,
|
||||
|
||||
// 暴力匹配器
|
||||
FlannBased
|
||||
|
||||
// 更多类型命名见 DescriptorMatcher.Create
|
||||
}
|
||||
@@ -7,15 +7,21 @@ using OpenCvSharp.XFeatures2D;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recognition.OpenCv.FeatureMatch;
|
||||
|
||||
public class FeatureMatcher
|
||||
{
|
||||
private readonly double _threshold; // SURF 100
|
||||
private readonly double _threshold = 100; // SURF 100
|
||||
private readonly Feature2D _feature2D;
|
||||
private readonly FlannBasedMatcher flnMatcher = new();
|
||||
|
||||
private readonly Dictionary<DescriptorMatcherType, DescriptorMatcher> _matcherFactory = new()
|
||||
{
|
||||
{ DescriptorMatcherType.BruteForce, DescriptorMatcher.Create(DescriptorMatcherType.BruteForce.ToString()) },
|
||||
{ DescriptorMatcherType.FlannBased, DescriptorMatcher.Create(DescriptorMatcherType.FlannBased.ToString()) }
|
||||
};
|
||||
|
||||
private readonly Size _trainMatSize; // 大图大小
|
||||
|
||||
@@ -34,11 +40,9 @@ public class FeatureMatcher
|
||||
/// <param name="trainMat"></param>
|
||||
/// <param name="featureStorage"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="threshold"></param>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public FeatureMatcher(Mat trainMat, FeatureStorage? featureStorage = null, Feature2DType type = Feature2DType.SIFT, double threshold = 100)
|
||||
public FeatureMatcher(Mat trainMat, FeatureStorage? featureStorage = null, Feature2DType type = Feature2DType.SIFT)
|
||||
{
|
||||
_threshold = threshold;
|
||||
_trainMatSize = trainMat.Size();
|
||||
if (Feature2DType.SURF == type)
|
||||
{
|
||||
@@ -86,11 +90,9 @@ public class FeatureMatcher
|
||||
/// <param name="trainMatSize"></param>
|
||||
/// <param name="featureStorage"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="threshold"></param>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public FeatureMatcher(Size trainMatSize, FeatureStorage featureStorage, Feature2DType type = Feature2DType.SIFT, double threshold = 100)
|
||||
public FeatureMatcher(Size trainMatSize, FeatureStorage featureStorage, Feature2DType type = Feature2DType.SIFT)
|
||||
{
|
||||
_threshold = threshold;
|
||||
_trainMatSize = trainMatSize;
|
||||
if (Feature2DType.SURF == type)
|
||||
{
|
||||
@@ -114,6 +116,13 @@ public class FeatureMatcher
|
||||
Debug.WriteLine($"切割特征点耗时: {sw.ElapsedMilliseconds}ms");
|
||||
}
|
||||
|
||||
public DescriptorMatcher GetMatcher(DescriptorMatcherType type)
|
||||
{
|
||||
return _matcherFactory[type];
|
||||
}
|
||||
|
||||
#region 普通匹配
|
||||
|
||||
/// <summary>
|
||||
/// 普通匹配(全图特征)
|
||||
/// </summary>
|
||||
@@ -150,11 +159,13 @@ public class FeatureMatcher
|
||||
/// 普通匹配
|
||||
/// </summary>
|
||||
/// <param name="trainKeyPoints"></param>
|
||||
/// <param name="trainRet"></param>
|
||||
/// <param name="trainDescriptors"></param>
|
||||
/// <param name="queryMat"></param>
|
||||
/// <param name="queryMatMask"></param>
|
||||
/// <param name="matcherType"></param>
|
||||
/// <returns></returns>
|
||||
public Point2f Match(KeyPoint[] trainKeyPoints, Mat trainRet, Mat queryMat, Mat? queryMatMask = null)
|
||||
public Point2f Match(KeyPoint[] trainKeyPoints, Mat trainDescriptors, Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
SpeedTimer speedTimer = new();
|
||||
|
||||
@@ -164,7 +175,7 @@ public class FeatureMatcher
|
||||
#pragma warning restore CS8604 // 引用类型参数可能为 null。
|
||||
speedTimer.Record("模板生成KeyPoint");
|
||||
|
||||
var matches = flnMatcher.Match(queryDescriptors, trainRet);
|
||||
var matches = GetMatcher(matcherType).Match(queryDescriptors, trainDescriptors);
|
||||
//Finding the Minimum and Maximum Distance
|
||||
double minDistance = 1000; //Backward approximation
|
||||
double maxDistance = 0;
|
||||
@@ -237,11 +248,13 @@ public class FeatureMatcher
|
||||
/// 普通匹配
|
||||
/// </summary>
|
||||
/// <param name="trainKeyPoints"></param>
|
||||
/// <param name="trainRet"></param>
|
||||
/// <param name="trainDescriptors"></param>
|
||||
/// <param name="queryMat"></param>
|
||||
/// <param name="queryMatMask"></param>
|
||||
/// <param name="matcherType"></param>
|
||||
/// <returns></returns>
|
||||
public Point2f[] MatchCorners(KeyPoint[] trainKeyPoints, Mat trainRet, Mat queryMat, Mat? queryMatMask = null)
|
||||
public Point2f[] MatchCorners(KeyPoint[] trainKeyPoints, Mat trainDescriptors, Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
SpeedTimer speedTimer = new();
|
||||
|
||||
@@ -251,7 +264,7 @@ public class FeatureMatcher
|
||||
#pragma warning restore CS8604 // 引用类型参数可能为 null。
|
||||
speedTimer.Record("模板生成KeyPoint");
|
||||
|
||||
var matches = flnMatcher.Match(queryDescriptors, trainRet);
|
||||
var matches = GetMatcher(matcherType).Match(queryDescriptors, trainDescriptors);
|
||||
//Finding the Minimum and Maximum Distance
|
||||
double minDistance = 1000; //Backward approximation
|
||||
double maxDistance = 0;
|
||||
@@ -328,91 +341,46 @@ public class FeatureMatcher
|
||||
return Cv2.BoundingRect(corners);
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// knn的方式匹配
|
||||
// /// </summary>
|
||||
// /// <param name="matSrc"></param>
|
||||
// /// <returns></returns>
|
||||
// [Obsolete]
|
||||
// public Point2f[]? KnnMatch(Mat matSrc)
|
||||
// {
|
||||
// SpeedTimer speedTimer = new();
|
||||
//
|
||||
// using var matSrcRet = new Mat();
|
||||
// KeyPoint[] keyPointsSrc;
|
||||
// using (var surf = SURF.Create(_threshold, 4, 3, false, true))
|
||||
// {
|
||||
// surf.DetectAndCompute(matSrc, null, out keyPointsSrc, matSrcRet);
|
||||
// speedTimer.Record("模板生成KeyPoint");
|
||||
// }
|
||||
//
|
||||
// var knnMatches = flnMatcher.KnnMatch(matSrcRet, _trainDescriptors, 2);
|
||||
// const float minRatio = 0.75f;
|
||||
//
|
||||
// var pointsSrc = new List<Point2f>();
|
||||
// var pointsDst = new List<Point2f>();
|
||||
// //Screening better matching points
|
||||
// // var goodMatches = new List<DMatch>();
|
||||
// for (int i = 0; i < knnMatches.Length; i++)
|
||||
// {
|
||||
// var best = knnMatches[i][0];
|
||||
// var better = knnMatches[i][1];
|
||||
// var r = best.Distance / better.Distance;
|
||||
// if (r > minRatio)
|
||||
// {
|
||||
// pointsSrc.Add(keyPointsSrc[best.QueryIdx].Pt);
|
||||
// pointsDst.Add(_trainKeyPoints[best.TrainIdx].Pt);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (pointsSrc.Count < 7)
|
||||
// {
|
||||
// Debug.WriteLine("匹配点过少");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// speedTimer.Record("FlannMatch.KnnMatch");
|
||||
//
|
||||
// // var outMat = new Mat();
|
||||
//
|
||||
// // algorithm RANSAC Filter the matched results
|
||||
// var pSrc = pointsSrc.ToPoint2d();
|
||||
// var pDst = pointsDst.ToPoint2d();
|
||||
// var outMask = new Mat();
|
||||
// // If the original matching result is null, Skip the filtering step
|
||||
// if (pSrc.Count > 0 && pDst.Count > 0)
|
||||
// {
|
||||
// var hMat = Cv2.FindHomography(pSrc, pDst, HomographyMethods.Ransac, mask: outMask);
|
||||
// speedTimer.Record("FindHomography");
|
||||
//
|
||||
// var objCorners = new Point2f[4];
|
||||
// objCorners[0] = new Point2f(0, 0);
|
||||
// objCorners[1] = new Point2f(0, matSrc.Rows);
|
||||
// objCorners[2] = new Point2f(matSrc.Cols, matSrc.Rows);
|
||||
// objCorners[3] = new Point2f(matSrc.Cols, 0);
|
||||
//
|
||||
// var sceneCorners = Cv2.PerspectiveTransform(objCorners, hMat);
|
||||
// speedTimer.Record("PerspectiveTransform");
|
||||
// speedTimer.DebugPrint();
|
||||
// return sceneCorners;
|
||||
// }
|
||||
//
|
||||
// speedTimer.DebugPrint();
|
||||
// return null;
|
||||
// }
|
||||
#endregion 普通匹配
|
||||
|
||||
#region Knn匹配
|
||||
|
||||
public Point2f KnnMatch(Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
return KnnMatch(_trainKeyPoints, _trainDescriptors, queryMat, queryMatMask, matcherType);
|
||||
}
|
||||
|
||||
public Point2f KnnMatch(Mat queryMat, float prevX, float prevY, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
var (cellRow, cellCol) = KeyPointFeatureBlockHelper.GetCellIndex(_trainMatSize, _splitRow, _splitCol, prevX, prevY);
|
||||
Debug.WriteLine($"当前坐标({prevX},{prevY})在特征块({cellRow},{cellCol})中");
|
||||
if (_lastMergedBlock == null || _lastMergedBlock.MergedCenterCellRow != cellRow || _lastMergedBlock.MergedCenterCellCol != cellCol)
|
||||
{
|
||||
Debug.WriteLine($"---------切换到新的特征块({cellRow},{cellCol}),合并特征点--------");
|
||||
_lastMergedBlock = KeyPointFeatureBlockHelper.MergeNeighboringFeatures(_blocks, _trainDescriptors, cellRow, cellCol);
|
||||
}
|
||||
|
||||
return KnnMatch(_lastMergedBlock.KeyPointArray, _lastMergedBlock.Descriptor!, queryMat, queryMatMask, matcherType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// https://github.com/tignioj/minimap/blob/main/matchmap/sifttest/sifttest5.py
|
||||
/// Copilot 生成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private Point2f? KnnMatch(KeyPoint[] trainKeyPoints, Mat trainRet, Mat queryMat, Mat? queryMatMask = null)
|
||||
private Point2f KnnMatch(KeyPoint[] trainKeyPoints, Mat trainDescriptors, Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
SpeedTimer speedTimer = new();
|
||||
using var queryDescriptors = new Mat();
|
||||
#pragma warning disable CS8604 // 引用类型参数可能为 null。
|
||||
_feature2D.DetectAndCompute(queryMat, queryMatMask, out var queryKeyPoints, queryDescriptors);
|
||||
#pragma warning restore CS8604 // 引用类型参数可能为 null。
|
||||
var matches = flnMatcher.KnnMatch(queryDescriptors, _trainDescriptors, k: 2);
|
||||
speedTimer.Record("模板生成KeyPoint");
|
||||
var matches = GetMatcher(matcherType).KnnMatch(queryDescriptors, trainDescriptors, k: 2);
|
||||
speedTimer.Record("FlannMatch");
|
||||
|
||||
// 应用比例测试来过滤匹配点
|
||||
List<DMatch> goodMatches = [];
|
||||
@@ -426,29 +394,101 @@ public class FeatureMatcher
|
||||
|
||||
if (goodMatches.Count < 7)
|
||||
{
|
||||
return null;
|
||||
return new Point2f();
|
||||
}
|
||||
|
||||
// 获取匹配点的坐标
|
||||
var srcPts = goodMatches.Select(m => queryKeyPoints[m.QueryIdx].Pt).ToArray();
|
||||
var dstPts = goodMatches.Select(m => _trainKeyPoints[m.TrainIdx].Pt).ToArray();
|
||||
var dstPts = goodMatches.Select(m => trainKeyPoints[m.TrainIdx].Pt).ToArray();
|
||||
|
||||
speedTimer.Record("GetGoodMatchPoints");
|
||||
|
||||
// 使用RANSAC找到变换矩阵
|
||||
var mask = new Mat();
|
||||
var M = Cv2.FindHomography(srcPts.ToList().ToPoint2d(), dstPts.ToList().ToPoint2d(), HomographyMethods.Ransac, 3.0, mask);
|
||||
if (M.Empty())
|
||||
var hMat = Cv2.FindHomography(srcPts.ToList().ToPoint2d(), dstPts.ToList().ToPoint2d(), HomographyMethods.Ransac, 3.0, mask);
|
||||
if (hMat.Empty())
|
||||
{
|
||||
return null;
|
||||
return new Point2f();
|
||||
}
|
||||
speedTimer.Record("FindHomography");
|
||||
|
||||
// 计算小地图的中心点
|
||||
var h = queryMat.Rows;
|
||||
var w = queryMat.Cols;
|
||||
var centerPoint = new Point2f(w / 2f, h / 2f);
|
||||
Point2f[] centerPoints = [centerPoint];
|
||||
Point2f[] transformedCenter = Cv2.PerspectiveTransform(centerPoints, M);
|
||||
Point2f[] transformedCenter = Cv2.PerspectiveTransform(centerPoints, hMat);
|
||||
|
||||
speedTimer.Record("PerspectiveTransform");
|
||||
speedTimer.DebugPrint();
|
||||
// 返回小地图在大地图中的中心坐标
|
||||
return transformedCenter[0];
|
||||
}
|
||||
|
||||
public Point2f[] KnnMatchCorners(KeyPoint[] trainKeyPoints, Mat trainDescriptors, Mat queryMat, Mat? queryMatMask = null,
|
||||
DescriptorMatcherType matcherType = DescriptorMatcherType.FlannBased)
|
||||
{
|
||||
SpeedTimer speedTimer = new();
|
||||
using var queryDescriptors = new Mat();
|
||||
#pragma warning disable CS8604 // 引用类型参数可能为 null。
|
||||
_feature2D.DetectAndCompute(queryMat, queryMatMask, out var queryKeyPoints, queryDescriptors);
|
||||
#pragma warning restore CS8604 // 引用类型参数可能为 null。
|
||||
speedTimer.Record("模板生成KeyPoint");
|
||||
var matches = GetMatcher(matcherType).KnnMatch(queryDescriptors, trainDescriptors, k: 2);
|
||||
speedTimer.Record("FlannMatch");
|
||||
|
||||
// 应用比例测试来过滤匹配点
|
||||
List<DMatch> goodMatches = [];
|
||||
foreach (var match in matches)
|
||||
{
|
||||
if (match.Length == 2 && match[0].Distance < 0.75 * match[1].Distance)
|
||||
{
|
||||
goodMatches.Add(match[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (goodMatches.Count < 7)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
// 获取匹配点的坐标
|
||||
var srcPts = goodMatches.Select(m => queryKeyPoints[m.QueryIdx].Pt).ToArray();
|
||||
var dstPts = goodMatches.Select(m => trainKeyPoints[m.TrainIdx].Pt).ToArray();
|
||||
|
||||
speedTimer.Record("GetGoodMatchPoints");
|
||||
|
||||
// 使用RANSAC找到变换矩阵
|
||||
var mask = new Mat();
|
||||
var hMat = Cv2.FindHomography(srcPts.ToList().ToPoint2d(), dstPts.ToList().ToPoint2d(), HomographyMethods.Ransac, 3.0, mask);
|
||||
if (hMat.Empty())
|
||||
{
|
||||
return [];
|
||||
}
|
||||
speedTimer.Record("FindHomography");
|
||||
|
||||
// 返回四个角点
|
||||
var objCorners = new Point2f[4];
|
||||
objCorners[0] = new Point2f(0, 0);
|
||||
objCorners[1] = new Point2f(0, queryMat.Rows);
|
||||
objCorners[2] = new Point2f(queryMat.Cols, queryMat.Rows);
|
||||
objCorners[3] = new Point2f(queryMat.Cols, 0);
|
||||
|
||||
var sceneCorners = Cv2.PerspectiveTransform(objCorners, hMat);
|
||||
speedTimer.Record("PerspectiveTransform");
|
||||
speedTimer.DebugPrint();
|
||||
return sceneCorners;
|
||||
}
|
||||
|
||||
public Rect KnnMatchRect(Mat queryMat, Mat? queryMatMask = null)
|
||||
{
|
||||
var corners = KnnMatchCorners(_trainKeyPoints, _trainDescriptors, queryMat, queryMatMask);
|
||||
if (corners.Length == 0)
|
||||
{
|
||||
return Rect.Empty;
|
||||
}
|
||||
return Cv2.BoundingRect(corners);
|
||||
}
|
||||
|
||||
#endregion Knn匹配
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace BetterGenshinImpact.Core.Recognition.OpenCv.FeatureMatch;
|
||||
|
||||
public class FeatureStorage(string name)
|
||||
{
|
||||
private readonly string rootPath = Global.Absolute(@"User\Map\");
|
||||
private readonly string rootPath = Global.Absolute(@"Assets\Map\");
|
||||
|
||||
public void SetType(Feature2DType type)
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recorder;
|
||||
|
||||
@@ -39,13 +40,13 @@ public class GlobalKeyMouseRecord : Singleton<GlobalKeyMouseRecord>
|
||||
{
|
||||
if (!TaskContext.Instance().IsInitialized)
|
||||
{
|
||||
MessageBox.Show("请先在启动页,启动截图器再使用本功能");
|
||||
Toast.Warning("请先在启动页,启动截图器再使用本功能");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Status != KeyMouseRecorderStatus.Stop)
|
||||
{
|
||||
MessageBox.Show("已经在录制状态,请不要重复启动录制功能");
|
||||
Toast.Warning("已经在录制状态,请不要重复启动录制功能");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Vanara.PInvoke;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Recorder;
|
||||
|
||||
@@ -22,12 +23,12 @@ public class KeyMouseMacroPlayer
|
||||
{
|
||||
if (!TaskContext.Instance().IsInitialized)
|
||||
{
|
||||
MessageBox.Show("请先在启动页,启动截图器再使用本功能");
|
||||
Toast.Warning("请先在启动页,启动截图器再使用本功能");
|
||||
return;
|
||||
}
|
||||
|
||||
var script = JsonSerializer.Deserialize<KeyMouseScript>(macro, KeyMouseRecorder.JsonOptions) ?? throw new Exception("Failed to deserialize macro");
|
||||
script.Adapt(TaskContext.Instance().SystemInfo.CaptureAreaRect);
|
||||
script.Adapt(TaskContext.Instance().SystemInfo.CaptureAreaRect, TaskContext.Instance().DpiScale);
|
||||
SystemControl.ActivateWindow();
|
||||
|
||||
if (withDelay)
|
||||
@@ -50,6 +51,11 @@ public class KeyMouseMacroPlayer
|
||||
var startTime = DateTime.UtcNow;
|
||||
foreach (var e in macroEvents)
|
||||
{
|
||||
if (ct.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var timeToWait = (int)(e.Time - (DateTime.UtcNow - startTime).TotalMilliseconds);
|
||||
if (timeToWait < 0)
|
||||
{
|
||||
|
||||
@@ -97,7 +97,8 @@ public class KeyMouseRecorder
|
||||
X = rect.X,
|
||||
Y = rect.Y,
|
||||
Width = rect.Width,
|
||||
Height = rect.Height
|
||||
Height = rect.Height,
|
||||
RecordDpi = TaskContext.Instance().DpiScale
|
||||
}
|
||||
};
|
||||
return JsonSerializer.Serialize(keyMouseScript, JsonOptions);
|
||||
|
||||
@@ -14,24 +14,28 @@ public class KeyMouseScript
|
||||
/// <summary>
|
||||
/// 转换原始脚本为适应当前分辨率的脚本
|
||||
/// </summary>
|
||||
/// <param name="captureRect"></param>
|
||||
public void Adapt(RECT captureRect)
|
||||
public void Adapt(RECT captureRect, double dpiScale)
|
||||
{
|
||||
foreach (var macroEvent in MacroEvents)
|
||||
{
|
||||
if (Info == null || Info.Width == 0 || Info.Height == 0)
|
||||
{
|
||||
Debug.WriteLine("错误的脚本数据 Info.Width == 0 || Info.Height == 0");
|
||||
break;
|
||||
}
|
||||
|
||||
if (macroEvent.Type == MacroEventType.MouseMoveTo
|
||||
|| macroEvent.Type == MacroEventType.MouseDown
|
||||
|| macroEvent.Type == MacroEventType.MouseUp)
|
||||
{
|
||||
if (Info == null || Info.Width == 0 || Info.Height == 0)
|
||||
{
|
||||
Debug.WriteLine("错误的脚本数据 Info.Width == 0 || Info.Height == 0");
|
||||
break;
|
||||
}
|
||||
|
||||
macroEvent.MouseX = (int)(captureRect.X + (macroEvent.MouseX - Info.X) * captureRect.Width * 1d / Info.Width);
|
||||
macroEvent.MouseY = (int)(captureRect.Y + (macroEvent.MouseY - Info.Y) * captureRect.Height * 1d / Info.Height);
|
||||
}
|
||||
else if (macroEvent.Type == MacroEventType.MouseMoveBy)
|
||||
{
|
||||
macroEvent.MouseX = (int)Math.Round(macroEvent.MouseX / Info.RecordDpi * dpiScale, 0);
|
||||
macroEvent.MouseY = (int)Math.Round(macroEvent.MouseY / Info.RecordDpi * dpiScale, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,19 @@ public class KeyMouseScriptInfo
|
||||
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public string? Author { get; set; }
|
||||
|
||||
public string? Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 制作时 BetterGI 的版本,用于兼容性检查
|
||||
/// </summary>
|
||||
public string? BgiVersion { get; set; }
|
||||
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int Height { get; set; }
|
||||
|
||||
public double RecordDpi { get; set; } = 1.0;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using BetterGenshinImpact.GameTask.AutoPathing;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
public class AutoPathingScript(string rootPath)
|
||||
{
|
||||
public async Task Run(string json)
|
||||
{
|
||||
var task = PathingTask.BuildFromJson(json);
|
||||
await new PathExecutor(CancellationContext.Instance.Cts.Token).Pathing(task);
|
||||
}
|
||||
|
||||
public async Task RunFile(string path)
|
||||
{
|
||||
var json = await new LimitedFile(rootPath).ReadText(path);
|
||||
await Run(json);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,13 @@
|
||||
using BetterGenshinImpact.Core.Script.Dependence.Model;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoDomain;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.AutoWood;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
@@ -10,6 +17,11 @@ public class Dispatcher
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加实时任务
|
||||
/// </summary>
|
||||
/// <param name="timer">实时任务触发器</param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public void AddTimer(RealtimeTimer timer)
|
||||
{
|
||||
var realtimeTimer = timer;
|
||||
@@ -24,4 +36,74 @@ public class Dispatcher
|
||||
|
||||
TaskTriggerDispatcher.Instance().AddTrigger(realtimeTimer.Name, realtimeTimer.Config);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运行独立任务
|
||||
/// </summary>
|
||||
/// <param name="soloTask">
|
||||
/// 支持的任务名称:
|
||||
/// - AutoGeniusInvokation: 启动自动七圣召唤任务
|
||||
/// - AutoWood: 启动自动伐木任务
|
||||
/// - AutoFight: 启动自动战斗任务
|
||||
/// - AutoDomain: 启动自动秘境任务
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public async Task RunTask(SoloTask soloTask)
|
||||
{
|
||||
if (soloTask == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(soloTask), "独立任务对象不能为空");
|
||||
}
|
||||
var taskSettingsPageViewModel = App.GetService<TaskSettingsPageViewModel>();
|
||||
if (taskSettingsPageViewModel == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(taskSettingsPageViewModel), "内部视图模型对象为空");
|
||||
}
|
||||
|
||||
// 根据名称执行任务
|
||||
switch (soloTask.Name)
|
||||
{
|
||||
case "AutoGeniusInvokation":
|
||||
if (taskSettingsPageViewModel.GetTcgStrategy(out var content))
|
||||
{
|
||||
return;
|
||||
}
|
||||
await new AutoGeniusInvokationTask(new GeniusInvokationTaskParam(content)).Start(CancellationContext.Instance.Cts.Token);
|
||||
break;
|
||||
|
||||
case "AutoWood":
|
||||
await new AutoWoodTask(new WoodTaskParam(taskSettingsPageViewModel.AutoWoodRoundNum, taskSettingsPageViewModel.AutoWoodDailyMaxCount)).Start(CancellationContext.Instance.Cts.Token);
|
||||
break;
|
||||
|
||||
case "AutoFight":
|
||||
if (taskSettingsPageViewModel.GetFightStrategy(out var path1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var autoFightConfig = TaskContext.Instance().Config.AutoFightConfig;
|
||||
var param = new AutoFightParam(path1)
|
||||
{
|
||||
FightFinishDetectEnabled = autoFightConfig.FightFinishDetectEnabled,
|
||||
PickDropsAfterFightEnabled = autoFightConfig.PickDropsAfterFightEnabled
|
||||
};
|
||||
await new AutoFightTask(param).Start(CancellationContext.Instance.Cts.Token);
|
||||
break;
|
||||
|
||||
case "AutoDomain":
|
||||
if (taskSettingsPageViewModel.GetFightStrategy(out var path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
await new AutoDomainTask(new AutoDomainParam(0, path)).Start(CancellationContext.Instance.Cts.Token);
|
||||
break;
|
||||
|
||||
// case "AutoMusicGame":
|
||||
// taskSettingsPageViewModel.SwitchAutoMusicGameCommand.Execute(null);
|
||||
// break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException($"未知的任务名称: {soloTask.Name}", nameof(soloTask.Name));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,78 @@
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.Common.Job;
|
||||
using Vanara.PInvoke;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
public class Genshin
|
||||
{
|
||||
private RECT captureAreaRect = TaskContext.Instance().SystemInfo.CaptureAreaRect;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏宽度
|
||||
/// </summary>
|
||||
public int Width => captureAreaRect.Width;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏高度
|
||||
/// </summary>
|
||||
public int Height => captureAreaRect.Height;
|
||||
|
||||
/// <summary>
|
||||
/// 游戏窗口大小相比1080P的缩放比例
|
||||
/// </summary>
|
||||
public double ScaleTo1080PRatio { get; } = TaskContext.Instance().SystemInfo.ScaleTo1080PRatio;
|
||||
|
||||
/// <summary>
|
||||
/// 系统屏幕的DPI缩放比例
|
||||
/// </summary>
|
||||
public double ScreenDpiScale => TaskContext.Instance().DpiScale;
|
||||
|
||||
/// <summary>
|
||||
/// 传送到指定位置
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Tp(double x, double y)
|
||||
{
|
||||
await new TpTask(CancellationContext.Instance.Cts).Tp(x, y);
|
||||
await new TpTask(CancellationContext.Instance.Cts.Token).Tp(x, y);
|
||||
}
|
||||
|
||||
public async Task Tp(double x, double y, bool force)
|
||||
{
|
||||
await new TpTask(CancellationContext.Instance.Cts.Token).Tp(x, y, force);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 传送到指定位置
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns></returns>
|
||||
public async Task Tp(string x, string y)
|
||||
{
|
||||
double.TryParse(x, out var dx);
|
||||
double.TryParse(y, out var dy);
|
||||
await Tp(dx, dy);
|
||||
}
|
||||
|
||||
public async Task Tp(string x, string y, bool force)
|
||||
{
|
||||
double.TryParse(x, out var dx);
|
||||
double.TryParse(y, out var dy);
|
||||
await Tp(dx, dy, force);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换队伍
|
||||
/// </summary>
|
||||
/// <param name="partyName">队伍界面自定义的队伍名称</param>
|
||||
/// <returns></returns>
|
||||
public async Task SwitchParty(string partyName)
|
||||
{
|
||||
await new SwitchPartyTask().Start(partyName, CancellationContext.Instance.Cts.Token);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,11 @@
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Vanara.PInvoke;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence;
|
||||
|
||||
@@ -8,4 +15,138 @@ public class GlobalMethod
|
||||
{
|
||||
await Task.Delay(millisecondsTimeout, CancellationContext.Instance.Cts.Token);
|
||||
}
|
||||
|
||||
#region 键盘操作
|
||||
|
||||
public static void KeyDown(string key)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(ToVk(key));
|
||||
}
|
||||
|
||||
public static void KeyUp(string key)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyUp(ToVk(key));
|
||||
}
|
||||
|
||||
public static void KeyPress(string key)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyPress(ToVk(key));
|
||||
}
|
||||
|
||||
private static User32.VK ToVk(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return User32Helper.ToVk(key);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new ArgumentException($"键盘编码必须是VirtualKeyCodes枚举中的值,当前传入的 {key} 不合法");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 键盘操作
|
||||
|
||||
#region 鼠标操作
|
||||
|
||||
private static int _gameWidth = 1920;
|
||||
private static int _gameHeight = 1080;
|
||||
private static double _dpi = 1;
|
||||
|
||||
public static void SetGameMetrics(int width, int height, double dpi = 1)
|
||||
{
|
||||
// 必须16:9 的分辨率
|
||||
if (width * 9 != height * 16)
|
||||
{
|
||||
throw new ArgumentException("游戏分辨率必须是16:9的分辨率");
|
||||
}
|
||||
|
||||
_gameWidth = width;
|
||||
_gameHeight = height;
|
||||
_dpi = dpi;
|
||||
}
|
||||
|
||||
public static void MoveMouseBy(int x, int y)
|
||||
{
|
||||
var realDpi = TaskContext.Instance().DpiScale;
|
||||
x = (int)(x * realDpi / _dpi);
|
||||
y = (int)(y * realDpi / _dpi);
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(x, y);
|
||||
}
|
||||
|
||||
public static void MoveMouseTo(int x, int y)
|
||||
{
|
||||
if (x < 0 || x > _gameWidth || y < 0 || y > _gameHeight)
|
||||
{
|
||||
throw new ArgumentException("鼠标坐标超出游戏窗口范围");
|
||||
}
|
||||
|
||||
GameCaptureRegion.GameRegionMove((size, s2) =>
|
||||
{
|
||||
var scale = 1920.0 / _gameWidth;
|
||||
return (x * scale * s2, y * scale * s2);
|
||||
});
|
||||
}
|
||||
|
||||
public static void Click(int x, int y)
|
||||
{
|
||||
MoveMouseTo(x, y);
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
}
|
||||
|
||||
public static void LeftButtonClick()
|
||||
{
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
}
|
||||
|
||||
public static void LeftButtonDown()
|
||||
{
|
||||
Simulation.SendInput.Mouse.LeftButtonDown();
|
||||
}
|
||||
|
||||
public static void LeftButtonUp()
|
||||
{
|
||||
Simulation.SendInput.Mouse.LeftButtonUp();
|
||||
}
|
||||
|
||||
public static void RightButtonClick()
|
||||
{
|
||||
Simulation.SendInput.Mouse.RightButtonClick();
|
||||
}
|
||||
|
||||
public static void RightButtonDown()
|
||||
{
|
||||
Simulation.SendInput.Mouse.RightButtonDown();
|
||||
}
|
||||
|
||||
public static void RightButtonUp()
|
||||
{
|
||||
Simulation.SendInput.Mouse.RightButtonUp();
|
||||
}
|
||||
|
||||
public static void MiddleButtonClick()
|
||||
{
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
}
|
||||
|
||||
public static void MiddleButtonDown()
|
||||
{
|
||||
Simulation.SendInput.Mouse.MiddleButtonDown();
|
||||
}
|
||||
|
||||
public static void MiddleButtonUp()
|
||||
{
|
||||
Simulation.SendInput.Mouse.MiddleButtonUp();
|
||||
}
|
||||
|
||||
#endregion 鼠标操作
|
||||
|
||||
#region 识图操作
|
||||
|
||||
public static ImageRegion CaptureGameRegion()
|
||||
{
|
||||
return TaskControl.CaptureToRectArea();
|
||||
}
|
||||
|
||||
#endregion 识图操作
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence.Model;
|
||||
using BetterGenshinImpact.Core.Script.Dependence.Model.TimerConfig;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence.Model;
|
||||
|
||||
/// <summary>
|
||||
/// 实时任务计时器
|
||||
/// 实时任务触发器
|
||||
/// </summary>
|
||||
public class RealtimeTimer
|
||||
{
|
||||
@@ -29,4 +32,13 @@ public class RealtimeTimer
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public RealtimeTimer(string name, dynamic config)
|
||||
{
|
||||
Name = name;
|
||||
if (Name == "AutoPick")
|
||||
{
|
||||
Config = ScriptObjectConverter.ConvertTo<AutoPickExternalConfig>(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence.Model;
|
||||
|
||||
/// <summary>
|
||||
/// 独立任务
|
||||
/// </summary>
|
||||
public class SoloTask
|
||||
{
|
||||
/// <summary>
|
||||
/// 独立任务名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 独立任务配置
|
||||
/// </summary>
|
||||
public object? Config;
|
||||
|
||||
public SoloTask(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public SoloTask(string name, dynamic config)
|
||||
{
|
||||
Name = name;
|
||||
// if (Name == "AutoPick")
|
||||
// {
|
||||
// Config = ScriptObjectConverter.ConvertTo<AutoPickExternalConfig>(config);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using System;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using Vanara.PInvoke;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Dependence.Simulator;
|
||||
|
||||
public class PostMessage
|
||||
{
|
||||
private readonly PostMessageSimulator _postMessageSimulator = TaskContext.Instance().PostMessageSimulator;
|
||||
|
||||
public void KeyDown(string key)
|
||||
{
|
||||
_postMessageSimulator.KeyDownBackground(ToVk(key));
|
||||
}
|
||||
|
||||
public void KeyUp(string key)
|
||||
{
|
||||
_postMessageSimulator.KeyUpBackground(ToVk(key));
|
||||
}
|
||||
|
||||
public void KeyPress(string key)
|
||||
{
|
||||
_postMessageSimulator.KeyPressBackground(ToVk(key));
|
||||
}
|
||||
|
||||
public void Click()
|
||||
{
|
||||
_postMessageSimulator.LeftButtonClick();
|
||||
}
|
||||
|
||||
private static User32.VK ToVk(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return User32Helper.ToVk(key);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new ArgumentException($"键盘编码必须是VirtualKeyCodes枚举中的值,当前传入的 {key} 不合法");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,51 @@
|
||||
using BetterGenshinImpact.Core.Script.Dependence;
|
||||
using BetterGenshinImpact.Core.Script.Dependence.Model;
|
||||
using Microsoft.ClearScript;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using OpenCvSharp;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script;
|
||||
|
||||
public class EngineExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// !!! 注意:这个方法会添加一些全局方法和对象,不要随便添加,以免安全风险!!!
|
||||
/// </summary>
|
||||
/// <param name="engine"></param>
|
||||
/// <param name="workDir"></param>
|
||||
/// <param name="searchPaths"></param>
|
||||
public static void InitHost(IScriptEngine engine, string workDir, string[]? searchPaths = null)
|
||||
{
|
||||
// engine.AddHostObject("xHost", new ExtendedHostFunctions()); // 有越权的安全风险
|
||||
|
||||
// 添加我的自定义实例化对象
|
||||
engine.AddHostObject("keyMouseScript", new KeyMouseScript(workDir));
|
||||
engine.AddHostObject("pathingScript", new AutoPathingScript(workDir));
|
||||
engine.AddHostObject("genshin", new Dependence.Genshin());
|
||||
engine.AddHostObject("log", new Log());
|
||||
engine.AddHostObject("file", new LimitedFile(workDir)); // 限制文件访问
|
||||
|
||||
// 实时任务调度器
|
||||
// 任务调度器
|
||||
engine.AddHostObject("dispatcher", new Dispatcher());
|
||||
engine.AddHostType("RealtimeTimer", typeof(RealtimeTimer));
|
||||
engine.AddHostType("SoloTask", typeof(SoloTask));
|
||||
|
||||
// PostMessage 作为类型实例化
|
||||
engine.AddHostType("PostMessage", typeof(Dependence.Simulator.PostMessage));
|
||||
|
||||
// 直接添加方法
|
||||
#pragma warning disable CS8974 // Converting method group to non-delegate type
|
||||
engine.AddHostObject("sleep", GlobalMethod.Sleep);
|
||||
#pragma warning restore CS8974 // Converting method group to non-delegate type
|
||||
AddAllGlobalMethod(engine);
|
||||
|
||||
// 识图模块相关
|
||||
engine.AddHostType("Mat", typeof(Mat));
|
||||
engine.AddHostType("RecognitionObject", typeof(RecognitionObject));
|
||||
engine.AddHostType("DesktopRegion", typeof(DesktopRegion));
|
||||
engine.AddHostType("GameCaptureRegion", typeof(GameCaptureRegion));
|
||||
engine.AddHostType("ImageRegion", typeof(ImageRegion));
|
||||
engine.AddHostType("Region", typeof(Region));
|
||||
|
||||
// 添加C#的类型
|
||||
engine.AddHostType(typeof(Task));
|
||||
@@ -38,4 +59,38 @@ public class EngineExtend
|
||||
engine.DocumentSettings.SearchPath = string.Join(';', searchPaths);
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddAllGlobalMethod(IScriptEngine engine)
|
||||
{
|
||||
// // 获取GlobalMethod类的所有静态方法
|
||||
// var methods = typeof(GlobalMethod).GetMethods(BindingFlags.Static | BindingFlags.Public);
|
||||
//
|
||||
// foreach (var method in methods)
|
||||
// {
|
||||
// // 使用方法名首字母小写作为HostObject的名称
|
||||
// var methodName = char.ToLowerInvariant(method.Name[0]) + method.Name[1..];
|
||||
// engine.AddHostObject(methodName, method);
|
||||
// }
|
||||
|
||||
#pragma warning disable CS8974 // Converting method group to non-delegate type
|
||||
engine.AddHostObject("sleep", GlobalMethod.Sleep);
|
||||
engine.AddHostObject("keyDown", GlobalMethod.KeyDown);
|
||||
engine.AddHostObject("keyUp", GlobalMethod.KeyUp);
|
||||
engine.AddHostObject("keyPress", GlobalMethod.KeyPress);
|
||||
engine.AddHostObject("setGameMetrics", GlobalMethod.SetGameMetrics);
|
||||
engine.AddHostObject("moveMouseBy", GlobalMethod.MoveMouseBy);
|
||||
engine.AddHostObject("moveMouseTo", GlobalMethod.MoveMouseTo);
|
||||
engine.AddHostObject("click", GlobalMethod.Click);
|
||||
engine.AddHostObject("leftButtonClick", GlobalMethod.LeftButtonClick);
|
||||
engine.AddHostObject("leftButtonDown", GlobalMethod.LeftButtonDown);
|
||||
engine.AddHostObject("leftButtonUp", GlobalMethod.LeftButtonUp);
|
||||
engine.AddHostObject("rightButtonClick", GlobalMethod.RightButtonClick);
|
||||
engine.AddHostObject("rightButtonDown", GlobalMethod.RightButtonDown);
|
||||
engine.AddHostObject("rightButtonUp", GlobalMethod.RightButtonUp);
|
||||
engine.AddHostObject("middleButtonClick", GlobalMethod.MiddleButtonClick);
|
||||
engine.AddHostObject("middleButtonDown", GlobalMethod.MiddleButtonDown);
|
||||
engine.AddHostObject("middleButtonUp", GlobalMethod.MiddleButtonUp);
|
||||
engine.AddHostObject("captureGameRegion", GlobalMethod.CaptureGameRegion);
|
||||
#pragma warning restore CS8974 // Converting method group to non-delegate type
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
using BetterGenshinImpact.Service;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Group;
|
||||
|
||||
/// <summary>
|
||||
/// 调度器 配置组
|
||||
/// </summary>
|
||||
public partial class ScriptGroup : ObservableObject
|
||||
{
|
||||
public int Index { get; set; }
|
||||
@@ -14,6 +18,9 @@ public partial class ScriptGroup : ObservableObject
|
||||
[ObservableProperty]
|
||||
private string _name = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private ScriptGroupConfig _config = new();
|
||||
|
||||
[ObservableProperty]
|
||||
private ObservableCollection<ScriptGroupProject> _projects = [];
|
||||
|
||||
@@ -34,6 +41,22 @@ public partial class ScriptGroup : ObservableObject
|
||||
|
||||
public static ScriptGroup FromJson(string json)
|
||||
{
|
||||
return JsonSerializer.Deserialize<ScriptGroup>(json, ConfigService.JsonOptions) ?? throw new Exception("解析脚本组JSON配置失败");
|
||||
var group = Newtonsoft.Json.JsonConvert.DeserializeObject<ScriptGroup>(json) ?? throw new Exception("解析配置组JSON配置失败");
|
||||
ResetGroupInfo(group);
|
||||
return group;
|
||||
}
|
||||
|
||||
public static void ResetGroupInfo(ScriptGroup group)
|
||||
{
|
||||
foreach (var project in group.Projects)
|
||||
{
|
||||
project.GroupInfo = group;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddProject(ScriptGroupProject project)
|
||||
{
|
||||
project.GroupInfo = this;
|
||||
Projects.Add(project);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Group;
|
||||
|
||||
[Serializable]
|
||||
public partial class ScriptGroupConfig : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private PathingPartyConfig _pathingConfig = new();
|
||||
}
|
||||
@@ -1,8 +1,17 @@
|
||||
using BetterGenshinImpact.Core.Script.Project;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Recorder;
|
||||
using BetterGenshinImpact.Core.Script.Project;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing.Model;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.IO;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Group;
|
||||
|
||||
@@ -11,12 +20,26 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
[ObservableProperty]
|
||||
private int _index;
|
||||
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 理论上是文件名
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 理论上是当前类型脚本根目录到脚本文件所在目录的相对路径
|
||||
/// 但是:
|
||||
/// 1. JS 脚本的文件名是内部的名称,文件夹名脚本所在文件夹,这个也是唯一标识
|
||||
/// 2. KeyMouse 脚本的文件名和文件夹名相同,文件夹名暂时无意义
|
||||
/// 3. Pathing 文件名就是实际脚本的文件名,文件夹名是脚本所在的相对目录
|
||||
/// </summary>
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
|
||||
[ObservableProperty]
|
||||
private string _type = string.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
public string TypeDesc => ScriptGroupProjectExtensions.TypeDescriptions[Type];
|
||||
|
||||
[ObservableProperty]
|
||||
private string _status = string.Empty;
|
||||
|
||||
@@ -27,26 +50,64 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
/// 执行周期
|
||||
/// 不在 ScheduleDescriptions 中则会被视为自定义Cron表达式
|
||||
/// </summary>
|
||||
public string Schedule { get; set; } = string.Empty;
|
||||
[ObservableProperty]
|
||||
private string _schedule = string.Empty;
|
||||
|
||||
[JsonIgnore]
|
||||
public string ScheduleDesc => ScriptGroupProjectExtensions.ScheduleDescriptions.GetValueOrDefault(Schedule, "自定义周期");
|
||||
|
||||
[ObservableProperty]
|
||||
private int _runNum = 1;
|
||||
|
||||
[JsonIgnore]
|
||||
public ScriptProject? Project { get; set; }
|
||||
|
||||
public ExpandoObject? JsScriptSettingsObject { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属配置组
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public ScriptGroup? GroupInfo { get; set; }
|
||||
|
||||
public ScriptGroupProject()
|
||||
{
|
||||
}
|
||||
|
||||
public ScriptGroupProject(ScriptProject project)
|
||||
{
|
||||
Id = project.Manifest.Id;
|
||||
Name = project.Manifest.Name;
|
||||
FolderName = project.FolderName;
|
||||
Status = "Enabled";
|
||||
Schedule = "Daily";
|
||||
Project = project;
|
||||
Type = "Javascript";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="folder"></param>
|
||||
/// <param name="type">KeyMouse|Pathing</param>
|
||||
public ScriptGroupProject(string name, string folder, string type)
|
||||
{
|
||||
Name = name;
|
||||
FolderName = folder;
|
||||
Status = "Enabled";
|
||||
Schedule = "Daily";
|
||||
Project = null; // 不是JS脚本
|
||||
Type = type;
|
||||
}
|
||||
|
||||
public static ScriptGroupProject BuildKeyMouseProject(string name)
|
||||
{
|
||||
return new ScriptGroupProject(name, name, "KeyMouse");
|
||||
}
|
||||
|
||||
public static ScriptGroupProject BuildPathingProject(string name, string folder)
|
||||
{
|
||||
return new ScriptGroupProject(name, folder, "Pathing");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -60,16 +121,74 @@ public partial class ScriptGroupProject : ObservableObject
|
||||
}
|
||||
Project = new ScriptProject(FolderName);
|
||||
}
|
||||
|
||||
public async Task Run()
|
||||
{
|
||||
if (Type == "Javascript")
|
||||
{
|
||||
if (Project == null)
|
||||
{
|
||||
throw new Exception("JS脚本未初始化");
|
||||
}
|
||||
await Project.ExecuteAsync(JsScriptSettingsObject);
|
||||
}
|
||||
if (Type == "KeyMouse")
|
||||
{
|
||||
// 加载并执行
|
||||
var json = await File.ReadAllTextAsync(Global.Absolute(@$"User\KeyMouseScript\{Name}"));
|
||||
await KeyMouseMacroPlayer.PlayMacro(json, CancellationContext.Instance.Cts.Token, false);
|
||||
}
|
||||
if (Type == "Pathing")
|
||||
{
|
||||
// 加载并执行
|
||||
var task = PathingTask.BuildFromFilePath(Path.Combine(MapPathingViewModel.PathJsonPath, FolderName, Name));
|
||||
TaskTriggerDispatcher.Instance().AddTrigger("AutoPick", null);
|
||||
var pathingTask = new PathExecutor(CancellationContext.Instance.Cts.Token);
|
||||
pathingTask.PartyConfig = GroupInfo?.Config.PathingConfig;
|
||||
await pathingTask.Pathing(task);
|
||||
}
|
||||
else
|
||||
{
|
||||
//throw new Exception("不支持的脚本类型");
|
||||
}
|
||||
}
|
||||
|
||||
partial void OnTypeChanged(string value)
|
||||
{
|
||||
OnPropertyChanged(nameof(TypeDesc));
|
||||
}
|
||||
|
||||
partial void OnStatusChanged(string value)
|
||||
{
|
||||
OnPropertyChanged(nameof(StatusDesc));
|
||||
}
|
||||
|
||||
partial void OnScheduleChanged(string value)
|
||||
{
|
||||
OnPropertyChanged(nameof(ScheduleDesc));
|
||||
}
|
||||
}
|
||||
|
||||
public static class ScriptGroupProjectExtensions
|
||||
public class ScriptGroupProjectExtensions
|
||||
{
|
||||
public static readonly Dictionary<string, string> TypeDescriptions = new()
|
||||
{
|
||||
{ "Javascript", "JS脚本" },
|
||||
{ "KeyMouse", "键鼠脚本" },
|
||||
{ "Pathing", "路径追踪" }
|
||||
};
|
||||
|
||||
public static readonly Dictionary<string, string> StatusDescriptions = new()
|
||||
{
|
||||
{ "Enabled", "启用" },
|
||||
{ "Disabled", "禁用" }
|
||||
};
|
||||
|
||||
public Dictionary<string, string> GetStatusDescriptions()
|
||||
{
|
||||
return StatusDescriptions;
|
||||
}
|
||||
|
||||
public static readonly Dictionary<string, string> ScheduleDescriptions = new()
|
||||
{
|
||||
{ "Daily", "每日" },
|
||||
@@ -82,4 +201,9 @@ public static class ScriptGroupProjectExtensions
|
||||
{ "Saturday", "每周六" },
|
||||
{ "Sunday", "每周日" }
|
||||
};
|
||||
|
||||
public Dictionary<string, string> GetScheduleDescriptions()
|
||||
{
|
||||
return ScheduleDescriptions;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,10 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.Model;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Project;
|
||||
|
||||
@@ -10,29 +14,24 @@ namespace BetterGenshinImpact.Core.Script.Project;
|
||||
public class Manifest
|
||||
{
|
||||
public int ManifestVersion { get; set; } = 1;
|
||||
|
||||
public string Id { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Version { get; set; } = string.Empty;
|
||||
public string? BgiVersion { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public List<Author> Authors { get; set; } = [];
|
||||
public string Main { get; set; } = string.Empty;
|
||||
public string SettingsUi { get; set; } = string.Empty;
|
||||
public string[] Scripts { get; set; } = [];
|
||||
public string[] Library { get; set; } = [];
|
||||
|
||||
public static Manifest FromJson(string json)
|
||||
{
|
||||
var manifest = JsonSerializer.Deserialize<Manifest>(json, ConfigService.JsonOptions) ?? throw new Exception("Failed to deserialize JSON.");
|
||||
var manifest = JsonSerializer.Deserialize<Manifest>(json, Global.ManifestJsonOptions) ?? throw new Exception("Failed to deserialize JSON.");
|
||||
return manifest;
|
||||
}
|
||||
|
||||
public void Validate(string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Id))
|
||||
{
|
||||
throw new Exception("manifest.json: id is not supported.");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(Name))
|
||||
{
|
||||
throw new Exception("manifest.json: name is required.");
|
||||
@@ -52,5 +51,29 @@ public class Manifest
|
||||
{
|
||||
throw new FileNotFoundException("main js file not found.");
|
||||
}
|
||||
|
||||
// 比较版本号大小 BgiVersion
|
||||
if (!string.IsNullOrWhiteSpace(BgiVersion) && Global.IsNewVersion(BgiVersion))
|
||||
{
|
||||
TaskControl.Logger.LogError("脚本 {Name} 版本号要求 {BgiVersion} 大于当前 BetterGI 版本号 {CurrentVersion} , 脚本可能无法正常工作,请更新 BetterGI 版本!", Name, BgiVersion, Global.Version);
|
||||
}
|
||||
}
|
||||
|
||||
public List<SettingItem> LoadSettingItems(string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(SettingsUi))
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var settingItems = new List<SettingItem>();
|
||||
var settingFile = Path.Combine(path, SettingsUi);
|
||||
if (File.Exists(settingFile))
|
||||
{
|
||||
var json = File.ReadAllText(settingFile);
|
||||
settingItems = JsonSerializer.Deserialize<List<SettingItem>>(json, ConfigService.JsonOptions) ?? [];
|
||||
}
|
||||
|
||||
return settingItems;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.Project;
|
||||
|
||||
@@ -21,16 +22,40 @@ public class ScriptProject
|
||||
{
|
||||
FolderName = folderName;
|
||||
ProjectPath = Path.Combine(Global.ScriptPath(), folderName);
|
||||
if (!Directory.Exists(ProjectPath))
|
||||
{
|
||||
throw new DirectoryNotFoundException("脚本文件夹不存在:" + ProjectPath);
|
||||
}
|
||||
ManifestFile = Path.GetFullPath(Path.Combine(ProjectPath, "manifest.json"));
|
||||
if (!File.Exists(ManifestFile))
|
||||
{
|
||||
throw new FileNotFoundException("manifest.json file not found.");
|
||||
throw new FileNotFoundException("manifest.json文件不存在,请确认此脚本是JS脚本类型。" + ManifestFile);
|
||||
}
|
||||
|
||||
Manifest = Manifest.FromJson(File.ReadAllText(ManifestFile));
|
||||
Manifest.Validate(ProjectPath);
|
||||
}
|
||||
|
||||
public StackPanel? LoadSettingUi(dynamic context)
|
||||
{
|
||||
var settingItems = Manifest.LoadSettingItems(ProjectPath);
|
||||
if (settingItems.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var stackPanel = new StackPanel();
|
||||
foreach (var item in settingItems)
|
||||
{
|
||||
var controls = item.ToControl(context);
|
||||
foreach (var control in controls)
|
||||
{
|
||||
stackPanel.Children.Add(control);
|
||||
}
|
||||
}
|
||||
|
||||
return stackPanel;
|
||||
}
|
||||
|
||||
public IScriptEngine BuildScriptEngine()
|
||||
{
|
||||
IScriptEngine engine = new V8ScriptEngine(V8ScriptEngineFlags.UseCaseInsensitiveMemberBinding | V8ScriptEngineFlags.EnableTaskPromiseConversion);
|
||||
@@ -38,10 +63,15 @@ public class ScriptProject
|
||||
return engine;
|
||||
}
|
||||
|
||||
public async Task ExecuteAsync()
|
||||
public async Task ExecuteAsync(dynamic? context = null)
|
||||
{
|
||||
var code = await LoadCode();
|
||||
var engine = BuildScriptEngine();
|
||||
if (context != null)
|
||||
{
|
||||
// 写入配置的内容
|
||||
engine.AddHostObject("settings", context);
|
||||
}
|
||||
try
|
||||
{
|
||||
await (Task)engine.Evaluate(code);
|
||||
|
||||
@@ -0,0 +1,480 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Core.Script.WebView;
|
||||
using BetterGenshinImpact.GameTask;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using BetterGenshinImpact.Helpers.Http;
|
||||
using BetterGenshinImpact.Model;
|
||||
using BetterGenshinImpact.View.Controls.Webview;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Vanara.PInvoke;
|
||||
using Wpf.Ui.Violeta.Controls;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script;
|
||||
|
||||
public class ScriptRepoUpdater : Singleton<ScriptRepoUpdater>
|
||||
{
|
||||
private readonly ILogger<ScriptRepoUpdater> _logger = App.GetLogger<ScriptRepoUpdater>();
|
||||
|
||||
private static readonly HttpClient _httpClient = new() { Timeout = TimeSpan.FromSeconds(30) };
|
||||
|
||||
// 仓储位置
|
||||
public static readonly string ReposPath = Global.Absolute("Repos");
|
||||
|
||||
// 仓储临时目录 用于下载与解压
|
||||
public static readonly string ReposTempPath = Path.Combine(ReposPath, "Temp");
|
||||
|
||||
// 中央仓库信息地址
|
||||
public static readonly string CenterRepoInfoUrl = "https://raw.githubusercontent.com/babalae/bettergi-scripts-list/refs/heads/main/repo.json";
|
||||
|
||||
// 中央仓库解压后文件夹名
|
||||
public static readonly string CenterRepoUnzipName = "bettergi-scripts-list-main";
|
||||
|
||||
public static readonly string CenterRepoPath = Path.Combine(ReposPath, CenterRepoUnzipName);
|
||||
|
||||
public static readonly Dictionary<string, string> PathMapper = new Dictionary<string, string>
|
||||
{
|
||||
{ "pathing", Global.Absolute("User\\AutoPathing") },
|
||||
{ "js", Global.Absolute("User\\JsScript") },
|
||||
{ "combat", Global.Absolute("User\\AutoFight") },
|
||||
{ "tcg", Global.Absolute("User\\AutoGeniusInvokation") },
|
||||
};
|
||||
|
||||
private WebpageWindow? _webWindow;
|
||||
|
||||
public void AutoUpdate()
|
||||
{
|
||||
var scriptConfig = TaskContext.Instance().Config.ScriptConfig;
|
||||
|
||||
if (!Directory.Exists(ReposPath))
|
||||
{
|
||||
Directory.CreateDirectory(ReposPath);
|
||||
}
|
||||
|
||||
// 判断更新周期是否到达
|
||||
if (DateTime.Now - scriptConfig.LastUpdateScriptRepoTime >= TimeSpan.FromDays(scriptConfig.AutoUpdateScriptRepoPeriod))
|
||||
{
|
||||
// 更新仓库
|
||||
Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var (repoPath, updated) = await UpdateCenterRepo();
|
||||
Debug.WriteLine($"脚本仓库更新完成,路径:{repoPath}");
|
||||
scriptConfig.LastUpdateScriptRepoTime = DateTime.Now;
|
||||
if (updated)
|
||||
{
|
||||
scriptConfig.ScriptRepoHintDotVisible = true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogDebug(e, $"脚本仓库更新失败:{e.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<(string, bool)> UpdateCenterRepo()
|
||||
{
|
||||
// 测速并获取信息
|
||||
var res = await ProxySpeedTester.GetFastestProxyAsync(CenterRepoInfoUrl);
|
||||
// 解析信息
|
||||
var fastProxyUrl = res.Item1;
|
||||
var jsonString = res.Item2;
|
||||
var (time, url, file) = ParseJson(jsonString);
|
||||
|
||||
var updated = false;
|
||||
|
||||
// 检查仓库是否存在,不存在则下载
|
||||
var needDownload = false;
|
||||
if (Directory.Exists(CenterRepoPath))
|
||||
{
|
||||
var p = Directory.GetFiles(CenterRepoPath, "repo.json", SearchOption.AllDirectories).FirstOrDefault();
|
||||
if (p is null)
|
||||
{
|
||||
needDownload = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
needDownload = true;
|
||||
}
|
||||
if (needDownload)
|
||||
{
|
||||
await DownloadRepoAndUnzip(string.Format(fastProxyUrl, url));
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// 搜索本地的 repo.json
|
||||
var localRepoJsonPath = Directory.GetFiles(CenterRepoPath, file, SearchOption.AllDirectories).FirstOrDefault();
|
||||
if (localRepoJsonPath is null)
|
||||
{
|
||||
throw new Exception("本地仓库缺少 repo.json");
|
||||
}
|
||||
|
||||
var (time2, url2, file2) = ParseJson(await File.ReadAllTextAsync(localRepoJsonPath));
|
||||
|
||||
// 检查是否需要更新
|
||||
if (long.Parse(time) > long.Parse(time2))
|
||||
{
|
||||
await DownloadRepoAndUnzip(string.Format(fastProxyUrl, url2));
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// 获取与 localRepoJsonPath 同名(无扩展名)的文件夹路径
|
||||
var folderName = Path.GetFileNameWithoutExtension(localRepoJsonPath);
|
||||
var folderPath = Path.Combine(Path.GetDirectoryName(localRepoJsonPath)!, folderName);
|
||||
if (!Directory.Exists(folderPath))
|
||||
{
|
||||
throw new Exception("本地仓库文件夹不存在");
|
||||
}
|
||||
|
||||
return (folderPath, updated);
|
||||
}
|
||||
|
||||
public string FindCenterRepoPath()
|
||||
{
|
||||
var localRepoJsonPath = Directory.GetFiles(CenterRepoPath, "repo.json", SearchOption.AllDirectories).FirstOrDefault();
|
||||
if (localRepoJsonPath is null)
|
||||
{
|
||||
throw new Exception("本地仓库缺少 repo.json");
|
||||
}
|
||||
|
||||
// 获取与 localRepoJsonPath 同名(无扩展名)的文件夹路径
|
||||
var folderName = Path.GetFileNameWithoutExtension(localRepoJsonPath);
|
||||
var folderPath = Path.Combine(Path.GetDirectoryName(localRepoJsonPath)!, folderName);
|
||||
if (!Directory.Exists(folderPath))
|
||||
{
|
||||
throw new Exception("本地仓库文件夹不存在");
|
||||
}
|
||||
|
||||
return folderPath;
|
||||
}
|
||||
|
||||
private (string time, string url, string file) ParseJson(string jsonString)
|
||||
{
|
||||
var json = JObject.Parse(jsonString);
|
||||
var time = json["time"]?.ToString();
|
||||
var url = json["url"]?.ToString();
|
||||
var file = json["file"]?.ToString();
|
||||
// 检查是否有空值
|
||||
if (time is null || url is null || file is null)
|
||||
{
|
||||
throw new Exception("repo.json 解析失败");
|
||||
}
|
||||
|
||||
return (time, url, file);
|
||||
}
|
||||
|
||||
public async Task DownloadRepoAndUnzip(string url)
|
||||
{
|
||||
// 下载
|
||||
var res = await _httpClient.GetAsync(url);
|
||||
if (!res.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception("下载失败");
|
||||
}
|
||||
|
||||
var bytes = await res.Content.ReadAsByteArrayAsync();
|
||||
|
||||
// 获取文件名
|
||||
var contentDisposition = res.Content.Headers.ContentDisposition;
|
||||
var fileName = contentDisposition is { FileName: not null } ? contentDisposition.FileName.Trim('"') : "temp.zip";
|
||||
|
||||
// 创建临时目录
|
||||
if (!Directory.Exists(ReposTempPath))
|
||||
{
|
||||
Directory.CreateDirectory(ReposTempPath);
|
||||
}
|
||||
|
||||
// 保存下载的文件
|
||||
var zipPath = Path.Combine(ReposTempPath, fileName);
|
||||
await File.WriteAllBytesAsync(zipPath, bytes);
|
||||
|
||||
// 删除旧文件夹
|
||||
if (Directory.Exists(CenterRepoPath))
|
||||
{
|
||||
DirectoryHelper.DeleteReadOnlyDirectory(CenterRepoPath);
|
||||
}
|
||||
|
||||
// 使用 System.IO.Compression 解压
|
||||
ZipFile.ExtractToDirectory(zipPath, ReposPath, true);
|
||||
}
|
||||
|
||||
public async Task ImportScriptFromClipboard()
|
||||
{
|
||||
// 获取剪切板内容
|
||||
if (Clipboard.ContainsText())
|
||||
{
|
||||
string clipboardText = Clipboard.GetText();
|
||||
await ImportScriptFromUri(clipboardText, true);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task ImportScriptFromUri(string uri, bool formClipboard)
|
||||
{
|
||||
// 检查剪切板内容是否符合特定的URL格式
|
||||
if (!string.IsNullOrEmpty(uri) && uri.Trim().ToLower().StartsWith("bettergi://script?import="))
|
||||
{
|
||||
Debug.WriteLine($"脚本订购内容:{uri}");
|
||||
// 执行相关操作
|
||||
var pathJson = ParseUri(uri);
|
||||
if (!string.IsNullOrEmpty(pathJson))
|
||||
{
|
||||
var uiMessageBox = new Wpf.Ui.Controls.MessageBox
|
||||
{
|
||||
Title = "脚本订阅",
|
||||
Content = $"检测到{(formClipboard ? "剪切板上存在" : "")}脚本订阅链接,解析后需要导入的脚本为:{pathJson}。\n是否导入并覆盖此文件或者文件夹下的脚本?",
|
||||
CloseButtonText = "关闭",
|
||||
PrimaryButtonText = "确认导入",
|
||||
WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
};
|
||||
|
||||
var result = await uiMessageBox.ShowDialogAsync();
|
||||
if (result == Wpf.Ui.Controls.MessageBoxResult.Primary)
|
||||
{
|
||||
await ImportScriptFromPathJson(pathJson);
|
||||
}
|
||||
|
||||
// ContentDialog dialog = new()
|
||||
// {
|
||||
// Title = "脚本订阅",
|
||||
// Content = $"检测到{(formClipboard ? "剪切板上存在" : "")}脚本订阅链接,解析后需要导入的脚本为:{pathJson}。\n是否导入并覆盖此文件或者文件夹下的脚本?",
|
||||
// CloseButtonText = "关闭",
|
||||
// PrimaryButtonText = "确认导入",
|
||||
// };
|
||||
//
|
||||
// var result = await dialog.ShowAsync();
|
||||
// if (result == ContentDialogResult.Primary)
|
||||
// {
|
||||
// await ImportScriptFromPathJson(pathJson);
|
||||
// }
|
||||
}
|
||||
|
||||
if (formClipboard)
|
||||
{
|
||||
// 清空剪切板内容
|
||||
Clipboard.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string? ParseUri(string uriString)
|
||||
{
|
||||
var uri = new Uri(uriString);
|
||||
|
||||
// 获取 query 参数
|
||||
string query = uri.Query;
|
||||
Debug.WriteLine($"Query: {query}");
|
||||
|
||||
// 解析 query 参数
|
||||
var queryParams = System.Web.HttpUtility.ParseQueryString(query);
|
||||
var import = queryParams["import"];
|
||||
if (string.IsNullOrEmpty(import))
|
||||
{
|
||||
Debug.WriteLine("未找到 import 参数");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Base64 解码后再使用url解码
|
||||
byte[] data = Convert.FromBase64String(import);
|
||||
return System.Web.HttpUtility.UrlDecode(System.Text.Encoding.UTF8.GetString(data));
|
||||
}
|
||||
|
||||
public async Task ImportScriptFromPathJson(string pathJson)
|
||||
{
|
||||
var paths = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(pathJson);
|
||||
if (paths is null || paths.Count == 0)
|
||||
{
|
||||
Toast.Warning("订阅脚本路径为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 保存订阅信息
|
||||
var scriptConfig = TaskContext.Instance().Config.ScriptConfig;
|
||||
scriptConfig.SubscribedScriptPaths.AddRange(paths);
|
||||
|
||||
Toast.Information("获取最新仓库信息中...");
|
||||
|
||||
// 更新仓库
|
||||
var (repoPath, _) = await Task.Run(UpdateCenterRepo);
|
||||
|
||||
// // 收集将被覆盖的文件和文件夹
|
||||
// var filesToOverwrite = new List<string>();
|
||||
// foreach (var path in paths)
|
||||
// {
|
||||
// var first = GetFirstFolder(path);
|
||||
// if (PathMapper.TryGetValue(first, out var userPath))
|
||||
// {
|
||||
// var scriptPath = Path.Combine(repoPath, path);
|
||||
// var destPath = Path.Combine(userPath, path.Replace(first, ""));
|
||||
// if (Directory.Exists(scriptPath))
|
||||
// {
|
||||
// if (Directory.Exists(destPath))
|
||||
// {
|
||||
// filesToOverwrite.Add(destPath);
|
||||
// }
|
||||
// }
|
||||
// else if (File.Exists(scriptPath))
|
||||
// {
|
||||
// if (File.Exists(destPath))
|
||||
// {
|
||||
// filesToOverwrite.Add(destPath);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Toast.Warning($"未知的脚本路径:{path}");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 提示用户确认
|
||||
// if (filesToOverwrite.Count > 0)
|
||||
// {
|
||||
// var message = "以下文件和文件夹将被覆盖:\n" + string.Join("\n", filesToOverwrite) + "\n是否覆盖所有文件和文件夹?";
|
||||
// var uiMessageBox = new Wpf.Ui.Controls.MessageBox
|
||||
// {
|
||||
// Title = "确认覆盖",
|
||||
// Content = message,
|
||||
// CloseButtonText = "取消",
|
||||
// PrimaryButtonText = "确认覆盖",
|
||||
// WindowStartupLocation = WindowStartupLocation.CenterOwner,
|
||||
// Owner = Application.Current.MainWindow,
|
||||
// };
|
||||
//
|
||||
// var result = await uiMessageBox.ShowDialogAsync();
|
||||
// if (result != Wpf.Ui.Controls.MessageBoxResult.Primary)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
|
||||
// 拷贝文件
|
||||
foreach (var path in paths)
|
||||
{
|
||||
var (first, remainingPath) = GetFirstFolderAndRemainingPath(path);
|
||||
if (PathMapper.TryGetValue(first, out var userPath))
|
||||
{
|
||||
var scriptPath = Path.Combine(repoPath, path);
|
||||
var destPath = Path.Combine(userPath, remainingPath);
|
||||
if (Directory.Exists(scriptPath))
|
||||
{
|
||||
if (Directory.Exists(destPath))
|
||||
{
|
||||
Directory.Delete(destPath, true);
|
||||
}
|
||||
|
||||
CopyDirectory(scriptPath, destPath);
|
||||
|
||||
// 图标处理
|
||||
DealWithIconFolder(destPath);
|
||||
}
|
||||
else if (File.Exists(scriptPath))
|
||||
{
|
||||
if (File.Exists(destPath))
|
||||
{
|
||||
File.Delete(destPath);
|
||||
}
|
||||
|
||||
File.Copy(scriptPath, destPath, true);
|
||||
}
|
||||
|
||||
Toast.Success("脚本订阅链接导入完成");
|
||||
}
|
||||
else
|
||||
{
|
||||
Toast.Warning($"未知的脚本路径:{path}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyDirectory(string sourceDir, string destDir)
|
||||
{
|
||||
// 创建目标目录
|
||||
Directory.CreateDirectory(destDir);
|
||||
|
||||
// 拷贝文件
|
||||
foreach (var file in Directory.GetFiles(sourceDir))
|
||||
{
|
||||
var destFile = Path.Combine(destDir, Path.GetFileName(file));
|
||||
File.Copy(file, destFile, true);
|
||||
}
|
||||
|
||||
// 拷贝子目录
|
||||
foreach (var dir in Directory.GetDirectories(sourceDir))
|
||||
{
|
||||
var destSubDir = Path.Combine(destDir, Path.GetFileName(dir));
|
||||
CopyDirectory(dir, destSubDir);
|
||||
}
|
||||
}
|
||||
|
||||
private static (string firstFolder, string remainingPath) GetFirstFolderAndRemainingPath(string path)
|
||||
{
|
||||
// 检查路径是否为空或仅包含部分字符
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
return (string.Empty, string.Empty);
|
||||
}
|
||||
|
||||
// 使用路径分隔符分割路径
|
||||
string[] parts = path.Split(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
// 返回第一个文件夹和剩余路径
|
||||
return parts.Length > 0 ? (parts[0], string.Join(Path.DirectorySeparatorChar, parts.Skip(1))) : (string.Empty, string.Empty);
|
||||
}
|
||||
|
||||
public void OpenLocalRepoInWebView()
|
||||
{
|
||||
if (_webWindow is not { IsVisible: true })
|
||||
{
|
||||
_webWindow = new WebpageWindow
|
||||
{
|
||||
Title = "enshin Copilot Scripts | BetterGI 脚本本地中央仓库",
|
||||
Width = 1366,
|
||||
Height = 768,
|
||||
};
|
||||
_webWindow.Closed += (s, e) => _webWindow = null;
|
||||
_webWindow.Panel!.DownloadFolderPath = MapPathingViewModel.PathJsonPath;
|
||||
_webWindow.NavigateToFile(Global.Absolute(@"Assets\Web\ScriptRepo\index.html"));
|
||||
_webWindow.Panel!.OnWebViewInitializedAction = () => _webWindow.Panel!.WebView.CoreWebView2.AddHostObjectToScript("repoWebBridge", new RepoWebBridge());
|
||||
_webWindow.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
_webWindow.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理带有 icon.ico 和 desktop.ini 的文件夹
|
||||
/// </summary>
|
||||
/// <param name="folderPath"></param>
|
||||
private void DealWithIconFolder(string folderPath)
|
||||
{
|
||||
if (Directory.Exists(folderPath)
|
||||
&& File.Exists(Path.Combine(folderPath, "desktop.ini")))
|
||||
{
|
||||
// 使用 Vanara 库中的 SetFileAttributes 函数设置文件夹属性
|
||||
if (Kernel32.SetFileAttributes(folderPath, FileFlagsAndAttributes.FILE_ATTRIBUTE_READONLY))
|
||||
{
|
||||
Debug.WriteLine($"成功将文件夹设置为只读: {folderPath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine($"无法设置文件夹为只读: {folderPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Policy;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.ViewModel.Message;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
|
||||
namespace BetterGenshinImpact.Core.Script.WebView;
|
||||
|
||||
/// <summary>
|
||||
/// 给 WebView 提供的桥接类
|
||||
/// 用于调用 C# 方法
|
||||
/// </summary>
|
||||
[ClassInterface(ClassInterfaceType.AutoDual)]
|
||||
[ComVisible(true)]
|
||||
public class RepoWebBridge
|
||||
{
|
||||
public async Task<string> GetRepoJson()
|
||||
{
|
||||
try
|
||||
{
|
||||
// var needUpdate = false;
|
||||
// string? localRepoJsonPath = null;
|
||||
// if (Directory.Exists(ScriptRepoUpdater.CenterRepoPath))
|
||||
// {
|
||||
// localRepoJsonPath = Directory.GetFiles(ScriptRepoUpdater.CenterRepoPath, "repo.json", SearchOption.AllDirectories).FirstOrDefault();
|
||||
// if (localRepoJsonPath is null)
|
||||
// {
|
||||
// needUpdate = true;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// needUpdate = true;
|
||||
// }
|
||||
//
|
||||
// if (needUpdate)
|
||||
// {
|
||||
// await ScriptRepoUpdater.Instance.UpdateCenterRepo();
|
||||
// }
|
||||
|
||||
await ScriptRepoUpdater.Instance.UpdateCenterRepo();
|
||||
|
||||
var localRepoJsonPath = Directory.GetFiles(ScriptRepoUpdater.CenterRepoPath, "repo.json", SearchOption.AllDirectories).FirstOrDefault();
|
||||
if (localRepoJsonPath is null)
|
||||
{
|
||||
throw new Exception("repo.json 不存在,可能是更新仓库信息失败!");
|
||||
}
|
||||
var json = await File.ReadAllTextAsync(localRepoJsonPath);
|
||||
return json;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await MessageBox.ShowAsync(e.Message, "获取仓库信息失败!");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public async void ImportUri(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
await ScriptRepoUpdater.Instance.ImportScriptFromUri(url, false);
|
||||
WeakReferenceMessenger.Default.Send(new RefreshDataMessage("Refresh"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await MessageBox.ShowAsync(e.Message, "订阅脚本链接失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ namespace BetterGenshinImpact.GameTask.AutoDomain;
|
||||
[Serializable]
|
||||
public partial class AutoDomainConfig : ObservableObject
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 战斗结束后延迟几秒再开始寻找石化古树,秒
|
||||
/// </summary>
|
||||
@@ -26,4 +25,10 @@ public partial class AutoDomainConfig : ObservableObject
|
||||
/// 寻找古树时,短距离移动的次数
|
||||
/// </summary>
|
||||
[ObservableProperty] private int _leftRightMoveTimes = 3;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动吃药
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _autoEat = false;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ public class AutoDomainParam : BaseTaskParam
|
||||
|
||||
public string CombatStrategyPath { get; set; }
|
||||
|
||||
public AutoDomainParam(CancellationTokenSource cts, int domainRoundNum, string path) : base(cts)
|
||||
public AutoDomainParam(int domainRoundNum, string path)
|
||||
{
|
||||
DomainRoundNum = domainRoundNum;
|
||||
if (domainRoundNum == 0)
|
||||
|
||||
@@ -10,11 +10,9 @@ using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.AutoPick.Assets;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Compunet.YoloV8;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
@@ -25,13 +23,18 @@ using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
using static Vanara.PInvoke.Kernel32;
|
||||
using static Vanara.PInvoke.User32;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoDomain;
|
||||
|
||||
public class AutoDomainTask
|
||||
public class AutoDomainTask : ISoloTask
|
||||
{
|
||||
public string Name => "自动秘境";
|
||||
|
||||
private readonly AutoDomainParam _taskParam;
|
||||
|
||||
private readonly PostMessageSimulator _simulator;
|
||||
@@ -42,13 +45,15 @@ public class AutoDomainTask
|
||||
|
||||
private readonly CombatScriptBag _combatScriptBag;
|
||||
|
||||
private CancellationToken _ct;
|
||||
|
||||
public AutoDomainTask(AutoDomainParam taskParam)
|
||||
{
|
||||
_taskParam = taskParam;
|
||||
_simulator = AutoFightContext.Instance.Simulator;
|
||||
|
||||
_predictor = YoloV8Builder.CreateDefaultBuilder()
|
||||
.UseOnnxModel(Global.Absolute("Assets\\Model\\Domain\\bgi_tree.onnx"))
|
||||
.UseOnnxModel(Global.Absolute(@"Assets\Model\Domain\bgi_tree.onnx"))
|
||||
.WithSessionOptions(BgiSessionOption.Instance.Options)
|
||||
.Build();
|
||||
|
||||
@@ -57,96 +62,64 @@ public class AutoDomainTask
|
||||
_combatScriptBag = CombatScriptParser.ReadAndParse(_taskParam.CombatStrategyPath);
|
||||
}
|
||||
|
||||
public async void Start()
|
||||
public async Task Start(CancellationToken ct)
|
||||
{
|
||||
var hasLock = false;
|
||||
try
|
||||
_ct = ct;
|
||||
|
||||
AutoFightAssets.DestroyInstance();
|
||||
Init();
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Started().Build()); // TODO: 通知后续需要删除迁移
|
||||
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
|
||||
// 前置进入秘境
|
||||
EnterDomain();
|
||||
|
||||
for (var i = 0; i < _taskParam.DomainRoundNum; i++)
|
||||
{
|
||||
AutoFightAssets.DestroyInstance();
|
||||
hasLock = await TaskSemaphore.WaitAsync(0);
|
||||
if (!hasLock)
|
||||
// 0. 关闭秘境提示
|
||||
Logger.LogDebug("0. 关闭秘境提示");
|
||||
CloseDomainTip();
|
||||
|
||||
// 队伍没初始化成功则重试
|
||||
RetryTeamInit(combatScenes);
|
||||
|
||||
// 0. 切换到第一个角色
|
||||
var combatCommands = FindCombatScriptAndSwitchAvatar(combatScenes);
|
||||
|
||||
// 1. 走到钥匙处启动
|
||||
Logger.LogInformation("自动秘境:{Text}", "1. 走到钥匙处启动");
|
||||
await WalkToPressF();
|
||||
|
||||
// 2. 执行战斗(战斗线程、视角线程、检测战斗完成线程)
|
||||
Logger.LogInformation("自动秘境:{Text}", "2. 执行战斗策略");
|
||||
await StartFight(combatScenes, combatCommands);
|
||||
EndFightWait();
|
||||
|
||||
// 3. 寻找石化古树 并左右移动直到石化古树位于屏幕中心
|
||||
Logger.LogInformation("自动秘境:{Text}", "3. 寻找石化古树");
|
||||
await FindPetrifiedTree();
|
||||
|
||||
// 4. 走到石化古树处
|
||||
Logger.LogInformation("自动秘境:{Text}", "4. 走到石化古树处");
|
||||
await WalkToPressF();
|
||||
|
||||
// 5. 快速领取奖励并判断是否有下一轮
|
||||
Logger.LogInformation("自动秘境:{Text}", "5. 领取奖励");
|
||||
if (!GettingTreasure(_taskParam.DomainRoundNum == 9999, i == _taskParam.DomainRoundNum - 1))
|
||||
{
|
||||
Logger.LogError("启动自动秘境功能失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
return;
|
||||
}
|
||||
|
||||
Init();
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Started().Build());
|
||||
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
|
||||
// 前置进入秘境
|
||||
EnterDomain();
|
||||
|
||||
for (var i = 0; i < _taskParam.DomainRoundNum; i++)
|
||||
{
|
||||
// 0. 关闭秘境提示
|
||||
Logger.LogDebug("0. 关闭秘境提示");
|
||||
CloseDomainTip();
|
||||
|
||||
// 队伍没初始化成功则重试
|
||||
RetryTeamInit(combatScenes);
|
||||
|
||||
// 0. 切换到第一个角色
|
||||
var combatCommands = FindCombatScriptAndSwitchAvatar(combatScenes);
|
||||
|
||||
// 1. 走到钥匙处启动
|
||||
Logger.LogInformation("自动秘境:{Text}", "1. 走到钥匙处启动");
|
||||
await WalkToPressF();
|
||||
|
||||
// 2. 执行战斗(战斗线程、视角线程、检测战斗完成线程)
|
||||
Logger.LogInformation("自动秘境:{Text}", "2. 执行战斗策略");
|
||||
await StartFight(combatScenes, combatCommands);
|
||||
EndFightWait();
|
||||
|
||||
// 3. 寻找石化古树 并左右移动直到石化古树位于屏幕中心
|
||||
Logger.LogInformation("自动秘境:{Text}", "3. 寻找石化古树");
|
||||
await FindPetrifiedTree();
|
||||
|
||||
// 4. 走到石化古树处
|
||||
Logger.LogInformation("自动秘境:{Text}", "4. 走到石化古树处");
|
||||
await WalkToPressF();
|
||||
|
||||
// 5. 快速领取奖励并判断是否有下一轮
|
||||
Logger.LogInformation("自动秘境:{Text}", "5. 领取奖励");
|
||||
if (!GettingTreasure(_taskParam.DomainRoundNum == 9999, i == _taskParam.DomainRoundNum - 1))
|
||||
if (i == _taskParam.DomainRoundNum - 1)
|
||||
{
|
||||
if (i == _taskParam.DomainRoundNum - 1)
|
||||
{
|
||||
Logger.LogInformation("配置的{Cnt}轮秘境已经完成,结束自动秘境", _taskParam.DomainRoundNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("体力已经耗尽,结束自动秘境");
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Success().Build());
|
||||
break;
|
||||
Logger.LogInformation("配置的{Cnt}轮秘境已经完成,结束自动秘境", _taskParam.DomainRoundNum);
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Progress().Build());
|
||||
}
|
||||
}
|
||||
catch (NormalEndException e)
|
||||
{
|
||||
Logger.LogInformation("自动秘境中断:" + e.Message);
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Cancelled().Build());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e.Message);
|
||||
Logger.LogDebug(e.StackTrace);
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Failure().Build());
|
||||
}
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.NormalTrigger);
|
||||
TaskSettingsPageViewModel.SetSwitchAutoDomainButtonText(false);
|
||||
Logger.LogInformation("→ {Text}", "自动秘境结束");
|
||||
|
||||
if (hasLock)
|
||||
{
|
||||
TaskSemaphore.Release();
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("体力已经耗尽,结束自动秘境");
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Success().Build());
|
||||
break;
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationWithScreenshotUsing(b => b.Domain().Progress().Build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,16 +128,12 @@ public class AutoDomainTask
|
||||
LogScreenResolution();
|
||||
if (_taskParam.DomainRoundNum == 9999)
|
||||
{
|
||||
Logger.LogInformation("→ {Text} 用尽所有体力后结束", "自动秘境,启动!");
|
||||
Logger.LogInformation("→ {Text} 用尽所有体力后结束", "自动秘境,");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("→ {Text} 设置总次数:{Cnt}", "自动秘境,启动!", _taskParam.DomainRoundNum);
|
||||
Logger.LogInformation("→ {Text} 设置总次数:{Cnt}", "自动秘境,", _taskParam.DomainRoundNum);
|
||||
}
|
||||
|
||||
SystemControl.ActivateWindow();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.OnlyCacheCapture);
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 5, _taskParam.Cts); // 等待缓存图像
|
||||
}
|
||||
|
||||
private void LogScreenResolution()
|
||||
@@ -202,7 +171,7 @@ public class AutoDomainTask
|
||||
Simulation.SendInput.Keyboard.KeyPress(VK.VK_F);
|
||||
Logger.LogInformation("自动秘境:{Text}", "进入秘境");
|
||||
// 秘境开门动画 5s
|
||||
Sleep(5000, _taskParam.Cts);
|
||||
Sleep(5000, _ct);
|
||||
}
|
||||
|
||||
int retryTimes = 0, clickCount = 0;
|
||||
@@ -216,11 +185,11 @@ public class AutoDomainTask
|
||||
clickCount++;
|
||||
}
|
||||
|
||||
Sleep(1500, _taskParam.Cts);
|
||||
Sleep(1500, _ct);
|
||||
}
|
||||
|
||||
// 载入动画
|
||||
Sleep(3000, _taskParam.Cts);
|
||||
Sleep(3000, _ct);
|
||||
}
|
||||
|
||||
private void CloseDomainTip()
|
||||
@@ -233,16 +202,16 @@ public class AutoDomainTask
|
||||
using var cactRectArea = CaptureToRectArea().Find(AutoFightContext.Instance.FightAssets.ClickAnyCloseTipRa);
|
||||
if (!cactRectArea.IsEmpty())
|
||||
{
|
||||
Sleep(1000, _taskParam.Cts);
|
||||
Sleep(1000, _ct);
|
||||
cactRectArea.Click();
|
||||
break;
|
||||
}
|
||||
|
||||
// todo 添加小地图角标位置检测 防止有人手点了
|
||||
Sleep(1000, _taskParam.Cts);
|
||||
Sleep(1000, _ct);
|
||||
}
|
||||
|
||||
Sleep(1500, _taskParam.Cts);
|
||||
Sleep(1500, _ct);
|
||||
}
|
||||
|
||||
private List<CombatCommand> FindCombatScriptAndSwitchAvatar(CombatScenes combatScenes)
|
||||
@@ -259,7 +228,7 @@ public class AutoDomainTask
|
||||
/// </summary>
|
||||
private async Task WalkToPressF()
|
||||
{
|
||||
if (_taskParam.Cts.Token.IsCancellationRequested)
|
||||
if (_ct.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -276,12 +245,12 @@ public class AutoDomainTask
|
||||
|
||||
try
|
||||
{
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested)
|
||||
while (!_ct.IsCancellationRequested)
|
||||
{
|
||||
using var fRectArea = Common.TaskControl.CaptureToRectArea().Find(AutoPickAssets.Instance.FRo);
|
||||
if (fRectArea.IsEmpty())
|
||||
{
|
||||
Sleep(100, _taskParam.Cts);
|
||||
Sleep(100, _ct);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -306,8 +275,8 @@ public class AutoDomainTask
|
||||
private Task StartFight(CombatScenes combatScenes, List<CombatCommand> combatCommands)
|
||||
{
|
||||
CancellationTokenSource cts = new();
|
||||
_taskParam.Cts.Token.Register(cts.Cancel);
|
||||
combatScenes.BeforeTask(cts);
|
||||
_ct.Register(cts.Cancel);
|
||||
combatScenes.BeforeTask(cts.Token);
|
||||
// 战斗操作
|
||||
var combatTask = new Task(() =>
|
||||
{
|
||||
@@ -337,20 +306,19 @@ public class AutoDomainTask
|
||||
}
|
||||
}, cts.Token);
|
||||
|
||||
// 视角操作
|
||||
|
||||
// 对局结束检测
|
||||
var domainEndTask = DomainEndDetectionTask(cts);
|
||||
|
||||
// 自动吃药
|
||||
var autoEatRecoveryHpTask = AutoEatRecoveryHpTask(cts.Token);
|
||||
combatTask.Start();
|
||||
domainEndTask.Start();
|
||||
|
||||
return Task.WhenAll(combatTask, domainEndTask);
|
||||
autoEatRecoveryHpTask.Start();
|
||||
return Task.WhenAll(combatTask, domainEndTask, autoEatRecoveryHpTask);
|
||||
}
|
||||
|
||||
private void EndFightWait()
|
||||
{
|
||||
if (_taskParam.Cts.Token.IsCancellationRequested)
|
||||
if (_ct.IsCancellationRequested)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -359,7 +327,7 @@ public class AutoDomainTask
|
||||
if (s > 0)
|
||||
{
|
||||
Logger.LogInformation("战斗结束后等待 {Second} 秒", s);
|
||||
Sleep((int)(s * 1000), _taskParam.Cts);
|
||||
Sleep((int)(s * 1000), _ct);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,19 +336,25 @@ public class AutoDomainTask
|
||||
/// </summary>
|
||||
private Task DomainEndDetectionTask(CancellationTokenSource cts)
|
||||
{
|
||||
return new Task(() =>
|
||||
return new Task(async () =>
|
||||
{
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested)
|
||||
try
|
||||
{
|
||||
if (IsDomainEnd())
|
||||
while (!_ct.IsCancellationRequested)
|
||||
{
|
||||
cts.Cancel();
|
||||
break;
|
||||
}
|
||||
if (IsDomainEnd())
|
||||
{
|
||||
await cts.CancelAsync();
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(1000);
|
||||
await Delay(1000, cts.Token);
|
||||
}
|
||||
}
|
||||
});
|
||||
catch
|
||||
{
|
||||
}
|
||||
}, cts.Token);
|
||||
}
|
||||
|
||||
private bool IsDomainEnd()
|
||||
@@ -406,16 +380,63 @@ public class AutoDomainTask
|
||||
return false;
|
||||
}
|
||||
|
||||
private Task AutoEatRecoveryHpTask(CancellationToken ct)
|
||||
{
|
||||
return new Task(async () =>
|
||||
{
|
||||
if (!_config.AutoEat)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!IsTakeFood())
|
||||
{
|
||||
Logger.LogInformation("未装备 “{Tool}”,不启用红血自动吃药功能", "便携营养袋");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
while (!_ct.IsCancellationRequested)
|
||||
{
|
||||
if (Bv.CurrentAvatarIsLowHp(CaptureToRectArea()))
|
||||
{
|
||||
// 模拟按键 "Z"
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_Z);
|
||||
Logger.LogInformation("检测到红血,按Z吃药");
|
||||
// TODO 吃饱了会一直吃
|
||||
}
|
||||
|
||||
await Delay(500, ct);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogDebug(e, "红血自动吃药检测时发生异常");
|
||||
}
|
||||
}, ct);
|
||||
}
|
||||
|
||||
private bool IsTakeFood()
|
||||
{
|
||||
// 获取图像
|
||||
using var ra = CaptureToRectArea();
|
||||
// 识别道具图标下是否是数字
|
||||
var s = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
var countArea = ra.DeriveCrop(1800 * s, 845 * s, 40 * s, 20 * s);
|
||||
var count = OcrFactory.Paddle.OcrWithoutDetector(countArea.SrcGreyMat);
|
||||
return int.TryParse(count, out _);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 旋转视角后寻找石化古树
|
||||
/// </summary>
|
||||
private Task FindPetrifiedTree()
|
||||
{
|
||||
CancellationTokenSource treeCts = new();
|
||||
_taskParam.Cts.Token.Register(treeCts.Cancel);
|
||||
_ct.Register(treeCts.Cancel);
|
||||
// 中键回正视角
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
Sleep(900, _taskParam.Cts);
|
||||
Sleep(900, _ct);
|
||||
|
||||
// 左右移动直到石化古树位于屏幕中心任务
|
||||
var moveAvatarTask = MoveAvatarHorizontallyTask(treeCts);
|
||||
@@ -437,7 +458,7 @@ public class AutoDomainTask
|
||||
var noDetectCount = 0;
|
||||
var prevKey = VK.VK_A;
|
||||
var backwardsAndForwardsCount = 0;
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested)
|
||||
while (!_ct.IsCancellationRequested)
|
||||
{
|
||||
var treeRect = DetectTree(CaptureToRectArea());
|
||||
if (treeRect != Rect.Empty)
|
||||
@@ -520,7 +541,7 @@ public class AutoDomainTask
|
||||
else
|
||||
{
|
||||
_simulator.KeyPress(VK.VK_W, 60);
|
||||
Sleep(500, _taskParam.Cts);
|
||||
Sleep(500, _ct);
|
||||
treeCts.Cancel();
|
||||
break;
|
||||
}
|
||||
@@ -565,12 +586,12 @@ public class AutoDomainTask
|
||||
{
|
||||
// 左右移动5次说明已经在树中心了
|
||||
_simulator.KeyPress(VK.VK_W, 60);
|
||||
Sleep(500, _taskParam.Cts);
|
||||
Sleep(500, _ct);
|
||||
treeCts.Cancel();
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(60, _taskParam.Cts);
|
||||
Sleep(60, _ct);
|
||||
}
|
||||
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
@@ -618,7 +639,7 @@ public class AutoDomainTask
|
||||
continuousCount++;
|
||||
}
|
||||
|
||||
if (angle < 180)
|
||||
if (angle <= 180)
|
||||
{
|
||||
// 左移视角
|
||||
var moveAngle = angle;
|
||||
@@ -671,7 +692,7 @@ public class AutoDomainTask
|
||||
private bool GettingTreasure(bool recognizeResin, bool isLastTurn)
|
||||
{
|
||||
// 等待窗口弹出
|
||||
Sleep(1500, _taskParam.Cts);
|
||||
Sleep(1500, _ct);
|
||||
|
||||
// 优先使用浓缩树脂
|
||||
var retryTimes = 0;
|
||||
@@ -690,22 +711,22 @@ public class AutoDomainTask
|
||||
useCondensedResinRa.Click();
|
||||
// 点两下 #224 #218
|
||||
// 解决水龙王按下左键后没松开,然后后续点击按下就没反应了
|
||||
Sleep(400, _taskParam.Cts);
|
||||
Sleep(400, _ct);
|
||||
useCondensedResinRa.Click();
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(800, _taskParam.Cts);
|
||||
Sleep(800, _ct);
|
||||
}
|
||||
|
||||
Sleep(1000, _taskParam.Cts);
|
||||
Sleep(1000, _ct);
|
||||
|
||||
var captureArea = TaskContext.Instance().SystemInfo.CaptureAreaRect;
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
// 跳过领取动画
|
||||
GameCaptureRegion.GameRegionClick((size, scale) => (size.Width - 140 * scale, 53 * scale));
|
||||
Sleep(200, _taskParam.Cts);
|
||||
Sleep(200, _ct);
|
||||
GameCaptureRegion.GameRegionClick((size, scale) => (size.Width - 140 * scale, 53 * scale));
|
||||
|
||||
// 优先点击继续
|
||||
@@ -749,7 +770,7 @@ public class AutoDomainTask
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(300, _taskParam.Cts);
|
||||
Sleep(300, _ct);
|
||||
}
|
||||
|
||||
throw new NormalEndException("未检测到秘境结束,可能是背包物品已满。");
|
||||
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 607 B |
@@ -9,8 +9,8 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
|
||||
{
|
||||
public Rect TeamRectNoIndex;
|
||||
public Rect TeamRect;
|
||||
public List<Rect> AvatarSideIconRectList;
|
||||
public List<Rect> AvatarIndexRectList;
|
||||
public List<Rect> AvatarSideIconRectList; // 侧边栏角色头像 非联机状态下
|
||||
public List<Rect> AvatarIndexRectList; // 侧边栏角色头像对应的白色块 非联机状态下
|
||||
public Rect ERect;
|
||||
public Rect QRect;
|
||||
public Rect EndTipsUpperRect; // 挑战达成提示
|
||||
@@ -29,6 +29,13 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
|
||||
|
||||
public Dictionary<string, string> AvatarCostumeMap;
|
||||
|
||||
// 联机
|
||||
public RecognitionObject OnePRa;
|
||||
|
||||
public RecognitionObject PRa;
|
||||
public Dictionary<string, List<Rect>> AvatarSideIconRectListMap; // 侧边栏角色头像 联机状态下
|
||||
public Dictionary<string, List<Rect>> AvatarIndexRectListMap; // 侧边栏角色头像对应的白色块 联机状态下
|
||||
|
||||
private AutoFightAssets()
|
||||
{
|
||||
TeamRectNoIndex = new Rect(CaptureRect.Width - (int)(355 * AssetScale), (int)(220 * AssetScale),
|
||||
@@ -79,6 +86,78 @@ public class AutoFightAssets : BaseAssets<AutoFightAssets>
|
||||
{ "Sea", "海风之梦" },
|
||||
};
|
||||
|
||||
// 联机
|
||||
// 1p_2 与 p_2 为同一位置
|
||||
// 1p_4 与 p_4 为同一位置
|
||||
AvatarSideIconRectListMap = new Dictionary<string, List<Rect>>
|
||||
{
|
||||
{
|
||||
"1p_2", [
|
||||
new Rect(CaptureRect.Width - (int)(155 * AssetScale), (int)(375 * AssetScale), (int)(76 * AssetScale), (int)(76 * AssetScale)),
|
||||
new Rect(CaptureRect.Width - (int)(155 * AssetScale), (int)(470 * AssetScale), (int)(76 * AssetScale), (int)(76 * AssetScale)),
|
||||
]
|
||||
},
|
||||
{
|
||||
"1p_3", [
|
||||
new Rect(CaptureRect.Width - (int)(155 * AssetScale), (int)(375 * AssetScale), (int)(76 * AssetScale), (int)(76 * AssetScale)),
|
||||
new Rect(CaptureRect.Width - (int)(155 * AssetScale), (int)(470 * AssetScale), (int)(76 * AssetScale), (int)(76 * AssetScale)),
|
||||
]
|
||||
},
|
||||
{ "1p_4", [new Rect(CaptureRect.Width - (int)(155 * AssetScale), (int)(515 * AssetScale), (int)(76 * AssetScale), (int)(76 * AssetScale))] },
|
||||
{
|
||||
"p_2", [
|
||||
new Rect(CaptureRect.Width - (int)(155 * AssetScale), (int)(375 * AssetScale), (int)(76 * AssetScale), (int)(76 * AssetScale)),
|
||||
new Rect(CaptureRect.Width - (int)(155 * AssetScale), (int)(470 * AssetScale), (int)(76 * AssetScale), (int)(76 * AssetScale)),
|
||||
]
|
||||
},
|
||||
{ "p_3", [new Rect(CaptureRect.Width - (int)(155 * AssetScale), (int)(475 * AssetScale), (int)(76 * AssetScale), (int)(76 * AssetScale))] },
|
||||
{ "p_4", [new Rect(CaptureRect.Width - (int)(155 * AssetScale), (int)(515 * AssetScale), (int)(76 * AssetScale), (int)(76 * AssetScale))] },
|
||||
};
|
||||
|
||||
AvatarIndexRectListMap = new Dictionary<string, List<Rect>>
|
||||
{
|
||||
{
|
||||
"1p_2", [
|
||||
new Rect(CaptureRect.Width - (int)(61 * AssetScale), (int)(412 * AssetScale), (int)(28 * AssetScale), (int)(24 * AssetScale)),
|
||||
new Rect(CaptureRect.Width - (int)(61 * AssetScale), (int)(508 * AssetScale), (int)(28 * AssetScale), (int)(24 * AssetScale)),
|
||||
]
|
||||
},
|
||||
{
|
||||
"1p_3", [
|
||||
new Rect(CaptureRect.Width - (int)(61 * AssetScale), (int)(459 * AssetScale), (int)(28 * AssetScale), (int)(24 * AssetScale)),
|
||||
new Rect(CaptureRect.Width - (int)(61 * AssetScale), (int)(555 * AssetScale), (int)(28 * AssetScale), (int)(24 * AssetScale)),
|
||||
]
|
||||
},
|
||||
{ "1p_4", [new Rect(CaptureRect.Width - (int)(61 * AssetScale), (int)(552 * AssetScale), (int)(28 * AssetScale), (int)(24 * AssetScale))] },
|
||||
{
|
||||
"p_2", [
|
||||
new Rect(CaptureRect.Width - (int)(61 * AssetScale), (int)(412 * AssetScale), (int)(28 * AssetScale), (int)(24 * AssetScale)),
|
||||
new Rect(CaptureRect.Width - (int)(61 * AssetScale), (int)(508 * AssetScale), (int)(28 * AssetScale), (int)(24 * AssetScale)),
|
||||
]
|
||||
},
|
||||
{ "p_3", [new Rect(CaptureRect.Width - (int)(61 * AssetScale), (int)(412 * AssetScale), (int)(28 * AssetScale), (int)(24 * AssetScale))] },
|
||||
{ "p_4", [new Rect(CaptureRect.Width - (int)(61 * AssetScale), (int)(507 * AssetScale), (int)(28 * AssetScale), (int)(24 * AssetScale))] },
|
||||
};
|
||||
|
||||
// 左上角的 1P 图标
|
||||
OnePRa = new RecognitionObject
|
||||
{
|
||||
Name = "1P",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoFight", "1p.png"),
|
||||
RegionOfInterest = new Rect(0, 0, CaptureRect.Width / 4, CaptureRect.Height / 7),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
// 右侧联机的 P 图标
|
||||
PRa = new RecognitionObject
|
||||
{
|
||||
Name = "P",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoFight", "p.png"),
|
||||
RegionOfInterest = new Rect(CaptureRect.Width - CaptureRect.Width / 7, CaptureRect.Height / 5, CaptureRect.Width / 7, CaptureRect.Height / 2 - CaptureRect.Width / 7),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
WandererIconRa = new RecognitionObject
|
||||
{
|
||||
Name = "WandererIcon",
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
[
|
||||
{
|
||||
"alias": [ "主角", "旅行者", "卑鄙的外乡人", "荣誉骑士", "爷", "风主", "岩主", "雷主", "草主", "水主", "履刑者", "抽卡不歪真君" ],
|
||||
"alias": [ "旅行者", "主角", "卑鄙的外乡人", "荣誉骑士", "爷", "主", "履刑者", "抽卡不歪真君" ],
|
||||
"id": "20000000",
|
||||
"name": "旅行者",
|
||||
"nameEn": "Traveler",
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "荧", "女主", "女主角", "莹", "萤", "黄毛阿姨", "荧妹", "女爷" ],
|
||||
"alias": [ "荧", "女主", "女主角", "莹", "萤", "黄毛阿姨", "荧妹", "女爷", "包包", "宴宁" ],
|
||||
"id": "10000007",
|
||||
"name": "荧",
|
||||
"nameEn": "PlayerGirl",
|
||||
@@ -21,7 +21,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "神里绫华", "Kamisato Ayaka", "Ayaka", "ayaka", "神里", "绫华", "神里凌华", "凌华", "白鹭公主", "神里大小姐", "小乌龟", "龟龟", "山里灵活" ],
|
||||
"alias": [ "神里绫华", "Kamisato Ayaka", "Ayaka", "神里", "绫华", "神里凌华", "凌华", "白鹭公主", "神里大小姐", "龟", "龟龟", "乌龟" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000002",
|
||||
"name": "神里绫华",
|
||||
@@ -30,7 +30,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "琴", "Jean", "jean", "团长", "代理团长", "琴团长", "蒲公英骑士", "琴·古恩希尔德", "古恩希尔德" ],
|
||||
"alias": [ "琴", "Jean", "团长", "代理团长", "琴团长", "蒲公英骑士" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000003",
|
||||
"name": "琴",
|
||||
@@ -39,7 +39,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "丽莎", "Lisa", "lisa", "图书管理员", "图书馆管理员", "蔷薇魔女", "丽莎阿姨", "丽莎·敏兹", "敏兹" ],
|
||||
"alias": [ "丽莎", "Lisa", "图书管理员", "图书馆管理员", "蔷薇魔女", "阿姨" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000006",
|
||||
"name": "丽莎",
|
||||
@@ -49,7 +49,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "芭芭拉", "Barbara", "barbara", "巴巴拉", "拉粑粑", "拉巴巴", "内鬼", "加湿器", "肉身解咒", "肉身解咒真君", "闪耀偶像", "偶像", "芭芭拉·佩奇", "佩奇" ],
|
||||
"alias": [ "芭芭拉", "Barbara", "巴巴拉", "内鬼", "加湿器", "肉身解咒", "肉身解咒真君", "闪耀偶像", "偶像" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000014",
|
||||
"name": "芭芭拉",
|
||||
@@ -58,7 +58,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "凯亚", "Kaeya", "kaeya", "盖亚", "凯子哥", "凯鸭", "矿工", "矿工头子", "骑兵队长", "凯子", "凝冰渡海真君", "凯亚·亚尔伯里奇", "亚尔伯里奇" ],
|
||||
"alias": [ "凯亚", "Kaeya", "盖亚", "凯子哥", "凯鸭", "矿工", "矿工头子", "骑兵队长", "凯子", "凝冰渡海真君" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000015",
|
||||
"name": "凯亚",
|
||||
@@ -67,7 +67,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "迪卢克", "diluc", "Diluc", "卢姥爷", "姥爷", "卢老爷", "卢锅巴", "正义人", "正e人", "正E人", "卢本伟", "暗夜英雄", "卢卢伯爵", "落魄了", "落魄了家人们", "迪卢克·莱艮芬德", "莱艮芬德" ],
|
||||
"alias": [ "迪卢克", "Diluc", "卢姥爷", "姥爷", "卢老爷", "卢锅巴", "正义人", "正e人", "正E人", "卢本伟", "暗夜英雄", "卢卢伯爵", "落魄了", "落魄了家人们" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000016",
|
||||
"name": "迪卢克",
|
||||
@@ -76,7 +76,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "雷泽", "razor", "Razor", "狼少年", "狼崽子", "狼崽", "卢皮卡", "小狼", "小狼狗", "狼孩" ],
|
||||
"alias": [ "雷泽", "Razor", "狼少年", "狼崽子", "狼崽", "卢皮卡", "小狼", "小狼狗", "狼孩" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000020",
|
||||
"name": "雷泽",
|
||||
@@ -86,7 +86,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "安柏", "Amber", "amber", "安伯", "兔兔伯爵", "飞行冠军", "侦查骑士", "点火姬", "点火机", "打火机", "打火姬" ],
|
||||
"alias": [ "安柏", "Amber", "安伯", "兔兔伯爵", "飞行冠军", "侦查骑士", "点火姬", "点火机", "打火机", "打火姬" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000021",
|
||||
"name": "安柏",
|
||||
@@ -95,7 +95,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "温迪", "Venti", "venti", "温蒂", "风神", "卖唱的", "巴巴托斯", "巴巴脱丝", "芭芭托斯", "芭芭脱丝", "干点正事", "不干正事", "吟游诗人", "诶嘿", "唉嘿", "摸鱼" ],
|
||||
"alias": [ "温迪", "Venti", "温蒂", "风神", "卖唱的", "巴巴托斯", "巴巴脱丝", "芭芭托斯", "芭芭脱丝", "干点正事", "不干正事", "吟游诗人", "诶嘿", "唉嘿", "摸鱼" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000022",
|
||||
"name": "温迪",
|
||||
@@ -105,7 +105,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "香菱", "Xiangling", "xiangling", "香玲", "锅巴", "厨师", "万民堂厨师", "香师傅", "卯香菱" ],
|
||||
"alias": [ "香菱", "Xiangling", "香玲", "锅巴", "厨师", "万民堂厨师", "香师傅" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000023",
|
||||
"name": "香菱",
|
||||
@@ -114,7 +114,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "北斗", "Beidou", "beidou", "大姐头", "大姐", "无冕的龙王" ],
|
||||
"alias": [ "北斗", "Beidou", "大姐头", "大姐", "无冕的龙王" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000024",
|
||||
"name": "北斗",
|
||||
@@ -123,7 +123,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "行秋", "Xingqiu", "xingqiu", "秋秋人", "秋妹妹", "书呆子", "枕玉", "飞云商会二少爷" ],
|
||||
"alias": [ "行秋", "Xingqiu", "秋秋人", "秋妹妹", "书呆子", "枕玉", "飞云商会二少爷" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000025",
|
||||
"name": "行秋",
|
||||
@@ -132,7 +132,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "魈", "Xiao", "xiao", "打桩机", "插秧", "三眼五显仙人", "三眼五显真人", "降魔大圣", "护法夜叉", "快乐风男", "无聊", "靖妖傩舞", "矮子仙人", "三点五尺仙人", "跳跳虎" ],
|
||||
"alias": [ "魈", "Xiao", "打桩机", "插秧", "三眼五显仙人", "三眼五显真人", "降魔大圣", "护法夜叉", "快乐风男", "无聊", "靖妖傩舞", "矮子仙人", "三点五尺仙人", "跳跳虎", "风夜叉" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000026",
|
||||
"name": "魈",
|
||||
@@ -141,7 +141,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "凝光", "Ningguang", "ningguang", "富婆", "天权星", "天权" ],
|
||||
"alias": [ "凝光", "Ningguang", "富婆", "天权星", "天权" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000027",
|
||||
"name": "凝光",
|
||||
@@ -150,7 +150,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "可莉", "Klee", "klee", "嘟嘟可", "火花骑士", "蹦蹦炸弹", "炸鱼", "放火烧山", "放火烧山真君", "蒙德最强战力", "逃跑的太阳", "啦啦啦", "哒哒哒", "炸弹人", "禁闭室", "太阳", "小太阳" ],
|
||||
"alias": [ "可莉", "逃跑的太阳", "Klee", "嘟嘟可", "火花骑士", "蹦蹦炸弹", "炸鱼", "放火烧山", "放火烧山真君", "蒙德最强战力", "逃跑的太阳", "啦啦啦", "哒哒哒", "炸弹人", "禁闭室", "太阳", "小太阳" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000029",
|
||||
"name": "可莉",
|
||||
@@ -159,7 +159,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "钟离", "Zhongli", "zhongli", "摩拉克斯", "岩王爷", "岩神", "钟师傅", "天动万象", "岩王帝君", "未来可期", "帝君", "拒收病婿" ],
|
||||
"alias": [ "钟离", "Zhongli", "摩拉克斯", "岩王爷", "岩神", "钟师傅", "天动万象", "岩王帝君", "未来可期", "帝君", "拒收病婿" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000030",
|
||||
"name": "钟离",
|
||||
@@ -169,7 +169,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "菲谢尔", "Fischl", "fischl", "皇女", "小艾米", "小艾咪", "奥兹", "断罪皇女", "中二病", "中二少女", "中二皇女", "奥兹发射器", "菲谢尔·冯·露弗施洛斯·那菲多特", "露弗施洛斯", "那菲多特" ],
|
||||
"alias": [ "菲谢尔", "Fischl", "皇女", "小艾米", "小艾咪", "奥兹", "断罪皇女", "中二病", "中二少女", "中二皇女", "奥兹发射器" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000031",
|
||||
"name": "菲谢尔",
|
||||
@@ -178,7 +178,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "班尼特", "Bennett", "bennett", "点赞哥", "点赞", "倒霉少年", "倒霉蛋", "霹雳闪雷真君", "班神", "班爷", "倒霉", "火神", "六星真神" ],
|
||||
"alias": [ "班尼特", "Bennett", "点赞哥", "点赞", "倒霉少年", "倒霉蛋", "霹雳闪雷真君", "班神", "班爷", "倒霉", "蒙德火神", "六星真神" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000032",
|
||||
"name": "班尼特",
|
||||
@@ -187,7 +187,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "达达利亚", "Tartaglia", "tartaglia", "Childe", "childe", "Ajax", "ajax", "达达鸭", "达达利鸭", "公子", "玩具销售员", "玩具推销员", "钱包", "鸭鸭", "愚人众末席", "阿贾克斯" ],
|
||||
"alias": [ "达达利亚", "Tartaglia", "Childe", "Ajax", "达达鸭", "达达利鸭", "公子", "玩具销售员", "玩具推销员", "钱包", "鸭鸭", "愚人众末席" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000033",
|
||||
"name": "达达利亚",
|
||||
@@ -197,7 +197,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "诺艾尔", "Noelle", "noelle", "女仆", "高达", "岩王帝姬" ],
|
||||
"alias": [ "诺艾尔", "Noelle", "女仆", "高达", "岩王帝姬" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000034",
|
||||
"name": "诺艾尔",
|
||||
@@ -206,7 +206,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "七七", "Qiqi", "qiqi", "僵尸", "肚饿真君", "度厄真君", "77" ],
|
||||
"alias": [ "七七", "Qiqi", "僵尸", "肚饿真君", "度厄真君", "77" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000035",
|
||||
"name": "七七",
|
||||
@@ -215,7 +215,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "重云", "Chongyun", "chongyun", "纯阳之体", "冰棍" ],
|
||||
"alias": [ "重云", "Chongyun", "纯阳之体", "冰棍" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000036",
|
||||
"name": "重云",
|
||||
@@ -224,7 +224,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "甘雨", "Ganyu", "ganyu", "椰羊", "椰奶", "王小美" ],
|
||||
"alias": [ "甘雨", "Ganyu", "椰羊", "椰奶", "王小美" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000037",
|
||||
"name": "甘雨",
|
||||
@@ -233,7 +233,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "阿贝多", "Albedo", "albedo", "可莉哥哥", "升降机", "升降台", "电梯", "白垩之子", "贝爷", "白垩", "阿贝少", "花呗多", "阿贝夕", "abd", "阿师傅" ],
|
||||
"alias": [ "阿贝多", "Albedo", "可莉哥哥", "升降机", "升降台", "电梯", "白垩之子", "贝爷", "白垩", "阿贝少", "花呗多", "阿贝夕", "阿师傅" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000038",
|
||||
"name": "阿贝多",
|
||||
@@ -242,7 +242,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "迪奥娜", "Diona", "diona", "迪欧娜", "dio", "dio娜", "冰猫", "猫猫", "猫娘", "喵喵", "调酒师", "迪奥娜·凯茨莱茵", "凯茨莱茵" ],
|
||||
"alias": [ "迪奥娜", "Diona", "迪欧娜", "dio娜", "冰猫", "猫猫", "猫娘", "喵喵", "调酒师" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000039",
|
||||
"name": "迪奥娜",
|
||||
@@ -252,7 +252,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "莫娜", "Mona", "mona", "穷鬼", "穷光蛋", "穷", "莫纳", "占星术士", "占星师", "讨龙真君", "半部讨龙真君", "阿斯托洛吉斯·莫娜·梅姬斯图斯", "阿斯托洛吉斯", "梅姬斯图斯", "梅姬斯图斯姬", "梅姬斯图斯卿" ],
|
||||
"alias": [ "莫娜", "Mona", "穷鬼", "穷光蛋", "穷", "莫纳", "占星术士", "占星师", "讨龙真君", "半部讨龙真君", "阿斯托洛吉斯·莫娜·梅姬斯图斯", "梅姬斯图斯", "梅姬斯图斯姬" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000041",
|
||||
"name": "莫娜",
|
||||
@@ -261,7 +261,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "刻晴", "Keqing", "keqing", "刻情", "氪晴", "刻师傅", "刻师父", "牛杂", "牛杂师傅", "斩尽牛杂", "免疫", "免疫免疫", "屁斜剑法", "玉衡星", "玉衡", "阿晴", "啊晴", "璃月雷神" ],
|
||||
"alias": [ "刻晴", "Keqing", "刻情", "氪晴", "刻师傅", "刻师父", "牛杂", "牛杂师傅", "斩尽牛杂", "免疫", "免疫免疫", "屁斜剑法", "玉衡星", "阿晴", "啊晴", "璃月雷神" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000042",
|
||||
"name": "刻晴",
|
||||
@@ -270,7 +270,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "砂糖", "Sucrose", "sucrose", "雷莹术士", "雷萤术士", "雷荧术士" ],
|
||||
"alias": [ "砂糖", "Sucrose", "sucrose" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000043",
|
||||
"name": "砂糖",
|
||||
@@ -279,7 +279,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "辛焱", "Xinyan", "xinyan", "辛炎", "黑妹", "摇滚" ],
|
||||
"alias": [ "辛焱", "Xinyan", "辛炎", "黑妹", "摇滚" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000044",
|
||||
"name": "辛焱",
|
||||
@@ -288,7 +288,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "罗莎莉亚", "Rosaria", "rosaria", "罗莎莉娅", "白色史莱姆", "白史莱姆", "修女", "罗莎利亚", "罗莎利娅", "罗沙莉亚", "罗沙莉娅", "罗沙利亚", "罗沙利娅", "萝莎莉亚", "萝莎莉娅", "萝莎利亚", "萝莎利娅", "萝沙莉亚", "萝沙莉娅", "萝沙利亚", "萝沙利娅" ],
|
||||
"alias": [ "罗莎莉亚", "Rosaria", "罗莎莉娅", "白色史莱姆", "白史莱姆", "修女", "罗莎利亚", "罗莎利娅", "罗沙莉亚", "罗沙莉娅", "罗沙利亚", "罗沙利娅", "萝莎莉亚", "萝莎莉娅", "萝莎利亚", "萝莎利娅", "萝沙莉亚", "萝沙莉娅", "萝沙利亚", "萝沙利娅" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000045",
|
||||
"name": "罗莎莉亚",
|
||||
@@ -297,7 +297,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "胡桃", "Hu Tao", "hu tao", "HuTao", "hutao", "Hutao", "胡淘", "往生堂堂主", "火化", "抬棺的", "蝴蝶", "核桃", "堂主", "胡堂主", "雪霁梅香", "桃子" ],
|
||||
"alias": [ "胡桃", "Hu Tao", "HuTao", "Hutao", "胡淘", "往生堂堂主", "火化", "抬棺的", "蝴蝶", "核桃", "堂主", "胡堂主", "雪霁梅香", "桃子", "桃" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000046",
|
||||
"name": "胡桃",
|
||||
@@ -306,7 +306,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "枫原万叶", "Kaedehara Kazuha", "Kazuha", "kazuha", "万叶", "叶天帝", "天帝", "叶师傅" ],
|
||||
"alias": [ "枫原万叶", "Kaedehara Kazuha", "Kazuha", "万叶", "叶天帝", "天帝", "叶师傅" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000047",
|
||||
"name": "枫原万叶",
|
||||
@@ -316,7 +316,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "烟绯", "Yanfei", "yanfei", "烟老师", "律师", "罗翔" ],
|
||||
"alias": [ "烟绯", "Yanfei", "烟老师", "律师", "罗翔" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000048",
|
||||
"name": "烟绯",
|
||||
@@ -325,7 +325,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "宵宫", "Yoimiya", "yoimiya", "霄宫", "烟花", "肖宫", "肖工", "绷带女孩", "长野原宵宫" ],
|
||||
"alias": [ "宵宫", "Yoimiya", "霄宫", "烟花", "肖宫", "肖工", "绷带女孩" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000049",
|
||||
"name": "宵宫",
|
||||
@@ -334,7 +334,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "托马", "Thoma", "thoma", "家政官", "太郎丸", "地头蛇", "男仆", "拖马" ],
|
||||
"alias": [ "托马", "Thoma", "家政官", "太郎丸", "地头蛇", "男仆", "拖马" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000050",
|
||||
"name": "托马",
|
||||
@@ -343,7 +343,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "优菈", "Eula", "eula", "优拉", "尤拉", "尤菈", "浪花骑士", "记仇", "优菈·劳伦斯", "劳伦斯" ],
|
||||
"alias": [ "优菈", "Eula", "优拉", "尤拉", "尤菈", "浪花骑士", "记仇", "劳伦斯" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000051",
|
||||
"name": "优菈",
|
||||
@@ -353,7 +353,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "雷电将军", "Raiden Shogun", "Raiden", "raiden", "雷神", "将军", "雷军", "巴尔", "阿影", "影", "巴尔泽布", "煮饭婆", "奶香一刀", "无想一刀", "宅女" ],
|
||||
"alias": [ "雷电将军", "Raiden Shogun", "Raiden", "雷神", "将军", "雷军", "巴尔", "阿影", "影", "巴尔泽布", "煮饭婆", "奶香一刀", "无想一刀", "宅女" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000052",
|
||||
"name": "雷电将军",
|
||||
@@ -362,7 +362,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "早柚", "Sayu", "sayu", "小狸猫", "狸猫", "忍者", "貉" ],
|
||||
"alias": [ "早柚", "Sayu", "小狸猫", "狸猫", "忍者", "貉" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000053",
|
||||
"name": "早柚",
|
||||
@@ -371,7 +371,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "珊瑚宫心海", "Sangonomiya Kokomi", "Kokomi", "kokomi", "心海", "军师", "珊瑚宫", "书记", "观赏鱼", "水母", "鱼", "美人鱼" ],
|
||||
"alias": [ "珊瑚宫心海", "Sangonomiya Kokomi", "Kokomi", "心海", "军师", "珊瑚宫", "书记", "观赏鱼", "水母", "鱼", "美人鱼" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000054",
|
||||
"name": "珊瑚宫心海",
|
||||
@@ -380,7 +380,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "五郎", "Gorou", "gorou", "柴犬", "土狗", "希娜", "希娜小姐" ],
|
||||
"alias": [ "五郎", "Gorou", "柴犬", "土狗", "希娜", "希娜小姐" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000055",
|
||||
"name": "五郎",
|
||||
@@ -389,7 +389,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "九条裟罗", "Kujou Sara", "Sara", "sara", "九条", "九条沙罗", "裟罗", "沙罗", "天狗" ],
|
||||
"alias": [ "九条裟罗", "Kujou Sara", "Sara", "九条", "九条沙罗", "裟罗", "沙罗", "天狗" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000056",
|
||||
"name": "九条裟罗",
|
||||
@@ -398,7 +398,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "荒泷一斗", "Arataki Itto", "Itto", "itto", "荒龙一斗", "荒泷天下第一斗", "一斗", "一抖", "荒泷", "1斗", "牛牛", "斗子哥", "牛子哥", "牛子", "孩子王", "斗虫", "巧乐兹", "放牛的" ],
|
||||
"alias": [ "荒泷一斗", "Arataki Itto", "Itto", "荒龙一斗", "荒泷天下第一斗", "一斗", "一抖", "荒泷", "1斗", "牛牛", "斗子哥", "牛子哥", "牛子", "孩子王", "斗虫", "巧乐兹", "放牛的" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000057",
|
||||
"name": "荒泷一斗",
|
||||
@@ -407,7 +407,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "八重神子", "Yae Miko", "Miko", "miko", "八重", "神子", "狐狸", "想得美哦", "巫女", "屑狐狸", "骚狐狸", "八重宫司", "婶子", "小八", "八重寄子", "寄子" ],
|
||||
"alias": [ "八重神子", "Yae Miko", "Miko", "八重", "神子", "狐狸", "想得美哦", "巫女", "屑狐狸", "骚狐狸", "八重宫司", "婶子", "小八", "八重寄子", "寄子", "八神虫子", "八神重子" ],
|
||||
"burstCD": 22.0,
|
||||
"id": "10000058",
|
||||
"name": "八重神子",
|
||||
@@ -416,7 +416,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "鹿野院平藏", "shikanoin heizou", "Heizou", "heizou", "heizo", "鹿野苑", "鹿野院", "平藏", "鹿野苑平藏", "小鹿", "风拳" ],
|
||||
"alias": [ "鹿野院平藏", "shikanoin heizou", "Heizou", "鹿野苑", "鹿野院", "平藏", "鹿野苑平藏", "小鹿" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000059",
|
||||
"name": "鹿野院平藏",
|
||||
@@ -425,7 +425,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "夜兰", "Yelan", "yelan", "夜阑", "叶澜", "腋兰", "夜天后" ],
|
||||
"alias": [ "夜兰", "Yelan", "夜阑", "叶澜", "腋兰", "夜天后" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000060",
|
||||
"name": "夜兰",
|
||||
@@ -434,7 +434,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "绮良良", "Kirara", "kirara", "琦良良", "崎良良", "草猫", "猫又", "宅急便", "草猫宅急便", "送货员", "快递员", "草猫快递" ],
|
||||
"alias": [ "绮良良", "Kirara", "大猫猫", "大喵喵", "稻妻猫猫", "绮娘娘", "琦良良", "良良", "快递员", "草猫", "草猫猫", "草喵", "草喵喵", "猫又" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000061",
|
||||
"name": "绮良良",
|
||||
@@ -443,7 +443,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "埃洛伊", "Aloy", "aloy" ],
|
||||
"alias": [ "埃洛伊", "Aloy" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000062",
|
||||
"name": "埃洛伊",
|
||||
@@ -452,7 +452,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "申鹤", "Shenhe", "shenhe", "神鹤", "小姨", "小姨子", "审鹤" ],
|
||||
"alias": [ "申鹤", "Shenhe", "神鹤", "小姨", "小姨子", "审鹤" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000063",
|
||||
"name": "申鹤",
|
||||
@@ -462,7 +462,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "云堇", "Yun Jin", "yunjin", "yun jin", "云瑾", "云先生", "云锦", "神女劈观", "土女" ],
|
||||
"alias": [ "云堇", "Yun Jin", "yun jin", "云瑾", "云先生", "云锦", "神女劈观" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000064",
|
||||
"name": "云堇",
|
||||
@@ -471,7 +471,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "久岐忍", "Kuki Shinobu", "Kuki", "kuki", "Shinobu", "shinobu", "97忍", "小忍", "久歧忍", "97", "茄忍", "茄子", "紫茄子", "阿忍", "忍姐" ],
|
||||
"alias": [ "久岐忍", "Kuki Shinobu", "Kuki", "Shinobu", "97忍", "小忍", "久歧忍", "97", "茄忍", "茄子", "紫茄子", "阿忍", "忍姐" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000065",
|
||||
"name": "久岐忍",
|
||||
@@ -480,7 +480,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "神里绫人", "Kamisato Ayato", "Ayato", "ayato", "绫人", "神里凌人", "凌人", "0人", "神人", "零人", "大舅哥" ],
|
||||
"alias": [ "神里绫人", "Kamisato Ayato", "Ayato", "绫人", "神里凌人", "凌人", "0人", "神人", "零人", "大舅哥" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000066",
|
||||
"name": "神里绫人",
|
||||
@@ -489,7 +489,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "柯莱", "Collei", "collei", "柯来", "科莱", "科来", "小天使", "须弥安柏", "草安柏", "须弥飞行冠军", "见习巡林员", "巡林员" ],
|
||||
"alias": [ "柯莱", "Collei", "柯来", "科莱", "科来", "小天使", "须弥安柏", "草安柏", "须弥飞行冠军" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000067",
|
||||
"name": "柯莱",
|
||||
@@ -498,7 +498,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "多莉", "Dori", "dori", "多利", "多力", "多丽", "奸商", "多莉·桑歌玛哈巴依", "桑歌玛哈巴依" ],
|
||||
"alias": [ "多莉", "Dori", "多利", "多力", "奸商" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000068",
|
||||
"name": "多莉",
|
||||
@@ -507,7 +507,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "提纳里", "Tighnari", "tighnari", "小提", "提那里", "缇娜里", "提哪里", "驴", "柯莱老师", "柯莱师傅", "柯莱师父", "巡林官", "大巡林官" ],
|
||||
"alias": [ "提纳里", "Tighnari", "提那里", "小提", "驴" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000069",
|
||||
"name": "提纳里",
|
||||
@@ -516,7 +516,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "妮露", "Nilou", "nilou", "尼露", "尼禄", "妮璐", "舞娘", "红牛" ],
|
||||
"alias": [ "妮露", "Nilou", "尼露", "妮璐", "舞娘", "红牛" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000070",
|
||||
"name": "妮露",
|
||||
@@ -525,7 +525,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "赛诺", "Cyno", "cyno", "塞诺", "胡狼", "牌佬", "打牌佬", "打牌王", "大风纪官", "大风机关" ],
|
||||
"alias": [ "赛诺", "Cyno", "塞诺", "胡狼", "大风纪官", "大风机关" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000071",
|
||||
"name": "赛诺",
|
||||
@@ -535,7 +535,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "坎蒂丝", "Candace", "candace", "坎迪斯", "阿如村守护者", "水北斗" ],
|
||||
"alias": [ "坎蒂丝", "Candace", "坎迪斯" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000072",
|
||||
"name": "坎蒂丝",
|
||||
@@ -545,7 +545,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "纳西妲", "Nahida", "nahida", "草王", "草神", "花神", "小吉祥", "小吉祥草王", "大慈树王", "草萝莉", "纳西坦", "羽毛球" ],
|
||||
"alias": [ "纳西妲", "Nahida", "草神", "小吉祥", "大吉祥", "小草神", "大慈树王", "小吉祥草王", "草萝莉", "羽毛球", "摩诃善法大吉祥智慧主", "智慧主", "智慧之神", "布耶尔" ],
|
||||
"burstCD": 13.5,
|
||||
"id": "10000073",
|
||||
"name": "纳西妲",
|
||||
@@ -555,7 +555,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "莱依拉", "Layla", "layla", "拉一拉", "莱依菈", "来依菈", "来依拉", "莱伊拉", "莱伊菈", "来伊拉", "来伊菈", "不眠不醒不可思议" ],
|
||||
"alias": [ "莱依拉", "Layla", "莱依菈", "来依菈", "来依拉" ],
|
||||
"burstCD": 12.0,
|
||||
"id": "10000074",
|
||||
"name": "莱依拉",
|
||||
@@ -564,7 +564,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "流浪者", "The Wanderer", "Wanderer", "wanderer", "散兵", "伞兵", "斯卡拉姆齐", "国崩", "倾奇者", "崩崩小圆帽", "阿帽" ],
|
||||
"alias": [ "流浪者", "Wanderer", "散兵", "国崩", "雷电国崩", "大炮", "雷电大炮", "雷大炮", "伞兵", "斯卡拉姆齐" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000075",
|
||||
"name": "流浪者",
|
||||
@@ -573,7 +573,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "珐露珊", "Faruzan", "faruzan", "法露珊", "发露珊", "法露姗", "发露姗", "发姐", "法姐", "百岁珊", "前辈", "甜妹", "初音未来" ],
|
||||
"alias": [ "珐露珊", "Faruzan", "法露珊", "法璐珊", "法露姗", "法璐姗", "珐露姗", "珐璐姗", "百岁珊", "百岁山", "前辈", "仙贝" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000076",
|
||||
"name": "珐露珊",
|
||||
@@ -582,7 +582,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "瑶瑶", "Yaoyao", "yaoyao", "遥遥" ],
|
||||
"alias": [ "瑶瑶", "Yaoyao", "遥遥", "萝卜", "月桂" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000077",
|
||||
"name": "瑶瑶",
|
||||
@@ -591,7 +591,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "艾尔海森", "Alhaitham", "alhaitham", "爱尔海森", "艾尔海参", "艾尔", "海森", "海参", "海神", "大书记官" ],
|
||||
"alias": [ "艾尔海森", "Alhaitham", "海哥", "埃尔海森", "海森", "海参", "书记官" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000078",
|
||||
"name": "艾尔海森",
|
||||
@@ -600,7 +600,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "迪希雅", "Dehya", "dehya", "蒂西亚", "迪希亚", "西亚", "西雅", "希雅", "鬃狮", "希望工程", "炎拳" ],
|
||||
"alias": [ "迪希雅", "Dehya", "迪希亚", "迪希娅", "迪西雅", "迪西亚" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000079",
|
||||
"name": "迪希雅",
|
||||
@@ -609,7 +609,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "米卡", "Mika", "mika", "米咖", "鹦鹉", "鹦鹉头", "玄凤鹦鹉" ],
|
||||
"alias": [ "米卡", "Mika", "鹦鹉", "凤头", "凤头鹦鹉" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000080",
|
||||
"name": "米卡",
|
||||
@@ -618,7 +618,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "卡维", "Kaveh", "kaveh", "艾尔海森室友", "室友", "建筑设计师", "设计师", "优秀校友" ],
|
||||
"alias": [ "卡维", "Kaveh", "艾尔海森室友" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000081",
|
||||
"name": "卡维",
|
||||
@@ -627,7 +627,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "白术", "Baizhu", "baizhu", "长生", "白术哥哥", "白先生", "白大夫", "白医生", "白求恩", "蛇架子", "白绳子" ],
|
||||
"alias": [ "白术", "Baizhu", "长生", "白医生" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000082",
|
||||
"name": "白术",
|
||||
@@ -636,7 +636,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "琳妮特", "Lynette", "lynette", "林妮特", "林尼特", "琳尼特", "魔术助手", "魔术助理", "助手", "助理", "二姐", "二妹", "登登", "噔噔", "锵锵", "枫丹猫猫" ],
|
||||
"alias": [ "琳妮特", "Lynette", "林妮特", "林尼特", "琳尼特", "女魔术师", "魔术猫", "魔术喵", "登登" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000083",
|
||||
"name": "琳妮特",
|
||||
@@ -645,7 +645,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "林尼", "Lyney", "lyney", "大魔术师", "魔术师", "大哥" ],
|
||||
"alias": [ "林尼", "Lyney", "林妮", "琳尼", "琳妮", "男魔术师", "魔术师" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000084",
|
||||
"name": "林尼",
|
||||
@@ -654,7 +654,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "菲米尼", "Freminet", "freminet", "非米尼", "潜水员", "三弟", "企鹅" ],
|
||||
"alias": [ "菲米尼", "Freminet", "非米尼", "潜水员" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000085",
|
||||
"name": "菲米尼",
|
||||
@@ -663,7 +663,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "莱欧斯利", "Wriothesley", "wriothesley", "莱欧斯里", "来欧斯利", "来欧斯里", "梅洛彼得堡的管理者", "监狱管理者", "公爵", "典狱长", "监狱长", "狱长", "欧拉欧拉", "空条承太郎", "承太郎", "白金之星", "冰拳", "厂长" ],
|
||||
"alias": [ "莱欧斯利", "Wriothesley", "莱欧", "枫丹桑博", "公爵" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000086",
|
||||
"name": "莱欧斯利",
|
||||
@@ -672,7 +672,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "那维莱特", "Neuvillette", "neuvillette", "那维来特", "那维莱獭", "那维来獭", "那维", "审判官", "最高审判官", "美露莘爸爸", "男美露莘", "水龙", "水龙王", "海獭", "水獭", "龙王", "那位来客" ],
|
||||
"alias": [ "那维莱特", "Neuvillette", "那维", "水龙王", "水龙", "审判官", "海獭", "龙王", "最高审判官", "水之龙王" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000087",
|
||||
"name": "那维莱特",
|
||||
@@ -681,7 +681,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "夏洛蒂", "Charlotte", "charlotte", "夏洛特", "夏洛", "记者", "小记者", "蒸汽鸟报记者", "鸟记者", "狗仔队", "跑得快", "战地记者" ],
|
||||
"alias": [ "夏洛蒂", "Charlotte", "夏洛", "夏洛帝", "记者", "小记者", "佳能400D", "400D" ],
|
||||
"burstCD": 20.0,
|
||||
"id": "10000088",
|
||||
"name": "夏洛蒂",
|
||||
@@ -691,7 +691,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "芙宁娜", "Furina", "furina", "芙卡洛斯", "水神", "芙宁娜女士", "大明星", "演员", "芙芙", "傻芙芙", "罪人", "假水神", "水的女儿", "白芙", "黑芙" ],
|
||||
"alias": [ "芙宁娜", "Furina", "Focalors", "水神", "芙芙", "芙卡洛斯", "傻芙芙" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000089",
|
||||
"name": "芙宁娜",
|
||||
@@ -700,7 +700,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "夏沃蕾", "Chevreuse", "chevreuse", "夏沃雷", "特巡队队长", "特巡队长", "枫丹帕姆", "枫丹西琳", "火枪", "火铳" ],
|
||||
"alias": [ "夏沃蕾", "chevreuse", "夏沃雷" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000090",
|
||||
"name": "夏沃蕾",
|
||||
@@ -709,7 +709,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "娜维娅", "Navia", "navia", "娜维雅", "娜维亚", "刺玫会会长", "会长", "老板", "领导", "总指挥", "大小姐", "流汗黄豆", "黄豆姐", "炮姐", "黄玫瑰", "迈勒斯", "西尔弗" ],
|
||||
"alias": [ "娜维娅", "navia", "大小姐", "刺玫会", "黄豆", "流汗黄豆", "黄豆姐", "娜薇娅", "娜薇雅", "娜维雅" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000091",
|
||||
"name": "娜维娅",
|
||||
@@ -718,7 +718,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "嘉明", "Gaming", "gaming", "佳明", "嘉铭", "镖师", "威水舞兽", "威水舞兽话事人", "舞狮少年", "雄狮少年", "嘉乐" ],
|
||||
"alias": [ "嘉明", "Gaming", "jiaming", "佳明", "嘉铭", "家明", "镖师", "舞狮少年", "舞狮" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000092",
|
||||
"name": "嘉明",
|
||||
@@ -727,7 +727,7 @@
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "闲云", "Xianyun", "xianyun", "留云", "流云", "留云借风", "留云借风真君", "仙鹤", "仙鸟", "那个女人", "哪个女人", "那只鸟", "那只鸡", "闲云阿姨", "机关仙人", "很会聊天真君", "很会说话真君", "两块禽肉真君", "鸟人" ],
|
||||
"alias": [ "闲云", "Xianyun", "流云", "刘云", "留云", "野鹤", "那个女人", "留云借风", "留云借风真君", "很会聊天", "很会聊天真君" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000093",
|
||||
"name": "闲云",
|
||||
@@ -736,7 +736,7 @@
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "千织", "Chiori", "chiori", "老板娘", "裁锦师", "裁缝" ],
|
||||
"alias": [ "千织", "Chiori", "千只", "设计师", "裁缝", "千织屋老板" ],
|
||||
"burstCD": 13.5,
|
||||
"id": "10000094",
|
||||
"name": "千织",
|
||||
@@ -763,7 +763,7 @@
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "赛索斯", "Sethos", "丁真" ],
|
||||
"alias": [ "赛索斯", "Sethos", "塞索斯", "塞索思", "赛索思" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000097",
|
||||
"name": "赛索斯",
|
||||
@@ -772,7 +772,7 @@
|
||||
"weapon": "12"
|
||||
},
|
||||
{
|
||||
"alias": [ "克洛琳德", "Clorinde", "科洛琳德", "克洛林德", "美玉", "美玉学姐", "学姐" ],
|
||||
"alias": [ "克洛琳德", "Clorinde", "琳德", "科洛琳德", "克洛林德", "克罗林德", "苹果姐" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000098",
|
||||
"name": "克洛琳德",
|
||||
@@ -781,7 +781,7 @@
|
||||
"weapon": "1"
|
||||
},
|
||||
{
|
||||
"alias": [ "艾梅莉埃", "Emilie", "调香师", "艾梅" ],
|
||||
"alias": [ "艾梅莉埃", "Emilie", "调香师", "艾梅", "香水设计师", "现场清理人" ],
|
||||
"burstCD": 13.5,
|
||||
"id": "10000099",
|
||||
"name": "艾梅莉埃",
|
||||
@@ -789,5 +789,42 @@
|
||||
"skillCD": 10.0,
|
||||
"skillHoldCD": 14.0,
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "卡齐娜", "Kachina", "卡奇娜", "卡齐纳", "卡齐那", "卡其那", "冲天钻钻" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000100",
|
||||
"name": "卡齐娜",
|
||||
"nameEn": "Kachina",
|
||||
"skillCD": 20.0,
|
||||
"weapon": "13"
|
||||
},
|
||||
{
|
||||
"alias": [ "基尼奇", "Kinich", "基哥", "基尼齐" ],
|
||||
"burstCD": 18.0,
|
||||
"id": "10000101",
|
||||
"name": "基尼奇",
|
||||
"nameEn": "Kinich",
|
||||
"skillCD": 18.0,
|
||||
"weapon": "11"
|
||||
},
|
||||
{
|
||||
"alias": [ "玛拉妮", "Mualani", "马拉尼", "鲨鱼妹", "海豹妹", "海豹", "纳塔鲨" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000102",
|
||||
"name": "玛拉妮",
|
||||
"nameEn": "Mualani",
|
||||
"skillCD": 1.8,
|
||||
"skillHoldCD": 6.0,
|
||||
"weapon": "10"
|
||||
},
|
||||
{
|
||||
"alias": [ "希诺宁", "Xilonen", "豹女", "岩大猫", "大岩猫", "岩猫", "岩猫猫", "西诺宁" ],
|
||||
"burstCD": 15.0,
|
||||
"id": "10000103",
|
||||
"name": "希诺宁",
|
||||
"nameEn": "Xilonen",
|
||||
"skillCD": 7.0,
|
||||
"weapon": "1"
|
||||
}
|
||||
]
|
||||
@@ -15,4 +15,16 @@ public partial class AutoFightConfig : ObservableObject
|
||||
/// 英文逗号分割 强制指定队伍角色
|
||||
/// </summary>
|
||||
[ObservableProperty] private string _teamNames = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测战斗结束
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _fightFinishDetectEnabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// 检测战斗结束
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _pickDropsAfterFightEnabled = true;
|
||||
}
|
||||
@@ -1,14 +1,12 @@
|
||||
using BetterGenshinImpact.GameTask.Model;
|
||||
using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
public class AutoFightParam : BaseTaskParam
|
||||
public class AutoFightParam(string path) : BaseTaskParam
|
||||
{
|
||||
public string CombatStrategyPath { get; set; }
|
||||
public string CombatStrategyPath { get; set; } = path;
|
||||
|
||||
public AutoFightParam(CancellationTokenSource cts, string path) : base(cts)
|
||||
{
|
||||
CombatStrategyPath = path;
|
||||
}
|
||||
public bool FightFinishDetectEnabled { get; set; } = false;
|
||||
|
||||
public bool PickDropsAfterFightEnabled { get; set; } = false;
|
||||
}
|
||||
@@ -1,107 +1,120 @@
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Assets;
|
||||
using BetterGenshinImpact.Core.Recognition.ONNX;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Model;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Script;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.Model.Enum;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using BetterGenshinImpact.GameTask.AutoPathing;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoFight;
|
||||
|
||||
public class AutoFightTask
|
||||
public class AutoFightTask : ISoloTask
|
||||
{
|
||||
public string Name => "自动战斗";
|
||||
|
||||
private readonly AutoFightParam _taskParam;
|
||||
|
||||
private readonly CombatScriptBag _combatScriptBag;
|
||||
|
||||
private CancellationToken _ct;
|
||||
|
||||
private readonly BgiYoloV8Predictor _predictor;
|
||||
|
||||
private DateTime _lastFightFlagTime = DateTime.Now; // 战斗标志最近一次出现的时间
|
||||
|
||||
public AutoFightTask(AutoFightParam taskParam)
|
||||
{
|
||||
_taskParam = taskParam;
|
||||
_combatScriptBag = CombatScriptParser.ReadAndParse(_taskParam.CombatStrategyPath);
|
||||
|
||||
if (_taskParam.FightFinishDetectEnabled)
|
||||
{
|
||||
_predictor = new BgiYoloV8Predictor(@"Assets\Model\World\bgi_world.onnx");
|
||||
}
|
||||
}
|
||||
|
||||
public async void Start()
|
||||
public async Task Start(CancellationToken ct)
|
||||
{
|
||||
var hasLock = false;
|
||||
try
|
||||
_ct = ct;
|
||||
|
||||
LogScreenResolution();
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
if (!combatScenes.CheckTeamInitialized())
|
||||
{
|
||||
AutoFightAssets.DestroyInstance();
|
||||
hasLock = await TaskSemaphore.WaitAsync(0);
|
||||
if (!hasLock)
|
||||
throw new Exception("识别队伍角色失败");
|
||||
}
|
||||
|
||||
var combatCommands = _combatScriptBag.FindCombatScript(combatScenes.Avatars);
|
||||
|
||||
// 新的取消token
|
||||
var cts2 = new CancellationTokenSource();
|
||||
ct.Register(cts2.Cancel);
|
||||
|
||||
combatScenes.BeforeTask(cts2.Token);
|
||||
|
||||
// 战斗操作
|
||||
var fightTask = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
while (!cts2.Token.IsCancellationRequested)
|
||||
{
|
||||
// 通用化战斗策略
|
||||
foreach (var command in combatCommands)
|
||||
{
|
||||
command.Execute(combatScenes);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e.Message);
|
||||
Debug.WriteLine(e.StackTrace);
|
||||
}
|
||||
}, cts2.Token);
|
||||
|
||||
// 战斗结束检测线程
|
||||
var endTask = Task.Run(async () =>
|
||||
{
|
||||
if (!_taskParam.FightFinishDetectEnabled)
|
||||
{
|
||||
Logger.LogError("启动自动战斗功能失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
return;
|
||||
}
|
||||
|
||||
Init();
|
||||
var combatScenes = new CombatScenes().InitializeTeam(CaptureToRectArea());
|
||||
if (!combatScenes.CheckTeamInitialized())
|
||||
try
|
||||
{
|
||||
throw new Exception("识别队伍角色失败");
|
||||
}
|
||||
var combatCommands = _combatScriptBag.FindCombatScript(combatScenes.Avatars);
|
||||
|
||||
combatScenes.BeforeTask(_taskParam.Cts);
|
||||
|
||||
// 战斗操作
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
while (!cts2.IsCancellationRequested)
|
||||
{
|
||||
while (!_taskParam.Cts.Token.IsCancellationRequested)
|
||||
var finish = await CheckFightFinish();
|
||||
if (finish)
|
||||
{
|
||||
// 通用化战斗策略
|
||||
foreach (var command in combatCommands)
|
||||
{
|
||||
command.Execute(combatScenes);
|
||||
}
|
||||
await cts2.CancelAsync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (NormalEndException)
|
||||
{
|
||||
Logger.LogInformation("战斗操作结束");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogWarning(e.Message);
|
||||
throw;
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (NormalEndException)
|
||||
{
|
||||
Logger.LogInformation("手动中断自动战斗");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e.Message);
|
||||
Logger.LogDebug(e.StackTrace);
|
||||
}
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.NormalTrigger);
|
||||
TaskSettingsPageViewModel.SetSwitchAutoFightButtonText(false);
|
||||
Logger.LogInformation("→ {Text}", "自动战斗结束");
|
||||
|
||||
if (hasLock)
|
||||
{
|
||||
TaskSemaphore.Release();
|
||||
Sleep(1000, cts2.Token);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.WriteLine(e.Message);
|
||||
Debug.WriteLine(e.StackTrace);
|
||||
}
|
||||
}, cts2.Token);
|
||||
|
||||
private void Init()
|
||||
{
|
||||
LogScreenResolution();
|
||||
Logger.LogInformation("→ {Text}", "自动战斗,启动!");
|
||||
SystemControl.ActivateWindow();
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.CacheCaptureWithTrigger);
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 5, _taskParam.Cts); // 等待缓存图像
|
||||
await Task.WhenAll(fightTask, endTask);
|
||||
|
||||
if (_taskParam is { FightFinishDetectEnabled: true, PickDropsAfterFightEnabled: true })
|
||||
{
|
||||
// 执行自动拾取掉落物的功能
|
||||
}
|
||||
}
|
||||
|
||||
private void LogScreenResolution()
|
||||
@@ -112,4 +125,47 @@ public class AutoFightTask
|
||||
Logger.LogWarning("游戏窗口分辨率不是 16:9 !当前分辨率为 {Width}x{Height} , 非 16:9 分辨率的游戏可能无法正常使用自动战斗功能 !", gameScreenSize.Width, gameScreenSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> CheckFightFinish()
|
||||
{
|
||||
// YOLO 判断血条和怪物位置
|
||||
if (HasFightFlag(CaptureToRectArea()))
|
||||
{
|
||||
_lastFightFlagTime = DateTime.Now;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 几秒内没有检测到血条和怪物位置,则开始旋转视角重新检测
|
||||
if ((DateTime.Now - _lastFightFlagTime).TotalSeconds > 5)
|
||||
{
|
||||
// 旋转完毕后都没有检测到血条和怪物位置,则按L键确认战斗结束
|
||||
List<int> angles = [0, 90, 180, 270];
|
||||
var rotateTask = new CameraRotateTask(_ct);
|
||||
foreach (var a in angles)
|
||||
{
|
||||
await rotateTask.WaitUntilRotatedTo(a, 5, 30);
|
||||
await Delay(1000, _ct!); // 等待视角稳定
|
||||
if (HasFightFlag(CaptureToRectArea()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 最终方案确认战斗结束
|
||||
Logger.LogInformation("识别到战斗结束");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool HasFightFlag(ImageRegion imageRegion)
|
||||
{
|
||||
// if (RuntimeHelper.IsDebug)
|
||||
// {
|
||||
// imageRegion.SrcMat.SaveImage(Global.Absolute(@"log\fight\" + $"{DateTime.Now:yyyyMMdd_HHmmss_ffff}.png"));
|
||||
// }
|
||||
var dict = _predictor.Detect(imageRegion);
|
||||
return dict.ContainsKey("health_bar") || dict.ContainsKey("enemy_identify");
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class DefaultAutoFightConfig
|
||||
static DefaultAutoFightConfig()
|
||||
{
|
||||
var json = File.ReadAllText(Global.Absolute(@"GameTask\AutoFight\Assets\combat_avatar.json"));
|
||||
var config = JsonSerializer.Deserialize<List<CombatAvatar>>(json, ConfigService.JsonOptions);
|
||||
var config = Newtonsoft.Json.JsonConvert.DeserializeObject<List<CombatAvatar>>(json);
|
||||
CombatAvatars = config ?? throw new Exception("combat_avatar.json deserialize failed");
|
||||
CombatAvatarNames = config.Select(x => x.Name).ToList();
|
||||
CombatAvatarMap = config.ToDictionary(x => x.Name);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using BetterGenshinImpact.Core.Recognition.OCR;
|
||||
using BetterGenshinImpact.Core.Recognition.OpenCv;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Config;
|
||||
@@ -7,8 +8,11 @@ using BetterGenshinImpact.Helpers;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using BetterGenshinImpact.GameTask.AutoTrackPath;
|
||||
using BetterGenshinImpact.GameTask.Common.BgiVision;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
@@ -72,7 +76,7 @@ public class Avatar
|
||||
/// <summary>
|
||||
/// 任务取消令牌
|
||||
/// </summary>
|
||||
public CancellationTokenSource? Cts { get; set; }
|
||||
public CancellationToken Ct { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 战斗场景
|
||||
@@ -102,13 +106,18 @@ public class Avatar
|
||||
/// <returns></returns>
|
||||
public void ThrowWhenDefeated(ImageRegion region)
|
||||
{
|
||||
using var confirmRectArea = region.Find(AutoFightContext.Instance.FightAssets.ConfirmRa);
|
||||
if (!confirmRectArea.IsEmpty())
|
||||
if (Bv.IsInRevivePrompt(region))
|
||||
{
|
||||
Logger.LogWarning("检测到复苏界面,存在角色被击败,前往七天神像复活");
|
||||
// 先打开地图
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_ESCAPE);
|
||||
Sleep(600, Cts);
|
||||
Sleep(600, Ct);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_M);
|
||||
throw new Exception("存在角色被击败,按 M 键打开地图,并停止自动秘境。");
|
||||
// tp 到七天神像复活
|
||||
var tpTask = new TpTask(Ct);
|
||||
tpTask.Tp(TpTask.ReviveStatueOfTheSevenPointX, TpTask.ReviveStatueOfTheSevenPointY, true).Wait(Ct);
|
||||
|
||||
throw new Exception("检测到复苏界面,存在角色被击败,前往七天神像复活");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +129,7 @@ public class Avatar
|
||||
{
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
if (Cts is { IsCancellationRequested: true })
|
||||
if (Ct is { IsCancellationRequested: true })
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -129,18 +138,55 @@ public class Avatar
|
||||
ThrowWhenDefeated(region);
|
||||
|
||||
var notActiveCount = CombatScenes.Avatars.Count(avatar => !avatar.IsActive(region));
|
||||
if (IsActive(region) && notActiveCount == 3)
|
||||
if (IsActive(region) && notActiveCount == CombatScenes.ExpectedTeamAvatarNum - 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_1 + (byte)Index - 1);
|
||||
// Debug.WriteLine($"切换到{Index}号位");
|
||||
// Cv2.ImWrite($"log/切换.png", content.CaptureRectArea.SrcMat);
|
||||
Sleep(250, Cts);
|
||||
// Cv2.ImWrite($"log/切换.png", region.SrcMat);
|
||||
Sleep(250, Ct);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试切换到本角色
|
||||
/// </summary>
|
||||
/// <param name="tryTimes"></param>
|
||||
/// <param name="needLog"></param>
|
||||
/// <returns></returns>
|
||||
public bool TrySwitch(int tryTimes = 4, bool needLog = true)
|
||||
{
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
if (Ct is { IsCancellationRequested: true })
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var region = CaptureToRectArea();
|
||||
ThrowWhenDefeated(region);
|
||||
|
||||
var notActiveCount = CombatScenes.Avatars.Count(avatar => !avatar.IsActive(region));
|
||||
if (IsActive(region) && notActiveCount == CombatScenes.ExpectedTeamAvatarNum - 1)
|
||||
{
|
||||
if (needLog && i > 0)
|
||||
{
|
||||
Logger.LogInformation("成功切换角色:{Name}", Name);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_1 + (byte)Index - 1);
|
||||
|
||||
Sleep(250, Ct);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换到本角色
|
||||
/// 切换cd是1秒,如果切换失败,会尝试再次切换,最多尝试5次
|
||||
@@ -248,14 +294,14 @@ public class Avatar
|
||||
{
|
||||
while (ms >= 0)
|
||||
{
|
||||
if (Cts is { IsCancellationRequested: true })
|
||||
if (Ct is { IsCancellationRequested: true })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AutoFightContext.Instance.Simulator.LeftButtonClick();
|
||||
ms -= 200;
|
||||
Sleep(200, Cts);
|
||||
Sleep(200, Ct);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +312,7 @@ public class Avatar
|
||||
{
|
||||
for (var i = 0; i < 1; i++)
|
||||
{
|
||||
if (Cts is { IsCancellationRequested: true })
|
||||
if (Ct is { IsCancellationRequested: true })
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -276,7 +322,7 @@ public class Avatar
|
||||
if (Name == "纳西妲")
|
||||
{
|
||||
AutoFightContext.Instance.Simulator.KeyDown(User32.VK.VK_E);
|
||||
Sleep(300, Cts);
|
||||
Sleep(300, Ct);
|
||||
for (int j = 0; j < 10; j++)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(1000, 0);
|
||||
@@ -296,7 +342,7 @@ public class Avatar
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_E);
|
||||
}
|
||||
|
||||
Sleep(200, Cts);
|
||||
Sleep(200, Ct);
|
||||
|
||||
var region = CaptureToRectArea();
|
||||
ThrowWhenDefeated(region);
|
||||
@@ -331,13 +377,13 @@ public class Avatar
|
||||
// var isBurstReleased = false;
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
if (Cts is { IsCancellationRequested: true })
|
||||
if (Ct is { IsCancellationRequested: true })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AutoFightContext.Instance.Simulator.KeyPress(User32.VK.VK_Q);
|
||||
Sleep(200, Cts);
|
||||
Sleep(200, Ct);
|
||||
|
||||
var region = CaptureToRectArea();
|
||||
ThrowWhenDefeated(region);
|
||||
@@ -345,7 +391,7 @@ public class Avatar
|
||||
if (notActiveCount == 0)
|
||||
{
|
||||
// isBurstReleased = true;
|
||||
Sleep(1500, Cts);
|
||||
Sleep(1500, Ct);
|
||||
return;
|
||||
}
|
||||
// else
|
||||
@@ -381,7 +427,7 @@ public class Avatar
|
||||
/// </summary>
|
||||
public void Dash(int ms = 0)
|
||||
{
|
||||
if (Cts is { IsCancellationRequested: true })
|
||||
if (Ct is { IsCancellationRequested: true })
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -398,7 +444,7 @@ public class Avatar
|
||||
|
||||
public void Walk(string key, int ms)
|
||||
{
|
||||
if (Cts is { IsCancellationRequested: true })
|
||||
if (Ct is { IsCancellationRequested: true })
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -470,15 +516,16 @@ public class Avatar
|
||||
|
||||
if (Name == "那维莱特")
|
||||
{
|
||||
var dpi = TaskContext.Instance().DpiScale;
|
||||
AutoFightContext.Instance.Simulator.LeftButtonDown();
|
||||
while (ms >= 0)
|
||||
{
|
||||
if (Cts is { IsCancellationRequested: true })
|
||||
if (Ct is { IsCancellationRequested: true })
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(1000, 0);
|
||||
Simulation.SendInput.Mouse.MoveMouseBy((int)(1000 * dpi), 0);
|
||||
ms -= 50;
|
||||
Sleep(50); // 持续操作不应该被cts取消
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class CombatScenes : IDisposable
|
||||
/// <summary>
|
||||
/// 当前配队
|
||||
/// </summary>
|
||||
public Avatar[] Avatars { get; set; } = new Avatar[1];
|
||||
public Avatar[] Avatars { get; set; } = Array.Empty<Avatar>();
|
||||
|
||||
public Dictionary<string, Avatar> AvatarMap { get; set; } = [];
|
||||
|
||||
@@ -39,10 +39,12 @@ public class CombatScenes : IDisposable
|
||||
|
||||
private readonly YoloV8Predictor _predictor =
|
||||
YoloV8Builder.CreateDefaultBuilder()
|
||||
.UseOnnxModel(Global.Absolute("Assets\\Model\\Common\\avatar_side_classify_sim.onnx"))
|
||||
.UseOnnxModel(Global.Absolute(@"Assets\Model\Common\avatar_side_classify_sim.onnx"))
|
||||
.WithSessionOptions(BgiSessionOption.Instance.Options)
|
||||
.Build();
|
||||
|
||||
public int ExpectedTeamAvatarNum { get; private set; } = 4;
|
||||
|
||||
/// <summary>
|
||||
/// 通过YOLO分类器识别队伍内角色
|
||||
/// </summary>
|
||||
@@ -56,14 +58,49 @@ public class CombatScenes : IDisposable
|
||||
return this;
|
||||
}
|
||||
|
||||
// 判断当前是否处于联机状态
|
||||
List<Rect> avatarSideIconRectList;
|
||||
List<Rect> avatarIndexRectList;
|
||||
var pRaList = imageRegion.FindMulti(AutoFightAssets.Instance.PRa);
|
||||
if (pRaList.Count > 0)
|
||||
{
|
||||
var num = pRaList.Count + 1;
|
||||
if (num > 4)
|
||||
{
|
||||
throw new Exception("当前处于联机状态,但是队伍人数超过4人,无法识别");
|
||||
}
|
||||
// 联机状态下判断
|
||||
var onePRa = imageRegion.Find(AutoFightAssets.Instance.OnePRa);
|
||||
var p = "p";
|
||||
if (onePRa.IsEmpty())
|
||||
{
|
||||
Logger.LogInformation("当前处于联机状态,且当前账号是房主,联机人数{Num}人", num);
|
||||
p = "1p";
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogInformation("当前处于联机状态,且在别人世界中,联机人数{Num}人", num);
|
||||
}
|
||||
|
||||
avatarSideIconRectList = AutoFightAssets.Instance.AvatarSideIconRectListMap[$"{p}_{num}"];
|
||||
avatarIndexRectList = AutoFightAssets.Instance.AvatarIndexRectListMap[$"{p}_{num}"];
|
||||
|
||||
ExpectedTeamAvatarNum = avatarSideIconRectList.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
avatarSideIconRectList = AutoFightAssets.Instance.AvatarSideIconRectList;
|
||||
avatarIndexRectList = AutoFightAssets.Instance.AvatarIndexRectList;
|
||||
}
|
||||
|
||||
// 识别队伍
|
||||
var names = new string[4];
|
||||
var displayNames = new string[4];
|
||||
var names = new string[avatarSideIconRectList.Count];
|
||||
var displayNames = new string[avatarSideIconRectList.Count];
|
||||
try
|
||||
{
|
||||
for (var i = 0; i < AutoFightAssets.Instance.AvatarSideIconRectList.Count; i++)
|
||||
for (var i = 0; i < avatarSideIconRectList.Count; i++)
|
||||
{
|
||||
var ra = imageRegion.DeriveCrop(AutoFightAssets.Instance.AvatarSideIconRectList[i]);
|
||||
var ra = imageRegion.DeriveCrop(avatarSideIconRectList[i]);
|
||||
var pair = ClassifyAvatarCnName(ra.SrcBitmap, i + 1);
|
||||
names[i] = pair.Item1;
|
||||
if (!string.IsNullOrEmpty(pair.Item2))
|
||||
@@ -81,14 +118,16 @@ public class CombatScenes : IDisposable
|
||||
displayNames[i] = pair.Item1;
|
||||
}
|
||||
}
|
||||
|
||||
Logger.LogInformation("识别到的队伍角色:{Text}", string.Join(",", displayNames));
|
||||
Avatars = BuildAvatars([.. names]);
|
||||
Avatars = BuildAvatars([.. names], null, avatarIndexRectList);
|
||||
AvatarMap = Avatars.ToDictionary(x => x.Name);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogWarning(e.Message);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -164,7 +203,7 @@ public class CombatScenes : IDisposable
|
||||
|
||||
public bool CheckTeamInitialized()
|
||||
{
|
||||
if (Avatars.Length < 4)
|
||||
if (Avatars.Length != ExpectedTeamAvatarNum)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -172,8 +211,18 @@ public class CombatScenes : IDisposable
|
||||
return true;
|
||||
}
|
||||
|
||||
private Avatar[] BuildAvatars(List<string> names, List<Rect>? nameRects = null)
|
||||
private Avatar[] BuildAvatars(List<string> names, List<Rect>? nameRects = null, List<Rect>? avatarIndexRectList = null)
|
||||
{
|
||||
if (avatarIndexRectList == null && ExpectedTeamAvatarNum == 4)
|
||||
{
|
||||
avatarIndexRectList = AutoFightContext.Instance.FightAssets.AvatarIndexRectList;
|
||||
}
|
||||
|
||||
if (avatarIndexRectList == null)
|
||||
{
|
||||
throw new Exception("联机状态下,此方法必须传入队伍角色编号位置信息");
|
||||
}
|
||||
|
||||
AvatarCount = names.Count;
|
||||
var avatars = new Avatar[AvatarCount];
|
||||
for (var i = 0; i < AvatarCount; i++)
|
||||
@@ -181,24 +230,24 @@ public class CombatScenes : IDisposable
|
||||
var nameRect = nameRects?[i] ?? Rect.Empty;
|
||||
avatars[i] = new Avatar(this, names[i], i + 1, nameRect)
|
||||
{
|
||||
IndexRect = AutoFightContext.Instance.FightAssets.AvatarIndexRectList[i]
|
||||
IndexRect = avatarIndexRectList[i]
|
||||
};
|
||||
}
|
||||
|
||||
return avatars;
|
||||
}
|
||||
|
||||
public void BeforeTask(CancellationTokenSource cts)
|
||||
public void BeforeTask(CancellationToken ct)
|
||||
{
|
||||
for (var i = 0; i < AvatarCount; i++)
|
||||
{
|
||||
Avatars[i].Cts = cts;
|
||||
Avatars[i].Ct = ct;
|
||||
}
|
||||
}
|
||||
|
||||
public Avatar? SelectAvatar(string name)
|
||||
{
|
||||
return AvatarMap.TryGetValue(name, out var avatar) ? avatar : null;
|
||||
return AvatarMap.GetValueOrDefault(name);
|
||||
}
|
||||
|
||||
#region OCR识别队伍(已弃用)
|
||||
|
||||
@@ -53,7 +53,7 @@ public class OneKeyFightTask : Singleton<OneKeyFightTask>
|
||||
if (_cts == null || _cts.Token.IsCancellationRequested)
|
||||
{
|
||||
_cts = new CancellationTokenSource();
|
||||
_fightTask = FightTask(_cts);
|
||||
_fightTask = FightTask(_cts.Token);
|
||||
if (!_fightTask.IsCompleted)
|
||||
{
|
||||
_fightTask.Start();
|
||||
@@ -65,7 +65,7 @@ public class OneKeyFightTask : Singleton<OneKeyFightTask>
|
||||
if (_cts == null || _cts.Token.IsCancellationRequested)
|
||||
{
|
||||
_cts = new CancellationTokenSource();
|
||||
_fightTask = FightTask(_cts);
|
||||
_fightTask = FightTask(_cts.Token);
|
||||
if (!_fightTask.IsCompleted)
|
||||
{
|
||||
_fightTask.Start();
|
||||
@@ -126,14 +126,14 @@ public class OneKeyFightTask : Singleton<OneKeyFightTask>
|
||||
/// <summary>
|
||||
/// 循环执行战斗宏
|
||||
/// </summary>
|
||||
private Task FightTask(CancellationTokenSource cts)
|
||||
private Task FightTask(CancellationToken ct)
|
||||
{
|
||||
// 切换截图模式
|
||||
var dispatcherCaptureMode = TaskTriggerDispatcher.Instance().GetCacheCaptureMode();
|
||||
if (dispatcherCaptureMode != DispatcherCaptureModeEnum.CacheCaptureWithTrigger)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().SetCacheCaptureMode(DispatcherCaptureModeEnum.CacheCaptureWithTrigger);
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 2, cts); // 等待缓存图像
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 2, ct); // 等待缓存图像
|
||||
}
|
||||
|
||||
var imageRegion = CaptureToRectArea();
|
||||
@@ -162,7 +162,7 @@ public class OneKeyFightTask : Singleton<OneKeyFightTask>
|
||||
return new Task(() =>
|
||||
{
|
||||
Logger.LogInformation("→ {Name}执行宏", activeAvatar.Name);
|
||||
while (!cts.Token.IsCancellationRequested && IsEnabled())
|
||||
while (!ct.IsCancellationRequested && IsEnabled())
|
||||
{
|
||||
if (IsHoldOnMode() && !_isKeyDown)
|
||||
{
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing
|
||||
{
|
||||
private readonly ILogger<AutoFishingTrigger> _logger = App.GetLogger<AutoFishingTrigger>();
|
||||
private readonly IOcrService _ocrService = OcrFactory.Paddle;
|
||||
private readonly YoloV8Predictor _predictor = YoloV8Builder.CreateDefaultBuilder().UseOnnxModel(Global.Absolute("Assets\\Model\\Fish\\bgi_fish.onnx")).WithSessionOptions(BgiSessionOption.Instance.Options).Build();
|
||||
private readonly YoloV8Predictor _predictor = YoloV8Builder.CreateDefaultBuilder().UseOnnxModel(Global.Absolute(@"Assets\Model\Fish\bgi_fish.onnx")).WithSessionOptions(BgiSessionOption.Instance.Options).Build();
|
||||
|
||||
public string Name => "自动钓鱼";
|
||||
public bool IsEnabled { get; set; }
|
||||
@@ -382,7 +382,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing
|
||||
}.InitTemplate();
|
||||
|
||||
// 截图
|
||||
using var captureRegion = TaskControl.CaptureToRectArea();
|
||||
using var captureRegion = TaskControl.CaptureToRectArea(forceNew: true);
|
||||
using var resRa = captureRegion.Find(ro);
|
||||
if (resRa.IsEmpty())
|
||||
{
|
||||
@@ -425,7 +425,7 @@ namespace BetterGenshinImpact.GameTask.AutoFishing
|
||||
while (IsEnabled)
|
||||
{
|
||||
// 截图
|
||||
var ra = TaskControl.CaptureToRectArea();
|
||||
var ra = TaskControl.CaptureToRectArea(forceNew: true);
|
||||
|
||||
// 找 鱼饵落点
|
||||
using var memoryStream = new MemoryStream();
|
||||
|
||||
@@ -781,6 +781,75 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1112,
|
||||
"nameEn": "freminet",
|
||||
"type": "character",
|
||||
"name": "菲米尼",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "冰元素",
|
||||
"weapon": "双手剑",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "flowing_eddies",
|
||||
"name": "洑流剑",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "pressurized_floe",
|
||||
"name": "浮冰增压",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "shadowhunters_ambush",
|
||||
"name": "猎影潜袭",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1101,
|
||||
"nameEn": "cryo",
|
||||
"type": "冰元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1201,
|
||||
"nameEn": "barbara",
|
||||
@@ -3888,6 +3957,75 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1510,
|
||||
"nameEn": "xianyun",
|
||||
"type": "character",
|
||||
"name": "闲云",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "风元素",
|
||||
"weapon": "法器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "word_of_wind_and_flower",
|
||||
"name": "清风散花词",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1105,
|
||||
"nameEn": "anemo",
|
||||
"type": "风元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "white_clouds_at_dawn",
|
||||
"name": "朝起鹤云",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1105,
|
||||
"nameEn": "anemo",
|
||||
"type": "风元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "stars_gather_at_dusk",
|
||||
"name": "暮集竹星",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1105,
|
||||
"nameEn": "anemo",
|
||||
"type": "风元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1601,
|
||||
"nameEn": "ningguang",
|
||||
@@ -4463,6 +4601,75 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1609,
|
||||
"nameEn": "chiori",
|
||||
"type": "character",
|
||||
"name": "千织",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "岩元素",
|
||||
"weapon": "单手剑",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "weaving_blade",
|
||||
"name": "心织刀流",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "fluttering_hasode",
|
||||
"name": "羽袖一触",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "hiyoku_twin_blades",
|
||||
"name": "二刀之形·比翼",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1106,
|
||||
"nameEn": "geo",
|
||||
"type": "岩元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 1701,
|
||||
"nameEn": "collei",
|
||||
@@ -5637,6 +5844,75 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2205,
|
||||
"nameEn": "hydro_hilichurl_rogue",
|
||||
"type": "character",
|
||||
"name": "丘丘水行游侠",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "水元素",
|
||||
"weapon": "其他武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "whirling_scythe",
|
||||
"name": "镰刀旋斩",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "slash_of_surging_tides",
|
||||
"name": "狂澜镰击",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "bubblefloat_blitz",
|
||||
"name": "浮泡攻势",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1102,
|
||||
"nameEn": "hydro",
|
||||
"type": "水元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2301,
|
||||
"nameEn": "fatui_pyro_agent",
|
||||
@@ -6322,6 +6598,83 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2406,
|
||||
"nameEn": "abyss_lector_violet_lightning",
|
||||
"type": "character",
|
||||
"name": "深渊咏者·紫电",
|
||||
"hp": 6,
|
||||
"energy": 2,
|
||||
"element": "雷元素",
|
||||
"weapon": "其他武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "den_of_thunder",
|
||||
"name": "渊薮落雷",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "shock_of_the_enigmatic_abyss",
|
||||
"name": "秘渊虚霆",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "wild_thunderburst",
|
||||
"name": "狂迸骇雷",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1104,
|
||||
"nameEn": "electro",
|
||||
"type": "雷元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "electric_rebirth",
|
||||
"name": "雷之新生",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2501,
|
||||
"nameEn": "maguu_kenki",
|
||||
@@ -6874,5 +7227,82 @@
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2703,
|
||||
"nameEn": "eremite_floral_ringdancer",
|
||||
"type": "character",
|
||||
"name": "镀金旅团·叶轮舞者",
|
||||
"hp": 10,
|
||||
"energy": 2,
|
||||
"element": "草元素",
|
||||
"weapon": "其他武器",
|
||||
"skills": [
|
||||
{
|
||||
"nameEn": "floralring_caress",
|
||||
"name": "叶轮轻扫",
|
||||
"skillTag": [
|
||||
"普通攻击"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"id": 1109,
|
||||
"nameEn": "unaligned_element",
|
||||
"type": "无色元素",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "spiraling_whirl",
|
||||
"name": "蔓延旋舞",
|
||||
"skillTag": [
|
||||
"元素战技"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "spirit_of_omens_awakening_dendro_spiritserpent",
|
||||
"name": "厄灵苏醒·草之灵蛇",
|
||||
"skillTag": [
|
||||
"元素爆发"
|
||||
],
|
||||
"cost": [
|
||||
{
|
||||
"id": 1107,
|
||||
"nameEn": "dendro",
|
||||
"type": "草元素",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"id": 1110,
|
||||
"nameEn": "energy",
|
||||
"type": "充能",
|
||||
"count": 2
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"nameEn": "spirit_of_omens_power",
|
||||
"name": "厄灵之能",
|
||||
"skillTag": [
|
||||
"被动技能"
|
||||
],
|
||||
"cost": []
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -1,15 +1,17 @@
|
||||
using BetterGenshinImpact.Helpers.Extensions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
|
||||
public class AutoGeniusInvokationTask
|
||||
public class AutoGeniusInvokationTask(GeniusInvokationTaskParam taskParam) : ISoloTask
|
||||
{
|
||||
public static void Start(GeniusInvokationTaskParam taskParam)
|
||||
public string Name => "自动七圣召唤";
|
||||
|
||||
public Task Start(CancellationToken ct)
|
||||
{
|
||||
TaskTriggerDispatcher.Instance().StopTimer();
|
||||
// 读取策略信息
|
||||
var duel = ScriptParser.Parse(taskParam.StrategyContent);
|
||||
SystemControl.ActivateWindow();
|
||||
duel.RunAsync(taskParam).SafeForget();
|
||||
duel.Run(ct);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,15 +61,15 @@ public class GeniusInvokationControl
|
||||
|
||||
public static bool OutputImageWhenError = true;
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
private CancellationToken _ct;
|
||||
|
||||
private readonly AutoGeniusInvokationAssets _assets = AutoGeniusInvokationAssets.Instance;
|
||||
|
||||
// private IGameCapture? _gameCapture;
|
||||
|
||||
public void Init(GeniusInvokationTaskParam taskParam)
|
||||
public void Init(CancellationToken ct)
|
||||
{
|
||||
_cts = taskParam.Cts;
|
||||
_ct = ct;
|
||||
// _gameCapture = taskParam.Dispatcher.GameCapture;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class GeniusInvokationControl
|
||||
{
|
||||
NewRetry.Do(() =>
|
||||
{
|
||||
if (_cts is { IsCancellationRequested: true })
|
||||
if (_ct is { IsCancellationRequested: true })
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class GeniusInvokationControl
|
||||
}
|
||||
}, TimeSpan.FromSeconds(1), 100);
|
||||
|
||||
if (_cts is { IsCancellationRequested: true })
|
||||
if (_ct is { IsCancellationRequested: true })
|
||||
{
|
||||
throw new TaskCanceledException("任务取消");
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
|
||||
public class GeniusInvokationTaskParam(CancellationTokenSource cts, string strategyContent) : BaseTaskParam(cts)
|
||||
public class GeniusInvokationTaskParam(string strategyContent) : BaseTaskParam
|
||||
{
|
||||
public string StrategyContent { get; set; } = strategyContent;
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
@@ -49,35 +48,22 @@ public class Duel
|
||||
/// </summary>
|
||||
public int CurrentDiceCount { get; set; } = 0;
|
||||
|
||||
public CancellationTokenSource Cts { get; set; } = default!;
|
||||
|
||||
private int _keqingECount = 0;
|
||||
|
||||
public async Task RunAsync(GeniusInvokationTaskParam taskParam)
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
await Task.Run(() => { Run(taskParam); });
|
||||
await Task.Run(() => { Run(ct); }, ct);
|
||||
}
|
||||
|
||||
public void Run(GeniusInvokationTaskParam taskParam)
|
||||
public void Run(CancellationToken ct)
|
||||
{
|
||||
var hasLock = false;
|
||||
Cts = taskParam.Cts;
|
||||
try
|
||||
{
|
||||
AutoGeniusInvokationAssets.DestroyInstance();
|
||||
hasLock = TaskControl.TaskSemaphore.Wait(0);
|
||||
if (!hasLock)
|
||||
{
|
||||
_logger.LogError("启动自动七圣召唤功能失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
return;
|
||||
}
|
||||
|
||||
LogScreenResolution();
|
||||
_logger.LogInformation("========================================");
|
||||
_logger.LogInformation("→ {Text}", "全自动七圣召唤,启动!");
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Started().Build());
|
||||
GeniusInvokationControl.GetInstance().Init(taskParam);
|
||||
SystemControl.ActivateWindow();
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Started().Build()); // TODO 需要移动
|
||||
GeniusInvokationControl.GetInstance().Init(ct);
|
||||
|
||||
// 对局准备 选择初始手牌
|
||||
GeniusInvokationControl.GetInstance().CommonDuelPrepare();
|
||||
@@ -302,36 +288,23 @@ public class Duel
|
||||
}
|
||||
catch (TaskCanceledException ex)
|
||||
{
|
||||
_logger.LogInformation(ex.Message);
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Cancelled().Build());
|
||||
throw;
|
||||
}
|
||||
catch (NormalEndException ex)
|
||||
{
|
||||
_logger.LogInformation(ex.Message);
|
||||
_logger.LogInformation("对局结束");
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Success().Build());
|
||||
throw;
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
_logger.LogError(ex.Message);
|
||||
_logger.LogDebug(ex.StackTrace);
|
||||
if (TaskContext.Instance().Config.DetailedErrorLogs)
|
||||
{
|
||||
_logger.LogError(ex.StackTrace);
|
||||
}
|
||||
NotificationHelper.SendTaskNotificationUsing(b => b.GeniusInvocation().Failure().Build());
|
||||
}
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskSettingsPageViewModel.SetSwitchAutoGeniusInvokationButtonText(false);
|
||||
_logger.LogInformation("← {Text}", "退出全自动七圣召唤");
|
||||
TaskTriggerDispatcher.Instance().StartTimer();
|
||||
|
||||
if (hasLock)
|
||||
{
|
||||
TaskControl.TaskSemaphore.Release();
|
||||
}
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class ScriptParser
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
MyLogger.LogError($"解析脚本错误,行号:{i + 1},错误信息:{ex}");
|
||||
MessageBox.Show($"解析脚本错误,行号:{i + 1},错误信息:{ex}", "策略解析失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Error($"解析脚本错误,行号:{i + 1},错误信息:{ex}", "策略解析失败");
|
||||
return default!;
|
||||
}
|
||||
|
||||
@@ -195,4 +195,4 @@ public class ScriptParser
|
||||
throw new System.Exception(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@ using System.Threading;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoMusicGame;
|
||||
|
||||
public class AutoMusicGameParam(CancellationTokenSource cts) : BaseTaskParam(cts);
|
||||
public class AutoMusicGameParam : BaseTaskParam;
|
||||
@@ -1,7 +1,4 @@
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
|
||||
using BetterGenshinImpact.View.Drawable;
|
||||
using BetterGenshinImpact.ViewModel.Pages;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
@@ -14,8 +11,10 @@ using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoMusicGame;
|
||||
|
||||
public class AutoMusicGameTask(AutoMusicGameParam taskParam)
|
||||
public class AutoMusicGameTask(AutoMusicGameParam taskParam) : ISoloTask
|
||||
{
|
||||
public string Name => "自动音游";
|
||||
|
||||
private readonly ConcurrentDictionary<User32.VK, int> _keyX = new()
|
||||
{
|
||||
[User32.VK.VK_A] = 417,
|
||||
@@ -30,62 +29,31 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam)
|
||||
|
||||
private readonly IntPtr _hWnd = TaskContext.Instance().GameHandle;
|
||||
|
||||
public async void Start()
|
||||
public Task Start(CancellationToken ct)
|
||||
{
|
||||
var hasLock = false;
|
||||
try
|
||||
Init();
|
||||
|
||||
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
var taskFactory = new TaskFactory();
|
||||
var taskList = new List<Task>();
|
||||
|
||||
// 计算按键位置
|
||||
var gameCaptureRegion = CaptureToRectArea();
|
||||
|
||||
foreach (var keyValuePair in _keyX)
|
||||
{
|
||||
hasLock = await TaskSemaphore.WaitAsync(0);
|
||||
if (!hasLock)
|
||||
{
|
||||
Logger.LogError("启动自动战斗功能失败:当前存在正在运行中的独立任务,请不要重复执行任务!");
|
||||
return;
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
var assetScale = TaskContext.Instance().SystemInfo.AssetScale;
|
||||
var taskFactory = new TaskFactory();
|
||||
var taskList = new List<Task>();
|
||||
|
||||
// 计算按键位置
|
||||
var gameCaptureRegion = CaptureToRectArea();
|
||||
|
||||
foreach (var keyValuePair in _keyX)
|
||||
{
|
||||
var (x, y) = gameCaptureRegion.ConvertPositionToGameCaptureRegion((int)(keyValuePair.Value * assetScale), (int)(_keyY * assetScale));
|
||||
// 添加任务
|
||||
taskList.Add(taskFactory.StartNew(() => DoWhitePressWin32(taskParam.Cts, keyValuePair.Key, new Point(x, y))));
|
||||
}
|
||||
|
||||
Task.WaitAll([.. taskList]);
|
||||
var (x, y) = gameCaptureRegion.ConvertPositionToGameCaptureRegion((int)(keyValuePair.Value * assetScale), (int)(_keyY * assetScale));
|
||||
// 添加任务
|
||||
taskList.Add(taskFactory.StartNew(() => DoWhitePressWin32(ct, keyValuePair.Key, new Point(x, y))));
|
||||
}
|
||||
catch (NormalEndException)
|
||||
{
|
||||
Logger.LogInformation("手动中断自动活动音游");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogError(e.Message);
|
||||
Logger.LogDebug(e.StackTrace);
|
||||
}
|
||||
finally
|
||||
{
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
TaskTriggerDispatcher.Instance().StartTimer();
|
||||
TaskSettingsPageViewModel.SetSwitchAutoFightButtonText(false);
|
||||
Logger.LogInformation("→ {Text}", "自动活动音游结束");
|
||||
|
||||
if (hasLock)
|
||||
{
|
||||
TaskSemaphore.Release();
|
||||
}
|
||||
}
|
||||
Task.WaitAll([.. taskList]);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void DoWhitePressWin32(CancellationTokenSource cts, User32.VK key, Point point)
|
||||
private void DoWhitePressWin32(CancellationToken ct, User32.VK key, Point point)
|
||||
{
|
||||
while (!cts.Token.IsCancellationRequested)
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
// Stopwatch sw = new();
|
||||
@@ -97,7 +65,7 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam)
|
||||
if (c.B < 220)
|
||||
{
|
||||
KeyDown(key);
|
||||
while (!cts.Token.IsCancellationRequested)
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
hdc = User32.GetDC(_hWnd);
|
||||
@@ -129,10 +97,6 @@ public class AutoMusicGameTask(AutoMusicGameParam taskParam)
|
||||
private void Init()
|
||||
{
|
||||
LogScreenResolution();
|
||||
Logger.LogInformation("→ {Text}", "活动音游,启动!");
|
||||
SystemControl.ActivateWindow();
|
||||
TaskTriggerDispatcher.Instance().StopTimer();
|
||||
Sleep(TaskContext.Instance().Config.TriggerInterval * 5, taskParam.Cts); // 等待缓存图像
|
||||
}
|
||||
|
||||
private void LogScreenResolution()
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.Common.Map;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing;
|
||||
|
||||
public class CameraRotateTask(CancellationToken ct)
|
||||
{
|
||||
private readonly double _dpi = TaskContext.Instance().DpiScale;
|
||||
|
||||
/// <summary>
|
||||
/// 向目标角度旋转
|
||||
/// </summary>
|
||||
/// <param name="targetOrientation"></param>
|
||||
/// <param name="imageRegion"></param>
|
||||
/// <returns></returns>
|
||||
public int RotateToApproach(int targetOrientation, ImageRegion imageRegion)
|
||||
{
|
||||
var cao = CameraOrientation.Compute(imageRegion.SrcGreyMat);
|
||||
var diff = (cao - targetOrientation + 180) % 360 - 180;
|
||||
diff += diff < -180 ? 360 : 0;
|
||||
if (diff == 0)
|
||||
{
|
||||
return diff;
|
||||
}
|
||||
|
||||
// 平滑的旋转视角
|
||||
// todo dpi 和分辨率都会影响转动速度
|
||||
double controlRatio = 1;
|
||||
if (Math.Abs(diff) > 90)
|
||||
{
|
||||
controlRatio = 4;
|
||||
}
|
||||
else if (Math.Abs(diff) > 30)
|
||||
{
|
||||
controlRatio = 3;
|
||||
}
|
||||
else if (Math.Abs(diff) > 5)
|
||||
{
|
||||
controlRatio = 2;
|
||||
}
|
||||
|
||||
Simulation.SendInput.Mouse.MoveMouseBy((int)Math.Round(-controlRatio * diff * _dpi), 0);
|
||||
return diff;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 转动视角到目标角度
|
||||
/// </summary>
|
||||
/// <param name="targetOrientation">目标角度</param>
|
||||
/// <param name="maxDiff">最大误差</param>
|
||||
/// <param name="maxTryTimes">最大尝试次数(超时时间)</param>
|
||||
/// <returns></returns>
|
||||
public async Task WaitUntilRotatedTo(int targetOrientation, int maxDiff, int maxTryTimes = 50)
|
||||
{
|
||||
int count = 0;
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
var screen = CaptureToRectArea();
|
||||
if (Math.Abs(RotateToApproach(targetOrientation, screen)) < maxDiff)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (count > maxTryTimes)
|
||||
{
|
||||
Logger.LogWarning("视角转动到目标角度超时,停止转动");
|
||||
break;
|
||||
}
|
||||
|
||||
await Delay(50, ct);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
public class ActionFactory
|
||||
{
|
||||
private static readonly ConcurrentDictionary<string, IActionHandler> _handlers = new();
|
||||
|
||||
public static IActionHandler GetAfterHandler(string handlerType)
|
||||
{
|
||||
return _handlers.GetOrAdd(handlerType, (key) =>
|
||||
{
|
||||
return key switch
|
||||
{
|
||||
"nahida_collect" => new NahidaCollectHandler(),
|
||||
"pick_around" => new PickAroundHandler(),
|
||||
"fight" => new AutoFightHandler(),
|
||||
"normal_attack" => new NormalAttackHandler(),
|
||||
"elemental_skill" => new ElementalSkillHandler(),
|
||||
"hydro_collect" => new ElementalCollectHandler(ElementalType.Hydro),
|
||||
"electro_collect" => new ElementalCollectHandler(ElementalType.Electro),
|
||||
"anemo_collect" => new ElementalCollectHandler(ElementalType.Anemo),
|
||||
_ => throw new ArgumentException("未知的后置 action 类型")
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public static IActionHandler GetBeforeHandler(string handlerType)
|
||||
{
|
||||
return _handlers.GetOrAdd(handlerType, (key) =>
|
||||
{
|
||||
return key switch
|
||||
{
|
||||
"up_down_grab_leaf" => new UpDownGrabLeaf(),
|
||||
_ => throw new ArgumentException("未知的前置 action 类型")
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using BetterGenshinImpact.Core.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoFight;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
internal class AutoFightHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
await StartFight(ct);
|
||||
}
|
||||
|
||||
private async Task StartFight(CancellationToken ct)
|
||||
{
|
||||
TaskControl.Logger.LogInformation("执行 {Text}", "自动战斗");
|
||||
// 爷们要战斗
|
||||
var taskParams = new AutoFightParam(GetFightStrategy())
|
||||
{
|
||||
FightFinishDetectEnabled = true,
|
||||
PickDropsAfterFightEnabled = true
|
||||
};
|
||||
var fightSoloTask = new AutoFightTask(taskParams);
|
||||
await fightSoloTask.Start(ct);
|
||||
}
|
||||
|
||||
private string GetFightStrategy()
|
||||
{
|
||||
var path = Global.Absolute(@"User\AutoFight\" + TaskContext.Instance().Config.AutoFightConfig.StrategyName + ".txt");
|
||||
if ("根据队伍自动选择".Equals(TaskContext.Instance().Config.AutoFightConfig.StrategyName))
|
||||
{
|
||||
path = Global.Absolute(@"User\AutoFight\");
|
||||
}
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
{
|
||||
throw new Exception("战斗策略文件不存在");
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoFight.Config;
|
||||
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Model;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 元素采集
|
||||
/// </summary>
|
||||
public class ElementalCollectHandler(ElementalType elementalType) : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
var combatScenes = await RunnerContext.Instance.GetCombatScenes(ct);
|
||||
if (combatScenes == null)
|
||||
{
|
||||
Logger.LogError("队伍识别未初始化成功!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 筛选出对应元素的角色列表
|
||||
var elementalCollectAvatars = ElementalCollectAvatarConfigs.Lists.Where(x => x.ElementalType == elementalType).ToList();
|
||||
// 循环遍历角色列表
|
||||
foreach (var combatScenesAvatar in combatScenes.Avatars)
|
||||
{
|
||||
// 判断是否为对应元素的角色
|
||||
var elementalCollectAvatar = elementalCollectAvatars.FirstOrDefault(x => x.Name == combatScenesAvatar.Name);
|
||||
if (elementalCollectAvatar == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 切人
|
||||
if (combatScenesAvatar.TrySwitch())
|
||||
{
|
||||
if (elementalCollectAvatar.NormalAttack)
|
||||
{
|
||||
combatScenesAvatar.Attack(100);
|
||||
}
|
||||
else if (elementalCollectAvatar.ElementalSkill)
|
||||
{
|
||||
// 获取CD时间
|
||||
var cdTime = combatScenesAvatar.SkillCd * 1000;
|
||||
var cdRemain = (DateTime.UtcNow - elementalCollectAvatar.LastUseSkillTime).TotalMilliseconds;
|
||||
if (cdRemain < cdTime)
|
||||
{
|
||||
var ms = (int)Math.Ceiling(cdTime - cdRemain) + 100;
|
||||
Logger.LogInformation("{}的E技能CD未结束,等待{Milliseconds}ms", combatScenesAvatar.Name, ms);
|
||||
await Delay(ms, ct);
|
||||
}
|
||||
|
||||
combatScenesAvatar.UseSkill();
|
||||
elementalCollectAvatar.LastUseSkillTime = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogError("切人失败,无法进行{Element}元素采集", elementalType.ToString());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ElementalCollectAvatar(string name, ElementalType elementalType, bool normalAttack, bool elementalSkill)
|
||||
{
|
||||
public string Name { get; set; } = name;
|
||||
public ElementalType ElementalType { get; set; } = elementalType;
|
||||
public bool NormalAttack { get; set; } = normalAttack;
|
||||
|
||||
public bool ElementalSkill { get; set; } = elementalSkill;
|
||||
|
||||
// public CombatAvatar Info => DefaultAutoFightConfig.CombatAvatarMap[Name];
|
||||
|
||||
public DateTime LastUseSkillTime { get; set; } = DateTime.MinValue;
|
||||
}
|
||||
|
||||
public class ElementalCollectAvatarConfigs
|
||||
{
|
||||
public static List<ElementalCollectAvatar> Lists { get; set; } =
|
||||
[
|
||||
// 水
|
||||
new ElementalCollectAvatar("芭芭拉", ElementalType.Hydro, true, true),
|
||||
new ElementalCollectAvatar("莫娜", ElementalType.Hydro, true, false),
|
||||
new ElementalCollectAvatar("心海", ElementalType.Hydro, true, true),
|
||||
new ElementalCollectAvatar("玛拉妮", ElementalType.Hydro, true, false),
|
||||
new ElementalCollectAvatar("那维莱特", ElementalType.Hydro, true, true),
|
||||
new ElementalCollectAvatar("芙宁娜", ElementalType.Hydro, true, false),
|
||||
new ElementalCollectAvatar("妮露", ElementalType.Hydro, false, true),
|
||||
new ElementalCollectAvatar("坎蒂斯", ElementalType.Hydro, false, true),
|
||||
new ElementalCollectAvatar("行秋", ElementalType.Hydro, false, true),
|
||||
new ElementalCollectAvatar("神里绫人", ElementalType.Hydro, false, true),
|
||||
// 雷
|
||||
new ElementalCollectAvatar("丽莎", ElementalType.Electro, true, true),
|
||||
new ElementalCollectAvatar("八重神子", ElementalType.Electro, true, false),
|
||||
new ElementalCollectAvatar("雷电将军", ElementalType.Electro, false, true),
|
||||
new ElementalCollectAvatar("久岐忍", ElementalType.Electro, false, true),
|
||||
new ElementalCollectAvatar("北斗", ElementalType.Electro, false, true),
|
||||
new ElementalCollectAvatar("菲谢尔", ElementalType.Electro, false, true),
|
||||
new ElementalCollectAvatar("雷泽", ElementalType.Electro, false, true),
|
||||
// 风
|
||||
new ElementalCollectAvatar("砂糖", ElementalType.Anemo, true, true),
|
||||
new ElementalCollectAvatar("鹿野院平藏", ElementalType.Anemo, true, true),
|
||||
new ElementalCollectAvatar("流浪者", ElementalType.Anemo, true, false),
|
||||
new ElementalCollectAvatar("闲云", ElementalType.Anemo, true, false),
|
||||
new ElementalCollectAvatar("万叶", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("珐露珊", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("琳妮特", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("温迪", ElementalType.Anemo, false, true),
|
||||
new ElementalCollectAvatar("琴", ElementalType.Anemo, false, true),
|
||||
];
|
||||
|
||||
public static ElementalCollectAvatar? Get(string name, ElementalType type) => Lists.FirstOrDefault(x => x.Name == name && x.ElementalType == type);
|
||||
|
||||
public static List<string> GetAvatarNameList(ElementalType type) => Lists.Where(x => x.ElementalType == type).Select(x => x.Name).ToList();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 触发元素战技
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public class ElementalSkillHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
Logger.LogInformation("执行 {Text}", "释放元素战技");
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_E);
|
||||
await Delay(1000, ct);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
public interface IActionHandler
|
||||
{
|
||||
Task RunAsync(CancellationToken ct);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.Helpers;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 使用纳西妲长按E技能进行收集,360°球形无死角扫码,`type = target`的情况才有效
|
||||
/// </summary>
|
||||
public class NahidaCollectHandler : IActionHandler
|
||||
{
|
||||
private DateTime lastETime = DateTime.MinValue;
|
||||
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
Logger.LogInformation("执行 {Nhd} 长按E转圈拾取", "纳西妲");
|
||||
|
||||
var combatScenes = await RunnerContext.Instance.GetCombatScenes(ct);
|
||||
if (combatScenes == null)
|
||||
{
|
||||
Logger.LogError("队伍识别未初始化成功!");
|
||||
return;
|
||||
}
|
||||
|
||||
// 切人
|
||||
if (combatScenes.AvatarMap.TryGetValue("纳西妲", out var nahida))
|
||||
{
|
||||
nahida.TrySwitch();
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.LogError("队伍中未找到纳西妲角色!");
|
||||
return;
|
||||
}
|
||||
|
||||
var cd = DateTime.Now - lastETime;
|
||||
if (cd < TimeSpan.FromSeconds(10))
|
||||
{
|
||||
await Delay((int)((6 - cd.TotalSeconds + 0.5) * 1000), ct);
|
||||
}
|
||||
|
||||
var dpi = TaskContext.Instance().DpiScale;
|
||||
|
||||
int x = (int)(400 * dpi), y = (int)(-30 * dpi);
|
||||
int i = 60;
|
||||
// 视角拉到最下面
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(0, 10000);
|
||||
await Delay(200, ct);
|
||||
|
||||
// 按住E技能 无死角扫码
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_E);
|
||||
await Delay(200, ct);
|
||||
|
||||
// 先地面来一圈
|
||||
for (int j = 0; j < 15; j++)
|
||||
{
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(x, 500);
|
||||
await Delay(30, ct);
|
||||
}
|
||||
|
||||
// 然后抬斜向转圈
|
||||
while (!ct.IsCancellationRequested && i > 0)
|
||||
{
|
||||
i--;
|
||||
if (i == 40)
|
||||
{
|
||||
y -= (int)(20 * dpi);
|
||||
}
|
||||
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(x, y);
|
||||
await Delay(30, ct);
|
||||
}
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_E);
|
||||
|
||||
lastETime = DateTime.Now;
|
||||
|
||||
await Delay(1000, ct);
|
||||
|
||||
// 恢复视角
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
|
||||
await Delay(1000, ct);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 触发普通攻击
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public class NormalAttackHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
Logger.LogInformation("执行 {Text}", "普通攻击");
|
||||
Simulation.SendInput.Mouse.LeftButtonClick();
|
||||
await Delay(1000, ct);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 采集任务到达点位后执行拾取操作
|
||||
/// </summary>
|
||||
public class PickAroundHandler : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
var screen = CaptureToRectArea();
|
||||
var angle = 0;
|
||||
CameraRotateTask rotateTask = new(ct);
|
||||
Logger.LogInformation("执行 {Text}", "小范围内自动拾取");
|
||||
await rotateTask.WaitUntilRotatedTo(angle, 5);
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_W);
|
||||
var startTime = DateTime.UtcNow;
|
||||
while (!ct.IsCancellationRequested)
|
||||
{
|
||||
angle = (5 + angle) % 360;
|
||||
rotateTask.RotateToApproach(angle, screen);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_SPACE);
|
||||
Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_F);
|
||||
await Delay(100, ct);
|
||||
if (DateTime.UtcNow - startTime > TimeSpan.FromSeconds(5))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Simulation.SendInput.Keyboard.KeyUp(User32.VK.VK_W);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.Core.Simulator;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Vanara.PInvoke;
|
||||
using static BetterGenshinImpact.GameTask.Common.TaskControl;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoPathing.Handler;
|
||||
|
||||
/// <summary>
|
||||
/// 须弥四叶印
|
||||
/// </summary>
|
||||
public class UpDownGrabLeaf : IActionHandler
|
||||
{
|
||||
public async Task RunAsync(CancellationToken ct)
|
||||
{
|
||||
await Delay(500, ct);
|
||||
Logger.LogInformation("开始上下晃动视角抓{Syy}", "四叶印");
|
||||
|
||||
int x = 0, y = -1000; // y代表垂直方向上的视角移动, x为水平方向
|
||||
int i = 40;
|
||||
// kbPress('w'); // 飞行
|
||||
while (i > 0 && !ct.IsCancellationRequested)
|
||||
{
|
||||
Simulation.SendInput.Keyboard.KeyDown(User32.VK.VK_T);
|
||||
if (i % 10 == 0)
|
||||
{
|
||||
y = -y;
|
||||
}
|
||||
|
||||
i--;
|
||||
Debug.WriteLine("上下晃动视角中");
|
||||
Simulation.SendInput.Mouse.MoveMouseBy(0, y);
|
||||
await Delay(40, ct);
|
||||
}
|
||||
|
||||
await Delay(500, ct);
|
||||
Simulation.SendInput.Mouse.MiddleButtonClick();
|
||||
await Delay(500, ct);
|
||||
}
|
||||
}
|
||||