Skip to content

Commit

Permalink
add a command.
Browse files Browse the repository at this point in the history
  • Loading branch information
a08381 committed Nov 21, 2021
1 parent 9eef1bd commit 865019a
Show file tree
Hide file tree
Showing 9 changed files with 1,526 additions and 189 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# CA1416: 验证平台兼容性
dotnet_diagnostic.CA1416.severity = silent
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
Remove-Item -Path .\SkipCutscene\bin\Release\net5.0-windows\SkipCutscene_Secure -Force -Recurse
Remove-Item -Path .\SkipCutscene\bin\Release\net5.0-windows\SkipCutscene -Force -Recurse
Remove-Item -Path .\SkipCutscene\bin\Release\net5.0-windows\SkipCutscene.deps.json -Force -Recurse
Remove-Item -Path .\SkipCutscene\bin\Release\net5.0-windows\ref -Force -Recurse
mkdir -Path .\SkipCutscene\bin\Package\
- name: Package
uses: papeloto/action-zip@v1
Expand All @@ -61,3 +62,33 @@ jobs:
with:
name: Package
path: ${{ github.workspace }}\SkipCutscene\bin\Package\
- name: Checkout dist
uses: actions/checkout@v2
with:
ref: dist
path: dist
- name: Upload dist
continue-on-error: false
run: |
cd "$Env:GITHUB_WORKSPACE"
$content = Get-Content ".\dist\repo.json"
$repo = ConvertFrom-Json $content
$version = '"AssemblyVersion": "9.9.9.9"'
$plugin = Get-Content ".\SkipCutscene\bin\Package\SkipCutscene.json" | ConvertFrom-Json
$old_version = $version -replace '9.9.9.9',$repo.AssemblyVersion
$new_version = $version -replace '9.9.9.9',$plugin.AssemblyVersion
$content = $content -replace $old_version,$new_version
Set-Content -Path ".\dist\repo.json" -Value $content
Copy-Item -Path .\SkipCutscene\bin\Package\latest.zip -Destination .\dist\ -Force
cd dist
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Regenerate PluginMaster"
- name: Push dist
continue-on-error: false
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: dist
directory: dist
Binary file modified Lib/Dalamud/Dalamud.dll
Binary file not shown.
1,539 changes: 1,370 additions & 169 deletions Lib/Dalamud/Dalamud.xml

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion SkipCutscene.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31129.286
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkipCutscene", "SkipCutscene\SkipCutscene.csproj", "{F8DC279F-8EA0-4B3B-AEFB-93701C9F61F5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SkipCutscene", "SkipCutscene\SkipCutscene.csproj", "{F8DC279F-8EA0-4B3B-AEFB-93701C9F61F5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0116F546-85BE-4B8B-9A6A-282D9B097AAB}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.github\workflows\main.yml = .github\workflows\main.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
17 changes: 17 additions & 0 deletions SkipCutscene/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Dalamud.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Plugins.a08381.SkipCutscene
{
class Config : IPluginConfiguration
{

public int Version { get; set; }

public bool IsEnabled { get; set; }
}
}
4 changes: 2 additions & 2 deletions SkipCutscene/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyVersion("1.2.0.1")]
[assembly: AssemblyFileVersion("1.2.0.1")]
109 changes: 92 additions & 17 deletions SkipCutscene/SkipCutscene.cs
Original file line number Diff line number Diff line change
@@ -1,46 +1,115 @@
using Dalamud;
using Dalamud.Game;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.Logging;
using Dalamud.Plugin;
using System;
using System.Diagnostics;
using System.Security.Cryptography;

namespace Plugins.a08381.SkipCutscene
{
public class SkipCutscene : IDalamudPlugin
public class SkipCutscene : IDalamudPlugin
{
public string Name => "SkipCutscene";

[PluginService]
public SigScanner SigScanner { get; private set; }
private Config config;

public CutsceneAddressResolver Address;
private RNGCryptoServiceProvider csp;

public void Dispose()
{
if (Address.Offset1 != IntPtr.Zero)
SafeMemory.Write<short>(Address.Offset1, 13173);
if (Address.Offset2 != IntPtr.Zero)
SafeMemory.Write<short>(Address.Offset2, 6260);
}
private readonly decimal _base = uint.MaxValue;

public SkipCutscene(DalamudPluginInterface pluginInterface)
public SkipCutscene()
{
if (Interface.GetPluginConfig() is not Config configuration)
{
configuration = new Config();
}

this.config = configuration;

Address = new CutsceneAddressResolver();

Address.Setup(SigScanner);

if (Address.Offset1 != IntPtr.Zero && Address.Offset2 != IntPtr.Zero)
{
PluginLog.Information("Cutscene Offset Found.");
SafeMemory.Write<short>(Address.Offset1, -28528);
SafeMemory.Write<short>(Address.Offset2, -28528);
if (this.config.IsEnabled)
SetEnabled(true);
}
else
{
PluginLog.Error("Cutscene Offset Not Found.");
PluginLog.Warning("Plugin Disabling...");
Dispose();
return;
}

csp = new();

CommandManager.AddHandler("/sc", new CommandInfo(this.OnCommand)
{
HelpMessage = "/sc: Roll your sanity check dice."
});
}

public void Dispose()
{
SetEnabled(false);
}

public string Name => "SkipCutscene";

[PluginService]
public DalamudPluginInterface Interface { get; private set; }

[PluginService]
public SigScanner SigScanner { get; private set; }

[PluginService]
public CommandManager CommandManager { get; private set; }

[PluginService]
public ChatGui ChatGui { get; private set; }

public CutsceneAddressResolver Address { get; private set; }

public void SetEnabled(bool isEnable)
{
if (Address.Offset1 != IntPtr.Zero && Address.Offset2 != IntPtr.Zero)
{
if (isEnable)
{
SafeMemory.Write<short>(Address.Offset1, -28528);
SafeMemory.Write<short>(Address.Offset2, -28528);
}
else
{
SafeMemory.Write<short>(Address.Offset1, 13173);
SafeMemory.Write<short>(Address.Offset2, 6260);
}
}
}

private void OnCommand(string command, string arguments)
{
if (command.ToLower() == "/sc")
{
byte[] rndSeries = new byte[4];
csp.GetBytes(rndSeries);
int rnd = (int)Math.Abs(BitConverter.ToUInt32(rndSeries, 0) / _base * 50 + 1);
if (this.config.IsEnabled)
{
ChatGui.Print(string.Format("sancheck: 1d100={0}, Failed", rnd + 50));
}
else
{
ChatGui.Print(string.Format("sancheck: 1d100={0}, Passed", rnd));
}
this.config.IsEnabled = !this.config.IsEnabled;
SetEnabled(this.config.IsEnabled);
}
}
}
Expand All @@ -55,8 +124,14 @@ protected override void Setup64Bit(SigScanner sig)
{
Offset1 = sig.ScanText("75 33 48 8B 0D ?? ?? ?? ?? BA ?? 00 00 00 48 83 C1 10 E8 ?? ?? ?? ?? 83 78");
Offset2 = sig.ScanText("74 18 8B D7 48 8D 0D");
PluginLog.Information("Offset1: [{0}]", Offset1.ToString("X"));
PluginLog.Information("Offset2: [{0}]", Offset2.ToString("X"));
PluginLog.Information(
"Offset1: [\"ffxiv_dx11.exe\"+{0}]",
(Offset1.ToInt64() - Process.GetCurrentProcess().MainModule.BaseAddress.ToInt64()).ToString("X")
);
PluginLog.Information(
"Offset2: [\"ffxiv_dx11.exe\"+{0}]",
(Offset2.ToInt64() - Process.GetCurrentProcess().MainModule.BaseAddress.ToInt64()).ToString("X")
);
}

}
Expand Down
3 changes: 3 additions & 0 deletions SkipCutscene/SkipCutscene.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<Platforms>x64;AnyCPU</Platforms>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>..\Lib\Dalamud\Dalamud.dll</HintPath>
Expand Down

0 comments on commit 865019a

Please sign in to comment.