Skip to content

Commit

Permalink
修复新海线幻海计时不正确的bug (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nukoooo authored Sep 24, 2023
1 parent e793097 commit 2f88c45
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
41 changes: 26 additions & 15 deletions 渔人的直感/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,16 @@ private void OnWork(object sender, DoWorkEventArgs e)
status = nStatus;
}

var buffTablePtr = Scanner.ReadIntPtr(Data.ActorTable) + Data.UiStatusEffects;
var localplayer = Scanner.ReadIntPtr(Data.ActorTable);
if (localplayer == IntPtr.Zero || Scanner.ReadByte(localplayer, Data.CharacterClassJobOffset) != 18)
{
Reset();
Status.End();
Fish.Reset();
continue;
}

var buffTablePtr = localplayer + Data.UiStatusEffects;
BuffCheck(buffTablePtr);
OceanFishingZoneCheck();
WeatherCheck(Data.WeatherPtr);
Expand Down Expand Up @@ -231,24 +240,26 @@ private void BuffCheck(IntPtr buffTablePtr)
};*/
break;
}

return;
}
else if (buffTablePtr == (IntPtr) Data.UiStatusEffects) //当前激活中 且 指针指向空角色(在登录界面等未加载人物的情况)

if (Status.Type != Status.StatusType.FishEyes) return;

var fishEyeIsActive = false;
for (var i = 0; i < 30; i++)
{
Debug.WriteLine("[BuffCheck] Reset");
Reset();
Status.End();
if (Scanner.ReadInt16(buffTablePtr + i * 12) != Data.FishEyesBuffId)
continue;
fishEyeIsActive = true;
break;
}
else if (Status.Type == Status.StatusType.FishEyes)
{
var fishEyeIsActive = false;
for (var i = 0; i < 30; i++)
if (Scanner.ReadInt16(buffTablePtr + i * 12) == Data.FishEyesBuffId)
fishEyeIsActive = true;

if (!fishEyeIsActive)
Status.End();
}
if (!fishEyeIsActive)
Status.End();

}

private void WeatherCheck(IntPtr weatherPtr)
{
var currentWeather = Scanner.ReadByte(weatherPtr);
Expand Down Expand Up @@ -318,7 +329,7 @@ private void OceanFishingZoneCheck()
// 检查是否在海钓里
var territory = Data.TerritoryType;
// 为什么换海域的时候territoryId会变成0啊啊啊啊啊
if (territory != 900 && territory != 0)
if (territory != 0 && !Data.IsInOceanFishing)
{
Reset();
// Console.WriteLine($"[OceanFishingZoneCheck] Reset. {territory}");
Expand Down
11 changes: 8 additions & 3 deletions 渔人的直感/Models/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ namespace 渔人的直感.Models
/// </summary>
public static class Data
{

public const int FishEyesBuffId = 762; // 50; // 鱼眼的Buff ID

public static List<SpecialWeather> SpecialWeathers = new List<SpecialWeather>();

private static SigScanner _scanner;
public static IntPtr StatusPtr;
public static IntPtr ActorTable;

public static short CharacterClassJobOffset;
//public static IntPtr BuffTablePtr;
private static IntPtr weatherPtr;
private static IntPtr territoryTypePtr;
Expand Down Expand Up @@ -60,6 +61,8 @@ public static byte OceanFishingCurrentZone
}
}

public static bool IsInOceanFishing => GetInstanceContentDirector() != IntPtr.Zero;

public static int UiStatusEffects; //UIStatusEffects相对于ActorTable的偏移。此值随着版本更新随时可能发生改变。

public static void Initialize(SigScanner scanner)
Expand Down Expand Up @@ -92,6 +95,10 @@ public static void Initialize(SigScanner scanner)

UiStatusEffects = scanner.ReadInt32(scanner.ScanText("48 8D 81 ? ? ? ? C3 CC CC CC CC CC CC CC CC 48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 33 F6 48 8B D9"), 3);

var characterDataOffset = scanner.ReadInt16(scanner.ScanText("48 81 E9 ? ? ? ? E9 ? ? ? ? CC CC CC CC CC CC CC CC CC CC CC CC 40 53 48 83 EC ? 48 8D 05 ? ? ? ? 48 8B D9 48 89 01 F6 C2 ? 74 ? BA ? ? ? ? E8 ? ? ? ? 48 8B C3 48 83 C4 ? 5B C3 CC CC CC CC CC 48 89 5C 24"), 3);
var classJobOffset = scanner.ReadByte(scanner.ScanText("44 0F B6 49 ? 88 51"), 4);
CharacterClassJobOffset = (short)(classJobOffset + characterDataOffset);

SpecialWeathers.Add(new SpecialWeather { Id = 145, Name = "幻海流", Duration = 120f });
if (Properties.Settings.Default.CheckDiademWeather)
{
Expand Down Expand Up @@ -139,10 +146,8 @@ private static IntPtr GetInstanceContentDirector()
return IntPtr.Zero;
}


return directorPtr;
}

}

public struct SpecialWeather
Expand Down

0 comments on commit 2f88c45

Please sign in to comment.