Skip to content

Commit

Permalink
Merge branch 'feat/camera_fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
keton committed Mar 11, 2024
2 parents b75051f + d34d9f3 commit ff72885
Show file tree
Hide file tree
Showing 24 changed files with 1,283 additions and 88 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CMake on a single platform

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

permissions:
contents: write

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

# UEVR UESDK submodule uses ssh, rewrite to https with access token
- name: Set github url and credentials
run: |
git config --global url."https://${{ secrets.REPO_ACCESS_TOKEN }}@github.com/.insteadOf" [email protected]:
- name: Configure CMake
run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target ace_combat_plugin

- name: Package
working-directory: ${{github.workspace}}
run: Invoke-Item package.cmd
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: Ace7Game
path: ${{github.workspace}}/build/Release/profile/*
if-no-files-found: error
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: Ace7Game.zip
body_path: ${{github.workspace}}/release-template.md
4 changes: 2 additions & 2 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Ace Combat 7 UEVR compatibility mod

### Download UEVR Profile [here](https://github.com/keton/ace-combat-uevr/releases/latest)

## Features
1. fixes cockpit camera so it works out of the box in most situations
1. adds 'unstuck cockpit instruments' button (left start/select button on Xbox controller) for those rare occurrences where automation fails.
1. adds optional controls remap selectable in plugin overlay in UEVR menu. After remap controls are in line with typical flight sim - LS is elevator and rudder, RS is aileron and throttle.

## Building

1. Install Visual Studio 2022 with C++, Windows SDK and CMake support
1. Make sure you follow all instructions [here](https://github.com/praydog/UEVR/blob/master/COMPILING.md) and are able to build UEVR from source
1. Clone the repository
1. Run `build.cmd` or in VS Developer Shell type:
```shell
cmake -S . -B build ./build -G "Visual Studio 17 2022" -A x64 -DCMAKE_BUILD_TYPE=Release
cmake --build ./build --clean-first --config Release --target ace_combat_plugin
```
1. copy resulting `ace_combat_plugin.dll` to your game profile `plugins` subfolder
2 changes: 1 addition & 1 deletion cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

[fetch-content.uevr]
git = "https://github.com/praydog/UEVR"
tag = "c25695a8c0ec35b556229046cc7011e27f4d42ee"
tag = "067279517877c0b3dd8a1bb46a7124c1e1aac113"

[target.ace_combat_plugin]
type = "shared"
Expand Down
83 changes: 83 additions & 0 deletions include/acesdk/AcePlayerPawn.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#pragma once

#include "uevr/API.hpp"

#include "uesdk/AActor.hpp"
#include "uesdk/APawn.hpp"
#include "uesdk/CameraComponent.hpp"
#include "uesdk/USceneComponent.hpp"

#include "acesdk/CameraViewComponent.hpp"

using namespace uevr;

// AcePlayerPawn has dynamic class name
class AcePlayerPawn : public APawn
{
public:
static API::UClass *static_class(bool force_search = false)
{
static API::UClass *result = nullptr;

if(result == nullptr || force_search) {
result = find_pawn_class();
}

return result;
}

CameraViewComponent *prop_camera_view()
{
const auto p_prop = get_property_data<CameraViewComponent *>(L"CameraView");
if(p_prop && *p_prop) {
return *p_prop;
}

return nullptr;
}

CameraComponent *prop_cockpit_camera()
{
const auto p_prop = get_property_data<CameraComponent *>(L"CockpitCamera");
if(p_prop && *p_prop) {
return *p_prop;
}

return nullptr;
}

USceneComponent *prop_cockpit_mesh()
{
const auto p_prop = get_property_data<USceneComponent *>(L"CockpitMesh");
if(p_prop && *p_prop) {
return *p_prop;
}

return nullptr;
}

USceneComponent *prop_plane_body_mesh()
{
const auto p_prop = get_property_data<USceneComponent *>(L"PlaneBodyMesh");
if(p_prop && *p_prop) {
return *p_prop;
}

return nullptr;
}

private:
static inline API::UClass *find_pawn_class()
{
const auto pawn = API::get()->get_local_pawn(0);
if(!pawn) {
return nullptr;
}

if(!pawn->get_full_name().starts_with(L"AcePlayerPawn_")) {
return nullptr;
}

return pawn->get_class();
}
};
98 changes: 98 additions & 0 deletions include/acesdk/CameraViewComponent.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

#pragma once

#include "uevr/API.hpp"

using namespace uevr;

enum CameraType : uint8_t
{
FIRST_PERSON = 0,
COCKPIT,
THIRD_PERSON,
REPLAY,
MINIGAME_CAMERA,
IMPACT_CAMERA,
VR_CAMERA,
NO_CAMERA,
ECameraType_MAX,
};

class CameraViewComponent : private API::UObject
{
public:
using API::UObject::get_full_name;

static API::UClass *static_class()
{
static auto result =
API::get()->find_uobject<API::UClass>(L"Class /Script/Nimbus.CameraViewComponent");
return result;
}

CameraType get_current_camera_type()
{
static const auto func = static_class()->find_function(L"GetCurrentCameraViewType");
if(!func) {
API::get()->log_error("CameraViewComponent::GetCurrentCameraViewType not found");
return CameraType::NO_CAMERA;
}

struct
{
uint8_t result;
} params{.result = 0};

process_event(func, &params);

return (CameraType)params.result;
}

void switch_to_cockpit_view()
{
static const auto func = static_class()->find_function(L"SwitchToCockpitView");
if(!func) {
API::get()->log_error("CameraViewComponent::SwitchToCockpitView not found");
return;
}

struct
{
intptr_t dummy;
} params{0};

process_event(func, &params);
}

void switch_to_first_person_view()
{
static const auto func = static_class()->find_function(L"SwitchToFirstPersonView");
if(!func) {
API::get()->log_error("CameraViewComponent::SwitchToFirstPersonView not found");
return;
}

struct
{
intptr_t dummy;
} params{0};

process_event(func, &params);
}

void switch_to_third_person_view()
{
static const auto func = static_class()->find_function(L"SwitchToThirdPersonView");
if(!func) {
API::get()->log_error("CameraViewComponent::SwitchToThirdPersonView not found");
return;
}

struct
{
intptr_t dummy;
} params{0};

process_event(func, &params);
}
};
47 changes: 47 additions & 0 deletions include/acesdk/Mission.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include "uevr/API.hpp"

using namespace uevr;

class Mission : public API::UObject
{
public:
using API::UObject::get_full_name;

static API::UClass *static_class(bool force_search = false)
{
static API::UClass *result = nullptr;
if(!result || force_search) {
result = API::get()->find_uobject<API::UClass>(L"Class /Script/Nimbus.Mission");
}
return result;
}

static Mission *get_instance(bool force_search = false)
{
auto klass = static_class(force_search);
if(klass) {
return klass->get_first_object_matching<Mission>();
}
return nullptr;
}

bool is_in_igc()
{
static const auto func = Mission::static_class()->find_function(L"IsInIGC");
if(!func) {
API::get()->log_error("Mission::IsInIGC not found");
return false;
}

struct
{
bool res;
} params{0};

process_event(func, &params);

return params.res;
}
};
Loading

0 comments on commit ff72885

Please sign in to comment.