From 270e5963a90dcbaf871a54d6bf96fada7af4ceed Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Tue, 21 Mar 2017 18:54:21 +0100 Subject: [PATCH] Added Terraria module --- Artemis/Artemis/Artemis.csproj | 11 +++ .../Corsair/CorsairKeyboard.cs | 5 - .../RocketLeague/RocketLeagueViewModel.cs | 2 +- .../Games/Terraria/TerrariaDataModel.cs | 18 ++++ .../Modules/Games/Terraria/TerrariaModel.cs | 91 +++++++++++++++++++ .../Games/Terraria/TerrariaSettings.cs | 8 ++ .../Modules/Games/Terraria/TerrariaView.xaml | 48 ++++++++++ .../Games/Terraria/TerrariaView.xaml.cs | 28 ++++++ .../Games/Terraria/TerrariaViewModel.cs | 47 ++++++++++ Artemis/Artemis/Settings/OffsetSettings.cs | 1 + Artemis/Artemis/Utilities/Updater.cs | 2 + .../LightFX2Artemis/LightFX2Artemis.vcxproj | 2 +- .../LogiLed2Artemis/LogiLed2Artemis.vcxproj | 1 + Artemis/Razer2Artemis/Razer2Artemis.vcxproj | 2 +- 14 files changed, 258 insertions(+), 8 deletions(-) create mode 100644 Artemis/Artemis/Modules/Games/Terraria/TerrariaDataModel.cs create mode 100644 Artemis/Artemis/Modules/Games/Terraria/TerrariaModel.cs create mode 100644 Artemis/Artemis/Modules/Games/Terraria/TerrariaSettings.cs create mode 100644 Artemis/Artemis/Modules/Games/Terraria/TerrariaView.xaml create mode 100644 Artemis/Artemis/Modules/Games/Terraria/TerrariaView.xaml.cs create mode 100644 Artemis/Artemis/Modules/Games/Terraria/TerrariaViewModel.cs diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 00dba2b00..492b5f6c4 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -384,6 +384,13 @@ AssettoCorsaView.xaml + + + + + TerrariaView.xaml + + @@ -856,6 +863,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Artemis/Artemis/DeviceProviders/Corsair/CorsairKeyboard.cs b/Artemis/Artemis/DeviceProviders/Corsair/CorsairKeyboard.cs index ef5adc1ab..4468016b9 100644 --- a/Artemis/Artemis/DeviceProviders/Corsair/CorsairKeyboard.cs +++ b/Artemis/Artemis/DeviceProviders/Corsair/CorsairKeyboard.cs @@ -88,11 +88,6 @@ namespace Artemis.DeviceProviders.Corsair break; } - Height = 8; - Width = 22; - Slug = "corsair-strafe-rgb"; - PreviewSettings = new PreviewSettings(new Rect(23, 12, 937, 324), Resources.strafe); - Logger.Debug("Corsair SDK reported device as: {0}", _keyboard.DeviceInfo.Model); _keyboard.Brush = _keyboardBrush ?? (_keyboardBrush = new ImageBrush()); } diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs index e46759d75..a1f168377 100644 --- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs +++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueViewModel.cs @@ -36,7 +36,7 @@ namespace Artemis.Modules.Games.RocketLeague { if (!SettingsProvider.Load().EnablePointersUpdate) { - VersionText = "You disabled pointer updates, this could result in the Rocket League effect not working after a game update."; + VersionText = "You disabled pointer updates, this could result in the Rocket League module not working after a game update."; return; } diff --git a/Artemis/Artemis/Modules/Games/Terraria/TerrariaDataModel.cs b/Artemis/Artemis/Modules/Games/Terraria/TerrariaDataModel.cs new file mode 100644 index 000000000..ce01c1f18 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/Terraria/TerrariaDataModel.cs @@ -0,0 +1,18 @@ +using Artemis.Modules.Abstract; +using MoonSharp.Interpreter; + +namespace Artemis.Modules.Games.Terraria +{ + [MoonSharpUserData] + public class TerrariaDataModel : ModuleDataModel + { + public int Hp { get; set; } + public int MaxHp { get; set; } + public int Mana { get; set; } + public int MaxMana { get; set; } + public int Breath { get; set; } + public int MaxBreath { get; set; } + public bool InWater { get; set; } + public bool InLava { get; set; } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/Terraria/TerrariaModel.cs b/Artemis/Artemis/Modules/Games/Terraria/TerrariaModel.cs new file mode 100644 index 000000000..c7f3c0c8c --- /dev/null +++ b/Artemis/Artemis/Modules/Games/Terraria/TerrariaModel.cs @@ -0,0 +1,91 @@ +using System; +using System.Linq; +using Artemis.DAL; +using Artemis.Managers; +using Artemis.Modules.Abstract; +using Artemis.Settings; +using Artemis.Utilities; +using Artemis.Utilities.Memory; + +namespace Artemis.Modules.Games.Terraria +{ + public class TerrariaModel : ModuleModel + { + private Memory _memory; + private GamePointersCollection _pointer; + + public TerrariaModel(DeviceManager deviceManager, LuaManager luaManager) : base(deviceManager, luaManager) + { + Settings = SettingsProvider.Load(); + DataModel = new TerrariaDataModel(); + ProcessNames.Add("Terraria"); + + // Generate a new offset when the game is updated + //_pointer = new GamePointersCollection + //{ + // Game = "Terraria", + // GameVersion = "1.3.4.4", + // GameAddresses = new List + // { + // new GamePointer + // { + // Description = "PlayerBase", + // BasePointer = new IntPtr(0x0039C078), + // Offsets = new[] {0x280, 0x6C0, 0x674, 0x3C} + // } + // } + //}; + //var res = JsonConvert.SerializeObject(_pointer, Formatting.Indented); + } + + public override string Name => "Terraria"; + public override bool IsOverlay => false; + public override bool IsBoundToProcess => true; + + public override void Dispose() + { + base.Dispose(); + + _memory?.Dispose(); + _memory = null; + } + + public override void Enable() + { + Updater.GetPointers(); + _pointer = SettingsProvider.Load().Terraria; + + base.Enable(); + } + + public override void Update() + { + if (_memory == null) + { + var tempProcess = MemoryHelpers.GetProcessIfRunning(ProcessNames[0]); + if (tempProcess == null) + return; + + _memory = new Memory(tempProcess); + } + + if (ProfileModel == null || DataModel == null || _memory == null) + return; + + var offsets = _pointer.GameAddresses.First(ga => ga.Description == "PlayerBase").ToString(); + var baseAddress = _memory.GetAddress("\"Terraria.exe\"" + offsets); + var basePointer = new IntPtr(_memory.ReadInt32(baseAddress)); + var playerPointer = new IntPtr(_memory.ReadInt32(basePointer + 0x18)); + + var dataModel = (TerrariaDataModel) DataModel; + dataModel.Hp = _memory.ReadInt32(playerPointer + 0x340); + dataModel.MaxHp = _memory.ReadInt32(playerPointer + 0x338); + dataModel.Mana = _memory.ReadInt32(playerPointer + 0x344); + dataModel.MaxMana = _memory.ReadInt32(playerPointer + 0x348); + dataModel.Breath = _memory.ReadInt32(playerPointer + 0x2B4); + dataModel.MaxBreath = _memory.ReadInt32(playerPointer + 0x2B0); + dataModel.InWater = Convert.ToBoolean(_memory.ReadInt32(playerPointer + 0x1D)); + dataModel.InLava = Convert.ToBoolean(_memory.ReadInt32(playerPointer + 0x20)); + } + } +} diff --git a/Artemis/Artemis/Modules/Games/Terraria/TerrariaSettings.cs b/Artemis/Artemis/Modules/Games/Terraria/TerrariaSettings.cs new file mode 100644 index 000000000..c155ff365 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/Terraria/TerrariaSettings.cs @@ -0,0 +1,8 @@ +using Artemis.Modules.Abstract; + +namespace Artemis.Modules.Games.Terraria +{ + public class TerrariaSettings : ModuleSettings + { + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/Terraria/TerrariaView.xaml b/Artemis/Artemis/Modules/Games/Terraria/TerrariaView.xaml new file mode 100644 index 000000000..f5cf0d7e4 --- /dev/null +++ b/Artemis/Artemis/Modules/Games/Terraria/TerrariaView.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +