diff --git a/Artemis/Artemis.sln b/Artemis/Artemis.sln index 6c8abbab3..0e9c57ea1 100644 --- a/Artemis/Artemis.sln +++ b/Artemis/Artemis.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis. EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Razer2Artemis", "Razer2Artemis\Razer2Artemis.vcxproj", "{39711909-C1D5-46CE-A9EA-2D561692EA47}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnrealTournament2Artemis", "UnrealTournament2Artemis\UnrealTournament2Artemis.vcxproj", "{3541864F-1662-4BD6-8328-2C87AE61D152}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CD_ROM|Any CPU = CD_ROM|Any CPU @@ -84,6 +86,34 @@ Global {39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x64.Build.0 = Release|x64 {39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x86.ActiveCfg = Release|Win32 {39711909-C1D5-46CE-A9EA-2D561692EA47}.SingleImage|x86.Build.0 = Release|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.CD_ROM|Any CPU.ActiveCfg = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.CD_ROM|Any CPU.Build.0 = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.CD_ROM|x64.ActiveCfg = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.CD_ROM|x64.Build.0 = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.CD_ROM|x86.ActiveCfg = Release|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.CD_ROM|x86.Build.0 = Release|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Debug|x64.ActiveCfg = Debug|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Debug|x64.Build.0 = Debug|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Debug|x86.ActiveCfg = Debug|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Debug|x86.Build.0 = Debug|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.DVD-5|Any CPU.ActiveCfg = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.DVD-5|Any CPU.Build.0 = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.DVD-5|x64.ActiveCfg = Debug|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.DVD-5|x64.Build.0 = Debug|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.DVD-5|x86.ActiveCfg = Debug|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.DVD-5|x86.Build.0 = Debug|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Release|Any CPU.ActiveCfg = Release|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Release|x64.ActiveCfg = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Release|x64.Build.0 = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Release|x86.ActiveCfg = Release|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.Release|x86.Build.0 = Release|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.SingleImage|Any CPU.ActiveCfg = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.SingleImage|Any CPU.Build.0 = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.SingleImage|x64.ActiveCfg = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.SingleImage|x64.Build.0 = Release|x64 + {3541864F-1662-4BD6-8328-2C87AE61D152}.SingleImage|x86.ActiveCfg = Release|Win32 + {3541864F-1662-4BD6-8328-2C87AE61D152}.SingleImage|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml index e591ac8f9..a1bdb0ccc 100644 --- a/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml +++ b/Artemis/Artemis/Modules/Games/CounterStrike/CounterStrikeView.xaml @@ -23,8 +23,8 @@ diff --git a/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml b/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml index 6adaf23ee..336f2b1d7 100644 --- a/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml +++ b/Artemis/Artemis/Modules/Games/Dota2/Dota2View.xaml @@ -24,7 +24,7 @@ diff --git a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchView.xaml b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchView.xaml index 1d5c7d9ad..6408374cd 100644 --- a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchView.xaml +++ b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchView.xaml @@ -23,7 +23,7 @@ diff --git a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueView.xaml b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueView.xaml index 657690ccd..d59f8c89b 100644 --- a/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueView.xaml +++ b/Artemis/Artemis/Modules/Games/RocketLeague/RocketLeagueView.xaml @@ -28,7 +28,7 @@ diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs index 5e0ad4f86..7f67a2b9d 100644 --- a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs +++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentDataModel.cs @@ -19,16 +19,100 @@ namespace Artemis.Modules.Games.UnrealTournament public class Player { - public string Name { get; set; } - public string Team { get; set; } public int Health { get; set; } public int Armor { get; set; } - public string Powerup { get; set; } + public PlayerState State { get; set; } + public Inventory Inventory { get; set; } + public Weapon Weapon { get; set; } + public MatchPlayer MatchStatus { get; set; } + } + + public class PlayerState + { + public string PlayerName { get; set; } + public string UniqueId { get; set; } + public int Score { get; set; } + public int TeamNum { get; set; } + public int RankCheck { get; set; } + public int DuelRank { get; set; } + public int No_of_Duel_Played { get; set; } + public int CTFRank { get; set; } + public int No_CTF_MatchesPlayed { get; set; } + public int TDMRank { get; set; } + public int No_TDM_MatchesPlayed { get; set; } + public int DMRank { get; set; } + public int No_DM_Matches_Played { get; set; } + public int ShowdownRank { get; set; } + public int No_Showdowns { get; set; } + } + + public class Inventory + { + public bool HasJumpBoots { get; set; } + public bool HasInvisibility { get; set; } + public bool HasBerserk { get; set; } + public bool HasUDamage { get; set; } + public bool HasThighPads { get; set; } + public bool HasShieldBelt { get; set; } + public bool HasChestArmor { get; set; } + public bool HasHelmet { get; set; } + } + + public class Weapon + { + public string Name { get; set; } + public int Ammo { get; set; } + public int MaxAmmo { get; set; } + public bool IsFiring { get; set; } + public int FireMode { get; set; } + public ZoomState ZoomState { get; set; } + } + + public enum ZoomState + { + Unzoomed = 0, + Zoomed = 3, + ZoomingIn = 2, + ZoomingOut = 1, } public class Environment { - public string Mode { get; set; } - public string MapName { get; set; } + public string GameMode { get; set; } + public bool MatchStarted { get; set; } + public int GoalScore { get; set; } + public string ServerName { get; set; } + public bool bWeaponStay { get; set; } + public bool bTeamGame { get; set; } + public bool bAllowTeamSwitches { get; set; } + public bool bStopGameClock { get; set; } + public bool bCasterControl { get; set; } + public bool bForcedBalance { get; set; } + public bool bPlayPlayerIntro { get; set; } + public int TimeLimit { get; set; } + public int SpawnProtectionTime { get; set; } + public int RemainingTime { get; set; } + public int ElapsedTime { get; set; } + public int RespawnWaitTime { get; set; } + public int ForceRespawnTime { get; set; } + } + + public class MatchPlayer + { + public string PlayerName { get; set; } + public string UniqueId { get; set; } + public int Score { get; set; } + public int TeamNum { get; set; } + public int RankCheck { get; set; } + public int DuelRank { get; set; } + public int No_of_Duel_Played { get; set; } + public int CTFRank { get; set; } + public int No_CTF_MatchesPlayed { get; set; } + public int TDMRank { get; set; } + public int No_TDM_MatchesPlayed { get; set; } + public int DMRank { get; set; } + public int No_DM_Matches_Played { get; set; } + public int ShowdownRank { get; set; } + public int No_Showdowns { get; set; } } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml index dfa2cce41..8f25cab9b 100644 --- a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml +++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentView.xaml @@ -28,7 +28,7 @@ diff --git a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentViewModel.cs b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentViewModel.cs index d8aa94b79..97721c840 100644 --- a/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentViewModel.cs +++ b/Artemis/Artemis/Modules/Games/UnrealTournament/UnrealTournamentViewModel.cs @@ -1,11 +1,7 @@ using Artemis.InjectionFactories; using Artemis.Managers; -using Artemis.Settings; -using Artemis.Utilities; -using Artemis.Utilities.Memory; using Artemis.ViewModels.Abstract; using Caliburn.Micro; -using Newtonsoft.Json; namespace Artemis.Modules.Games.UnrealTournament { @@ -16,7 +12,7 @@ namespace Artemis.Modules.Games.UnrealTournament public UnrealTournamentViewModel(MainManager main, IEventAggregator events, IProfileEditorVmFactory pFactory) : base(main, new UnrealTournamentModel(main, new UnrealTournamentSettings()), events, pFactory) { - DisplayName = "Rocket League"; + DisplayName = "Unreal Tournament"; MainManager.EffectManager.EffectModels.Add(GameModel); } @@ -33,7 +29,5 @@ namespace Artemis.Modules.Games.UnrealTournament } public UnrealTournamentModel UnrealTournamentModel { get; set; } - - } } \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml index 66d62178d..c8e7be806 100644 --- a/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml +++ b/Artemis/Artemis/Modules/Games/Witcher3/Witcher3View.xaml @@ -23,7 +23,7 @@ diff --git a/Artemis/Artemis/Profiles/Layers/Animations/GrowAnimation.cs b/Artemis/Artemis/Profiles/Layers/Animations/GrowAnimation.cs index da70c3808..c3ca162b6 100644 --- a/Artemis/Artemis/Profiles/Layers/Animations/GrowAnimation.cs +++ b/Artemis/Artemis/Profiles/Layers/Animations/GrowAnimation.cs @@ -24,7 +24,7 @@ namespace Artemis.Profiles.Layers.Animations public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c) { - if (applied.Brush == null) + if (applied?.Brush == null) return; const int scale = 4; diff --git a/Artemis/Artemis/Profiles/Layers/Models/LayerConditionModel.cs b/Artemis/Artemis/Profiles/Layers/Models/LayerConditionModel.cs index 3e93af114..0f04dfddf 100644 --- a/Artemis/Artemis/Profiles/Layers/Models/LayerConditionModel.cs +++ b/Artemis/Artemis/Profiles/Layers/Models/LayerConditionModel.cs @@ -31,7 +31,7 @@ namespace Artemis.Profiles.Layers.Models // Put the subject in a list, allowing Dynamic Linq to be used. if (Type == "String") { - return _interpreter.Eval($"subject.{Field}.ToLower() {Operator} value", + return _interpreter.Eval($"subject.{Field}.ToLower(){Operator}(value)", new Parameter("subject", subject.GetType(), subject), new Parameter("value", Value.ToLower())); } diff --git a/Artemis/Artemis/Utilities/GeneralHelpers.cs b/Artemis/Artemis/Utilities/GeneralHelpers.cs index af9771b92..1ab9cbe54 100644 --- a/Artemis/Artemis/Utilities/GeneralHelpers.cs +++ b/Artemis/Artemis/Utilities/GeneralHelpers.cs @@ -57,6 +57,8 @@ namespace Artemis.Utilities { var propertyNames = path.Split('.'); var prop = o.GetType().GetProperty(propertyNames[0]); + if (prop == null) + return null; var value = prop.GetValue(o, null); if (propertyNames.Length == 1 || value == null) diff --git a/Artemis/Artemis/ViewModels/Profiles/LayerConditionViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/LayerConditionViewModel.cs index 81f1b05ec..411c2157d 100644 --- a/Artemis/Artemis/ViewModels/Profiles/LayerConditionViewModel.cs +++ b/Artemis/Artemis/ViewModels/Profiles/LayerConditionViewModel.cs @@ -25,6 +25,15 @@ namespace Artemis.ViewModels.Profiles new NamedOperator("Not equal to", "!=") }; + private readonly NamedOperator[] _stringOperators = + { + new NamedOperator("Equal to", "=="), + new NamedOperator("Not equal to", "!="), + new NamedOperator("Contains", ".Contains"), + new NamedOperator("Starts with", ".StartsWith"), + new NamedOperator("Ends with", ".EndsWith"), + }; + private readonly NamedOperator[] _operators = { new NamedOperator("Equal to", "=="), @@ -156,6 +165,10 @@ namespace Artemis.ViewModels.Profiles Enums.Add("False"); EnumValueIsVisible = true; break; + case "String": + Operators.AddRange(_stringOperators); + UserValueIsVisible = true; + break; default: Operators.AddRange(_operators); UserValueIsVisible = true; diff --git a/Artemis/UnrealTournament2Artemis/Artemis.uplugin b/Artemis/UnrealTournament2Artemis/Artemis.uplugin new file mode 100644 index 000000000..8ea2a6467 --- /dev/null +++ b/Artemis/UnrealTournament2Artemis/Artemis.uplugin @@ -0,0 +1,21 @@ +{ + "Version" : 1, + "FileVersion": 3, + "FriendlyName": "Artemis Plugin", + "VersionName": "1.0", + "CreatedBy": "Robert Beekman", + "CreatedByURL": "https://github.com/SpoinkyNL/Artemis", + "EngineVersion": "4.4.0", + "Description": "Communicates with Artemis to let the main program know what's happening ingame", + "Category": "UnrealTournament.Mod", + "EnabledByDefault": true, + "CanContainContent": false, + + "Modules": [ + { + "Name": "Artemis", + "Type": "Runtime", + "WhitelistPlatforms": [ "Win32", "Win64" ] + } + ] +} \ No newline at end of file diff --git a/Artemis/UnrealTournament2Artemis/Binaries/Win64/UE4-Artemis-Win64-Shipping.dll b/Artemis/UnrealTournament2Artemis/Binaries/Win64/UE4-Artemis-Win64-Shipping.dll new file mode 100644 index 000000000..87c719160 Binary files /dev/null and b/Artemis/UnrealTournament2Artemis/Binaries/Win64/UE4-Artemis-Win64-Shipping.dll differ diff --git a/Artemis/UnrealTournament2Artemis/Binaries/Win64/UE4-Win64-Shipping.modules b/Artemis/UnrealTournament2Artemis/Binaries/Win64/UE4-Win64-Shipping.modules new file mode 100644 index 000000000..a577932a1 --- /dev/null +++ b/Artemis/UnrealTournament2Artemis/Binaries/Win64/UE4-Win64-Shipping.modules @@ -0,0 +1,8 @@ +{ + "Changelist" : 2897679, + "BuildId" : "5a8ef5b7-c9bb-42bd-ab7c-fb8e33f704ec", + "Modules" : + { + "Artemis" : "UE4-Artemis-Win64-Shipping.dll" + } +} \ No newline at end of file diff --git a/Artemis/UnrealTournament2Artemis/Source/Artemis.Build.cs b/Artemis/UnrealTournament2Artemis/Source/Artemis.Build.cs new file mode 100644 index 000000000..54660fe05 --- /dev/null +++ b/Artemis/UnrealTournament2Artemis/Source/Artemis.Build.cs @@ -0,0 +1,23 @@ +using System.IO; + +namespace UnrealBuildTool.Rules +{ + public class Artemis : ModuleRules + { + public Artemis(TargetInfo Target) + { + PublicDependencyModuleNames.AddRange( + new string[] + { + "Core", + "CoreUObject", + "Engine", + "UnrealTournament", + "InputCore", + "SlateCore", + "Json" + } + ); + } + } +} \ No newline at end of file diff --git a/Artemis/UnrealTournament2Artemis/Source/Private/Artemis.cpp b/Artemis/UnrealTournament2Artemis/Source/Private/Artemis.cpp new file mode 100644 index 000000000..3680cf068 --- /dev/null +++ b/Artemis/UnrealTournament2Artemis/Source/Private/Artemis.cpp @@ -0,0 +1,225 @@ +// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. + +#include "Artemis.h" + +#include "UnrealTournament.h" +#include "UTPlayerController.h" +#include "UTGameState.h" +#include "UTArmor.h" +#include "UTTimedPowerup.h" + +DEFINE_LOG_CATEGORY_STATIC(LogUTKBLightShow, Log, All); + +AArtemis::AArtemis(const FObjectInitializer& ObjectInitializer) + : Super(ObjectInitializer) +{ +} + +FArtemis::FArtemis() +{ + FrameTimeMinimum = 0.03f; + DeltaTimeAccumulator = 0; +} + +IMPLEMENT_MODULE(FArtemis, Artemis) + +void FArtemis::StartupModule() +{ + WritePipe(FString(TEXT("Unreal Tournament plugin loaded"))); +} + +void FArtemis::ShutdownModule() +{ + +} + +void FArtemis::Tick(float DeltaTime) +{ + if (GIsEditor) + { + return; + } + + // Avoid double ticking + if (LastFrameCounter > 0 && LastFrameCounter == GFrameCounter) + { + return; + } + + LastFrameCounter = GFrameCounter; + + // We may be going 120hz, don't spam the device + DeltaTimeAccumulator += DeltaTime; + if (DeltaTimeAccumulator < FrameTimeMinimum) + { + return; + } + DeltaTimeAccumulator = 0; + + // Setup JSON object + TSharedRef RootJson(new FJsonObject()); + TSharedRef PlayerJson(new FJsonObject()); + TSharedRef EnvironmentJson(new FJsonObject()); + RootJson->SetObjectField("Player", PlayerJson); + RootJson->SetObjectField("Environment", EnvironmentJson); + // Setup JSON writer to be used before returning + FString Buffer; + TSharedRef > Writer = TJsonWriterFactory<>::Create(&Buffer); + + AUTPlayerController* UTPC = nullptr; + AUTGameState* GS = nullptr; + const TIndirectArray& AllWorlds = GEngine->GetWorldContexts(); + for (const FWorldContext& Context : AllWorlds) + { + UWorld* World = Context.World(); + if (World && World->WorldType == EWorldType::Game) + { + UTPC = Cast(GEngine->GetFirstLocalPlayerController(World)); + if (UTPC) + { + UUTLocalPlayer* UTLP = Cast(UTPC->GetLocalPlayer()); + if (UTLP == nullptr || UTLP->IsMenuGame()) + { + UTPC = nullptr; + continue; + } + + GS = World->GetGameState(); + break; + } + } + } + + if (!UTPC || !GS) + { + RootJson->SetStringField("State", "MainMenu"); + FJsonSerializer::Serialize(RootJson, Writer); + WritePipe(Buffer); + return; + } + + // Update environment data + if (GS->GetGameModeClass()) + { + EnvironmentJson->SetStringField("GameMode", GS->GetGameModeClass()->GetName()); + } + EnvironmentJson->SetBoolField("MatchStarted", GS->HasMatchStarted()); + EnvironmentJson->SetNumberField("GoalScore", GS->GoalScore); + // Insert GameState JsonReport + GS->MakeJsonReport(EnvironmentJson); + // The JsonReport may contain all players, which is a bit too much + if (EnvironmentJson->HasField("Players")) + { + EnvironmentJson->RemoveField("Players"); + } + + // Update player data + // If character not found player must be spectating(?) + if (!UTPC->GetUTCharacter()) + { + RootJson->SetStringField("State", "Spectating"); + } + // If dead, don't try reading HP/Armor + else if (UTPC->GetUTCharacter()->IsDead()) + { + RootJson->SetStringField("State", "Dead"); + PlayerJson->SetNumberField("Health", 0); + PlayerJson->SetNumberField("Armor", 0); + } + // Player is found and alive + else + { + // Update HP and armor + RootJson->SetStringField("State", "Alive"); + PlayerJson->SetNumberField("Health", UTPC->GetUTCharacter()->Health); + PlayerJson->SetNumberField("Armor", UTPC->GetUTCharacter()->ArmorAmount); + + // Update player powerups data + TSharedRef InventoryJson(new FJsonObject()); + PlayerJson->SetObjectField("Inventory", InventoryJson); + InventoryJson->SetBoolField("HasJumpBoots", false); + InventoryJson->SetBoolField("HasInvisibility", false); + InventoryJson->SetBoolField("HasBerserk", false); + InventoryJson->SetBoolField("HasUDamage", false); + InventoryJson->SetBoolField("HasThighPads", false); + InventoryJson->SetBoolField("HasShieldBelt", false); + InventoryJson->SetBoolField("HasChestArmor", false); + InventoryJson->SetBoolField("HasHelmet", false); + + for (TInventoryIterator<> It(UTPC->GetUTCharacter()); It; ++It) + { + AUTInventory* InventoryItem = (*It); + // Using Contains here because pickups might have slighty different names in different contexts + if (InventoryItem->GetClass()->GetName().Contains("Armor_ThighPads")) + { + InventoryJson->SetBoolField("HasThighPads", true); + } + else if (InventoryItem->GetClass()->GetName().Contains("Armor_ShieldBelt")) + { + InventoryJson->SetBoolField("HasShieldBelt", true); + } + else if (InventoryItem->GetClass()->GetName().Contains("Armor_Chest")) + { + InventoryJson->SetBoolField("HasChestArmor", true); + } + else if (InventoryItem->GetClass()->GetName().Contains("Armor_Helmet")) + { + InventoryJson->SetBoolField("HasHelmet", true); + } + else if (InventoryItem->GetClass()->GetName().Contains("JumpBoots")) + { + InventoryJson->SetBoolField("HasJumpBoots", true); + } + else if (InventoryItem->GetClass()->GetName().Contains("Invis")) + { + InventoryJson->SetBoolField("HasInvisibility", true); + } + else if (InventoryItem->GetClass()->GetName().Contains("Berserk")) + { + InventoryJson->SetBoolField("HasBerserk", true); + } + else if (InventoryItem->GetClass()->GetName().Contains("UDamage")) + { + InventoryJson->SetBoolField("HasUDamage", true); + } + } + + // Update player weapon data + TSharedRef WeaponJson(new FJsonObject()); + PlayerJson->SetObjectField("Weapon", WeaponJson); + if (UTPC->GetUTCharacter()->GetWeapon()) + { + WeaponJson->SetStringField("Name", UTPC->GetUTCharacter()->GetWeapon()->GetClass()->GetName()); + WeaponJson->SetNumberField("Ammo", UTPC->GetUTCharacter()->GetWeapon()->Ammo); + WeaponJson->SetNumberField("MaxAmmo", UTPC->GetUTCharacter()->GetWeapon()->MaxAmmo); + WeaponJson->SetBoolField("IsFiring", UTPC->GetUTCharacter()->GetWeapon()->IsFiring()); + WeaponJson->SetNumberField("FireMode", UTPC->GetUTCharacter()->GetWeapon()->GetCurrentFireMode()); + WeaponJson->SetNumberField("ZoomState", UTPC->GetUTCharacter()->GetWeapon()->ZoomState); + } + else { + WeaponJson->SetStringField("Name", "None"); + } + } + // Insert PlayerState JsonReport + TSharedRef PlayerStateJson(new FJsonObject()); + PlayerJson->SetObjectField("State", PlayerStateJson); + if (UTPC->UTPlayerState) + { + UTPC->UTPlayerState->MakeJsonReport(PlayerStateJson); + } + + FJsonSerializer::Serialize(RootJson, Writer); + WritePipe(Buffer); +} + +void FArtemis::WritePipe(FString msg) +{ + pipe = CreateFile(TEXT("\\\\.\\pipe\\artemis"), GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr); + if (pipe == nullptr || pipe == INVALID_HANDLE_VALUE) + { + return; + } + + uint32 BytesWritten = 0; + WriteFile(pipe, TCHAR_TO_ANSI(*msg), msg.Len(), (::DWORD*)&BytesWritten, nullptr); +} \ No newline at end of file diff --git a/Artemis/UnrealTournament2Artemis/Source/Private/Artemis.h b/Artemis/UnrealTournament2Artemis/Source/Private/Artemis.h new file mode 100644 index 000000000..2ca2f51e9 --- /dev/null +++ b/Artemis/UnrealTournament2Artemis/Source/Private/Artemis.h @@ -0,0 +1,41 @@ +// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. +#pragma once + +#include "Core.h" +#include "UnrealTournament.h" +#include "JsonSerializer.h" +#include "JsonObject.h" +#include "JsonReader.h" + +#include "Artemis.generated.h" + +UCLASS(Blueprintable, Meta = (ChildCanTick)) +class AArtemis : public AActor +{ + GENERATED_UCLASS_BODY() + +}; + +struct FArtemis : FTickableGameObject, IModuleInterface +{ + FArtemis(); + virtual void Tick(float DeltaTime) override; + virtual bool IsTickable() const override { return true; } + virtual bool IsTickableInEditor() const override { return true; } + virtual bool IsTickableWhenPaused() const override { return true; } + + virtual void StartupModule() override; + virtual void ShutdownModule() override; + + // Put a real stat id here + virtual TStatId GetStatId() const + { + return TStatId(); + } + + void WritePipe(FString msg); + HANDLE pipe; + float DeltaTimeAccumulator; + float FrameTimeMinimum; + uint64 LastFrameCounter; +}; \ No newline at end of file diff --git a/Artemis/UnrealTournament2Artemis/UnrealTournament2Artemis.vcxproj b/Artemis/UnrealTournament2Artemis/UnrealTournament2Artemis.vcxproj new file mode 100644 index 000000000..b4cd9703f --- /dev/null +++ b/Artemis/UnrealTournament2Artemis/UnrealTournament2Artemis.vcxproj @@ -0,0 +1,165 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {3541864F-1662-4BD6-8328-2C87AE61D152} + Win32Proj + UnrealTournament2Artemis + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;UNREALTOURNAMENT2ARTEMIS_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;UNREALTOURNAMENT2ARTEMIS_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;UNREALTOURNAMENT2ARTEMIS_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;UNREALTOURNAMENT2ARTEMIS_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Artemis/UnrealTournament2Artemis/UnrealTournament2Artemis.vcxproj.filters b/Artemis/UnrealTournament2Artemis/UnrealTournament2Artemis.vcxproj.filters new file mode 100644 index 000000000..256e298e2 --- /dev/null +++ b/Artemis/UnrealTournament2Artemis/UnrealTournament2Artemis.vcxproj.filters @@ -0,0 +1,45 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + + \ No newline at end of file